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: [no-unused-vars] Used vars incorrectly reported in presence of static blocks #5577

Closed
4 tasks done
gebsh opened this issue Aug 30, 2022 · 1 comment · Fixed by #5580
Closed
4 tasks done

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

gebsh opened this issue Aug 30, 2022 · 1 comment · Fixed by #5580
Labels
accepting prs Go ahead, send a pull request that resolves this issue bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@gebsh
Copy link
Contributor

gebsh commented Aug 30, 2022

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
@gebsh gebsh added bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for maintainers to take a look labels Aug 30, 2022
@jcurtis
Copy link

jcurtis commented Aug 30, 2022

Reverting to 5.36.0 fixes this for me. I believe 5.36.1 introduced a compatibility issue with typescript 4.8 in #5574

@bradzacher bradzacher added accepting prs Go ahead, send a pull request that resolves this issue and removed triage Waiting for maintainers to take a look labels Aug 31, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 2, 2022
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 bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants