eslint-json-compat-utils is a specialized utility designed to bridge the gap between ESLint rules written for `jsonc-eslint-parser` and those compatible with `@eslint/json`. It provides conversion functions that adapt rule objects, plugin objects, and `create` functions, enabling developers to reuse existing logic across different JSON AST parsers in ESLint. The current stable version is 0.2.3, with releases occurring periodically to address bugs and add minor features, as seen in recent patch updates. Its key differentiator is its focused purpose on AST transformation for JSON linting rules, specifically to ensure compatibility when transitioning between or supporting both `jsonc-eslint-parser` (which supports JSONC, JSON5) and `@eslint/json` (standard JSON).
npm install eslint-json-compat-utilsVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to use `toCompatRule` to convert an existing ESLint rule, originally targeting `jsonc-eslint-parser` AST nodes, into a version compatible with `@eslint/json`.
Only use this package when migrating or supporting rules that were originally written for `jsonc-eslint-parser` and need to function with `@eslint/json`.
Thoroughly test converted rules with `@eslint/json` to ensure all original logic is preserved. For very complex rules, manual review of the converted rule's behavior and potential post-conversion tweaks may be necessary.
Ensure you are using `eslint-json-compat-utils` version `0.2.3` or newer to benefit from recent fixes for node conversion issues, especially for minus number nodes and JSON5 unofficial static nodes. Update your `jsonc-eslint-parser` peer dependency to `^2.4.0 || ^3.0.0`.
Ensure `toCompatRule` or `toCompatCreate` was used correctly on the rule/create function. Verify the `jsonc-eslint-parser` version is compatible with `eslint-json-compat-utils` (current minimum `^2.4.0 || ^3.0.0`). For complex rules, manually inspect the converted AST structure or simplify the original rule's AST traversal.
Ensure the converted plugin is correctly installed (`npm install your-plugin`) and registered in your `.eslintrc.*` file under the `plugins` array, and that `parser: '@eslint/json'` is set.