@eslint/compat
Advanced tools
Comparing version
@@ -1,6 +0,6 @@ | ||
export type FixupRuleDefinition = import("./types.ts").FixupRuleDefinition; | ||
export type FixupLegacyRuleDefinition = import("./types.ts").FixupLegacyRuleDefinition; | ||
export type FixupPluginDefinition = import("./types.ts").FixupPluginDefinition; | ||
export type FixupConfig = import("./types.ts").FixupConfig; | ||
export type FixupConfigArray = import("./types.ts").FixupConfigArray; | ||
export type FixupPluginDefinition = import("eslint").ESLint.Plugin; | ||
export type FixupRuleDefinition = import("eslint").Rule.RuleModule; | ||
export type FixupLegacyRuleDefinition = import("eslint").Rule.OldStyleRule; | ||
export type FixupConfig = import("eslint").Linter.FlatConfig; | ||
export type FixupConfigArray = Array<FixupConfig>; | ||
/** | ||
@@ -12,3 +12,3 @@ * Takes the given configuration and creates a new configuration with all of the | ||
*/ | ||
export function fixupConfigRules(config: import("./types.ts").FixupConfigArray | FixupConfig): import("./types.ts").FixupConfigArray; | ||
export function fixupConfigRules(config: FixupConfigArray | FixupConfig): FixupConfigArray; | ||
/** | ||
@@ -15,0 +15,0 @@ * Takes the given plugin and creates a new plugin with all of the rules wrapped |
@@ -0,1 +1,2 @@ | ||
// @ts-self-types="./index.d.ts" | ||
/** | ||
@@ -14,7 +15,7 @@ * @filedescription Object Schema | ||
/** @typedef {import("./types.ts").FixupRuleDefinition} FixupRuleDefinition */ | ||
/** @typedef {import("./types.ts").FixupLegacyRuleDefinition} FixupLegacyRuleDefinition */ | ||
/** @typedef {import("./types.ts").FixupPluginDefinition} FixupPluginDefinition */ | ||
/** @typedef {import("./types.ts").FixupConfig} FixupConfig */ | ||
/** @typedef {import("./types.ts").FixupConfigArray} FixupConfigArray */ | ||
/** @typedef {import("eslint").ESLint.Plugin} FixupPluginDefinition */ | ||
/** @typedef {import("eslint").Rule.RuleModule} FixupRuleDefinition */ | ||
/** @typedef {import("eslint").Rule.OldStyleRule} FixupLegacyRuleDefinition */ | ||
/** @typedef {import("eslint").Linter.FlatConfig} FixupConfig */ | ||
/** @typedef {Array<FixupConfig>} FixupConfigArray */ | ||
@@ -21,0 +22,0 @@ //----------------------------------------------------------------------------- |
{ | ||
"name": "@eslint/compat", | ||
"version": "1.0.1", | ||
"version": "1.0.3", | ||
"description": "Compatibility utilities for ESLint", | ||
@@ -17,10 +17,3 @@ "type": "module", | ||
"files": [ | ||
"dist/cjs/index.cjs", | ||
"dist/cjs/index.d.cts", | ||
"dist/cjs/types.d.ts", | ||
"dist/esm/index.js", | ||
"dist/esm/index.d.ts", | ||
"dist/esm/types.d.ts", | ||
"README.md", | ||
"LICENSE" | ||
"dist" | ||
], | ||
@@ -34,3 +27,5 @@ "publishConfig": { | ||
"scripts": { | ||
"build": "rollup -c && tsc -p tsconfig.esm.json && tsc -p tsconfig.cjs.json", | ||
"build:cts": "node -e \"fs.copyFileSync('dist/esm/index.d.ts', 'dist/cjs/index.d.cts')\"", | ||
"build": "rollup -c && tsc -p tsconfig.esm.json && npm run build:cts", | ||
"test:jsr": "npx jsr@latest publish --dry-run", | ||
"test": "mocha tests/*.js" | ||
@@ -55,7 +50,7 @@ }, | ||
"devDependencies": { | ||
"@types/eslint": "^8.56.10", | ||
"eslint": "^9.0.0", | ||
"mocha": "^10.4.0", | ||
"rollup": "^4.16.2", | ||
"typescript": "^5.4.5", | ||
"rollup-plugin-copy": "^3.5.0" | ||
"typescript": "^5.4.5" | ||
}, | ||
@@ -62,0 +57,0 @@ "engines": { |
# ESLint Compatibility Utilities | ||
## Overview | ||
@@ -8,2 +7,4 @@ | ||
**Note:** All plugins are not guaranteed to work in ESLint v9.x. This package fixes the most common issues but can't fix everything. | ||
## Installation | ||
@@ -33,5 +34,5 @@ | ||
* `fixupRule(rule)` - wraps the given rule in a compatibility layer and returns the result | ||
* `fixupPluginRules(plugin)` - wraps each rule in the given plugin using `fixupRule()` and returns a new object that represents the plugin with the fixed-up rules | ||
* `fixupConfigRules(configs)` - wraps all plugins found in an array of config objects using `fixupPluginRules()` | ||
- `fixupRule(rule)` - wraps the given rule in a compatibility layer and returns the result | ||
- `fixupPluginRules(plugin)` - wraps each rule in the given plugin using `fixupRule()` and returns a new object that represents the plugin with the fixed-up rules | ||
- `fixupConfigRules(configs)` - wraps all plugins found in an array of config objects using `fixupPluginRules()` | ||
@@ -82,11 +83,11 @@ ### Fixing Rules | ||
export default [ | ||
{ | ||
plugins: { | ||
// insert the fixed plugin instead of the original | ||
somePlugin: fixupPluginRules(somePlugin) | ||
}, | ||
rules: { | ||
"somePlugin/rule-name": "error" | ||
} | ||
} | ||
{ | ||
plugins: { | ||
// insert the fixed plugin instead of the original | ||
somePlugin: fixupPluginRules(somePlugin), | ||
}, | ||
rules: { | ||
"somePlugin/rule-name": "error", | ||
}, | ||
}, | ||
]; | ||
@@ -103,11 +104,11 @@ ``` | ||
module.exports = [ | ||
{ | ||
plugins: { | ||
// insert the fixed plugin instead of the original | ||
somePlugin: fixupPluginRules(somePlugin) | ||
}, | ||
rules: { | ||
"somePlugin/rule-name": "error" | ||
} | ||
} | ||
{ | ||
plugins: { | ||
// insert the fixed plugin instead of the original | ||
somePlugin: fixupPluginRules(somePlugin), | ||
}, | ||
rules: { | ||
"somePlugin/rule-name": "error", | ||
}, | ||
}, | ||
]; | ||
@@ -126,6 +127,6 @@ ``` | ||
export default [ | ||
...fixupConfigRules(someConfig), | ||
{ | ||
// your overrides | ||
} | ||
...fixupConfigRules(someConfig), | ||
{ | ||
// your overrides | ||
}, | ||
]; | ||
@@ -142,6 +143,6 @@ ``` | ||
module.exports = [ | ||
...fixupConfigRules(someConfig), | ||
{ | ||
// your overrides | ||
} | ||
...fixupConfigRules(someConfig), | ||
{ | ||
// your overrides | ||
}, | ||
]; | ||
@@ -148,0 +149,0 @@ ``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
148
0.68%34781
-5.02%7
-22.22%464
-9.55%