-
-
Couldn't load subscription status.
- Fork 6.4k
feat(remark-lint): add #8057
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
feat(remark-lint): add #8057
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,3 @@ | ||
| { | ||
| "settings": { | ||
| "bullet": "-", | ||
| "resourceLink": true | ||
| }, | ||
| "plugins": [ | ||
| "remark-frontmatter", | ||
| "remark-preset-lint-node", | ||
| ["remark-gfm", false], | ||
| ["remark-lint-fenced-code-flag", false], | ||
| ["remark-lint-first-heading-level", false], | ||
| ["remark-lint-maximum-line-length", false], | ||
| ["remark-lint-no-file-name-articles", false], | ||
| ["remark-lint-no-literal-urls", false], | ||
| ["remark-lint-no-unused-definitions", false], | ||
| ["remark-lint-no-undefined-references", false], | ||
| ["remark-lint-prohibited-strings", false], | ||
| ["remark-lint-unordered-list-marker-style", "-"], | ||
| ["remark-preset-lint-node/remark-lint-nodejs-links.js", false] | ||
| ] | ||
| "plugins": ["remark-frontmatter", "@node-core/remark-lint"] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "**/*.{js,mjs,ts,tsx,md,mdx}": ["prettier --check --write", "eslint --fix"], | ||
| "**/*.{json,yml}": ["prettier --check --write"] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,123 @@ | ||
| # `@node-core/remark-lint` | ||
|
|
||
| A [`remark-lint`](https://github.com/remarkjs/remark-lint) plugin with configurations tailored to the documentation and contribution standards of the [Node.js GitHub Organization](https://github.com/nodejs). | ||
|
|
||
| ## Installation | ||
|
|
||
| ```bash | ||
| npm install --save-dev @node-core/remark-lint | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
|
||
| Add the plugin to your `.remarkrc` or `remark.config.js`: | ||
|
|
||
| ```json | ||
| { | ||
| "plugins": ["@node-core/remark-lint"] | ||
| } | ||
| ``` | ||
|
|
||
| Run remark to lint your Markdown files: | ||
|
|
||
| ```bash | ||
| npx remark . --frail | ||
avivkeller marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ``` | ||
|
|
||
| ## Configuration | ||
|
|
||
| ### Released Versions | ||
|
|
||
| Some rules, such as `node-core:yaml-comments`, validate version references against known released Node.js versions. You can provide these using the `releasedVersions` option: | ||
|
|
||
| ```json | ||
| { | ||
| "plugins": [ | ||
| [ | ||
| "@node-core/remark-lint", | ||
| { | ||
| "releasedVersions": ["v18.0.0", "v18.1.0", "v18.2.0", "v20.0.0"] | ||
| } | ||
| ] | ||
| ] | ||
| } | ||
| ``` | ||
|
|
||
| For Node.js projects, these versions can be automatically generated [using `list-released-versions-from-changelogs.mjs`](https://github.com/nodejs/node/blob/main/tools/lint-md/list-released-versions-from-changelogs.mjs). | ||
|
|
||
| If not specified, version-related rules will accept any valid SemVer format. | ||
|
|
||
| ## Rules | ||
|
|
||
| ### `node-core:duplicate-stability-nodes` | ||
|
|
||
| Prevents redundant stability markers in nested sections. | ||
|
|
||
| **Not allowed:** | ||
|
|
||
| ```markdown | ||
| # Parent Section | ||
|
|
||
| > Stability: 2 - Stable | ||
|
|
||
| ## Child Section | ||
|
|
||
| > Stability: 2 - Stable <!-- Redundant! --> | ||
| ``` | ||
|
|
||
| ### `node-core:hashed-self-reference` | ||
|
|
||
| Ensures self-references use fragment-only links. | ||
|
|
||
| **Allowed:** | ||
|
|
||
| ```markdown | ||
| See the [Introduction](#introduction) section. | ||
| ``` | ||
|
|
||
| **Not allowed:** | ||
|
|
||
| ```markdown | ||
| See the [Introduction](document.md#introduction) section. | ||
| ``` | ||
|
|
||
| ### `node-core:ordered-references` | ||
|
|
||
| Enforces alphabetical sorting of reference-style link definitions. | ||
|
|
||
| **Allowed:** | ||
|
|
||
| ```markdown | ||
| [api]: https://example.com/api | ||
| [docs]: https://example.com/docs | ||
| [info]: https://example.com/info | ||
| ``` | ||
|
|
||
| ### `node-core:required-metadata` | ||
|
|
||
| Requires essential metadata for documentation: | ||
|
|
||
| - `llm_description`: A description for Large Language Models (can be inferred from first paragraph) | ||
| - `introduced_in`: API introduction version | ||
|
|
||
| Metadata can be provided in comments: | ||
|
|
||
| ```markdown | ||
| <!-- llm_description= Utilities for working with file paths --> | ||
| ``` | ||
|
|
||
| ### `node-core:yaml-comments` | ||
|
|
||
| Enforces structure and content of YAML comment blocks: | ||
|
|
||
| - `added`: An array of valid version strings | ||
| - `napiVersion`: The N-API version | ||
| - `deprecated`: An array of valid version strings | ||
| - `removed`: An array of valid version strings | ||
| - `changes`: An array of: | ||
| - `pr-url`: Pull request URL | ||
| - `commit`: Commit hash (only required for security fixes) | ||
| - `version`: Valid version string | ||
| - `description`: Change description | ||
|
|
||
| All version references must be valid SemVer, or match the provided `releasedVersions`. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import globals from 'globals'; | ||
|
|
||
| import baseConfig from '../../eslint.config.js'; | ||
|
|
||
| export default [ | ||
| ...baseConfig, | ||
| { | ||
| languageOptions: { | ||
| globals: globals.nodeBuiltin, | ||
| parserOptions: { | ||
| // Allow nullish syntax (i.e. "?." or "??"), | ||
| // and top-level await | ||
| ecmaVersion: 'latest', | ||
| }, | ||
| }, | ||
| }, | ||
| ]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| { | ||
| "name": "@node-core/remark-lint", | ||
| "type": "module", | ||
| "version": "1.0.0", | ||
| "exports": { | ||
| ".": "./src/index.mjs", | ||
| "./api": "./src/api.mjs" | ||
| }, | ||
| "scripts": { | ||
| "lint": "node --run lint:js", | ||
| "lint:fix": "node --run lint:js:fix", | ||
| "lint:js": "eslint \"**/*.mjs\"", | ||
| "lint:js:fix": "node --run lint:js -- --fix", | ||
| "test": "node --run test:unit", | ||
| "test:unit": "cross-env NODE_NO_WARNINGS=1 node --experimental-test-coverage --test \"**/*.test.mjs\"" | ||
| }, | ||
| "dependencies": { | ||
| "remark-gfm": "^4.0.1", | ||
| "remark-lint-blockquote-indentation": "^4.0.1", | ||
| "remark-lint-checkbox-character-style": "^5.0.1", | ||
| "remark-lint-checkbox-content-indent": "^5.0.1", | ||
| "remark-lint-code-block-style": "^4.0.1", | ||
| "remark-lint-definition-spacing": "^4.0.1", | ||
| "remark-lint-fenced-code-flag": "^4.2.0", | ||
| "remark-lint-fenced-code-marker": "^4.0.1", | ||
| "remark-lint-final-definition": "^4.0.2", | ||
| "remark-lint-heading-style": "^4.0.1", | ||
| "remark-lint-maximum-line-length": "^4.1.1", | ||
| "remark-lint-no-consecutive-blank-lines": "^5.0.1", | ||
| "remark-lint-no-file-name-consecutive-dashes": "^3.0.1", | ||
| "remark-lint-no-file-name-outer-dashes": "^3.0.1", | ||
| "remark-lint-no-heading-indent": "^5.0.1", | ||
| "remark-lint-no-literal-urls": "^4.0.1", | ||
| "remark-lint-no-multiple-toplevel-headings": "^4.0.1", | ||
| "remark-lint-no-shell-dollars": "^4.0.1", | ||
| "remark-lint-no-table-indentation": "^5.0.1", | ||
| "remark-lint-no-tabs": "^4.0.1", | ||
| "remark-lint-no-trailing-spaces": "^3.0.2", | ||
| "remark-lint-no-unused-definitions": "^4.0.2", | ||
| "remark-lint-prohibited-strings": "^4.0.0", | ||
| "remark-lint-rule-style": "^4.0.1", | ||
| "remark-lint-strong-marker": "^4.0.1", | ||
| "remark-lint-table-cell-padding": "^5.1.1", | ||
| "remark-lint-table-pipes": "^5.0.1", | ||
| "remark-lint-unordered-list-marker-style": "^4.0.1", | ||
| "remark-preset-lint-recommended": "^7.0.1", | ||
| "semver": "^7.7.2", | ||
| "unified-lint-rule": "^3.0.1", | ||
| "unist-util-visit": "^5.0.0", | ||
| "yaml": "^2.8.1" | ||
| }, | ||
| "devDependencies": { | ||
| "cross-env": "catalog:", | ||
| "dedent": "^1.6.0", | ||
| "globals": "^16.3.0", | ||
| "remark-parse": "^11.0.0", | ||
| "unified": "^11.0.5" | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.