Expand description
Library surface for the import-lint CLI, split out from the binary
(src/main.rs) so integration tests can drive discovery and the pipeline
directly without spawning a subprocess (PLAN-v1.md M2).
Re-exports§
pub use overlay::Overlays;pub use runner::RunnerOptions;pub use runner::run;pub use source_type::SUPPORTED_EXTENSIONS_MESSAGE;pub use source_type::source_type_for_path;pub use walk::walk;pub use walk::walk_with_excludes;
Modules§
- lsp
- The
import-lint lspserver (L2,docs/PLAN-lsp.md§2, decisions E2-E5/E8/E10): a synchronouslsp-server/lsp-typesmain loop wrapping the existingcrate::watch::WatchSessionengine. Diagnostics are push-only (textDocument/publishDiagnostics) for the whole project, not just open documents (E3) — every engine cycle already computes the full set, so the server’s only job is diffing it against what it last published per file. - output
- Output formats for rendered diagnostics (PLAN-v1.md §6, M5):
pretty(default, ESLint-stylish-like),json(ESLint-compatible),github(workflow commands). - overlay
- In-memory overlay content for open editor buffers (L1,
docs/PLAN-lsp.md§3): an overlay’s content overrides its file’s on-disk content in extraction (runner.rs) and in diagnostic line/col rendering (report.rs), while everything else about the pipeline — walking, resolution, the check phase — is unaffected.Overlaysis owned bywatch::WatchSessionand empty by default, which is what the one-shot CLI path (runner::run) and non-LSP watch mode always pass, so behavior is unchanged unless something actually populates it (the futureimport-lint lspserver, L2). - report
- Turning a checked
ModuleGraphinto theRenderedDiagnostics a formatter renders (PLAN-v1.md §2.1 step 5–6, §5--report-unresolved/--quiet). Factored out ofmain.rs’slint()(M5) so watch mode (crates/cli/src/watch.rs, M6) can rebuild the same report every cycle without duplicating the logic. - runner
- Discovery + link orchestration (PLAN-v1.md §2.1 steps 2–4, §8, M2): walk, then
parse+extract and resolve in parallel (rayon +
AllocatorPool), producing aModuleGraph. The check phase (PLAN-v1.md §2.1 step 5) is M3’s job. - setup
- Project setup: turning CLI flags + config-file discovery into a
LintConfig, project root, roots to walk,tsconfigpath, and self-reference mode (PLAN-v1.md §5, D7). Factored out ofmain.rs’slint()(M5) so watch mode’sConfigChangedreload path (crates/cli/src/watch.rs, M6 brief D-W1) can redo exactly the same computation without duplicating it. - source_
type - Extension ->
oxc_span::SourceTypemapping, shared by every command that needs to know how to parse a file from its path (inspect, the discovery+pipeline runner incrate::runner). - walk
- File discovery (PLAN-v1.md §2.1 step 2, M2): the
ignorecrate’s parallel walker, rooted at the configured include paths. - watch
- Watch mode (PLAN-v1.md §7, M6 brief).
WatchSessionimplements the update policy (brief D-W1: full re-check every debounced batch, extraction cached; a freshProjectResolver+ re-walk only on a “structural” change) and is fully drivable withoutnotify(brief D-W3) — seecrates/cli/tests/watch.rs.watch_loopis the thinnotify/notify-debouncer-fulllayer that maps real filesystem events toChangeKinds and drives aWatchSessionfrom them (brief D-W2).