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:
loki5512344 2026-09-15 17:07:46 +02:00
parent d5d34afb00
commit 7c8498bc2a
Signed by: boba
GPG key ID: 253067914055423B
15 changed files with 340 additions and 38 deletions

View file

@ -80,8 +80,8 @@ See [docs/EXAMPLES.md](docs/EXAMPLES.md) for more, and
TypeScript/JavaScript and Java (the open niche) are in — real-world tested
on `google/guava`. `fix` auto-repairs small breakages on the same
dry-run/atomic engine (unused, missing and misordered Java imports;
TS rules next), then Python, Go. `split` (automatic file decomposition) is
dry-run/atomic engine (Java: unused, missing and
misordered imports; TS: unused imports), then Python, Go. `split` (automatic file decomposition) is
planned — no tool does it. Full plan: [docs/PLAN.md](docs/PLAN.md).
## License