Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Warn for deprecation in Node output (fixes #7443) #10953

Merged
merged 8 commits into from Oct 30, 2018
Prev

Move meta.docs.replacedBy to meta.replacedBy

  • Loading branch information...
calling committed Oct 28, 2018
commit f7eb61937d0cd588eda34b88347c59a0ed94825e
@@ -226,7 +226,7 @@ function generateRuleIndexPage(basedir) {
if (rule.meta.deprecated) {
categoriesData.deprecated.rules.push({
name: basename,
replacedBy: rule.meta.docs.replacedBy || []
replacedBy: rule.meta.replacedBy || []
});
} else {
const output = {
@@ -55,7 +55,6 @@ The source file for a rule exports an object with the following properties.
* `category` (string) specifies the heading under which the rule is listed in the [rules index](../rules/)
* `recommended` (boolean) is whether the `"extends": "eslint:recommended"` property in a [configuration file](../user-guide/configuring.md#extending-configuration-files) enables the rule
* `url` (string) specifies the URL at which the full documentation can be accessed
* `replacedBy` (array) in the case of a deprecated rule, specifies replacement rule(s)

In a custom rule or plugin, you can omit `docs` or include any properties that you need in it.

@@ -67,6 +66,8 @@ The source file for a rule exports an object with the following properties.

* `deprecated` (boolean) indicates whether the rule has been deprecated. You may omit the `deprecated` property if the rule has not been deprecated.

* `replacedBy` (array) in the case of a deprecated rule, specifies replacement rule(s)

`create` (function) returns an object with methods that ESLint calls to "visit" nodes while traversing the abstract syntax tree (AST as defined by [ESTree](https://github.com/estree/estree)) of JavaScript code:

* if a key is a node type or a [selector](./selectors.md), ESLint calls that **visitor** function while going **down** the tree
@@ -289,7 +289,7 @@ function createRuleWarnings(rules, loadedRules) {

if (loadedRule.meta && loadedRule.meta.deprecated) {
const deprecatedRule = { ruleId: name };
const replacedBy = lodash.get(loadedRule, "meta.docs.replacedBy", []);
const replacedBy = lodash.get(loadedRule, "meta.replacedBy", []);

if (replacedBy.every(newRule => lodash.isString(newRule))) {
deprecatedRule.replacedBy = replacedBy;
@@ -25,12 +25,13 @@ module.exports = {
description: "enforce consistent indentation",
category: "Stylistic Issues",
recommended: false,
replacedBy: ["indent"],
url: "https://eslint.org/docs/rules/indent-legacy"
},

deprecated: true,

replacedBy: ["indent"],

fixable: "whitespace",

schema: [
@@ -18,7 +18,6 @@ module.exports = {
description: "require or disallow newlines around directives",
category: "Stylistic Issues",
recommended: false,
replacedBy: ["padding-line-between-statements"],
url: "https://eslint.org/docs/rules/lines-around-directive"
},
schema: [{
@@ -42,7 +41,8 @@ module.exports = {
]
}],
fixable: "whitespace",
deprecated: true
deprecated: true,
replacedBy: ["padding-line-between-statements"]
},

create(context) {
@@ -22,7 +22,6 @@ module.exports = {
description: "require or disallow an empty line after variable declarations",
category: "Stylistic Issues",
recommended: false,
replacedBy: ["padding-line-between-statements"],
url: "https://eslint.org/docs/rules/newline-after-var"
},

@@ -34,7 +33,9 @@ module.exports = {

fixable: "whitespace",

deprecated: true
deprecated: true,

replacedBy: ["padding-line-between-statements"]
},

create(context) {
@@ -15,12 +15,12 @@ module.exports = {
description: "require an empty line before `return` statements",
category: "Stylistic Issues",
recommended: false,
replacedBy: ["padding-line-between-statements"],
url: "https://eslint.org/docs/rules/newline-before-return"
},
fixable: "whitespace",
schema: [],
deprecated: true
deprecated: true,
replacedBy: ["padding-line-between-statements"]
},

create(context) {
@@ -22,11 +22,12 @@ module.exports = {
description: "disallow `catch` clause parameters from shadowing variables in the outer scope",
category: "Variables",
recommended: false,
url: "https://eslint.org/docs/rules/no-catch-shadow",
replacedBy: ["no-shadow"]
url: "https://eslint.org/docs/rules/no-catch-shadow"
},
deprecated: true,

replacedBy: ["no-shadow"],

schema: [],

messages: {
@@ -16,12 +16,13 @@ module.exports = {
description: "disallow assignments to native objects or read-only global variables",
category: "Best Practices",
recommended: false,
replacedBy: ["no-global-assign"],
url: "https://eslint.org/docs/rules/no-native-reassign"
},

deprecated: true,

replacedBy: ["no-global-assign"],

schema: [
{
type: "object",
@@ -16,11 +16,12 @@ module.exports = {
description: "disallow negating the left operand in `in` expressions",
category: "Possible Errors",
recommended: false,
replacedBy: ["no-unsafe-negation"],
url: "https://eslint.org/docs/rules/no-negated-in-lhs"
},
deprecated: true,

replacedBy: ["no-unsafe-negation"],

schema: []
},

@@ -16,12 +16,13 @@ module.exports = {
description: "disallow spacing between function identifiers and their applications (deprecated)",
category: "Stylistic Issues",
recommended: false,
replacedBy: ["func-call-spacing"],
url: "https://eslint.org/docs/rules/no-spaced-func"
},

deprecated: true,

replacedBy: ["func-call-spacing"],

fixable: "whitespace",
schema: []
},
@@ -15,12 +15,13 @@ module.exports = {
description: "require `Reflect` methods where applicable",
category: "ECMAScript 6",
recommended: false,
replacedBy: [],
url: "https://eslint.org/docs/rules/prefer-reflect"
},

deprecated: true,

replacedBy: [],

schema: [
{
type: "object",
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.