Skip to content

Bug: [no-unused-vars] Used vars incorrectly reported in presence of static blocks #5577

Closed
@gebsh

Description

@gebsh

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.

Playground Link

Playground does not work

Repro Code

function foo() {}

export class Foo {
	static {}

	constructor() {
		foo();
	}
}

ESLint Config

module.exports = {
	parser: '@typescript-eslint/parser',
	plugins: ['@typescript-eslint/eslint-plugin'],
	rules: {
		'@typescript-eslint/no-unused-vars': 'warn',
	},
};

tsconfig

No response

Expected Result

No report about unused variables.

Actual Result

The foo function is reported as unused even though it's used by the Foo class.

Additional Info

Removing the static block from Foo removes the report.

Initially, I thought that this may be related to #5571, but this issue still persists after upgrading to 5.36.1.

Versions

package version
@typescript-eslint/eslint-plugin 5.36.1
@typescript-eslint/parser 5.36.1
TypeScript 4.8.2
ESLint 8.23.0
node 18.8.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issuebugSomething isn't workingpackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions