unimport icon indicating copy to clipboard operation
unimport copied to clipboard

ESLint Plugin?

Open antfu opened this issue 2 years ago • 2 comments

Describe the feature

One downside of auto-import is that some people would be concerned about the implicitness and uncertainty of where a function has been imported.

Wonder if we can come up with an optional eslint plugin that automatically inserts the import statement into the file.

Unlike the IDE auto-insertion that often injects the wrong path, and only available when you are typing that entry or explicitly clicking on the entry. Unimport maintains a list of imports with unique names, so that you always get the correct path. Meanwhile, with an ESLint Plugin, you can run it with a CLI and even filter the files you want it to enable. Combined with rules like https://www.npmjs.com/package/eslint-plugin-unused-imports, you can get autofix when you add or remove functions. Make the import statements almost fully automated.

Additional information

  • [X] Would you be willing to help implement this feature?

antfu avatar Dec 08 '23 01:12 antfu

Got a PoC working, https://github.com/antfu/eslint-plugin-unimport, still a lot polishing to do to make it usable tho.

https://github.com/unjs/unimport/assets/11247099/4003d8f6-d8fe-49a1-a115-7afdf3b656b4

antfu avatar Dec 09 '23 02:12 antfu

Any update on this one?

jongbonga avatar Aug 20 '24 15:08 jongbonga