Skip to content

linter: option to disable auto-fix for no-console #22191

@jlowcs

Description

@jlowcs

(for transparency, the following was AI-generated, then reviewed by me)

Summary

Allow disabling the auto-fix behavior of the no-console rule on a per-rule basis, while keeping the rule itself enabled.

Motivation

The no-console rule is auto-fixable in oxlint. When lint:fix runs on save (or via a pre-commit hook, editor integration, etc.), any console.log I add for debugging is silently removed before I get a chance to use it.

This makes the typical debugging loop painful:

  1. Add console.log(...) to inspect a value.
  2. Save the file.
  3. The line is gone.
  4. Re-add it, remember to add the disable comment, run the code, then clean up manually.

I still want the rule enabled — console.log shouldn't ship to production. I just don't want it auto-removed while I'm actively working on the file.

Proposed solution

Add a way to opt out of auto-fix for a specific rule, without disabling the rule itself. The rule would still report violations (so CI / the editor would flag them), but --fix would leave them alone.

A couple of possible shapes:

Option A — per-rule config object

{
  "rules": {
    "no-console": ["error", { "fix": false }]
  }
}

Option B — global noFix list

{
  "noFix": ["no-console"],
  "rules": {
    "no-console": "error"
  }
}

Option A feels most consistent with how rule configuration usually works. Either way, it needs to live in the config file so it applies to editor/IDE integrations on save — a CLI flag wouldn't help, since the annoying auto-fix happens through the editor's lint-on-save, not from running oxlint --fix manually.

Workarounds considered

  • Disabling the rule entirely — no, I want the safety net for committed code.
  • // oxlint-disable-next-line no-console — works, but I have to remember to add it every time, and the comment also gets in the way.
  • Using console.warn / console.error — only helps if those variants are allowed, and it's not really what I want to log.
  • Turning off format-on-save / fix-on-save — too broad; I lose auto-fix for every other rule too.

Prior art

ESLint has discussed similar requests (e.g. per-rule fixable: false overrides). Some projects work around it by wrapping rules, but a first-class option in oxlint would be cleaner.

Additional context

This is a debugging-ergonomics issue rather than a correctness one — no-console is doing exactly what it's documented to do. The request is to make the auto-fix opt-out-able so the rule stays useful in CI without fighting the developer mid-edit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Priority

    None yet

    Start date

    None yet

    Target date

    None yet

    Effort

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions