Skip to content

Commit

Permalink
📝 update decuments
Browse files Browse the repository at this point in the history
  • Loading branch information
mysticatea committed May 3, 2019
1 parent 9243079 commit 528282a
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 16 deletions.
24 changes: 14 additions & 10 deletions README.md
Expand Up @@ -29,11 +29,14 @@ $ npm install --save-dev eslint eslint-plugin-node
],
"rules": {
"node/exports-style": ["error", "module.exports"],
"node/file-extension-in-import": ["error", "always"],
"node/prefer-global/buffer": ["error", "always"],
"node/prefer-global/console": ["error", "always"],
"node/prefer-global/process": ["error", "always"],
"node/prefer-global/url-search-params": ["error", "always"],
"node/prefer-global/url": ["error", "always"]
"node/prefer-global/url": ["error", "always"],
"node/prefer-promises/dns": "error",
"node/prefer-promises/fs": "error"
}
}
```
Expand All @@ -44,6 +47,7 @@ $ npm install --save-dev eslint eslint-plugin-node
{
"name": "your-module",
"version": "1.0.0",
"type": "commonjs",
"engines": {
"node": ">=8.10.0"
}
Expand All @@ -60,18 +64,18 @@ $ npm install --save-dev eslint eslint-plugin-node

| Rule ID | Description | |
|:--------|:------------|:--:|
| [node/no-extraneous-import](./docs/rules/no-extraneous-import.md) | disallow `import` declarations of extraneous packages | |
| [node/no-extraneous-require](./docs/rules/no-extraneous-require.md) | disallow `require()` expressions of extraneous packages | ⭐️ |
| [node/no-missing-import](./docs/rules/no-missing-import.md) | disallow `import` declarations of missing files | |
| [node/no-missing-require](./docs/rules/no-missing-require.md) | disallow `require()` expressions of missing files | ⭐️ |
| [node/no-unpublished-bin](./docs/rules/no-unpublished-bin.md) | disallow 'bin' files which are ignored by npm | ⭐️ |
| [node/no-unpublished-import](./docs/rules/no-unpublished-import.md) | disallow `import` declarations of private things | |
| [node/no-unpublished-require](./docs/rules/no-unpublished-require.md) | disallow `require()` expressions of private things | ⭐️ |
| [node/no-extraneous-import](./docs/rules/no-extraneous-import.md) | disallow `import` declarations which import extraneous modules | ⭐️ |
| [node/no-extraneous-require](./docs/rules/no-extraneous-require.md) | disallow `require()` expressions which import extraneous modules | ⭐️ |
| [node/no-missing-import](./docs/rules/no-missing-import.md) | disallow `import` declarations which import non-existence modules | ⭐️ |
| [node/no-missing-require](./docs/rules/no-missing-require.md) | disallow `require()` expressions which import non-existence modules | ⭐️ |
| [node/no-unpublished-bin](./docs/rules/no-unpublished-bin.md) | disallow `bin` files that npm ignores | ⭐️ |
| [node/no-unpublished-import](./docs/rules/no-unpublished-import.md) | disallow `import` declarations which import private modules | ⭐️ |
| [node/no-unpublished-require](./docs/rules/no-unpublished-require.md) | disallow `require()` expressions which import private modules | ⭐️ |
| [node/no-unsupported-features/es-builtins](./docs/rules/no-unsupported-features/es-builtins.md) | disallow unsupported ECMAScript built-ins on the specified version | ⭐️ |
| [node/no-unsupported-features/es-syntax](./docs/rules/no-unsupported-features/es-syntax.md) | disallow unsupported ECMAScript syntax on the specified version | ⭐️ |
| [node/no-unsupported-features/node-builtins](./docs/rules/no-unsupported-features/node-builtins.md) | disallow unsupported Node.js built-in APIs on the specified version | ⭐️ |
| [node/process-exit-as-throw](./docs/rules/process-exit-as-throw.md) | make `process.exit()` expressions the same code path as `throw` | ⭐️ |
| [node/shebang](./docs/rules/shebang.md) | enforce the correct usage of shebang | ⭐️✒️ |
| [node/shebang](./docs/rules/shebang.md) | suggest correct usage of shebang | ⭐️✒️ |

### Best Practices

Expand Down Expand Up @@ -102,7 +106,7 @@ These rules have been deprecated in accordance with the [deprecation policy](htt
| Rule ID | Replaced by |
|:--------|:------------|
| [node/no-hide-core-modules](./docs/rules/no-hide-core-modules.md) | (nothing) |
| [node/no-unsupported-features](./docs/rules/no-unsupported-features.md) | [node/no-unsupported-features/es-syntax](./docs/rules/no-unsupported-features/es-syntax.md) and [node/no-unsupported-features/es-builtins](./docs/rules/no-unsupported-features/es-builtins.md) |
| [node/no-unsupported-features](./docs/rules/no-unsupported-features.md) | [node/node/no-unsupported-features/es-syntax](./docs/rules/node/no-unsupported-features/es-syntax.md) and [node/node/no-unsupported-features/es-builtins](./docs/rules/node/no-unsupported-features/es-builtins.md) |

<!--RULES_TABLE_END-->

Expand Down
2 changes: 2 additions & 0 deletions docs/rules/no-extraneous-import.md
@@ -1,6 +1,8 @@
# node/no-extraneous-import
> disallow `import` declarations which import extraneous modules
- ⭐️ This rule is included in `plugin:node/recommended` preset.

If an `import` declaration's source is extraneous (it's not written in `package.json`), the program works in local, but will not work after dependencies are re-installed. It will cause troubles to your team/contributors.
This rule disallows `import` declarations of extraneous modules.

Expand Down
2 changes: 2 additions & 0 deletions docs/rules/no-missing-import.md
@@ -1,6 +1,8 @@
# node/no-missing-import
> disallow `import` declarations which import non-existence modules
- ⭐️ This rule is included in `plugin:node/recommended` preset.

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.
Expand Down
2 changes: 2 additions & 0 deletions docs/rules/no-unpublished-import.md
@@ -1,6 +1,8 @@
# node/no-unpublished-import
> disallow `import` declarations which import private modules
- ⭐️ This rule is included in `plugin:node/recommended` preset.

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.
Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-unsupported-features.md
@@ -1,7 +1,7 @@
# node/no-unsupported-features
> disallow unsupported ECMAScript features on the specified version
- ⛔ This rule has been deprecated. Use [node/no-unsupported-features/es-syntax](./node/no-unsupported-features/es-syntax.md) and [node/no-unsupported-features/es-builtins](./node/no-unsupported-features/es-builtins.md) instead.
- ⛔ This rule has been deprecated. Use [node/no-unsupported-features/es-syntax](./no-unsupported-features/es-syntax.md) and [node/no-unsupported-features/es-builtins](./no-unsupported-features/es-builtins.md) instead.

**:warning: This is deprecated since v7.0.0.** Use [node/no-unsupported-features/es-syntax](./no-unsupported-features/es-syntax.md) and [node/no-unsupported-features/es-builtins](./no-unsupported-features/es-builtins.md) instead.

Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-extraneous-import.js
Expand Up @@ -17,7 +17,7 @@ module.exports = {
description:
"disallow `import` declarations which import extraneous modules",
category: "Possible Errors",
recommended: false,
recommended: true,
url:
"https://github.com/mysticatea/eslint-plugin-node/blob/v8.0.1/docs/rules/no-extraneous-import.md",
},
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-missing-import.js
Expand Up @@ -16,7 +16,7 @@ module.exports = {
description:
"disallow `import` declarations which import non-existence modules",
category: "Possible Errors",
recommended: false,
recommended: true,
url:
"https://github.com/mysticatea/eslint-plugin-node/blob/v8.0.1/docs/rules/no-missing-import.md",
},
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-unpublished-import.js
Expand Up @@ -17,7 +17,7 @@ module.exports = {
description:
"disallow `import` declarations which import private modules",
category: "Possible Errors",
recommended: false,
recommended: true,
url:
"https://github.com/mysticatea/eslint-plugin-node/blob/v8.0.1/docs/rules/no-unpublished-import.md",
},
Expand Down
4 changes: 2 additions & 2 deletions scripts/update-docs-header-and-footer.js
Expand Up @@ -37,7 +37,7 @@ function renderHeader(rule) {
}
if (rule.deprecated) {
const replace = rule.replacedBy.map(
ruleId => `[${ruleId}](./${ruleId}.md)`
ruleId => `[${ruleId}](./${ruleId.replace("node/", "")}.md)`
)
const replaceText =
replace.length === 0
Expand Down Expand Up @@ -73,7 +73,7 @@ for (const rule of rules) {
const filePath = path.resolve(docsRoot, `${rule.name}.md`)
const original = fs.readFileSync(filePath, "utf8")
const body = original.replace(headerPattern, "").replace(footerPattern, "")
const content = `${renderHeader(rule)}${body}${renderFooter(rule)}`
const content = `${renderHeader(rule)}${body}${renderFooter(rule)}\n`

fs.writeFileSync(filePath, content)
}

0 comments on commit 528282a

Please sign in to comment.