diff --git a/docs/.prettierrc.js b/docs/.prettierrc.js new file mode 100644 index 00000000..33dca487 --- /dev/null +++ b/docs/.prettierrc.js @@ -0,0 +1,14 @@ +/* eslint-disable import/no-commonjs */ +module.exports = { + overrides: [ + { + files: '*.md', + options: { + printWidth: 80, + proseWrap: 'always', + trailingComma: 'es5', + parser: 'markdown', + }, + }, + ], +}; diff --git a/docs/.prettierrc.markdown.js b/docs/.prettierrc.markdown.js deleted file mode 100644 index 247dc093..00000000 --- a/docs/.prettierrc.markdown.js +++ /dev/null @@ -1,5 +0,0 @@ -/* eslint-disable import/no-commonjs */ -module.exports = { - parser: 'markdown', - printWidth: 80, -}; diff --git a/docs/.remarkrc.js b/docs/.remarkrc.js index ec3b4a37..ab2e03aa 100644 --- a/docs/.remarkrc.js +++ b/docs/.remarkrc.js @@ -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 }, }; diff --git a/docs/package.json b/docs/package.json index 93181974..5b8a2d43 100644 --- a/docs/package.json +++ b/docs/package.json @@ -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", diff --git a/docs/scripts/lint-md b/docs/scripts/lint-md index 82f3d953..2cf223e8 100755 --- a/docs/scripts/lint-md +++ b/docs/scripts/lint-md @@ -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 + + diff --git a/docs/scripts/lint-md-fix b/docs/scripts/lint-md-fix index 029d600d..d1421a06 100755 --- a/docs/scripts/lint-md-fix +++ b/docs/scripts/lint-md-fix @@ -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