Skip to content

Commit

Permalink
πŸ“ tweak documents
Browse files Browse the repository at this point in the history
  • Loading branch information
mysticatea committed May 3, 2019
1 parent a84a009 commit 11d2d41
Show file tree
Hide file tree
Showing 17 changed files with 26 additions and 45 deletions.
3 changes: 1 addition & 2 deletions docs/rules/file-extension-in-import.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# node/file-extension-in-import
> enforce the style of file extensions in `import` declarations
- βœ’οΈ The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
> - βœ’οΈ The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
We can omit file extensions in `import`/`export` declarations.

Expand Down
3 changes: 1 addition & 2 deletions docs/rules/no-deprecated-api.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# node/no-deprecated-api
> disallow deprecated APIs
- ⭐️ This rule is included in `plugin:node/recommended` preset.
> - ⭐️ This rule is included in `plugin:node/recommended` preset.
Node has many deprecated API.
The community is going to remove those API from Node in future, so we should not use those.
Expand Down
3 changes: 1 addition & 2 deletions docs/rules/no-extraneous-import.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# node/no-extraneous-import
> disallow `import` declarations which import extraneous modules
- ⭐️ This rule is included in `plugin:node/recommended` preset.
> - ⭐️ 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
3 changes: 1 addition & 2 deletions docs/rules/no-extraneous-require.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# node/no-extraneous-require
> disallow `require()` expressions which import extraneous modules
- ⭐️ This rule is included in `plugin:node/recommended` preset.
> - ⭐️ This rule is included in `plugin:node/recommended` preset.
If a `require()`'s target 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 `require()` of extraneous modules.
Expand Down
3 changes: 1 addition & 2 deletions docs/rules/no-hide-core-modules.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# node/no-hide-core-modules
> disallow third-party modules which are hiding core modules
- β›” This rule has been deprecated.
> - β›” This rule has been deprecated.
**: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).

Expand Down
3 changes: 1 addition & 2 deletions docs/rules/no-missing-import.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# node/no-missing-import
> disallow `import` declarations which import non-existence modules
- ⭐️ This rule is included in `plugin:node/recommended` preset.
> - ⭐️ 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.

Expand Down
3 changes: 1 addition & 2 deletions docs/rules/no-missing-require.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# node/no-missing-require
> disallow `require()` expressions which import non-existence modules
- ⭐️ This rule is included in `plugin:node/recommended` preset.
> - ⭐️ This rule is included in `plugin:node/recommended` preset.
Maybe we cannot find typo of import paths until run it, so this rule checks import paths.

Expand Down
3 changes: 1 addition & 2 deletions docs/rules/no-unpublished-bin.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# node/no-unpublished-bin
> disallow `bin` files that npm ignores
- ⭐️ This rule is included in `plugin:node/recommended` preset.
> - ⭐️ This rule is included in `plugin:node/recommended` preset.
We can publish CLI commands by `npm`. It uses `bin` field of `package.json`.

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

Expand Down
3 changes: 1 addition & 2 deletions docs/rules/no-unpublished-require.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# node/no-unpublished-require
> disallow `require()` expressions which import private modules
- ⭐️ This rule is included in `plugin:node/recommended` preset.
> - ⭐️ This rule is included in `plugin:node/recommended` preset.
If a `require()` expression's target is not published, the program works in local, but will not work after published to npm.
This rule disallows `require()` expressions of unpublished files/modules.
Expand Down
3 changes: 1 addition & 2 deletions docs/rules/no-unsupported-features.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# node/no-unsupported-features
> disallow unsupported ECMAScript features on the specified version
- β›” 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.
> - β›” 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
3 changes: 1 addition & 2 deletions docs/rules/no-unsupported-features/es-builtins.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# node/no-unsupported-features/es-builtins
> disallow unsupported ECMAScript built-ins on the specified version
- ⭐️ This rule is included in `plugin:node/recommended` preset.
> - ⭐️ This rule is included in `plugin:node/recommended` preset.
ECMAScript standard is updating every two months.
You can check [node.green](https://node.green/) to know which Node.js version supports each ECMAScript feature.
Expand Down
3 changes: 1 addition & 2 deletions docs/rules/no-unsupported-features/es-syntax.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# node/no-unsupported-features/es-syntax
> disallow unsupported ECMAScript syntax on the specified version
- ⭐️ This rule is included in `plugin:node/recommended` preset.
> - ⭐️ This rule is included in `plugin:node/recommended` preset.
ECMAScript standard is updating every two months.
You can check [node.green](https://node.green/) to know which Node.js version supports each ECMAScript feature.
Expand Down
3 changes: 1 addition & 2 deletions docs/rules/no-unsupported-features/node-builtins.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# node/no-unsupported-features/node-builtins
> disallow unsupported Node.js built-in APIs on the specified version
- ⭐️ This rule is included in `plugin:node/recommended` preset.
> - ⭐️ This rule is included in `plugin:node/recommended` preset.
Node.js community is improving built-in APIs continuously.
You can check [Node.js Documentation](https://nodejs.org/api/) to know which Node.js version supports each Node.js API.
Expand Down
3 changes: 1 addition & 2 deletions docs/rules/process-exit-as-throw.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# node/process-exit-as-throw
> make `process.exit()` expressions the same code path as `throw`
- ⭐️ This rule is included in `plugin:node/recommended` preset.
> - ⭐️ This rule is included in `plugin:node/recommended` preset.
## πŸ“– Rule Details

Expand Down
5 changes: 2 additions & 3 deletions docs/rules/shebang.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# node/shebang
> suggest correct usage of shebang
- ⭐️ This rule is included in `plugin:node/recommended` preset.
- βœ’οΈ The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
> - ⭐️ This rule is included in `plugin:node/recommended` preset.
> - βœ’οΈ The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
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.
Expand Down
21 changes: 9 additions & 12 deletions scripts/update-docs-header-and-footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
const fs = require("fs")
const path = require("path")
const { rules } = require("./rules")
const headerPattern = /^#.+\n(?:>.+\n)?(?:\n(?:-.+\n)+)?\n+/u
const headerPattern = /^#.+\n(?:>.+\n)*\n+/u
const footerPattern = /\n+## πŸ”Ž Implementation[\s\S]*$/u
const ruleRoot = path.resolve(__dirname, "../lib/rules")
const testRoot = path.resolve(__dirname, "../tests/lib/rules")
Expand All @@ -22,17 +22,16 @@ const listFormatter = new Intl.ListFormat("en", { type: "conjunction" })
* @returns {string} The document header.
*/
function renderHeader(rule) {
const title = `# ${rule.id}\n> ${rule.description}`
const notes = []
const lines = [`# ${rule.id}`, `> ${rule.description}`]

if (rule.recommended) {
notes.push(
"- ⭐️ This rule is included in `plugin:node/recommended` preset."
lines.push(
"> - ⭐️ This rule is included in `plugin:node/recommended` preset."
)
}
if (rule.fixable) {
notes.push(
"- βœ’οΈ The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule."
lines.push(
"> - βœ’οΈ The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule."
)
}
if (rule.deprecated) {
Expand All @@ -43,13 +42,11 @@ function renderHeader(rule) {
replace.length === 0
? ""
: ` Use ${listFormatter.format(replace)} instead.`
notes.push(`- β›” This rule has been deprecated.${replaceText}`)
lines.push(`> - β›” This rule has been deprecated.${replaceText}`)
}
lines.push("", "")

if (notes.length > 0) {
return `${title}\n\n${notes.join("\n")}\n\n`
}
return `${title}\n\n`
return lines.join("\n")
}

/**
Expand Down

0 comments on commit 11d2d41

Please sign in to comment.