Skip to content
Permalink
Browse files

Docs: update README.md for deprecation rules

  • Loading branch information...
mysticatea committed Jul 18, 2018
1 parent 4467dcb commit a589060d98326631d2fafc912480b82de75a1d0d
Showing with 42 additions and 8 deletions.
  1. +7 −5 README.md
  2. +2 −0 docs/rules/no-unsupported-features.md
  3. +4 −1 lib/rules/no-unsupported-features.js
  4. +2 −0 scripts/rules.js
  5. +27 −2 scripts/update-readme.js
@@ -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

@@ -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.

@@ -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",
},
@@ -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.
*/

/**
@@ -41,6 +42,7 @@ const rules = glob
name,
deprecated: Boolean(meta.deprecated),
fixable: Boolean(meta.fixable),
replacedBy: [],
},
meta.docs
)
@@ -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.
@@ -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.
@@ -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,

0 comments on commit a589060

Please sign in to comment.
You can’t perform that action at this time.