Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

馃搸 noUnusedVariables should report unused imports #4685

Closed
Conaclos opened this issue Jul 10, 2023 · 2 comments
Closed

馃搸 noUnusedVariables should report unused imports #4685

Conaclos opened this issue Jul 10, 2023 · 2 comments
Labels
A-Linter Area: linter Help wanted Help would be really appreciated task A task, an action that needs to be performed

Comments

@Conaclos
Copy link
Contributor

Description

As discussed in #4188, the current implementation of noUnusedVariables does not report unused imports as in the following example:

import { unused } from "module"
import defaultUnused, * as unusedNamespace from "module"

The equivalent ESLint rule no-unused-var reports unused imports.
I didn't see any reason why noUnusedVariables ignores unused imports.

noUnusedVariables should report unused imports.

@Conaclos Conaclos added Help wanted Help would be really appreciated task A task, an action that needs to be performed A-Linter Area: linter labels Jul 10, 2023
@arendjr
Copy link
Contributor

arendjr commented Jul 19, 2023

For TypeScript users there's a work-around: you can also use noUnusedLocals in your tsconfig.json and it will also report them.

Still agree Rome should also be able to handle this. Might try to give this a go if I have some time.

@arendjr
Copy link
Contributor

arendjr commented Jul 21, 2023

It seems the current rule in main actually does report unused imports now. There's an invalidImport.ts test case even already. Just to make double sure, I added the snippet to the test cases:

import { unused } from "module";
import defaultUnused, * as unusedNamespace from "module";

But all 3 were reported by the rule too, so I think this is safe to close.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-Linter Area: linter Help wanted Help would be really appreciated task A task, an action that needs to be performed
Projects
None yet
Development

No branches or pull requests

2 participants