-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
eslint.config.js
66 lines (63 loc) · 1.5 KB
/
eslint.config.js
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
import js from '@eslint/js';
import react from 'eslint-plugin-react';
import airbnb from 'eslint-config-airbnb';
import globals from 'globals';
import babelParser from '@babel/eslint-parser';
// Helper function to trim whitespace from global keys
const trimGlobals = (globals) => {
const trimmedGlobals = {};
for (const key in globals) {
if (Object.prototype.hasOwnProperty.call(globals, key)) {
trimmedGlobals[key.trim()] = globals[key];
}
}
return trimmedGlobals;
};
export default [
{
ignores: ['node_modules/**'],
},
{
files: ['**/*.js', '**/*.jsx'],
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
globals: {
...trimGlobals(globals.browser),
...trimGlobals(globals.node),
},
parser: babelParser,
parserOptions: {
requireConfigFile: false,
babelOptions: {
presets: ['@babel/preset-react'],
},
},
},
plugins: {
react,
},
settings: {
react: {
version: 'detect', // Automatically detect the React version
},
},
rules: {
...js.configs.recommended.rules,
...react.configs.recommended.rules,
...airbnb.rules,
'react/react-in-jsx-scope': 'off', // Disable the rule for React 17+
},
},
{
// setting for jest test files
files: ['**/*.test.js', '**/*.test.jsx'],
languageOptions: {
globals: {
jest: true,
test: 'readonly',
expect: 'readonly',
},
},
},
];