Skip to content

feat: add warning-aware import diagnostics - #1480

Closed
scarf005 wants to merge 1 commit into
denoland:mainfrom
scarf005:feat/import-warning-autofix
Closed

feat: add warning-aware import diagnostics#1480
scarf005 wants to merge 1 commit into
denoland:mainfrom
scarf005:feat/import-warning-autofix

Conversation

@scarf005

Copy link
Copy Markdown

Summary

  • add warning severity plumbing to deno_lint diagnostics and example reporting
  • make no-import-prefix and no-unversioned-import warnings with lockfile-aware deno.json(c) autofixes
  • avoid guessed versions and handle overlapping fixes when both warnings trigger

Related: denoland/deno#30681

Demote import prefix and unversioned import findings to warnings so workspace import maps are easier to adopt. Make their autofixes update deno.json(c) only when the lockfile can supply a concrete version.

Assisted-by: openai/gpt-5.4 on opencode
Co-authored-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com>
@CLAassistant

CLAassistant commented Mar 20, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@bartlomieju

Copy link
Copy Markdown
Member

Verdict: WIP (draft) — needs a rebase onto the merged severity work before it can land. Not merging. Confined mostly to new rules + examples/dlint plus diagnostic plumbing.

Biggest item: the severity plumbing is now duplicated/superseded
This PR re-adds its own LintDiagnosticSeverity { Error, Warning } enum plus diagnostic_level()/highlight_style()/severity() in src/diagnostic.rs. But the target branch already merged LintDiagnostic::severity (#1487): src/diagnostic.rs now defines LintDiagnosticSeverity (Error/Warning) with as_str(), serde round-trip, the severity field defaulting to Error, and the same DiagnosticLevel/highlight-style mapping — all with tests. As-is this PR will hard-conflict and produce duplicate definitions. The plumbing half should be dropped and rebased to build on the existing enum + severity field, keeping only what's genuinely new (the add_warning_with_fixes-style ergonomics if the merged API doesn't already provide them). The wide churn across jsx_*, no_window*, no_process_global, etc. will also need reconciling against the merged changes.

The genuinely new, valuable part: the two import rules

  • no-unversioned-import + no-import-prefix as warnings with lockfile-aware deno.json(c) autofixes via fix_with_deno_config_package. The "avoid guessed versions / handle overlapping fixes when both trigger" design is the right instinct — overlapping fixes are exactly where autofixers corrupt code, so good that it's handled.
  • Integration tests spin up real temp deno.json/deno.lock projects (unique dirs via pid + AtomicUsize) — solid coverage. Minor: I don't see temp-dir cleanup, so runs may leave deno_lint_no_unversioned_import_* dirs in $TMPDIR; add teardown (or use a scope-guard) to avoid litter.

To finish (draft)

Perf: nothing concerning in the rule paths (per-import checks).

Foundation is reasonable; the work now is mostly reconciling with the severity infrastructure that landed after this was opened.

@scarf005 scarf005 closed this Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants