-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy patheslint.config.js
More file actions
143 lines (135 loc) · 3.62 KB
/
eslint.config.js
File metadata and controls
143 lines (135 loc) · 3.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
import path from 'node:path';
import { includeIgnoreFile } from '@eslint/compat';
import js from '@eslint/js';
import { defineConfig } from 'eslint/config';
import { configs, helpers, plugins } from 'eslint-config-airbnb-extended';
import { rules as prettierConfigRules } from 'eslint-config-prettier';
import prettierPlugin from 'eslint-plugin-prettier';
import reactPlugin from 'eslint-plugin-react';
import globals from 'globals';
const gitignorePath = path.resolve('.', '.gitignore');
const { jsFiles, tsFiles } = helpers.extensions;
const jsConfig = defineConfig([
// ESLint recommended config
{
name: 'js/config',
...js.configs.recommended,
},
// Stylistic plugin
plugins.stylistic,
// Import X plugin
plugins.importX,
// Airbnb base recommended config
...configs.base.recommended,
]);
const reactConfig = defineConfig([
// React plugin
plugins.react,
// React hooks plugin
plugins.reactHooks,
// React JSX A11y plugin
plugins.reactA11y,
// Airbnb React recommended config
...configs.react.recommended,
// React 17+ automatic JSX runtime
reactPlugin.configs.flat['jsx-runtime'],
]);
const typescriptConfig = defineConfig([
// TypeScript ESLint plugin
plugins.typescriptEslint,
// Airbnb base TypeScript config
...configs.base.typescript,
// Airbnb React TypeScript config
...configs.react.typescript,
]);
const prettierConfig = defineConfig([
// Prettier plugin
{
name: 'prettier/plugin/config',
plugins: {
prettier: prettierPlugin,
},
},
// Prettier config
{
name: 'prettier/config',
rules: {
...prettierConfigRules,
'prettier/prettier': 'error',
},
},
]);
const projectOverrides = defineConfig([
{
name: 'project/rule-overrides',
files: [...jsFiles, ...tsFiles],
languageOptions: {
globals: {
JSX: 'readonly',
...globals.browser,
},
},
rules: {
'linebreak-style': 'off',
'no-underscore-dangle': 'off',
'no-shadow': 'off',
'import-x/prefer-default-export': 'off',
'import-x/extensions': 'off',
'import-x/no-unresolved': 'off',
'import-x/no-extraneous-dependencies': [
'error',
{
devDependencies: true,
optionalDependencies: false,
peerDependencies: true,
bundledDependencies: true,
},
],
'react/no-unstable-nested-components': ['error', { allowAsProps: true }],
'react/jsx-filename-extension': [
'error',
{
extensions: ['.tsx', '.jsx'],
},
],
// obsolete in a React 19
'react/prop-types': 'off',
'react/require-default-props': 'off',
'react/jsx-props-no-spreading': 'off',
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'error',
},
},
{
name: 'project/typescript-rule-overrides',
files: tsFiles,
rules: {
// disabled for now to get eslint to pass
'@typescript-eslint/consistent-type-definitions': 'off',
'@typescript-eslint/no-unsafe-enum-comparison': 'off',
'@typescript-eslint/only-throw-error': 'off',
'@typescript-eslint/array-type': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{
args: 'after-used',
enableAutofixRemoval: {
imports: true,
},
ignoreRestSiblings: true,
vars: 'all',
},
],
'@typescript-eslint/no-shadow': 'error',
'no-undef': 'off',
},
},
]);
export default defineConfig([
includeIgnoreFile(gitignorePath),
...jsConfig,
...reactConfig,
...typescriptConfig,
...prettierConfig,
...projectOverrides,
]);