Skip to content

Enhancement: [no-unused-vars] Support for ignoreClassWithStaticInitBlock and reportUsedIgnorePattern Options #9120

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

Closed
4 tasks done
bachmacintosh opened this issue May 19, 2024 · 8 comments · Fixed by #9324 or #9325
Closed
4 tasks done
Assignees
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 locked due to age Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing. package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Milestone

Comments

@bachmacintosh
Copy link
Contributor

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have searched for related issues and found none that matched my issue.
  • I have read the FAQ and my problem is not listed.

Issue Description

ESLint 9 added new options to their no-unused-vars rule:

  • reportUsedIgnorePattern - Will indicate a problem if an item matches its ignore pattern, but is actually being used
  • ignoreClassWithStaticInitBlock - Ignores classes with items in static initialization blocks that would normally be marked as unused

See no-unused-vars for more info.

These options don't appear to be implemented in typescript-eslint's no-unused-vars extension rule.

Expected Outcome

I would expect index.ts in the reproduction repo to be linted and throw the linting errors seen in this ESLint Playground Link. This uses the same code as in the reproduction repo.

Actual Outcome

An error is thrown by typescript-eslint, because these options are not recognized / implemented in the extension rule:

Oops! Something went wrong! :(

ESLint: 9.3.0

Error: Key "rules": Key "@typescript-eslint/no-unused-vars":
	Value {"varsIgnorePattern":"^_","reportUsedIgnorePattern":true,"ignoreClassWithStaticInitBlock":true} should be string.
	Value {"varsIgnorePattern":"^_","reportUsedIgnorePattern":true,"ignoreClassWithStaticInitBlock":true} should be equal to one of the allowed values.
	Value {"varsIgnorePattern":"^_","reportUsedIgnorePattern":true,"ignoreClassWithStaticInitBlock":true} should NOT have additional properties.
		Unexpected property "reportUsedIgnorePattern". Expected properties: "vars", "varsIgnorePattern", "args", "ignoreRestSiblings", "argsIgnorePattern", "caughtErrors", "caughtErrorsIgnorePattern", "destructuredArrayIgnorePattern".
	Value {"varsIgnorePattern":"^_","reportUsedIgnorePattern":true,"ignoreClassWithStaticInitBlock":true} should match exactly one schema in oneOf.

Reproduction Repository Link

https://github.com/bachmacintosh/tseslint-no-unused-vars

Repro Steps

  1. clone the repo
  2. npm install
  3. npm run lint

Versions

package version
typescript-eslint 8.0.0-alpha.14
TypeScript 5.4.5
ESLint 9.3.0
node 20.12.2
@bachmacintosh bachmacintosh added bug Something isn't working triage Waiting for team members to take a look labels May 19, 2024
@bradzacher
Copy link
Member

I have a branch bringing across these things as part of #8211 but I haven't had time to finalise it yet. Hopefully next week.

I was going through all the commits that touched the file upstream and porting them across to our implementation.

@bradzacher bradzacher self-assigned this May 19, 2024
@bradzacher bradzacher added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin 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 bug Something isn't working triage Waiting for team members to take a look labels May 19, 2024
@Vinccool96

This comment was marked as off-topic.

@kirkwaiblinger

This comment was marked as off-topic.

@Vinccool96

This comment has been minimized.

@Vinccool96

This comment was marked as off-topic.

@kirkwaiblinger

This comment was marked as off-topic.

@bradzacher
Copy link
Member

In this case essentially what we need to do is go through all of the recent commits to the no-unused-vars lint rule upstream and figure out what the changes are and how to add those changes to our fork.
Our fork is less of a fork and more of a complete and utter rewrite - which makes this quite the complex task. Possible for any contributor to do - but far from easy.

In general we'd be happy for anyone to do the work but in this particular case I had already started on this work man weeks ago (well before this issue was raised) - I just haven't had the bandwidth to finish it yet.

@bradzacher bradzacher added this to the 8.0.0 milestone Jun 11, 2024
@bradzacher bradzacher changed the title Bug: [8.0.0-alpha] [no-unused-vars] Support for ignoreClassWithStaticInitBlock and reportUsedIgnorePattern Options Enhancement: [no-unused-vars] Support for ignoreClassWithStaticInitBlock and reportUsedIgnorePattern Options Jun 11, 2024
@bradzacher bradzacher closed this as not planned Won't fix, can't repro, duplicate, stale Jun 25, 2024
@bradzacher bradzacher reopened this Jun 25, 2024
@bradzacher
Copy link
Member

This has landed on v8!

@github-actions github-actions bot added the locked due to age Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing. label Jul 3, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 3, 2024
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 locked due to age Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing. package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
4 participants