Skip to content

Commit

Permalink
Add flat config support
Browse files Browse the repository at this point in the history
  • Loading branch information
tamiroh committed Nov 12, 2024
1 parent 6499695 commit b546a7e
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 1 deletion.
12 changes: 12 additions & 0 deletions packages/eslint-config-airbnb-base/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,18 @@ Our default export contains all of our ESLint rules, including ECMAScript 6+. It

2. Add `"extends": "airbnb-base"` to your .eslintrc.

If using flat config, you can import `"eslint-config-airbnb-base/flat"` on your `eslint.config.mjs` file like this:

```javascript
import airbnbBase from "eslint-config-airbnb-base/flat";
export default [
...airbnbBase,
// Add your own configs
];
```


### eslint-config-airbnb-base/legacy

Lints ES5 and below. Requires `eslint` and `eslint-plugin-import`.
Expand Down
26 changes: 26 additions & 0 deletions packages/eslint-config-airbnb-base/flat.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const index = require('./index');
const bestPractices = require('./rules/best-practices');
const errors = require('./rules/errors');
const node = require('./rules/flat/node');
const style = require('./rules/style');
const variables = require('./rules/variables');
const es6 = require('./rules/flat/es6');
const imports = require('./rules/flat/imports');
const strict = require('./rules/strict');

module.exports = [
bestPractices,
errors,
node,
style,
variables,
es6,
imports,
strict,
{
languageOptions: {
parserOptions: index.parserOptions,
},
rules: {},
}
];
4 changes: 3 additions & 1 deletion packages/eslint-config-airbnb-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"main": "index.js",
"exports": {
".": "./index.js",
"./flat": "./flat.js",
"./legacy": "./legacy.js",
"./whitespace": "./whitespace.js",
"./rules/best-practices": "./rules/best-practices.js",
Expand Down Expand Up @@ -87,6 +88,7 @@
"node": "^10.12.0 || >=12.0.0"
},
"dependencies": {
"confusing-browser-globals": "^1.0.11"
"confusing-browser-globals": "^1.0.11",
"globals": "^15.12.0"
}
}
12 changes: 12 additions & 0 deletions packages/eslint-config-airbnb-base/rules/flat/es6.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const es6 = require('../es6');
const globals = require('globals');

module.exports = {
languageOptions: {
globals: {
...globals.es2015,
},
parserOptions: es6.parserOptions,
},
rules: es6.rules,
};
17 changes: 17 additions & 0 deletions packages/eslint-config-airbnb-base/rules/flat/imports.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const importPlugin = require('eslint-plugin-import');
const globals = require('globals');
const imports = require('../imports');

module.exports = {
languageOptions: {
globals: {
...globals.es2015,
},
parserOptions: imports.parserOptions,
},
plugins: {
import: importPlugin
},
settings: imports.settings,
rules: imports.rules,
};
11 changes: 11 additions & 0 deletions packages/eslint-config-airbnb-base/rules/flat/node.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const globals = require('globals');
const node = require('../node');

module.exports = {
languageOptions: {
globals: {
...globals.es2015,
}
},
rules: node.rules,
};

0 comments on commit b546a7e

Please sign in to comment.