You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm having some difficulties where this plugin leaves some unused imports "behind" when there are too many.
My use-case is for code generation, where I'm not certain what imports a piece of code will use, so I am putting all possible imports at the top of the file and then using --fix to remove those that are not used. One of the packages I'm using in this way is lucide-react, which exports a lot of different icons as separate components.
However when I do this, it seems to always leave four imports behind. I've come up with a minimal reproduction.
Create an empty directory
npm init
npm i --save react lucide-react
npm i --save-dev eslint typescript typescript-eslint eslint-plugin-unused-imports
You'll see 4 imports were left "behind". In the output:
/Users/obeattie/src/github.com/lispwoso/unused-import-repro/index.ts
1:10 error 'ExpandIcon' is defined but never used. Allowed unused vars must match /^_/u @typescript-eslint/no-unused-vars
1:10 error 'ExpandIcon' is defined but never used unused-imports/no-unused-imports
1:22 error 'LucideClipboardType' is defined but never used. Allowed unused vars must match /^_/u @typescript-eslint/no-unused-vars
1:22 error 'LucideClipboardType' is defined but never used unused-imports/no-unused-imports
1:43 error 'LucideTv2' is defined but never used. Allowed unused vars must match /^_/u @typescript-eslint/no-unused-vars
1:43 error 'LucideTv2' is defined but never used unused-imports/no-unused-imports
1:54 error 'Strikethrough' is defined but never used. Allowed unused vars must match /^_/u @typescript-eslint/no-unused-vars
1:54 error 'Strikethrough' is defined but never used unused-imports/no-unused-imports
✖ 8 problems (8 errors, 0 warnings)
4 errors and 0 warnings potentially fixable with the `--fix` option.
…and they will remain in the index.ts file, as well:
I'm having some difficulties where this plugin leaves some unused imports "behind" when there are too many.
My use-case is for code generation, where I'm not certain what imports a piece of code will use, so I am putting all possible imports at the top of the file and then using
--fix
to remove those that are not used. One of the packages I'm using in this way islucide-react
, which exports a lot of different icons as separate components.However when I do this, it seems to always leave four imports behind. I've come up with a minimal reproduction.
npm init
npm i --save react lucide-react
npm i --save-dev eslint typescript typescript-eslint eslint-plugin-unused-imports
npx eslint --fix ./index.ts
You'll see 4 imports were left "behind". In the output:
…and they will remain in the
index.ts
file, as well:If you run
npx eslint --fix ./index.ts
again, they will be removed.Not sure why this is happening but would really appreciate some help! 🙏
The text was updated successfully, but these errors were encountered: