Skip to main content

Crate import_lint_cli

Crate import_lint_cli 

Source
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 lsp server (L2, docs/PLAN-lsp.md §2, decisions E2-E5/E8/E10): a synchronous lsp-server/lsp-types main loop wrapping the existing crate::watch::WatchSession engine. 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. Overlays is owned by watch::WatchSession and 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 future import-lint lsp server, L2).
report
Turning a checked ModuleGraph into the RenderedDiagnostics a formatter renders (PLAN-v1.md §2.1 step 5–6, §5 --report-unresolved/--quiet). Factored out of main.rs’s lint() (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 a ModuleGraph. 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, tsconfig path, and self-reference mode (PLAN-v1.md §5, D7). Factored out of main.rs’s lint() (M5) so watch mode’s ConfigChanged reload path (crates/cli/src/watch.rs, M6 brief D-W1) can redo exactly the same computation without duplicating it.
source_type
Extension -> oxc_span::SourceType mapping, shared by every command that needs to know how to parse a file from its path (inspect, the discovery+pipeline runner in crate::runner).
walk
File discovery (PLAN-v1.md §2.1 step 2, M2): the ignore crate’s parallel walker, rooted at the configured include paths.
watch
Watch mode (PLAN-v1.md §7, M6 brief). WatchSession implements the update policy (brief D-W1: full re-check every debounced batch, extraction cached; a fresh ProjectResolver + re-walk only on a “structural” change) and is fully drivable without notify (brief D-W3) — see crates/cli/tests/watch.rs. watch_loop is the thin notify/notify-debouncer-full layer that maps real filesystem events to ChangeKinds and drives a WatchSession from them (brief D-W2).