Skip to content
Permalink
Browse files
Breaking: remove meta.docs.category in core rules (fixes #13398) (#14594
)

* Breaking: remove category in core rules (fixes #13398)

chore: rm meta.cat from core rules

chore: do not require meta.cat in internal rules

chore: rename cat => ruletype

Chore: rename conf/category-list.json => rule-type-list.json

chore: update tools/update-rule-types

chore: review suggestions

Update conf/rule-type-list.json

Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com>

Update Makefile.js

Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com>

* chore: remove unused files

* fix: conflicts

* remove missingMetaDocsDescription message

Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com>
Co-authored-by: Bryan Mishkin <698306+bmish@users.noreply.github.com>
  • Loading branch information
3 people committed Aug 24, 2021
1 parent a79c9f3 commit 305e14af8bd12afc01487abee5c9b0f3eaca989e
Show file tree
Hide file tree
Showing 289 changed files with 13 additions and 364 deletions.
@@ -177,8 +177,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/rule-type-list.json",
ruleTypesData = JSON.parse(cat(path.resolve(ruleTypes)));

RULE_FILES
.map(filename => [filename, path.basename(filename, ".js")])
@@ -189,7 +189,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 || []
});
@@ -201,20 +201,20 @@ function generateRuleIndexPage() {
fixable: !!rule.meta.fixable,
hasSuggestions: !!rule.meta.hasSuggestions
},
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.types = ruleTypesData.types.filter(ruleType => !!ruleType.rules);

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

output.to(outputFile);
}
@@ -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", "displayName": "Possible Problems", "description": "These rules relate to possible logic errors in code:" },
{ "name": "suggestion", "displayName": "Suggestions", "description": "These rules suggest alternate ways of doing things:" },
{ "name": "layout", "displayName": "Layout & Formatting", "description": "These rules care about how the code looks rather than how it executes:" }
],
"deprecated": {
"name": "Deprecated",
@@ -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"
},
@@ -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"
},
@@ -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"
},
@@ -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"
},
@@ -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"
},
@@ -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"
},
@@ -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"
},