From e173dbc76f5a2d619524466cad52676e3f402efb Mon Sep 17 00:00:00 2001 From: "Nicholas C. Zakas" Date: Wed, 19 Sep 2018 08:24:18 -0700 Subject: [PATCH 01/25] New: Add --fix-type option to CLI (fixes #10855) --- docs/developer-guide/working-with-rules.md | 4 + docs/user-guide/command-line-interface.md | 19 ++ lib/cli-engine.js | 21 +- lib/cli.js | 7 +- lib/options.js | 5 + lib/rules/accessor-pairs.js | 4 + lib/rules/array-bracket-newline.js | 5 + lib/rules/array-bracket-spacing.js | 5 + lib/rules/array-callback-return.js | 2 + lib/rules/array-element-newline.js | 4 + lib/rules/arrow-body-style.js | 2 + lib/rules/arrow-parens.js | 2 + lib/rules/arrow-spacing.js | 2 + lib/rules/block-scoped-var.js | 2 + lib/rules/block-spacing.js | 2 + lib/rules/brace-style.js | 2 + lib/rules/callback-return.js | 2 + lib/rules/camelcase.js | 2 + lib/rules/capitalized-comments.js | 4 + lib/rules/class-methods-use-this.js | 3 + lib/rules/comma-dangle.js | 4 + lib/rules/comma-spacing.js | 2 + lib/rules/comma-style.js | 5 + lib/rules/complexity.js | 2 + lib/rules/computed-property-spacing.js | 2 + lib/rules/consistent-return.js | 2 + lib/rules/consistent-this.js | 2 + lib/rules/constructor-super.js | 2 + lib/rules/curly.js | 2 + lib/rules/default-case.js | 2 + lib/rules/dot-location.js | 2 + lib/rules/dot-notation.js | 2 + lib/rules/eol-last.js | 5 + lib/rules/eqeqeq.js | 2 + lib/rules/for-direction.js | 4 + lib/rules/func-call-spacing.js | 4 + lib/rules/func-name-matching.js | 3 + lib/rules/func-names.js | 3 + lib/rules/func-style.js | 3 + lib/rules/function-paren-newline.js | 5 + lib/rules/generator-star-spacing.js | 3 + lib/rules/getter-return.js | 5 + lib/rules/global-require.js | 2 + lib/rules/guard-for-in.js | 2 + lib/rules/handle-callback-err.js | 2 + lib/rules/id-blacklist.js | 2 + lib/rules/id-length.js | 2 + lib/rules/id-match.js | 2 + lib/rules/implicit-arrow-linebreak.js | 4 + lib/rules/indent-legacy.js | 2 + lib/rules/indent.js | 2 + lib/rules/init-declarations.js | 2 + lib/rules/jsx-quotes.js | 2 + lib/rules/key-spacing.js | 7 +- lib/rules/keyword-spacing.js | 2 + lib/rules/line-comment-position.js | 2 + lib/rules/linebreak-style.js | 2 + lib/rules/lines-around-comment.js | 2 + lib/rules/lines-around-directive.js | 4 + lib/rules/lines-between-class-members.js | 2 + lib/rules/max-classes-per-file.js | 4 + lib/rules/max-depth.js | 2 + lib/rules/max-len.js | 2 + lib/rules/max-lines-per-function.js | 2 + lib/rules/max-lines.js | 2 + lib/rules/max-nested-callbacks.js | 2 + lib/rules/max-params.js | 2 + lib/rules/max-statements-per-line.js | 2 + lib/rules/max-statements.js | 2 + lib/rules/multiline-comment-style.js | 3 + lib/rules/multiline-ternary.js | 3 + lib/rules/new-cap.js | 2 + lib/rules/new-parens.js | 3 +- lib/rules/newline-after-var.js | 2 + lib/rules/newline-before-return.js | 3 + lib/rules/newline-per-chained-call.js | 4 + lib/rules/no-alert.js | 2 + lib/rules/no-array-constructor.js | 2 + lib/rules/no-async-promise-executor.js | 3 + lib/rules/no-await-in-loop.js | 4 + lib/rules/no-bitwise.js | 2 + lib/rules/no-buffer-constructor.js | 4 + lib/rules/no-caller.js | 2 + lib/rules/no-case-declarations.js | 2 + lib/rules/no-catch-shadow.js | 4 +- lib/rules/no-class-assign.js | 2 + lib/rules/no-compare-neg-zero.js | 4 + lib/rules/no-cond-assign.js | 2 + lib/rules/no-confusing-arrow.js | 2 + lib/rules/no-console.js | 2 + lib/rules/no-const-assign.js | 2 + lib/rules/no-constant-condition.js | 2 + lib/rules/no-continue.js | 2 + lib/rules/no-control-regex.js | 6 +- lib/rules/no-debugger.js | 4 + lib/rules/no-delete-var.js | 2 + lib/rules/no-div-regex.js | 2 + lib/rules/no-dupe-args.js | 2 + lib/rules/no-dupe-class-members.js | 2 + lib/rules/no-dupe-keys.js | 2 + lib/rules/no-duplicate-case.js | 2 + lib/rules/no-duplicate-imports.js | 2 + lib/rules/no-else-return.js | 2 + lib/rules/no-empty-character-class.js | 2 + lib/rules/no-empty-function.js | 2 + lib/rules/no-empty-pattern.js | 2 + lib/rules/no-empty.js | 2 + lib/rules/no-eq-null.js | 2 + lib/rules/no-eval.js | 2 + lib/rules/no-ex-assign.js | 2 + lib/rules/no-extend-native.js | 2 + lib/rules/no-extra-bind.js | 3 +- lib/rules/no-extra-boolean-cast.js | 3 +- lib/rules/no-extra-label.js | 3 +- lib/rules/no-extra-parens.js | 11 +- lib/rules/no-extra-semi.js | 2 + lib/rules/no-fallthrough.js | 2 + lib/rules/no-floating-decimal.js | 3 +- lib/rules/no-func-assign.js | 2 + lib/rules/no-global-assign.js | 2 + lib/rules/no-implicit-coercion.js | 3 + lib/rules/no-implicit-globals.js | 2 + lib/rules/no-implied-eval.js | 2 + lib/rules/no-inline-comments.js | 2 + lib/rules/no-inner-declarations.js | 2 + lib/rules/no-invalid-regexp.js | 2 + lib/rules/no-invalid-this.js | 2 + lib/rules/no-irregular-whitespace.js | 2 + lib/rules/no-iterator.js | 2 + lib/rules/no-label-var.js | 2 + lib/rules/no-labels.js | 2 + lib/rules/no-lone-blocks.js | 2 + lib/rules/no-lonely-if.js | 3 +- lib/rules/no-loop-func.js | 2 + lib/rules/no-magic-numbers.js | 3 + lib/rules/no-misleading-character-class.js | 4 + lib/rules/no-mixed-operators.js | 3 + lib/rules/no-mixed-requires.js | 2 + lib/rules/no-mixed-spaces-and-tabs.js | 2 + lib/rules/no-multi-assign.js | 3 + lib/rules/no-multi-spaces.js | 2 + lib/rules/no-multi-str.js | 2 + lib/rules/no-multiple-empty-lines.js | 2 + lib/rules/no-native-reassign.js | 2 + lib/rules/no-negated-condition.js | 2 + lib/rules/no-negated-in-lhs.js | 4 +- lib/rules/no-nested-ternary.js | 2 + lib/rules/no-new-func.js | 2 + lib/rules/no-new-object.js | 2 + lib/rules/no-new-require.js | 2 + lib/rules/no-new-symbol.js | 2 + lib/rules/no-new-wrappers.js | 2 + lib/rules/no-new.js | 2 + lib/rules/no-obj-calls.js | 2 + lib/rules/no-octal-escape.js | 2 + lib/rules/no-octal.js | 2 + lib/rules/no-param-reassign.js | 2 + lib/rules/no-path-concat.js | 2 + lib/rules/no-plusplus.js | 2 + lib/rules/no-process-env.js | 2 + lib/rules/no-process-exit.js | 2 + lib/rules/no-proto.js | 2 + lib/rules/no-prototype-builtins.js | 2 + lib/rules/no-redeclare.js | 2 + lib/rules/no-regex-spaces.js | 3 +- lib/rules/no-restricted-globals.js | 2 + lib/rules/no-restricted-imports.js | 2 + lib/rules/no-restricted-modules.js | 2 + lib/rules/no-restricted-properties.js | 2 + lib/rules/no-restricted-syntax.js | 2 + lib/rules/no-return-assign.js | 2 + lib/rules/no-return-await.js | 4 + lib/rules/no-script-url.js | 2 + lib/rules/no-self-assign.js | 2 + lib/rules/no-self-compare.js | 2 + lib/rules/no-sequences.js | 2 + lib/rules/no-shadow-restricted-names.js | 2 + lib/rules/no-shadow.js | 2 + lib/rules/no-spaced-func.js | 2 + lib/rules/no-sparse-arrays.js | 2 + lib/rules/no-sync.js | 2 + lib/rules/no-tabs.js | 2 + lib/rules/no-template-curly-in-string.js | 2 + lib/rules/no-ternary.js | 2 + lib/rules/no-this-before-super.js | 2 + lib/rules/no-throw-literal.js | 2 + lib/rules/no-trailing-spaces.js | 2 + lib/rules/no-undef-init.js | 3 +- lib/rules/no-undef.js | 2 + lib/rules/no-undefined.js | 2 + lib/rules/no-underscore-dangle.js | 2 + lib/rules/no-unexpected-multiline.js | 2 + lib/rules/no-unmodified-loop-condition.js | 2 + lib/rules/no-unneeded-ternary.js | 2 + lib/rules/no-unreachable.js | 2 + lib/rules/no-unsafe-finally.js | 2 + lib/rules/no-unsafe-negation.js | 3 + lib/rules/no-unused-expressions.js | 2 + lib/rules/no-unused-labels.js | 3 +- lib/rules/no-unused-vars.js | 20 +- lib/rules/no-use-before-define.js | 2 + lib/rules/no-useless-call.js | 2 + lib/rules/no-useless-computed-key.js | 3 +- lib/rules/no-useless-concat.js | 2 + lib/rules/no-useless-constructor.js | 2 + lib/rules/no-useless-escape.js | 2 + lib/rules/no-useless-rename.js | 4 + lib/rules/no-useless-return.js | 3 + lib/rules/no-var.js | 2 + lib/rules/no-void.js | 2 + lib/rules/no-warning-comments.js | 2 + lib/rules/no-whitespace-before-property.js | 2 + lib/rules/no-with.js | 2 + lib/rules/nonblock-statement-body-position.js | 4 + lib/rules/object-curly-newline.js | 4 + lib/rules/object-curly-spacing.js | 2 + lib/rules/object-property-newline.js | 5 +- lib/rules/object-shorthand.js | 2 + lib/rules/one-var-declaration-per-line.js | 2 + lib/rules/one-var.js | 2 + lib/rules/operator-assignment.js | 2 + lib/rules/operator-linebreak.js | 2 + lib/rules/padded-blocks.js | 2 + lib/rules/padding-line-between-statements.js | 4 + lib/rules/prefer-arrow-callback.js | 2 + lib/rules/prefer-const.js | 2 + lib/rules/prefer-destructuring.js | 3 + lib/rules/prefer-numeric-literals.js | 3 +- lib/rules/prefer-object-spread.js | 4 + lib/rules/prefer-promise-reject-errors.js | 4 + lib/rules/prefer-reflect.js | 2 + lib/rules/prefer-rest-params.js | 2 + lib/rules/prefer-spread.js | 3 +- lib/rules/prefer-template.js | 3 +- lib/rules/quote-props.js | 2 + lib/rules/quotes.js | 2 + lib/rules/radix.js | 2 + lib/rules/require-atomic-updates.js | 4 + lib/rules/require-await.js | 3 + lib/rules/require-jsdoc.js | 2 + lib/rules/require-unicode-regexp.js | 4 + lib/rules/require-yield.js | 2 + lib/rules/rest-spread-spacing.js | 4 + lib/rules/semi-spacing.js | 2 + lib/rules/semi-style.js | 3 + lib/rules/semi.js | 2 + lib/rules/sort-imports.js | 2 + lib/rules/sort-keys.js | 3 + lib/rules/sort-vars.js | 2 + lib/rules/space-before-blocks.js | 2 + lib/rules/space-before-function-paren.js | 2 + lib/rules/space-in-parens.js | 2 + lib/rules/space-infix-ops.js | 2 + lib/rules/space-unary-ops.js | 2 + lib/rules/spaced-comment.js | 2 + lib/rules/strict.js | 2 + lib/rules/switch-colon-spacing.js | 4 + lib/rules/symbol-description.js | 2 + lib/rules/template-curly-spacing.js | 2 + lib/rules/template-tag-spacing.js | 2 + lib/rules/unicode-bom.js | 2 + lib/rules/use-isnan.js | 2 + lib/rules/valid-jsdoc.js | 2 + lib/rules/valid-typeof.js | 2 + lib/rules/vars-on-top.js | 2 + lib/rules/wrap-iife.js | 2 + lib/rules/wrap-regex.js | 4 +- lib/rules/yield-star-spacing.js | 2 + lib/rules/yoda.js | 2 + ...semi-and-prefer-arrow-callback.expected.js | 7 + ...fix-both-semi-and-prefer-arrow-callback.js | 7 + ...fix-only-prefer-arrow-callback.expected.js | 7 + .../fix-only-prefer-arrow-callback.js | 7 + .../fix-types/fix-only-semi.expected.js | 7 + tests/fixtures/fix-types/fix-only-semi.js | 7 + tests/lib/cli-engine.js | 49 ++++ tests/lib/cli.js | 70 +++++ tests/lib/options.js | 25 ++ tools/rule-types.json | 266 ++++++++++++++++++ tools/update-rule-types.js | 72 +++++ 280 files changed, 1212 insertions(+), 43 deletions(-) create mode 100644 tests/fixtures/fix-types/fix-both-semi-and-prefer-arrow-callback.expected.js create mode 100644 tests/fixtures/fix-types/fix-both-semi-and-prefer-arrow-callback.js create mode 100644 tests/fixtures/fix-types/fix-only-prefer-arrow-callback.expected.js create mode 100644 tests/fixtures/fix-types/fix-only-prefer-arrow-callback.js create mode 100644 tests/fixtures/fix-types/fix-only-semi.expected.js create mode 100644 tests/fixtures/fix-types/fix-only-semi.js create mode 100644 tools/rule-types.json create mode 100644 tools/update-rule-types.js diff --git a/docs/developer-guide/working-with-rules.md b/docs/developer-guide/working-with-rules.md index 85b8c25ea38..886396bc3c7 100644 --- a/docs/developer-guide/working-with-rules.md +++ b/docs/developer-guide/working-with-rules.md @@ -26,6 +26,8 @@ Here is the basic format of the source file for a rule: module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow unnecessary semicolons", category: "Possible Errors", @@ -49,6 +51,8 @@ The source file for a rule exports an object with the following properties. `meta` (object) contains metadata for the rule: +* `type` (string) indicates the type of rule, which is one of `"problem"`, `"suggestion"`, or `"style"` + * `docs` (object) is required for core rules of ESLint: * `description` (string) provides the short description of the rule in the [rules index](../rules/) diff --git a/docs/user-guide/command-line-interface.md b/docs/user-guide/command-line-interface.md index 62ecd3c2021..944e1bd9f35 100644 --- a/docs/user-guide/command-line-interface.md +++ b/docs/user-guide/command-line-interface.md @@ -46,6 +46,7 @@ Specifying rules and plugins: Fixing problems: --fix Automatically fix problems --fix-dry-run Automatically fix problems without saving the changes to the file system + --fix-type Array Specify the types of fixes to apply Ignoring files: --ignore-path path::String Specify path of ignore file @@ -233,6 +234,24 @@ getSomeText | eslint --stdin --fix-dry-run --format=json This flag can be useful for integrations (e.g. editor plugins) which need to autofix text from the command line without saving it to the filesystem. +#### `--fix-type` + +This option allows you to specify the type of fixes to apply when using either `--fix` or `--fix-dry-run`. The three types of fixes are: + +1. `problem` - fix potential errors in the code +1. `suggestion` - apply fixes to the code that improve it +1. `style` - apply fixes that do not mutate the program structure (AST) + +You can specify one or more fix type on the command line. Here are some examples: + +``` +eslint --fix --fix-type suggestion . +eslint --fix --fix-type suggestion --fix-type problem . +eslint --fix --fix-type suggestion,style . +``` + +This option is helpful if you are using another program to style your code but you would still like ESLint to apply other types of fixes. + ### Ignoring files #### `--ignore-path` diff --git a/lib/cli-engine.js b/lib/cli-engine.js index f801aee48ca..a246188f165 100644 --- a/lib/cli-engine.js +++ b/lib/cli-engine.js @@ -50,6 +50,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. @@ -176,7 +177,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, @@ -185,7 +185,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 = { @@ -456,6 +455,24 @@ 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 41040450f94..6e3c1a7f4fb 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 c3858ba753f..c3166de82a3 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", 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 2ed72942d46..8eb9f991295 100644 --- a/lib/rules/lines-around-directive.js +++ b/lib/rules/lines-around-directive.js @@ -14,12 +14,15 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "style", + docs: { description: "require or disallow newlines around directives", category: "Stylistic Issues", recommended: false, url: "https://eslint.org/docs/rules/lines-around-directive" }, + schema: [{ oneOf: [ { @@ -40,6 +43,7 @@ module.exports = { } ] }], + fixable: "whitespace", deprecated: true, replacedBy: ["padding-line-between-statements"] 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 df2ad7620e7..e34fd05d55b 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", diff --git a/lib/rules/newline-before-return.js b/lib/rules/newline-before-return.js index e9de4bb1414..98793a70508 100644 --- a/lib/rules/newline-before-return.js +++ b/lib/rules/newline-before-return.js @@ -11,12 +11,15 @@ module.exports = { meta: { + type: "style", + docs: { description: "require an empty line before `return` statements", category: "Stylistic Issues", recommended: false, 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 a9253dde047..60a0493b343 100644 --- a/lib/rules/no-catch-shadow.js +++ b/lib/rules/no-catch-shadow.js @@ -18,16 +18,18 @@ 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", recommended: false, url: "https://eslint.org/docs/rules/no-catch-shadow" }, - deprecated: true, replacedBy: ["no-shadow"], + 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 6d6cad13e97..abbe1868e89 100644 --- a/lib/rules/no-extra-bind.js +++ b/lib/rules/no-extra-bind.js @@ -22,6 +22,8 @@ const SIDE_EFFECT_FREE_NODE_TYPES = new Set(["Literal", "Identifier", "ThisExpre module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow unnecessary calls to `.bind()`", category: "Best Practices", @@ -30,7 +32,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 de6934c635a..7920ebdc564 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 f24499b1491..9ecfb4da7cb 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 54252cdbccd..0084ad1570b 100644 --- a/lib/rules/no-negated-in-lhs.js +++ b/lib/rules/no-negated-in-lhs.js @@ -12,16 +12,18 @@ module.exports = { meta: { + type: "problem", + docs: { description: "disallow negating the left operand in `in` expressions", category: "Possible Errors", recommended: false, url: "https://eslint.org/docs/rules/no-negated-in-lhs" }, - deprecated: true, replacedBy: ["no-unsafe-negation"], + 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 1f584f88bf2..02cb710fdc8 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", 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 c22a94da38b..2b4de762f6f 100644 --- a/lib/rules/no-tabs.js +++ b/lib/rules/no-tabs.js @@ -18,6 +18,8 @@ const anyNonWhitespaceRegex = /\S/; module.exports = { meta: { + type: "style", + docs: { description: "disallow all tabs", category: "Stylistic Issues", 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 6f36813aca5..a73c537ab21 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,22 +374,18 @@ module.exports = { return ref.isRead() && ( // self update. e.g. `a += 1`, `a++` - ( - parent.type === "AssignmentExpression" && + (// in RHS of an assignment for itself. e.g. `a = a + 1` + (( + parent.type === "AssignmentExpression" && granpa.type === "ExpressionStatement" && parent.left === id - ) || + ) || ( 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 3efd0f27f7f..fb0d5878dcc 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 4af85fef015..7e020510c38 100644 --- a/lib/rules/padding-line-between-statements.js +++ b/lib/rules/padding-line-between-statements.js @@ -400,13 +400,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..b4bbf33f296 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 8b3bc5e0e43..acf846c998a 100644 --- a/lib/rules/prefer-const.js +++ b/lib/rules/prefer-const.js @@ -330,6 +330,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 bda827cb7a6..796bbdf05fd 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 c6cf0d74774..e8dbe17b88d 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 17b49cc1184..dcad686661d 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-both-semi-and-prefer-arrow-callback.expected.js b/tests/fixtures/fix-types/fix-both-semi-and-prefer-arrow-callback.expected.js new file mode 100644 index 00000000000..cd5a78eb4d3 --- /dev/null +++ b/tests/fixtures/fix-types/fix-both-semi-and-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-both-semi-and-prefer-arrow-callback.js b/tests/fixtures/fix-types/fix-both-semi-and-prefer-arrow-callback.js new file mode 100644 index 00000000000..26d3429d028 --- /dev/null +++ b/tests/fixtures/fix-types/fix-both-semi-and-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-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/lib/cli-engine.js b/tests/lib/cli-engine.js index acc093b3101..569f1f8bf33 100644 --- a/tests/lib/cli-engine.js +++ b/tests/lib/cli-engine.js @@ -332,6 +332,55 @@ 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 fix both style and problem rules when fixTypes has 'suggestion' and 'style'", () => { + engine = new CLIEngine({ + cwd: path.join(fixtureDir, ".."), + useEslintrc: false, + fix: true, + fixTypes: ["suggestion", "style"] + }); + const inputPath = getFixturePath("fix-types/fix-both-semi-and-prefer-arrow-callback.js"); + const outputPath = getFixturePath("fix-types/fix-both-semi-and-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/cli.js b/tests/lib/cli.js index 9824edbadad..0332bcd033d 100644 --- a/tests/lib/cli.js +++ b/tests/lib/cli.js @@ -267,6 +267,17 @@ describe("cli", () => { }); }); + describe("when using --fix-type without --fix or --fix-dry-run", () => { + it("should exit with error", () => { + const filePath = getFixturePath("passing.js"); + const code = `--fix-type suggestion ${filePath}`; + + const exit = cli.execute(code); + + assert.strictEqual(exit, 2); + }); + }); + describe("when executing a file with a syntax error", () => { it("should exit with error", () => { const filePath = getFixturePath("syntax-error.js"); @@ -764,6 +775,36 @@ describe("cli", () => { }); + it("should pass fixTypes to CLIEngine when --fix-type is passed", () => { + + const expectedCLIEngineOptions = { + fix: true, + fixTypes: ["suggestion"] + }; + + // create a fake CLIEngine to test with + const fakeCLIEngine = sandbox.mock().withExactArgs(sinon.match(expectedCLIEngineOptions)); + + fakeCLIEngine.prototype = leche.fake(CLIEngine.prototype); + sandbox.stub(fakeCLIEngine.prototype, "executeOnFiles").returns({ + errorCount: 0, + warningCount: 0, + results: [] + }); + sandbox.stub(fakeCLIEngine.prototype, "getFormatter").returns(() => "done"); + fakeCLIEngine.outputFixes = sandbox.stub(); + + localCLI = proxyquire("../../lib/cli", { + "./cli-engine": fakeCLIEngine, + "./util/logging": log + }); + + const exitCode = localCLI.execute("--fix --fix-type suggestion ."); + + assert.strictEqual(exitCode, 0); + + }); + it("should rewrite files when in fix mode", () => { const report = { @@ -887,6 +928,35 @@ describe("cli", () => { }); + it("should pass fixTypes to CLIEngine when --fix-type is passed", () => { + + const expectedCLIEngineOptions = { + fix: true, + fixTypes: ["suggestion"] + }; + + // create a fake CLIEngine to test with + const fakeCLIEngine = sandbox.mock().withExactArgs(sinon.match(expectedCLIEngineOptions)); + + fakeCLIEngine.prototype = leche.fake(CLIEngine.prototype); + sandbox.stub(fakeCLIEngine.prototype, "executeOnFiles").returns({ + errorCount: 0, + warningCount: 0, + results: [] + }); + sandbox.stub(fakeCLIEngine.prototype, "getFormatter").returns(() => "done"); + fakeCLIEngine.outputFixes = sandbox.stub(); + + localCLI = proxyquire("../../lib/cli", { + "./cli-engine": fakeCLIEngine, + "./util/logging": log + }); + + const exitCode = localCLI.execute("--fix-dry-run --fix-type suggestion ."); + + assert.strictEqual(exitCode, 0); + }); + it("should not rewrite files when in fix-dry-run mode", () => { const report = { 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 From f50690fd7db1bfafe4a32b07edc832272f819049 Mon Sep 17 00:00:00 2001 From: "Nicholas C. Zakas" Date: Tue, 2 Oct 2018 14:25:59 -0700 Subject: [PATCH 02/25] Chore: Update rule types --- lib/rules/arrow-parens.js | 2 +- lib/rules/arrow-spacing.js | 2 +- lib/rules/dot-location.js | 2 +- lib/rules/generator-star-spacing.js | 2 +- lib/rules/max-classes-per-file.js | 2 +- lib/rules/no-extra-parens.js | 2 +- lib/rules/no-extra-semi.js | 2 +- lib/rules/no-floating-decimal.js | 2 +- lib/rules/no-multi-spaces.js | 2 +- lib/rules/no-multi-str.js | 2 +- lib/rules/no-octal-escape.js | 2 +- lib/rules/no-octal.js | 2 +- lib/rules/template-curly-spacing.js | 2 +- lib/rules/valid-jsdoc.js | 2 +- tools/rule-types.json | 28 ++++++++++++++-------------- 15 files changed, 28 insertions(+), 28 deletions(-) diff --git a/lib/rules/arrow-parens.js b/lib/rules/arrow-parens.js index 035c970a4a9..a4fa26e18d9 100644 --- a/lib/rules/arrow-parens.js +++ b/lib/rules/arrow-parens.js @@ -16,7 +16,7 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { - type: "suggestion", + type: "style", docs: { description: "require parentheses around arrow function arguments", diff --git a/lib/rules/arrow-spacing.js b/lib/rules/arrow-spacing.js index 5cfc061d477..fa95ffed06c 100644 --- a/lib/rules/arrow-spacing.js +++ b/lib/rules/arrow-spacing.js @@ -16,7 +16,7 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { - type: "suggestion", + type: "style", docs: { description: "enforce consistent spacing before and after the arrow in arrow functions", diff --git a/lib/rules/dot-location.js b/lib/rules/dot-location.js index 710f3e97855..f6b97537cef 100644 --- a/lib/rules/dot-location.js +++ b/lib/rules/dot-location.js @@ -13,7 +13,7 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { - type: "suggestion", + type: "style", docs: { description: "enforce consistent newlines before and after dots", diff --git a/lib/rules/generator-star-spacing.js b/lib/rules/generator-star-spacing.js index 83bdeeebe7c..887c8b225e0 100644 --- a/lib/rules/generator-star-spacing.js +++ b/lib/rules/generator-star-spacing.js @@ -27,7 +27,7 @@ const OVERRIDE_SCHEMA = { module.exports = { meta: { - type: "suggestion", + type: "style", docs: { description: "enforce consistent spacing around `*` operators in generator functions", diff --git a/lib/rules/max-classes-per-file.js b/lib/rules/max-classes-per-file.js index 3193a731c94..e8b27ac5c42 100644 --- a/lib/rules/max-classes-per-file.js +++ b/lib/rules/max-classes-per-file.js @@ -15,7 +15,7 @@ module.exports = { meta: { - type: "suggestion", + type: "style", docs: { description: "enforce a maximum number of classes per file", diff --git a/lib/rules/no-extra-parens.js b/lib/rules/no-extra-parens.js index a7821b598cc..0d499f4ee90 100644 --- a/lib/rules/no-extra-parens.js +++ b/lib/rules/no-extra-parens.js @@ -12,7 +12,7 @@ const astUtils = require("../util/ast-utils.js"); module.exports = { meta: { - type: "problem", + type: "style", docs: { description: "disallow unnecessary parentheses", diff --git a/lib/rules/no-extra-semi.js b/lib/rules/no-extra-semi.js index 1a118a31c79..8b0c6f54ec3 100644 --- a/lib/rules/no-extra-semi.js +++ b/lib/rules/no-extra-semi.js @@ -18,7 +18,7 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { - type: "problem", + type: "style", docs: { description: "disallow unnecessary semicolons", diff --git a/lib/rules/no-floating-decimal.js b/lib/rules/no-floating-decimal.js index c835d6a545f..282daca636c 100644 --- a/lib/rules/no-floating-decimal.js +++ b/lib/rules/no-floating-decimal.js @@ -17,7 +17,7 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { - type: "suggestion", + type: "style", docs: { description: "disallow leading or trailing decimal points in numeric literals", diff --git a/lib/rules/no-multi-spaces.js b/lib/rules/no-multi-spaces.js index 0cbd110beac..1f382d1f3a2 100644 --- a/lib/rules/no-multi-spaces.js +++ b/lib/rules/no-multi-spaces.js @@ -13,7 +13,7 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { - type: "suggestion", + type: "style", docs: { description: "disallow multiple spaces", diff --git a/lib/rules/no-multi-str.js b/lib/rules/no-multi-str.js index 844842392df..217fe907c95 100644 --- a/lib/rules/no-multi-str.js +++ b/lib/rules/no-multi-str.js @@ -17,7 +17,7 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { - type: "suggestion", + type: "style", docs: { description: "disallow multiline strings", diff --git a/lib/rules/no-octal-escape.js b/lib/rules/no-octal-escape.js index fc073b14033..eb2b9f21311 100644 --- a/lib/rules/no-octal-escape.js +++ b/lib/rules/no-octal-escape.js @@ -11,7 +11,7 @@ module.exports = { meta: { - type: "suggestion", + type: "style", docs: { description: "disallow octal escape sequences in string literals", diff --git a/lib/rules/no-octal.js b/lib/rules/no-octal.js index db1fa40aa5d..36a6115b1af 100644 --- a/lib/rules/no-octal.js +++ b/lib/rules/no-octal.js @@ -11,7 +11,7 @@ module.exports = { meta: { - type: "suggestion", + type: "style", docs: { description: "disallow octal literals", diff --git a/lib/rules/template-curly-spacing.js b/lib/rules/template-curly-spacing.js index b3ab3e288a3..f3899b4c89b 100644 --- a/lib/rules/template-curly-spacing.js +++ b/lib/rules/template-curly-spacing.js @@ -24,7 +24,7 @@ const CLOSE_PAREN = /^\}/; module.exports = { meta: { - type: "suggestion", + type: "style", docs: { description: "require or disallow spacing around embedded expressions of template strings", diff --git a/lib/rules/valid-jsdoc.js b/lib/rules/valid-jsdoc.js index c7b96af5c05..a8407369873 100644 --- a/lib/rules/valid-jsdoc.js +++ b/lib/rules/valid-jsdoc.js @@ -16,7 +16,7 @@ const doctrine = require("doctrine"); module.exports = { meta: { - type: "problem", + type: "style", docs: { description: "enforce valid JSDoc comments", diff --git a/tools/rule-types.json b/tools/rule-types.json index 1a866e3497e..f5a0b5db54a 100644 --- a/tools/rule-types.json +++ b/tools/rule-types.json @@ -5,8 +5,8 @@ "array-callback-return": "suggestion", "array-element-newline": "style", "arrow-body-style": "suggestion", - "arrow-parens": "suggestion", - "arrow-spacing": "suggestion", + "arrow-parens": "style", + "arrow-spacing": "style", "block-scoped-var": "suggestion", "block-spacing": "style", "brace-style": "style", @@ -24,7 +24,7 @@ "constructor-super": "suggestion", "curly": "suggestion", "default-case": "suggestion", - "dot-location": "suggestion", + "dot-location": "style", "dot-notation": "suggestion", "eol-last": "style", "eqeqeq": "suggestion", @@ -34,7 +34,7 @@ "func-names": "style", "func-style": "style", "function-paren-newline": "style", - "generator-star-spacing": "suggestion", + "generator-star-spacing": "style", "getter-return": "problem", "global-require": "suggestion", "guard-for-in": "suggestion", @@ -54,7 +54,7 @@ "lines-around-comment": "style", "lines-around-directive": "style", "lines-between-class-members": "style", - "max-classes-per-file": "suggestion", + "max-classes-per-file": "style", "max-depth": "style", "max-len": "style", "max-lines": "style", @@ -108,10 +108,10 @@ "no-extra-bind": "suggestion", "no-extra-boolean-cast": "problem", "no-extra-label": "suggestion", - "no-extra-parens": "problem", - "no-extra-semi": "problem", + "no-extra-parens": "style", + "no-extra-semi": "style", "no-fallthrough": "suggestion", - "no-floating-decimal": "suggestion", + "no-floating-decimal": "style", "no-func-assign": "problem", "no-global-assign": "suggestion", "no-implicit-coercion": "suggestion", @@ -134,8 +134,8 @@ "no-mixed-requires": "suggestion", "no-mixed-spaces-and-tabs": "style", "no-multi-assign": "style", - "no-multi-spaces": "suggestion", - "no-multi-str": "suggestion", + "no-multi-spaces": "style", + "no-multi-str": "style", "no-multiple-empty-lines": "style", "no-native-reassign": "suggestion", "no-negated-condition": "style", @@ -148,8 +148,8 @@ "no-new-symbol": "suggestion", "no-new-wrappers": "suggestion", "no-obj-calls": "problem", - "no-octal": "suggestion", - "no-octal-escape": "suggestion", + "no-octal": "style", + "no-octal-escape": "style", "no-param-reassign": "suggestion", "no-path-concat": "suggestion", "no-plusplus": "style", @@ -252,11 +252,11 @@ "strict": "suggestion", "switch-colon-spacing": "style", "symbol-description": "suggestion", - "template-curly-spacing": "suggestion", + "template-curly-spacing": "style", "template-tag-spacing": "style", "unicode-bom": "style", "use-isnan": "problem", - "valid-jsdoc": "problem", + "valid-jsdoc": "style", "valid-typeof": "problem", "vars-on-top": "suggestion", "wrap-iife": "suggestion", From 9105a5f38a25d416a4fd1ee159a0c3afc91812e4 Mon Sep 17 00:00:00 2001 From: "Nicholas C. Zakas" Date: Wed, 3 Oct 2018 08:32:18 -0700 Subject: [PATCH 03/25] Docs: Update Nodejs API docs with new CLIEngine option --- docs/developer-guide/nodejs-api.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/developer-guide/nodejs-api.md b/docs/developer-guide/nodejs-api.md index 0ff1e04ef2c..7b619319db0 100644 --- a/docs/developer-guide/nodejs-api.md +++ b/docs/developer-guide/nodejs-api.md @@ -347,7 +347,8 @@ The `CLIEngine` is a constructor, and you can create a new instance by passing i * `cwd` - Path to a directory that should be considered as the current working directory. * `envs` - An array of environments to load (default: empty array). Corresponds to `--env`. * `extensions` - An array of filename extensions that should be checked for code. The default is an array containing just `".js"`. Corresponds to `--ext`. It is only used in conjunction with directories, not with filenames or glob patterns. -* `fix` - This can be a boolean or a function which will be provided each linting message and should return a boolean. True indicates that fixes should be included with the output report, and that errors and warnings should not be listed if they can be fixed. However, the files on disk will not be changed. To persist changes to disk, call [`outputFixes()`](#cliengineoutputfixes). +* `fix` - A boolean or a function. If a function, it will be passed each linting message and should return a boolean indicating whether the fix should be included with the output report (errors and warnings will not be listed if fixed). Files on disk are never changed regardless of the value of `fix`. To persist changes to disk, call [`outputFixes()`](#cliengineoutputfixes). +* `fixTypes` - An array of rule types for which fixes should be applied. This array acts like a filter, only allowing rules of the given types to apply fixes. * `globals` - An array of global variables to declare (default: empty array). Corresponds to `--global`. * `ignore` - False disables use of `.eslintignore`, `ignorePath` and `ignorePattern` (default: true). Corresponds to `--no-ignore`. * `ignorePath` - The ignore file to use instead of `.eslintignore` (default: null). Corresponds to `--ignore-path`. From bc6be278b0dc72924c0fb36cb6499a1bfb2d49cf Mon Sep 17 00:00:00 2001 From: "Nicholas C. Zakas" Date: Wed, 3 Oct 2018 08:56:03 -0700 Subject: [PATCH 04/25] Chore: Fix lint errors --- docs/developer-guide/nodejs-api.md | 4 ++-- docs/user-guide/command-line-interface.md | 2 +- tools/update-rule-types.js | 20 ++++++++++---------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/docs/developer-guide/nodejs-api.md b/docs/developer-guide/nodejs-api.md index 7b619319db0..521ad22464b 100644 --- a/docs/developer-guide/nodejs-api.md +++ b/docs/developer-guide/nodejs-api.md @@ -347,8 +347,8 @@ The `CLIEngine` is a constructor, and you can create a new instance by passing i * `cwd` - Path to a directory that should be considered as the current working directory. * `envs` - An array of environments to load (default: empty array). Corresponds to `--env`. * `extensions` - An array of filename extensions that should be checked for code. The default is an array containing just `".js"`. Corresponds to `--ext`. It is only used in conjunction with directories, not with filenames or glob patterns. -* `fix` - A boolean or a function. If a function, it will be passed each linting message and should return a boolean indicating whether the fix should be included with the output report (errors and warnings will not be listed if fixed). Files on disk are never changed regardless of the value of `fix`. To persist changes to disk, call [`outputFixes()`](#cliengineoutputfixes). -* `fixTypes` - An array of rule types for which fixes should be applied. This array acts like a filter, only allowing rules of the given types to apply fixes. +* `fix` - A boolean or a function (default: `false`). If a function, it will be passed each linting message and should return a boolean indicating whether the fix should be included with the output report (errors and warnings will not be listed if fixed). Files on disk are never changed regardless of the value of `fix`. To persist changes to disk, call [`outputFixes()`](#cliengineoutputfixes). +* `fixTypes` - An array of rule types for which fixes should be applied (default: `null`). This array acts like a filter, only allowing rules of the given types to apply fixes. Possible array values are `"problem"`, `"suggestion"`, and `"style"`. * `globals` - An array of global variables to declare (default: empty array). Corresponds to `--global`. * `ignore` - False disables use of `.eslintignore`, `ignorePath` and `ignorePattern` (default: true). Corresponds to `--no-ignore`. * `ignorePath` - The ignore file to use instead of `.eslintignore` (default: null). Corresponds to `--ignore-path`. diff --git a/docs/user-guide/command-line-interface.md b/docs/user-guide/command-line-interface.md index 944e1bd9f35..5d3cf7c9288 100644 --- a/docs/user-guide/command-line-interface.md +++ b/docs/user-guide/command-line-interface.md @@ -46,7 +46,7 @@ Specifying rules and plugins: Fixing problems: --fix Automatically fix problems --fix-dry-run Automatically fix problems without saving the changes to the file system - --fix-type Array Specify the types of fixes to apply + --fix-type Array Specify the types of fixes to apply (problem, suggestion, style) Ignoring files: --ignore-path path::String Specify path of ignore file diff --git a/tools/update-rule-types.js b/tools/update-rule-types.js index 37c4597199b..23ea16a6350 100644 --- a/tools/update-rule-types.js +++ b/tools/update-rule-types.js @@ -1,9 +1,9 @@ /** * 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"; @@ -17,12 +17,10 @@ module.exports = (fileInfo, api) => { 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"); - }); + const nodes = j(source).find(j.ObjectExpression).filter(p => p.node.properties.some(node => node.key.name === "meta")); // updating logic - return nodes.replaceWith((p) => { + return nodes.replaceWith(p => { // gather important nodes from the rule const metaNode = p.node.properties.find(node => node.key.name === "meta"); @@ -30,7 +28,7 @@ module.exports = (fileInfo, api) => { 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 @@ -43,17 +41,18 @@ module.exports = (fileInfo, api) => { 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 { @@ -64,9 +63,10 @@ module.exports = (fileInfo, api) => { j.identifier("type"), j.literal(ruleType) ); + p.node.properties[0].value.properties.unshift(newProp); } return p.node; }).toSource(); -}; \ No newline at end of file +}; From 67c958189656da359a598ed9e5649e39e03e4b5b Mon Sep 17 00:00:00 2001 From: "Nicholas C. Zakas" Date: Wed, 3 Oct 2018 08:56:33 -0700 Subject: [PATCH 05/25] Chore: Update options message for --fix-type --- lib/options.js | 2 +- tests/lib/options.js | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/options.js b/lib/options.js index 3f289220664..7d1d66f29ad 100644 --- a/lib/options.js +++ b/lib/options.js @@ -100,7 +100,7 @@ module.exports = optionator({ { option: "fix-type", type: "Array", - description: "Specify the types of fixes to apply" + description: "Specify the types of fixes to apply (problem, suggestion, style)" }, { heading: "Ignoring files" diff --git a/tests/lib/options.js b/tests/lib/options.js index 9027c42a324..60cd7b716b3 100644 --- a/tests/lib/options.js +++ b/tests/lib/options.js @@ -332,24 +332,24 @@ describe("options", () => { 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"); + assert.strictEqual(currentOptions.fixType.length, 1); + assert.strictEqual(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"); + assert.strictEqual(currentOptions.fixType.length, 2); + assert.strictEqual(currentOptions.fixType[0], "problem"); + assert.strictEqual(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"); + assert.strictEqual(currentOptions.fixType.length, 2); + assert.strictEqual(currentOptions.fixType[0], "problem"); + assert.strictEqual(currentOptions.fixType[1], "suggestion"); }); }); From 01ed312d6237f2803e8fde316b6e9029a85f1636 Mon Sep 17 00:00:00 2001 From: "Nicholas C. Zakas" Date: Wed, 3 Oct 2018 09:06:26 -0700 Subject: [PATCH 06/25] CLIEngine validates fixType values --- lib/cli-engine.js | 20 ++++++++++++++++++++ tests/lib/cli-engine.js | 11 +++++++++++ 2 files changed, 31 insertions(+) diff --git a/lib/cli-engine.js b/lib/cli-engine.js index a246188f165..8e88518c0ef 100644 --- a/lib/cli-engine.js +++ b/lib/cli-engine.js @@ -33,6 +33,7 @@ const fs = require("fs"), const debug = require("debug")("eslint:cli-engine"); const resolver = new ModuleResolver(); +const validFixTypes = new Set(["problem", "suggestion", "style"]); //------------------------------------------------------------------------------ // Typedefs @@ -87,6 +88,21 @@ const resolver = new ModuleResolver(); // Helpers //------------------------------------------------------------------------------ +/** + * Determines if each fix type in an array is supported by ESLint and throws + * an error if not. + * @param {string[]} fixTypes An array of fix types to check. + * @returns {void} + * @throws {Error} If an invalid fix type is found. + */ +function validateFixTypes(fixTypes) { + for (const fixType of fixTypes) { + if (!validFixTypes.has(fixType)) { + throw new Error(`Invalid fix type "${fixType}" found.`); + } + } +} + /** * It will calculate the error and warning count for collection of messages per file * @param {Object[]} messages - Collection of messages @@ -459,9 +475,13 @@ class CLIEngine { // setup special filter for fixes if (this.options.fixTypes && this.options.fixTypes.length > 0) { + // throw an error if any invalid fix types are found + validateFixTypes(this.options.fixTypes); + // convert to Set for faster lookup const fixTypes = new Set(this.options.fixTypes); + // make sure there is at least one valid // save original value of options.fix in case it's a function const originalFix = this.options.fix; diff --git a/tests/lib/cli-engine.js b/tests/lib/cli-engine.js index 569f1f8bf33..7afa74d208b 100644 --- a/tests/lib/cli-engine.js +++ b/tests/lib/cli-engine.js @@ -334,6 +334,17 @@ describe("CLIEngine", () => { describe("Fix Types", () => { + it("should throw an error when an invalid fix type is specified", () => { + assert.throws(() => { + engine = new CLIEngine({ + cwd: path.join(fixtureDir, ".."), + useEslintrc: false, + fix: true, + fixTypes: ["styl"] + }); + }, /invalid fix type/i); + }); + it("should not fix non-style rules when fixTypes has only 'style'", () => { engine = new CLIEngine({ cwd: path.join(fixtureDir, ".."), From a40c6d970ae9b4e5ec236a69f4881374b19eb6bb Mon Sep 17 00:00:00 2001 From: "Nicholas C. Zakas" Date: Wed, 3 Oct 2018 09:35:41 -0700 Subject: [PATCH 07/25] Check for rule.meta when filtering fixes --- lib/cli-engine.js | 4 ++-- .../fix-types/ignore-missing-meta.expected.js | 8 +++++++ .../fixtures/fix-types/ignore-missing-meta.js | 8 +++++++ .../rules/fix-types-test/no-program.js | 22 +++++++++++++++++++ tests/lib/cli-engine.js | 19 +++++++++++++++- 5 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 tests/fixtures/fix-types/ignore-missing-meta.expected.js create mode 100644 tests/fixtures/fix-types/ignore-missing-meta.js create mode 100644 tests/fixtures/rules/fix-types-test/no-program.js diff --git a/lib/cli-engine.js b/lib/cli-engine.js index 8e88518c0ef..80c2314b902 100644 --- a/lib/cli-engine.js +++ b/lib/cli-engine.js @@ -481,13 +481,13 @@ class CLIEngine { // convert to Set for faster lookup const fixTypes = new Set(this.options.fixTypes); - // make sure there is at least one valid // 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); + const rule = rules.get(lintResult.ruleId); + const matches = rule.meta && fixTypes.has(rule.meta.type); return matches && (typeof originalFix === "function" ? originalFix(lintResult) : true); }; diff --git a/tests/fixtures/fix-types/ignore-missing-meta.expected.js b/tests/fixtures/fix-types/ignore-missing-meta.expected.js new file mode 100644 index 00000000000..b6e3019aa01 --- /dev/null +++ b/tests/fixtures/fix-types/ignore-missing-meta.expected.js @@ -0,0 +1,8 @@ +/* eslint semi: "error" */ +/* eslint no-program: "error" */ +/* eslint prefer-arrow-callback: "error" */ +"use strict"; + +func(function() { + return true; +}); diff --git a/tests/fixtures/fix-types/ignore-missing-meta.js b/tests/fixtures/fix-types/ignore-missing-meta.js new file mode 100644 index 00000000000..ee9b9d9d869 --- /dev/null +++ b/tests/fixtures/fix-types/ignore-missing-meta.js @@ -0,0 +1,8 @@ +/* eslint semi: "error" */ +/* eslint no-program: "error" */ +/* eslint prefer-arrow-callback: "error" */ +"use strict"; + +func(function() { + return true; +}) diff --git a/tests/fixtures/rules/fix-types-test/no-program.js b/tests/fixtures/rules/fix-types-test/no-program.js new file mode 100644 index 00000000000..fd33c11cd3d --- /dev/null +++ b/tests/fixtures/rules/fix-types-test/no-program.js @@ -0,0 +1,22 @@ +"use strict"; + +module.exports = { + fixable: "code", + + create(context) { + + return { + + "Program": function(node) { + context.report({ + node, + message: "Program!", + fix(fixer) { + return fixer.insertTextAfter(node, ";"); + } + }); + } + }; + } + +} \ No newline at end of file diff --git a/tests/lib/cli-engine.js b/tests/lib/cli-engine.js index 7afa74d208b..f512d52af35 100644 --- a/tests/lib/cli-engine.js +++ b/tests/lib/cli-engine.js @@ -333,7 +333,7 @@ describe("CLIEngine", () => { }); describe("Fix Types", () => { - + it("should throw an error when an invalid fix type is specified", () => { assert.throws(() => { engine = new CLIEngine({ @@ -390,6 +390,23 @@ describe("CLIEngine", () => { assert.strictEqual(report.results[0].output, expectedOutput); }); + it("should not throw an error when a rule doesn't have a 'meta' property", () => { + engine = new CLIEngine({ + cwd: path.join(fixtureDir, ".."), + useEslintrc: false, + fix: true, + fixTypes: ["style"], + rulePaths: [getFixturePath("rules", "fix-types-test")] + }); + + const inputPath = getFixturePath("fix-types/ignore-missing-meta.js"); + const outputPath = getFixturePath("fix-types/ignore-missing-meta.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", () => { From febe03fc08e6fc538019322cb3560fabf67a7189 Mon Sep 17 00:00:00 2001 From: "Nicholas C. Zakas" Date: Wed, 3 Oct 2018 09:36:32 -0700 Subject: [PATCH 08/25] Call getRules() just once when filtering fixes --- lib/cli-engine.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/cli-engine.js b/lib/cli-engine.js index 80c2314b902..fb518d4ca64 100644 --- a/lib/cli-engine.js +++ b/lib/cli-engine.js @@ -484,8 +484,10 @@ class CLIEngine { // save original value of options.fix in case it's a function const originalFix = this.options.fix; + // get list of rules here because getRules() is expensive + const rules = this.getRules(); + this.options.fix = lintResult => { - const rules = this.getRules(); const rule = rules.get(lintResult.ruleId); const matches = rule.meta && fixTypes.has(rule.meta.type); From dfc80d359e3f219a93d089f16b8b36c721213880 Mon Sep 17 00:00:00 2001 From: "Nicholas C. Zakas" Date: Wed, 3 Oct 2018 09:39:21 -0700 Subject: [PATCH 09/25] Set no-multiline-str to suggestion --- lib/rules/no-multi-str.js | 2 +- tools/rule-types.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/rules/no-multi-str.js b/lib/rules/no-multi-str.js index 217fe907c95..844842392df 100644 --- a/lib/rules/no-multi-str.js +++ b/lib/rules/no-multi-str.js @@ -17,7 +17,7 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { - type: "style", + type: "suggestion", docs: { description: "disallow multiline strings", diff --git a/tools/rule-types.json b/tools/rule-types.json index f5a0b5db54a..770874c2cfb 100644 --- a/tools/rule-types.json +++ b/tools/rule-types.json @@ -135,7 +135,7 @@ "no-mixed-spaces-and-tabs": "style", "no-multi-assign": "style", "no-multi-spaces": "style", - "no-multi-str": "style", + "no-multi-str": "suggestion", "no-multiple-empty-lines": "style", "no-native-reassign": "suggestion", "no-negated-condition": "style", From 9293d08543c5433bb97d2b3d3a0b34441e7a6e68 Mon Sep 17 00:00:00 2001 From: "Nicholas C. Zakas" Date: Thu, 4 Oct 2018 09:43:05 -0700 Subject: [PATCH 10/25] Add check for missing rule info in rule-types.json --- Makefile.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Makefile.js b/Makefile.js index 2a5c7ab8d69..ed95ccb22ad 100644 --- a/Makefile.js +++ b/Makefile.js @@ -863,7 +863,7 @@ target.checkRuleFiles = function() { echo("Validating rules"); const eslintRecommended = require("./conf/eslint-recommended").rules; - + const ruleTypes = require("./tools/rule-types.json"); const ruleFiles = find("lib/rules/").filter(fileType("js")); let errors = 0; @@ -880,6 +880,15 @@ target.checkRuleFiles = function() { return Object.prototype.hasOwnProperty.call(eslintRecommended, basename); } + /** + * Check if basename is present in rule-types.json file. + * @returns {boolean} true if present + * @private + */ + function isInRuleTypes() { + return Object.prototype.hasOwnProperty.call(ruleTypes, basename); + } + /** * Check if id is present in title * @param {string} id id to check for @@ -918,6 +927,12 @@ target.checkRuleFiles = function() { errors++; } + // check for recommended configuration + if (!isInRuleTypes()) { + console.error("Missing setting for %s in tools/rule-types.json", basename); + errors++; + } + // check for tests if (!test("-f", `tests/lib/rules/${basename}.js`)) { console.error("Missing tests for rule %s", basename); From 98bc478cd37fca5481e83a17c3493d4ab2b05e06 Mon Sep 17 00:00:00 2001 From: "Nicholas C. Zakas" Date: Thu, 4 Oct 2018 10:05:02 -0700 Subject: [PATCH 11/25] Account for late definition of rules in CLIEngine --- lib/cli-engine.js | 17 ++++++++++++++--- tests/lib/cli-engine.js | 37 ++++++++++++++++++++++++++++++++++++- 2 files changed, 50 insertions(+), 4 deletions(-) diff --git a/lib/cli-engine.js b/lib/cli-engine.js index fb518d4ca64..3cdde761231 100644 --- a/lib/cli-engine.js +++ b/lib/cli-engine.js @@ -484,11 +484,11 @@ class CLIEngine { // save original value of options.fix in case it's a function const originalFix = this.options.fix; - // get list of rules here because getRules() is expensive - const rules = this.getRules(); + // create a cache of rules (but don't populate until needed) + this._rulesCache = null; this.options.fix = lintResult => { - const rule = rules.get(lintResult.ruleId); + const rule = this._rulesCache.get(lintResult.ruleId); const matches = rule.meta && fixTypes.has(rule.meta.type); return matches && (typeof originalFix === "function" ? originalFix(lintResult) : true); @@ -599,6 +599,11 @@ class CLIEngine { } } + // if there's a cache, populate it + if ("_rulesCache" in this) { + this._rulesCache = this.getRules(); + } + debug(`Processing ${fileInfo.filename}`); const { result, config } = processFile(fileInfo.filename, configHelper, options, this.linter); @@ -669,6 +674,12 @@ class CLIEngine { } usedDeprecatedRules = []; } else { + + // if there's a cache, populate it + if ("_rulesCache" in this) { + this._rulesCache = this.getRules(); + } + const { result, config } = processText( text, configHelper, diff --git a/tests/lib/cli-engine.js b/tests/lib/cli-engine.js index f512d52af35..7099e391092 100644 --- a/tests/lib/cli-engine.js +++ b/tests/lib/cli-engine.js @@ -407,6 +407,42 @@ describe("CLIEngine", () => { assert.strictEqual(report.results[0].output, expectedOutput); }); + it("should not throw an error when a rule is loaded after initialization with executeOnFiles()", () => { + engine = new CLIEngine({ + cwd: path.join(fixtureDir, ".."), + useEslintrc: false, + fix: true, + fixTypes: ["style"] + }); + + engine.linter.defineRule("no-program", require(getFixturePath("rules", "fix-types-test", "no-program.js"))); + + const inputPath = getFixturePath("fix-types/ignore-missing-meta.js"); + const outputPath = getFixturePath("fix-types/ignore-missing-meta.expected.js"); + const report = engine.executeOnFiles([inputPath]); + const expectedOutput = fs.readFileSync(outputPath, "utf8"); + + assert.strictEqual(report.results[0].output, expectedOutput); + }); + + it("should not throw an error when a rule is loaded after initialization with executeOnText()", () => { + engine = new CLIEngine({ + cwd: path.join(fixtureDir, ".."), + useEslintrc: false, + fix: true, + fixTypes: ["style"] + }); + + engine.linter.defineRule("no-program", require(getFixturePath("rules", "fix-types-test", "no-program.js"))); + + const inputPath = getFixturePath("fix-types/ignore-missing-meta.js"); + const outputPath = getFixturePath("fix-types/ignore-missing-meta.expected.js"); + const report = engine.executeOnText(fs.readFileSync(inputPath, { encoding: "utf8" }), 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", () => { @@ -715,7 +751,6 @@ describe("CLIEngine", () => { }); - it("should report zero messages when given a config file and a valid file", () => { engine = new CLIEngine({ From b5782f9eeea23a13b2d50096ff5469423fa9645d Mon Sep 17 00:00:00 2001 From: "Nicholas C. Zakas" Date: Thu, 4 Oct 2018 10:55:36 -0700 Subject: [PATCH 12/25] Add ruleType data to doc page for rules --- Makefile.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Makefile.js b/Makefile.js index ed95ccb22ad..ff0b13d7bf7 100644 --- a/Makefile.js +++ b/Makefile.js @@ -708,6 +708,7 @@ target.gensite = function(prereleaseVersion) { ruleName = path.basename(filename, ".md"), filePath = path.join("docs", path.relative("tmp", filename)); let text = cat(filename), + ruleType = "", title; process.stdout.write(`> Updating files (Steps 4-9): ${i}/${length} - ${filePath + " ".repeat(30)}\r`); @@ -726,8 +727,11 @@ target.gensite = function(prereleaseVersion) { const ruleDocsContent = textSplit.slice(1).join("\n"); text = `${ruleHeading}${isRecommended ? RECOMMENDED_TEXT : ""}${isFixable ? FIXABLE_TEXT : ""}\n${ruleDocsContent}`; - title = `${ruleName} - Rules`; + + if (rule && rule.meta) { + ruleType = `ruleType: ${rule.meta.type}`; + } } else { // extract the title from the file itself @@ -744,6 +748,7 @@ target.gensite = function(prereleaseVersion) { `title: ${title}`, "layout: doc", `edit_link: https://github.com/eslint/eslint/edit/master/${filePath}`, + ruleType, "---", "", "", From a35500ad3035be6aaa0798067eb2d5e826a0f3f5 Mon Sep 17 00:00:00 2001 From: "Nicholas C. Zakas" Date: Fri, 5 Oct 2018 09:27:23 -0700 Subject: [PATCH 13/25] Remove duplicate test --- tests/lib/cli.js | 31 +------------------------------ 1 file changed, 1 insertion(+), 30 deletions(-) diff --git a/tests/lib/cli.js b/tests/lib/cli.js index 0332bcd033d..1cc482f1c58 100644 --- a/tests/lib/cli.js +++ b/tests/lib/cli.js @@ -775,35 +775,6 @@ describe("cli", () => { }); - it("should pass fixTypes to CLIEngine when --fix-type is passed", () => { - - const expectedCLIEngineOptions = { - fix: true, - fixTypes: ["suggestion"] - }; - - // create a fake CLIEngine to test with - const fakeCLIEngine = sandbox.mock().withExactArgs(sinon.match(expectedCLIEngineOptions)); - - fakeCLIEngine.prototype = leche.fake(CLIEngine.prototype); - sandbox.stub(fakeCLIEngine.prototype, "executeOnFiles").returns({ - errorCount: 0, - warningCount: 0, - results: [] - }); - sandbox.stub(fakeCLIEngine.prototype, "getFormatter").returns(() => "done"); - fakeCLIEngine.outputFixes = sandbox.stub(); - - localCLI = proxyquire("../../lib/cli", { - "./cli-engine": fakeCLIEngine, - "./util/logging": log - }); - - const exitCode = localCLI.execute("--fix --fix-type suggestion ."); - - assert.strictEqual(exitCode, 0); - - }); it("should rewrite files when in fix mode", () => { @@ -956,7 +927,7 @@ describe("cli", () => { assert.strictEqual(exitCode, 0); }); - + it("should not rewrite files when in fix-dry-run mode", () => { const report = { From 047a242faebaa7631b6065bc1558af0f2e52872e Mon Sep 17 00:00:00 2001 From: "Nicholas C. Zakas" Date: Fri, 5 Oct 2018 09:35:50 -0700 Subject: [PATCH 14/25] Update spacing rules to be of type style --- lib/rules/rest-spread-spacing.js | 2 +- lib/rules/yield-star-spacing.js | 2 +- tools/rule-types.json | 4 ++-- tools/update-rule-types.js | 7 ++++++- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/rules/rest-spread-spacing.js b/lib/rules/rest-spread-spacing.js index bbc10320183..efe19c9835b 100644 --- a/lib/rules/rest-spread-spacing.js +++ b/lib/rules/rest-spread-spacing.js @@ -11,7 +11,7 @@ module.exports = { meta: { - type: "suggestion", + type: "style", docs: { description: "enforce spacing between rest and spread operators and their expressions", diff --git a/lib/rules/yield-star-spacing.js b/lib/rules/yield-star-spacing.js index 9f9b1c34623..65e737cb860 100644 --- a/lib/rules/yield-star-spacing.js +++ b/lib/rules/yield-star-spacing.js @@ -11,7 +11,7 @@ module.exports = { meta: { - type: "suggestion", + type: "style", docs: { description: "require or disallow spacing around the `*` in `yield*` expressions", diff --git a/tools/rule-types.json b/tools/rule-types.json index 770874c2cfb..25c4e1ea265 100644 --- a/tools/rule-types.json +++ b/tools/rule-types.json @@ -236,7 +236,7 @@ "require-jsdoc": "style", "require-unicode-regexp": "suggestion", "require-yield": "suggestion", - "rest-spread-spacing": "suggestion", + "rest-spread-spacing": "style", "semi": "style", "semi-spacing": "style", "semi-style": "style", @@ -261,6 +261,6 @@ "vars-on-top": "suggestion", "wrap-iife": "suggestion", "wrap-regex": "style", - "yield-star-spacing": "suggestion", + "yield-star-spacing": "style", "yoda": "suggestion" } \ No newline at end of file diff --git a/tools/update-rule-types.js b/tools/update-rule-types.js index 23ea16a6350..352a0d8e336 100644 --- a/tools/update-rule-types.js +++ b/tools/update-rule-types.js @@ -24,8 +24,13 @@ module.exports = (fileInfo, api) => { // 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; + // if there's no properties, just exit + if (!metaNode.value.properties) { + return; + } + + const typeNode = metaNode.value.properties.find(node => node.key.name === "type"); const docsNode = metaNode.value.properties.find(node => node.key.name === "docs"); const categoryNode = docsNode.value.properties.find(node => node.key.name === "category").value; From 2b31a12d1785efd908994d9e1424bdb3b6fba921 Mon Sep 17 00:00:00 2001 From: "Nicholas C. Zakas" Date: Wed, 17 Oct 2018 10:41:46 -0700 Subject: [PATCH 15/25] Fix lint issues in update-rule-types.js --- tools/update-rule-types.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/update-rule-types.js b/tools/update-rule-types.js index 352a0d8e336..3a20092a4eb 100644 --- a/tools/update-rule-types.js +++ b/tools/update-rule-types.js @@ -27,7 +27,7 @@ module.exports = (fileInfo, api) => { // if there's no properties, just exit if (!metaNode.value.properties) { - return; + return null; } const typeNode = metaNode.value.properties.find(node => node.key.name === "type"); From bc74300d1fa07cc1aed376eeb5e444ca5e3a47b2 Mon Sep 17 00:00:00 2001 From: "Nicholas C. Zakas" Date: Fri, 19 Oct 2018 09:38:53 -0700 Subject: [PATCH 16/25] Change ruleType to rule_type in doc page front matter --- Makefile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.js b/Makefile.js index ff0b13d7bf7..e468d0a16bc 100644 --- a/Makefile.js +++ b/Makefile.js @@ -730,7 +730,7 @@ target.gensite = function(prereleaseVersion) { title = `${ruleName} - Rules`; if (rule && rule.meta) { - ruleType = `ruleType: ${rule.meta.type}`; + ruleType = `rule_type: ${rule.meta.type}`; } } else { From 19c0f655b56281645aeb7500e3fc9e0d44a607f0 Mon Sep 17 00:00:00 2001 From: "Nicholas C. Zakas" Date: Fri, 19 Oct 2018 09:55:18 -0700 Subject: [PATCH 17/25] Update rule type mappings based on feedback --- lib/rules/camelcase.js | 2 +- lib/rules/capitalized-comments.js | 2 +- lib/rules/consistent-this.js | 2 +- lib/rules/func-style.js | 2 +- lib/rules/max-classes-per-file.js | 2 +- lib/rules/max-depth.js | 2 +- lib/rules/max-lines-per-function.js | 2 +- lib/rules/max-lines.js | 2 +- lib/rules/max-nested-callbacks.js | 2 +- lib/rules/max-params.js | 2 +- lib/rules/max-statements.js | 2 +- lib/rules/multiline-comment-style.js | 2 +- lib/rules/no-array-constructor.js | 2 +- lib/rules/no-bitwise.js | 2 +- lib/rules/no-console.js | 2 +- lib/rules/no-continue.js | 2 +- lib/rules/no-dupe-class-members.js | 2 +- lib/rules/no-duplicate-imports.js | 2 +- lib/rules/no-empty.js | 2 +- lib/rules/no-extra-boolean-cast.js | 2 +- lib/rules/no-fallthrough.js | 2 +- lib/rules/no-floating-decimal.js | 2 +- lib/rules/no-inline-comments.js | 2 +- lib/rules/no-lonely-if.js | 2 +- lib/rules/no-mixed-operators.js | 2 +- lib/rules/no-multi-assign.js | 2 +- lib/rules/no-negated-condition.js | 2 +- lib/rules/no-nested-ternary.js | 2 +- lib/rules/no-new-object.js | 2 +- lib/rules/no-octal-escape.js | 2 +- lib/rules/no-octal.js | 2 +- lib/rules/no-plusplus.js | 2 +- lib/rules/no-regex-spaces.js | 2 +- lib/rules/no-restricted-syntax.js | 2 +- lib/rules/no-ternary.js | 2 +- lib/rules/no-this-before-super.js | 2 +- lib/rules/no-undef.js | 2 +- lib/rules/no-underscore-dangle.js | 2 +- lib/rules/no-unneeded-ternary.js | 2 +- lib/rules/no-unused-vars.js | 2 +- lib/rules/prefer-arrow-callback.js | 2 +- lib/rules/prefer-object-spread.js | 2 +- lib/rules/sort-keys.js | 2 +- lib/rules/sort-vars.js | 2 +- tools/rule-types.json | 86 ++++++++++++++-------------- 45 files changed, 87 insertions(+), 87 deletions(-) diff --git a/lib/rules/camelcase.js b/lib/rules/camelcase.js index 6e3c1a7f4fb..8aeb4b5bd0d 100644 --- a/lib/rules/camelcase.js +++ b/lib/rules/camelcase.js @@ -11,7 +11,7 @@ module.exports = { meta: { - type: "style", + type: "suggestion", docs: { description: "enforce camelcase naming convention", diff --git a/lib/rules/capitalized-comments.js b/lib/rules/capitalized-comments.js index 24a66eab53c..86427ba7acc 100644 --- a/lib/rules/capitalized-comments.js +++ b/lib/rules/capitalized-comments.js @@ -108,7 +108,7 @@ function createRegExpForIgnorePatterns(normalizedOptions) { module.exports = { meta: { - type: "style", + type: "suggestion", docs: { description: "enforce or disallow capitalization of the first letter of a comment", diff --git a/lib/rules/consistent-this.js b/lib/rules/consistent-this.js index 935344cea6f..4bdcdfdc10e 100644 --- a/lib/rules/consistent-this.js +++ b/lib/rules/consistent-this.js @@ -10,7 +10,7 @@ module.exports = { meta: { - type: "style", + type: "suggestion", docs: { description: "enforce consistent naming when capturing the current execution context", diff --git a/lib/rules/func-style.js b/lib/rules/func-style.js index 9236c59fc8e..b7e368cbd2e 100644 --- a/lib/rules/func-style.js +++ b/lib/rules/func-style.js @@ -10,7 +10,7 @@ module.exports = { meta: { - type: "style", + type: "suggestion", docs: { description: "enforce the consistent use of either `function` declarations or expressions", diff --git a/lib/rules/max-classes-per-file.js b/lib/rules/max-classes-per-file.js index e8b27ac5c42..3193a731c94 100644 --- a/lib/rules/max-classes-per-file.js +++ b/lib/rules/max-classes-per-file.js @@ -15,7 +15,7 @@ module.exports = { meta: { - type: "style", + type: "suggestion", docs: { description: "enforce a maximum number of classes per file", diff --git a/lib/rules/max-depth.js b/lib/rules/max-depth.js index 7c21cad7340..34d58b0d31e 100644 --- a/lib/rules/max-depth.js +++ b/lib/rules/max-depth.js @@ -11,7 +11,7 @@ module.exports = { meta: { - type: "style", + type: "suggestion", docs: { description: "enforce a maximum depth that blocks can be nested", diff --git a/lib/rules/max-lines-per-function.js b/lib/rules/max-lines-per-function.js index 10675529853..8c64a20bcc3 100644 --- a/lib/rules/max-lines-per-function.js +++ b/lib/rules/max-lines-per-function.js @@ -69,7 +69,7 @@ function getCommentLineNumbers(comments) { module.exports = { meta: { - type: "style", + type: "suggestion", docs: { description: "enforce a maximum number of line of code in a function", diff --git a/lib/rules/max-lines.js b/lib/rules/max-lines.js index 957db9ee734..730e05ab41c 100644 --- a/lib/rules/max-lines.js +++ b/lib/rules/max-lines.js @@ -17,7 +17,7 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { - type: "style", + type: "suggestion", docs: { description: "enforce a maximum number of lines per file", diff --git a/lib/rules/max-nested-callbacks.js b/lib/rules/max-nested-callbacks.js index f3ae73216b5..d4ecb4e2a5c 100644 --- a/lib/rules/max-nested-callbacks.js +++ b/lib/rules/max-nested-callbacks.js @@ -11,7 +11,7 @@ module.exports = { meta: { - type: "style", + type: "suggestion", docs: { description: "enforce a maximum depth that callbacks can be nested", diff --git a/lib/rules/max-params.js b/lib/rules/max-params.js index ec9fdffc19b..f678974acf3 100644 --- a/lib/rules/max-params.js +++ b/lib/rules/max-params.js @@ -19,7 +19,7 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { - type: "style", + type: "suggestion", docs: { description: "enforce a maximum number of parameters in function definitions", diff --git a/lib/rules/max-statements.js b/lib/rules/max-statements.js index ce930a3a1a8..e32dedad632 100644 --- a/lib/rules/max-statements.js +++ b/lib/rules/max-statements.js @@ -19,7 +19,7 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { - type: "style", + type: "suggestion", docs: { description: "enforce a maximum number of statements allowed in function blocks", diff --git a/lib/rules/multiline-comment-style.js b/lib/rules/multiline-comment-style.js index 6eb95438007..73eab7c5741 100644 --- a/lib/rules/multiline-comment-style.js +++ b/lib/rules/multiline-comment-style.js @@ -12,7 +12,7 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { - type: "style", + type: "suggestion", docs: { description: "enforce a particular style for multiline comments", diff --git a/lib/rules/no-array-constructor.js b/lib/rules/no-array-constructor.js index b867cb61329..90c6d6bbd59 100644 --- a/lib/rules/no-array-constructor.js +++ b/lib/rules/no-array-constructor.js @@ -11,7 +11,7 @@ module.exports = { meta: { - type: "style", + type: "suggestion", docs: { description: "disallow `Array` constructors", diff --git a/lib/rules/no-bitwise.js b/lib/rules/no-bitwise.js index ba0ff9c950e..df492937c0b 100644 --- a/lib/rules/no-bitwise.js +++ b/lib/rules/no-bitwise.js @@ -22,7 +22,7 @@ const BITWISE_OPERATORS = [ module.exports = { meta: { - type: "style", + type: "suggestion", docs: { description: "disallow bitwise operators", diff --git a/lib/rules/no-console.js b/lib/rules/no-console.js index aeb9a8cf335..d3a2e344751 100644 --- a/lib/rules/no-console.js +++ b/lib/rules/no-console.js @@ -17,7 +17,7 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { - type: "problem", + type: "suggestion", docs: { description: "disallow the use of `console`", diff --git a/lib/rules/no-continue.js b/lib/rules/no-continue.js index 0461fc839de..96718d17a3d 100644 --- a/lib/rules/no-continue.js +++ b/lib/rules/no-continue.js @@ -11,7 +11,7 @@ module.exports = { meta: { - type: "style", + type: "suggestion", docs: { description: "disallow `continue` statements", diff --git a/lib/rules/no-dupe-class-members.js b/lib/rules/no-dupe-class-members.js index 7dfb312b0ff..97f63a28962 100644 --- a/lib/rules/no-dupe-class-members.js +++ b/lib/rules/no-dupe-class-members.js @@ -11,7 +11,7 @@ module.exports = { meta: { - type: "suggestion", + type: "problem", docs: { description: "disallow duplicate class members", diff --git a/lib/rules/no-duplicate-imports.js b/lib/rules/no-duplicate-imports.js index 490ed3725d0..1d5bdfdc1a2 100644 --- a/lib/rules/no-duplicate-imports.js +++ b/lib/rules/no-duplicate-imports.js @@ -101,7 +101,7 @@ function handleExports(context, importsInFile, exportsInFile) { module.exports = { meta: { - type: "suggestion", + type: "problem", docs: { description: "disallow duplicate module imports", diff --git a/lib/rules/no-empty.js b/lib/rules/no-empty.js index 4073046f00a..9d72969e67e 100644 --- a/lib/rules/no-empty.js +++ b/lib/rules/no-empty.js @@ -16,7 +16,7 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { - type: "problem", + type: "suggestion", docs: { description: "disallow empty block statements", diff --git a/lib/rules/no-extra-boolean-cast.js b/lib/rules/no-extra-boolean-cast.js index 3fdc6b633df..615603177a5 100644 --- a/lib/rules/no-extra-boolean-cast.js +++ b/lib/rules/no-extra-boolean-cast.js @@ -17,7 +17,7 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { - type: "problem", + type: "suggestion", docs: { description: "disallow unnecessary boolean casts", diff --git a/lib/rules/no-fallthrough.js b/lib/rules/no-fallthrough.js index c3f7520359c..b7fa221050d 100644 --- a/lib/rules/no-fallthrough.js +++ b/lib/rules/no-fallthrough.js @@ -55,7 +55,7 @@ function hasBlankLinesBetween(node, token) { module.exports = { meta: { - type: "suggestion", + type: "problem", docs: { description: "disallow fallthrough of `case` statements", diff --git a/lib/rules/no-floating-decimal.js b/lib/rules/no-floating-decimal.js index 282daca636c..c835d6a545f 100644 --- a/lib/rules/no-floating-decimal.js +++ b/lib/rules/no-floating-decimal.js @@ -17,7 +17,7 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { - type: "style", + type: "suggestion", docs: { description: "disallow leading or trailing decimal points in numeric literals", diff --git a/lib/rules/no-inline-comments.js b/lib/rules/no-inline-comments.js index 27990ec0fa2..c282d16e754 100644 --- a/lib/rules/no-inline-comments.js +++ b/lib/rules/no-inline-comments.js @@ -12,7 +12,7 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { - type: "style", + type: "suggestion", docs: { description: "disallow inline comments after code", diff --git a/lib/rules/no-lonely-if.js b/lib/rules/no-lonely-if.js index 4f69bc7b779..4bbb5399ff9 100644 --- a/lib/rules/no-lonely-if.js +++ b/lib/rules/no-lonely-if.js @@ -10,7 +10,7 @@ module.exports = { meta: { - type: "style", + type: "suggestion", docs: { description: "disallow `if` statements as the only statement in `else` blocks", diff --git a/lib/rules/no-mixed-operators.js b/lib/rules/no-mixed-operators.js index d66d03c69f5..22ed65f5b1f 100644 --- a/lib/rules/no-mixed-operators.js +++ b/lib/rules/no-mixed-operators.js @@ -71,7 +71,7 @@ function includesBothInAGroup(groups, left, right) { module.exports = { meta: { - type: "style", + type: "suggestion", docs: { description: "disallow mixed binary operators", diff --git a/lib/rules/no-multi-assign.js b/lib/rules/no-multi-assign.js index 0ee34a69fcb..8524a1a571e 100644 --- a/lib/rules/no-multi-assign.js +++ b/lib/rules/no-multi-assign.js @@ -12,7 +12,7 @@ module.exports = { meta: { - type: "style", + type: "suggestion", docs: { description: "disallow use of chained assignment expressions", diff --git a/lib/rules/no-negated-condition.js b/lib/rules/no-negated-condition.js index f713de30d75..e55a8287487 100644 --- a/lib/rules/no-negated-condition.js +++ b/lib/rules/no-negated-condition.js @@ -10,7 +10,7 @@ module.exports = { meta: { - type: "style", + type: "suggestion", docs: { description: "disallow negated conditions", diff --git a/lib/rules/no-nested-ternary.js b/lib/rules/no-nested-ternary.js index bfae4ade551..87a11e87962 100644 --- a/lib/rules/no-nested-ternary.js +++ b/lib/rules/no-nested-ternary.js @@ -11,7 +11,7 @@ module.exports = { meta: { - type: "style", + type: "suggestion", docs: { description: "disallow nested ternary expressions", diff --git a/lib/rules/no-new-object.js b/lib/rules/no-new-object.js index 4279548e339..f5cc28664f4 100644 --- a/lib/rules/no-new-object.js +++ b/lib/rules/no-new-object.js @@ -11,7 +11,7 @@ module.exports = { meta: { - type: "style", + type: "suggestion", docs: { description: "disallow `Object` constructors", diff --git a/lib/rules/no-octal-escape.js b/lib/rules/no-octal-escape.js index eb2b9f21311..fc073b14033 100644 --- a/lib/rules/no-octal-escape.js +++ b/lib/rules/no-octal-escape.js @@ -11,7 +11,7 @@ module.exports = { meta: { - type: "style", + type: "suggestion", docs: { description: "disallow octal escape sequences in string literals", diff --git a/lib/rules/no-octal.js b/lib/rules/no-octal.js index 36a6115b1af..db1fa40aa5d 100644 --- a/lib/rules/no-octal.js +++ b/lib/rules/no-octal.js @@ -11,7 +11,7 @@ module.exports = { meta: { - type: "style", + type: "suggestion", docs: { description: "disallow octal literals", diff --git a/lib/rules/no-plusplus.js b/lib/rules/no-plusplus.js index 95f923b65fb..4c854de1a06 100644 --- a/lib/rules/no-plusplus.js +++ b/lib/rules/no-plusplus.js @@ -12,7 +12,7 @@ module.exports = { meta: { - type: "style", + type: "suggestion", docs: { description: "disallow the unary operators `++` and `--`", diff --git a/lib/rules/no-regex-spaces.js b/lib/rules/no-regex-spaces.js index ce6a7c86f45..d0f7293d20e 100644 --- a/lib/rules/no-regex-spaces.js +++ b/lib/rules/no-regex-spaces.js @@ -13,7 +13,7 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { - type: "problem", + type: "suggestion", docs: { description: "disallow multiple spaces in regular expressions", diff --git a/lib/rules/no-restricted-syntax.js b/lib/rules/no-restricted-syntax.js index b075f7e436a..74eea147891 100644 --- a/lib/rules/no-restricted-syntax.js +++ b/lib/rules/no-restricted-syntax.js @@ -10,7 +10,7 @@ module.exports = { meta: { - type: "style", + type: "suggestion", docs: { description: "disallow specified syntax", diff --git a/lib/rules/no-ternary.js b/lib/rules/no-ternary.js index 64674a1eed3..890f2abfa0c 100644 --- a/lib/rules/no-ternary.js +++ b/lib/rules/no-ternary.js @@ -11,7 +11,7 @@ module.exports = { meta: { - type: "style", + type: "suggestion", docs: { description: "disallow ternary operators", diff --git a/lib/rules/no-this-before-super.js b/lib/rules/no-this-before-super.js index 61a191bfc10..93fb094e9bc 100644 --- a/lib/rules/no-this-before-super.js +++ b/lib/rules/no-this-before-super.js @@ -36,7 +36,7 @@ function isConstructorFunction(node) { module.exports = { meta: { - type: "suggestion", + type: "problem", docs: { description: "disallow `this`/`super` before calling `super()` in constructors", diff --git a/lib/rules/no-undef.js b/lib/rules/no-undef.js index da89f9ef51e..f923644eca1 100644 --- a/lib/rules/no-undef.js +++ b/lib/rules/no-undef.js @@ -25,7 +25,7 @@ function hasTypeOfOperator(node) { module.exports = { meta: { - type: "suggestion", + type: "problem", docs: { description: "disallow the use of undeclared variables unless mentioned in `/*global */` comments", diff --git a/lib/rules/no-underscore-dangle.js b/lib/rules/no-underscore-dangle.js index 9448ecde77d..926803b992d 100644 --- a/lib/rules/no-underscore-dangle.js +++ b/lib/rules/no-underscore-dangle.js @@ -11,7 +11,7 @@ module.exports = { meta: { - type: "style", + type: "suggestion", docs: { description: "disallow dangling underscores in identifiers", diff --git a/lib/rules/no-unneeded-ternary.js b/lib/rules/no-unneeded-ternary.js index 29cbe72eb96..3a7dd5fad7d 100644 --- a/lib/rules/no-unneeded-ternary.js +++ b/lib/rules/no-unneeded-ternary.js @@ -24,7 +24,7 @@ const OPERATOR_INVERSES = { module.exports = { meta: { - type: "style", + type: "suggestion", docs: { description: "disallow ternary operators when simpler alternatives exist", diff --git a/lib/rules/no-unused-vars.js b/lib/rules/no-unused-vars.js index a73c537ab21..4bd4146ce99 100644 --- a/lib/rules/no-unused-vars.js +++ b/lib/rules/no-unused-vars.js @@ -18,7 +18,7 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { - type: "suggestion", + type: "problem", docs: { description: "disallow unused variables", diff --git a/lib/rules/prefer-arrow-callback.js b/lib/rules/prefer-arrow-callback.js index b4bbf33f296..32ac8fb9eb7 100644 --- a/lib/rules/prefer-arrow-callback.js +++ b/lib/rules/prefer-arrow-callback.js @@ -179,7 +179,7 @@ module.exports = { * @returns {void} */ function enterScope() { - stack.push({ this: false, super: false, meta: false }); + stack.push(); } /** diff --git a/lib/rules/prefer-object-spread.js b/lib/rules/prefer-object-spread.js index 4709faf5c1f..a8dac696be0 100644 --- a/lib/rules/prefer-object-spread.js +++ b/lib/rules/prefer-object-spread.js @@ -212,7 +212,7 @@ function defineFixer(node, sourceCode) { module.exports = { meta: { - type: "style", + type: "suggestion", docs: { description: diff --git a/lib/rules/sort-keys.js b/lib/rules/sort-keys.js index 7da671c980c..0668e617d3c 100644 --- a/lib/rules/sort-keys.js +++ b/lib/rules/sort-keys.js @@ -73,7 +73,7 @@ const isValidOrders = { module.exports = { meta: { - type: "style", + type: "suggestion", docs: { description: "require object keys to be sorted", diff --git a/lib/rules/sort-vars.js b/lib/rules/sort-vars.js index 7b0e0cdca37..b6a2c86779c 100644 --- a/lib/rules/sort-vars.js +++ b/lib/rules/sort-vars.js @@ -11,7 +11,7 @@ module.exports = { meta: { - type: "style", + type: "suggestion", docs: { description: "require variables within the same declaration block to be sorted", diff --git a/tools/rule-types.json b/tools/rule-types.json index 25c4e1ea265..212d32fc289 100644 --- a/tools/rule-types.json +++ b/tools/rule-types.json @@ -11,8 +11,8 @@ "block-spacing": "style", "brace-style": "style", "callback-return": "suggestion", - "camelcase": "style", - "capitalized-comments": "style", + "camelcase": "suggestion", + "capitalized-comments": "suggestion", "class-methods-use-this": "suggestion", "comma-dangle": "style", "comma-spacing": "style", @@ -20,7 +20,7 @@ "complexity": "suggestion", "computed-property-spacing": "style", "consistent-return": "suggestion", - "consistent-this": "style", + "consistent-this": "suggestion", "constructor-super": "suggestion", "curly": "suggestion", "default-case": "suggestion", @@ -32,7 +32,7 @@ "func-call-spacing": "style", "func-name-matching": "style", "func-names": "style", - "func-style": "style", + "func-style": "suggestion", "function-paren-newline": "style", "generator-star-spacing": "style", "getter-return": "problem", @@ -54,16 +54,16 @@ "lines-around-comment": "style", "lines-around-directive": "style", "lines-between-class-members": "style", - "max-classes-per-file": "style", - "max-depth": "style", + "max-classes-per-file": "suggestion", + "max-depth": "suggestion", "max-len": "style", - "max-lines": "style", - "max-lines-per-function": "style", - "max-nested-callbacks": "style", - "max-params": "style", - "max-statements": "style", + "max-lines": "suggestion", + "max-lines-per-function": "suggestion", + "max-nested-callbacks": "suggestion", + "max-params": "suggestion", + "max-statements": "suggestion", "max-statements-per-line": "style", - "multiline-comment-style": "style", + "multiline-comment-style": "suggestion", "multiline-ternary": "style", "new-cap": "style", "new-parens": "style", @@ -71,10 +71,10 @@ "newline-before-return": "style", "newline-per-chained-call": "style", "no-alert": "suggestion", - "no-array-constructor": "style", + "no-array-constructor": "suggestion", "no-async-promise-executor": "problem", "no-await-in-loop": "problem", - "no-bitwise": "style", + "no-bitwise": "suggestion", "no-buffer-constructor": "suggestion", "no-caller": "suggestion", "no-case-declarations": "suggestion", @@ -83,21 +83,21 @@ "no-compare-neg-zero": "problem", "no-cond-assign": "problem", "no-confusing-arrow": "suggestion", - "no-console": "problem", + "no-console": "suggestion", "no-const-assign": "suggestion", "no-constant-condition": "problem", - "no-continue": "style", + "no-continue": "suggestion", "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-class-members": "problem", "no-dupe-keys": "problem", "no-duplicate-case": "problem", - "no-duplicate-imports": "suggestion", + "no-duplicate-imports": "problem", "no-else-return": "suggestion", - "no-empty": "problem", + "no-empty": "suggestion", "no-empty-character-class": "problem", "no-empty-function": "suggestion", "no-empty-pattern": "suggestion", @@ -106,18 +106,18 @@ "no-ex-assign": "problem", "no-extend-native": "suggestion", "no-extra-bind": "suggestion", - "no-extra-boolean-cast": "problem", + "no-extra-boolean-cast": "suggestion", "no-extra-label": "suggestion", "no-extra-parens": "style", "no-extra-semi": "style", - "no-fallthrough": "suggestion", - "no-floating-decimal": "style", + "no-fallthrough": "problem", + "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-inline-comments": "suggestion", "no-inner-declarations": "problem", "no-invalid-regexp": "problem", "no-invalid-this": "suggestion", @@ -126,44 +126,44 @@ "no-label-var": "suggestion", "no-labels": "suggestion", "no-lone-blocks": "suggestion", - "no-lonely-if": "style", + "no-lonely-if": "suggestion", "no-loop-func": "suggestion", "no-magic-numbers": "suggestion", "no-misleading-character-class": "problem", - "no-mixed-operators": "style", + "no-mixed-operators": "suggestion", "no-mixed-requires": "suggestion", "no-mixed-spaces-and-tabs": "style", - "no-multi-assign": "style", + "no-multi-assign": "suggestion", "no-multi-spaces": "style", "no-multi-str": "suggestion", "no-multiple-empty-lines": "style", "no-native-reassign": "suggestion", - "no-negated-condition": "style", + "no-negated-condition": "suggestion", "no-negated-in-lhs": "problem", - "no-nested-ternary": "style", + "no-nested-ternary": "suggestion", "no-new": "suggestion", "no-new-func": "suggestion", - "no-new-object": "style", + "no-new-object": "suggestion", "no-new-require": "suggestion", "no-new-symbol": "suggestion", "no-new-wrappers": "suggestion", "no-obj-calls": "problem", - "no-octal": "style", - "no-octal-escape": "style", + "no-octal": "suggestion", + "no-octal-escape": "suggestion", "no-param-reassign": "suggestion", "no-path-concat": "suggestion", - "no-plusplus": "style", + "no-plusplus": "suggestion", "no-process-env": "suggestion", "no-process-exit": "suggestion", "no-proto": "suggestion", "no-prototype-builtins": "problem", "no-redeclare": "suggestion", - "no-regex-spaces": "problem", + "no-regex-spaces": "suggestion", "no-restricted-globals": "suggestion", "no-restricted-imports": "suggestion", "no-restricted-modules": "suggestion", "no-restricted-properties": "suggestion", - "no-restricted-syntax": "style", + "no-restricted-syntax": "suggestion", "no-return-assign": "suggestion", "no-return-await": "suggestion", "no-script-url": "suggestion", @@ -177,23 +177,23 @@ "no-sync": "suggestion", "no-tabs": "style", "no-template-curly-in-string": "problem", - "no-ternary": "style", - "no-this-before-super": "suggestion", + "no-ternary": "suggestion", + "no-this-before-super": "problem", "no-throw-literal": "suggestion", "no-trailing-spaces": "style", - "no-undef": "suggestion", + "no-undef": "problem", "no-undef-init": "suggestion", "no-undefined": "suggestion", - "no-underscore-dangle": "style", + "no-underscore-dangle": "suggestion", "no-unexpected-multiline": "problem", "no-unmodified-loop-condition": "suggestion", - "no-unneeded-ternary": "style", + "no-unneeded-ternary": "suggestion", "no-unreachable": "problem", "no-unsafe-finally": "problem", "no-unsafe-negation": "problem", "no-unused-expressions": "suggestion", "no-unused-labels": "suggestion", - "no-unused-vars": "suggestion", + "no-unused-vars": "problem", "no-use-before-define": "suggestion", "no-useless-call": "suggestion", "no-useless-computed-key": "suggestion", @@ -222,7 +222,7 @@ "prefer-const": "suggestion", "prefer-destructuring": "suggestion", "prefer-numeric-literals": "suggestion", - "prefer-object-spread": "style", + "prefer-object-spread": "suggestion", "prefer-promise-reject-errors": "suggestion", "prefer-reflect": "suggestion", "prefer-rest-params": "suggestion", @@ -241,8 +241,8 @@ "semi-spacing": "style", "semi-style": "style", "sort-imports": "suggestion", - "sort-keys": "style", - "sort-vars": "style", + "sort-keys": "suggestion", + "sort-vars": "suggestion", "space-before-blocks": "style", "space-before-function-paren": "style", "space-in-parens": "style", From 9ee371f866baed1744ca7e27dc44c048a13b0e77 Mon Sep 17 00:00:00 2001 From: "Nicholas C. Zakas" Date: Mon, 29 Oct 2018 09:44:41 -0700 Subject: [PATCH 18/25] Update rules to use 'layout' instead of 'style' --- docs/developer-guide/nodejs-api.md | 2 +- docs/developer-guide/working-with-rules.md | 5 +- docs/user-guide/command-line-interface.md | 8 +- lib/cli-engine.js | 2 +- lib/options.js | 2 +- lib/rules/array-bracket-newline.js | 2 +- lib/rules/array-bracket-spacing.js | 2 +- lib/rules/array-element-newline.js | 2 +- lib/rules/arrow-parens.js | 2 +- lib/rules/arrow-spacing.js | 2 +- lib/rules/block-spacing.js | 2 +- lib/rules/brace-style.js | 2 +- lib/rules/comma-dangle.js | 2 +- lib/rules/comma-spacing.js | 2 +- lib/rules/comma-style.js | 2 +- lib/rules/computed-property-spacing.js | 2 +- lib/rules/dot-location.js | 2 +- lib/rules/eol-last.js | 2 +- lib/rules/func-call-spacing.js | 2 +- lib/rules/func-name-matching.js | 2 +- lib/rules/func-names.js | 2 +- lib/rules/function-paren-newline.js | 2 +- lib/rules/generator-star-spacing.js | 2 +- lib/rules/id-blacklist.js | 2 +- lib/rules/id-length.js | 2 +- lib/rules/id-match.js | 2 +- lib/rules/implicit-arrow-linebreak.js | 2 +- lib/rules/indent-legacy.js | 2 +- lib/rules/indent.js | 2 +- lib/rules/jsx-quotes.js | 2 +- lib/rules/key-spacing.js | 2 +- lib/rules/keyword-spacing.js | 2 +- lib/rules/line-comment-position.js | 2 +- lib/rules/linebreak-style.js | 2 +- lib/rules/lines-around-comment.js | 2 +- lib/rules/lines-around-directive.js | 2 +- lib/rules/lines-between-class-members.js | 2 +- lib/rules/max-len.js | 2 +- lib/rules/max-statements-per-line.js | 2 +- lib/rules/multiline-ternary.js | 2 +- lib/rules/new-cap.js | 2 +- lib/rules/new-parens.js | 2 +- lib/rules/newline-after-var.js | 2 +- lib/rules/newline-before-return.js | 2 +- lib/rules/newline-per-chained-call.js | 2 +- lib/rules/no-extra-parens.js | 2 +- lib/rules/no-extra-semi.js | 2 +- lib/rules/no-mixed-spaces-and-tabs.js | 2 +- lib/rules/no-multi-spaces.js | 2 +- lib/rules/no-multiple-empty-lines.js | 2 +- lib/rules/no-spaced-func.js | 2 +- lib/rules/no-tabs.js | 2 +- lib/rules/no-trailing-spaces.js | 2 +- lib/rules/no-whitespace-before-property.js | 2 +- lib/rules/nonblock-statement-body-position.js | 2 +- lib/rules/object-curly-newline.js | 2 +- lib/rules/object-curly-spacing.js | 2 +- lib/rules/object-property-newline.js | 2 +- lib/rules/one-var-declaration-per-line.js | 2 +- lib/rules/one-var.js | 2 +- lib/rules/operator-assignment.js | 2 +- lib/rules/operator-linebreak.js | 2 +- lib/rules/padded-blocks.js | 2 +- lib/rules/padding-line-between-statements.js | 2 +- lib/rules/quote-props.js | 2 +- lib/rules/quotes.js | 2 +- lib/rules/require-jsdoc.js | 2 +- lib/rules/rest-spread-spacing.js | 2 +- lib/rules/semi-spacing.js | 2 +- lib/rules/semi-style.js | 2 +- lib/rules/semi.js | 2 +- lib/rules/space-before-blocks.js | 2 +- lib/rules/space-before-function-paren.js | 2 +- lib/rules/space-in-parens.js | 2 +- lib/rules/space-infix-ops.js | 2 +- lib/rules/space-unary-ops.js | 2 +- lib/rules/spaced-comment.js | 2 +- lib/rules/switch-colon-spacing.js | 2 +- lib/rules/template-curly-spacing.js | 2 +- lib/rules/template-tag-spacing.js | 2 +- lib/rules/unicode-bom.js | 2 +- lib/rules/valid-jsdoc.js | 2 +- lib/rules/wrap-iife.js | 2 +- lib/rules/wrap-regex.js | 2 +- lib/rules/yield-star-spacing.js | 2 +- tests/lib/cli-engine.js | 16 +- tools/rule-types.json | 160 +++++++++--------- 87 files changed, 179 insertions(+), 176 deletions(-) diff --git a/docs/developer-guide/nodejs-api.md b/docs/developer-guide/nodejs-api.md index 521ad22464b..834fecefda9 100644 --- a/docs/developer-guide/nodejs-api.md +++ b/docs/developer-guide/nodejs-api.md @@ -348,7 +348,7 @@ The `CLIEngine` is a constructor, and you can create a new instance by passing i * `envs` - An array of environments to load (default: empty array). Corresponds to `--env`. * `extensions` - An array of filename extensions that should be checked for code. The default is an array containing just `".js"`. Corresponds to `--ext`. It is only used in conjunction with directories, not with filenames or glob patterns. * `fix` - A boolean or a function (default: `false`). If a function, it will be passed each linting message and should return a boolean indicating whether the fix should be included with the output report (errors and warnings will not be listed if fixed). Files on disk are never changed regardless of the value of `fix`. To persist changes to disk, call [`outputFixes()`](#cliengineoutputfixes). -* `fixTypes` - An array of rule types for which fixes should be applied (default: `null`). This array acts like a filter, only allowing rules of the given types to apply fixes. Possible array values are `"problem"`, `"suggestion"`, and `"style"`. +* `fixTypes` - An array of rule types for which fixes should be applied (default: `null`). This array acts like a filter, only allowing rules of the given types to apply fixes. Possible array values are `"problem"`, `"suggestion"`, and `"layout"`. * `globals` - An array of global variables to declare (default: empty array). Corresponds to `--global`. * `ignore` - False disables use of `.eslintignore`, `ignorePath` and `ignorePattern` (default: true). Corresponds to `--no-ignore`. * `ignorePath` - The ignore file to use instead of `.eslintignore` (default: null). Corresponds to `--ignore-path`. diff --git a/docs/developer-guide/working-with-rules.md b/docs/developer-guide/working-with-rules.md index 886396bc3c7..a0524ea5b64 100644 --- a/docs/developer-guide/working-with-rules.md +++ b/docs/developer-guide/working-with-rules.md @@ -51,7 +51,10 @@ The source file for a rule exports an object with the following properties. `meta` (object) contains metadata for the rule: -* `type` (string) indicates the type of rule, which is one of `"problem"`, `"suggestion"`, or `"style"` +* `type` (string) indicates the type of rule, which is one of `"problem"`, `"suggestion"`, or `"layout"`: + * `"problem"` means the rule is identifying code that either will cause an error or may cause a confusing behavior. Developers should consider this a high priority to resolve. + * `"suggestion"` means the rule is identifying something that could be done in a better way but no errors will occur if the code isn't changed. + * `"layout"` means the rule cares primarily about whitespace, semicolons, commas, and parentheses, all the parts of the program that determine how the code looks rather than how it executes. These rules work on parts of the code that aren't specified in the AST. * `docs` (object) is required for core rules of ESLint: diff --git a/docs/user-guide/command-line-interface.md b/docs/user-guide/command-line-interface.md index 5d3cf7c9288..7fee37cf418 100644 --- a/docs/user-guide/command-line-interface.md +++ b/docs/user-guide/command-line-interface.md @@ -46,7 +46,7 @@ Specifying rules and plugins: Fixing problems: --fix Automatically fix problems --fix-dry-run Automatically fix problems without saving the changes to the file system - --fix-type Array Specify the types of fixes to apply (problem, suggestion, style) + --fix-type Array Specify the types of fixes to apply (problem, suggestion, layout) Ignoring files: --ignore-path path::String Specify path of ignore file @@ -240,17 +240,17 @@ This option allows you to specify the type of fixes to apply when using either ` 1. `problem` - fix potential errors in the code 1. `suggestion` - apply fixes to the code that improve it -1. `style` - apply fixes that do not mutate the program structure (AST) +1. `layout` - apply fixes that do not change the program structure (AST) You can specify one or more fix type on the command line. Here are some examples: ``` eslint --fix --fix-type suggestion . eslint --fix --fix-type suggestion --fix-type problem . -eslint --fix --fix-type suggestion,style . +eslint --fix --fix-type suggestion,layout . ``` -This option is helpful if you are using another program to style your code but you would still like ESLint to apply other types of fixes. +This option is helpful if you are using another program to format your code but you would still like ESLint to apply other types of fixes. ### Ignoring files diff --git a/lib/cli-engine.js b/lib/cli-engine.js index 3cdde761231..6fd3f0c1de9 100644 --- a/lib/cli-engine.js +++ b/lib/cli-engine.js @@ -33,7 +33,7 @@ const fs = require("fs"), const debug = require("debug")("eslint:cli-engine"); const resolver = new ModuleResolver(); -const validFixTypes = new Set(["problem", "suggestion", "style"]); +const validFixTypes = new Set(["problem", "suggestion", "layout"]); //------------------------------------------------------------------------------ // Typedefs diff --git a/lib/options.js b/lib/options.js index 7d1d66f29ad..ee7357a296a 100644 --- a/lib/options.js +++ b/lib/options.js @@ -100,7 +100,7 @@ module.exports = optionator({ { option: "fix-type", type: "Array", - description: "Specify the types of fixes to apply (problem, suggestion, style)" + description: "Specify the types of fixes to apply (problem, suggestion, layout)" }, { heading: "Ignoring files" diff --git a/lib/rules/array-bracket-newline.js b/lib/rules/array-bracket-newline.js index 31c2c76f68b..a458e69f761 100644 --- a/lib/rules/array-bracket-newline.js +++ b/lib/rules/array-bracket-newline.js @@ -13,7 +13,7 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "enforce linebreaks after opening and before closing array brackets", diff --git a/lib/rules/array-bracket-spacing.js b/lib/rules/array-bracket-spacing.js index 764fc2d959f..4bead37a12f 100644 --- a/lib/rules/array-bracket-spacing.js +++ b/lib/rules/array-bracket-spacing.js @@ -12,7 +12,7 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "enforce consistent spacing inside array brackets", diff --git a/lib/rules/array-element-newline.js b/lib/rules/array-element-newline.js index 16c76e7dbb9..440290917d3 100644 --- a/lib/rules/array-element-newline.js +++ b/lib/rules/array-element-newline.js @@ -13,7 +13,7 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "enforce line breaks after each array element", diff --git a/lib/rules/arrow-parens.js b/lib/rules/arrow-parens.js index a4fa26e18d9..637a0c1f1f1 100644 --- a/lib/rules/arrow-parens.js +++ b/lib/rules/arrow-parens.js @@ -16,7 +16,7 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "require parentheses around arrow function arguments", diff --git a/lib/rules/arrow-spacing.js b/lib/rules/arrow-spacing.js index fa95ffed06c..87d381840a9 100644 --- a/lib/rules/arrow-spacing.js +++ b/lib/rules/arrow-spacing.js @@ -16,7 +16,7 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "enforce consistent spacing before and after the arrow in arrow functions", diff --git a/lib/rules/block-spacing.js b/lib/rules/block-spacing.js index 8bfd51024f5..6496f8596d3 100644 --- a/lib/rules/block-spacing.js +++ b/lib/rules/block-spacing.js @@ -13,7 +13,7 @@ const util = require("../util/ast-utils"); module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "disallow or enforce spaces inside of blocks after opening block and before closing block", diff --git a/lib/rules/brace-style.js b/lib/rules/brace-style.js index 152d1463d87..d172124d2f4 100644 --- a/lib/rules/brace-style.js +++ b/lib/rules/brace-style.js @@ -13,7 +13,7 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "enforce consistent brace style for blocks", diff --git a/lib/rules/comma-dangle.js b/lib/rules/comma-dangle.js index d2560b01122..96799b30796 100644 --- a/lib/rules/comma-dangle.js +++ b/lib/rules/comma-dangle.js @@ -76,7 +76,7 @@ function normalizeOptions(optionValue) { module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "require or disallow trailing commas", diff --git a/lib/rules/comma-spacing.js b/lib/rules/comma-spacing.js index 83c7a94b013..2db0035b545 100644 --- a/lib/rules/comma-spacing.js +++ b/lib/rules/comma-spacing.js @@ -12,7 +12,7 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "enforce consistent spacing before and after commas", diff --git a/lib/rules/comma-style.js b/lib/rules/comma-style.js index fdf078bade1..2586cf66e92 100644 --- a/lib/rules/comma-style.js +++ b/lib/rules/comma-style.js @@ -13,7 +13,7 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "enforce consistent comma style", diff --git a/lib/rules/computed-property-spacing.js b/lib/rules/computed-property-spacing.js index 1cde4c5c47b..188d863d0d0 100644 --- a/lib/rules/computed-property-spacing.js +++ b/lib/rules/computed-property-spacing.js @@ -12,7 +12,7 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "enforce consistent spacing inside computed property brackets", diff --git a/lib/rules/dot-location.js b/lib/rules/dot-location.js index f6b97537cef..0eefec2eaff 100644 --- a/lib/rules/dot-location.js +++ b/lib/rules/dot-location.js @@ -13,7 +13,7 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "enforce consistent newlines before and after dots", diff --git a/lib/rules/eol-last.js b/lib/rules/eol-last.js index 7a748178f6c..84f4d45f176 100644 --- a/lib/rules/eol-last.js +++ b/lib/rules/eol-last.js @@ -16,7 +16,7 @@ const lodash = require("lodash"); module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "require or disallow newline at the end of files", diff --git a/lib/rules/func-call-spacing.js b/lib/rules/func-call-spacing.js index 8a812c82565..c49aa9e59f7 100644 --- a/lib/rules/func-call-spacing.js +++ b/lib/rules/func-call-spacing.js @@ -17,7 +17,7 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "require or disallow spacing between function identifiers and their invocations", diff --git a/lib/rules/func-name-matching.js b/lib/rules/func-name-matching.js index 5b9d7fcb62d..f14c998dc7f 100644 --- a/lib/rules/func-name-matching.js +++ b/lib/rules/func-name-matching.js @@ -70,7 +70,7 @@ const optionsObject = { module.exports = { meta: { - type: "style", + type: "suggestion", docs: { description: "require function names to match the name of the variable or property to which they are assigned", diff --git a/lib/rules/func-names.js b/lib/rules/func-names.js index ee1234e29f4..4ccbae0f0cb 100644 --- a/lib/rules/func-names.js +++ b/lib/rules/func-names.js @@ -26,7 +26,7 @@ function isFunctionName(variable) { module.exports = { meta: { - type: "style", + type: "suggestion", docs: { description: "require or disallow named `function` expressions", diff --git a/lib/rules/function-paren-newline.js b/lib/rules/function-paren-newline.js index 20bed8f3f8c..37256484f4a 100644 --- a/lib/rules/function-paren-newline.js +++ b/lib/rules/function-paren-newline.js @@ -16,7 +16,7 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "enforce consistent line breaks inside function parentheses", diff --git a/lib/rules/generator-star-spacing.js b/lib/rules/generator-star-spacing.js index 887c8b225e0..6f860290cec 100644 --- a/lib/rules/generator-star-spacing.js +++ b/lib/rules/generator-star-spacing.js @@ -27,7 +27,7 @@ const OVERRIDE_SCHEMA = { module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "enforce consistent spacing around `*` operators in generator functions", diff --git a/lib/rules/id-blacklist.js b/lib/rules/id-blacklist.js index b16ca682172..7b8facbabe0 100644 --- a/lib/rules/id-blacklist.js +++ b/lib/rules/id-blacklist.js @@ -12,7 +12,7 @@ module.exports = { meta: { - type: "style", + type: "suggestion", docs: { description: "disallow specified identifiers", diff --git a/lib/rules/id-length.js b/lib/rules/id-length.js index 731eddf50fc..d72eb08876a 100644 --- a/lib/rules/id-length.js +++ b/lib/rules/id-length.js @@ -12,7 +12,7 @@ module.exports = { meta: { - type: "style", + type: "suggestion", docs: { description: "enforce minimum and maximum identifier lengths", diff --git a/lib/rules/id-match.js b/lib/rules/id-match.js index d982a759d92..17dfbc05bd2 100644 --- a/lib/rules/id-match.js +++ b/lib/rules/id-match.js @@ -11,7 +11,7 @@ module.exports = { meta: { - type: "style", + type: "suggestion", docs: { description: "require identifiers to match a specified regular expression", diff --git a/lib/rules/implicit-arrow-linebreak.js b/lib/rules/implicit-arrow-linebreak.js index 7602a82e2c2..cd729f8ad93 100644 --- a/lib/rules/implicit-arrow-linebreak.js +++ b/lib/rules/implicit-arrow-linebreak.js @@ -9,7 +9,7 @@ //------------------------------------------------------------------------------ module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "enforce the location of arrow function bodies", diff --git a/lib/rules/indent-legacy.js b/lib/rules/indent-legacy.js index c3166de82a3..16687b521ed 100644 --- a/lib/rules/indent-legacy.js +++ b/lib/rules/indent-legacy.js @@ -21,7 +21,7 @@ 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", + type: "layout", docs: { description: "enforce consistent indentation", diff --git a/lib/rules/indent.js b/lib/rules/indent.js index 5c8ed43885b..dc9fbaf908b 100644 --- a/lib/rules/indent.js +++ b/lib/rules/indent.js @@ -490,7 +490,7 @@ const ELEMENT_LIST_SCHEMA = { module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "enforce consistent indentation", diff --git a/lib/rules/jsx-quotes.js b/lib/rules/jsx-quotes.js index cfc0a391cb3..603d55330b5 100644 --- a/lib/rules/jsx-quotes.js +++ b/lib/rules/jsx-quotes.js @@ -38,7 +38,7 @@ const QUOTE_SETTINGS = { module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "enforce the consistent use of either double or single quotes in JSX attributes", diff --git a/lib/rules/key-spacing.js b/lib/rules/key-spacing.js index 9adaeb96df9..2d1315fde09 100644 --- a/lib/rules/key-spacing.js +++ b/lib/rules/key-spacing.js @@ -128,7 +128,7 @@ const messages = { module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "enforce consistent spacing between keys and values in object literal properties", diff --git a/lib/rules/keyword-spacing.js b/lib/rules/keyword-spacing.js index ca1ce055635..66ce2cb34c0 100644 --- a/lib/rules/keyword-spacing.js +++ b/lib/rules/keyword-spacing.js @@ -65,7 +65,7 @@ function isCloseParenOfTemplate(token) { module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "enforce consistent spacing before and after keywords", diff --git a/lib/rules/line-comment-position.js b/lib/rules/line-comment-position.js index 92b8ce75185..7c791d5f277 100644 --- a/lib/rules/line-comment-position.js +++ b/lib/rules/line-comment-position.js @@ -12,7 +12,7 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "enforce position of line comments", diff --git a/lib/rules/linebreak-style.js b/lib/rules/linebreak-style.js index 4568d4038d0..5345d53f288 100644 --- a/lib/rules/linebreak-style.js +++ b/lib/rules/linebreak-style.js @@ -17,7 +17,7 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "enforce consistent linebreak style", diff --git a/lib/rules/lines-around-comment.js b/lib/rules/lines-around-comment.js index a62b8291dff..30175cd3663 100644 --- a/lib/rules/lines-around-comment.js +++ b/lib/rules/lines-around-comment.js @@ -52,7 +52,7 @@ function getCommentLineNums(comments) { module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "require empty lines around comments", diff --git a/lib/rules/lines-around-directive.js b/lib/rules/lines-around-directive.js index 8eb9f991295..02bbe13b4fc 100644 --- a/lib/rules/lines-around-directive.js +++ b/lib/rules/lines-around-directive.js @@ -14,7 +14,7 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "require or disallow newlines around directives", diff --git a/lib/rules/lines-between-class-members.js b/lib/rules/lines-between-class-members.js index 563117628db..5c1e69277a5 100644 --- a/lib/rules/lines-between-class-members.js +++ b/lib/rules/lines-between-class-members.js @@ -12,7 +12,7 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "require or disallow an empty line between class members", diff --git a/lib/rules/max-len.js b/lib/rules/max-len.js index b869a9ec3ec..13dd72160cc 100644 --- a/lib/rules/max-len.js +++ b/lib/rules/max-len.js @@ -65,7 +65,7 @@ const OPTIONS_OR_INTEGER_SCHEMA = { module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "enforce a maximum line length", diff --git a/lib/rules/max-statements-per-line.js b/lib/rules/max-statements-per-line.js index 819d2347c03..f3fb8e9d5cf 100644 --- a/lib/rules/max-statements-per-line.js +++ b/lib/rules/max-statements-per-line.js @@ -16,7 +16,7 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "enforce a maximum number of statements allowed per line", diff --git a/lib/rules/multiline-ternary.js b/lib/rules/multiline-ternary.js index 34a52cf4fa9..d1d577a4ffa 100644 --- a/lib/rules/multiline-ternary.js +++ b/lib/rules/multiline-ternary.js @@ -13,7 +13,7 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "enforce newlines between operands of ternary expressions", diff --git a/lib/rules/new-cap.js b/lib/rules/new-cap.js index 98bf286d507..834f4605ed2 100644 --- a/lib/rules/new-cap.js +++ b/lib/rules/new-cap.js @@ -74,7 +74,7 @@ function calculateCapIsNewExceptions(config) { module.exports = { meta: { - type: "style", + type: "suggestion", docs: { description: "require constructor names to begin with a capital letter", diff --git a/lib/rules/new-parens.js b/lib/rules/new-parens.js index 00a7524aab8..0637a8fbca2 100644 --- a/lib/rules/new-parens.js +++ b/lib/rules/new-parens.js @@ -21,7 +21,7 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "require parentheses when invoking a constructor with no arguments", diff --git a/lib/rules/newline-after-var.js b/lib/rules/newline-after-var.js index e34fd05d55b..83fd420d733 100644 --- a/lib/rules/newline-after-var.js +++ b/lib/rules/newline-after-var.js @@ -18,7 +18,7 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "require or disallow an empty line after variable declarations", diff --git a/lib/rules/newline-before-return.js b/lib/rules/newline-before-return.js index 98793a70508..2743bf7a8be 100644 --- a/lib/rules/newline-before-return.js +++ b/lib/rules/newline-before-return.js @@ -11,7 +11,7 @@ module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "require an empty line before `return` statements", diff --git a/lib/rules/newline-per-chained-call.js b/lib/rules/newline-per-chained-call.js index 97a74492659..9d993137682 100644 --- a/lib/rules/newline-per-chained-call.js +++ b/lib/rules/newline-per-chained-call.js @@ -14,7 +14,7 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "require a newline after each call in a method chain", diff --git a/lib/rules/no-extra-parens.js b/lib/rules/no-extra-parens.js index 0d499f4ee90..3a21b69580b 100644 --- a/lib/rules/no-extra-parens.js +++ b/lib/rules/no-extra-parens.js @@ -12,7 +12,7 @@ const astUtils = require("../util/ast-utils.js"); module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "disallow unnecessary parentheses", diff --git a/lib/rules/no-extra-semi.js b/lib/rules/no-extra-semi.js index 8b0c6f54ec3..1893e57ef3a 100644 --- a/lib/rules/no-extra-semi.js +++ b/lib/rules/no-extra-semi.js @@ -18,7 +18,7 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "disallow unnecessary semicolons", diff --git a/lib/rules/no-mixed-spaces-and-tabs.js b/lib/rules/no-mixed-spaces-and-tabs.js index 7c0fead1ed0..1fc0b6074b8 100644 --- a/lib/rules/no-mixed-spaces-and-tabs.js +++ b/lib/rules/no-mixed-spaces-and-tabs.js @@ -10,7 +10,7 @@ module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "disallow mixed spaces and tabs for indentation", diff --git a/lib/rules/no-multi-spaces.js b/lib/rules/no-multi-spaces.js index 1f382d1f3a2..f1792c31ed7 100644 --- a/lib/rules/no-multi-spaces.js +++ b/lib/rules/no-multi-spaces.js @@ -13,7 +13,7 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "disallow multiple spaces", diff --git a/lib/rules/no-multiple-empty-lines.js b/lib/rules/no-multiple-empty-lines.js index ed4f44d5efc..f945cfeffe2 100644 --- a/lib/rules/no-multiple-empty-lines.js +++ b/lib/rules/no-multiple-empty-lines.js @@ -11,7 +11,7 @@ module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "disallow multiple empty lines", diff --git a/lib/rules/no-spaced-func.js b/lib/rules/no-spaced-func.js index 02cb710fdc8..8535881f435 100644 --- a/lib/rules/no-spaced-func.js +++ b/lib/rules/no-spaced-func.js @@ -12,7 +12,7 @@ module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "disallow spacing between function identifiers and their applications (deprecated)", diff --git a/lib/rules/no-tabs.js b/lib/rules/no-tabs.js index 2b4de762f6f..0002f559290 100644 --- a/lib/rules/no-tabs.js +++ b/lib/rules/no-tabs.js @@ -18,7 +18,7 @@ const anyNonWhitespaceRegex = /\S/; module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "disallow all tabs", diff --git a/lib/rules/no-trailing-spaces.js b/lib/rules/no-trailing-spaces.js index 1c75a19658f..18f0340ef01 100644 --- a/lib/rules/no-trailing-spaces.js +++ b/lib/rules/no-trailing-spaces.js @@ -16,7 +16,7 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "disallow trailing whitespace at the end of lines", diff --git a/lib/rules/no-whitespace-before-property.js b/lib/rules/no-whitespace-before-property.js index 49dc4ad7d04..1ecc51db67c 100644 --- a/lib/rules/no-whitespace-before-property.js +++ b/lib/rules/no-whitespace-before-property.js @@ -16,7 +16,7 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "disallow whitespace before properties", diff --git a/lib/rules/nonblock-statement-body-position.js b/lib/rules/nonblock-statement-body-position.js index d284c704832..01763cea92f 100644 --- a/lib/rules/nonblock-statement-body-position.js +++ b/lib/rules/nonblock-statement-body-position.js @@ -12,7 +12,7 @@ const POSITION_SCHEMA = { enum: ["beside", "below", "any"] }; module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "enforce the location of single-line statements", diff --git a/lib/rules/object-curly-newline.js b/lib/rules/object-curly-newline.js index 58162ae6c11..c460ea56bc3 100644 --- a/lib/rules/object-curly-newline.js +++ b/lib/rules/object-curly-newline.js @@ -134,7 +134,7 @@ function areLineBreaksRequired(node, options, first, last) { module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "enforce consistent line breaks inside braces", diff --git a/lib/rules/object-curly-spacing.js b/lib/rules/object-curly-spacing.js index 712fbf3cd79..bde4f14253e 100644 --- a/lib/rules/object-curly-spacing.js +++ b/lib/rules/object-curly-spacing.js @@ -12,7 +12,7 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "enforce consistent spacing inside braces", diff --git a/lib/rules/object-property-newline.js b/lib/rules/object-property-newline.js index 4c037c4b6cd..3e2c0171577 100644 --- a/lib/rules/object-property-newline.js +++ b/lib/rules/object-property-newline.js @@ -11,7 +11,7 @@ module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "enforce placing object properties on separate lines", diff --git a/lib/rules/one-var-declaration-per-line.js b/lib/rules/one-var-declaration-per-line.js index f174508a69f..e7e40d66c0c 100644 --- a/lib/rules/one-var-declaration-per-line.js +++ b/lib/rules/one-var-declaration-per-line.js @@ -10,7 +10,7 @@ module.exports = { meta: { - type: "style", + type: "suggestion", docs: { description: "require or disallow newlines around variable declarations", diff --git a/lib/rules/one-var.js b/lib/rules/one-var.js index fb0d5878dcc..44f05fb700a 100644 --- a/lib/rules/one-var.js +++ b/lib/rules/one-var.js @@ -11,7 +11,7 @@ module.exports = { meta: { - type: "style", + type: "suggestion", docs: { description: "enforce variables to be declared either together or separately in functions", diff --git a/lib/rules/operator-assignment.js b/lib/rules/operator-assignment.js index 7e1d0803f3d..8bb01737dd6 100644 --- a/lib/rules/operator-assignment.js +++ b/lib/rules/operator-assignment.js @@ -89,7 +89,7 @@ function canBeFixed(node) { module.exports = { meta: { - type: "style", + type: "suggestion", docs: { description: "require or disallow assignment operator shorthand where possible", diff --git a/lib/rules/operator-linebreak.js b/lib/rules/operator-linebreak.js index 158855dbb93..cd6e996b1b1 100644 --- a/lib/rules/operator-linebreak.js +++ b/lib/rules/operator-linebreak.js @@ -17,7 +17,7 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "enforce consistent linebreak style for operators", diff --git a/lib/rules/padded-blocks.js b/lib/rules/padded-blocks.js index b308983d0e4..7c0b56ba7f8 100644 --- a/lib/rules/padded-blocks.js +++ b/lib/rules/padded-blocks.js @@ -11,7 +11,7 @@ module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "require or disallow padding within blocks", diff --git a/lib/rules/padding-line-between-statements.js b/lib/rules/padding-line-between-statements.js index 7e020510c38..3e55a2516d0 100644 --- a/lib/rules/padding-line-between-statements.js +++ b/lib/rules/padding-line-between-statements.js @@ -400,7 +400,7 @@ const StatementTypes = { module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "require or disallow padding lines between statements", diff --git a/lib/rules/quote-props.js b/lib/rules/quote-props.js index ec3f753ec62..7184bd34d35 100644 --- a/lib/rules/quote-props.js +++ b/lib/rules/quote-props.js @@ -17,7 +17,7 @@ const espree = require("espree"), module.exports = { meta: { - type: "style", + type: "suggestion", docs: { description: "require quotes around object literal property names", diff --git a/lib/rules/quotes.js b/lib/rules/quotes.js index 248ed90d089..e0db17fcb7c 100644 --- a/lib/rules/quotes.js +++ b/lib/rules/quotes.js @@ -76,7 +76,7 @@ const AVOID_ESCAPE = "avoid-escape"; module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "enforce the consistent use of either backticks, double, or single quotes", diff --git a/lib/rules/require-jsdoc.js b/lib/rules/require-jsdoc.js index c0f5a3d5891..949314993b6 100644 --- a/lib/rules/require-jsdoc.js +++ b/lib/rules/require-jsdoc.js @@ -6,7 +6,7 @@ module.exports = { meta: { - type: "style", + type: "suggestion", docs: { description: "require JSDoc comments", diff --git a/lib/rules/rest-spread-spacing.js b/lib/rules/rest-spread-spacing.js index efe19c9835b..04539395ef4 100644 --- a/lib/rules/rest-spread-spacing.js +++ b/lib/rules/rest-spread-spacing.js @@ -11,7 +11,7 @@ module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "enforce spacing between rest and spread operators and their expressions", diff --git a/lib/rules/semi-spacing.js b/lib/rules/semi-spacing.js index 41c3eb078ba..56ae687d856 100644 --- a/lib/rules/semi-spacing.js +++ b/lib/rules/semi-spacing.js @@ -13,7 +13,7 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "enforce consistent spacing before and after semicolons", diff --git a/lib/rules/semi-style.js b/lib/rules/semi-style.js index 62bbb05742c..dd76b68f82b 100644 --- a/lib/rules/semi-style.js +++ b/lib/rules/semi-style.js @@ -65,7 +65,7 @@ function isLastChild(node) { module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "enforce location of semicolons", diff --git a/lib/rules/semi.js b/lib/rules/semi.js index 98f68a4b325..e8f4c959d4c 100644 --- a/lib/rules/semi.js +++ b/lib/rules/semi.js @@ -17,7 +17,7 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "require or disallow semicolons instead of ASI", diff --git a/lib/rules/space-before-blocks.js b/lib/rules/space-before-blocks.js index feb60bd5e5b..195c756593e 100644 --- a/lib/rules/space-before-blocks.js +++ b/lib/rules/space-before-blocks.js @@ -13,7 +13,7 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "enforce consistent spacing before blocks", diff --git a/lib/rules/space-before-function-paren.js b/lib/rules/space-before-function-paren.js index ec4053c1ec9..64ba72bf9ea 100644 --- a/lib/rules/space-before-function-paren.js +++ b/lib/rules/space-before-function-paren.js @@ -16,7 +16,7 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "enforce consistent spacing before `function` definition opening parenthesis", diff --git a/lib/rules/space-in-parens.js b/lib/rules/space-in-parens.js index f5175e0d6b6..88f4f0b50e1 100644 --- a/lib/rules/space-in-parens.js +++ b/lib/rules/space-in-parens.js @@ -12,7 +12,7 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "enforce consistent spacing inside parentheses", diff --git a/lib/rules/space-infix-ops.js b/lib/rules/space-infix-ops.js index dcad686661d..45b76795eae 100644 --- a/lib/rules/space-infix-ops.js +++ b/lib/rules/space-infix-ops.js @@ -10,7 +10,7 @@ module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "require spacing around infix operators", diff --git a/lib/rules/space-unary-ops.js b/lib/rules/space-unary-ops.js index 5b3a0ef0167..b56fa4f2fac 100644 --- a/lib/rules/space-unary-ops.js +++ b/lib/rules/space-unary-ops.js @@ -16,7 +16,7 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "enforce consistent spacing before or after unary operators", diff --git a/lib/rules/spaced-comment.js b/lib/rules/spaced-comment.js index 4908094e32c..d4c86d27cf8 100644 --- a/lib/rules/spaced-comment.js +++ b/lib/rules/spaced-comment.js @@ -151,7 +151,7 @@ function createNeverStylePattern(markers) { module.exports = { meta: { - type: "style", + type: "suggestion", docs: { description: "enforce consistent spacing after the `//` or `/*` in a comment", diff --git a/lib/rules/switch-colon-spacing.js b/lib/rules/switch-colon-spacing.js index f79c08c2b50..e94b3292106 100644 --- a/lib/rules/switch-colon-spacing.js +++ b/lib/rules/switch-colon-spacing.js @@ -17,7 +17,7 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "enforce spacing around colons of switch statements", diff --git a/lib/rules/template-curly-spacing.js b/lib/rules/template-curly-spacing.js index f3899b4c89b..ea801cbe5d2 100644 --- a/lib/rules/template-curly-spacing.js +++ b/lib/rules/template-curly-spacing.js @@ -24,7 +24,7 @@ const CLOSE_PAREN = /^\}/; module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "require or disallow spacing around embedded expressions of template strings", diff --git a/lib/rules/template-tag-spacing.js b/lib/rules/template-tag-spacing.js index 0d5b23c8682..f258cde3d88 100644 --- a/lib/rules/template-tag-spacing.js +++ b/lib/rules/template-tag-spacing.js @@ -11,7 +11,7 @@ module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "require or disallow spacing between template tags and their literals", diff --git a/lib/rules/unicode-bom.js b/lib/rules/unicode-bom.js index 4c9a68b173a..20f48e22b3c 100644 --- a/lib/rules/unicode-bom.js +++ b/lib/rules/unicode-bom.js @@ -10,7 +10,7 @@ module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "require or disallow Unicode byte order mark (BOM)", diff --git a/lib/rules/valid-jsdoc.js b/lib/rules/valid-jsdoc.js index a8407369873..c7b96af5c05 100644 --- a/lib/rules/valid-jsdoc.js +++ b/lib/rules/valid-jsdoc.js @@ -16,7 +16,7 @@ const doctrine = require("doctrine"); module.exports = { meta: { - type: "style", + type: "problem", docs: { description: "enforce valid JSDoc comments", diff --git a/lib/rules/wrap-iife.js b/lib/rules/wrap-iife.js index c31ade1801d..ce272235b4f 100644 --- a/lib/rules/wrap-iife.js +++ b/lib/rules/wrap-iife.js @@ -17,7 +17,7 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { - type: "suggestion", + type: "layout", docs: { description: "require parentheses around immediate `function` invocations", diff --git a/lib/rules/wrap-regex.js b/lib/rules/wrap-regex.js index 110f944cf53..4ecbcecbbeb 100644 --- a/lib/rules/wrap-regex.js +++ b/lib/rules/wrap-regex.js @@ -11,7 +11,7 @@ module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "require parenthesis around regex literals", diff --git a/lib/rules/yield-star-spacing.js b/lib/rules/yield-star-spacing.js index 65e737cb860..e7712a51dbf 100644 --- a/lib/rules/yield-star-spacing.js +++ b/lib/rules/yield-star-spacing.js @@ -11,7 +11,7 @@ module.exports = { meta: { - type: "style", + type: "layout", docs: { description: "require or disallow spacing around the `*` in `yield*` expressions", diff --git a/tests/lib/cli-engine.js b/tests/lib/cli-engine.js index 7099e391092..942994d6822 100644 --- a/tests/lib/cli-engine.js +++ b/tests/lib/cli-engine.js @@ -340,17 +340,17 @@ describe("CLIEngine", () => { cwd: path.join(fixtureDir, ".."), useEslintrc: false, fix: true, - fixTypes: ["styl"] + fixTypes: ["layou"] }); }, /invalid fix type/i); }); - it("should not fix non-style rules when fixTypes has only 'style'", () => { + it("should not fix non-style rules when fixTypes has only 'layout'", () => { engine = new CLIEngine({ cwd: path.join(fixtureDir, ".."), useEslintrc: false, fix: true, - fixTypes: ["style"] + fixTypes: ["layout"] }); const inputPath = getFixturePath("fix-types/fix-only-semi.js"); const outputPath = getFixturePath("fix-types/fix-only-semi.expected.js"); @@ -375,12 +375,12 @@ describe("CLIEngine", () => { assert.strictEqual(report.results[0].output, expectedOutput); }); - it("should fix both style and problem rules when fixTypes has 'suggestion' and 'style'", () => { + it("should fix both style and problem rules when fixTypes has 'suggestion' and 'layout'", () => { engine = new CLIEngine({ cwd: path.join(fixtureDir, ".."), useEslintrc: false, fix: true, - fixTypes: ["suggestion", "style"] + fixTypes: ["suggestion", "layout"] }); const inputPath = getFixturePath("fix-types/fix-both-semi-and-prefer-arrow-callback.js"); const outputPath = getFixturePath("fix-types/fix-both-semi-and-prefer-arrow-callback.expected.js"); @@ -395,7 +395,7 @@ describe("CLIEngine", () => { cwd: path.join(fixtureDir, ".."), useEslintrc: false, fix: true, - fixTypes: ["style"], + fixTypes: ["layout"], rulePaths: [getFixturePath("rules", "fix-types-test")] }); @@ -412,7 +412,7 @@ describe("CLIEngine", () => { cwd: path.join(fixtureDir, ".."), useEslintrc: false, fix: true, - fixTypes: ["style"] + fixTypes: ["layout"] }); engine.linter.defineRule("no-program", require(getFixturePath("rules", "fix-types-test", "no-program.js"))); @@ -430,7 +430,7 @@ describe("CLIEngine", () => { cwd: path.join(fixtureDir, ".."), useEslintrc: false, fix: true, - fixTypes: ["style"] + fixTypes: ["layout"] }); engine.linter.defineRule("no-program", require(getFixturePath("rules", "fix-types-test", "no-program.js"))); diff --git a/tools/rule-types.json b/tools/rule-types.json index 212d32fc289..17739c94046 100644 --- a/tools/rule-types.json +++ b/tools/rule-types.json @@ -1,75 +1,75 @@ { "accessor-pairs": "suggestion", - "array-bracket-newline": "style", - "array-bracket-spacing": "style", + "array-bracket-newline": "layout", + "array-bracket-spacing": "layout", "array-callback-return": "suggestion", - "array-element-newline": "style", + "array-element-newline": "layout", "arrow-body-style": "suggestion", - "arrow-parens": "style", - "arrow-spacing": "style", + "arrow-parens": "layout", + "arrow-spacing": "layout", "block-scoped-var": "suggestion", - "block-spacing": "style", - "brace-style": "style", + "block-spacing": "layout", + "brace-style": "layout", "callback-return": "suggestion", "camelcase": "suggestion", "capitalized-comments": "suggestion", "class-methods-use-this": "suggestion", - "comma-dangle": "style", - "comma-spacing": "style", - "comma-style": "style", + "comma-dangle": "layout", + "comma-spacing": "layout", + "comma-style": "layout", "complexity": "suggestion", - "computed-property-spacing": "style", + "computed-property-spacing": "layout", "consistent-return": "suggestion", "consistent-this": "suggestion", "constructor-super": "suggestion", "curly": "suggestion", "default-case": "suggestion", - "dot-location": "style", + "dot-location": "layout", "dot-notation": "suggestion", - "eol-last": "style", + "eol-last": "layout", "eqeqeq": "suggestion", "for-direction": "problem", - "func-call-spacing": "style", - "func-name-matching": "style", - "func-names": "style", + "func-call-spacing": "layout", + "func-name-matching": "suggestion", + "func-names": "suggestion", "func-style": "suggestion", - "function-paren-newline": "style", - "generator-star-spacing": "style", + "function-paren-newline": "layout", + "generator-star-spacing": "layout", "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", + "id-blacklist": "suggestion", + "id-length": "suggestion", + "id-match": "suggestion", + "implicit-arrow-linebreak": "layout", + "indent": "layout", + "indent-legacy": "layout", "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", + "jsx-quotes": "layout", + "key-spacing": "layout", + "keyword-spacing": "layout", + "line-comment-position": "layout", + "linebreak-style": "layout", + "lines-around-comment": "layout", + "lines-around-directive": "layout", + "lines-between-class-members": "layout", "max-classes-per-file": "suggestion", "max-depth": "suggestion", - "max-len": "style", + "max-len": "layout", "max-lines": "suggestion", "max-lines-per-function": "suggestion", "max-nested-callbacks": "suggestion", "max-params": "suggestion", "max-statements": "suggestion", - "max-statements-per-line": "style", + "max-statements-per-line": "layout", "multiline-comment-style": "suggestion", - "multiline-ternary": "style", - "new-cap": "style", - "new-parens": "style", - "newline-after-var": "style", - "newline-before-return": "style", - "newline-per-chained-call": "style", + "multiline-ternary": "layout", + "new-cap": "suggestion", + "new-parens": "layout", + "newline-after-var": "layout", + "newline-before-return": "layout", + "newline-per-chained-call": "layout", "no-alert": "suggestion", "no-array-constructor": "suggestion", "no-async-promise-executor": "problem", @@ -108,8 +108,8 @@ "no-extra-bind": "suggestion", "no-extra-boolean-cast": "suggestion", "no-extra-label": "suggestion", - "no-extra-parens": "style", - "no-extra-semi": "style", + "no-extra-parens": "layout", + "no-extra-semi": "layout", "no-fallthrough": "problem", "no-floating-decimal": "suggestion", "no-func-assign": "problem", @@ -132,11 +132,11 @@ "no-misleading-character-class": "problem", "no-mixed-operators": "suggestion", "no-mixed-requires": "suggestion", - "no-mixed-spaces-and-tabs": "style", + "no-mixed-spaces-and-tabs": "layout", "no-multi-assign": "suggestion", - "no-multi-spaces": "style", + "no-multi-spaces": "layout", "no-multi-str": "suggestion", - "no-multiple-empty-lines": "style", + "no-multiple-empty-lines": "layout", "no-native-reassign": "suggestion", "no-negated-condition": "suggestion", "no-negated-in-lhs": "problem", @@ -172,15 +172,15 @@ "no-sequences": "suggestion", "no-shadow": "suggestion", "no-shadow-restricted-names": "suggestion", - "no-spaced-func": "style", + "no-spaced-func": "layout", "no-sparse-arrays": "problem", "no-sync": "suggestion", - "no-tabs": "style", + "no-tabs": "layout", "no-template-curly-in-string": "problem", "no-ternary": "suggestion", "no-this-before-super": "problem", "no-throw-literal": "suggestion", - "no-trailing-spaces": "style", + "no-trailing-spaces": "layout", "no-undef": "problem", "no-undef-init": "suggestion", "no-undefined": "suggestion", @@ -205,19 +205,19 @@ "no-var": "suggestion", "no-void": "suggestion", "no-warning-comments": "suggestion", - "no-whitespace-before-property": "style", + "no-whitespace-before-property": "layout", "no-with": "suggestion", - "nonblock-statement-body-position": "style", - "object-curly-newline": "style", - "object-curly-spacing": "style", - "object-property-newline": "style", + "nonblock-statement-body-position": "layout", + "object-curly-newline": "layout", + "object-curly-spacing": "layout", + "object-property-newline": "layout", "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", + "one-var": "suggestion", + "one-var-declaration-per-line": "suggestion", + "operator-assignment": "suggestion", + "operator-linebreak": "layout", + "padded-blocks": "layout", + "padding-line-between-statements": "layout", "prefer-arrow-callback": "suggestion", "prefer-const": "suggestion", "prefer-destructuring": "suggestion", @@ -228,39 +228,39 @@ "prefer-rest-params": "suggestion", "prefer-spread": "suggestion", "prefer-template": "suggestion", - "quote-props": "style", - "quotes": "style", + "quote-props": "suggestion", + "quotes": "layout", "radix": "suggestion", "require-atomic-updates": "problem", "require-await": "suggestion", - "require-jsdoc": "style", + "require-jsdoc": "suggestion", "require-unicode-regexp": "suggestion", "require-yield": "suggestion", - "rest-spread-spacing": "style", - "semi": "style", - "semi-spacing": "style", - "semi-style": "style", + "rest-spread-spacing": "layout", + "semi": "layout", + "semi-spacing": "layout", + "semi-style": "layout", "sort-imports": "suggestion", "sort-keys": "suggestion", "sort-vars": "suggestion", - "space-before-blocks": "style", - "space-before-function-paren": "style", - "space-in-parens": "style", - "space-infix-ops": "style", - "space-unary-ops": "style", - "spaced-comment": "style", + "space-before-blocks": "layout", + "space-before-function-paren": "layout", + "space-in-parens": "layout", + "space-infix-ops": "layout", + "space-unary-ops": "layout", + "spaced-comment": "suggestion", "strict": "suggestion", - "switch-colon-spacing": "style", + "switch-colon-spacing": "layout", "symbol-description": "suggestion", - "template-curly-spacing": "style", - "template-tag-spacing": "style", - "unicode-bom": "style", + "template-curly-spacing": "layout", + "template-tag-spacing": "layout", + "unicode-bom": "layout", "use-isnan": "problem", - "valid-jsdoc": "style", + "valid-jsdoc": "problem", "valid-typeof": "problem", "vars-on-top": "suggestion", - "wrap-iife": "suggestion", - "wrap-regex": "style", - "yield-star-spacing": "style", + "wrap-iife": "layout", + "wrap-regex": "layout", + "yield-star-spacing": "layout", "yoda": "suggestion" } \ No newline at end of file From c5feaadd42fb71cf81d0f363b644c124d4efef5e Mon Sep 17 00:00:00 2001 From: "Nicholas C. Zakas" Date: Mon, 29 Oct 2018 09:55:36 -0700 Subject: [PATCH 19/25] Fix update-rule-types script and prefer-arrow-callback --- lib/rules/prefer-arrow-callback.js | 2 +- tools/update-rule-types.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/rules/prefer-arrow-callback.js b/lib/rules/prefer-arrow-callback.js index 32ac8fb9eb7..b4bbf33f296 100644 --- a/lib/rules/prefer-arrow-callback.js +++ b/lib/rules/prefer-arrow-callback.js @@ -179,7 +179,7 @@ module.exports = { * @returns {void} */ function enterScope() { - stack.push(); + stack.push({ this: false, super: false, meta: false }); } /** diff --git a/tools/update-rule-types.js b/tools/update-rule-types.js index 3a20092a4eb..527cf2288e6 100644 --- a/tools/update-rule-types.js +++ b/tools/update-rule-types.js @@ -27,7 +27,7 @@ module.exports = (fileInfo, api) => { // if there's no properties, just exit if (!metaNode.value.properties) { - return null; + return p.node; } const typeNode = metaNode.value.properties.find(node => node.key.name === "type"); From 4873de42f98804c8095a7786dc39cdcbc02a7887 Mon Sep 17 00:00:00 2001 From: "Nicholas C. Zakas" Date: Mon, 29 Oct 2018 10:17:22 -0700 Subject: [PATCH 20/25] Fix lint error --- tests/lib/cli.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/lib/cli.js b/tests/lib/cli.js index 1cc482f1c58..50d80c38472 100644 --- a/tests/lib/cli.js +++ b/tests/lib/cli.js @@ -927,7 +927,7 @@ describe("cli", () => { assert.strictEqual(exitCode, 0); }); - + it("should not rewrite files when in fix-dry-run mode", () => { const report = { From c86671749b89ba31f0d6ca6d7d59025ce9f75a0f Mon Sep 17 00:00:00 2001 From: "Nicholas C. Zakas" Date: Fri, 2 Nov 2018 10:13:45 -0700 Subject: [PATCH 21/25] Update rule types based on latest feedback --- lib/rules/array-callback-return.js | 2 +- lib/rules/constructor-super.js | 2 +- lib/rules/no-class-assign.js | 2 +- lib/rules/no-const-assign.js | 2 +- lib/rules/no-empty-pattern.js | 2 +- lib/rules/no-extra-semi.js | 2 +- lib/rules/no-new-symbol.js | 2 +- lib/rules/no-self-assign.js | 2 +- lib/rules/no-self-compare.js | 2 +- lib/rules/no-unmodified-loop-condition.js | 2 +- tools/rule-types.json | 20 ++++++++++---------- 11 files changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/rules/array-callback-return.js b/lib/rules/array-callback-return.js index 70ff7f0a7ae..bfee39b037b 100644 --- a/lib/rules/array-callback-return.js +++ b/lib/rules/array-callback-return.js @@ -141,7 +141,7 @@ function isCallbackOfArrayMethod(node) { module.exports = { meta: { - type: "suggestion", + type: "problem", docs: { description: "enforce `return` statements in callbacks of array methods", diff --git a/lib/rules/constructor-super.js b/lib/rules/constructor-super.js index c9fe8cec884..e4cdb099b3b 100644 --- a/lib/rules/constructor-super.js +++ b/lib/rules/constructor-super.js @@ -92,7 +92,7 @@ function isPossibleConstructor(node) { module.exports = { meta: { - type: "suggestion", + type: "problem", docs: { description: "require `super()` calls in constructors", diff --git a/lib/rules/no-class-assign.js b/lib/rules/no-class-assign.js index 60f36eafc3c..7bc65df1ba6 100644 --- a/lib/rules/no-class-assign.js +++ b/lib/rules/no-class-assign.js @@ -13,7 +13,7 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { - type: "suggestion", + type: "problem", docs: { description: "disallow reassigning class members", diff --git a/lib/rules/no-const-assign.js b/lib/rules/no-const-assign.js index 7b18f319a06..32f8154cc23 100644 --- a/lib/rules/no-const-assign.js +++ b/lib/rules/no-const-assign.js @@ -13,7 +13,7 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { - type: "suggestion", + type: "problem", docs: { description: "disallow reassigning `const` variables", diff --git a/lib/rules/no-empty-pattern.js b/lib/rules/no-empty-pattern.js index cef3887ee60..9f34bfde92e 100644 --- a/lib/rules/no-empty-pattern.js +++ b/lib/rules/no-empty-pattern.js @@ -10,7 +10,7 @@ module.exports = { meta: { - type: "suggestion", + type: "problem", docs: { description: "disallow empty destructuring patterns", diff --git a/lib/rules/no-extra-semi.js b/lib/rules/no-extra-semi.js index 1893e57ef3a..d87a181672f 100644 --- a/lib/rules/no-extra-semi.js +++ b/lib/rules/no-extra-semi.js @@ -18,7 +18,7 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { - type: "layout", + type: "suggestion", docs: { description: "disallow unnecessary semicolons", diff --git a/lib/rules/no-new-symbol.js b/lib/rules/no-new-symbol.js index fa61e2c539b..ccf757ed6a0 100644 --- a/lib/rules/no-new-symbol.js +++ b/lib/rules/no-new-symbol.js @@ -11,7 +11,7 @@ module.exports = { meta: { - type: "suggestion", + type: "problem", docs: { description: "disallow `new` operators with the `Symbol` object", diff --git a/lib/rules/no-self-assign.js b/lib/rules/no-self-assign.js index fac05aa3f7e..d493855efe9 100644 --- a/lib/rules/no-self-assign.js +++ b/lib/rules/no-self-assign.js @@ -165,7 +165,7 @@ function eachSelfAssignment(left, right, props, report) { module.exports = { meta: { - type: "suggestion", + type: "problem", docs: { description: "disallow assignments where both sides are exactly the same", diff --git a/lib/rules/no-self-compare.js b/lib/rules/no-self-compare.js index 5dbd1f4466e..8986240ec5c 100644 --- a/lib/rules/no-self-compare.js +++ b/lib/rules/no-self-compare.js @@ -12,7 +12,7 @@ module.exports = { meta: { - type: "suggestion", + type: "problem", docs: { description: "disallow comparisons where both sides are exactly the same", diff --git a/lib/rules/no-unmodified-loop-condition.js b/lib/rules/no-unmodified-loop-condition.js index 2fed7f03106..95898c5f19d 100644 --- a/lib/rules/no-unmodified-loop-condition.js +++ b/lib/rules/no-unmodified-loop-condition.js @@ -165,7 +165,7 @@ function updateModifiedFlag(conditions, modifiers) { module.exports = { meta: { - type: "suggestion", + type: "problem", docs: { description: "disallow unmodified loop conditions", diff --git a/tools/rule-types.json b/tools/rule-types.json index 17739c94046..5320ad7f7bc 100644 --- a/tools/rule-types.json +++ b/tools/rule-types.json @@ -2,7 +2,7 @@ "accessor-pairs": "suggestion", "array-bracket-newline": "layout", "array-bracket-spacing": "layout", - "array-callback-return": "suggestion", + "array-callback-return": "problem", "array-element-newline": "layout", "arrow-body-style": "suggestion", "arrow-parens": "layout", @@ -21,7 +21,7 @@ "computed-property-spacing": "layout", "consistent-return": "suggestion", "consistent-this": "suggestion", - "constructor-super": "suggestion", + "constructor-super": "problem", "curly": "suggestion", "default-case": "suggestion", "dot-location": "layout", @@ -79,12 +79,12 @@ "no-caller": "suggestion", "no-case-declarations": "suggestion", "no-catch-shadow": "suggestion", - "no-class-assign": "suggestion", + "no-class-assign": "problem", "no-compare-neg-zero": "problem", "no-cond-assign": "problem", "no-confusing-arrow": "suggestion", "no-console": "suggestion", - "no-const-assign": "suggestion", + "no-const-assign": "problem", "no-constant-condition": "problem", "no-continue": "suggestion", "no-control-regex": "problem", @@ -100,7 +100,7 @@ "no-empty": "suggestion", "no-empty-character-class": "problem", "no-empty-function": "suggestion", - "no-empty-pattern": "suggestion", + "no-empty-pattern": "problem", "no-eq-null": "suggestion", "no-eval": "suggestion", "no-ex-assign": "problem", @@ -109,7 +109,7 @@ "no-extra-boolean-cast": "suggestion", "no-extra-label": "suggestion", "no-extra-parens": "layout", - "no-extra-semi": "layout", + "no-extra-semi": "suggestion", "no-fallthrough": "problem", "no-floating-decimal": "suggestion", "no-func-assign": "problem", @@ -145,7 +145,7 @@ "no-new-func": "suggestion", "no-new-object": "suggestion", "no-new-require": "suggestion", - "no-new-symbol": "suggestion", + "no-new-symbol": "problem", "no-new-wrappers": "suggestion", "no-obj-calls": "problem", "no-octal": "suggestion", @@ -167,8 +167,8 @@ "no-return-assign": "suggestion", "no-return-await": "suggestion", "no-script-url": "suggestion", - "no-self-assign": "suggestion", - "no-self-compare": "suggestion", + "no-self-assign": "problem", + "no-self-compare": "problem", "no-sequences": "suggestion", "no-shadow": "suggestion", "no-shadow-restricted-names": "suggestion", @@ -186,7 +186,7 @@ "no-undefined": "suggestion", "no-underscore-dangle": "suggestion", "no-unexpected-multiline": "problem", - "no-unmodified-loop-condition": "suggestion", + "no-unmodified-loop-condition": "problem", "no-unneeded-ternary": "suggestion", "no-unreachable": "problem", "no-unsafe-finally": "problem", From 6ce2222e347fa9f32b63160abb76b833c6aa4891 Mon Sep 17 00:00:00 2001 From: "Nicholas C. Zakas" Date: Fri, 2 Nov 2018 10:20:06 -0700 Subject: [PATCH 22/25] Fix bug CLIEngine --- lib/cli-engine.js | 2 +- tests/lib/cli-engine.js | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/cli-engine.js b/lib/cli-engine.js index 6fd3f0c1de9..c2b380b429f 100644 --- a/lib/cli-engine.js +++ b/lib/cli-engine.js @@ -473,7 +473,7 @@ class CLIEngine { } // setup special filter for fixes - if (this.options.fixTypes && this.options.fixTypes.length > 0) { + if (this.options.fix && this.options.fixTypes && this.options.fixTypes.length > 0) { // throw an error if any invalid fix types are found validateFixTypes(this.options.fixTypes); diff --git a/tests/lib/cli-engine.js b/tests/lib/cli-engine.js index 942994d6822..d5b0b3728aa 100644 --- a/tests/lib/cli-engine.js +++ b/tests/lib/cli-engine.js @@ -345,6 +345,20 @@ describe("CLIEngine", () => { }, /invalid fix type/i); }); + it("should not fix any rules when fixTypes is used without fix", () => { + engine = new CLIEngine({ + cwd: path.join(fixtureDir, ".."), + useEslintrc: false, + fix: false, + fixTypes: ["layout"] + }); + + const inputPath = getFixturePath("fix-types/fix-only-semi.js"); + const report = engine.executeOnFiles([inputPath]); + + assert.isUndefined(report.results[0].output); + }); + it("should not fix non-style rules when fixTypes has only 'layout'", () => { engine = new CLIEngine({ cwd: path.join(fixtureDir, ".."), From 1b546cf8cfb19acd5f513a64be9c8e6635896dff Mon Sep 17 00:00:00 2001 From: "Nicholas C. Zakas" Date: Mon, 5 Nov 2018 08:44:54 -0800 Subject: [PATCH 23/25] Update new rule issue template with category info --- .github/ISSUE_TEMPLATE/NEW_RULE.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/NEW_RULE.md b/.github/ISSUE_TEMPLATE/NEW_RULE.md index 8dfb93ba281..5a50001b0e6 100644 --- a/.github/ISSUE_TEMPLATE/NEW_RULE.md +++ b/.github/ISSUE_TEMPLATE/NEW_RULE.md @@ -21,9 +21,9 @@ about: Propose a new rule to be added to ESLint **What category of rule is this? (place an "X" next to just one item)** -[ ] Enforces code style -[ ] Warns about a potential error -[ ] Suggests an alternate way of doing something +[ ] Warns about a potential error (problem) +[ ] Suggests an alternate way of doing something (suggestion) +[ ] Enforces code style (layout) [ ] Other (please specify:) **Provide 2-3 code examples that this rule will warn about:** From 7e80da5ac8c9c1bd50ec5516a359c55ac6e671d7 Mon Sep 17 00:00:00 2001 From: "Nicholas C. Zakas" Date: Mon, 5 Nov 2018 08:45:33 -0800 Subject: [PATCH 24/25] Final update of rule types --- lib/rules/no-buffer-constructor.js | 2 +- lib/rules/no-use-before-define.js | 2 +- lib/rules/valid-jsdoc.js | 2 +- tools/rule-types.json | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/rules/no-buffer-constructor.js b/lib/rules/no-buffer-constructor.js index a1f2a1d1ad7..bf4c8891ad1 100644 --- a/lib/rules/no-buffer-constructor.js +++ b/lib/rules/no-buffer-constructor.js @@ -10,7 +10,7 @@ module.exports = { meta: { - type: "suggestion", + type: "problem", docs: { description: "disallow use of the `Buffer()` constructor", diff --git a/lib/rules/no-use-before-define.js b/lib/rules/no-use-before-define.js index 6f0b66bdb52..500cd3a4103 100644 --- a/lib/rules/no-use-before-define.js +++ b/lib/rules/no-use-before-define.js @@ -136,7 +136,7 @@ function isInInitializer(variable, reference) { module.exports = { meta: { - type: "suggestion", + type: "problem", docs: { description: "disallow the use of variables before they are defined", diff --git a/lib/rules/valid-jsdoc.js b/lib/rules/valid-jsdoc.js index c7b96af5c05..b434491bfad 100644 --- a/lib/rules/valid-jsdoc.js +++ b/lib/rules/valid-jsdoc.js @@ -16,7 +16,7 @@ const doctrine = require("doctrine"); module.exports = { meta: { - type: "problem", + type: "suggestion", docs: { description: "enforce valid JSDoc comments", diff --git a/tools/rule-types.json b/tools/rule-types.json index 5320ad7f7bc..40010c8969d 100644 --- a/tools/rule-types.json +++ b/tools/rule-types.json @@ -75,7 +75,7 @@ "no-async-promise-executor": "problem", "no-await-in-loop": "problem", "no-bitwise": "suggestion", - "no-buffer-constructor": "suggestion", + "no-buffer-constructor": "problem", "no-caller": "suggestion", "no-case-declarations": "suggestion", "no-catch-shadow": "suggestion", @@ -194,7 +194,7 @@ "no-unused-expressions": "suggestion", "no-unused-labels": "suggestion", "no-unused-vars": "problem", - "no-use-before-define": "suggestion", + "no-use-before-define": "problem", "no-useless-call": "suggestion", "no-useless-computed-key": "suggestion", "no-useless-concat": "suggestion", @@ -256,7 +256,7 @@ "template-tag-spacing": "layout", "unicode-bom": "layout", "use-isnan": "problem", - "valid-jsdoc": "problem", + "valid-jsdoc": "suggestion", "valid-typeof": "problem", "vars-on-top": "suggestion", "wrap-iife": "layout", From 5e1c448203a63ea4d2e3b4ea2a09f31cbc68b754 Mon Sep 17 00:00:00 2001 From: "Nicholas C. Zakas" Date: Mon, 5 Nov 2018 09:01:13 -0800 Subject: [PATCH 25/25] Refactor CLIEngine piece based on feedback --- lib/cli-engine.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/cli-engine.js b/lib/cli-engine.js index c2b380b429f..652d68b59b4 100644 --- a/lib/cli-engine.js +++ b/lib/cli-engine.js @@ -475,6 +475,8 @@ class CLIEngine { // setup special filter for fixes if (this.options.fix && this.options.fixTypes && this.options.fixTypes.length > 0) { + debug(`Using fix types ${this.options.fixTypes}`); + // throw an error if any invalid fix types are found validateFixTypes(this.options.fixTypes); @@ -482,7 +484,8 @@ class CLIEngine { const fixTypes = new Set(this.options.fixTypes); // save original value of options.fix in case it's a function - const originalFix = this.options.fix; + const originalFix = (typeof this.options.fix === "function") + ? this.options.fix : () => this.options.fix; // create a cache of rules (but don't populate until needed) this._rulesCache = null; @@ -491,7 +494,7 @@ class CLIEngine { const rule = this._rulesCache.get(lintResult.ruleId); const matches = rule.meta && fixTypes.has(rule.meta.type); - return matches && (typeof originalFix === "function" ? originalFix(lintResult) : true); + return matches && originalFix(lintResult); }; }