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

[no-unused-vars] implement destructuredArrayIgnorePattern from eslint 8.11 #4691

Closed
3 tasks done
neryams opened this issue Mar 16, 2022 · 3 comments · Fixed by #4748
Closed
3 tasks done

[no-unused-vars] implement destructuredArrayIgnorePattern from eslint 8.11 #4691

neryams opened this issue Mar 16, 2022 · 3 comments · Fixed by #4748
Labels
accepting prs Go ahead, send a pull request that resolves this issue enhancement: plugin rule option New rule option for an existing eslint-plugin rule package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@neryams
Copy link

neryams commented Mar 16, 2022

eslint added a super useful option to the no-unused-vars rule in version 8.11.0, destructuredArrayIgnorePattern.

https://eslint.org/docs/rules/no-unused-vars#destructuredarrayignorepattern

Trying to use this option with typescript-eslint causes eslint to fail because the option is not found.

Here is the PR on the eslint repository related to this feature: eslint/eslint#15649 (there's already discussion on that page about the option not working with this package)

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have read the FAQ and my problem is not listed.

Repro

use the rule

{
  "rules": {
    "@typescript-eslint/no-unused-vars": ["error", { "destructuredArrayIgnorePattern": "^_" }]
  }
}

with @typescript-eslint/eslint-plugin active. eslint will fail.

Expected Result

eslint should be able to use the destructuredArrayIgnorePattern with @typescript-eslint/eslint-plugin active

Actual Result

eslint fails with the error:

Oops! Something went wrong! :(

ESLint: 8.11.0

Error: Client\.eslintrc.json:
        Configuration for rule "@typescript-eslint/no-unused-vars" is invalid:
        Value {"destructuredArrayIgnorePattern":"^_"} should be equal to one of the allowed values.
        Value {"destructuredArrayIgnorePattern":"^_"} should NOT have additional properties.
        Value {"destructuredArrayIgnorePattern":"^_"} should match exactly one schema in oneOf.

    at ConfigValidator.validateRuleOptions (C:\Repos\kbmax3\KBMax3\KBMax.Fabric.Web\node_modules\@eslint\eslintrc\dist\eslintrc.cjs:2027:23)
    at C:\Repos\kbmax3\KBMax3\KBMax.Fabric.Web\node_modules\@eslint\eslintrc\dist\eslintrc.cjs:2082:18
    at Array.forEach (<anonymous>)
    at ConfigValidator.validateRules (C:\Repos\kbmax3\KBMax3\KBMax.Fabric.Web\node_modules\@eslint\eslintrc\dist\eslintrc.cjs:2079:34)
    at ConfigValidator.validateConfigArray (C:\Repos\kbmax3\KBMax3\KBMax.Fabric.Web\node_modules\@eslint\eslintrc\dist\eslintrc.cjs:2205:18)
    at CascadingConfigArrayFactory._finalizeConfigArray (C:\Repos\kbmax3\KBMax3\KBMax.Fabric.Web\node_modules\@eslint\eslintrc\dist\eslintrc.cjs:3947:23)
    at CascadingConfigArrayFactory.getConfigArrayForFile (C:\Repos\kbmax3\KBMax3\KBMax.Fabric.Web\node_modules\@eslint\eslintrc\dist\eslintrc.cjs:3753:21)
    at FileEnumerator._iterateFilesRecursive (C:\Repos\kbmax3\KBMax3\KBMax.Fabric.Web\node_modules\eslint\lib\cli-engine\file-enumerator.js:446:49)
    at _iterateFilesRecursive.next (<anonymous>)
    at FileEnumerator.iterateFiles (C:\Repos\kbmax3\KBMax3\KBMax.Fabric.Web\node_modules\eslint\lib\cli-engine\file-enumerator.js:297:49)

Versions

package version
@typescript-eslint/eslint-plugin 5.15.0
@typescript-eslint/parser 5.15.0
TypeScript 4.0.3
ESLint 8.11.0
node 16.13.0
@neryams neryams added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for maintainers to take a look labels Mar 16, 2022
@bradzacher bradzacher added enhancement: plugin rule option New rule option for an existing eslint-plugin rule accepting prs Go ahead, send a pull request that resolves this issue and removed triage Waiting for maintainers to take a look labels Mar 16, 2022
@boris-petrov
Copy link

I never understood what is the benefit of using this rule with TypeScript - doesn't the compiler already do that? Are there cases where the rule does a better job than it?

@bradzacher
Copy link
Member

bradzacher commented Mar 29, 2022

Two quick reasons

  • Options. You can configure the rule. You can't configure the TS check.
  • Build. The TS error will block the build with noEmitOnError. An eslint rule will not.

@boris-petrov
Copy link

I see. Thanks for the answer!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepting prs Go ahead, send a pull request that resolves this issue enhancement: plugin rule option New rule option for an existing eslint-plugin rule package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
3 participants