@eslint/eslintrc
Advanced tools
Comparing version 2.1.2 to 2.1.3
{ | ||
"name": "@eslint/eslintrc", | ||
"version": "2.1.2", | ||
"version": "2.1.3", | ||
"description": "The legacy ESLintRC config file format for ESLint", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -19,3 +19,3 @@ # ESLintRC Library | ||
## Usage | ||
## Usage (ESM) | ||
@@ -70,4 +70,48 @@ The primary class in this package is `FlatCompat`, which is a utility to translate ESLintRC-style configs into flat configs. Here's how you use it inside of your `eslint.config.js` file: | ||
## Usage (CommonJS) | ||
Using `FlatCompat` in CommonJS files is similar to ESM, but you'll use `require()` and `module.exports` instead of `import` and `export`. Here's how you use it inside of your `eslint.config.js` CommonJS file: | ||
```js | ||
const { FlatCompat } = require("@eslint/eslintrc"); | ||
const js = require("@eslint/js"); | ||
const compat = new FlatCompat({ | ||
baseDirectory: __dirname, // optional; default: process.cwd() | ||
resolvePluginsRelativeTo: __dirname, // optional | ||
recommendedConfig: js.configs.recommended, // optional | ||
allConfig: js.configs.all, // optional | ||
}); | ||
module.exports = [ | ||
// mimic ESLintRC-style extends | ||
...compat.extends("standard", "example"), | ||
// mimic environments | ||
...compat.env({ | ||
es2020: true, | ||
node: true | ||
}), | ||
// mimic plugins | ||
...compat.plugins("airbnb", "react"), | ||
// translate an entire config | ||
...compat.config({ | ||
plugins: ["airbnb", "react"], | ||
extends: "standard", | ||
env: { | ||
es2020: true, | ||
node: true | ||
}, | ||
rules: { | ||
semi: "error" | ||
} | ||
}) | ||
]; | ||
``` | ||
## License | ||
MIT License |
657201
116