Skip to content

Commit

Permalink
Docs: update README.md for deprecation rules
Browse files Browse the repository at this point in the history
  • Loading branch information
mysticatea committed Jul 18, 2018
1 parent 4467dcb commit a589060
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 8 deletions.
12 changes: 7 additions & 5 deletions README.md
Expand Up @@ -87,14 +87,16 @@ $ npm install --save-dev eslint eslint-plugin-node
| [node/prefer-global/url-search-params](./docs/rules/prefer-global/url-search-params.md) | enforce either `URLSearchParams` or `require("url").URLSearchParams` | |
| [node/prefer-global/url](./docs/rules/prefer-global/url.md) | enforce either `URL` or `require("url").URL` | |

<!--RULES_TABLE_END-->
### Deprecated rules

### Deprecated
These rules have been deprecated in accordance with the [deprecation policy](https://eslint.org/docs/user-guide/rule-deprecation), and replaced by newer rules:

| Deprecated rule | Replaced by | |
|:--------|:------------|:--:|
| [node/no-unsupported-features](./docs/rules/no-unsupported-features.md) | [node/no-unsupported-ecma-features](./docs/rules/no-unsupported-features/no-unsupported-ecma-features.md) | |
| 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) |

<!--RULES_TABLE_END-->

## 🔧 Configs

Expand Down
2 changes: 2 additions & 0 deletions docs/rules/no-unsupported-features.md
@@ -1,5 +1,7 @@
# Disallow unsupported ECMAScript features on the specified version (no-unsupported-features)

**: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.

Node.js doesn't support all ECMAScript standard features.
This rule reports when you used unsupported ECMAScript 2015-2018 features on the specified Node.js version.

Expand Down
5 changes: 4 additions & 1 deletion lib/rules/no-unsupported-features.js
Expand Up @@ -1046,7 +1046,10 @@ module.exports = {
"disallow unsupported ECMAScript features on the specified version",
category: "Possible Errors",
recommended: false,
replacedBy: ["no-unsupported-ecma-features"],
replacedBy: [
"no-unsupported-features/es-syntax",
"no-unsupported-features/es-builtins",
],
url:
"https://github.com/mysticatea/eslint-plugin-node/blob/v7.0.1/docs/rules/no-unsupported-features.md",
},
Expand Down
2 changes: 2 additions & 0 deletions scripts/rules.js
Expand Up @@ -18,6 +18,7 @@ const rootDir = path.resolve(__dirname, "../lib/rules/")
* @property {boolean} recommended The flag to indicate a recommended rule.
* @property {boolean} deprecated The flag to indicate a deprecated rule.
* @property {boolean} fixable The flag to indicate a fixable rule.
* @property {string[]} replacedBy The flag to indicate a fixable rule.
*/

/**
Expand All @@ -41,6 +42,7 @@ const rules = glob
name,
deprecated: Boolean(meta.deprecated),
fixable: Boolean(meta.fixable),
replacedBy: [],
},
meta.docs
)
Expand Down
29 changes: 27 additions & 2 deletions scripts/update-readme.js
Expand Up @@ -6,7 +6,7 @@

const fs = require("fs")
const path = require("path")
const { categories } = require("./rules")
const { categories, rules } = require("./rules")

/**
* Render a given rule as a table row.
Expand All @@ -20,6 +20,20 @@ function renderRule(rule) {
return `| ${link} | ${description} | ${mark} |`
}

/**
* Render a given rule as a table row.
* @param {RuleInfo} rule The rule information.
* @returns {string} The table row.
*/
function renderDeprecatedRule(rule) {
const link = `[${rule.id}](./docs/rules/${rule.name}.md)`
const replacedBy = rule.replacedBy
.map(name => `[node/${name}](./docs/rules/${name}.md)`)
.join(" and ")

return `| ${link} | ${replacedBy || "(nothing)"} |`
}

/**
* Render a given category as a section.
* @param {CategoryInfo} category The rule information.
Expand All @@ -35,7 +49,18 @@ ${category.rules.map(renderRule).join("\n")}
}

const filePath = path.resolve(__dirname, "../README.md")
const content = categories.map(renderCategory).join("\n")
const content = `${categories.map(renderCategory).join("\n")}
### Deprecated rules
These rules have been deprecated in accordance with the [deprecation policy](https://eslint.org/docs/user-guide/rule-deprecation), and replaced by newer rules:
| Rule ID | Replaced by |
|:--------|:------------|
${rules
.filter(rule => rule.deprecated)
.map(renderDeprecatedRule)
.join("\n")}
`

fs.writeFileSync(
filePath,
Expand Down

0 comments on commit a589060

Please sign in to comment.