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
6
todo.md
6
todo.md
|
|
@ -56,7 +56,11 @@ AI оставляем СНАРУЖИ: при неоднозначности jmov
|
|||
insert `import pkg.Type;` at the import-block end; ambiguous/wildcard → `--json` `candidates`, applied:false;
|
||||
закрыт guava-разрыв «перенесли файл, соседняя ссылка без импорта умерла» — проверено mv+fix+javac SUCCESS),
|
||||
import-order (DONE: Google-стиль — statics первыми, ASCII-сортировка, дедуп; конфликтующие с другими правилами откладываются (prune_overlaps по severity) и сходятся за 2-3 прогона), class-name-mismatch
|
||||
- [ ] TS v1: unused-imports, import-order; add-import требует индекс экспортов (символ→файл)
|
||||
- [x] TS v1: unused-imports (DONE: whole-statement delete, все биндинги мертвы → строка уходит;
|
||||
mixed used/unused НЕ трогаем — в ESM импорт исполняет побочные эффекты модуля,
|
||||
partial-удаление specifier'ов отложено осознанно)
|
||||
- [ ] TS v1: import-order (нет кэнона без eslint-config — grouping-конвенции плавающие; ждать запроса),
|
||||
add-import требует индекс экспортов (символ→файл)
|
||||
- [ ] Форматирование: свой cargo-fmt НЕ строим (вечный long-tail). Только «import formatting»
|
||||
(порядок/группировка — у нас уже есть spans). Опционально `--format-after <cmd>` (prettier /
|
||||
google-java-format), не зависимость
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue