1
0
Fork 0

Make prettier format everything

This commit is contained in:
Pixelastic 2018-08-24 15:51:55 +02:00
parent a058fe7d1f
commit 1908d81854
6 changed files with 52 additions and 27 deletions

14
docs/.prettierrc.js Normal file
View file

@ -0,0 +1,14 @@
/* eslint-disable import/no-commonjs */
module.exports = {
overrides: [
{
files: '*.md',
options: {
printWidth: 80,
proseWrap: 'always',
trailingComma: 'es5',
parser: 'markdown',
},
},
],
};

View file

@ -1,5 +0,0 @@
/* eslint-disable import/no-commonjs */
module.exports = {
parser: 'markdown',
printWidth: 80,
};

View file

@ -2,7 +2,7 @@
const remarkMode = process.env.REMARK_MODE;
/**
* Linting config.
* Check the followin links for the list of all rules:
* Check the following links for the list of all rules:
* - https://github.com/remarkjs/remark-lint/tree/master/packages/remark-preset-lint-consistent
* - https://github.com/remarkjs/remark-lint/tree/master/packages/remark-preset-lint-recommended
* - https://github.com/remarkjs/remark-lint/tree/master/packages/remark-preset-lint-markdown-style-guide
@ -14,22 +14,19 @@ const lintConfig = {
'remark-preset-lint-recommended',
'preset-lint-markdown-style-guide',
// Following rules are configured to fit what prettier does
'lint-no-trailing-spaces', // No trailing spaces
['lint-emphasis-marker', '_'], // Italic with _, bold with **
['lint-list-item-spacing', false], // No need to add lines between list items
['lint-list-item-indent', 'space'], // Indent list items with one space
['lint-maximum-heading-length', 80], // Warn on heading that can be too long
['lint-maximum-line-length', 120], // Warn on lines that are too long
['lint-maximum-line-length', 80], // Warn on lines that are too long
],
};
const fixConfig = {
settings: {
emphasis: '_', // Italic with _
strong: '*', // Bold with *
listItemIndent: 1, // Indent list items with one space
},
plugins: {
frontmatter: true,
'reference-links': true,
frontmatter: true, // Frontmatter is needed to it does not choke on it
'reference-links': true, // Convert links to reference table at bottom of file
},
};

View file

@ -51,7 +51,7 @@
"postcss-clean": "^1.1.0",
"postcss-import": "^11.1.0",
"postcss-nested": "^3.0.0",
"prettier": "1.9.2",
"prettier": "^1.14.2",
"pug": "^2.0.3",
"puppeteer": "^1.6.1",
"remark-cli": "^5.0.0",

View file

@ -1,12 +1,17 @@
#!/usr/bin/env sh
# Check text content (misspelling, weasel words, offensive writing)
textlint ./*.md ./src/*.md
set -e
# Check markdown styling (links, spacing, etc)
remark \
--no-stdout \
--quiet \
--frail \
./*.md \
./src/*.md
# Check text content (misspelling, weasel words, offensive writing)
textlint \
./*.md \
./src/*.md

View file

@ -1,14 +1,28 @@
#!/usr/bin/env sh
set -e
# This will attempt to automatically fix most of the Markdown linting issues
# detected.
# REMARK_MODE=fix \
# remark \
# --quiet \
# ./src/*.md \
# --output
# We will first transform the file according to remark config. This will mostly
# convert inline links to references at the bottom of the file.
REMARK_MODE=fix \
remark \
--quiet \
./*.md \
./src/*.md \
--output
# textlint \
# --fix \
# ./src/*.md
# We then check the actual natural language content of the file, to fix
# misspellings, punctuation and other fixable issues.
textlint \
--fix \
./*.md \
./src/*.md
# Finally, we'll run everything through prettier to make sure all files are
# formatted the same way. This will remove trailing spaces, fit all content
# under 80 char long lines, etc
prettier \
--config ./.prettierrc.markdown.js
--write \
./*.md \
./src/*.md