diff --git a/package.json b/package.json index 20eab0a7..20a59cad 100644 --- a/package.json +++ b/package.json @@ -132,8 +132,10 @@ "remark": "^15.0.0", "remark-cli": "^12.0.0", "remark-comment-config": "^8.0.0", + "remark-directive": "^3.0.0", "remark-gfm": "^4.0.0", "remark-github": "^12.0.0", + "remark-math": "^6.0.0", "remark-mdx": "^3.0.0", "remark-toc": "^9.0.0", "remark-validate-links": "^13.0.0", diff --git a/packages/remark-lint-definition-case/index.js b/packages/remark-lint-definition-case/index.js index 5fae127a..bec81d64 100644 --- a/packages/remark-lint-definition-case/index.js +++ b/packages/remark-lint-definition-case/index.js @@ -51,6 +51,16 @@ * {"name": "not-ok.md", "label": "output"} * * 1:1-1:47: Do not use uppercase characters in definition labels + * + * @example + * {"gfm": true, "label": "input", "name": "gfm.md"} + * + * [^X]: Footnote definitions (from GFM) are checked too. + * + * @example + * {"gfm": true, "label": "output", "name": "gfm.md"} + * + * 1:1-1:55: Do not use uppercase characters in definition labels */ /** diff --git a/packages/remark-lint-definition-case/readme.md b/packages/remark-lint-definition-case/readme.md index 9ce5d1f9..4414f6c2 100644 --- a/packages/remark-lint-definition-case/readme.md +++ b/packages/remark-lint-definition-case/readme.md @@ -167,6 +167,23 @@ No messages. 1:1-1:47: Do not use uppercase characters in definition labels ``` +##### `gfm.md` + +###### In + +> 👉 **Note**: this example uses +> GFM ([`remark-gfm`][github-remark-gfm]). + +```markdown +[^X]: Footnote definitions (from GFM) are checked too. +``` + +###### Out + +```text +1:1-1:55: Do not use uppercase characters in definition labels +``` + ## Compatibility Projects maintained by the unified collective are compatible with maintained @@ -236,6 +253,8 @@ abide by its terms. [github-gist-esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c +[github-remark-gfm]: https://github.com/remarkjs/remark-gfm + [github-remark-lint]: https://github.com/remarkjs/remark-lint [github-unified-transformer]: https://github.com/unifiedjs/unified#transformer diff --git a/packages/remark-lint-definition-spacing/index.js b/packages/remark-lint-definition-spacing/index.js index 6e23bf2a..610ac1d2 100644 --- a/packages/remark-lint-definition-spacing/index.js +++ b/packages/remark-lint-definition-spacing/index.js @@ -6,6 +6,9 @@ * * This package checks the whitepsace in definition labels. * + * GFM footnotes are not affected by this rule as footnote labels cannot + * contain whitespace. + * * ## When should I use this? * * You can use this package to check that definition labels are consistent. @@ -79,7 +82,7 @@ const remarkLintDefinitionSpacing = lintRule( const value = String(file) visit(tree, function (node) { - if (node.type === 'definition' || node.type === 'footnoteDefinition') { + if (node.type === 'definition') { const end = pointEnd(node) const start = pointStart(node) diff --git a/packages/remark-lint-definition-spacing/readme.md b/packages/remark-lint-definition-spacing/readme.md index 182efd4c..3d3482f4 100644 --- a/packages/remark-lint-definition-spacing/readme.md +++ b/packages/remark-lint-definition-spacing/readme.md @@ -32,6 +32,9 @@ a definition label. This package checks the whitepsace in definition labels. +GFM footnotes are not affected by this rule as footnote labels cannot +contain whitespace. + ## When should I use this? You can use this package to check that definition labels are consistent. diff --git a/packages/remark-lint-file-extension/index.js b/packages/remark-lint-file-extension/index.js index 99f60f17..97426321 100644 --- a/packages/remark-lint-file-extension/index.js +++ b/packages/remark-lint-file-extension/index.js @@ -20,8 +20,8 @@ * * ###### Parameters * - * * `options` (`string`, default: `'md'`) - * — preferred file extension + * * `options` (`Array` or `string`, default: `['mdx', 'md']`) + * — allowed file extension(s) * * ###### Returns * @@ -50,7 +50,7 @@ * @example * {"name": "readme.mkd", "label": "output", "positionless": true} * - * 1:1: Incorrect extension: use `md` + * 1:1: Incorrect extension: use `mdx` or `md` * * @example * {"name": "readme.mkd", "config": "mkd"} @@ -61,6 +61,12 @@ */ import {lintRule} from 'unified-lint-rule' +import {quotation} from 'quotation' + +/** @type {ReadonlyArray} */ +const defaultExtensions = ['mdx', 'md'] + +const listFormat = new Intl.ListFormat('en', {type: 'disjunction'}) const remarkLintFileExtension = lintRule( { @@ -70,17 +76,22 @@ const remarkLintFileExtension = lintRule( /** * @param {Root} _ * Tree. - * @param {string | null | undefined} [options='md'] + * @param {ReadonlyArray | string | null | undefined} [options='md'] * Configuration (default: `'md'`). * @returns {undefined} * Nothing. */ function (_, file, options) { - const option = options || 'md' - const ext = file.extname + const extensions = + typeof options === 'string' ? [options] : options || defaultExtensions + const extname = file.extname + const extension = extname ? extname.slice(1) : undefined - if (ext && ext.slice(1) !== option) { - file.message('Incorrect extension: use `' + option + '`') + if (extension && !extensions.includes(extension)) { + file.message( + 'Incorrect extension: use ' + + listFormat.format(quotation(extensions, '`')) + ) } } ) diff --git a/packages/remark-lint-file-extension/package.json b/packages/remark-lint-file-extension/package.json index 8d77c699..5489d172 100644 --- a/packages/remark-lint-file-extension/package.json +++ b/packages/remark-lint-file-extension/package.json @@ -33,6 +33,7 @@ ], "dependencies": { "@types/mdast": "^4.0.0", + "quotation": "^2.0.0", "unified-lint-rule": "^2.0.0" }, "scripts": {}, diff --git a/packages/remark-lint-file-extension/readme.md b/packages/remark-lint-file-extension/readme.md index b3d20e2b..b6035b84 100644 --- a/packages/remark-lint-file-extension/readme.md +++ b/packages/remark-lint-file-extension/readme.md @@ -129,8 +129,8 @@ Warn for unexpected extensions. ###### Parameters -* `options` (`string`, default: `'md'`) - — preferred file extension +* `options` (`Array` or `string`, default: `['mdx', 'md']`) + — allowed file extension(s) ###### Returns @@ -162,7 +162,7 @@ No messages. ###### Out ```text -1:1: Incorrect extension: use `md` +1:1: Incorrect extension: use `mdx` or `md` ``` ##### `readme.mkd` diff --git a/packages/remark-lint-final-definition/index.js b/packages/remark-lint-final-definition/index.js index c4812b2d..252c140f 100644 --- a/packages/remark-lint-final-definition/index.js +++ b/packages/remark-lint-final-definition/index.js @@ -119,8 +119,6 @@ const remarkLintFinalDefinition = lintRule( definitions.push(node) } else if ( node.type === 'root' || - node.type === 'blockquote' || - node.type === 'listItem' || // Ignore HTML comments. (node.type === 'html' && /^[\t ]*