Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support flat config for eslint-config-airbnb-base #3061

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
};
Loading