From 9b3692c519b00b17a5a8408dbaaccfc422c27596 Mon Sep 17 00:00:00 2001 From: Bryan Mishkin <698306+bmish@users.noreply.github.com> Date: Wed, 9 Nov 2022 10:03:14 -0500 Subject: [PATCH] docs: cleanup docs, add markdownlint, tweak eslint-doc-generator options --- .markdownlint.json | 9 +++ .markdownlintignore | 3 + README.md | 66 +++++++++---------- docs/rules/callback-return.md | 4 +- docs/rules/exports-style.md | 12 ++-- docs/rules/file-extension-in-import.md | 10 +-- docs/rules/handle-callback-err.md | 6 +- docs/rules/no-callback-literal.md | 4 +- docs/rules/no-deprecated-api.md | 8 +-- docs/rules/no-exports-assign.md | 2 +- docs/rules/no-extraneous-import.md | 2 +- docs/rules/no-extraneous-require.md | 2 +- docs/rules/no-hide-core-modules.md | 6 +- docs/rules/no-missing-import.md | 8 +-- docs/rules/no-missing-require.md | 6 +- docs/rules/no-mixed-requires.md | 20 +++--- docs/rules/no-process-exit.md | 2 +- docs/rules/no-unpublished-bin.md | 2 +- docs/rules/no-unpublished-import.md | 8 +-- docs/rules/no-unpublished-require.md | 6 +- docs/rules/no-unsupported-features.md | 10 +-- .../no-unsupported-features/es-builtins.md | 2 +- .../no-unsupported-features/es-syntax.md | 2 +- .../no-unsupported-features/node-builtins.md | 2 +- docs/rules/prefer-global/buffer.md | 8 +-- docs/rules/prefer-global/console.md | 8 +-- docs/rules/prefer-global/process.md | 8 +-- docs/rules/prefer-global/text-decoder.md | 8 +-- docs/rules/prefer-global/text-encoder.md | 8 +-- docs/rules/prefer-global/url-search-params.md | 8 +-- docs/rules/prefer-global/url.md | 8 +-- docs/rules/prefer-promises/dns.md | 4 +- docs/rules/prefer-promises/fs.md | 4 +- docs/rules/process-exit-as-throw.md | 2 +- docs/rules/shebang.md | 4 +- package.json | 16 +++-- 36 files changed, 150 insertions(+), 138 deletions(-) create mode 100644 .markdownlint.json create mode 100644 .markdownlintignore diff --git a/.markdownlint.json b/.markdownlint.json new file mode 100644 index 00000000..06fc90b9 --- /dev/null +++ b/.markdownlint.json @@ -0,0 +1,9 @@ +{ + "line-length": false, + "no-inline-html": { + "allowed_elements": ["details"] + }, + "ul-style": { + "style": "dash" + } +} diff --git a/.markdownlintignore b/.markdownlintignore new file mode 100644 index 00000000..bdaede90 --- /dev/null +++ b/.markdownlintignore @@ -0,0 +1,3 @@ +CHANGELOG.md +LICENSE +node_modules diff --git a/README.md b/README.md index 2d9d60d5..981670b3 100644 --- a/README.md +++ b/README.md @@ -57,43 +57,41 @@ npm install --save-dev eslint eslint-plugin-n -πŸ’Ό Configurations enabled in.\ -βœ… Set in the `recommended` configuration.\ -β˜‘οΈ Set in the `recommended-module` configuration.\ -βœ”οΈ Set in the `recommended-script` configuration.\ +πŸ’Ό [Configurations](https://github.com/eslint-community/eslint-plugin-n#-configs) enabled in.\ +βœ… Set in the `recommended` [configuration](https://github.com/eslint-community/eslint-plugin-n#-configs).\ πŸ”§ Automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--fix).\ ❌ Deprecated. ### Best Practices -| Name | Description | πŸ’Ό | πŸ”§ | ❌ | -| :--------------------------------------------------- | :----------------------- | :------ | :- | :- | -| [no-deprecated-api](docs/rules/no-deprecated-api.md) | disallow deprecated APIs | βœ… β˜‘οΈ βœ”οΈ | | | +| Name | Description | πŸ’Ό | πŸ”§ | ❌ | +| :--------------------------------------------------- | :----------------------- | :- | :- | :- | +| [no-deprecated-api](docs/rules/no-deprecated-api.md) | disallow deprecated APIs | βœ… | | | ### Possible Errors -| NameΒ Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β  | Description | πŸ’Ό | πŸ”§ | ❌ | -| :------------------------------------------------------------------------------------------- | :-------------------------------------------------------------------------- | :------ | :- | :- | -| [handle-callback-err](docs/rules/handle-callback-err.md) | require error handling in callbacks | | | | -| [no-callback-literal](docs/rules/no-callback-literal.md) | enforce Node.js-style error-first callback pattern is followed | | | | -| [no-exports-assign](docs/rules/no-exports-assign.md) | disallow the assignment to `exports` | βœ… β˜‘οΈ βœ”οΈ | | | -| [no-extraneous-import](docs/rules/no-extraneous-import.md) | disallow `import` declarations which import extraneous modules | βœ… β˜‘οΈ βœ”οΈ | | | -| [no-extraneous-require](docs/rules/no-extraneous-require.md) | disallow `require()` expressions which import extraneous modules | βœ… β˜‘οΈ βœ”οΈ | | | -| [no-hide-core-modules](docs/rules/no-hide-core-modules.md) | disallow third-party modules which are hiding core modules | | | ❌ | -| [no-missing-import](docs/rules/no-missing-import.md) | disallow `import` declarations which import non-existence modules | βœ… β˜‘οΈ βœ”οΈ | | | -| [no-missing-require](docs/rules/no-missing-require.md) | disallow `require()` expressions which import non-existence modules | βœ… β˜‘οΈ βœ”οΈ | | | -| [no-new-require](docs/rules/no-new-require.md) | disallow `new` operators with calls to `require` | | | | -| [no-path-concat](docs/rules/no-path-concat.md) | disallow string concatenation with `__dirname` and `__filename` | | | | -| [no-process-exit](docs/rules/no-process-exit.md) | disallow the use of `process.exit()` | βœ… β˜‘οΈ βœ”οΈ | | | -| [no-unpublished-bin](docs/rules/no-unpublished-bin.md) | disallow `bin` files that npm ignores | βœ… β˜‘οΈ βœ”οΈ | | | -| [no-unpublished-import](docs/rules/no-unpublished-import.md) | disallow `import` declarations which import private modules | βœ… β˜‘οΈ βœ”οΈ | | | -| [no-unpublished-require](docs/rules/no-unpublished-require.md) | disallow `require()` expressions which import private modules | βœ… β˜‘οΈ βœ”οΈ | | | -| [no-unsupported-features](docs/rules/no-unsupported-features.md) | disallow unsupported ECMAScript features on the specified version | | | ❌ | -| [no-unsupported-features/es-builtins](docs/rules/no-unsupported-features/es-builtins.md) | disallow unsupported ECMAScript built-ins on the specified version | βœ… β˜‘οΈ βœ”οΈ | | | -| [no-unsupported-features/es-syntax](docs/rules/no-unsupported-features/es-syntax.md) | disallow unsupported ECMAScript syntax on the specified version | βœ… β˜‘οΈ βœ”οΈ | | | -| [no-unsupported-features/node-builtins](docs/rules/no-unsupported-features/node-builtins.md) | disallow unsupported Node.js built-in APIs on the specified version | βœ… β˜‘οΈ βœ”οΈ | | | -| [process-exit-as-throw](docs/rules/process-exit-as-throw.md) | require that `process.exit()` expressions use the same code path as `throw` | βœ… β˜‘οΈ βœ”οΈ | | | -| [shebang](docs/rules/shebang.md) | require correct usage of shebang | βœ… β˜‘οΈ βœ”οΈ | πŸ”§ | | +| NameΒ Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β  | Description | πŸ’Ό | πŸ”§ | ❌ | +| :------------------------------------------------------------------------------------------- | :-------------------------------------------------------------------------- | :- | :- | :- | +| [handle-callback-err](docs/rules/handle-callback-err.md) | require error handling in callbacks | | | | +| [no-callback-literal](docs/rules/no-callback-literal.md) | enforce Node.js-style error-first callback pattern is followed | | | | +| [no-exports-assign](docs/rules/no-exports-assign.md) | disallow the assignment to `exports` | βœ… | | | +| [no-extraneous-import](docs/rules/no-extraneous-import.md) | disallow `import` declarations which import extraneous modules | βœ… | | | +| [no-extraneous-require](docs/rules/no-extraneous-require.md) | disallow `require()` expressions which import extraneous modules | βœ… | | | +| [no-hide-core-modules](docs/rules/no-hide-core-modules.md) | disallow third-party modules which are hiding core modules | | | ❌ | +| [no-missing-import](docs/rules/no-missing-import.md) | disallow `import` declarations which import non-existence modules | βœ… | | | +| [no-missing-require](docs/rules/no-missing-require.md) | disallow `require()` expressions which import non-existence modules | βœ… | | | +| [no-new-require](docs/rules/no-new-require.md) | disallow `new` operators with calls to `require` | | | | +| [no-path-concat](docs/rules/no-path-concat.md) | disallow string concatenation with `__dirname` and `__filename` | | | | +| [no-process-exit](docs/rules/no-process-exit.md) | disallow the use of `process.exit()` | βœ… | | | +| [no-unpublished-bin](docs/rules/no-unpublished-bin.md) | disallow `bin` files that npm ignores | βœ… | | | +| [no-unpublished-import](docs/rules/no-unpublished-import.md) | disallow `import` declarations which import private modules | βœ… | | | +| [no-unpublished-require](docs/rules/no-unpublished-require.md) | disallow `require()` expressions which import private modules | βœ… | | | +| [no-unsupported-features](docs/rules/no-unsupported-features.md) | disallow unsupported ECMAScript features on the specified version | | | ❌ | +| [no-unsupported-features/es-builtins](docs/rules/no-unsupported-features/es-builtins.md) | disallow unsupported ECMAScript built-ins on the specified version | βœ… | | | +| [no-unsupported-features/es-syntax](docs/rules/no-unsupported-features/es-syntax.md) | disallow unsupported ECMAScript syntax on the specified version | βœ… | | | +| [no-unsupported-features/node-builtins](docs/rules/no-unsupported-features/node-builtins.md) | disallow unsupported Node.js built-in APIs on the specified version | βœ… | | | +| [process-exit-as-throw](docs/rules/process-exit-as-throw.md) | require that `process.exit()` expressions use the same code path as `throw` | βœ… | | | +| [shebang](docs/rules/shebang.md) | require correct usage of shebang | βœ… | πŸ”§ | | ### Stylistic Issues @@ -124,11 +122,13 @@ npm install --save-dev eslint eslint-plugin-n This plugin provides three configs: -- `plugin:n/recommended` considers both CommonJS and ES Modules. If [`"type":"module"` field](https://medium.com/@nodejs/announcing-a-new-experimental-modules-1be8d2d6c2ff#b023) existed in package.json then it considers files as ES Modules. Otherwise it considers files as CommonJS. In addition, it considers `*.mjs` files as ES Modules and `*.cjs` files as CommonJS. -- `plugin:n/recommended-module` considers all files as ES Modules. -- `plugin:n/recommended-script` considers all files as CommonJS. +| Name | Description | +| :-- | :-- | +| `plugin:n/recommended` | Considers both CommonJS and ES Modules. If [`"type":"module"` field](https://medium.com/@nodejs/announcing-a-new-experimental-modules-1be8d2d6c2ff#b023) existed in package.json then it considers files as ES Modules. Otherwise it considers files as CommonJS. In addition, it considers `*.mjs` files as ES Modules and `*.cjs` files as CommonJS. | +| `plugin:n/recommended-module` | Considers all files as ES Modules. | +| `plugin:n/recommended-script` | Considers all files as CommonJS. | -Those preset config: +These preset configs: - enable [no-process-exit](http://eslint.org/docs/rules/no-process-exit) rule because [the official document](https://nodejs.org/api/process.html#process_process_exit_code) does not recommend a use of `process.exit()`. - enable plugin rules which are given βœ… in the above table. diff --git a/docs/rules/callback-return.md b/docs/rules/callback-return.md index 8f3ae6a1..4b91f61c 100644 --- a/docs/rules/callback-return.md +++ b/docs/rules/callback-return.md @@ -102,8 +102,8 @@ function bar(err, send) { Because it is difficult to understand the meaning of a program through static analysis, this rule has limitations: -* *false negatives* when this rule reports correct code, but the program calls the callback more than one time (which is incorrect behavior) -* *false positives* when this rule reports incorrect code, but the program calls the callback only one time (which is correct behavior) +- *false negatives* when this rule reports correct code, but the program calls the callback more than one time (which is incorrect behavior) +- *false positives* when this rule reports incorrect code, but the program calls the callback only one time (which is correct behavior) #### Passing the callback by reference diff --git a/docs/rules/exports-style.md b/docs/rules/exports-style.md index cf164d1a..2cec56e6 100644 --- a/docs/rules/exports-style.md +++ b/docs/rules/exports-style.md @@ -21,7 +21,7 @@ In this case, `exports.bar` will be lost since only the instance of `module.expo This rule enforces the export style. -If you use `module.exports`, this rule disallows `exports`.
+If you use `module.exports`, this rule disallows `exports`.\ If you use `exports`, this rule disallows `module.exports`. You can select it by an option. @@ -48,7 +48,7 @@ This rule has a string option. #### module.exports -Examples of :-1: **incorrect** code for the `"module.exports"` option: +Examples of πŸ‘Ž **incorrect** code for the `"module.exports"` option: ```js /*eslint n/exports-style: ["error", "module.exports"]*/ @@ -57,7 +57,7 @@ exports.foo = 1 exports.bar = 2 ``` -Examples of :+1: **correct** code for the `"module.exports"` option: +Examples of πŸ‘ **correct** code for the `"module.exports"` option: ```js /*eslint n/exports-style: ["error", "module.exports"]*/ @@ -72,7 +72,7 @@ module.exports.baz = 3 #### exports -Examples of :-1: **incorrect** code for the `"exports"` option: +Examples of πŸ‘Ž **incorrect** code for the `"exports"` option: ```js /*eslint n/exports-style: ["error", "exports"]*/ @@ -85,7 +85,7 @@ module.exports = { module.exports.baz = 3 ``` -Examples of :+1: **correct** code for the `"exports"` option: +Examples of πŸ‘ **correct** code for the `"exports"` option: ```js /*eslint n/exports-style: ["error", "exports"]*/ @@ -96,7 +96,7 @@ exports.bar = 2 #### allowBatchAssign -Examples of :+1: **correct** code for the `"exports"` and `{"allowBatchAssign": true}` option: +Examples of πŸ‘ **correct** code for the `"exports"` and `{"allowBatchAssign": true}` option: ```js /*eslint n/exports-style: ["error", "exports", {"allowBatchAssign": true}]*/ diff --git a/docs/rules/file-extension-in-import.md b/docs/rules/file-extension-in-import.md index 6d76e420..031c2777 100644 --- a/docs/rules/file-extension-in-import.md +++ b/docs/rules/file-extension-in-import.md @@ -41,7 +41,7 @@ This rule has a string option and an object option. #### always -Examples of :-1: **incorrect** code for the `"always"` option: +Examples of πŸ‘Ž **incorrect** code for the `"always"` option: ```js /*eslint n/file-extension-in-import: ["error", "always"]*/ @@ -49,7 +49,7 @@ Examples of :-1: **incorrect** code for the `"always"` option: import foo from "./path/to/a/file" ``` -Examples of :+1: **correct** code for the `"always"` option: +Examples of πŸ‘ **correct** code for the `"always"` option: ```js /*eslint n/file-extension-in-import: ["error", "always"]*/ @@ -60,7 +60,7 @@ import foo from "./path/to/a/file.js" #### never -Examples of :-1: **incorrect** code for the `"never"` option: +Examples of πŸ‘Ž **incorrect** code for the `"never"` option: ```js /*eslint n/file-extension-in-import: ["error", "never"]*/ @@ -68,7 +68,7 @@ Examples of :-1: **incorrect** code for the `"never"` option: import foo from "./path/to/a/file.js" ``` -Examples of :+1: **correct** code for the `"never"` option: +Examples of πŸ‘ **correct** code for the `"never"` option: ```js /*eslint n/file-extension-in-import: ["error", "never"]*/ @@ -79,7 +79,7 @@ import foo from "./path/to/a/file" #### .xxx -Examples of :+1: **correct** code for the `["always", { ".js": "never" }]` option: +Examples of πŸ‘ **correct** code for the `["always", { ".js": "never" }]` option: ```js /*eslint n/file-extension-in-import: ["error", "always", { ".js": "never" }]*/ diff --git a/docs/rules/handle-callback-err.md b/docs/rules/handle-callback-err.md index a646f6ac..b30b45fc 100644 --- a/docs/rules/handle-callback-err.md +++ b/docs/rules/handle-callback-err.md @@ -68,9 +68,9 @@ so you need a more flexible configuration to ensure that the rule reports all un If the configured name of the error variable begins with a `^` it is considered to be a regexp pattern. -* If the option is `"^(err|error|anySpecificError)$"`, the rule reports unhandled errors where the parameter name can be `err`, `error` or `anySpecificError`. -* If the option is `"^.+Error$"`, the rule reports unhandled errors where the parameter name ends with `Error` (for example, `connectionError` or `validationError` will match). -* If the option is `"^.*(e|E)rr"`, the rule reports unhandled errors where the parameter name matches any string that contains `err` or `Err` (for example, `err`, `error`, `anyError`, `some_err` will match). +- If the option is `"^(err|error|anySpecificError)$"`, the rule reports unhandled errors where the parameter name can be `err`, `error` or `anySpecificError`. +- If the option is `"^.+Error$"`, the rule reports unhandled errors where the parameter name ends with `Error` (for example, `connectionError` or `validationError` will match). +- If the option is `"^.*(e|E)rr"`, the rule reports unhandled errors where the parameter name matches any string that contains `err` or `Err` (for example, `err`, `error`, `anyError`, `some_err` will match). ## πŸ”Ž Implementation diff --git a/docs/rules/no-callback-literal.md b/docs/rules/no-callback-literal.md index 63654213..3515ba8f 100644 --- a/docs/rules/no-callback-literal.md +++ b/docs/rules/no-callback-literal.md @@ -8,7 +8,7 @@ When invoking a callback function which uses the Node.js error-first callback pa When a function is named `cb` or `callback`, then it must be invoked with a first argument that is `undefined`, `null`, an `Error` class, or a subclass or `Error`. -Examples of :-1: **incorrect** code for this rule: +Examples of πŸ‘Ž **incorrect** code for this rule: ```js /*eslint n/no-callback-literal: "error" */ @@ -18,7 +18,7 @@ cb({ a: 1 }); callback(0); ``` -Examples of :+1: **correct** code for this rule: +Examples of πŸ‘ **correct** code for this rule: ```js /*eslint n/no-callback-literal: "error" */ diff --git a/docs/rules/no-deprecated-api.md b/docs/rules/no-deprecated-api.md index f6b8b1aa..40b45072 100644 --- a/docs/rules/no-deprecated-api.md +++ b/docs/rules/no-deprecated-api.md @@ -1,6 +1,6 @@ # Disallow deprecated APIs (`n/no-deprecated-api`) -πŸ’Ό This rule is enabled in the following configs: βœ… `recommended`, β˜‘οΈ `recommended-module`, βœ”οΈ `recommended-script`. +πŸ’Ό This rule is enabled in the βœ… `recommended` [config](https://github.com/eslint-community/eslint-plugin-n#-configs). @@ -9,7 +9,7 @@ The community is going to remove those API from Node in future, so we should not ## πŸ“– Rule Details -Examples of :-1: **incorrect** code for this rule: +Examples of πŸ‘Ž **incorrect** code for this rule: ```js /*eslint n/no-deprecated-api: "error" */ @@ -272,7 +272,7 @@ This option can include the following values: - `util._extend` - `vm.runInDebugContext` -Examples of :+1: **correct** code for the `{"ignoreModuleItems": ["new buffer.Buffer()"]}`: +Examples of πŸ‘ **correct** code for the `{"ignoreModuleItems": ["new buffer.Buffer()"]}`: ```js /*eslint n/no-deprecated-api: [error, {ignoreModuleItems: ["new buffer.Buffer()"]}] */ @@ -304,7 +304,7 @@ This option can include the following values: - `process.binding` - `process.env.NODE_REPL_HISTORY_FILE` -Examples of :+1: **correct** code for the `{"ignoreGlobalItems": ["new Buffer()"]}`: +Examples of πŸ‘ **correct** code for the `{"ignoreGlobalItems": ["new Buffer()"]}`: ```js /*eslint n/no-deprecated-api: [error, {ignoreGlobalItems: ["new Buffer()"]}] */ diff --git a/docs/rules/no-exports-assign.md b/docs/rules/no-exports-assign.md index 0bb10bb1..891e1ebb 100644 --- a/docs/rules/no-exports-assign.md +++ b/docs/rules/no-exports-assign.md @@ -1,6 +1,6 @@ # Disallow the assignment to `exports` (`n/no-exports-assign`) -πŸ’Ό This rule is enabled in the following configs: βœ… `recommended`, β˜‘οΈ `recommended-module`, βœ”οΈ `recommended-script`. +πŸ’Ό This rule is enabled in the βœ… `recommended` [config](https://github.com/eslint-community/eslint-plugin-n#-configs). diff --git a/docs/rules/no-extraneous-import.md b/docs/rules/no-extraneous-import.md index 875fad25..c8b6f768 100644 --- a/docs/rules/no-extraneous-import.md +++ b/docs/rules/no-extraneous-import.md @@ -1,6 +1,6 @@ # Disallow `import` declarations which import extraneous modules (`n/no-extraneous-import`) -πŸ’Ό This rule is enabled in the following configs: βœ… `recommended`, β˜‘οΈ `recommended-module`, βœ”οΈ `recommended-script`. +πŸ’Ό This rule is enabled in the βœ… `recommended` [config](https://github.com/eslint-community/eslint-plugin-n#-configs). diff --git a/docs/rules/no-extraneous-require.md b/docs/rules/no-extraneous-require.md index d63212d1..5e7a1e0f 100644 --- a/docs/rules/no-extraneous-require.md +++ b/docs/rules/no-extraneous-require.md @@ -1,6 +1,6 @@ # Disallow `require()` expressions which import extraneous modules (`n/no-extraneous-require`) -πŸ’Ό This rule is enabled in the following configs: βœ… `recommended`, β˜‘οΈ `recommended-module`, βœ”οΈ `recommended-script`. +πŸ’Ό This rule is enabled in the βœ… `recommended` [config](https://github.com/eslint-community/eslint-plugin-n#-configs). diff --git a/docs/rules/no-hide-core-modules.md b/docs/rules/no-hide-core-modules.md index a00f6c1a..24a43fcf 100644 --- a/docs/rules/no-hide-core-modules.md +++ b/docs/rules/no-hide-core-modules.md @@ -4,7 +4,7 @@ -**:warning: This is deprecated since v4.2.0.** This rule was based on an invalid assumption. See also [#69](https://github.com/mysticatea/eslint-plugin-node/issues/69). +**⚠️ This is deprecated since v4.2.0.** This rule was based on an invalid assumption. See also [#69](https://github.com/mysticatea/eslint-plugin-node/issues/69). If you have dependencies which have the same name as core modules, your module would use the third-party modules instead of core modules. Especially, if you depends on such modules indirectly and npm flattens dependencies, you can depend on such third-party modules before as you know it. @@ -14,7 +14,7 @@ This rule warns `require()` expressions and `import` declarations if those impor ## πŸ“– Rule Details -:-1: Examples of **incorrect** code for this rule: +πŸ‘Ž Examples of **incorrect** code for this rule: ```js /*eslint n/no-hide-core-modules: "error"*/ @@ -24,7 +24,7 @@ const path = require("path") // ERROR if `path` module exists in node_modules d // ... ``` -:+1: Examples of **correct** code for this rule: +πŸ‘ Examples of **correct** code for this rule: ```js /*eslint n/no-hide-core-modules: "error"*/ diff --git a/docs/rules/no-missing-import.md b/docs/rules/no-missing-import.md index b84d7463..3e9bd7ac 100644 --- a/docs/rules/no-missing-import.md +++ b/docs/rules/no-missing-import.md @@ -1,19 +1,19 @@ # Disallow `import` declarations which import non-existence modules (`n/no-missing-import`) -πŸ’Ό This rule is enabled in the following configs: βœ… `recommended`, β˜‘οΈ `recommended-module`, βœ”οΈ `recommended-script`. +πŸ’Ό This rule is enabled in the βœ… `recommended` [config](https://github.com/eslint-community/eslint-plugin-n#-configs). This is similar to [no-missing-require](no-missing-require.md), but this rule handles `import` and `export` declarations. -:warning: ECMAScript 2015 (ES6) does not define the lookup logic and Node does not support modules yet. So this rule spec might be changed in future. +⚠️ ECMAScript 2015 (ES6) does not define the lookup logic and Node does not support modules yet. So this rule spec might be changed in future. ## πŸ“– Rule Details This rule checks the file paths of `import` and `export` declarations. If the file paths don't exist, this reports these. -Examples of :-1: **incorrect** code for this rule: +Examples of πŸ‘Ž **incorrect** code for this rule: ```js /*eslint n/no-missing-import: "error" */ @@ -22,7 +22,7 @@ import typoFile from "./typo-file"; /*ERROR: "./typo-file" is not found.*/ import typoModule from "typo-module"; /*ERROR: "typo-module" is not found.*/ ``` -Examples of :+1: **correct** code for this rule: +Examples of πŸ‘ **correct** code for this rule: ```js /*eslint n/no-missing-import: "error" */ diff --git a/docs/rules/no-missing-require.md b/docs/rules/no-missing-require.md index 9b87d5c3..96822d5f 100644 --- a/docs/rules/no-missing-require.md +++ b/docs/rules/no-missing-require.md @@ -1,6 +1,6 @@ # Disallow `require()` expressions which import non-existence modules (`n/no-missing-require`) -πŸ’Ό This rule is enabled in the following configs: βœ… `recommended`, β˜‘οΈ `recommended-module`, βœ”οΈ `recommended-script`. +πŸ’Ό This rule is enabled in the βœ… `recommended` [config](https://github.com/eslint-community/eslint-plugin-n#-configs). @@ -15,7 +15,7 @@ const foo = require("./foo"); This rule checks the file paths of `require()`s, then reports the path of files which don't exist. -Examples of :-1: **incorrect** code for this rule: +Examples of πŸ‘Ž **incorrect** code for this rule: ```js /*eslint n/no-missing-require: "error" */ @@ -24,7 +24,7 @@ var typoFile = require("./typo-file"); /*error "./typo-file" is not found.*/ var typoModule = require("typo-module"); /*error "typo-module" is not found.*/ ``` -Examples of :+1: **correct** code for this rule: +Examples of πŸ‘ **correct** code for this rule: ```js /*eslint n/no-missing-require: "error" */ diff --git a/docs/rules/no-mixed-requires.md b/docs/rules/no-mixed-requires.md index e36b35c9..db8bf41c 100644 --- a/docs/rules/no-mixed-requires.md +++ b/docs/rules/no-mixed-requires.md @@ -8,17 +8,17 @@ In the Node.js community it is often customary to separate initializations with When this rule is enabled, each `var` statement must satisfy the following conditions: -* either none or all variable declarations must be require declarations (default) -* all require declarations must be of the same type (grouping) +- either none or all variable declarations must be require declarations (default) +- all require declarations must be of the same type (grouping) This rule distinguishes between six kinds of variable declaration types: -* `core`: declaration of a required [core module][1] -* `file`: declaration of a required [file module][2] -* `module`: declaration of a required module from the [node_modules folder][3] -* `computed`: declaration of a required module whose type could not be determined (either because it is computed or because require was called without an argument) -* `uninitialized`: a declaration that is not initialized -* `other`: any other kind of declaration +- `core`: declaration of a required +- `file`: declaration of a required +- `module`: declaration of a required module from the +- `computed`: declaration of a required module whose type could not be determined (either because it is computed or because require was called without an argument) +- `uninitialized`: a declaration that is not initialized +- `other`: any other kind of declaration In this document, the first four types are summed up under the term *require declaration*. @@ -111,9 +111,9 @@ var async = require('async'), ### Known Limitations -* The implementation is not aware of any local functions with the name `require` that may shadow Node.js' global `require`. +- The implementation is not aware of any local functions with the name `require` that may shadow Node.js' global `require`. -* Internally, the list of core modules is retrieved via `require("repl")._builtinLibs`. If you use different versions of Node.js for ESLint and your application, the list of core modules for each version may be different. +- Internally, the list of core modules is retrieved via `require("repl")._builtinLibs`. If you use different versions of Node.js for ESLint and your application, the list of core modules for each version may be different. The above mentioned `_builtinLibs` property became available in 0.8, for earlier versions a hardcoded list of module names is used as a fallback. If your version of Node.js is older than 0.6 that list may be inaccurate. ## πŸ”Ž Implementation diff --git a/docs/rules/no-process-exit.md b/docs/rules/no-process-exit.md index 07ad8c4b..c00cfa74 100644 --- a/docs/rules/no-process-exit.md +++ b/docs/rules/no-process-exit.md @@ -1,6 +1,6 @@ # Disallow the use of `process.exit()` (`n/no-process-exit`) -πŸ’Ό This rule is enabled in the following configs: βœ… `recommended`, β˜‘οΈ `recommended-module`, βœ”οΈ `recommended-script`. +πŸ’Ό This rule is enabled in the βœ… `recommended` [config](https://github.com/eslint-community/eslint-plugin-n#-configs). diff --git a/docs/rules/no-unpublished-bin.md b/docs/rules/no-unpublished-bin.md index 2f413103..4288b480 100644 --- a/docs/rules/no-unpublished-bin.md +++ b/docs/rules/no-unpublished-bin.md @@ -1,6 +1,6 @@ # Disallow `bin` files that npm ignores (`n/no-unpublished-bin`) -πŸ’Ό This rule is enabled in the following configs: βœ… `recommended`, β˜‘οΈ `recommended-module`, βœ”οΈ `recommended-script`. +πŸ’Ό This rule is enabled in the βœ… `recommended` [config](https://github.com/eslint-community/eslint-plugin-n#-configs). diff --git a/docs/rules/no-unpublished-import.md b/docs/rules/no-unpublished-import.md index a33419b0..3507a9fb 100644 --- a/docs/rules/no-unpublished-import.md +++ b/docs/rules/no-unpublished-import.md @@ -1,12 +1,12 @@ # Disallow `import` declarations which import private modules (`n/no-unpublished-import`) -πŸ’Ό This rule is enabled in the following configs: βœ… `recommended`, β˜‘οΈ `recommended-module`, βœ”οΈ `recommended-script`. +πŸ’Ό This rule is enabled in the βœ… `recommended` [config](https://github.com/eslint-community/eslint-plugin-n#-configs). This is similar to [no-unpublished-require](no-unpublished-require.md), but this rule handles `import` declarations. -:warning: ECMAScript 2015 (ES6) does not define the lookup logic and Node does not support modules yet. So this rule spec might be changed in future. +⚠️ ECMAScript 2015 (ES6) does not define the lookup logic and Node does not support modules yet. So this rule spec might be changed in future. ## πŸ“– Rule Details @@ -17,8 +17,8 @@ If a source code file satisfies all of the following conditions, the file is \*p Then this rule warns `import` declarations in \*published\* files if the `import` declaration imports \*unpublished\* files or the packages of `devDependencies`. -> This intends to prevent "Module Not Found" error after `npm publish`.
-> :bulb: If you want to import `devDependencies`, please write `.npmignore` or `"files"` field of `package.json`. +> This intends to prevent "Module Not Found" error after `npm publish`.\ +> πŸ’‘ If you want to import `devDependencies`, please write `.npmignore` or `"files"` field of `package.json`. ### Options diff --git a/docs/rules/no-unpublished-require.md b/docs/rules/no-unpublished-require.md index bfe1bf61..84615ee8 100644 --- a/docs/rules/no-unpublished-require.md +++ b/docs/rules/no-unpublished-require.md @@ -1,6 +1,6 @@ # Disallow `require()` expressions which import private modules (`n/no-unpublished-require`) -πŸ’Ό This rule is enabled in the following configs: βœ… `recommended`, β˜‘οΈ `recommended-module`, βœ”οΈ `recommended-script`. +πŸ’Ό This rule is enabled in the βœ… `recommended` [config](https://github.com/eslint-community/eslint-plugin-n#-configs). @@ -16,8 +16,8 @@ If a source code file satisfies all of the following conditions, the file is \*p Then this rule warns `require()` expressions in \*published\* files if the `require()` expression imports \*unpublished\* files or the packages of `devDependencies`. -> This intends to prevent "Module Not Found" error after `npm publish`.
-> :bulb: If you want to import `devDependencies`, please write `.npmignore` or `"files"` field of `package.json`. +> This intends to prevent "Module Not Found" error after `npm publish`.\ +> πŸ’‘ If you want to import `devDependencies`, please write `.npmignore` or `"files"` field of `package.json`. ### Options diff --git a/docs/rules/no-unsupported-features.md b/docs/rules/no-unsupported-features.md index ad6d00e3..95061279 100644 --- a/docs/rules/no-unsupported-features.md +++ b/docs/rules/no-unsupported-features.md @@ -12,7 +12,7 @@ This rule reports when you used unsupported ECMAScript 2015-2018 features on the ## πŸ“– Rule Details -:warning: This rule expects to be used with the following configuration: +⚠️ This rule expects to be used with the following configuration: ```json { @@ -21,7 +21,7 @@ This rule reports when you used unsupported ECMAScript 2015-2018 features on the } ``` -:warning: This rule reads the [engines] field of `package.json` to detect Node.js version. +⚠️ This rule reads the [engines] field of `package.json` to detect Node.js version. I recommend a use of the [engines] field since it's the official way to indicate what Node.js versions your module is supporting. For example of `package.json`: @@ -38,7 +38,7 @@ For example of `package.json`: If the [engines] field is omitted, this rule chooses `4` since it's the minimum version the community is maintaining. -Examples of :-1: **incorrect** code for this rule: +Examples of πŸ‘Ž **incorrect** code for this rule: ```js /*eslint n/no-unsupported-features: ["error", {version: 4}]*/ @@ -73,7 +73,7 @@ var p = new Proxy(o, { /*error Proxy is not supported yet on Node v4.*/ }); ``` -Examples of :+1: **correct** code for this rule: +Examples of πŸ‘ **correct** code for this rule: ```js /*eslint n/no-unsupported-features: ["error", {version: 4}]*/ @@ -280,7 +280,7 @@ The `"ignores"` option accepts an array of the following strings. If a group value is given, all sub items of the value are ignored. e.g. if `"String.*"` is given then `"String.raw"` and `"String.fromCodePoint"` are ignored. -Examples of :+1: **correct** code for the `"ignores"` option: +Examples of πŸ‘ **correct** code for the `"ignores"` option: ```js /*eslint n/no-unsupported-features: ["error", {version: 4, ignores: ["defaultParameters"]}]*/ diff --git a/docs/rules/no-unsupported-features/es-builtins.md b/docs/rules/no-unsupported-features/es-builtins.md index b6699512..ac2cf3ec 100644 --- a/docs/rules/no-unsupported-features/es-builtins.md +++ b/docs/rules/no-unsupported-features/es-builtins.md @@ -1,6 +1,6 @@ # Disallow unsupported ECMAScript built-ins on the specified version (`n/no-unsupported-features/es-builtins`) -πŸ’Ό This rule is enabled in the following configs: βœ… `recommended`, β˜‘οΈ `recommended-module`, βœ”οΈ `recommended-script`. +πŸ’Ό This rule is enabled in the βœ… `recommended` [config](https://github.com/eslint-community/eslint-plugin-n#-configs). diff --git a/docs/rules/no-unsupported-features/es-syntax.md b/docs/rules/no-unsupported-features/es-syntax.md index 24f6b75d..cc7e5d0c 100644 --- a/docs/rules/no-unsupported-features/es-syntax.md +++ b/docs/rules/no-unsupported-features/es-syntax.md @@ -1,6 +1,6 @@ # Disallow unsupported ECMAScript syntax on the specified version (`n/no-unsupported-features/es-syntax`) -πŸ’Ό This rule is enabled in the following configs: βœ… `recommended`, β˜‘οΈ `recommended-module`, βœ”οΈ `recommended-script`. +πŸ’Ό This rule is enabled in the βœ… `recommended` [config](https://github.com/eslint-community/eslint-plugin-n#-configs). diff --git a/docs/rules/no-unsupported-features/node-builtins.md b/docs/rules/no-unsupported-features/node-builtins.md index 0b4e6b91..3f091570 100644 --- a/docs/rules/no-unsupported-features/node-builtins.md +++ b/docs/rules/no-unsupported-features/node-builtins.md @@ -1,6 +1,6 @@ # Disallow unsupported Node.js built-in APIs on the specified version (`n/no-unsupported-features/node-builtins`) -πŸ’Ό This rule is enabled in the following configs: βœ… `recommended`, β˜‘οΈ `recommended-module`, βœ”οΈ `recommended-script`. +πŸ’Ό This rule is enabled in the βœ… `recommended` [config](https://github.com/eslint-community/eslint-plugin-n#-configs). diff --git a/docs/rules/prefer-global/buffer.md b/docs/rules/prefer-global/buffer.md index b4c91584..8acd7417 100644 --- a/docs/rules/prefer-global/buffer.md +++ b/docs/rules/prefer-global/buffer.md @@ -29,7 +29,7 @@ This rule has a string option. #### always -Examples of :-1: **incorrect** code for this rule: +Examples of πŸ‘Ž **incorrect** code for this rule: ```js /*eslint n/prefer-global/buffer: [error]*/ @@ -38,7 +38,7 @@ const { Buffer } = require("buffer") const b = Buffer.alloc(16) ``` -Examples of :+1: **correct** code for this rule: +Examples of πŸ‘ **correct** code for this rule: ```js /*eslint n/prefer-global/buffer: [error]*/ @@ -48,7 +48,7 @@ const b = Buffer.alloc(16) #### never -Examples of :-1: **incorrect** code for the `"never"` option: +Examples of πŸ‘Ž **incorrect** code for the `"never"` option: ```js /*eslint n/prefer-global/buffer: [error, never]*/ @@ -56,7 +56,7 @@ Examples of :-1: **incorrect** code for the `"never"` option: const b = Buffer.alloc(16) ``` -Examples of :+1: **correct** code for the `"never"` option: +Examples of πŸ‘ **correct** code for the `"never"` option: ```js /*eslint n/prefer-global/buffer: [error, never]*/ diff --git a/docs/rules/prefer-global/console.md b/docs/rules/prefer-global/console.md index e4779fdc..f14fd6c9 100644 --- a/docs/rules/prefer-global/console.md +++ b/docs/rules/prefer-global/console.md @@ -29,7 +29,7 @@ This rule has a string option. #### always -Examples of :-1: **incorrect** code for this rule: +Examples of πŸ‘Ž **incorrect** code for this rule: ```js /*eslint n/prefer-global/console: [error]*/ @@ -38,7 +38,7 @@ const console = require("console") console.log("hello") ``` -Examples of :+1: **correct** code for this rule: +Examples of πŸ‘ **correct** code for this rule: ```js /*eslint n/prefer-global/console: [error]*/ @@ -48,7 +48,7 @@ console.log("hello") #### never -Examples of :-1: **incorrect** code for the `"never"` option: +Examples of πŸ‘Ž **incorrect** code for the `"never"` option: ```js /*eslint n/prefer-global/console: [error, never]*/ @@ -56,7 +56,7 @@ Examples of :-1: **incorrect** code for the `"never"` option: console.log("hello") ``` -Examples of :+1: **correct** code for the `"never"` option: +Examples of πŸ‘ **correct** code for the `"never"` option: ```js /*eslint n/prefer-global/console: [error, never]*/ diff --git a/docs/rules/prefer-global/process.md b/docs/rules/prefer-global/process.md index 8a46dd1d..d99e27f5 100644 --- a/docs/rules/prefer-global/process.md +++ b/docs/rules/prefer-global/process.md @@ -29,7 +29,7 @@ This rule has a string option. #### always -Examples of :-1: **incorrect** code for this rule: +Examples of πŸ‘Ž **incorrect** code for this rule: ```js /*eslint n/prefer-global/process: [error]*/ @@ -38,7 +38,7 @@ const process = require("process") process.exit(0) ``` -Examples of :+1: **correct** code for this rule: +Examples of πŸ‘ **correct** code for this rule: ```js /*eslint n/prefer-global/process: [error]*/ @@ -48,7 +48,7 @@ process.exit(0) #### never -Examples of :-1: **incorrect** code for the `"never"` option: +Examples of πŸ‘Ž **incorrect** code for the `"never"` option: ```js /*eslint n/prefer-global/process: [error, never]*/ @@ -56,7 +56,7 @@ Examples of :-1: **incorrect** code for the `"never"` option: process.exit(0) ``` -Examples of :+1: **correct** code for the `"never"` option: +Examples of πŸ‘ **correct** code for the `"never"` option: ```js /*eslint n/prefer-global/process: [error, never]*/ diff --git a/docs/rules/prefer-global/text-decoder.md b/docs/rules/prefer-global/text-decoder.md index 40cc8728..eeb52306 100644 --- a/docs/rules/prefer-global/text-decoder.md +++ b/docs/rules/prefer-global/text-decoder.md @@ -29,7 +29,7 @@ This rule has a string option. #### always -Examples of :-1: **incorrect** code for this rule: +Examples of πŸ‘Ž **incorrect** code for this rule: ```js /*eslint n/prefer-global/text-decoder: [error]*/ @@ -38,7 +38,7 @@ const { TextDecoder } = require("util") const u = new TextDecoder(s) ``` -Examples of :+1: **correct** code for this rule: +Examples of πŸ‘ **correct** code for this rule: ```js /*eslint n/prefer-global/text-decoder: [error]*/ @@ -48,7 +48,7 @@ const u = new TextDecoder(s) #### never -Examples of :-1: **incorrect** code for the `"never"` option: +Examples of πŸ‘Ž **incorrect** code for the `"never"` option: ```js /*eslint n/prefer-global/text-decoder: [error, never]*/ @@ -56,7 +56,7 @@ Examples of :-1: **incorrect** code for the `"never"` option: const u = new TextDecoder(s) ``` -Examples of :+1: **correct** code for the `"never"` option: +Examples of πŸ‘ **correct** code for the `"never"` option: ```js /*eslint n/prefer-global/text-decoder: [error, never]*/ diff --git a/docs/rules/prefer-global/text-encoder.md b/docs/rules/prefer-global/text-encoder.md index 5432f56c..371f9b3e 100644 --- a/docs/rules/prefer-global/text-encoder.md +++ b/docs/rules/prefer-global/text-encoder.md @@ -29,7 +29,7 @@ This rule has a string option. #### always -Examples of :-1: **incorrect** code for this rule: +Examples of πŸ‘Ž **incorrect** code for this rule: ```js /*eslint n/prefer-global/text-encoder: [error]*/ @@ -38,7 +38,7 @@ const { TextEncoder } = require("util") const u = new TextEncoder(s) ``` -Examples of :+1: **correct** code for this rule: +Examples of πŸ‘ **correct** code for this rule: ```js /*eslint n/prefer-global/text-encoder: [error]*/ @@ -48,7 +48,7 @@ const u = new TextEncoder(s) #### never -Examples of :-1: **incorrect** code for the `"never"` option: +Examples of πŸ‘Ž **incorrect** code for the `"never"` option: ```js /*eslint n/prefer-global/text-encoder: [error, never]*/ @@ -56,7 +56,7 @@ Examples of :-1: **incorrect** code for the `"never"` option: const u = new TextEncoder(s) ``` -Examples of :+1: **correct** code for the `"never"` option: +Examples of πŸ‘ **correct** code for the `"never"` option: ```js /*eslint n/prefer-global/text-encoder: [error, never]*/ diff --git a/docs/rules/prefer-global/url-search-params.md b/docs/rules/prefer-global/url-search-params.md index b0758c52..e2ff4b17 100644 --- a/docs/rules/prefer-global/url-search-params.md +++ b/docs/rules/prefer-global/url-search-params.md @@ -29,7 +29,7 @@ This rule has a string option. #### always -Examples of :-1: **incorrect** code for this rule: +Examples of πŸ‘Ž **incorrect** code for this rule: ```js /*eslint n/prefer-global/url-search-params: [error]*/ @@ -38,7 +38,7 @@ const { URLSearchParams } = require("url") const u = new URLSearchParams(s) ``` -Examples of :+1: **correct** code for this rule: +Examples of πŸ‘ **correct** code for this rule: ```js /*eslint n/prefer-global/url-search-params: [error]*/ @@ -48,7 +48,7 @@ const u = new URLSearchParams(s) #### never -Examples of :-1: **incorrect** code for the `"never"` option: +Examples of πŸ‘Ž **incorrect** code for the `"never"` option: ```js /*eslint n/prefer-global/url-search-params: [error, never]*/ @@ -56,7 +56,7 @@ Examples of :-1: **incorrect** code for the `"never"` option: const u = new URLSearchParams(s) ``` -Examples of :+1: **correct** code for the `"never"` option: +Examples of πŸ‘ **correct** code for the `"never"` option: ```js /*eslint n/prefer-global/url-search-params: [error, never]*/ diff --git a/docs/rules/prefer-global/url.md b/docs/rules/prefer-global/url.md index 33ff2a51..a38ab8f6 100644 --- a/docs/rules/prefer-global/url.md +++ b/docs/rules/prefer-global/url.md @@ -29,7 +29,7 @@ This rule has a string option. #### always -Examples of :-1: **incorrect** code for this rule: +Examples of πŸ‘Ž **incorrect** code for this rule: ```js /*eslint n/prefer-global/url: [error]*/ @@ -38,7 +38,7 @@ const { URL } = require("url") const u = new URL(s) ``` -Examples of :+1: **correct** code for this rule: +Examples of πŸ‘ **correct** code for this rule: ```js /*eslint n/prefer-global/url: [error]*/ @@ -48,7 +48,7 @@ const u = new URL(s) #### never -Examples of :-1: **incorrect** code for the `"never"` option: +Examples of πŸ‘Ž **incorrect** code for the `"never"` option: ```js /*eslint n/prefer-global/url: [error, never]*/ @@ -56,7 +56,7 @@ Examples of :-1: **incorrect** code for the `"never"` option: const u = new URL(s) ``` -Examples of :+1: **correct** code for the `"never"` option: +Examples of πŸ‘ **correct** code for the `"never"` option: ```js /*eslint n/prefer-global/url: [error, never]*/ diff --git a/docs/rules/prefer-promises/dns.md b/docs/rules/prefer-promises/dns.md index 501bae78..6e0a73ff 100644 --- a/docs/rules/prefer-promises/dns.md +++ b/docs/rules/prefer-promises/dns.md @@ -9,7 +9,7 @@ Promise API and `async`/`await` syntax will make code more readable than callbac This rule disallows callback API in favor of promise API. -Examples of :-1: **incorrect** code for this rule: +Examples of πŸ‘Ž **incorrect** code for this rule: ```js /*eslint n/prefer-promises/dns: [error]*/ @@ -33,7 +33,7 @@ function lookup(hostname) { } ``` -Examples of :+1: **correct** code for this rule: +Examples of πŸ‘ **correct** code for this rule: ```js /*eslint n/prefer-promises/dns: [error]*/ diff --git a/docs/rules/prefer-promises/fs.md b/docs/rules/prefer-promises/fs.md index ed7f420c..e38130f4 100644 --- a/docs/rules/prefer-promises/fs.md +++ b/docs/rules/prefer-promises/fs.md @@ -9,7 +9,7 @@ Promise API and `async`/`await` syntax will make code more readable than callbac This rule disallows callback API in favor of promise API. -Examples of :-1: **incorrect** code for this rule: +Examples of πŸ‘Ž **incorrect** code for this rule: ```js /*eslint n/prefer-promises/fs: [error]*/ @@ -33,7 +33,7 @@ function readData(filePath) { } ``` -Examples of :+1: **correct** code for this rule: +Examples of πŸ‘ **correct** code for this rule: ```js /*eslint n/prefer-promises/fs: [error]*/ diff --git a/docs/rules/process-exit-as-throw.md b/docs/rules/process-exit-as-throw.md index ed0b7681..aaf0ef13 100644 --- a/docs/rules/process-exit-as-throw.md +++ b/docs/rules/process-exit-as-throw.md @@ -1,6 +1,6 @@ # Require that `process.exit()` expressions use the same code path as `throw` (`n/process-exit-as-throw`) -πŸ’Ό This rule is enabled in the following configs: βœ… `recommended`, β˜‘οΈ `recommended-module`, βœ”οΈ `recommended-script`. +πŸ’Ό This rule is enabled in the βœ… `recommended` [config](https://github.com/eslint-community/eslint-plugin-n#-configs). diff --git a/docs/rules/shebang.md b/docs/rules/shebang.md index 32d2acf9..63ab3639 100644 --- a/docs/rules/shebang.md +++ b/docs/rules/shebang.md @@ -1,6 +1,6 @@ # Require correct usage of shebang (`n/shebang`) -πŸ’Ό This rule is enabled in the following configs: βœ… `recommended`, β˜‘οΈ `recommended-module`, βœ”οΈ `recommended-script`. +πŸ’Ό This rule is enabled in the βœ… `recommended` [config](https://github.com/eslint-community/eslint-plugin-n#-configs). πŸ”§ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix). @@ -9,8 +9,6 @@ When we make a CLI tool with Node.js, we add `bin` field to `package.json`, then we add a shebang the entry file. This rule suggests correct usage of shebang. -**Fixable:** This rule is automatically fixable using the `--fix` flag on the command line. - ## πŸ“– Rule Details This rule looks up `package.json` file from each linting target file. diff --git a/package.json b/package.json index a3361251..b9836c49 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ "husky": "^8.0.2", "import-meta-resolve": "^1.1.1", "lint-staged": "^12.4.1", + "markdownlint-cli": "^0.32.2", "mocha": "^10.1.0", "npm-run-all": "^4.1.5", "nyc": "^15.1.0", @@ -49,21 +50,22 @@ "clean": "rimraf .nyc_output coverage", "codecov": "nyc report --reporter text-lcov | codecov --pipe --disable=gcov -t $CODECOV_TOKEN", "coverage": "opener ./coverage/lcov-report/index.html", + "format": "prettier --loglevel warn --write \"**/*.{js,css,md}\"", "lint": "npm-run-all \"lint:*\"", + "lint:docs": "markdownlint \"**/*.md\"", "lint:eslint-docs": "npm run update:eslint-docs -- --check", "lint:js": "eslint lib scripts tests/lib .eslintrc.js", "new": "node scripts/new-rule", + "postversion": "git push && git push --tags", + "prepare": "husky install", "pretest": "npm run -s lint", + "preversion": "npm test", "test": "nyc npm run -s test:_mocha", - "test:ci": "nyc npm run -s test:_mocha", "test:_mocha": "_mocha \"tests/lib/**/*.js\" --reporter progress --timeout 4000", - "preversion": "npm test", + "test:ci": "nyc npm run -s test:_mocha", + "update:eslint-docs": "eslint-doc-generator --config-emoji recommended-module,β˜‘οΈ --config-emoji recommended-script,βœ”οΈ --split-by meta.docs.category --ignore-config recommended-module --ignore-config recommended-script --url-configs \"https://github.com/eslint-community/eslint-plugin-n#-configs\"", "version": "npm run -s build && eslint lib/rules --fix && git add .", - "postversion": "git push && git push --tags", - "watch": "npm run test:_mocha -- --watch --growl", - "format": "prettier --loglevel warn --write \"**/*.{js,css,md}\"", - "prepare": "husky install", - "update:eslint-docs": "eslint-doc-generator --config-emoji recommended-module,β˜‘οΈ --config-emoji recommended-script,βœ”οΈ --split-by meta.docs.category" + "watch": "npm run test:_mocha -- --watch --growl" }, "repository": { "type": "git",