Registry / testing / eslint-fix-utils

eslint-fix-utils

JSON →
library0.4.2jsnpmunverified

A library of utilities for ESLint rule fixers and suggestions, providing functions to safely manipulate AST nodes (e.g., add/remove object properties, array elements) while handling commas and formatting. Current stable version is 0.4.2. Released under MIT, actively maintained. Key differentiator: offers both higher-level fixer helpers (fixAddObjectProperty, fixRemoveArrayElement) and full APIs (addObjectProperty, removeArrayElement) for custom fix logic. Requires ESLint >=8 and @types/estree >=1. ESM-only since v0.4.0.

npm install eslint-fix-utils
INSTALL
IMPORT
SIG · ESLINT-FIX-UTILS
E
eslint-fix-utils
testingjavascriptv0.4.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

addObjectProperty
import { addObjectProperty } from 'eslint-fix-utils'
const { addObjectProperty } = require('eslint-fix-utils')
ESM-only since v0.4.0. Named export, not default.
removeArrayElement
import { removeArrayElement } from 'eslint-fix-utils'
import removeArrayElement from 'eslint-fix-utils'
Must use named import, not default.
fixRemoveObjectProperty
import { fixRemoveObjectProperty } from 'eslint-fix-utils'
Curried fixer versions are also named exports.

Shows how to use addObjectProperty in an ESLint rule to add a property to an object expression. Demonstrates named imports and the fix function pattern.

import { addObjectProperty, removeArrayElement } from 'eslint-fix-utils'; export default { create(context) { return { ObjectExpression(node) { context.report({ node, messageId: 'addProperty', fix: (fixer) => { return addObjectProperty(context, fixer, node, 'type', 'module'); }, }); }, }; }, };
Debug
Known issues
breakingv0.4.0 drops support for Node 18 and switches to ESM-only with bundled exports.
fix
Update Node to ^20.19.0 || ^22.12.0 || >=24.0.0. Use native ESM or a bundler that handles ESM.
affects: >=0.4.0
breakingv0.3.0 removed support for Node 18.
fix
Upgrade Node to >=20 or stick with v0.2.x.
affects: >=0.3.0
deprecatedAll 'fix' prefixed functions are wrappers; consider using the full API variants directly for more control.
fix
Use addObjectProperty, removeArrayElement, etc., instead of fixAddObjectProperty if you need custom fix logic.
affects: >=0.4.0
Errors
Common errors & fixes
ERR_REQUIRE_ESM: require() of ES Module /path/to/eslint-fix-utils/index.js from /path/to/your-file.js not supported.
Package is ESM-only since v0.4.0, but required with require().
fix
Switch to import syntax or use dynamic import().
TypeError: fixer is not a function
When using the full API functions, the fixer argument must be provided as a separate parameter.
fix
Ensure you call the function with the correct signature: addObjectProperty(context, fixer, node, key, value).
Cannot find module '@types/estree' or its corresponding type declarations.
@types/estree is a peer dependency and not installed automatically.
fix
Run npm install --save-dev @types/estree or add it to your devDependencies.
Upgrade
Version history
0.4.2latest on npm
Audit
Dependencies
@types/estreerequiredTypeScript types for ESTree AST nodes used in all functions.
eslintrequiredCore peer dependency for ESLint rule context and fixer APIs.
Agent activity
4 hits · last 30 days
node
4
Resources
eslint-fix-utils — npm install eslint-fix-utils · libregistry