diff --git a/lib/cli-engine.js b/lib/cli-engine.js index 5b52459ac83..7b0a9d03cb6 100644 --- a/lib/cli-engine.js +++ b/lib/cli-engine.js @@ -48,6 +48,7 @@ const resolver = new ModuleResolver(); * @property {string[]} envs An array of environments to load. * @property {string[]} extensions An array of file extensions to check. * @property {boolean|Function} fix Execute in autofix mode. If a function, should return a boolean. + * @property {string[]} fixTypes Array of rule types to apply fixes for. * @property {string[]} globals An array of global variables to declare. * @property {boolean} ignore False disables use of .eslintignore. * @property {string} ignorePath The ignore file to use instead of .eslintignore. @@ -174,7 +175,6 @@ function processText(text, configHelper, filename, fix, allowInlineConfig, repor } const autofixingEnabled = typeof fix !== "undefined" && (!processor || processor.supportsAutofix); - const fixedResult = linter.verifyAndFix(text, config, { filename: effectiveFilename, allowInlineConfig, @@ -183,7 +183,6 @@ function processText(text, configHelper, filename, fix, allowInlineConfig, repor preprocess: processor && (rawText => processor.preprocess(rawText, effectiveFilename)), postprocess: processor && (problemLists => processor.postprocess(problemLists, effectiveFilename)) }); - const stats = calculateStatsPerFile(fixedResult.messages); const result = { @@ -429,6 +428,23 @@ class CLIEngine { */ this._lintResultCache = new LintResultCache(cacheFile, this.config); } + + // setup special filter for fixes + if (this.options.fixTypes && this.options.fixTypes.length > 0) { + + // convert to Set for faster lookup + const fixTypes = new Set(this.options.fixTypes); + + // save original value of options.fix in case it's a function + const originalFix = this.options.fix; + + this.options.fix = (lintResult) => { + const rules = this.getRules(); + const matches = fixTypes.has(rules.get(lintResult.ruleId).meta.type); + return matches && (typeof originalFix === "function" ? originalFix(lintResult) : true); + }; + } + } getRules() { diff --git a/lib/cli.js b/lib/cli.js index f854015fe9c..f67eb7274ff 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -64,6 +64,7 @@ function translateOptions(cliOptions) { cacheFile: cliOptions.cacheFile, cacheLocation: cliOptions.cacheLocation, fix: (cliOptions.fix || cliOptions.fixDryRun) && (cliOptions.quiet ? quietFixPredicate : true), + fixTypes: cliOptions.fixType, allowInlineConfig: cliOptions.inlineConfig, reportUnusedDisableDirectives: cliOptions.reportUnusedDisableDirectives }; @@ -187,8 +188,12 @@ const cli = { return 2; } - const engine = new CLIEngine(translateOptions(currentOptions)); + if (currentOptions.fixType && !currentOptions.fix && !currentOptions.fixDryRun) { + log.error("The --fix-type option requires either --fix or --fix-dry-run."); + return 2; + } + const engine = new CLIEngine(translateOptions(currentOptions)); const report = useStdin ? engine.executeOnText(text, currentOptions.stdinFilename, true) : engine.executeOnFiles(files); if (currentOptions.fix) { diff --git a/lib/options.js b/lib/options.js index 9265d151d5c..3f289220664 100644 --- a/lib/options.js +++ b/lib/options.js @@ -97,6 +97,11 @@ module.exports = optionator({ default: false, description: "Automatically fix problems without saving the changes to the file system" }, + { + option: "fix-type", + type: "Array", + description: "Specify the types of fixes to apply" + }, { heading: "Ignoring files" }, diff --git a/lib/rules/accessor-pairs.js b/lib/rules/accessor-pairs.js index 68607295438..032e8943057 100644 --- a/lib/rules/accessor-pairs.js +++ b/lib/rules/accessor-pairs.js @@ -72,12 +72,15 @@ function isPropertyDescriptor(node) { module.exports = { meta: { + type: "suggestion", + docs: { description: "enforce getter and setter pairs in objects", category: "Best Practices", recommended: false, url: "https://eslint.org/docs/rules/accessor-pairs" }, + schema: [{ type: "object", properties: { @@ -90,6 +93,7 @@ module.exports = { }, additionalProperties: false }], + messages: { getter: "Getter is not present.", setter: "Setter is not present." diff --git a/lib/rules/array-bracket-newline.js b/lib/rules/array-bracket-newline.js index e8f7c502ef4..31c2c76f68b 100644 --- a/lib/rules/array-bracket-newline.js +++ b/lib/rules/array-bracket-newline.js @@ -13,13 +13,17 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "style", + 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" }, + fixable: "whitespace", + schema: [ { oneOf: [ @@ -42,6 +46,7 @@ module.exports = { ] } ], + messages: { unexpectedOpeningLinebreak: "There should be no linebreak after '['.", unexpectedClosingLinebreak: "There should be no linebreak before ']'.", diff --git a/lib/rules/array-bracket-spacing.js b/lib/rules/array-bracket-spacing.js index f46c3978dfa..764fc2d959f 100644 --- a/lib/rules/array-bracket-spacing.js +++ b/lib/rules/array-bracket-spacing.js @@ -12,13 +12,17 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "style", + docs: { description: "enforce consistent spacing inside array brackets", category: "Stylistic Issues", recommended: false, url: "https://eslint.org/docs/rules/array-bracket-spacing" }, + fixable: "whitespace", + schema: [ { enum: ["always", "never"] @@ -39,6 +43,7 @@ module.exports = { additionalProperties: false } ], + messages: { unexpectedSpaceAfter: "There should be no space after '{{tokenValue}}'.", unexpectedSpaceBefore: "There should be no space before '{{tokenValue}}'.", diff --git a/lib/rules/array-callback-return.js b/lib/rules/array-callback-return.js index 4d374cf2240..70ff7f0a7ae 100644 --- a/lib/rules/array-callback-return.js +++ b/lib/rules/array-callback-return.js @@ -141,6 +141,8 @@ function isCallbackOfArrayMethod(node) { module.exports = { meta: { + type: "suggestion", + docs: { description: "enforce `return` statements in callbacks of array methods", category: "Best Practices", diff --git a/lib/rules/array-element-newline.js b/lib/rules/array-element-newline.js index c4caf8c71c0..16c76e7dbb9 100644 --- a/lib/rules/array-element-newline.js +++ b/lib/rules/array-element-newline.js @@ -13,13 +13,17 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "style", + docs: { description: "enforce line breaks after each array element", category: "Stylistic Issues", recommended: false, url: "https://eslint.org/docs/rules/array-element-newline" }, + fixable: "whitespace", + schema: [ { oneOf: [ diff --git a/lib/rules/arrow-body-style.js b/lib/rules/arrow-body-style.js index 92068c75c42..c2ce3b59e4f 100644 --- a/lib/rules/arrow-body-style.js +++ b/lib/rules/arrow-body-style.js @@ -16,6 +16,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "suggestion", + docs: { description: "require braces around arrow function bodies", category: "ECMAScript 6", diff --git a/lib/rules/arrow-parens.js b/lib/rules/arrow-parens.js index 7a6ef6f8bed..035c970a4a9 100644 --- a/lib/rules/arrow-parens.js +++ b/lib/rules/arrow-parens.js @@ -16,6 +16,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "suggestion", + docs: { description: "require parentheses around arrow function arguments", category: "ECMAScript 6", diff --git a/lib/rules/arrow-spacing.js b/lib/rules/arrow-spacing.js index a1db18fc910..5cfc061d477 100644 --- a/lib/rules/arrow-spacing.js +++ b/lib/rules/arrow-spacing.js @@ -16,6 +16,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "suggestion", + docs: { description: "enforce consistent spacing before and after the arrow in arrow functions", category: "ECMAScript 6", diff --git a/lib/rules/block-scoped-var.js b/lib/rules/block-scoped-var.js index 1000fbc83c6..053cfc334cd 100644 --- a/lib/rules/block-scoped-var.js +++ b/lib/rules/block-scoped-var.js @@ -10,6 +10,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "enforce the use of variables within the scope they are defined", category: "Best Practices", diff --git a/lib/rules/block-spacing.js b/lib/rules/block-spacing.js index 838c2c7016b..8bfd51024f5 100644 --- a/lib/rules/block-spacing.js +++ b/lib/rules/block-spacing.js @@ -13,6 +13,8 @@ const util = require("../util/ast-utils"); module.exports = { meta: { + type: "style", + docs: { description: "disallow or enforce spaces inside of blocks after opening block and before closing block", category: "Stylistic Issues", diff --git a/lib/rules/brace-style.js b/lib/rules/brace-style.js index 236a01096ab..152d1463d87 100644 --- a/lib/rules/brace-style.js +++ b/lib/rules/brace-style.js @@ -13,6 +13,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "style", + docs: { description: "enforce consistent brace style for blocks", category: "Stylistic Issues", diff --git a/lib/rules/callback-return.js b/lib/rules/callback-return.js index f55fed87db0..c5263cde46b 100644 --- a/lib/rules/callback-return.js +++ b/lib/rules/callback-return.js @@ -10,6 +10,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "require `return` statements after callbacks", category: "Node.js and CommonJS", diff --git a/lib/rules/camelcase.js b/lib/rules/camelcase.js index 3005963ab04..ff305788dcb 100644 --- a/lib/rules/camelcase.js +++ b/lib/rules/camelcase.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "style", + docs: { description: "enforce camelcase naming convention", category: "Stylistic Issues", diff --git a/lib/rules/capitalized-comments.js b/lib/rules/capitalized-comments.js index 8fabde287cc..24a66eab53c 100644 --- a/lib/rules/capitalized-comments.js +++ b/lib/rules/capitalized-comments.js @@ -108,13 +108,17 @@ function createRegExpForIgnorePatterns(normalizedOptions) { module.exports = { meta: { + type: "style", + 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" }, + fixable: "code", + schema: [ { enum: ["always", "never"] }, { diff --git a/lib/rules/class-methods-use-this.js b/lib/rules/class-methods-use-this.js index b7d94135bb7..a15ab6b89e4 100644 --- a/lib/rules/class-methods-use-this.js +++ b/lib/rules/class-methods-use-this.js @@ -11,12 +11,15 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "enforce that class methods utilize `this`", category: "Best Practices", recommended: false, url: "https://eslint.org/docs/rules/class-methods-use-this" }, + schema: [{ type: "object", properties: { diff --git a/lib/rules/comma-dangle.js b/lib/rules/comma-dangle.js index 9bc6c3fa8cc..d2560b01122 100644 --- a/lib/rules/comma-dangle.js +++ b/lib/rules/comma-dangle.js @@ -76,13 +76,17 @@ function normalizeOptions(optionValue) { module.exports = { meta: { + type: "style", + docs: { description: "require or disallow trailing commas", category: "Stylistic Issues", recommended: false, url: "https://eslint.org/docs/rules/comma-dangle" }, + fixable: "code", + schema: { definitions: { value: { diff --git a/lib/rules/comma-spacing.js b/lib/rules/comma-spacing.js index d3f82b3a4b9..83c7a94b013 100644 --- a/lib/rules/comma-spacing.js +++ b/lib/rules/comma-spacing.js @@ -12,6 +12,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "style", + docs: { description: "enforce consistent spacing before and after commas", category: "Stylistic Issues", diff --git a/lib/rules/comma-style.js b/lib/rules/comma-style.js index 7f996b344d4..fdf078bade1 100644 --- a/lib/rules/comma-style.js +++ b/lib/rules/comma-style.js @@ -13,13 +13,17 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "style", + docs: { description: "enforce consistent comma style", category: "Stylistic Issues", recommended: false, url: "https://eslint.org/docs/rules/comma-style" }, + fixable: "code", + schema: [ { enum: ["first", "last"] @@ -37,6 +41,7 @@ module.exports = { additionalProperties: false } ], + messages: { unexpectedLineBeforeAndAfterComma: "Bad line breaking before and after ','.", expectedCommaFirst: "',' should be placed first.", diff --git a/lib/rules/complexity.js b/lib/rules/complexity.js index bc66d303b63..af583c02791 100644 --- a/lib/rules/complexity.js +++ b/lib/rules/complexity.js @@ -20,6 +20,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "suggestion", + docs: { description: "enforce a maximum cyclomatic complexity allowed in a program", category: "Best Practices", diff --git a/lib/rules/computed-property-spacing.js b/lib/rules/computed-property-spacing.js index 060b2c5b40d..1cde4c5c47b 100644 --- a/lib/rules/computed-property-spacing.js +++ b/lib/rules/computed-property-spacing.js @@ -12,6 +12,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "style", + docs: { description: "enforce consistent spacing inside computed property brackets", category: "Stylistic Issues", diff --git a/lib/rules/consistent-return.js b/lib/rules/consistent-return.js index 6185d094fb5..ffd7ef20589 100644 --- a/lib/rules/consistent-return.js +++ b/lib/rules/consistent-return.js @@ -53,6 +53,8 @@ function isClassConstructor(node) { module.exports = { meta: { + type: "suggestion", + docs: { description: "require `return` statements to either always or never specify values", category: "Best Practices", diff --git a/lib/rules/consistent-this.js b/lib/rules/consistent-this.js index 5cc3a647dab..935344cea6f 100644 --- a/lib/rules/consistent-this.js +++ b/lib/rules/consistent-this.js @@ -10,6 +10,8 @@ module.exports = { meta: { + type: "style", + docs: { description: "enforce consistent naming when capturing the current execution context", category: "Stylistic Issues", diff --git a/lib/rules/constructor-super.js b/lib/rules/constructor-super.js index 3cbc2f59f89..c9fe8cec884 100644 --- a/lib/rules/constructor-super.js +++ b/lib/rules/constructor-super.js @@ -92,6 +92,8 @@ function isPossibleConstructor(node) { module.exports = { meta: { + type: "suggestion", + docs: { description: "require `super()` calls in constructors", category: "ECMAScript 6", diff --git a/lib/rules/curly.js b/lib/rules/curly.js index ad8da821c1c..ee12da71352 100644 --- a/lib/rules/curly.js +++ b/lib/rules/curly.js @@ -16,6 +16,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "suggestion", + docs: { description: "enforce consistent brace style for all control statements", category: "Best Practices", diff --git a/lib/rules/default-case.js b/lib/rules/default-case.js index cf123198f4a..3061265ed8e 100644 --- a/lib/rules/default-case.js +++ b/lib/rules/default-case.js @@ -12,6 +12,8 @@ const DEFAULT_COMMENT_PATTERN = /^no default$/i; module.exports = { meta: { + type: "suggestion", + docs: { description: "require `default` cases in `switch` statements", category: "Best Practices", diff --git a/lib/rules/dot-location.js b/lib/rules/dot-location.js index 34d2d4eaab8..710f3e97855 100644 --- a/lib/rules/dot-location.js +++ b/lib/rules/dot-location.js @@ -13,6 +13,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "suggestion", + docs: { description: "enforce consistent newlines before and after dots", category: "Best Practices", diff --git a/lib/rules/dot-notation.js b/lib/rules/dot-notation.js index a7062df8a5b..55ccea4ce38 100644 --- a/lib/rules/dot-notation.js +++ b/lib/rules/dot-notation.js @@ -19,6 +19,8 @@ const keywords = require("../util/keywords"); module.exports = { meta: { + type: "suggestion", + docs: { description: "enforce dot notation whenever possible", category: "Best Practices", diff --git a/lib/rules/eol-last.js b/lib/rules/eol-last.js index 3ecf4227399..7a748178f6c 100644 --- a/lib/rules/eol-last.js +++ b/lib/rules/eol-last.js @@ -16,18 +16,23 @@ const lodash = require("lodash"); module.exports = { meta: { + type: "style", + docs: { description: "require or disallow newline at the end of files", category: "Stylistic Issues", recommended: false, url: "https://eslint.org/docs/rules/eol-last" }, + fixable: "whitespace", + schema: [ { enum: ["always", "never", "unix", "windows"] } ], + messages: { missing: "Newline required at end of file but not found.", unexpected: "Newline not allowed at end of file." diff --git a/lib/rules/eqeqeq.js b/lib/rules/eqeqeq.js index 2c5e9ae9e4f..715c5ce7c02 100644 --- a/lib/rules/eqeqeq.js +++ b/lib/rules/eqeqeq.js @@ -17,6 +17,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "suggestion", + docs: { description: "require the use of `===` and `!==`", category: "Best Practices", diff --git a/lib/rules/for-direction.js b/lib/rules/for-direction.js index b93c4c2caa4..db079b26793 100644 --- a/lib/rules/for-direction.js +++ b/lib/rules/for-direction.js @@ -11,14 +11,18 @@ module.exports = { meta: { + type: "problem", + 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" }, + fixable: null, schema: [], + messages: { incorrectDirection: "The update clause in this loop moves the variable in the wrong direction." } diff --git a/lib/rules/func-call-spacing.js b/lib/rules/func-call-spacing.js index 9aae3e2517e..8a812c82565 100644 --- a/lib/rules/func-call-spacing.js +++ b/lib/rules/func-call-spacing.js @@ -17,6 +17,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "style", + docs: { description: "require or disallow spacing between function identifiers and their invocations", category: "Stylistic Issues", @@ -25,6 +27,7 @@ module.exports = { }, fixable: "whitespace", + schema: { anyOf: [ { @@ -58,6 +61,7 @@ module.exports = { } ] }, + messages: { unexpected: "Unexpected newline between function name and paren.", missing: "Missing space between function name and paren." diff --git a/lib/rules/func-name-matching.js b/lib/rules/func-name-matching.js index 89c07c3514c..5b9d7fcb62d 100644 --- a/lib/rules/func-name-matching.js +++ b/lib/rules/func-name-matching.js @@ -70,6 +70,8 @@ const optionsObject = { module.exports = { meta: { + type: "style", + docs: { description: "require function names to match the name of the variable or property to which they are assigned", category: "Stylistic Issues", @@ -88,6 +90,7 @@ module.exports = { items: [optionsObject] }] }, + messages: { matchProperty: "Function name `{{funcName}}` should match property name `{{name}}`", matchVariable: "Function name `{{funcName}}` should match variable name `{{name}}`", diff --git a/lib/rules/func-names.js b/lib/rules/func-names.js index 31f30291811..ee1234e29f4 100644 --- a/lib/rules/func-names.js +++ b/lib/rules/func-names.js @@ -26,6 +26,8 @@ function isFunctionName(variable) { module.exports = { meta: { + type: "style", + docs: { description: "require or disallow named `function` expressions", category: "Stylistic Issues", @@ -58,6 +60,7 @@ module.exports = { } ] }, + messages: { unnamed: "Unexpected unnamed {{name}}.", named: "Unexpected named {{name}}." diff --git a/lib/rules/func-style.js b/lib/rules/func-style.js index ff48792d29a..9236c59fc8e 100644 --- a/lib/rules/func-style.js +++ b/lib/rules/func-style.js @@ -10,6 +10,8 @@ module.exports = { meta: { + type: "style", + docs: { description: "enforce the consistent use of either `function` declarations or expressions", category: "Stylistic Issues", @@ -31,6 +33,7 @@ module.exports = { additionalProperties: false } ], + messages: { expression: "Expected a function expression.", declaration: "Expected a function declaration." diff --git a/lib/rules/function-paren-newline.js b/lib/rules/function-paren-newline.js index d78e88038e2..20bed8f3f8c 100644 --- a/lib/rules/function-paren-newline.js +++ b/lib/rules/function-paren-newline.js @@ -16,13 +16,17 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "style", + docs: { description: "enforce consistent line breaks inside function parentheses", category: "Stylistic Issues", recommended: false, url: "https://eslint.org/docs/rules/function-paren-newline" }, + fixable: "whitespace", + schema: [ { oneOf: [ @@ -42,6 +46,7 @@ module.exports = { ] } ], + messages: { expectedBefore: "Expected newline before ')'.", expectedAfter: "Expected newline after '('.", diff --git a/lib/rules/generator-star-spacing.js b/lib/rules/generator-star-spacing.js index 97868dd3fa9..83bdeeebe7c 100644 --- a/lib/rules/generator-star-spacing.js +++ b/lib/rules/generator-star-spacing.js @@ -27,6 +27,8 @@ const OVERRIDE_SCHEMA = { module.exports = { meta: { + type: "suggestion", + docs: { description: "enforce consistent spacing around `*` operators in generator functions", category: "ECMAScript 6", @@ -56,6 +58,7 @@ module.exports = { ] } ], + messages: { missingBefore: "Missing space before *.", missingAfter: "Missing space after *.", diff --git a/lib/rules/getter-return.js b/lib/rules/getter-return.js index 452ba49f595..dc3d9d6b627 100644 --- a/lib/rules/getter-return.js +++ b/lib/rules/getter-return.js @@ -44,13 +44,17 @@ function getId(node) { module.exports = { meta: { + type: "problem", + docs: { description: "enforce `return` statements in getters", category: "Possible Errors", recommended: true, url: "https://eslint.org/docs/rules/getter-return" }, + fixable: null, + schema: [ { type: "object", @@ -62,6 +66,7 @@ module.exports = { additionalProperties: false } ], + messages: { expected: "Expected to return a value in {{name}}.", expectedAlways: "Expected {{name}} to always return a value." diff --git a/lib/rules/global-require.js b/lib/rules/global-require.js index a5f5335d01d..6576cfb6a1f 100644 --- a/lib/rules/global-require.js +++ b/lib/rules/global-require.js @@ -48,6 +48,8 @@ function isShadowed(scope, node) { module.exports = { meta: { + type: "suggestion", + docs: { description: "require `require()` calls to be placed at top-level module scope", category: "Node.js and CommonJS", diff --git a/lib/rules/guard-for-in.js b/lib/rules/guard-for-in.js index 0f85e4984aa..6e8452a4844 100644 --- a/lib/rules/guard-for-in.js +++ b/lib/rules/guard-for-in.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "require `for-in` loops to include an `if` statement", category: "Best Practices", diff --git a/lib/rules/handle-callback-err.js b/lib/rules/handle-callback-err.js index f6e6c108ce1..c62016d5895 100644 --- a/lib/rules/handle-callback-err.js +++ b/lib/rules/handle-callback-err.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "require error handling in callbacks", category: "Node.js and CommonJS", diff --git a/lib/rules/id-blacklist.js b/lib/rules/id-blacklist.js index ba9b5d4b398..b16ca682172 100644 --- a/lib/rules/id-blacklist.js +++ b/lib/rules/id-blacklist.js @@ -12,6 +12,8 @@ module.exports = { meta: { + type: "style", + docs: { description: "disallow specified identifiers", category: "Stylistic Issues", diff --git a/lib/rules/id-length.js b/lib/rules/id-length.js index eaed26217dd..731eddf50fc 100644 --- a/lib/rules/id-length.js +++ b/lib/rules/id-length.js @@ -12,6 +12,8 @@ module.exports = { meta: { + type: "style", + docs: { description: "enforce minimum and maximum identifier lengths", category: "Stylistic Issues", diff --git a/lib/rules/id-match.js b/lib/rules/id-match.js index 608ef17d114..d982a759d92 100644 --- a/lib/rules/id-match.js +++ b/lib/rules/id-match.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "style", + docs: { description: "require identifiers to match a specified regular expression", category: "Stylistic Issues", diff --git a/lib/rules/implicit-arrow-linebreak.js b/lib/rules/implicit-arrow-linebreak.js index a7ad1122b50..7602a82e2c2 100644 --- a/lib/rules/implicit-arrow-linebreak.js +++ b/lib/rules/implicit-arrow-linebreak.js @@ -9,13 +9,17 @@ //------------------------------------------------------------------------------ module.exports = { meta: { + type: "style", + docs: { description: "enforce the location of arrow function bodies", category: "Stylistic Issues", recommended: false, url: "https://eslint.org/docs/rules/implicit-arrow-linebreak" }, + fixable: "whitespace", + schema: [ { enum: ["beside", "below"] diff --git a/lib/rules/indent-legacy.js b/lib/rules/indent-legacy.js index e6dc92163b0..528e46b2dd5 100644 --- a/lib/rules/indent-legacy.js +++ b/lib/rules/indent-legacy.js @@ -21,6 +21,8 @@ const astUtils = require("../util/ast-utils"); /* istanbul ignore next: this rule has known coverage issues, but it's deprecated and shouldn't be updated in the future anyway. */ module.exports = { meta: { + type: "style", + docs: { description: "enforce consistent indentation", category: "Stylistic Issues", @@ -30,7 +32,6 @@ module.exports = { }, deprecated: true, - fixable: "whitespace", schema: [ diff --git a/lib/rules/indent.js b/lib/rules/indent.js index 940c080a037..5c8ed43885b 100644 --- a/lib/rules/indent.js +++ b/lib/rules/indent.js @@ -490,6 +490,8 @@ const ELEMENT_LIST_SCHEMA = { module.exports = { meta: { + type: "style", + docs: { description: "enforce consistent indentation", category: "Stylistic Issues", diff --git a/lib/rules/init-declarations.js b/lib/rules/init-declarations.js index 412b96dc0ab..755090917f9 100644 --- a/lib/rules/init-declarations.js +++ b/lib/rules/init-declarations.js @@ -44,6 +44,8 @@ function isInitialized(node) { module.exports = { meta: { + type: "suggestion", + docs: { description: "require or disallow initialization in variable declarations", category: "Variables", diff --git a/lib/rules/jsx-quotes.js b/lib/rules/jsx-quotes.js index 3dd9567d737..cfc0a391cb3 100644 --- a/lib/rules/jsx-quotes.js +++ b/lib/rules/jsx-quotes.js @@ -38,6 +38,8 @@ const QUOTE_SETTINGS = { module.exports = { meta: { + type: "style", + docs: { description: "enforce the consistent use of either double or single quotes in JSX attributes", category: "Stylistic Issues", diff --git a/lib/rules/key-spacing.js b/lib/rules/key-spacing.js index 75578b2c747..9adaeb96df9 100644 --- a/lib/rules/key-spacing.js +++ b/lib/rules/key-spacing.js @@ -128,6 +128,8 @@ const messages = { module.exports = { meta: { + type: "style", + docs: { description: "enforce consistent spacing between keys and values in object literal properties", category: "Stylistic Issues", @@ -360,10 +362,9 @@ module.exports = { */ function isKeyValueProperty(property) { return !( - property.method || + (property.method || property.shorthand || - property.kind !== "init" || - property.type !== "Property" // Could be "ExperimentalSpreadProperty" or "SpreadElement" + property.kind !== "init" || property.type !== "Property") // Could be "ExperimentalSpreadProperty" or "SpreadElement" ); } diff --git a/lib/rules/keyword-spacing.js b/lib/rules/keyword-spacing.js index 2a66779e7aa..ca1ce055635 100644 --- a/lib/rules/keyword-spacing.js +++ b/lib/rules/keyword-spacing.js @@ -65,6 +65,8 @@ function isCloseParenOfTemplate(token) { module.exports = { meta: { + type: "style", + docs: { description: "enforce consistent spacing before and after keywords", category: "Stylistic Issues", diff --git a/lib/rules/line-comment-position.js b/lib/rules/line-comment-position.js index 7f45a94b6b5..92b8ce75185 100644 --- a/lib/rules/line-comment-position.js +++ b/lib/rules/line-comment-position.js @@ -12,6 +12,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "style", + docs: { description: "enforce position of line comments", category: "Stylistic Issues", diff --git a/lib/rules/linebreak-style.js b/lib/rules/linebreak-style.js index cd432dbcca1..4568d4038d0 100644 --- a/lib/rules/linebreak-style.js +++ b/lib/rules/linebreak-style.js @@ -17,6 +17,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "style", + docs: { description: "enforce consistent linebreak style", category: "Stylistic Issues", diff --git a/lib/rules/lines-around-comment.js b/lib/rules/lines-around-comment.js index 67fd2032b3e..a62b8291dff 100644 --- a/lib/rules/lines-around-comment.js +++ b/lib/rules/lines-around-comment.js @@ -52,6 +52,8 @@ function getCommentLineNums(comments) { module.exports = { meta: { + type: "style", + docs: { description: "require empty lines around comments", category: "Stylistic Issues", diff --git a/lib/rules/lines-around-directive.js b/lib/rules/lines-around-directive.js index e8d613a41f0..d0de9ed1716 100644 --- a/lib/rules/lines-around-directive.js +++ b/lib/rules/lines-around-directive.js @@ -14,6 +14,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "style", + docs: { description: "require or disallow newlines around directives", category: "Stylistic Issues", @@ -21,6 +23,7 @@ module.exports = { replacedBy: ["padding-line-between-statements"], url: "https://eslint.org/docs/rules/lines-around-directive" }, + schema: [{ oneOf: [ { @@ -41,6 +44,7 @@ module.exports = { } ] }], + fixable: "whitespace", deprecated: true }, diff --git a/lib/rules/lines-between-class-members.js b/lib/rules/lines-between-class-members.js index 8d4e6dd8c18..563117628db 100644 --- a/lib/rules/lines-between-class-members.js +++ b/lib/rules/lines-between-class-members.js @@ -12,6 +12,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "style", + docs: { description: "require or disallow an empty line between class members", category: "Stylistic Issues", diff --git a/lib/rules/max-classes-per-file.js b/lib/rules/max-classes-per-file.js index bf6b4ba31c6..3193a731c94 100644 --- a/lib/rules/max-classes-per-file.js +++ b/lib/rules/max-classes-per-file.js @@ -15,18 +15,22 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "enforce a maximum number of classes per file", category: "Best Practices", recommended: false, url: "https://eslint.org/docs/rules/max-classes-per-file" }, + schema: [ { type: "integer", minimum: 1 } ], + messages: { maximumExceeded: "Number of classes per file must not exceed {{ max }}" } diff --git a/lib/rules/max-depth.js b/lib/rules/max-depth.js index 368dcfa6681..7c21cad7340 100644 --- a/lib/rules/max-depth.js +++ b/lib/rules/max-depth.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "style", + docs: { description: "enforce a maximum depth that blocks can be nested", category: "Stylistic Issues", diff --git a/lib/rules/max-len.js b/lib/rules/max-len.js index 88a388309b2..b869a9ec3ec 100644 --- a/lib/rules/max-len.js +++ b/lib/rules/max-len.js @@ -65,6 +65,8 @@ const OPTIONS_OR_INTEGER_SCHEMA = { module.exports = { meta: { + type: "style", + docs: { description: "enforce a maximum line length", category: "Stylistic Issues", diff --git a/lib/rules/max-lines-per-function.js b/lib/rules/max-lines-per-function.js index ccf6304e4b2..10675529853 100644 --- a/lib/rules/max-lines-per-function.js +++ b/lib/rules/max-lines-per-function.js @@ -69,6 +69,8 @@ function getCommentLineNumbers(comments) { module.exports = { meta: { + type: "style", + docs: { description: "enforce a maximum number of line of code in a function", category: "Stylistic Issues", diff --git a/lib/rules/max-lines.js b/lib/rules/max-lines.js index 7eb959795ab..957db9ee734 100644 --- a/lib/rules/max-lines.js +++ b/lib/rules/max-lines.js @@ -17,6 +17,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "style", + docs: { description: "enforce a maximum number of lines per file", category: "Stylistic Issues", diff --git a/lib/rules/max-nested-callbacks.js b/lib/rules/max-nested-callbacks.js index 8cc80ae7aab..f3ae73216b5 100644 --- a/lib/rules/max-nested-callbacks.js +++ b/lib/rules/max-nested-callbacks.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "style", + docs: { description: "enforce a maximum depth that callbacks can be nested", category: "Stylistic Issues", diff --git a/lib/rules/max-params.js b/lib/rules/max-params.js index 4089e8ae899..ec9fdffc19b 100644 --- a/lib/rules/max-params.js +++ b/lib/rules/max-params.js @@ -19,6 +19,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "style", + docs: { description: "enforce a maximum number of parameters in function definitions", category: "Stylistic Issues", diff --git a/lib/rules/max-statements-per-line.js b/lib/rules/max-statements-per-line.js index 566f04ab53b..819d2347c03 100644 --- a/lib/rules/max-statements-per-line.js +++ b/lib/rules/max-statements-per-line.js @@ -16,6 +16,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "style", + docs: { description: "enforce a maximum number of statements allowed per line", category: "Stylistic Issues", diff --git a/lib/rules/max-statements.js b/lib/rules/max-statements.js index 525790df806..ce930a3a1a8 100644 --- a/lib/rules/max-statements.js +++ b/lib/rules/max-statements.js @@ -19,6 +19,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "style", + docs: { description: "enforce a maximum number of statements allowed in function blocks", category: "Stylistic Issues", diff --git a/lib/rules/multiline-comment-style.js b/lib/rules/multiline-comment-style.js index 5dd39e00a77..6eb95438007 100644 --- a/lib/rules/multiline-comment-style.js +++ b/lib/rules/multiline-comment-style.js @@ -12,12 +12,15 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "style", + docs: { description: "enforce a particular style for multiline comments", category: "Stylistic Issues", recommended: false, url: "https://eslint.org/docs/rules/multiline-comment-style" }, + fixable: "whitespace", schema: [{ enum: ["starred-block", "separate-lines", "bare-block"] }] }, diff --git a/lib/rules/multiline-ternary.js b/lib/rules/multiline-ternary.js index 6a22a1113c1..34a52cf4fa9 100644 --- a/lib/rules/multiline-ternary.js +++ b/lib/rules/multiline-ternary.js @@ -13,12 +13,15 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "style", + docs: { description: "enforce newlines between operands of ternary expressions", category: "Stylistic Issues", recommended: false, url: "https://eslint.org/docs/rules/multiline-ternary" }, + schema: [ { enum: ["always", "always-multiline", "never"] diff --git a/lib/rules/new-cap.js b/lib/rules/new-cap.js index cc33e3b8175..98bf286d507 100644 --- a/lib/rules/new-cap.js +++ b/lib/rules/new-cap.js @@ -74,6 +74,8 @@ function calculateCapIsNewExceptions(config) { module.exports = { meta: { + type: "style", + docs: { description: "require constructor names to begin with a capital letter", category: "Stylistic Issues", diff --git a/lib/rules/new-parens.js b/lib/rules/new-parens.js index fab302000c9..00a7524aab8 100644 --- a/lib/rules/new-parens.js +++ b/lib/rules/new-parens.js @@ -21,6 +21,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "style", + docs: { description: "require parentheses when invoking a constructor with no arguments", category: "Stylistic Issues", @@ -29,7 +31,6 @@ module.exports = { }, schema: [], - fixable: "code" }, diff --git a/lib/rules/newline-after-var.js b/lib/rules/newline-after-var.js index 62ccb3db29e..69e5929d44f 100644 --- a/lib/rules/newline-after-var.js +++ b/lib/rules/newline-after-var.js @@ -18,6 +18,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "style", + docs: { description: "require or disallow an empty line after variable declarations", category: "Stylistic Issues", @@ -33,7 +35,6 @@ module.exports = { ], fixable: "whitespace", - deprecated: true }, diff --git a/lib/rules/newline-before-return.js b/lib/rules/newline-before-return.js index 5bc1f7031b0..53eeba1edad 100644 --- a/lib/rules/newline-before-return.js +++ b/lib/rules/newline-before-return.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "style", + docs: { description: "require an empty line before `return` statements", category: "Stylistic Issues", @@ -18,6 +20,7 @@ module.exports = { replacedBy: ["padding-line-between-statements"], url: "https://eslint.org/docs/rules/newline-before-return" }, + fixable: "whitespace", schema: [], deprecated: true diff --git a/lib/rules/newline-per-chained-call.js b/lib/rules/newline-per-chained-call.js index 2adcdfe45a6..97a74492659 100644 --- a/lib/rules/newline-per-chained-call.js +++ b/lib/rules/newline-per-chained-call.js @@ -14,13 +14,17 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "style", + docs: { description: "require a newline after each call in a method chain", category: "Stylistic Issues", recommended: false, url: "https://eslint.org/docs/rules/newline-per-chained-call" }, + fixable: "whitespace", + schema: [{ type: "object", properties: { diff --git a/lib/rules/no-alert.js b/lib/rules/no-alert.js index 1c08460f340..21f10b3c399 100644 --- a/lib/rules/no-alert.js +++ b/lib/rules/no-alert.js @@ -74,6 +74,8 @@ function isGlobalThisReferenceOrGlobalWindow(scope, node) { module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow the use of `alert`, `confirm`, and `prompt`", category: "Best Practices", diff --git a/lib/rules/no-array-constructor.js b/lib/rules/no-array-constructor.js index 51676f78211..b867cb61329 100644 --- a/lib/rules/no-array-constructor.js +++ b/lib/rules/no-array-constructor.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "style", + docs: { description: "disallow `Array` constructors", category: "Stylistic Issues", diff --git a/lib/rules/no-async-promise-executor.js b/lib/rules/no-async-promise-executor.js index 55d489eb6dd..fc65f539a3e 100644 --- a/lib/rules/no-async-promise-executor.js +++ b/lib/rules/no-async-promise-executor.js @@ -10,12 +10,15 @@ module.exports = { meta: { + type: "problem", + docs: { description: "disallow using an async function as a Promise executor", category: "Possible Errors", recommended: false, url: "https://eslint.org/docs/rules/no-async-promise-executor" }, + fixable: null, schema: [] }, diff --git a/lib/rules/no-await-in-loop.js b/lib/rules/no-await-in-loop.js index ef0bda90bf9..9ca89866a6e 100644 --- a/lib/rules/no-await-in-loop.js +++ b/lib/rules/no-await-in-loop.js @@ -55,13 +55,17 @@ function isLooped(node, parent) { module.exports = { meta: { + type: "problem", + docs: { description: "disallow `await` inside of loops", category: "Possible Errors", recommended: false, url: "https://eslint.org/docs/rules/no-await-in-loop" }, + schema: [], + messages: { unexpectedAwait: "Unexpected `await` inside a loop." } diff --git a/lib/rules/no-bitwise.js b/lib/rules/no-bitwise.js index 36bbdaf349c..ba0ff9c950e 100644 --- a/lib/rules/no-bitwise.js +++ b/lib/rules/no-bitwise.js @@ -22,6 +22,8 @@ const BITWISE_OPERATORS = [ module.exports = { meta: { + type: "style", + docs: { description: "disallow bitwise operators", category: "Stylistic Issues", diff --git a/lib/rules/no-buffer-constructor.js b/lib/rules/no-buffer-constructor.js index 51f78edb1fe..a1f2a1d1ad7 100644 --- a/lib/rules/no-buffer-constructor.js +++ b/lib/rules/no-buffer-constructor.js @@ -10,13 +10,17 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow use of the `Buffer()` constructor", category: "Node.js and CommonJS", recommended: false, url: "https://eslint.org/docs/rules/no-buffer-constructor" }, + schema: [], + messages: { deprecated: "{{expr}} is deprecated. Use Buffer.from(), Buffer.alloc(), or Buffer.allocUnsafe() instead." } diff --git a/lib/rules/no-caller.js b/lib/rules/no-caller.js index 9756b212ffe..1703ad867dc 100644 --- a/lib/rules/no-caller.js +++ b/lib/rules/no-caller.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow the use of `arguments.caller` or `arguments.callee`", category: "Best Practices", diff --git a/lib/rules/no-case-declarations.js b/lib/rules/no-case-declarations.js index c05795200e6..1d54e221625 100644 --- a/lib/rules/no-case-declarations.js +++ b/lib/rules/no-case-declarations.js @@ -10,6 +10,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow lexical declarations in case clauses", category: "Best Practices", diff --git a/lib/rules/no-catch-shadow.js b/lib/rules/no-catch-shadow.js index f749490f31e..77ac81042e4 100644 --- a/lib/rules/no-catch-shadow.js +++ b/lib/rules/no-catch-shadow.js @@ -18,6 +18,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow `catch` clause parameters from shadowing variables in the outer scope", category: "Variables", @@ -25,8 +27,8 @@ module.exports = { url: "https://eslint.org/docs/rules/no-catch-shadow", replacedBy: ["no-shadow"] }, - deprecated: true, + deprecated: true, schema: [], messages: { diff --git a/lib/rules/no-class-assign.js b/lib/rules/no-class-assign.js index 9b28d40d4a3..60f36eafc3c 100644 --- a/lib/rules/no-class-assign.js +++ b/lib/rules/no-class-assign.js @@ -13,6 +13,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow reassigning class members", category: "ECMAScript 6", diff --git a/lib/rules/no-compare-neg-zero.js b/lib/rules/no-compare-neg-zero.js index 6903bd06544..f5c8d5f417b 100644 --- a/lib/rules/no-compare-neg-zero.js +++ b/lib/rules/no-compare-neg-zero.js @@ -10,14 +10,18 @@ module.exports = { meta: { + type: "problem", + docs: { description: "disallow comparing against -0", category: "Possible Errors", recommended: true, url: "https://eslint.org/docs/rules/no-compare-neg-zero" }, + fixable: null, schema: [], + messages: { unexpected: "Do not use the '{{operator}}' operator to compare against -0." } diff --git a/lib/rules/no-cond-assign.js b/lib/rules/no-cond-assign.js index caf9563e952..aed3e4a7a9b 100644 --- a/lib/rules/no-cond-assign.js +++ b/lib/rules/no-cond-assign.js @@ -19,6 +19,8 @@ const NODE_DESCRIPTIONS = { module.exports = { meta: { + type: "problem", + docs: { description: "disallow assignment operators in conditional expressions", category: "Possible Errors", diff --git a/lib/rules/no-confusing-arrow.js b/lib/rules/no-confusing-arrow.js index 503174e9a67..f18ec194530 100644 --- a/lib/rules/no-confusing-arrow.js +++ b/lib/rules/no-confusing-arrow.js @@ -27,6 +27,8 @@ function isConditional(node) { module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow arrow functions where they could be confused with comparisons", category: "ECMAScript 6", diff --git a/lib/rules/no-console.js b/lib/rules/no-console.js index 5fb3a159be8..aeb9a8cf335 100644 --- a/lib/rules/no-console.js +++ b/lib/rules/no-console.js @@ -17,6 +17,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "problem", + docs: { description: "disallow the use of `console`", category: "Possible Errors", diff --git a/lib/rules/no-const-assign.js b/lib/rules/no-const-assign.js index 3188bd34d3b..7b18f319a06 100644 --- a/lib/rules/no-const-assign.js +++ b/lib/rules/no-const-assign.js @@ -13,6 +13,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow reassigning `const` variables", category: "ECMAScript 6", diff --git a/lib/rules/no-constant-condition.js b/lib/rules/no-constant-condition.js index 48b1fbf689f..88984c36e7f 100644 --- a/lib/rules/no-constant-condition.js +++ b/lib/rules/no-constant-condition.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "problem", + docs: { description: "disallow constant expressions in conditions", category: "Possible Errors", diff --git a/lib/rules/no-continue.js b/lib/rules/no-continue.js index 3075b77f9fd..0461fc839de 100644 --- a/lib/rules/no-continue.js +++ b/lib/rules/no-continue.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "style", + docs: { description: "disallow `continue` statements", category: "Stylistic Issues", diff --git a/lib/rules/no-control-regex.js b/lib/rules/no-control-regex.js index 24bb6be6671..24e6b197be0 100644 --- a/lib/rules/no-control-regex.js +++ b/lib/rules/no-control-regex.js @@ -6,7 +6,7 @@ "use strict"; const RegExpValidator = require("regexpp").RegExpValidator; -const collector = new class { +const collector = new (class { constructor() { this.ecmaVersion = 2018; this._source = ""; @@ -41,7 +41,7 @@ const collector = new class { } return this._controlChars; } -}(); +})(); //------------------------------------------------------------------------------ // Rule Definition @@ -49,6 +49,8 @@ const collector = new class { module.exports = { meta: { + type: "problem", + docs: { description: "disallow control characters in regular expressions", category: "Possible Errors", diff --git a/lib/rules/no-debugger.js b/lib/rules/no-debugger.js index 5d63bb7e141..95a28a86215 100644 --- a/lib/rules/no-debugger.js +++ b/lib/rules/no-debugger.js @@ -11,14 +11,18 @@ module.exports = { meta: { + type: "problem", + docs: { description: "disallow the use of `debugger`", category: "Possible Errors", recommended: true, url: "https://eslint.org/docs/rules/no-debugger" }, + fixable: null, schema: [], + messages: { unexpected: "Unexpected 'debugger' statement." } diff --git a/lib/rules/no-delete-var.js b/lib/rules/no-delete-var.js index f54a396ec2d..aeab951d75f 100644 --- a/lib/rules/no-delete-var.js +++ b/lib/rules/no-delete-var.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow deleting variables", category: "Variables", diff --git a/lib/rules/no-div-regex.js b/lib/rules/no-div-regex.js index c050249fd6e..408e006528b 100644 --- a/lib/rules/no-div-regex.js +++ b/lib/rules/no-div-regex.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow division operators explicitly at the beginning of regular expressions", category: "Best Practices", diff --git a/lib/rules/no-dupe-args.js b/lib/rules/no-dupe-args.js index e5a7f4154e7..4e42336ae3d 100644 --- a/lib/rules/no-dupe-args.js +++ b/lib/rules/no-dupe-args.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "problem", + docs: { description: "disallow duplicate arguments in `function` definitions", category: "Possible Errors", diff --git a/lib/rules/no-dupe-class-members.js b/lib/rules/no-dupe-class-members.js index d0fc3597360..7dfb312b0ff 100644 --- a/lib/rules/no-dupe-class-members.js +++ b/lib/rules/no-dupe-class-members.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow duplicate class members", category: "ECMAScript 6", diff --git a/lib/rules/no-dupe-keys.js b/lib/rules/no-dupe-keys.js index 31493bd048d..9b9c02f5efc 100644 --- a/lib/rules/no-dupe-keys.js +++ b/lib/rules/no-dupe-keys.js @@ -84,6 +84,8 @@ class ObjectInfo { module.exports = { meta: { + type: "problem", + docs: { description: "disallow duplicate keys in object literals", category: "Possible Errors", diff --git a/lib/rules/no-duplicate-case.js b/lib/rules/no-duplicate-case.js index 128b1fc1b1c..93c8548f91a 100644 --- a/lib/rules/no-duplicate-case.js +++ b/lib/rules/no-duplicate-case.js @@ -12,6 +12,8 @@ module.exports = { meta: { + type: "problem", + docs: { description: "disallow duplicate case labels", category: "Possible Errors", diff --git a/lib/rules/no-duplicate-imports.js b/lib/rules/no-duplicate-imports.js index 32071da15fd..490ed3725d0 100644 --- a/lib/rules/no-duplicate-imports.js +++ b/lib/rules/no-duplicate-imports.js @@ -101,6 +101,8 @@ function handleExports(context, importsInFile, exportsInFile) { module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow duplicate module imports", category: "ECMAScript 6", diff --git a/lib/rules/no-else-return.js b/lib/rules/no-else-return.js index 1000fa807ac..eebdec76e0e 100644 --- a/lib/rules/no-else-return.js +++ b/lib/rules/no-else-return.js @@ -18,6 +18,8 @@ const FixTracker = require("../util/fix-tracker"); module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow `else` blocks after `return` statements in `if` statements", category: "Best Practices", diff --git a/lib/rules/no-empty-character-class.js b/lib/rules/no-empty-character-class.js index e3f06b069a8..6d2fb3c5018 100644 --- a/lib/rules/no-empty-character-class.js +++ b/lib/rules/no-empty-character-class.js @@ -29,6 +29,8 @@ const regex = /^\/([^\\[]|\\.|\[([^\\\]]|\\.)+])*\/[gimuys]*$/; module.exports = { meta: { + type: "problem", + docs: { description: "disallow empty character classes in regular expressions", category: "Possible Errors", diff --git a/lib/rules/no-empty-function.js b/lib/rules/no-empty-function.js index c8039314ab0..a443796e4e2 100644 --- a/lib/rules/no-empty-function.js +++ b/lib/rules/no-empty-function.js @@ -90,6 +90,8 @@ function getKind(node) { module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow empty functions", category: "Best Practices", diff --git a/lib/rules/no-empty-pattern.js b/lib/rules/no-empty-pattern.js index 939710560fa..cef3887ee60 100644 --- a/lib/rules/no-empty-pattern.js +++ b/lib/rules/no-empty-pattern.js @@ -10,6 +10,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow empty destructuring patterns", category: "Best Practices", diff --git a/lib/rules/no-empty.js b/lib/rules/no-empty.js index 2f4c258a26f..4073046f00a 100644 --- a/lib/rules/no-empty.js +++ b/lib/rules/no-empty.js @@ -16,6 +16,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "problem", + docs: { description: "disallow empty block statements", category: "Possible Errors", diff --git a/lib/rules/no-eq-null.js b/lib/rules/no-eq-null.js index eadd16de37f..b8dead96d25 100644 --- a/lib/rules/no-eq-null.js +++ b/lib/rules/no-eq-null.js @@ -12,6 +12,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow `null` comparisons without type-checking operators", category: "Best Practices", diff --git a/lib/rules/no-eval.js b/lib/rules/no-eval.js index c3ea87d466d..39d91e776e9 100644 --- a/lib/rules/no-eval.js +++ b/lib/rules/no-eval.js @@ -76,6 +76,8 @@ function isMember(node, name) { module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow the use of `eval()`", category: "Best Practices", diff --git a/lib/rules/no-ex-assign.js b/lib/rules/no-ex-assign.js index 1c7beccf89e..4cc179a6e8f 100644 --- a/lib/rules/no-ex-assign.js +++ b/lib/rules/no-ex-assign.js @@ -13,6 +13,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "problem", + docs: { description: "disallow reassigning exceptions in `catch` clauses", category: "Possible Errors", diff --git a/lib/rules/no-extend-native.js b/lib/rules/no-extend-native.js index a1bf49f1325..13895f0d06b 100644 --- a/lib/rules/no-extend-native.js +++ b/lib/rules/no-extend-native.js @@ -24,6 +24,8 @@ const propertyDefinitionMethods = new Set(["defineProperty", "defineProperties"] module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow extending native types", category: "Best Practices", diff --git a/lib/rules/no-extra-bind.js b/lib/rules/no-extra-bind.js index b8376adfc11..2f9aa8d2b74 100644 --- a/lib/rules/no-extra-bind.js +++ b/lib/rules/no-extra-bind.js @@ -16,6 +16,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow unnecessary calls to `.bind()`", category: "Best Practices", @@ -24,7 +26,6 @@ module.exports = { }, schema: [], - fixable: "code", messages: { diff --git a/lib/rules/no-extra-boolean-cast.js b/lib/rules/no-extra-boolean-cast.js index 5eac6b53fe4..3fdc6b633df 100644 --- a/lib/rules/no-extra-boolean-cast.js +++ b/lib/rules/no-extra-boolean-cast.js @@ -17,6 +17,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "problem", + docs: { description: "disallow unnecessary boolean casts", category: "Possible Errors", @@ -25,7 +27,6 @@ module.exports = { }, schema: [], - fixable: "code", messages: { diff --git a/lib/rules/no-extra-label.js b/lib/rules/no-extra-label.js index 9310e90f71e..f8acf7b2834 100644 --- a/lib/rules/no-extra-label.js +++ b/lib/rules/no-extra-label.js @@ -17,6 +17,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow unnecessary labels", category: "Best Practices", @@ -25,7 +27,6 @@ module.exports = { }, schema: [], - fixable: "code", messages: { diff --git a/lib/rules/no-extra-parens.js b/lib/rules/no-extra-parens.js index 47c58946cf1..a7821b598cc 100644 --- a/lib/rules/no-extra-parens.js +++ b/lib/rules/no-extra-parens.js @@ -12,6 +12,8 @@ const astUtils = require("../util/ast-utils.js"); module.exports = { meta: { + type: "problem", + docs: { description: "disallow unnecessary parentheses", category: "Possible Errors", @@ -382,8 +384,7 @@ module.exports = { * Allow extra parens around a new expression if * there are intervening parentheses. */ - callee.type === "MemberExpression" && - doesMemberExpressionContainCallExpression(callee) + (callee.type === "MemberExpression" && doesMemberExpressionContainCallExpression(callee)) ) ) { report(node.callee); @@ -574,15 +575,13 @@ module.exports = { * If `let` is the only thing on the left side of the loop, it's the loop variable: `for ((let) of foo);` * Removing it will cause a syntax error, because it will be parsed as the start of a VariableDeclarator. */ - firstLeftToken.range[1] === node.left.range[1] || - - /* + (firstLeftToken.range[1] === node.left.range[1] || /* * If `let` is followed by a `[` token, it's a property access on the `let` value: `for ((let[foo]) of bar);` * Removing it will cause the property access to be parsed as a destructuring declaration of `foo` instead. */ astUtils.isOpeningBracketToken( sourceCode.getTokenAfter(firstLeftToken, astUtils.isNotClosingParenToken) - ) + )) ) ) { tokensToIgnore.add(firstLeftToken); diff --git a/lib/rules/no-extra-semi.js b/lib/rules/no-extra-semi.js index 4d40b5e1538..1a118a31c79 100644 --- a/lib/rules/no-extra-semi.js +++ b/lib/rules/no-extra-semi.js @@ -18,6 +18,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "problem", + docs: { description: "disallow unnecessary semicolons", category: "Possible Errors", diff --git a/lib/rules/no-fallthrough.js b/lib/rules/no-fallthrough.js index ce4f91ad964..c3f7520359c 100644 --- a/lib/rules/no-fallthrough.js +++ b/lib/rules/no-fallthrough.js @@ -55,6 +55,8 @@ function hasBlankLinesBetween(node, token) { module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow fallthrough of `case` statements", category: "Best Practices", diff --git a/lib/rules/no-floating-decimal.js b/lib/rules/no-floating-decimal.js index a62846cc10f..c835d6a545f 100644 --- a/lib/rules/no-floating-decimal.js +++ b/lib/rules/no-floating-decimal.js @@ -17,6 +17,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow leading or trailing decimal points in numeric literals", category: "Best Practices", @@ -25,7 +27,6 @@ module.exports = { }, schema: [], - fixable: "code" }, diff --git a/lib/rules/no-func-assign.js b/lib/rules/no-func-assign.js index 029f6a9d7d1..ae96ab01f43 100644 --- a/lib/rules/no-func-assign.js +++ b/lib/rules/no-func-assign.js @@ -13,6 +13,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "problem", + docs: { description: "disallow reassigning `function` declarations", category: "Possible Errors", diff --git a/lib/rules/no-global-assign.js b/lib/rules/no-global-assign.js index 3397bdbe000..73f36b25e47 100644 --- a/lib/rules/no-global-assign.js +++ b/lib/rules/no-global-assign.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow assignments to native objects or read-only global variables", category: "Best Practices", diff --git a/lib/rules/no-implicit-coercion.js b/lib/rules/no-implicit-coercion.js index 3bfe3f0d3a2..826d9398cab 100644 --- a/lib/rules/no-implicit-coercion.js +++ b/lib/rules/no-implicit-coercion.js @@ -152,6 +152,8 @@ function getNonEmptyOperand(node) { module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow shorthand type conversions", category: "Best Practices", @@ -160,6 +162,7 @@ module.exports = { }, fixable: "code", + schema: [{ type: "object", properties: { diff --git a/lib/rules/no-implicit-globals.js b/lib/rules/no-implicit-globals.js index c4717b6a374..2eea2b28463 100644 --- a/lib/rules/no-implicit-globals.js +++ b/lib/rules/no-implicit-globals.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow variable and `function` declarations in the global scope", category: "Best Practices", diff --git a/lib/rules/no-implied-eval.js b/lib/rules/no-implied-eval.js index de294bc8858..d31b5dfee80 100644 --- a/lib/rules/no-implied-eval.js +++ b/lib/rules/no-implied-eval.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow the use of `eval()`-like methods", category: "Best Practices", diff --git a/lib/rules/no-inline-comments.js b/lib/rules/no-inline-comments.js index 2fb21909229..27990ec0fa2 100644 --- a/lib/rules/no-inline-comments.js +++ b/lib/rules/no-inline-comments.js @@ -12,6 +12,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "style", + docs: { description: "disallow inline comments after code", category: "Stylistic Issues", diff --git a/lib/rules/no-inner-declarations.js b/lib/rules/no-inner-declarations.js index 032c0a0f096..60508d3e864 100644 --- a/lib/rules/no-inner-declarations.js +++ b/lib/rules/no-inner-declarations.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "problem", + docs: { description: "disallow variable or `function` declarations in nested blocks", category: "Possible Errors", diff --git a/lib/rules/no-invalid-regexp.js b/lib/rules/no-invalid-regexp.js index 7169e0ca770..74659001fdb 100644 --- a/lib/rules/no-invalid-regexp.js +++ b/lib/rules/no-invalid-regexp.js @@ -19,6 +19,8 @@ const undefined1 = void 0; module.exports = { meta: { + type: "problem", + docs: { description: "disallow invalid regular expression strings in `RegExp` constructors", category: "Possible Errors", diff --git a/lib/rules/no-invalid-this.js b/lib/rules/no-invalid-this.js index 480deebc14c..e9be4445260 100644 --- a/lib/rules/no-invalid-this.js +++ b/lib/rules/no-invalid-this.js @@ -17,6 +17,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow `this` keywords outside of classes or class-like objects", category: "Best Practices", diff --git a/lib/rules/no-irregular-whitespace.js b/lib/rules/no-irregular-whitespace.js index 729f829a1f7..537af183114 100644 --- a/lib/rules/no-irregular-whitespace.js +++ b/lib/rules/no-irregular-whitespace.js @@ -27,6 +27,8 @@ const LINE_BREAK = astUtils.createGlobalLinebreakMatcher(); module.exports = { meta: { + type: "problem", + docs: { description: "disallow irregular whitespace outside of strings and comments", category: "Possible Errors", diff --git a/lib/rules/no-iterator.js b/lib/rules/no-iterator.js index ca12fcda477..82319a3fb1d 100644 --- a/lib/rules/no-iterator.js +++ b/lib/rules/no-iterator.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow the use of the `__iterator__` property", category: "Best Practices", diff --git a/lib/rules/no-label-var.js b/lib/rules/no-label-var.js index 3f5aba4fc1e..fdba2defc35 100644 --- a/lib/rules/no-label-var.js +++ b/lib/rules/no-label-var.js @@ -17,6 +17,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow labels that share a name with a variable", category: "Variables", diff --git a/lib/rules/no-labels.js b/lib/rules/no-labels.js index bd6ec57a350..34db20725b0 100644 --- a/lib/rules/no-labels.js +++ b/lib/rules/no-labels.js @@ -16,6 +16,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow labeled statements", category: "Best Practices", diff --git a/lib/rules/no-lone-blocks.js b/lib/rules/no-lone-blocks.js index 5e22aacf00f..6b51795863b 100644 --- a/lib/rules/no-lone-blocks.js +++ b/lib/rules/no-lone-blocks.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow unnecessary nested blocks", category: "Best Practices", diff --git a/lib/rules/no-lonely-if.js b/lib/rules/no-lonely-if.js index 3ecc41e8cf6..4f69bc7b779 100644 --- a/lib/rules/no-lonely-if.js +++ b/lib/rules/no-lonely-if.js @@ -10,6 +10,8 @@ module.exports = { meta: { + type: "style", + docs: { description: "disallow `if` statements as the only statement in `else` blocks", category: "Stylistic Issues", @@ -18,7 +20,6 @@ module.exports = { }, schema: [], - fixable: "code" }, diff --git a/lib/rules/no-loop-func.js b/lib/rules/no-loop-func.js index d103cb53350..e6063806a5d 100644 --- a/lib/rules/no-loop-func.js +++ b/lib/rules/no-loop-func.js @@ -154,6 +154,8 @@ function isSafe(loopNode, reference) { module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow `function` declarations and expressions inside loop statements", category: "Best Practices", diff --git a/lib/rules/no-magic-numbers.js b/lib/rules/no-magic-numbers.js index b70ca826750..84c08dfb08e 100644 --- a/lib/rules/no-magic-numbers.js +++ b/lib/rules/no-magic-numbers.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow magic numbers", category: "Best Practices", @@ -40,6 +42,7 @@ module.exports = { }, additionalProperties: false }], + messages: { useConst: "Number constants declarations must use 'const'.", noMagic: "No magic number: {{raw}}." diff --git a/lib/rules/no-misleading-character-class.js b/lib/rules/no-misleading-character-class.js index e410efed9c9..4fa650ed527 100644 --- a/lib/rules/no-misleading-character-class.js +++ b/lib/rules/no-misleading-character-class.js @@ -101,13 +101,17 @@ const kinds = Object.keys(hasCharacterSequence); module.exports = { meta: { + type: "problem", + docs: { description: "disallow characters which are made with multiple code points in character class syntax", category: "Possible Errors", recommended: false, url: "https://eslint.org/docs/rules/no-misleading-character-class" }, + schema: [], + messages: { surrogatePairWithoutUFlag: "Unexpected surrogate pair in character class. Use 'u' flag.", combiningClass: "Unexpected combined character in character class.", diff --git a/lib/rules/no-mixed-operators.js b/lib/rules/no-mixed-operators.js index d4ead20062d..d66d03c69f5 100644 --- a/lib/rules/no-mixed-operators.js +++ b/lib/rules/no-mixed-operators.js @@ -71,12 +71,15 @@ function includesBothInAGroup(groups, left, right) { module.exports = { meta: { + type: "style", + docs: { description: "disallow mixed binary operators", category: "Stylistic Issues", recommended: false, url: "https://eslint.org/docs/rules/no-mixed-operators" }, + schema: [ { type: "object", diff --git a/lib/rules/no-mixed-requires.js b/lib/rules/no-mixed-requires.js index 1058f3a511e..438ac668a80 100644 --- a/lib/rules/no-mixed-requires.js +++ b/lib/rules/no-mixed-requires.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow `require` calls to be mixed with regular variable declarations", category: "Node.js and CommonJS", diff --git a/lib/rules/no-mixed-spaces-and-tabs.js b/lib/rules/no-mixed-spaces-and-tabs.js index 7cb4b4ceeae..7c0fead1ed0 100644 --- a/lib/rules/no-mixed-spaces-and-tabs.js +++ b/lib/rules/no-mixed-spaces-and-tabs.js @@ -10,6 +10,8 @@ module.exports = { meta: { + type: "style", + docs: { description: "disallow mixed spaces and tabs for indentation", category: "Stylistic Issues", diff --git a/lib/rules/no-multi-assign.js b/lib/rules/no-multi-assign.js index ca3f778ac6f..0ee34a69fcb 100644 --- a/lib/rules/no-multi-assign.js +++ b/lib/rules/no-multi-assign.js @@ -12,12 +12,15 @@ module.exports = { meta: { + type: "style", + docs: { description: "disallow use of chained assignment expressions", category: "Stylistic Issues", recommended: false, url: "https://eslint.org/docs/rules/no-multi-assign" }, + schema: [] }, diff --git a/lib/rules/no-multi-spaces.js b/lib/rules/no-multi-spaces.js index 41bcd4fb611..0cbd110beac 100644 --- a/lib/rules/no-multi-spaces.js +++ b/lib/rules/no-multi-spaces.js @@ -13,6 +13,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow multiple spaces", category: "Best Practices", diff --git a/lib/rules/no-multi-str.js b/lib/rules/no-multi-str.js index ee0aaaa4c0c..844842392df 100644 --- a/lib/rules/no-multi-str.js +++ b/lib/rules/no-multi-str.js @@ -17,6 +17,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow multiline strings", category: "Best Practices", diff --git a/lib/rules/no-multiple-empty-lines.js b/lib/rules/no-multiple-empty-lines.js index a111786a308..ed4f44d5efc 100644 --- a/lib/rules/no-multiple-empty-lines.js +++ b/lib/rules/no-multiple-empty-lines.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "style", + docs: { description: "disallow multiple empty lines", category: "Stylistic Issues", diff --git a/lib/rules/no-native-reassign.js b/lib/rules/no-native-reassign.js index b1064b0bb36..29233416fc3 100644 --- a/lib/rules/no-native-reassign.js +++ b/lib/rules/no-native-reassign.js @@ -12,6 +12,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow assignments to native objects or read-only global variables", category: "Best Practices", diff --git a/lib/rules/no-negated-condition.js b/lib/rules/no-negated-condition.js index 254dcb5c23c..f713de30d75 100644 --- a/lib/rules/no-negated-condition.js +++ b/lib/rules/no-negated-condition.js @@ -10,6 +10,8 @@ module.exports = { meta: { + type: "style", + docs: { description: "disallow negated conditions", category: "Stylistic Issues", diff --git a/lib/rules/no-negated-in-lhs.js b/lib/rules/no-negated-in-lhs.js index 7f08814c941..ee13b9c497e 100644 --- a/lib/rules/no-negated-in-lhs.js +++ b/lib/rules/no-negated-in-lhs.js @@ -12,6 +12,8 @@ module.exports = { meta: { + type: "problem", + docs: { description: "disallow negating the left operand in `in` expressions", category: "Possible Errors", @@ -19,8 +21,8 @@ module.exports = { replacedBy: ["no-unsafe-negation"], url: "https://eslint.org/docs/rules/no-negated-in-lhs" }, - deprecated: true, + deprecated: true, schema: [] }, diff --git a/lib/rules/no-nested-ternary.js b/lib/rules/no-nested-ternary.js index 15e72f20d1c..bfae4ade551 100644 --- a/lib/rules/no-nested-ternary.js +++ b/lib/rules/no-nested-ternary.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "style", + docs: { description: "disallow nested ternary expressions", category: "Stylistic Issues", diff --git a/lib/rules/no-new-func.js b/lib/rules/no-new-func.js index 8ee327baa1c..23e92f7bf30 100644 --- a/lib/rules/no-new-func.js +++ b/lib/rules/no-new-func.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow `new` operators with the `Function` object", category: "Best Practices", diff --git a/lib/rules/no-new-object.js b/lib/rules/no-new-object.js index 3f68cbc1b51..4279548e339 100644 --- a/lib/rules/no-new-object.js +++ b/lib/rules/no-new-object.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "style", + docs: { description: "disallow `Object` constructors", category: "Stylistic Issues", diff --git a/lib/rules/no-new-require.js b/lib/rules/no-new-require.js index f74daa7569c..1eae0659430 100644 --- a/lib/rules/no-new-require.js +++ b/lib/rules/no-new-require.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow `new` operators with calls to `require`", category: "Node.js and CommonJS", diff --git a/lib/rules/no-new-symbol.js b/lib/rules/no-new-symbol.js index a537268e38d..fa61e2c539b 100644 --- a/lib/rules/no-new-symbol.js +++ b/lib/rules/no-new-symbol.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow `new` operators with the `Symbol` object", category: "ECMAScript 6", diff --git a/lib/rules/no-new-wrappers.js b/lib/rules/no-new-wrappers.js index e8d516212b6..ae2aeec0341 100644 --- a/lib/rules/no-new-wrappers.js +++ b/lib/rules/no-new-wrappers.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow `new` operators with the `String`, `Number`, and `Boolean` objects", category: "Best Practices", diff --git a/lib/rules/no-new.js b/lib/rules/no-new.js index f9121bc18f6..2e0702597ea 100644 --- a/lib/rules/no-new.js +++ b/lib/rules/no-new.js @@ -12,6 +12,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow `new` operators outside of assignments or comparisons", category: "Best Practices", diff --git a/lib/rules/no-obj-calls.js b/lib/rules/no-obj-calls.js index 320343cb2c0..92492b7a26e 100644 --- a/lib/rules/no-obj-calls.js +++ b/lib/rules/no-obj-calls.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "problem", + docs: { description: "disallow calling global object properties as functions", category: "Possible Errors", diff --git a/lib/rules/no-octal-escape.js b/lib/rules/no-octal-escape.js index e9509b87f82..fc073b14033 100644 --- a/lib/rules/no-octal-escape.js +++ b/lib/rules/no-octal-escape.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow octal escape sequences in string literals", category: "Best Practices", diff --git a/lib/rules/no-octal.js b/lib/rules/no-octal.js index d782c23a39b..db1fa40aa5d 100644 --- a/lib/rules/no-octal.js +++ b/lib/rules/no-octal.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow octal literals", category: "Best Practices", diff --git a/lib/rules/no-param-reassign.js b/lib/rules/no-param-reassign.js index be1a559178a..243bb6412cf 100644 --- a/lib/rules/no-param-reassign.js +++ b/lib/rules/no-param-reassign.js @@ -12,6 +12,8 @@ const stopNodePattern = /(?:Statement|Declaration|Function(?:Expression)?|Progra module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow reassigning `function` parameters", category: "Best Practices", diff --git a/lib/rules/no-path-concat.js b/lib/rules/no-path-concat.js index 1dee7bda111..dad56a4f56a 100644 --- a/lib/rules/no-path-concat.js +++ b/lib/rules/no-path-concat.js @@ -10,6 +10,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow string concatenation with `__dirname` and `__filename`", category: "Node.js and CommonJS", diff --git a/lib/rules/no-plusplus.js b/lib/rules/no-plusplus.js index f754b367219..95f923b65fb 100644 --- a/lib/rules/no-plusplus.js +++ b/lib/rules/no-plusplus.js @@ -12,6 +12,8 @@ module.exports = { meta: { + type: "style", + docs: { description: "disallow the unary operators `++` and `--`", category: "Stylistic Issues", diff --git a/lib/rules/no-process-env.js b/lib/rules/no-process-env.js index 71b27ffd720..a66d9709b09 100644 --- a/lib/rules/no-process-env.js +++ b/lib/rules/no-process-env.js @@ -10,6 +10,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow the use of `process.env`", category: "Node.js and CommonJS", diff --git a/lib/rules/no-process-exit.js b/lib/rules/no-process-exit.js index 2d22d7fd96a..fcfc6b2af59 100644 --- a/lib/rules/no-process-exit.js +++ b/lib/rules/no-process-exit.js @@ -10,6 +10,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow the use of `process.exit()`", category: "Node.js and CommonJS", diff --git a/lib/rules/no-proto.js b/lib/rules/no-proto.js index e37c6c22e62..80b96509416 100644 --- a/lib/rules/no-proto.js +++ b/lib/rules/no-proto.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow the use of the `__proto__` property", category: "Best Practices", diff --git a/lib/rules/no-prototype-builtins.js b/lib/rules/no-prototype-builtins.js index f52847f44d4..17139530672 100644 --- a/lib/rules/no-prototype-builtins.js +++ b/lib/rules/no-prototype-builtins.js @@ -10,6 +10,8 @@ module.exports = { meta: { + type: "problem", + docs: { description: "disallow calling some `Object.prototype` methods directly on objects", category: "Possible Errors", diff --git a/lib/rules/no-redeclare.js b/lib/rules/no-redeclare.js index 79ab21137ec..e88436d7c57 100644 --- a/lib/rules/no-redeclare.js +++ b/lib/rules/no-redeclare.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow variable redeclaration", category: "Best Practices", diff --git a/lib/rules/no-regex-spaces.js b/lib/rules/no-regex-spaces.js index 089e0602865..ce6a7c86f45 100644 --- a/lib/rules/no-regex-spaces.js +++ b/lib/rules/no-regex-spaces.js @@ -13,6 +13,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "problem", + docs: { description: "disallow multiple spaces in regular expressions", category: "Possible Errors", @@ -21,7 +23,6 @@ module.exports = { }, schema: [], - fixable: "code" }, diff --git a/lib/rules/no-restricted-globals.js b/lib/rules/no-restricted-globals.js index 72b02c032aa..1a2629a8ec9 100644 --- a/lib/rules/no-restricted-globals.js +++ b/lib/rules/no-restricted-globals.js @@ -17,6 +17,8 @@ const DEFAULT_MESSAGE_TEMPLATE = "Unexpected use of '{{name}}'.", module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow specified global variables", category: "Variables", diff --git a/lib/rules/no-restricted-imports.js b/lib/rules/no-restricted-imports.js index fdebb8ca3ad..e4563172e0b 100644 --- a/lib/rules/no-restricted-imports.js +++ b/lib/rules/no-restricted-imports.js @@ -53,6 +53,8 @@ const arrayOfStringsOrObjects = { module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow specified modules when loaded by `import`", category: "ECMAScript 6", diff --git a/lib/rules/no-restricted-modules.js b/lib/rules/no-restricted-modules.js index d63d2ce4f45..ef8748a7d04 100644 --- a/lib/rules/no-restricted-modules.js +++ b/lib/rules/no-restricted-modules.js @@ -47,6 +47,8 @@ const arrayOfStringsOrObjects = { module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow specified modules when loaded by `require`", category: "Node.js and CommonJS", diff --git a/lib/rules/no-restricted-properties.js b/lib/rules/no-restricted-properties.js index c0f1cfb6d38..eede6ad1c16 100644 --- a/lib/rules/no-restricted-properties.js +++ b/lib/rules/no-restricted-properties.js @@ -13,6 +13,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow certain properties on certain objects", category: "Best Practices", diff --git a/lib/rules/no-restricted-syntax.js b/lib/rules/no-restricted-syntax.js index c472d9432e6..b075f7e436a 100644 --- a/lib/rules/no-restricted-syntax.js +++ b/lib/rules/no-restricted-syntax.js @@ -10,6 +10,8 @@ module.exports = { meta: { + type: "style", + docs: { description: "disallow specified syntax", category: "Stylistic Issues", diff --git a/lib/rules/no-return-assign.js b/lib/rules/no-return-assign.js index 519f9e0d039..b3c39ea2b8c 100644 --- a/lib/rules/no-return-assign.js +++ b/lib/rules/no-return-assign.js @@ -22,6 +22,8 @@ const SENTINEL_TYPE = /^(?:[a-zA-Z]+?Statement|ArrowFunctionExpression|FunctionE module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow assignment operators in `return` statements", category: "Best Practices", diff --git a/lib/rules/no-return-await.js b/lib/rules/no-return-await.js index 5f531a18310..24cb45ee5a7 100644 --- a/lib/rules/no-return-await.js +++ b/lib/rules/no-return-await.js @@ -14,6 +14,8 @@ const message = "Redundant use of `await` on a return value."; module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow unnecessary `return await`", category: "Best Practices", @@ -22,7 +24,9 @@ module.exports = { url: "https://eslint.org/docs/rules/no-return-await" }, + fixable: null, + schema: [ ] }, diff --git a/lib/rules/no-script-url.js b/lib/rules/no-script-url.js index ba74dafb8e2..40e9bfe8b27 100644 --- a/lib/rules/no-script-url.js +++ b/lib/rules/no-script-url.js @@ -13,6 +13,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow `javascript:` urls", category: "Best Practices", diff --git a/lib/rules/no-self-assign.js b/lib/rules/no-self-assign.js index 87d1f2ff4f7..fac05aa3f7e 100644 --- a/lib/rules/no-self-assign.js +++ b/lib/rules/no-self-assign.js @@ -165,6 +165,8 @@ function eachSelfAssignment(left, right, props, report) { module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow assignments where both sides are exactly the same", category: "Best Practices", diff --git a/lib/rules/no-self-compare.js b/lib/rules/no-self-compare.js index 6ebc3870feb..5dbd1f4466e 100644 --- a/lib/rules/no-self-compare.js +++ b/lib/rules/no-self-compare.js @@ -12,6 +12,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow comparisons where both sides are exactly the same", category: "Best Practices", diff --git a/lib/rules/no-sequences.js b/lib/rules/no-sequences.js index e74943d8109..2570912f348 100644 --- a/lib/rules/no-sequences.js +++ b/lib/rules/no-sequences.js @@ -17,6 +17,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow comma operators", category: "Best Practices", diff --git a/lib/rules/no-shadow-restricted-names.js b/lib/rules/no-shadow-restricted-names.js index 70052f56f2d..9bdd5086804 100644 --- a/lib/rules/no-shadow-restricted-names.js +++ b/lib/rules/no-shadow-restricted-names.js @@ -10,6 +10,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow identifiers from shadowing restricted names", category: "Variables", diff --git a/lib/rules/no-shadow.js b/lib/rules/no-shadow.js index 955fc05e582..f910230d6a2 100644 --- a/lib/rules/no-shadow.js +++ b/lib/rules/no-shadow.js @@ -17,6 +17,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow variable declarations from shadowing variables declared in the outer scope", category: "Variables", diff --git a/lib/rules/no-spaced-func.js b/lib/rules/no-spaced-func.js index 42d1e4b243a..0df0996e601 100644 --- a/lib/rules/no-spaced-func.js +++ b/lib/rules/no-spaced-func.js @@ -12,6 +12,8 @@ module.exports = { meta: { + type: "style", + docs: { description: "disallow spacing between function identifiers and their applications (deprecated)", category: "Stylistic Issues", @@ -21,7 +23,6 @@ module.exports = { }, deprecated: true, - fixable: "whitespace", schema: [] }, diff --git a/lib/rules/no-sparse-arrays.js b/lib/rules/no-sparse-arrays.js index 1cc6f7ccba9..985109c36b2 100644 --- a/lib/rules/no-sparse-arrays.js +++ b/lib/rules/no-sparse-arrays.js @@ -10,6 +10,8 @@ module.exports = { meta: { + type: "problem", + docs: { description: "disallow sparse arrays", category: "Possible Errors", diff --git a/lib/rules/no-sync.js b/lib/rules/no-sync.js index eb7b787d38c..a0096e3d043 100644 --- a/lib/rules/no-sync.js +++ b/lib/rules/no-sync.js @@ -13,6 +13,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow synchronous methods", category: "Node.js and CommonJS", diff --git a/lib/rules/no-tabs.js b/lib/rules/no-tabs.js index 08a8fa5b758..4556a5970e2 100644 --- a/lib/rules/no-tabs.js +++ b/lib/rules/no-tabs.js @@ -16,12 +16,15 @@ const regex = /\t/; module.exports = { meta: { + type: "style", + docs: { description: "disallow all tabs", category: "Stylistic Issues", recommended: false, url: "https://eslint.org/docs/rules/no-tabs" }, + schema: [] }, diff --git a/lib/rules/no-template-curly-in-string.js b/lib/rules/no-template-curly-in-string.js index ed74fcc6f7f..c286ec69000 100644 --- a/lib/rules/no-template-curly-in-string.js +++ b/lib/rules/no-template-curly-in-string.js @@ -10,6 +10,8 @@ module.exports = { meta: { + type: "problem", + docs: { description: "disallow template literal placeholder syntax in regular strings", category: "Possible Errors", diff --git a/lib/rules/no-ternary.js b/lib/rules/no-ternary.js index 4dcc8db069e..64674a1eed3 100644 --- a/lib/rules/no-ternary.js +++ b/lib/rules/no-ternary.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "style", + docs: { description: "disallow ternary operators", category: "Stylistic Issues", diff --git a/lib/rules/no-this-before-super.js b/lib/rules/no-this-before-super.js index 8a489879edd..61a191bfc10 100644 --- a/lib/rules/no-this-before-super.js +++ b/lib/rules/no-this-before-super.js @@ -36,6 +36,8 @@ function isConstructorFunction(node) { module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow `this`/`super` before calling `super()` in constructors", category: "ECMAScript 6", diff --git a/lib/rules/no-throw-literal.js b/lib/rules/no-throw-literal.js index 301354b6b2c..c4a6b86bfb4 100644 --- a/lib/rules/no-throw-literal.js +++ b/lib/rules/no-throw-literal.js @@ -13,6 +13,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow throwing literals as exceptions", category: "Best Practices", diff --git a/lib/rules/no-trailing-spaces.js b/lib/rules/no-trailing-spaces.js index cca7af2aac3..1c75a19658f 100644 --- a/lib/rules/no-trailing-spaces.js +++ b/lib/rules/no-trailing-spaces.js @@ -16,6 +16,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "style", + docs: { description: "disallow trailing whitespace at the end of lines", category: "Stylistic Issues", diff --git a/lib/rules/no-undef-init.js b/lib/rules/no-undef-init.js index f00b05d4ff0..67f3944d47e 100644 --- a/lib/rules/no-undef-init.js +++ b/lib/rules/no-undef-init.js @@ -13,6 +13,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow initializing variables to `undefined`", category: "Variables", @@ -21,7 +23,6 @@ module.exports = { }, schema: [], - fixable: "code" }, diff --git a/lib/rules/no-undef.js b/lib/rules/no-undef.js index c8347d50d1a..da89f9ef51e 100644 --- a/lib/rules/no-undef.js +++ b/lib/rules/no-undef.js @@ -25,6 +25,8 @@ function hasTypeOfOperator(node) { module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow the use of undeclared variables unless mentioned in `/*global */` comments", category: "Variables", diff --git a/lib/rules/no-undefined.js b/lib/rules/no-undefined.js index 8491ab5d540..b92f6700637 100644 --- a/lib/rules/no-undefined.js +++ b/lib/rules/no-undefined.js @@ -10,6 +10,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow the use of `undefined` as an identifier", category: "Variables", diff --git a/lib/rules/no-underscore-dangle.js b/lib/rules/no-underscore-dangle.js index c76488a9431..9448ecde77d 100644 --- a/lib/rules/no-underscore-dangle.js +++ b/lib/rules/no-underscore-dangle.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "style", + docs: { description: "disallow dangling underscores in identifiers", category: "Stylistic Issues", diff --git a/lib/rules/no-unexpected-multiline.js b/lib/rules/no-unexpected-multiline.js index 181a00b2d0d..3bed96fc77d 100644 --- a/lib/rules/no-unexpected-multiline.js +++ b/lib/rules/no-unexpected-multiline.js @@ -16,6 +16,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "problem", + docs: { description: "disallow confusing multiline expressions", category: "Possible Errors", diff --git a/lib/rules/no-unmodified-loop-condition.js b/lib/rules/no-unmodified-loop-condition.js index fecd8ba5cca..2fed7f03106 100644 --- a/lib/rules/no-unmodified-loop-condition.js +++ b/lib/rules/no-unmodified-loop-condition.js @@ -165,6 +165,8 @@ function updateModifiedFlag(conditions, modifiers) { module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow unmodified loop conditions", category: "Best Practices", diff --git a/lib/rules/no-unneeded-ternary.js b/lib/rules/no-unneeded-ternary.js index 6b58b018da0..29cbe72eb96 100644 --- a/lib/rules/no-unneeded-ternary.js +++ b/lib/rules/no-unneeded-ternary.js @@ -24,6 +24,8 @@ const OPERATOR_INVERSES = { module.exports = { meta: { + type: "style", + docs: { description: "disallow ternary operators when simpler alternatives exist", category: "Stylistic Issues", diff --git a/lib/rules/no-unreachable.js b/lib/rules/no-unreachable.js index 80d246307c3..5f90500a090 100644 --- a/lib/rules/no-unreachable.js +++ b/lib/rules/no-unreachable.js @@ -101,6 +101,8 @@ class ConsecutiveRange { module.exports = { meta: { + type: "problem", + docs: { description: "disallow unreachable code after `return`, `throw`, `continue`, and `break` statements", category: "Possible Errors", diff --git a/lib/rules/no-unsafe-finally.js b/lib/rules/no-unsafe-finally.js index 1ebdd2e3775..ab612ae6526 100644 --- a/lib/rules/no-unsafe-finally.js +++ b/lib/rules/no-unsafe-finally.js @@ -20,6 +20,8 @@ const SENTINEL_NODE_TYPE_CONTINUE = /^(?:Program|(?:Function|Class)(?:Declaratio module.exports = { meta: { + type: "problem", + docs: { description: "disallow control flow statements in `finally` blocks", category: "Possible Errors", diff --git a/lib/rules/no-unsafe-negation.js b/lib/rules/no-unsafe-negation.js index b04f80106c6..3a0402eb0d5 100644 --- a/lib/rules/no-unsafe-negation.js +++ b/lib/rules/no-unsafe-negation.js @@ -41,12 +41,15 @@ function isNegation(node) { module.exports = { meta: { + type: "problem", + docs: { description: "disallow negating the left operand of relational operators", category: "Possible Errors", recommended: true, url: "https://eslint.org/docs/rules/no-unsafe-negation" }, + schema: [], fixable: "code" }, diff --git a/lib/rules/no-unused-expressions.js b/lib/rules/no-unused-expressions.js index fedfac17d1f..854298b4119 100644 --- a/lib/rules/no-unused-expressions.js +++ b/lib/rules/no-unused-expressions.js @@ -10,6 +10,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow unused expressions", category: "Best Practices", diff --git a/lib/rules/no-unused-labels.js b/lib/rules/no-unused-labels.js index 3e1dcb6601f..c9e097df458 100644 --- a/lib/rules/no-unused-labels.js +++ b/lib/rules/no-unused-labels.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow unused labels", category: "Best Practices", @@ -19,7 +21,6 @@ module.exports = { }, schema: [], - fixable: "code" }, diff --git a/lib/rules/no-unused-vars.js b/lib/rules/no-unused-vars.js index fff3e33d923..bd517607c07 100644 --- a/lib/rules/no-unused-vars.js +++ b/lib/rules/no-unused-vars.js @@ -18,6 +18,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow unused variables", category: "Variables", @@ -372,7 +374,8 @@ module.exports = { return ref.isRead() && ( // self update. e.g. `a += 1`, `a++` - ( + (// in RHS of an assignment for itself. e.g. `a = a + 1` + (( parent.type === "AssignmentExpression" && granpa.type === "ExpressionStatement" && parent.left === id @@ -380,14 +383,9 @@ module.exports = { ( parent.type === "UpdateExpression" && granpa.type === "ExpressionStatement" - ) || - - // in RHS of an assignment for itself. e.g. `a = a + 1` - ( - rhsNode && - isInside(id, rhsNode) && - !isInsideOfStorableFunction(id, rhsNode) - ) + ) || rhsNode && + isInside(id, rhsNode) && + !isInsideOfStorableFunction(id, rhsNode))) ); } diff --git a/lib/rules/no-use-before-define.js b/lib/rules/no-use-before-define.js index 64d82570279..6f0b66bdb52 100644 --- a/lib/rules/no-use-before-define.js +++ b/lib/rules/no-use-before-define.js @@ -136,6 +136,8 @@ function isInInitializer(variable, reference) { module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow the use of variables before they are defined", category: "Variables", diff --git a/lib/rules/no-useless-call.js b/lib/rules/no-useless-call.js index 0778b374f4f..74e8bec08bc 100644 --- a/lib/rules/no-useless-call.js +++ b/lib/rules/no-useless-call.js @@ -49,6 +49,8 @@ function isValidThisArg(expectedThis, thisArg, sourceCode) { module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow unnecessary calls to `.call()` and `.apply()`", category: "Best Practices", diff --git a/lib/rules/no-useless-computed-key.js b/lib/rules/no-useless-computed-key.js index 189f50853c8..ef1f856f3ef 100644 --- a/lib/rules/no-useless-computed-key.js +++ b/lib/rules/no-useless-computed-key.js @@ -18,6 +18,8 @@ const MESSAGE_UNNECESSARY_COMPUTED = "Unnecessarily computed property [{{propert module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow unnecessary computed property keys in object literals", category: "ECMAScript 6", @@ -26,7 +28,6 @@ module.exports = { }, schema: [], - fixable: "code" }, create(context) { diff --git a/lib/rules/no-useless-concat.js b/lib/rules/no-useless-concat.js index e8e36aa1c1a..df310119032 100644 --- a/lib/rules/no-useless-concat.js +++ b/lib/rules/no-useless-concat.js @@ -66,6 +66,8 @@ function getRight(node) { module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow unnecessary concatenation of literals or template literals", category: "Best Practices", diff --git a/lib/rules/no-useless-constructor.js b/lib/rules/no-useless-constructor.js index 59e40bef8f4..c10376450eb 100644 --- a/lib/rules/no-useless-constructor.js +++ b/lib/rules/no-useless-constructor.js @@ -142,6 +142,8 @@ function isRedundantSuperCall(body, ctorParams) { module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow unnecessary constructors", category: "ECMAScript 6", diff --git a/lib/rules/no-useless-escape.js b/lib/rules/no-useless-escape.js index 7f4b87ed92c..c3c0421cc0c 100644 --- a/lib/rules/no-useless-escape.js +++ b/lib/rules/no-useless-escape.js @@ -79,6 +79,8 @@ function parseRegExp(regExpText) { module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow unnecessary escape characters", category: "Best Practices", diff --git a/lib/rules/no-useless-rename.js b/lib/rules/no-useless-rename.js index 83a03deb630..337f875b456 100644 --- a/lib/rules/no-useless-rename.js +++ b/lib/rules/no-useless-rename.js @@ -11,13 +11,17 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow renaming import, export, and destructured assignments to the same name", category: "ECMAScript 6", recommended: false, url: "https://eslint.org/docs/rules/no-useless-rename" }, + fixable: "code", + schema: [ { type: "object", diff --git a/lib/rules/no-useless-return.js b/lib/rules/no-useless-return.js index b5b8ebc32a1..bb11b4b3619 100644 --- a/lib/rules/no-useless-return.js +++ b/lib/rules/no-useless-return.js @@ -66,12 +66,15 @@ function isInFinally(node) { module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow redundant return statements", category: "Best Practices", recommended: false, url: "https://eslint.org/docs/rules/no-useless-return" }, + fixable: "code", schema: [] }, diff --git a/lib/rules/no-var.js b/lib/rules/no-var.js index 2c32a023dc9..edaed98f62e 100644 --- a/lib/rules/no-var.js +++ b/lib/rules/no-var.js @@ -180,6 +180,8 @@ function hasReferenceInTDZ(node) { module.exports = { meta: { + type: "suggestion", + docs: { description: "require `let` or `const` instead of `var`", category: "ECMAScript 6", diff --git a/lib/rules/no-void.js b/lib/rules/no-void.js index 1d3d887da66..d2b5d2f9631 100644 --- a/lib/rules/no-void.js +++ b/lib/rules/no-void.js @@ -10,6 +10,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow `void` operators", category: "Best Practices", diff --git a/lib/rules/no-warning-comments.js b/lib/rules/no-warning-comments.js index 5ff76e3a391..9ea39b490f8 100644 --- a/lib/rules/no-warning-comments.js +++ b/lib/rules/no-warning-comments.js @@ -13,6 +13,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow specified warning terms in comments", category: "Best Practices", diff --git a/lib/rules/no-whitespace-before-property.js b/lib/rules/no-whitespace-before-property.js index 4b71a9ec17d..49dc4ad7d04 100644 --- a/lib/rules/no-whitespace-before-property.js +++ b/lib/rules/no-whitespace-before-property.js @@ -16,6 +16,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "style", + docs: { description: "disallow whitespace before properties", category: "Stylistic Issues", diff --git a/lib/rules/no-with.js b/lib/rules/no-with.js index d72dcdfb21e..ecdf22c7d91 100644 --- a/lib/rules/no-with.js +++ b/lib/rules/no-with.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow `with` statements", category: "Best Practices", diff --git a/lib/rules/nonblock-statement-body-position.js b/lib/rules/nonblock-statement-body-position.js index e447ef886b3..d284c704832 100644 --- a/lib/rules/nonblock-statement-body-position.js +++ b/lib/rules/nonblock-statement-body-position.js @@ -12,13 +12,17 @@ const POSITION_SCHEMA = { enum: ["beside", "below", "any"] }; module.exports = { meta: { + type: "style", + docs: { description: "enforce the location of single-line statements", category: "Stylistic Issues", recommended: false, url: "https://eslint.org/docs/rules/nonblock-statement-body-position" }, + fixable: "whitespace", + schema: [ POSITION_SCHEMA, { diff --git a/lib/rules/object-curly-newline.js b/lib/rules/object-curly-newline.js index 494e78cff4a..58162ae6c11 100644 --- a/lib/rules/object-curly-newline.js +++ b/lib/rules/object-curly-newline.js @@ -134,13 +134,17 @@ function areLineBreaksRequired(node, options, first, last) { module.exports = { meta: { + type: "style", + docs: { description: "enforce consistent line breaks inside braces", category: "Stylistic Issues", recommended: false, url: "https://eslint.org/docs/rules/object-curly-newline" }, + fixable: "whitespace", + schema: [ { oneOf: [ diff --git a/lib/rules/object-curly-spacing.js b/lib/rules/object-curly-spacing.js index e7c847a6a95..712fbf3cd79 100644 --- a/lib/rules/object-curly-spacing.js +++ b/lib/rules/object-curly-spacing.js @@ -12,6 +12,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "style", + docs: { description: "enforce consistent spacing inside braces", category: "Stylistic Issues", diff --git a/lib/rules/object-property-newline.js b/lib/rules/object-property-newline.js index 65baf0a95e3..4c037c4b6cd 100644 --- a/lib/rules/object-property-newline.js +++ b/lib/rules/object-property-newline.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "style", + docs: { description: "enforce placing object properties on separate lines", category: "Stylistic Issues", @@ -38,8 +40,7 @@ module.exports = { create(context) { const allowSameLine = context.options[0] && ( - Boolean(context.options[0].allowAllPropertiesOnSameLine) || - Boolean(context.options[0].allowMultiplePropertiesPerLine) // Deprecated + (Boolean(context.options[0].allowAllPropertiesOnSameLine) || Boolean(context.options[0].allowMultiplePropertiesPerLine)) // Deprecated ); const errorMessage = allowSameLine ? "Object properties must go on a new line if they aren't all on the same line." diff --git a/lib/rules/object-shorthand.js b/lib/rules/object-shorthand.js index 21f039f8b6e..ff6a51a4d17 100644 --- a/lib/rules/object-shorthand.js +++ b/lib/rules/object-shorthand.js @@ -24,6 +24,8 @@ const astUtils = require("../util/ast-utils"); //------------------------------------------------------------------------------ module.exports = { meta: { + type: "suggestion", + docs: { description: "require or disallow method and property shorthand syntax for object literals", category: "ECMAScript 6", diff --git a/lib/rules/one-var-declaration-per-line.js b/lib/rules/one-var-declaration-per-line.js index e17529b6bed..f174508a69f 100644 --- a/lib/rules/one-var-declaration-per-line.js +++ b/lib/rules/one-var-declaration-per-line.js @@ -10,6 +10,8 @@ module.exports = { meta: { + type: "style", + docs: { description: "require or disallow newlines around variable declarations", category: "Stylistic Issues", diff --git a/lib/rules/one-var.js b/lib/rules/one-var.js index 13ab72b04ae..5a604cb528e 100644 --- a/lib/rules/one-var.js +++ b/lib/rules/one-var.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "style", + docs: { description: "enforce variables to be declared either together or separately in functions", category: "Stylistic Issues", diff --git a/lib/rules/operator-assignment.js b/lib/rules/operator-assignment.js index 8e4b7025eda..7e1d0803f3d 100644 --- a/lib/rules/operator-assignment.js +++ b/lib/rules/operator-assignment.js @@ -89,6 +89,8 @@ function canBeFixed(node) { module.exports = { meta: { + type: "style", + docs: { description: "require or disallow assignment operator shorthand where possible", category: "Stylistic Issues", diff --git a/lib/rules/operator-linebreak.js b/lib/rules/operator-linebreak.js index be2709a1bda..158855dbb93 100644 --- a/lib/rules/operator-linebreak.js +++ b/lib/rules/operator-linebreak.js @@ -17,6 +17,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "style", + docs: { description: "enforce consistent linebreak style for operators", category: "Stylistic Issues", diff --git a/lib/rules/padded-blocks.js b/lib/rules/padded-blocks.js index 370d47bccff..b308983d0e4 100644 --- a/lib/rules/padded-blocks.js +++ b/lib/rules/padded-blocks.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "style", + docs: { description: "require or disallow padding within blocks", category: "Stylistic Issues", diff --git a/lib/rules/padding-line-between-statements.js b/lib/rules/padding-line-between-statements.js index f571e1e2e33..c537236293c 100644 --- a/lib/rules/padding-line-between-statements.js +++ b/lib/rules/padding-line-between-statements.js @@ -397,13 +397,17 @@ const StatementTypes = { module.exports = { meta: { + type: "style", + docs: { description: "require or disallow padding lines between statements", category: "Stylistic Issues", recommended: false, url: "https://eslint.org/docs/rules/padding-line-between-statements" }, + fixable: "whitespace", + schema: { definitions: { paddingType: { diff --git a/lib/rules/prefer-arrow-callback.js b/lib/rules/prefer-arrow-callback.js index 1bc140b101b..77fc8f9fea0 100644 --- a/lib/rules/prefer-arrow-callback.js +++ b/lib/rules/prefer-arrow-callback.js @@ -132,6 +132,8 @@ function hasDuplicateParams(paramsList) { module.exports = { meta: { + type: "suggestion", + docs: { description: "require using arrow functions for callbacks", category: "ECMAScript 6", diff --git a/lib/rules/prefer-const.js b/lib/rules/prefer-const.js index 774fcf06437..44d11dd235d 100644 --- a/lib/rules/prefer-const.js +++ b/lib/rules/prefer-const.js @@ -271,6 +271,8 @@ function findUp(node, type, shouldStop) { module.exports = { meta: { + type: "suggestion", + docs: { description: "require `const` declarations for variables that are never reassigned after declared", category: "ECMAScript 6", diff --git a/lib/rules/prefer-destructuring.js b/lib/rules/prefer-destructuring.js index 112ea64613c..119fae56089 100644 --- a/lib/rules/prefer-destructuring.js +++ b/lib/rules/prefer-destructuring.js @@ -10,12 +10,15 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "require destructuring from arrays and/or objects", category: "ECMAScript 6", recommended: false, url: "https://eslint.org/docs/rules/prefer-destructuring" }, + schema: [ { diff --git a/lib/rules/prefer-numeric-literals.js b/lib/rules/prefer-numeric-literals.js index 051a91c81cb..ca7358aa013 100644 --- a/lib/rules/prefer-numeric-literals.js +++ b/lib/rules/prefer-numeric-literals.js @@ -38,6 +38,8 @@ function isParseInt(calleeNode) { module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow `parseInt()` and `Number.parseInt()` in favor of binary, octal, and hexadecimal literals", category: "ECMAScript 6", @@ -46,7 +48,6 @@ module.exports = { }, schema: [], - fixable: "code" }, diff --git a/lib/rules/prefer-object-spread.js b/lib/rules/prefer-object-spread.js index 8e54de2496a..4709faf5c1f 100644 --- a/lib/rules/prefer-object-spread.js +++ b/lib/rules/prefer-object-spread.js @@ -212,6 +212,8 @@ function defineFixer(node, sourceCode) { module.exports = { meta: { + type: "style", + docs: { description: "disallow using Object.assign with an object literal as the first argument and prefer the use of object spread instead.", @@ -219,8 +221,10 @@ module.exports = { recommended: false, url: "https://eslint.org/docs/rules/prefer-object-spread" }, + schema: [], fixable: "code", + messages: { useSpreadMessage: "Use an object spread instead of `Object.assign` eg: `{ ...foo }`", useLiteralMessage: "Use an object literal instead of `Object.assign`. eg: `{ foo: bar }`" diff --git a/lib/rules/prefer-promise-reject-errors.js b/lib/rules/prefer-promise-reject-errors.js index e3d298a743c..0db5ae874cf 100644 --- a/lib/rules/prefer-promise-reject-errors.js +++ b/lib/rules/prefer-promise-reject-errors.js @@ -12,13 +12,17 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "suggestion", + docs: { description: "require using Error objects as Promise rejection reasons", category: "Best Practices", recommended: false, url: "https://eslint.org/docs/rules/prefer-promise-reject-errors" }, + fixable: null, + schema: [ { type: "object", diff --git a/lib/rules/prefer-reflect.js b/lib/rules/prefer-reflect.js index 765163e0eb3..6adec5cec30 100644 --- a/lib/rules/prefer-reflect.js +++ b/lib/rules/prefer-reflect.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "require `Reflect` methods where applicable", category: "ECMAScript 6", diff --git a/lib/rules/prefer-rest-params.js b/lib/rules/prefer-rest-params.js index 133456e4d17..95a562c4a2f 100644 --- a/lib/rules/prefer-rest-params.js +++ b/lib/rules/prefer-rest-params.js @@ -62,6 +62,8 @@ function isNotNormalMemberAccess(reference) { module.exports = { meta: { + type: "suggestion", + docs: { description: "require rest parameters instead of `arguments`", category: "ECMAScript 6", diff --git a/lib/rules/prefer-spread.js b/lib/rules/prefer-spread.js index 9bf69c80f7b..790fd3b82aa 100644 --- a/lib/rules/prefer-spread.js +++ b/lib/rules/prefer-spread.js @@ -49,6 +49,8 @@ function isValidThisArg(expectedThis, thisArg, context) { module.exports = { meta: { + type: "suggestion", + docs: { description: "require spread operators instead of `.apply()`", category: "ECMAScript 6", @@ -57,7 +59,6 @@ module.exports = { }, schema: [], - fixable: "code" }, diff --git a/lib/rules/prefer-template.js b/lib/rules/prefer-template.js index 0471d61caef..386674a92ef 100644 --- a/lib/rules/prefer-template.js +++ b/lib/rules/prefer-template.js @@ -141,6 +141,8 @@ function endsWithTemplateCurly(node) { module.exports = { meta: { + type: "suggestion", + docs: { description: "require template literals instead of string concatenation", category: "ECMAScript 6", @@ -149,7 +151,6 @@ module.exports = { }, schema: [], - fixable: "code" }, diff --git a/lib/rules/quote-props.js b/lib/rules/quote-props.js index 36739494da4..ec3f753ec62 100644 --- a/lib/rules/quote-props.js +++ b/lib/rules/quote-props.js @@ -17,6 +17,8 @@ const espree = require("espree"), module.exports = { meta: { + type: "style", + docs: { description: "require quotes around object literal property names", category: "Stylistic Issues", diff --git a/lib/rules/quotes.js b/lib/rules/quotes.js index 8dd61c3e371..248ed90d089 100644 --- a/lib/rules/quotes.js +++ b/lib/rules/quotes.js @@ -76,6 +76,8 @@ const AVOID_ESCAPE = "avoid-escape"; module.exports = { meta: { + type: "style", + docs: { description: "enforce the consistent use of either backticks, double, or single quotes", category: "Stylistic Issues", diff --git a/lib/rules/radix.js b/lib/rules/radix.js index f71220beb4e..5d3805d0a70 100644 --- a/lib/rules/radix.js +++ b/lib/rules/radix.js @@ -78,6 +78,8 @@ function isDefaultRadix(radix) { module.exports = { meta: { + type: "suggestion", + docs: { description: "enforce the consistent use of the radix argument when using `parseInt()`", category: "Best Practices", diff --git a/lib/rules/require-atomic-updates.js b/lib/rules/require-atomic-updates.js index 5d7d7151455..9c1ed8389f4 100644 --- a/lib/rules/require-atomic-updates.js +++ b/lib/rules/require-atomic-updates.js @@ -12,14 +12,18 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "problem", + docs: { description: "disallow assignments that can lead to race conditions due to usage of `await` or `yield`", category: "Possible Errors", recommended: false, url: "https://eslint.org/docs/rules/require-atomic-updates" }, + fixable: null, schema: [], + messages: { nonAtomicUpdate: "Possible race condition: `{{value}}` might be reassigned based on an outdated value of `{{value}}`." } diff --git a/lib/rules/require-await.js b/lib/rules/require-await.js index de39f372fd6..5e614c50251 100644 --- a/lib/rules/require-await.js +++ b/lib/rules/require-await.js @@ -31,12 +31,15 @@ function capitalizeFirstLetter(text) { module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow async functions which have no `await` expression", category: "Best Practices", recommended: false, url: "https://eslint.org/docs/rules/require-await" }, + schema: [] }, diff --git a/lib/rules/require-jsdoc.js b/lib/rules/require-jsdoc.js index 91b90b7d10a..c0f5a3d5891 100644 --- a/lib/rules/require-jsdoc.js +++ b/lib/rules/require-jsdoc.js @@ -6,6 +6,8 @@ module.exports = { meta: { + type: "style", + docs: { description: "require JSDoc comments", category: "Stylistic Issues", diff --git a/lib/rules/require-unicode-regexp.js b/lib/rules/require-unicode-regexp.js index 55ca4ff89a6..880405e9a25 100644 --- a/lib/rules/require-unicode-regexp.js +++ b/lib/rules/require-unicode-regexp.js @@ -22,15 +22,19 @@ const { module.exports = { meta: { + type: "suggestion", + docs: { description: "enforce the use of `u` flag on RegExp", category: "Best Practices", recommended: false, url: "https://eslint.org/docs/rules/require-unicode-regexp" }, + messages: { requireUFlag: "Use the 'u' flag." }, + schema: [] }, diff --git a/lib/rules/require-yield.js b/lib/rules/require-yield.js index 83a29876f09..7bb7cf9a872 100644 --- a/lib/rules/require-yield.js +++ b/lib/rules/require-yield.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "require generator functions to contain `yield`", category: "ECMAScript 6", diff --git a/lib/rules/rest-spread-spacing.js b/lib/rules/rest-spread-spacing.js index e87d881298b..bbc10320183 100644 --- a/lib/rules/rest-spread-spacing.js +++ b/lib/rules/rest-spread-spacing.js @@ -11,13 +11,17 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "enforce spacing between rest and spread operators and their expressions", category: "ECMAScript 6", recommended: false, url: "https://eslint.org/docs/rules/rest-spread-spacing" }, + fixable: "whitespace", + schema: [ { enum: ["always", "never"] diff --git a/lib/rules/semi-spacing.js b/lib/rules/semi-spacing.js index 75b53055a69..41c3eb078ba 100644 --- a/lib/rules/semi-spacing.js +++ b/lib/rules/semi-spacing.js @@ -13,6 +13,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "style", + docs: { description: "enforce consistent spacing before and after semicolons", category: "Stylistic Issues", diff --git a/lib/rules/semi-style.js b/lib/rules/semi-style.js index 34899bb5444..62bbb05742c 100644 --- a/lib/rules/semi-style.js +++ b/lib/rules/semi-style.js @@ -65,12 +65,15 @@ function isLastChild(node) { module.exports = { meta: { + type: "style", + docs: { description: "enforce location of semicolons", category: "Stylistic Issues", recommended: false, url: "https://eslint.org/docs/rules/semi-style" }, + schema: [{ enum: ["last", "first"] }], fixable: "whitespace" }, diff --git a/lib/rules/semi.js b/lib/rules/semi.js index 129d106414d..98f68a4b325 100644 --- a/lib/rules/semi.js +++ b/lib/rules/semi.js @@ -17,6 +17,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "style", + docs: { description: "require or disallow semicolons instead of ASI", category: "Stylistic Issues", diff --git a/lib/rules/sort-imports.js b/lib/rules/sort-imports.js index 8735be5d307..76997cc73d8 100644 --- a/lib/rules/sort-imports.js +++ b/lib/rules/sort-imports.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "enforce sorted import declarations within modules", category: "ECMAScript 6", diff --git a/lib/rules/sort-keys.js b/lib/rules/sort-keys.js index 6e538f73291..7da671c980c 100644 --- a/lib/rules/sort-keys.js +++ b/lib/rules/sort-keys.js @@ -73,12 +73,15 @@ const isValidOrders = { module.exports = { meta: { + type: "style", + docs: { description: "require object keys to be sorted", category: "Stylistic Issues", recommended: false, url: "https://eslint.org/docs/rules/sort-keys" }, + schema: [ { enum: ["asc", "desc"] diff --git a/lib/rules/sort-vars.js b/lib/rules/sort-vars.js index 334deb0657f..7b0e0cdca37 100644 --- a/lib/rules/sort-vars.js +++ b/lib/rules/sort-vars.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "style", + docs: { description: "require variables within the same declaration block to be sorted", category: "Stylistic Issues", diff --git a/lib/rules/space-before-blocks.js b/lib/rules/space-before-blocks.js index 4f22ae6b653..feb60bd5e5b 100644 --- a/lib/rules/space-before-blocks.js +++ b/lib/rules/space-before-blocks.js @@ -13,6 +13,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "style", + docs: { description: "enforce consistent spacing before blocks", category: "Stylistic Issues", diff --git a/lib/rules/space-before-function-paren.js b/lib/rules/space-before-function-paren.js index 81697d64f1f..ec4053c1ec9 100644 --- a/lib/rules/space-before-function-paren.js +++ b/lib/rules/space-before-function-paren.js @@ -16,6 +16,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "style", + docs: { description: "enforce consistent spacing before `function` definition opening parenthesis", category: "Stylistic Issues", diff --git a/lib/rules/space-in-parens.js b/lib/rules/space-in-parens.js index aa137438034..f5175e0d6b6 100644 --- a/lib/rules/space-in-parens.js +++ b/lib/rules/space-in-parens.js @@ -12,6 +12,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "style", + docs: { description: "enforce consistent spacing inside parentheses", category: "Stylistic Issues", diff --git a/lib/rules/space-infix-ops.js b/lib/rules/space-infix-ops.js index 49b64658d19..0e9f809bec3 100644 --- a/lib/rules/space-infix-ops.js +++ b/lib/rules/space-infix-ops.js @@ -10,6 +10,8 @@ module.exports = { meta: { + type: "style", + docs: { description: "require spacing around infix operators", category: "Stylistic Issues", diff --git a/lib/rules/space-unary-ops.js b/lib/rules/space-unary-ops.js index 5032b46c3b0..5b3a0ef0167 100644 --- a/lib/rules/space-unary-ops.js +++ b/lib/rules/space-unary-ops.js @@ -16,6 +16,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "style", + docs: { description: "enforce consistent spacing before or after unary operators", category: "Stylistic Issues", diff --git a/lib/rules/spaced-comment.js b/lib/rules/spaced-comment.js index 6fbe2aac790..4908094e32c 100644 --- a/lib/rules/spaced-comment.js +++ b/lib/rules/spaced-comment.js @@ -151,6 +151,8 @@ function createNeverStylePattern(markers) { module.exports = { meta: { + type: "style", + docs: { description: "enforce consistent spacing after the `//` or `/*` in a comment", category: "Stylistic Issues", diff --git a/lib/rules/strict.js b/lib/rules/strict.js index 8b5757738de..bec1baf4653 100644 --- a/lib/rules/strict.js +++ b/lib/rules/strict.js @@ -80,6 +80,8 @@ function isSimpleParameterList(params) { module.exports = { meta: { + type: "suggestion", + docs: { description: "require or disallow strict mode directives", category: "Strict Mode", diff --git a/lib/rules/switch-colon-spacing.js b/lib/rules/switch-colon-spacing.js index 23dfff6133d..f79c08c2b50 100644 --- a/lib/rules/switch-colon-spacing.js +++ b/lib/rules/switch-colon-spacing.js @@ -17,12 +17,15 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "style", + docs: { description: "enforce spacing around colons of switch statements", category: "Stylistic Issues", recommended: false, url: "https://eslint.org/docs/rules/switch-colon-spacing" }, + schema: [ { type: "object", @@ -33,6 +36,7 @@ module.exports = { additionalProperties: false } ], + fixable: "whitespace" }, diff --git a/lib/rules/symbol-description.js b/lib/rules/symbol-description.js index 271012b5429..7bb4e2dec69 100644 --- a/lib/rules/symbol-description.js +++ b/lib/rules/symbol-description.js @@ -18,6 +18,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "suggestion", + docs: { description: "require symbol descriptions", category: "ECMAScript 6", diff --git a/lib/rules/template-curly-spacing.js b/lib/rules/template-curly-spacing.js index 6702d730cd3..b3ab3e288a3 100644 --- a/lib/rules/template-curly-spacing.js +++ b/lib/rules/template-curly-spacing.js @@ -24,6 +24,8 @@ const CLOSE_PAREN = /^\}/; module.exports = { meta: { + type: "suggestion", + docs: { description: "require or disallow spacing around embedded expressions of template strings", category: "ECMAScript 6", diff --git a/lib/rules/template-tag-spacing.js b/lib/rules/template-tag-spacing.js index aee7ac108be..0d5b23c8682 100644 --- a/lib/rules/template-tag-spacing.js +++ b/lib/rules/template-tag-spacing.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "style", + docs: { description: "require or disallow spacing between template tags and their literals", category: "Stylistic Issues", diff --git a/lib/rules/unicode-bom.js b/lib/rules/unicode-bom.js index 03b2d5ae68e..4c9a68b173a 100644 --- a/lib/rules/unicode-bom.js +++ b/lib/rules/unicode-bom.js @@ -10,6 +10,8 @@ module.exports = { meta: { + type: "style", + docs: { description: "require or disallow Unicode byte order mark (BOM)", category: "Stylistic Issues", diff --git a/lib/rules/use-isnan.js b/lib/rules/use-isnan.js index 5bad5b3c6dd..343ca045444 100644 --- a/lib/rules/use-isnan.js +++ b/lib/rules/use-isnan.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "problem", + docs: { description: "require calls to `isNaN()` when checking for `NaN`", category: "Possible Errors", diff --git a/lib/rules/valid-jsdoc.js b/lib/rules/valid-jsdoc.js index 42d66a8a79b..c7b96af5c05 100644 --- a/lib/rules/valid-jsdoc.js +++ b/lib/rules/valid-jsdoc.js @@ -16,6 +16,8 @@ const doctrine = require("doctrine"); module.exports = { meta: { + type: "problem", + docs: { description: "enforce valid JSDoc comments", category: "Possible Errors", diff --git a/lib/rules/valid-typeof.js b/lib/rules/valid-typeof.js index ac4e74f20ba..e3245e8f306 100644 --- a/lib/rules/valid-typeof.js +++ b/lib/rules/valid-typeof.js @@ -10,6 +10,8 @@ module.exports = { meta: { + type: "problem", + docs: { description: "enforce comparing `typeof` expressions against valid strings", category: "Possible Errors", diff --git a/lib/rules/vars-on-top.js b/lib/rules/vars-on-top.js index 0489aa61fcc..d69c223388f 100644 --- a/lib/rules/vars-on-top.js +++ b/lib/rules/vars-on-top.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "require `var` declarations be placed at the top of their containing scope", category: "Best Practices", diff --git a/lib/rules/wrap-iife.js b/lib/rules/wrap-iife.js index d006d30a004..c31ade1801d 100644 --- a/lib/rules/wrap-iife.js +++ b/lib/rules/wrap-iife.js @@ -17,6 +17,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "suggestion", + docs: { description: "require parentheses around immediate `function` invocations", category: "Best Practices", diff --git a/lib/rules/wrap-regex.js b/lib/rules/wrap-regex.js index 1816e0e9e64..110f944cf53 100644 --- a/lib/rules/wrap-regex.js +++ b/lib/rules/wrap-regex.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "style", + docs: { description: "require parenthesis around regex literals", category: "Stylistic Issues", @@ -19,8 +21,8 @@ module.exports = { }, schema: [], - fixable: "code", + messages: { requireParens: "Wrap the regexp literal in parens to disambiguate the slash." } diff --git a/lib/rules/yield-star-spacing.js b/lib/rules/yield-star-spacing.js index 33a37f0d991..9f9b1c34623 100644 --- a/lib/rules/yield-star-spacing.js +++ b/lib/rules/yield-star-spacing.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "require or disallow spacing around the `*` in `yield*` expressions", category: "ECMAScript 6", diff --git a/lib/rules/yoda.js b/lib/rules/yoda.js index 35368dd4df9..8789c001ef9 100644 --- a/lib/rules/yoda.js +++ b/lib/rules/yoda.js @@ -152,6 +152,8 @@ function same(a, b) { module.exports = { meta: { + type: "suggestion", + docs: { description: "require or disallow \"Yoda\" conditions", category: "Best Practices", diff --git a/tests/fixtures/fix-types/fix-only-prefer-arrow-callback.expected.js b/tests/fixtures/fix-types/fix-only-prefer-arrow-callback.expected.js new file mode 100644 index 00000000000..392dbf08994 --- /dev/null +++ b/tests/fixtures/fix-types/fix-only-prefer-arrow-callback.expected.js @@ -0,0 +1,7 @@ +/* eslint semi: "error" */ +/* eslint prefer-arrow-callback: "error" */ +"use strict"; + +func(() => { + return true; +}) diff --git a/tests/fixtures/fix-types/fix-only-prefer-arrow-callback.js b/tests/fixtures/fix-types/fix-only-prefer-arrow-callback.js new file mode 100644 index 00000000000..26d3429d028 --- /dev/null +++ b/tests/fixtures/fix-types/fix-only-prefer-arrow-callback.js @@ -0,0 +1,7 @@ +/* eslint semi: "error" */ +/* eslint prefer-arrow-callback: "error" */ +"use strict"; + +func(function() { + return true; +}) diff --git a/tests/fixtures/fix-types/fix-only-semi.expected.js b/tests/fixtures/fix-types/fix-only-semi.expected.js new file mode 100644 index 00000000000..3a8f9f44e01 --- /dev/null +++ b/tests/fixtures/fix-types/fix-only-semi.expected.js @@ -0,0 +1,7 @@ +/* eslint semi: "error" */ +/* eslint prefer-arrow-callback: "error" */ +"use strict"; + +func(function() { + return true; +}); diff --git a/tests/fixtures/fix-types/fix-only-semi.js b/tests/fixtures/fix-types/fix-only-semi.js new file mode 100644 index 00000000000..26d3429d028 --- /dev/null +++ b/tests/fixtures/fix-types/fix-only-semi.js @@ -0,0 +1,7 @@ +/* eslint semi: "error" */ +/* eslint prefer-arrow-callback: "error" */ +"use strict"; + +func(function() { + return true; +}) diff --git a/tests/fixtures/fix-types/semi.expected.js b/tests/fixtures/fix-types/semi.expected.js new file mode 100644 index 00000000000..40d6cf87c01 --- /dev/null +++ b/tests/fixtures/fix-types/semi.expected.js @@ -0,0 +1,7 @@ +/* eslint semi: "error" */ +/* eslint prefer-arrow-callback: "error" */ +"use strict"; + +func(function () { + return true; +}); diff --git a/tests/fixtures/fix-types/semi.js b/tests/fixtures/fix-types/semi.js new file mode 100644 index 00000000000..26d3429d028 --- /dev/null +++ b/tests/fixtures/fix-types/semi.js @@ -0,0 +1,7 @@ +/* eslint semi: "error" */ +/* eslint prefer-arrow-callback: "error" */ +"use strict"; + +func(function() { + return true; +}) diff --git a/tests/lib/cli-engine.js b/tests/lib/cli-engine.js index cac7671b197..45560db454b 100644 --- a/tests/lib/cli-engine.js +++ b/tests/lib/cli-engine.js @@ -331,6 +331,40 @@ describe("CLIEngine", () => { assert.strictEqual(report.results[0].output, expectedOutput); }); + describe("Fix Types", () => { + + it("should not fix non-style rules when fixTypes has only 'style'", () => { + engine = new CLIEngine({ + cwd: path.join(fixtureDir, ".."), + useEslintrc: false, + fix: true, + fixTypes: ["style"] + }); + const inputPath = getFixturePath("fix-types/fix-only-semi.js"); + const outputPath = getFixturePath("fix-types/fix-only-semi.expected.js"); + const report = engine.executeOnFiles([inputPath]); + const expectedOutput = fs.readFileSync(outputPath, "utf8"); + + assert.strictEqual(report.results[0].output, expectedOutput); + }); + + it("should not fix style or problem rules when fixTypes has only 'suggestion'", () => { + engine = new CLIEngine({ + cwd: path.join(fixtureDir, ".."), + useEslintrc: false, + fix: true, + fixTypes: ["suggestion"] + }); + const inputPath = getFixturePath("fix-types/fix-only-prefer-arrow-callback.js"); + const outputPath = getFixturePath("fix-types/fix-only-prefer-arrow-callback.expected.js"); + const report = engine.executeOnFiles([inputPath]); + const expectedOutput = fs.readFileSync(outputPath, "utf8"); + + assert.strictEqual(report.results[0].output, expectedOutput); + }); + + }); + it("should return a message and omit fixed text when in fix mode and fixes aren't done", () => { engine = new CLIEngine({ diff --git a/tests/lib/options.js b/tests/lib/options.js index 26a84b4a090..9027c42a324 100644 --- a/tests/lib/options.js +++ b/tests/lib/options.js @@ -328,6 +328,31 @@ describe("options", () => { }); }); + describe("--fix-type", () => { + it("should return one value with --fix-type is passed", () => { + const currentOptions = options.parse("--fix-type problem"); + + assert.equal(currentOptions.fixType.length, 1); + assert.equal(currentOptions.fixType[0], "problem"); + }); + + it("should return two values when --fix-type is passed twice", () => { + const currentOptions = options.parse("--fix-type problem --fix-type suggestion"); + + assert.equal(currentOptions.fixType.length, 2); + assert.equal(currentOptions.fixType[0], "problem"); + assert.equal(currentOptions.fixType[1], "suggestion"); + }); + + it("should return two values when --fix-type is passed a comma-separated value", () => { + const currentOptions = options.parse("--fix-type problem,suggestion"); + + assert.equal(currentOptions.fixType.length, 2); + assert.equal(currentOptions.fixType[0], "problem"); + assert.equal(currentOptions.fixType[1], "suggestion"); + }); + }); + describe("--debug", () => { it("should return true for --debug when passed", () => { const currentOptions = options.parse("--debug"); diff --git a/tools/rule-types.json b/tools/rule-types.json new file mode 100644 index 00000000000..1a866e3497e --- /dev/null +++ b/tools/rule-types.json @@ -0,0 +1,266 @@ +{ + "accessor-pairs": "suggestion", + "array-bracket-newline": "style", + "array-bracket-spacing": "style", + "array-callback-return": "suggestion", + "array-element-newline": "style", + "arrow-body-style": "suggestion", + "arrow-parens": "suggestion", + "arrow-spacing": "suggestion", + "block-scoped-var": "suggestion", + "block-spacing": "style", + "brace-style": "style", + "callback-return": "suggestion", + "camelcase": "style", + "capitalized-comments": "style", + "class-methods-use-this": "suggestion", + "comma-dangle": "style", + "comma-spacing": "style", + "comma-style": "style", + "complexity": "suggestion", + "computed-property-spacing": "style", + "consistent-return": "suggestion", + "consistent-this": "style", + "constructor-super": "suggestion", + "curly": "suggestion", + "default-case": "suggestion", + "dot-location": "suggestion", + "dot-notation": "suggestion", + "eol-last": "style", + "eqeqeq": "suggestion", + "for-direction": "problem", + "func-call-spacing": "style", + "func-name-matching": "style", + "func-names": "style", + "func-style": "style", + "function-paren-newline": "style", + "generator-star-spacing": "suggestion", + "getter-return": "problem", + "global-require": "suggestion", + "guard-for-in": "suggestion", + "handle-callback-err": "suggestion", + "id-blacklist": "style", + "id-length": "style", + "id-match": "style", + "implicit-arrow-linebreak": "style", + "indent": "style", + "indent-legacy": "style", + "init-declarations": "suggestion", + "jsx-quotes": "style", + "key-spacing": "style", + "keyword-spacing": "style", + "line-comment-position": "style", + "linebreak-style": "style", + "lines-around-comment": "style", + "lines-around-directive": "style", + "lines-between-class-members": "style", + "max-classes-per-file": "suggestion", + "max-depth": "style", + "max-len": "style", + "max-lines": "style", + "max-lines-per-function": "style", + "max-nested-callbacks": "style", + "max-params": "style", + "max-statements": "style", + "max-statements-per-line": "style", + "multiline-comment-style": "style", + "multiline-ternary": "style", + "new-cap": "style", + "new-parens": "style", + "newline-after-var": "style", + "newline-before-return": "style", + "newline-per-chained-call": "style", + "no-alert": "suggestion", + "no-array-constructor": "style", + "no-async-promise-executor": "problem", + "no-await-in-loop": "problem", + "no-bitwise": "style", + "no-buffer-constructor": "suggestion", + "no-caller": "suggestion", + "no-case-declarations": "suggestion", + "no-catch-shadow": "suggestion", + "no-class-assign": "suggestion", + "no-compare-neg-zero": "problem", + "no-cond-assign": "problem", + "no-confusing-arrow": "suggestion", + "no-console": "problem", + "no-const-assign": "suggestion", + "no-constant-condition": "problem", + "no-continue": "style", + "no-control-regex": "problem", + "no-debugger": "problem", + "no-delete-var": "suggestion", + "no-div-regex": "suggestion", + "no-dupe-args": "problem", + "no-dupe-class-members": "suggestion", + "no-dupe-keys": "problem", + "no-duplicate-case": "problem", + "no-duplicate-imports": "suggestion", + "no-else-return": "suggestion", + "no-empty": "problem", + "no-empty-character-class": "problem", + "no-empty-function": "suggestion", + "no-empty-pattern": "suggestion", + "no-eq-null": "suggestion", + "no-eval": "suggestion", + "no-ex-assign": "problem", + "no-extend-native": "suggestion", + "no-extra-bind": "suggestion", + "no-extra-boolean-cast": "problem", + "no-extra-label": "suggestion", + "no-extra-parens": "problem", + "no-extra-semi": "problem", + "no-fallthrough": "suggestion", + "no-floating-decimal": "suggestion", + "no-func-assign": "problem", + "no-global-assign": "suggestion", + "no-implicit-coercion": "suggestion", + "no-implicit-globals": "suggestion", + "no-implied-eval": "suggestion", + "no-inline-comments": "style", + "no-inner-declarations": "problem", + "no-invalid-regexp": "problem", + "no-invalid-this": "suggestion", + "no-irregular-whitespace": "problem", + "no-iterator": "suggestion", + "no-label-var": "suggestion", + "no-labels": "suggestion", + "no-lone-blocks": "suggestion", + "no-lonely-if": "style", + "no-loop-func": "suggestion", + "no-magic-numbers": "suggestion", + "no-misleading-character-class": "problem", + "no-mixed-operators": "style", + "no-mixed-requires": "suggestion", + "no-mixed-spaces-and-tabs": "style", + "no-multi-assign": "style", + "no-multi-spaces": "suggestion", + "no-multi-str": "suggestion", + "no-multiple-empty-lines": "style", + "no-native-reassign": "suggestion", + "no-negated-condition": "style", + "no-negated-in-lhs": "problem", + "no-nested-ternary": "style", + "no-new": "suggestion", + "no-new-func": "suggestion", + "no-new-object": "style", + "no-new-require": "suggestion", + "no-new-symbol": "suggestion", + "no-new-wrappers": "suggestion", + "no-obj-calls": "problem", + "no-octal": "suggestion", + "no-octal-escape": "suggestion", + "no-param-reassign": "suggestion", + "no-path-concat": "suggestion", + "no-plusplus": "style", + "no-process-env": "suggestion", + "no-process-exit": "suggestion", + "no-proto": "suggestion", + "no-prototype-builtins": "problem", + "no-redeclare": "suggestion", + "no-regex-spaces": "problem", + "no-restricted-globals": "suggestion", + "no-restricted-imports": "suggestion", + "no-restricted-modules": "suggestion", + "no-restricted-properties": "suggestion", + "no-restricted-syntax": "style", + "no-return-assign": "suggestion", + "no-return-await": "suggestion", + "no-script-url": "suggestion", + "no-self-assign": "suggestion", + "no-self-compare": "suggestion", + "no-sequences": "suggestion", + "no-shadow": "suggestion", + "no-shadow-restricted-names": "suggestion", + "no-spaced-func": "style", + "no-sparse-arrays": "problem", + "no-sync": "suggestion", + "no-tabs": "style", + "no-template-curly-in-string": "problem", + "no-ternary": "style", + "no-this-before-super": "suggestion", + "no-throw-literal": "suggestion", + "no-trailing-spaces": "style", + "no-undef": "suggestion", + "no-undef-init": "suggestion", + "no-undefined": "suggestion", + "no-underscore-dangle": "style", + "no-unexpected-multiline": "problem", + "no-unmodified-loop-condition": "suggestion", + "no-unneeded-ternary": "style", + "no-unreachable": "problem", + "no-unsafe-finally": "problem", + "no-unsafe-negation": "problem", + "no-unused-expressions": "suggestion", + "no-unused-labels": "suggestion", + "no-unused-vars": "suggestion", + "no-use-before-define": "suggestion", + "no-useless-call": "suggestion", + "no-useless-computed-key": "suggestion", + "no-useless-concat": "suggestion", + "no-useless-constructor": "suggestion", + "no-useless-escape": "suggestion", + "no-useless-rename": "suggestion", + "no-useless-return": "suggestion", + "no-var": "suggestion", + "no-void": "suggestion", + "no-warning-comments": "suggestion", + "no-whitespace-before-property": "style", + "no-with": "suggestion", + "nonblock-statement-body-position": "style", + "object-curly-newline": "style", + "object-curly-spacing": "style", + "object-property-newline": "style", + "object-shorthand": "suggestion", + "one-var": "style", + "one-var-declaration-per-line": "style", + "operator-assignment": "style", + "operator-linebreak": "style", + "padded-blocks": "style", + "padding-line-between-statements": "style", + "prefer-arrow-callback": "suggestion", + "prefer-const": "suggestion", + "prefer-destructuring": "suggestion", + "prefer-numeric-literals": "suggestion", + "prefer-object-spread": "style", + "prefer-promise-reject-errors": "suggestion", + "prefer-reflect": "suggestion", + "prefer-rest-params": "suggestion", + "prefer-spread": "suggestion", + "prefer-template": "suggestion", + "quote-props": "style", + "quotes": "style", + "radix": "suggestion", + "require-atomic-updates": "problem", + "require-await": "suggestion", + "require-jsdoc": "style", + "require-unicode-regexp": "suggestion", + "require-yield": "suggestion", + "rest-spread-spacing": "suggestion", + "semi": "style", + "semi-spacing": "style", + "semi-style": "style", + "sort-imports": "suggestion", + "sort-keys": "style", + "sort-vars": "style", + "space-before-blocks": "style", + "space-before-function-paren": "style", + "space-in-parens": "style", + "space-infix-ops": "style", + "space-unary-ops": "style", + "spaced-comment": "style", + "strict": "suggestion", + "switch-colon-spacing": "style", + "symbol-description": "suggestion", + "template-curly-spacing": "suggestion", + "template-tag-spacing": "style", + "unicode-bom": "style", + "use-isnan": "problem", + "valid-jsdoc": "problem", + "valid-typeof": "problem", + "vars-on-top": "suggestion", + "wrap-iife": "suggestion", + "wrap-regex": "style", + "yield-star-spacing": "suggestion", + "yoda": "suggestion" +} \ No newline at end of file diff --git a/tools/update-rule-types.js b/tools/update-rule-types.js new file mode 100644 index 00000000000..37c4597199b --- /dev/null +++ b/tools/update-rule-types.js @@ -0,0 +1,72 @@ +/** + * JSCodeShift script to update meta.type in rules. + * Run over the rules directory only. Use this command: + * + * jscodeshift -t tools/update-rule-types.js lib/rules/ + * + * @author Nicholas C. Zakas + */ +"use strict"; + +const path = require("path"); +const ruleTypes = require("./rule-types.json"); + +module.exports = (fileInfo, api) => { + const j = api.jscodeshift; + const source = fileInfo.source; + const ruleName = path.basename(fileInfo.path, ".js"); + + // get the object literal representing the rule + const nodes = j(source).find(j.ObjectExpression).filter((p) => { + return p.node.properties.some(node => node.key.name === "meta"); + }); + + // updating logic + return nodes.replaceWith((p) => { + + // gather important nodes from the rule + const metaNode = p.node.properties.find(node => node.key.name === "meta"); + const typeNode = metaNode.value.properties ? metaNode.value.properties.find(node => node.key.name === "type") : null; + + const docsNode = metaNode.value.properties.find(node => node.key.name === "docs"); + const categoryNode = docsNode.value.properties.find(node => node.key.name === "category").value; + + let ruleType; + + // the rule-types.json file takes highest priority + if (ruleName in ruleTypes) { + ruleType = ruleTypes[ruleName]; + } else { + + // otherwise fallback to category + switch (categoryNode.value) { + case "Stylistic Issues": + ruleType = "style"; + break; + + case "Possible Errors": + ruleType = "problem"; + break; + + default: + ruleType = "suggestion"; + } + } + + if (typeNode) { + // update existing type node + typeNode.value = j.literal(ruleType); + } else { + + // add new type node if one doesn't exist + const newProp = j.property( + "init", + j.identifier("type"), + j.literal(ruleType) + ); + p.node.properties[0].value.properties.unshift(newProp); + } + + return p.node; + }).toSource(); +}; \ No newline at end of file