-
Notifications
You must be signed in to change notification settings - Fork 90
/
eslint.config.mjs
81 lines (78 loc) · 2.18 KB
/
eslint.config.mjs
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
import eslint from '@eslint/js';
import { includeIgnoreFile } from '@eslint/compat';
import path from 'node:path';
import globals from 'globals';
import reactPlugin from 'eslint-plugin-react';
import reactHooksPlugin from 'eslint-plugin-react-hooks';
import reactPerfPlugin from 'eslint-plugin-react-perf';
import importPlugin from 'eslint-plugin-import';
import prettierRecommended from 'eslint-plugin-prettier/recommended';
const gitignorePath = path.resolve(import.meta.dirname, '.gitignore');
/** @type {import('@typescript-eslint/utils').TSESLint.FlatConfig.ConfigFile} */
export default [
includeIgnoreFile(gitignorePath),
{
name: 'global ignore',
// If ignores is used without any other keys in the configuration object,
// then the patterns act as global ignores.
ignores: []
},
eslint.configs.recommended,
reactPlugin.configs.flat.recommended,
importPlugin.flatConfigs.errors,
reactPerfPlugin.configs.flat['recommended'],
{
plugins: { 'react-hooks': reactHooksPlugin },
settings: {
// version config for eslint-plugin-react
react: {
version: 'detect'
}
}
},
prettierRecommended,
{
name: 'src and test rules',
files: ['packages/*/+(src|test)/**/*'],
languageOptions: {
globals: {
...globals.browser,
process: 'readonly'
}
},
rules: {
'no-unused-vars': ['error', { ignoreRestSiblings: true }],
'no-console': 'error',
'react/prop-types': 'off',
'prefer-object-spread': 'warn',
'react-hooks/rules-of-hooks': 'error',
'react/jsx-no-constructed-context-values': 'error'
}
},
{
name: 'jest tests',
files: [`packages/*/test/**`],
languageOptions: {
globals: {
...globals.jest,
...globals.node
}
},
rules: {
'react/prop-types': 'off',
'react/display-name': 'off',
'react-perf/jsx-no-new-object-as-prop': 'off',
'react-perf/jsx-no-new-function-as-prop': 'off',
'react-perf/jsx-no-new-array-as-prop': 'off'
}
},
{
// rules for everybody else
ignores: [`packages/*/+(src|test)/**`],
languageOptions: {
globals: {
...globals.node
}
}
}
];