eslint / eslint

Find and fix problems in your JavaScript code.
https://eslint.org
MIT License
24.83k stars 4.49k forks source link

Bug: Configuration for rule "id-match" is invalid #16771

Closed heohex closed 1 year ago

heohex commented 1 year ago

Environment

Node version: v14.19.0 npm version: 8.19.2 Local ESLint version: 7.32.0 Global ESLint version: - Operating System: Windows 10

What parser are you using?

Default (Espree)

What did you do?

Configuration ``` { "env": { "es2020": true, "browser": true, "node": true, "jquery": true }, "extends": [ "eslint:recommended", ".\/.goja.json", ".\/.webapp.json" ], "plugins": [ ], "rules": { "id-match": [ "error", "^[^а-яА-ЯёЁ]+$", { "properties": true, "classFields": true } ], "indent": [ "warn", 4, { "ignoreComments": true } ], "linebreak-style": [ "warn", "unix" ], "key-spacing": [ "off", { "align": "value" } ], "quotes": [ "off", "double" ], "semi": [ "off", "always" ], "no-mixed-spaces-and-tabs": [ "off", "smart-tabs" ], "no-redeclare": [ "off", "always" ], "no-unused-vars": [ "warn", { "vars": "local", "args": "none", "caughtErrors": "none" } ], "no-empty": [ "off" ], "no-useless-escape": [ "off" ], "no-undef": [ "warn" ], "no-extra-semi": [ "off" ], "no-console": [ "off" ], "no-extra-boolean-cast": [ "off" ], "no-control-regex": [ "off" ], "no-cond-assign": [ "off" ], "no-constant-condition": [ "off" ], "no-delete-var": [ "off" ], "no-fallthrough": [ "off" ], "no-unused-labels": [ "warn" ], "no-unreachable": [ "warn" ], "no-dupe-keys": [ "warn" ], "no-unsafe-negation": [ "warn" ], "no-func-assign": [ "warn" ], "valid-typeof": [ "warn" ], "no-self-compare": "error", "no-self-assign": [ "warn" ], "no-use-before-define": [ "warn", { "functions": false, "classes": false, "variables": false } ], "no-prototype-builtins": [ "off" ] } } ```
"id-match": [
    "error",
    "^[^а-яА-ЯёЁ]+$",
    {
        "properties": true,
        "classFields": true
    }
]

What did you expect to happen?

Both rules(properties, classFields) in id-match work correctly. If i remove classFields - no errors

What actually happened?

Got error in webstorm

Error: .eslintrc.json: Configuration for rule "id-match" is invalid: Value {"properties":true,"classFields":true,"onlyDeclarations":false,"ignoreDestructuring":false} should NOT have additional properties.

Error: .eslintrc.json: Configuration for rule "id-match" is invalid: Value {"properties":true,"classFields":true,"onlyDeclarations":false,"ignoreDestructuring":false} should NOT have additional properties.

at ConfigValidator.validateRuleOptions (D:\projects\webapp\node_modules\@eslint\eslintrc\lib\shared\config-validator.js:144:23)
at D:\projects\webapp\node_modules\@eslint\eslintrc\lib\shared\config-validator.js:199:18
at Array.forEach (<anonymous>)
at ConfigValidator.validateRules (D:\projects\webapp\node_modules\@eslint\eslintrc\lib\shared\config-validator.js:196:34)
at ConfigValidator.validateConfigArray (D:\projects\webapp\node_modules\@eslint\eslintrc\lib\shared\config-validator.js:322:18)
at CascadingConfigArrayFactory._finalizeConfigArray (D:\projects\webapp\node_modules\@eslint\eslintrc\lib\cascading-config-array-factory.js:493:23)
at CascadingConfigArrayFactory.getConfigArrayForFile (D:\projects\webapp\node_modules\@eslint\eslintrc\lib\cascading-config-array-factory.js:299:21)
at CLIEngine.isPathIgnored (D:\projects\webapp\node_modules\eslint\lib\cli-engine\cli-engine.js:973:18)
at ESLintPlugin.invokeESLint (C:\Users\%USER%\AppData\Local\JetBrains\Toolbox\apps\WebStorm\ch-0\223.8214.51\plugins\javascript-impl\languageService\eslint\bin\eslint-plugin.js:89:23)
at ESLintPlugin.getErrors (C:\Users\%USER%\AppData\Local\JetBrains\Toolbox\apps\WebStorm\ch-0\223.8214.51\plugins\javascript-impl\languageService\eslint\bin\eslint-plugin.js:67:21)

Participation

Additional comments

Test id-match with properties and classFields with:

  1. eslint 5.16.0 - fine ✔️
  2. eslint 6.8.0 - fine ✔️
  3. eslint 7.32.0 - broken❌
  4. eslint 8.31.0 - fine ✔️
mdjermanovic commented 1 year ago

Hi @heohex, thanks for the issue!

  • eslint 5.16.0 - fine ✔️
  • eslint 6.8.0 - fine ✔️
  • eslint 7.32.0 - broken❌
  • eslint 8.31.0 - fine ✔️

The classFields option was added in v8.0.0, so it is expected behavior that v7.32.0 throws a configuration error because this option did not exist in v7.32.0. To use this option, you'll need ESLint >= 8.0.0.

Before v7, config schema for this rule was incomplete - it used to allow configuring unknown options but they had no effect.

heohex commented 1 year ago

Hi @mdjermanovic, thanks for the reply. Unfortunately, I could not find information about this in the documentation :( Closed.