Skip to content

Commit

Permalink
Breaking: remove category in core rules (fixes eslint#13398)
Browse files Browse the repository at this point in the history
chore: rm meta.cat from core rules

chore: do not require meta.cat in internal rules

chore: rename cat => ruletype
  • Loading branch information
aladdin-add committed May 17, 2021
1 parent 2466a05 commit 0bf640c
Show file tree
Hide file tree
Showing 290 changed files with 13 additions and 350 deletions.
18 changes: 9 additions & 9 deletions Makefile.js
Expand Up @@ -176,8 +176,8 @@ function generateFormatterExamples(formatterInfo, prereleaseVersion) {
*/
function generateRuleIndexPage() {
const outputFile = "../website/_data/rules.yml",
categoryList = "conf/category-list.json",
categoriesData = JSON.parse(cat(path.resolve(categoryList)));
ruleTypes = "conf/category-list.json",
ruleTypesData = JSON.parse(cat(path.resolve(ruleTypes)));

RULE_FILES
.map(filename => [filename, path.basename(filename, ".js")])
Expand All @@ -188,7 +188,7 @@ function generateRuleIndexPage() {
const rule = require(path.resolve(filename));

if (rule.meta.deprecated) {
categoriesData.deprecated.rules.push({
ruleTypesData.deprecated.rules.push({
name: basename,
replacedBy: rule.meta.replacedBy || []
});
Expand All @@ -199,20 +199,20 @@ function generateRuleIndexPage() {
recommended: rule.meta.docs.recommended || false,
fixable: !!rule.meta.fixable
},
category = categoriesData.categories.find(c => c.name === rule.meta.docs.category);
ruleType = ruleTypesData.types.find(c => c.name === rule.meta.type);

if (!category.rules) {
category.rules = [];
if (!ruleType.rules) {
ruleType.rules = [];
}

category.rules.push(output);
ruleType.rules.push(output);
}
});

// `.rules` will be `undefined` if all rules in category are deprecated.
categoriesData.categories = categoriesData.categories.filter(category => !!category.rules);
ruleTypesData.ruleTypes = ruleTypesData.types.filter(ruleType => !!ruleType.rules);

const output = yaml.safeDump(categoriesData, { sortKeys: true });
const output = yaml.safeDump(ruleTypesData, { sortKeys: true });

output.to(outputFile);
}
Expand Down
11 changes: 4 additions & 7 deletions conf/category-list.json
@@ -1,11 +1,8 @@
{
"categories": [
{ "name": "Possible Errors", "description": "These rules relate to possible syntax or logic errors in JavaScript code:" },
{ "name": "Best Practices", "description": "These rules relate to better ways of doing things to help you avoid problems:" },
{ "name": "Strict Mode", "description": "These rules relate to strict mode directives:" },
{ "name": "Variables", "description": "These rules relate to variable declarations:" },
{ "name": "Stylistic Issues", "description": "These rules relate to style guidelines, and are therefore quite subjective:" },
{ "name": "ECMAScript 6", "description": "These rules relate to ES6, also known as ES2015:" }
"types": [
{ "name": "problem", "description": "Warns about a potential error." },
{ "name": "suggestion", "description": "Suggests an alternate way of doing something." },
{ "name": "layout", "description": "Enforces code style." }
],
"deprecated": {
"name": "Deprecated",
Expand Down
1 change: 0 additions & 1 deletion lib/rules/accessor-pairs.js
Expand Up @@ -140,7 +140,6 @@ module.exports = {

docs: {
description: "enforce getter and setter pairs in objects and classes",
category: "Best Practices",
recommended: false,
url: "https://eslint.org/docs/rules/accessor-pairs"
},
Expand Down
1 change: 0 additions & 1 deletion lib/rules/array-bracket-newline.js
Expand Up @@ -17,7 +17,6 @@ module.exports = {

docs: {
description: "enforce linebreaks after opening and before closing array brackets",
category: "Stylistic Issues",
recommended: false,
url: "https://eslint.org/docs/rules/array-bracket-newline"
},
Expand Down
1 change: 0 additions & 1 deletion lib/rules/array-bracket-spacing.js
Expand Up @@ -16,7 +16,6 @@ module.exports = {

docs: {
description: "enforce consistent spacing inside array brackets",
category: "Stylistic Issues",
recommended: false,
url: "https://eslint.org/docs/rules/array-bracket-spacing"
},
Expand Down
1 change: 0 additions & 1 deletion lib/rules/array-callback-return.js
Expand Up @@ -139,7 +139,6 @@ module.exports = {

docs: {
description: "enforce `return` statements in callbacks of array methods",
category: "Best Practices",
recommended: false,
url: "https://eslint.org/docs/rules/array-callback-return"
},
Expand Down
1 change: 0 additions & 1 deletion lib/rules/array-element-newline.js
Expand Up @@ -17,7 +17,6 @@ module.exports = {

docs: {
description: "enforce line breaks after each array element",
category: "Stylistic Issues",
recommended: false,
url: "https://eslint.org/docs/rules/array-element-newline"
},
Expand Down
1 change: 0 additions & 1 deletion lib/rules/arrow-body-style.js
Expand Up @@ -20,7 +20,6 @@ module.exports = {

docs: {
description: "require braces around arrow function bodies",
category: "ECMAScript 6",
recommended: false,
url: "https://eslint.org/docs/rules/arrow-body-style"
},
Expand Down
1 change: 0 additions & 1 deletion lib/rules/arrow-parens.js
Expand Up @@ -33,7 +33,6 @@ module.exports = {

docs: {
description: "require parentheses around arrow function arguments",
category: "ECMAScript 6",
recommended: false,
url: "https://eslint.org/docs/rules/arrow-parens"
},
Expand Down
1 change: 0 additions & 1 deletion lib/rules/arrow-spacing.js
Expand Up @@ -20,7 +20,6 @@ module.exports = {

docs: {
description: "enforce consistent spacing before and after the arrow in arrow functions",
category: "ECMAScript 6",
recommended: false,
url: "https://eslint.org/docs/rules/arrow-spacing"
},
Expand Down
1 change: 0 additions & 1 deletion lib/rules/block-scoped-var.js
Expand Up @@ -14,7 +14,6 @@ module.exports = {

docs: {
description: "enforce the use of variables within the scope they are defined",
category: "Best Practices",
recommended: false,
url: "https://eslint.org/docs/rules/block-scoped-var"
},
Expand Down
1 change: 0 additions & 1 deletion lib/rules/block-spacing.js
Expand Up @@ -17,7 +17,6 @@ module.exports = {

docs: {
description: "disallow or enforce spaces inside of blocks after opening block and before closing block",
category: "Stylistic Issues",
recommended: false,
url: "https://eslint.org/docs/rules/block-spacing"
},
Expand Down
1 change: 0 additions & 1 deletion lib/rules/brace-style.js
Expand Up @@ -17,7 +17,6 @@ module.exports = {

docs: {
description: "enforce consistent brace style for blocks",
category: "Stylistic Issues",
recommended: false,
url: "https://eslint.org/docs/rules/brace-style"
},
Expand Down
1 change: 0 additions & 1 deletion lib/rules/callback-return.js
Expand Up @@ -18,7 +18,6 @@ module.exports = {

docs: {
description: "require `return` statements after callbacks",
category: "Node.js and CommonJS",
recommended: false,
url: "https://eslint.org/docs/rules/callback-return"
},
Expand Down
1 change: 0 additions & 1 deletion lib/rules/camelcase.js
Expand Up @@ -15,7 +15,6 @@ module.exports = {

docs: {
description: "enforce camelcase naming convention",
category: "Stylistic Issues",
recommended: false,
url: "https://eslint.org/docs/rules/camelcase"
},
Expand Down
1 change: 0 additions & 1 deletion lib/rules/capitalized-comments.js
Expand Up @@ -105,7 +105,6 @@ module.exports = {

docs: {
description: "enforce or disallow capitalization of the first letter of a comment",
category: "Stylistic Issues",
recommended: false,
url: "https://eslint.org/docs/rules/capitalized-comments"
},
Expand Down
1 change: 0 additions & 1 deletion lib/rules/class-methods-use-this.js
Expand Up @@ -21,7 +21,6 @@ module.exports = {

docs: {
description: "enforce that class methods utilize `this`",
category: "Best Practices",
recommended: false,
url: "https://eslint.org/docs/rules/class-methods-use-this"
},
Expand Down
1 change: 0 additions & 1 deletion lib/rules/comma-dangle.js
Expand Up @@ -77,7 +77,6 @@ module.exports = {

docs: {
description: "require or disallow trailing commas",
category: "Stylistic Issues",
recommended: false,
url: "https://eslint.org/docs/rules/comma-dangle"
},
Expand Down
1 change: 0 additions & 1 deletion lib/rules/comma-spacing.js
Expand Up @@ -16,7 +16,6 @@ module.exports = {

docs: {
description: "enforce consistent spacing before and after commas",
category: "Stylistic Issues",
recommended: false,
url: "https://eslint.org/docs/rules/comma-spacing"
},
Expand Down
1 change: 0 additions & 1 deletion lib/rules/comma-style.js
Expand Up @@ -17,7 +17,6 @@ module.exports = {

docs: {
description: "enforce consistent comma style",
category: "Stylistic Issues",
recommended: false,
url: "https://eslint.org/docs/rules/comma-style"
},
Expand Down
1 change: 0 additions & 1 deletion lib/rules/complexity.js
Expand Up @@ -24,7 +24,6 @@ module.exports = {

docs: {
description: "enforce a maximum cyclomatic complexity allowed in a program",
category: "Best Practices",
recommended: false,
url: "https://eslint.org/docs/rules/complexity"
},
Expand Down
1 change: 0 additions & 1 deletion lib/rules/computed-property-spacing.js
Expand Up @@ -16,7 +16,6 @@ module.exports = {

docs: {
description: "enforce consistent spacing inside computed property brackets",
category: "Stylistic Issues",
recommended: false,
url: "https://eslint.org/docs/rules/computed-property-spacing"
},
Expand Down
1 change: 0 additions & 1 deletion lib/rules/consistent-return.js
Expand Up @@ -46,7 +46,6 @@ module.exports = {

docs: {
description: "require `return` statements to either always or never specify values",
category: "Best Practices",
recommended: false,
url: "https://eslint.org/docs/rules/consistent-return"
},
Expand Down
1 change: 0 additions & 1 deletion lib/rules/consistent-this.js
Expand Up @@ -14,7 +14,6 @@ module.exports = {

docs: {
description: "enforce consistent naming when capturing the current execution context",
category: "Stylistic Issues",
recommended: false,
url: "https://eslint.org/docs/rules/consistent-this"
},
Expand Down
1 change: 0 additions & 1 deletion lib/rules/constructor-super.js
Expand Up @@ -122,7 +122,6 @@ module.exports = {

docs: {
description: "require `super()` calls in constructors",
category: "ECMAScript 6",
recommended: true,
url: "https://eslint.org/docs/rules/constructor-super"
},
Expand Down
1 change: 0 additions & 1 deletion lib/rules/curly.js
Expand Up @@ -20,7 +20,6 @@ module.exports = {

docs: {
description: "enforce consistent brace style for all control statements",
category: "Best Practices",
recommended: false,
url: "https://eslint.org/docs/rules/curly"
},
Expand Down
1 change: 0 additions & 1 deletion lib/rules/default-case-last.js
Expand Up @@ -15,7 +15,6 @@ module.exports = {

docs: {
description: "enforce default clauses in switch statements to be last",
category: "Best Practices",
recommended: false,
url: "https://eslint.org/docs/rules/default-case-last"
},
Expand Down
1 change: 0 additions & 1 deletion lib/rules/default-case.js
Expand Up @@ -16,7 +16,6 @@ module.exports = {

docs: {
description: "require `default` cases in `switch` statements",
category: "Best Practices",
recommended: false,
url: "https://eslint.org/docs/rules/default-case"
},
Expand Down
1 change: 0 additions & 1 deletion lib/rules/default-param-last.js
Expand Up @@ -11,7 +11,6 @@ module.exports = {

docs: {
description: "enforce default parameters to be last",
category: "Best Practices",
recommended: false,
url: "https://eslint.org/docs/rules/default-param-last"
},
Expand Down
1 change: 0 additions & 1 deletion lib/rules/dot-location.js
Expand Up @@ -17,7 +17,6 @@ module.exports = {

docs: {
description: "enforce consistent newlines before and after dots",
category: "Best Practices",
recommended: false,
url: "https://eslint.org/docs/rules/dot-location"
},
Expand Down
1 change: 0 additions & 1 deletion lib/rules/dot-notation.js
Expand Up @@ -26,7 +26,6 @@ module.exports = {

docs: {
description: "enforce dot notation whenever possible",
category: "Best Practices",
recommended: false,
url: "https://eslint.org/docs/rules/dot-notation"
},
Expand Down
1 change: 0 additions & 1 deletion lib/rules/eol-last.js
Expand Up @@ -20,7 +20,6 @@ module.exports = {

docs: {
description: "require or disallow newline at the end of files",
category: "Stylistic Issues",
recommended: false,
url: "https://eslint.org/docs/rules/eol-last"
},
Expand Down
1 change: 0 additions & 1 deletion lib/rules/eqeqeq.js
Expand Up @@ -21,7 +21,6 @@ module.exports = {

docs: {
description: "require the use of `===` and `!==`",
category: "Best Practices",
recommended: false,
url: "https://eslint.org/docs/rules/eqeqeq"
},
Expand Down
1 change: 0 additions & 1 deletion lib/rules/for-direction.js
Expand Up @@ -15,7 +15,6 @@ module.exports = {

docs: {
description: "enforce \"for\" loop update clause moving the counter in the right direction.",
category: "Possible Errors",
recommended: true,
url: "https://eslint.org/docs/rules/for-direction"
},
Expand Down
1 change: 0 additions & 1 deletion lib/rules/func-call-spacing.js
Expand Up @@ -21,7 +21,6 @@ module.exports = {

docs: {
description: "require or disallow spacing between function identifiers and their invocations",
category: "Stylistic Issues",
recommended: false,
url: "https://eslint.org/docs/rules/func-call-spacing"
},
Expand Down
1 change: 0 additions & 1 deletion lib/rules/func-name-matching.js
Expand Up @@ -74,7 +74,6 @@ module.exports = {

docs: {
description: "require function names to match the name of the variable or property to which they are assigned",
category: "Stylistic Issues",
recommended: false,
url: "https://eslint.org/docs/rules/func-name-matching"
},
Expand Down
1 change: 0 additions & 1 deletion lib/rules/func-names.js
Expand Up @@ -30,7 +30,6 @@ module.exports = {

docs: {
description: "require or disallow named `function` expressions",
category: "Stylistic Issues",
recommended: false,
url: "https://eslint.org/docs/rules/func-names"
},
Expand Down
1 change: 0 additions & 1 deletion lib/rules/func-style.js
Expand Up @@ -14,7 +14,6 @@ module.exports = {

docs: {
description: "enforce the consistent use of either `function` declarations or expressions",
category: "Stylistic Issues",
recommended: false,
url: "https://eslint.org/docs/rules/func-style"
},
Expand Down
1 change: 0 additions & 1 deletion lib/rules/function-call-argument-newline.js
Expand Up @@ -15,7 +15,6 @@ module.exports = {

docs: {
description: "enforce line breaks between arguments of a function call",
category: "Stylistic Issues",
recommended: false,
url: "https://eslint.org/docs/rules/function-call-argument-newline"
},
Expand Down
1 change: 0 additions & 1 deletion lib/rules/function-paren-newline.js
Expand Up @@ -20,7 +20,6 @@ module.exports = {

docs: {
description: "enforce consistent line breaks inside function parentheses",
category: "Stylistic Issues",
recommended: false,
url: "https://eslint.org/docs/rules/function-paren-newline"
},
Expand Down
1 change: 0 additions & 1 deletion lib/rules/generator-star-spacing.js
Expand Up @@ -31,7 +31,6 @@ module.exports = {

docs: {
description: "enforce consistent spacing around `*` operators in generator functions",
category: "ECMAScript 6",
recommended: false,
url: "https://eslint.org/docs/rules/generator-star-spacing"
},
Expand Down
1 change: 0 additions & 1 deletion lib/rules/getter-return.js
Expand Up @@ -35,7 +35,6 @@ module.exports = {

docs: {
description: "enforce `return` statements in getters",
category: "Possible Errors",
recommended: true,
url: "https://eslint.org/docs/rules/getter-return"
},
Expand Down
1 change: 0 additions & 1 deletion lib/rules/global-require.js
Expand Up @@ -57,7 +57,6 @@ module.exports = {

docs: {
description: "require `require()` calls to be placed at top-level module scope",
category: "Node.js and CommonJS",
recommended: false,
url: "https://eslint.org/docs/rules/global-require"
},
Expand Down
1 change: 0 additions & 1 deletion lib/rules/grouped-accessor-pairs.js
Expand Up @@ -96,7 +96,6 @@ module.exports = {

docs: {
description: "require grouped accessor pairs in object literals and classes",
category: "Best Practices",
recommended: false,
url: "https://eslint.org/docs/rules/grouped-accessor-pairs"
},
Expand Down

0 comments on commit 0bf640c

Please sign in to comment.