eslint-flat-config-airbnb
Version:
A mostly reasonable approach to JavaScript, updated for ESLint 9+
72 lines (63 loc) • 2.38 kB
Markdown
A mostly reasonable approach to JavaScript, updated for ESLint 9+.
This fork of the [Airbnb JavaScript Style Guide](https://github.com/airbnb/javascript) updates the rules and configurations to support ESLint 9.0+ while maintaining the core principles of clean, consistent, and modern JavaScript code.
- The original [guide](https://github.com/airbnb/javascript) is widely adopted but does not yet support ESLint 9.0+.
- This version ensures compatibility with the latest ESLint rules and best practices.
- Updates may include deprecations, rule refinements, and modern JavaScript features.
To use this updated guide in your project:
```
npm install --save-dev eslint-flat-config-airbnb
```
Extend it in your eslint.config.mjs:
```
import globals from 'globals';
import pluginJs from '@eslint/js';
import tseslint from 'typescript-eslint';
import importPlugin from 'eslint-plugin-import';
import airbnb from 'eslint-flat-config-airbnb';
export default [
{
ignores: ['node_modules', 'build', 'dist'],
},
{
files: ['src/**/*.{js,mjs,cjs,ts}'],
},
{
languageOptions: {
globals: globals.node,
},
},
pluginJs.configs.recommended,
...tseslint.configs.recommended,
importPlugin.flatConfigs.recommended,
...airbnb.base,
{
settings: {
'import/resolver': {
node: {
extensions: ['.js', '.jsx', '.ts', '.tsx'],
},
},
},
},
{
rules: {
semi: ['error', 'always'],
'no-underscore-dangle': ['error', { allow: ['_id', '__dirname', '__type'] }],
indent: ['error', 4],
'template-curly-spacing': ['error', 'always'],
'object-curly-spacing': ['error', 'always'],
'computed-property-spacing': ['error', 'always'],
'no-multiple-empty-lines': ['error', { max: 1, maxEOF: 0, maxBOF: 0 }],
quotes: ['error', 'single', 'avoid-escape'],
'no-use-before-define': ['error', { functions: false }],
'prefer-const': 1,
'max-len': ['error', { code: 200 }],
complexity: ['error', { max: 15 }],
'key-spacing': ['error', { beforeColon: false, afterColon: true }],
},
},
];
```