Skip to content

Commit

Permalink
fix: detect lint errors
Browse files Browse the repository at this point in the history
The previous version had a bug where it...uh...didn't actually lint
anything. We've added a test now to at least make sure errors are
reported.

Fixes: nodejs#219
  • Loading branch information
Trott committed Aug 21, 2021
1 parent 642cab0 commit db0ddea
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
7 changes: 4 additions & 3 deletions README.md
Expand Up @@ -48,6 +48,7 @@ version numbers for the `nodejs-yaml-comments` rule.
For better compatibility with the nodejs/node changelogs, there are a few
exceptions:

- Version numbers `^0.0.0 || ^0.1.0` are not validated using the provided list,
they are validating using the `vx.x.x` pattern.
- `REPLACEME` placeholder is always valid, regardless it's in the list or not.
* Version numbers `^0.0.0 || ^0.1.0` are not validated using the provided list.
They are validated using the `vx.x.x` pattern.
* `REPLACEME` placeholder is always valid, regardless if it's in the list or
not.
6 changes: 4 additions & 2 deletions index.js
@@ -1,4 +1,4 @@
// @see https://github.com/nodejs/node/blob/master/doc/guides/doc-style-guide.md
// @see https://github.com/nodejs/node/blob/HEAD/doc/guides/doc-style-guide.md

import remarkPresetLintRecommended from "remark-preset-lint-recommended";
import remarkLintBlockquoteIndentation from "remark-lint-blockquote-indentation";
Expand Down Expand Up @@ -34,7 +34,7 @@ import remarkLintTablePipes from "remark-lint-table-pipes";
import remarkLintUnorderedListMarkerStyle from "remark-lint-unordered-list-marker-style";

// Add in rules alphabetically
const remarkPresetLintNode = [
const plugins = [
// Leave preset at the top so it can be overridden
remarkPresetLintRecommended,
[remarkLintBlockquoteIndentation, 2],
Expand Down Expand Up @@ -109,4 +109,6 @@ const remarkPresetLintNode = [
[remarkLintUnorderedListMarkerStyle, "*"],
];

const remarkPresetLintNode = { plugins };

export default remarkPresetLintNode;
5 changes: 4 additions & 1 deletion package.json
Expand Up @@ -8,7 +8,10 @@
"fix": "eslint . --fix && prettier . -w",
"lint": "eslint . && prettier . -c",
"lockfile-lint": "lockfile-lint --allowed-hosts npm --allowed-schemes https: --empty-hostname false --type npm --path package-lock.json",
"remark": "remark \"tmp/*.md\" \"tmp/doc/**/*.md\" \"tmp/lib/**/*.md\" \"tmp/benchmark/**/*.md\" \"tmp/src/**/*.md\" \"tmp/test/README.md\" \"tmp/test/[a-eg-z]*/**/*.md\" \"tmp/tools/doc/*.md\" \"tmp/tools/icu/**/*.md\" --use ./index.js --use gfm -fq",
"remark": "npm run remark-local && npm run remark-expected-failure && npm run remark-node-core",
"remark-node-core": "remark \"tmp/*.md\" \"tmp/doc/**/*.md\" \"tmp/lib/**/*.md\" \"tmp/benchmark/**/*.md\" \"tmp/src/**/*.md\" \"tmp/test/README.md\" \"tmp/test/[a-eg-z]*/**/*.md\" \"tmp/tools/doc/*.md\" \"tmp/tools/icu/**/*.md\" --use ./index.js --use gfm -fq",
"remark-local": "remark *.md --use ./index.js --use gfm -fq",
"remark-expected-failure": "! remark test/fail.md --use ./index.js --use gfm -fq || (echo \"Error: failed to detect lint problems\" && exit 1)",
"test": "npm run lint && npm run lockfile-lint && npm run remark"
},
"repository": {
Expand Down
3 changes: 3 additions & 0 deletions test/fail.md
@@ -0,0 +1,3 @@
# File that should fail

Welcome to Node!

0 comments on commit db0ddea

Please sign in to comment.