Skip to content

VSCode: auto fix adds ignore directives #14261

@mjwwit

Description

@mjwwit

What version of Oxlint are you using?

1.13.0 (VSCode extension 1.19.0)

What command did you run?

oxc.applyAllFixesFile

What does your .oxlintrc.json config file look like?

{
  "$schema": "./node_modules/oxlint/configuration_schema.json",
  "plugins": ["typescript", "unicorn", "oxc", "import", "node", "promise", "vitest"],
  "env": {
    "node": true,
    "es2024": true
  },
  // "categories": {
  //   "correctness": "error",
  //   "perf": "off",
  //   "restriction": "off",
  //   "suspicious": "off",
  //   "pedantic": "off",
  //   "style": "off",
  //   "nursery": "off"
  // },
  "ignorePatterns": ["/dist/**", "/node_modules/**", "/*.js"],
  "rules": {
    // Correctness
    "no-irregular-whitespace": "warn",

    // Perf
    "no-useless-call": "warn",
    "oxc/no-accumulating-spread": "warn",
    "unicorn/prefer-array-find": "error",
    "unicorn/prefer-set-has": "warn",

    // Restriction
    "no-empty": "error",
    "no-empty-function": "error",
    "no-eq-null": "error",
    "no-iterator": "error",
    "no-proto": "error",
    "no-regex-spaces": "error",
    "no-restricted-imports": [
      "error",
      {
        "paths": [
          {
            "name": "node-fetch",
            "message": "Please use Node.js built-in fetch instead"
          }
        ],
        "patterns": [
          {
            "group": ["node:url"],
            "message": "Please use WHATWG URL instead (global)"
          }
        ]
      }
    ],
    "no-unused-expressions": "error",
    "no-var": "error",
    "unicode-bom": ["error", "never"],
    "node/no-new-require": "error",
    "oxc/bad-bitwise-operator": "error",
    "oxc/no-const-enum": "error",
    // "promise/catch-or-return": "error", // This one gives false positives when returning a promise directly
    "typescript/no-dynamic-delete": "error",
    "typescript/no-empty-object-type": "error",
    "typescript/no-explicit-any": "warn",
    "typescript/no-namespace": "error",
    "typescript/no-non-null-asserted-nullish-coalescing": "error",
    "typescript/no-require-imports": "error",
    "typescript/prefer-literal-enum-member": "error",
    "unicorn/no-abusive-eslint-disable": "error",
    "unicorn/no-anonymous-default-export": "error",
    "unicorn/no-length-as-slice-end": "error",
    "unicorn/no-magic-array-flat-depth": "error",
    "unicorn/prefer-node-protocol": "error",
    "unicorn/prefer-number-properties": "error",

    // Suspicious
    "no-extend-native": "error",
    "no-unexpected-multiline": "warn",
    "no-unneeded-ternary": "error",
    "no-useless-concat": "error",
    "no-useless-constructor": "error",
    "import/no-absolute-path": "error",
    "import/no-empty-named-blocks": "error",
    "import/no-named-as-default": "error",
    "import/no-self-import": "error",
    "oxc/approx-constant": "error",
    "oxc/misrefactored-assign-op": "error",
    "promise/no-promise-in-callback": "error",
    "typescript/no-extraneous-class": "warn",
    "typescript/no-unnecessary-type-constraint": "error",
    "unicorn/consistent-function-scoping": "warn",
    "unicorn/no-accessor-recursion": "error",
    "unicorn/no-instanceof-builtins": "warn", // TODO: Not sure on this one

    // Pedantic
    "no-array-constructor": "error",
    "no-prototype-builtins": "error",
    "no-redeclare": "error",
    "no-throw-literal": "error",
    "prefer-promise-reject-errors": "error",
    "require-await": "warn",
    "typescript/ban-ts-comment": [
      "error",
      {
        "minimumDescriptionLength": 10
      }
    ],
    "typescript/no-unsafe-function-type": "error",

    // Style
    "curly": "error",
    "import/consistent-type-specifier-style": ["error", "prefer-inline"],
    "import/first": "error",
    "import/no-duplicates": "error",
    "typescript/consistent-type-imports": [
      "error",
      {
        "disallowTypeAnnotations": false,
        "prefer": "type-imports",
        "fixStyle": "inline-type-imports"
      }
    ],
    "vitest/no-import-node-test": "error"

    // Nursery
  },
  "overrides": [
    {
      "files": ["**/*.js"],
      "rules": {
        "typescript/no-require-imports": "off"
      }
    },
    {
      "files": ["**/test/**.ts", "**/*.spec.ts", "**/*.test.ts"],
      "rules": {
        "consistent-function-scoping": "off",
        "no-throw-literal": "off",
        "typescript/no-explicit-any": "off",
        "typescript/unbound-method": "off"
      }
    }
  ]
}

What happened?

Oxc VSCode v1.19.0 introduced a bug where the "Fix all auto-fixable problems" (oxc.applyAllFixesFile) command adds ignore-next-line directives. Example, it adds // oxlint-disable-next-line no-accumulating-spread to "fix" a problem in a reduce. v1.18.0 of the extension did not have this problem.

Adding ignore directives isn't "fixing" the issue, and issues that cannot be properly auto-fixed should just be left alone.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions