Skip to content

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

@bachmacintosh

Description

@bachmacintosh

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

Metadata

Metadata

Assignees

Labels

accepting prsGo ahead, send a pull request that resolves this issueenhancement: plugin rule optionNew rule option for an existing eslint-plugin rulelocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.package: eslint-pluginIssues related to @typescript-eslint/eslint-plugin

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions