[no-unused-vars] False negative with new JSX transform #3303
Labels
enhancement
New feature or request
package: scope-manager
Issues related to @typescript-eslint/scope-manager
Repro
In tsconfig, I have
Expected Result
If using the new JSX transform, the
React
should be flagged as an unused variable.NB: users may also be using the new JSX transform with
jsx
set topreserve
in tsconfig (e.g. if using babel to actually transpile TS to JS), so should have a way to configure it otherwise.Actual Result
React
is identified as in use, so is not flagged as unused.Additional Info
What I'm pretty sure is going on:
Referencer
(https://github.com/typescript-eslint/typescript-eslint/blob/498f397ff3898dde631f37311615b555f38a414e/packages/scope-manager/src/referencer/Referencer.ts) is referencing the JSX pragma (React
by default) anywhere that it finds JSX in usejsxFragmentName
allows being ignored by being set to null, butjsxPragma
does notI'd suggest adding a condition if
jsxPragma
is null, just ignore it in referencing like it does withjsxFragmentName
? Could also add some smarts to auto detect settingjsxPragma
to null when thejsx
option isreact-jsx
orreact-jsxdev
, but the null option would still be required to handlepreserve
as above (could be either).Versions
@typescript-eslint/eslint-plugin
4.19.0
@typescript-eslint/parser
4.19.0
TypeScript
4.2.3
ESLint
7.22.0
node
14.16.0
The text was updated successfully, but these errors were encountered: