eslint-plugin-autofix

raw JSON →
2.2.0 verified Sat Apr 25 auth: no javascript

An ESLint plugin (v2.2.0) that wraps ESLint core and custom rules to provide autofix functionality. It converts original fixable rules into autofixable versions by applying fixes automatically. Requires Node.js >=18 and ESLint >=8. The plugin prefixes rule names with 'autofix/' and includes a wide range of ESLint built-in rules. Released as part of a monorepo with similar plugins like eslint-plugin-no-autofix. Supports ESLint v9 as of v2.0.0. Differentiator: enables autofix for rules that are normally not fixable, but does not modify the original rule behavior.

error ESLint: Failed to load plugin 'autofix' declared in '.eslintrc'
cause eslint-plugin-autofix not installed or version incompatible with ESLint version.
fix
Run 'npm install eslint-plugin-autofix --save-dev' and ensure ESLint version is >=8.
error ESLint: Error while loading rule 'autofix/no-unused-vars': Rule 'no-unused-vars' is not defined in plugin 'autofix'.
cause The autofix rule name does not map to any existing rule in the plugin or the original ESLint rule does not exist.
fix
Verify that 'no-unused-vars' is a valid ESLint rule; the autofix plugin wraps most ESLint core rules.
error ReferenceError: require is not defined in ES module scope
cause Using CommonJS require in an ESM project (type: 'module' in package.json).
fix
Use 'import autofix from 'eslint-plugin-autofix'' instead of require.
breaking v2.0.0 dropped support for ESLint <8 and Node.js <18. Upgrade to ESLint 8+ and Node 18+.
fix Update ESLint to >=8 and Node.js to >=18.
deprecated The plugin may not be actively maintained; check the repository for recent updates. Last release was v2.2.0 in 2024-09.
fix Consider monitoring the repo for updates or using ESLint's built-in autofix.
gotcha Rule names must be prefixed with 'autofix/' in the eslintrc rules object. Omitting the prefix will use the original ESLint rule without autofix.
fix Always use 'autofix/<rule-name>' format.
gotcha The plugin does not modify the original rule's behavior; it only applies fixes to the reported errors. Some rules may not produce fixes even if the rule name is prefixed.
fix Check the rule's documentation to see if it is fixable.
npm install eslint-plugin-autofix
yarn add eslint-plugin-autofix
pnpm add eslint-plugin-autofix

Example ESLint configuration using eslint-plugin-autofix to enable autofix for no-debugger and no-unused-vars rules.

// .eslintrc.js
module.exports = {
  plugins: ['autofix'],
  rules: {
    'autofix/no-debugger': 'error',
    'autofix/no-unused-vars': ['error', { args: 'none' }],
  },
};