feat(ts): ts/unused-import rule — whole-statement delete of dead TS/JS imports
- binds names via tree-sitter (default, namespace, named + alias, type-only), keeps a statement when ANY bound name occurs outside it (word scan over comments/strings included): under-delete is the safe direction, mirroring the Java rule's asymmetry - ESM caveat encoded in the policy: mixed live/dead statements are not touched — removing a specifier would still drop the module's side effects - side-effect imports and 'export .. from' re-exports are never candidates - parser/ts became a folder (mod/extract/unused_imports) to keep the 4-entries-per-module rule; word_occurs shared via crate::parser - java/rules/unused_imports now reuses the shared word scanner (DRY)
This commit is contained in:
parent
d5d34afb00
commit
7c8498bc2a
15 changed files with 340 additions and 38 deletions
|
|
@ -53,7 +53,11 @@ exit codes). Current Java rules: `java/unused-import` (deletes single-type
|
|||
imports whose name is provably unreferenced), `java/missing-import`
|
||||
(inserts the import of a project class used by simple name — unique FQN
|
||||
candidate required) and `java/import-order` (Google style: statics first,
|
||||
then single-type, ASCII-sorted, duplicates dropped). Unknown `--rule`
|
||||
then single-type, ASCII-sorted, duplicates dropped). TS/JS:
|
||||
`ts/unused-import` deletes whole statements whose every bound name is
|
||||
unreferenced; mixed statements (one name live) stay untouched because ESM
|
||||
imports carry module side effects, so partial specifier surgery is
|
||||
deliberately off. Unknown `--rule`
|
||||
fails with `INVALID_ARGUMENT` and lists the known ids. A candidate the
|
||||
engine cannot prove safe is reported with `"applied": false` and a
|
||||
`candidates` array of FQN options — resolve it yourself (pick one, add
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue