{"name":"@eslint/compat","version":"1.3.0","keywords":["eslint","compatibility","eslintplugin","eslint-plugin"],"author":{"name":"Nicholas C. Zakas"},"license":"Apache-2.0","_id":"@eslint/compat@1.3.0","maintainers":[{"name":"openjsfoundation","email":"npm@openjsf.org"},{"name":"eslintbot","email":"contact@eslint.org"}],"homepage":"https://github.com/eslint/rewrite/tree/main/packages/compat#readme","bugs":{"url":"https://github.com/eslint/rewrite/issues"},"dist":{"shasum":"ce9dbd81e06c942a9570fbe3c2e10e3103f12c1c","tarball":"http://registry-npm.ywwl.com/@eslint/compat/download/@eslint/compat-1.3.0.tgz","fileCount":7,"integrity":"sha512-ZBygRBqpDYiIHsN+d1WyHn3TYgzgpzLEcgJUxTATyiInQbKZz6wZb6+ljwdg8xeeOe4v03z6Uh6lELiw0/mVhQ==","signatures":[{"sig":"MEQCIF2DT4bqnHrBU288Z8vya1JXBo7wDX2AAkhRFzrcDJnrAiBLydZlQ2GmCAnwzKg7y4wEsBsILTAbrOaVxqL8ydx+yQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@eslint%2fcompat@1.3.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":50431,"size":11009,"noattachment":false,"key":"/@eslint/compat/-/@eslint/compat-1.3.0.tgz"},"main":"dist/esm/index.js","type":"module","types":"dist/esm/index.d.ts","engines":{"node":"^18.18.0 || ^20.9.0 || >=21.1.0"},"exports":{"import":{"types":"./dist/esm/index.d.ts","default":"./dist/esm/index.js"},"require":{"types":"./dist/cjs/index.d.cts","default":"./dist/cjs/index.cjs"}},"gitHead":"48b1f849476582257e1b6a110c4af55adbbec2e8","scripts":{"test":"mocha tests/*.js","build":"rollup -c && tsc -p tsconfig.esm.json && npm run build:cts","test:jsr":"npx jsr@latest publish --dry-run","build:cts":"node ../../tools/build-cts.js dist/esm/index.d.ts dist/cjs/index.d.cts","test:coverage":"c8 npm test"},"_npmUser":{"name":"eslintbot","email":"contact@eslint.org"},"repository":{"url":"git+https://github.com/eslint/rewrite.git","type":"git","directory":"packages/compat"},"_npmVersion":"10.9.2","description":"Compatibility utilities for ESLint","directories":{"test":"tests"},"_nodeVersion":"22.16.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"c8":"^9.1.0","mocha":"^10.4.0","eslint":"^9.27.0","rollup":"^4.16.2","typescript":"^5.4.5","@eslint/core":"^0.15.0"},"peerDependencies":{"eslint":"^9.10.0"},"peerDependenciesMeta":{"eslint":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/compat_1.3.0_1749674156637_0.5235087749479987","host":"s3://npm-registry-packages-npm-production"},"readme":"# ESLint Compatibility Utilities\n\n## Overview\n\nThis package contains functions that allow you to wrap existing ESLint rules, plugins, and configurations that were intended for use with ESLint v8.x or v9.x to allow them to work as-is in ESLint v9.x and v10.x.\n\n**Note:** All plugins are not guaranteed to work in ESLint v9.x or v10.x. This package fixes the most common issues but can't fix everything.\n\n## Installation\n\nFor Node.js and compatible runtimes:\n\n```shell\nnpm install @eslint/compat -D\n# or\nyarn add @eslint/compat -D\n# or\npnpm install @eslint/compat -D\n# or\nbun add @eslint/compat -D\n```\n\nFor Deno:\n\n```shell\ndeno add @eslint/compat\n```\n\n## Usage\n\nThis package exports the following functions in both ESM and CommonJS format:\n\n- `fixupRule(rule)` - wraps the given rule in a compatibility layer and returns the result\n- `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\n- `fixupConfigRules(configs)` - wraps all plugins found in an array of config objects using `fixupPluginRules()`\n- `includeIgnoreFile(path)` (deprecated) - reads an ignore file (like `.gitignore`) and converts the patterns into the correct format for the config file\n\n### Fixing Rules\n\nIf you have a rule that you'd like to make compatible with ESLint v9.x or v10.x, you can do so using the `fixupRule()` function:\n\n```js\n// ESM example\nimport { fixupRule } from \"@eslint/compat\";\n\n// Step 1: Import your rule\nimport myRule from \"./local-rule.js\";\n\n// Step 2: Create backwards-compatible rule\nconst compatRule = fixupRule(myRule);\n\n// Step 3 (optional): Export fixed rule\nexport default compatRule;\n```\n\nOr in CommonJS:\n\n```js\n// CommonJS example\nconst { fixupRule } = require(\"@eslint/compat\");\n\n// Step 1: Import your rule\nconst myRule = require(\"./local-rule.js\");\n\n// Step 2: Create backwards-compatible rule\nconst compatRule = fixupRule(myRule);\n\n// Step 3 (optional): Export fixed rule\nmodule.exports = compatRule;\n```\n\n### Fixing Plugins\n\nIf you are using a plugin in your `eslint.config.js` that is not yet compatible with ESLint v9.x or v10.x, you can wrap it using the `fixupPluginRules()` function:\n\n```js\n// eslint.config.js - ESM example\nimport { defineConfig } from \"eslint/config\";\nimport { fixupPluginRules } from \"@eslint/compat\";\nimport somePlugin from \"eslint-plugin-some-plugin\";\n\nexport default defineConfig([\n\t{\n\t\tplugins: {\n\t\t\t// insert the fixed plugin instead of the original\n\t\t\tsomePlugin: fixupPluginRules(somePlugin),\n\t\t},\n\t\trules: {\n\t\t\t\"somePlugin/rule-name\": \"error\",\n\t\t},\n\t},\n]);\n```\n\nOr in CommonJS:\n\n```js\n// eslint.config.js - CommonJS example\nconst { defineConfig } = require(\"eslint/config\");\nconst { fixupPluginRules } = require(\"@eslint/compat\");\nconst somePlugin = require(\"eslint-plugin-some-plugin\");\n\nmodule.exports = defineConfig([\n\t{\n\t\tplugins: {\n\t\t\t// insert the fixed plugin instead of the original\n\t\t\tsomePlugin: fixupPluginRules(somePlugin),\n\t\t},\n\t\trules: {\n\t\t\t\"somePlugin/rule-name\": \"error\",\n\t\t},\n\t},\n]);\n```\n\n### Fixing Configs\n\nIf you are importing other configs into your `eslint.config.js` that use plugins that are not yet compatible with ESLint v9.x or v10.x, you can wrap the entire array or a single object using the `fixupConfigRules()` function:\n\n```js\n// eslint.config.js - ESM example\nimport { defineConfig } from \"eslint/config\";\nimport { fixupConfigRules } from \"@eslint/compat\";\nimport someConfig from \"eslint-config-some-config\";\n\nexport default defineConfig([\n\t...fixupConfigRules(someConfig),\n\t{\n\t\t// your overrides\n\t},\n]);\n```\n\nOr in CommonJS:\n\n```js\n// eslint.config.js - CommonJS example\nconst { defineConfig } = require(\"eslint/config\");\nconst { fixupConfigRules } = require(\"@eslint/compat\");\nconst someConfig = require(\"eslint-config-some-config\");\n\nmodule.exports = defineConfig([\n\t...fixupConfigRules(someConfig),\n\t{\n\t\t// your overrides\n\t},\n]);\n```\n\n### Including Ignore Files\n\n**Deprecated**: The `includeIgnoreFile()` exported by this package has been deprecated ([eslint/rewrite#329](https://github.com/eslint/rewrite/issues/329)). Use the `includeIgnoreFile()` function exported by `@eslint/config-helpers` instead (also available at `eslint/config`). This section is only preserved for historical reference.\n\nIf you were using an alternate ignore file in ESLint v8.x, such as using `--ignore-path .gitignore` on the command line, you can include those patterns programmatically in your config file using the `includeIgnoreFile()` function.\n\nThe `includeIgnoreFile()` function also accepts a second optional `name` parameter that allows you to set a custom name for this configuration object. If not specified, it defaults to `\"Imported .gitignore patterns\"`. For example:\n\n```js\n// eslint.config.js - ESM example\nimport { defineConfig } from \"eslint/config\";\nimport { includeIgnoreFile } from \"@eslint/compat\";\nimport path from \"node:path\";\n\nconst gitignorePath = path.resolve(import.meta.dirname, \".gitignore\");\n\nexport default defineConfig([\n\tincludeIgnoreFile(gitignorePath, \"Imported .gitignore patterns\"), // second argument is optional.\n\t{\n\t\t// your overrides\n\t},\n]);\n```\n\nOr in CommonJS:\n\n```js\n// eslint.config.js - CommonJS example\nconst { defineConfig } = require(\"eslint/config\");\nconst { includeIgnoreFile } = require(\"@eslint/compat\");\nconst path = require(\"node:path\");\nconst gitignorePath = path.resolve(__dirname, \".gitignore\");\n\nmodule.exports = defineConfig([\n\tincludeIgnoreFile(gitignorePath, \"Imported .gitignore patterns\"), // second argument is optional.\n\t{\n\t\t// your overrides\n\t},\n]);\n```\n\n**Limitation:** This works without modification when the ignore file is in the same directory as your config file. If the ignore file is in a different directory, you may need to modify the patterns manually.\n\n## License\n\nApache 2.0\n\n<!-- NOTE: This section is autogenerated. Do not manually edit.-->\n<!--sponsorsstart-->\n\n## Sponsors\n\nThe following companies, organizations, and individuals support ESLint's ongoing maintenance and development. [Become a Sponsor](https://eslint.org/donate)\nto get your logo on our READMEs and [website](https://eslint.org/sponsors).\n\n<h3>Platinum Sponsors</h3>\n<p><a href=\"https://automattic.com\"><img src=\"https://images.opencollective.com/automattic/d0ef3e1/logo.png\" alt=\"Automattic\" height=\"128\"></a></p><h3>Gold Sponsors</h3>\n<p><a href=\"https://qlty.sh/\"><img src=\"https://images.opencollective.com/qltysh/33d157d/logo.png\" alt=\"Qlty Software\" height=\"96\"></a> <a href=\"https://shopify.engineering/\"><img src=\"https://avatars.githubusercontent.com/u/8085\" alt=\"Shopify\" height=\"96\"></a> <a href=\"https://www.coderabbit.ai/?utm_source=cr_org&utm_medium=github\"><img src=\"https://avatars.githubusercontent.com/u/132028505\" alt=\"CodeRabbit\" height=\"96\"></a></p><h3>Silver Sponsors</h3>\n<p><a href=\"https://vite.dev/\"><img src=\"https://images.opencollective.com/vite/d472863/logo.png\" alt=\"Vite\" height=\"64\"></a> <a href=\"https://liftoff.io/\"><img src=\"https://images.opencollective.com/liftoff/2d6c3b6/logo.png\" alt=\"Liftoff\" height=\"64\"></a> <a href=\"https://stackblitz.com\"><img src=\"https://avatars.githubusercontent.com/u/28635252\" alt=\"StackBlitz\" height=\"64\"></a></p><h3>Bronze Sponsors</h3>\n<p><a href=\"https://cybozu.co.jp/\"><img src=\"https://images.opencollective.com/cybozu/933e46d/logo.png\" alt=\"Cybozu\" height=\"32\"></a> <a href=\"https://opensource.sap.com\"><img src=\"https://avatars.githubusercontent.com/u/2531208\" alt=\"SAP\" height=\"32\"></a> <a href=\"https://icons8.com/\"><img src=\"https://images.opencollective.com/icons8/7fa1641/logo.png\" alt=\"Icons8\" height=\"32\"></a> <a href=\"https://discord.com\"><img src=\"https://images.opencollective.com/discordapp/f9645d9/logo.png\" alt=\"Discord\" height=\"32\"></a> <a href=\"https://www.gitbook.com\"><img src=\"https://avatars.githubusercontent.com/u/7111340\" alt=\"GitBook\" height=\"32\"></a> <a href=\"https://citadel-ai.com\"><img src=\"https://avatars.githubusercontent.com/u/75781367\" alt=\"Citadel AI\" height=\"32\"></a> <a href=\"https://www.testmuai.com\"><img src=\"https://avatars.githubusercontent.com/u/171592363\" alt=\"TestMu AI Open Source Office (Formerly LambdaTest)\" height=\"32\"></a></p>\n<h3>Technology Sponsors</h3>\nTechnology sponsors allow us to use their products and services for free as part of a contribution to the open source ecosystem and our work.\n<p><a href=\"https://netlify.com\"><img src=\"https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/netlify-icon.svg\" alt=\"Netlify\" height=\"32\"></a> <a href=\"https://algolia.com\"><img src=\"https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/algolia-icon.svg\" alt=\"Algolia\" height=\"32\"></a> <a href=\"https://1password.com\"><img src=\"https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/1password-icon.svg\" alt=\"1Password\" height=\"32\"></a></p>\n<!--sponsorsend-->\n","publish_time":1749674156826,"_cnpm_publish_time":1749674156826,"dist-tags":{"latest":"2.1.1"}}