Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Using eslint --config .eslintrc triggers errors that do not occur when omitted #15988

Closed
1 task
PythonCoderAS opened this issue Jun 12, 2022 · 2 comments
Closed
1 task
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly repro:needed
Projects

Comments

@PythonCoderAS
Copy link

PythonCoderAS commented Jun 12, 2022

Environment

Node version: v18.3.0
npm version: v8.11.0
Local ESLint version: v8.17.0 (Currently used)
Global ESLint version: Not found
Operating System: darwin 20.5.0

What parser are you using?

@typescript-eslint/parser

What did you do?

Configuration
{
  "extends": ["pythoncoderas-combo"]
}
{} // Literally *any* code!

What did you expect to happen?

The linting to work

What actually happened?

Oops! Something went wrong! :(

ESLint: 8.17.0

Error: --config » eslint-config-pythoncoderas-combo » eslint-config-pythoncoderas » eslint-config-airbnb-base » /private/tmp/node_modules/eslint-config-airbnb-base/rules/best-practices.js:
        Configuration for rule "dot-notation" is invalid:
        Value {"allowKeywords":true,"allowPattern":"","allowPrivateClassPropertyAccess":false,"allowProtectedClassPropertyAccess":false,"allowIndexSignaturePropertyAccess":false} should NOT have additional properties.

    at ConfigValidator.validateRuleOptions (~/WebstormProjects/github-copy-secrets/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2027:23)
    at ~/WebstormProjects/github-copy-secrets/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2082:18
    at Array.forEach (<anonymous>)
    at ConfigValidator.validateRules (~/WebstormProjects/github-copy-secrets/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2079:34)
    at ConfigValidator.validateConfigArray (~/WebstormProjects/github-copy-secrets/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2205:18)
    at CascadingConfigArrayFactory._finalizeConfigArray (~/WebstormProjects/github-copy-secrets/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3947:23)
    at CascadingConfigArrayFactory.getConfigArrayForFile (~/WebstormProjects/github-copy-secrets/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3753:21)
    at FileEnumerator._iterateFilesRecursive (~/WebstormProjects/github-copy-secrets/node_modules/eslint/lib/cli-engine/file-enumerator.js:446:49)
    at _iterateFilesRecursive.next (<anonymous>)
    at FileEnumerator.iterateFiles (~/WebstormProjects/github-copy-secrets/node_modules/eslint/lib/cli-engine/file-enumerator.js:297:49)

Participation

  • I am willing to submit a pull request for this issue.

Additional comments

When not using --config, everything works correctly. I also did some research and https://github.com/airbnb/javascript/blob/cbf9ade10a2f6f06c9da6dbfa25b344bee4bbef6/packages/eslint-config-airbnb-base/rules/best-practices.js#L46 defines the dot-notation rule. In conjunction with typescript-eslint/typescript-eslint#2047 (comment) this means that there is a weird bug in eslint.

Repro repo: https://github.com/PythonCoderAS/eslint-15988-repro

@PythonCoderAS PythonCoderAS added bug ESLint is working incorrectly repro:needed labels Jun 12, 2022
@eslint-github-bot eslint-github-bot bot added this to Needs Triage in Triage Jun 12, 2022
@nzakas
Copy link
Member

nzakas commented Jun 30, 2022

The way that configs are calculated is fairly complicated, so passing a config on the command line is not the same thing as when ESLint finds a config on its own. This doesn’t necessarily mean that there’s a bug. If you want to explore the details, you can run with the —debug flag.

The current config system is frozen and we aren’t making any further changes to it as we work on switching to a new config system, so closing.

@nzakas nzakas closed this as not planned Won't fix, can't repro, duplicate, stale Jun 30, 2022
Triage automation moved this from Needs Triage to Complete Jun 30, 2022
@mdjermanovic
Copy link
Member

Configuration for rule "dot-notation" is invalid:
Value AllowKeywords":true,"allowPattern":"","allowPrivateClassPropertyAccess":false,"allowProtectedClassPropertyAccess":false,"allowIndexSignaturePropertyAccess":false} should NOT have additional properties.

This is caused by #12592.

eslint-config-airbnb-typescript loads eslint-config-airbnb-base to get its configurations for core rules and use them as configurations for typescript-eslint plugin rules. But it doesn't deep-clone the configurations, so the same objects end up in configurations for multiple rules. During the validation for @typescript-eslint/dot-notation rule, ESLint sets defaults on the same object that is used as configuration for the core dot-notation rule, which then doesn't pass the validation due to unknown properties.

@eslint-github-bot eslint-github-bot bot locked and limited conversation to collaborators Dec 28, 2022
@eslint-github-bot eslint-github-bot bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Dec 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly repro:needed
Projects
Archived in project
Triage
Complete
Development

No branches or pull requests

3 participants