-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy patheslint.config.mjs
More file actions
129 lines (122 loc) · 3.54 KB
/
eslint.config.mjs
File metadata and controls
129 lines (122 loc) · 3.54 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
import js from '@eslint/js';
import tsPlugin from '@typescript-eslint/eslint-plugin';
import eslintConfigPrettier from 'eslint-config-prettier/flat';
import jestPlugin from 'eslint-plugin-jest';
import reactPlugin from 'eslint-plugin-react';
import reactHooksPlugin from 'eslint-plugin-react-hooks';
import unusedImports from 'eslint-plugin-unused-imports';
import globals from 'globals';
export default [
{
ignores: [
'**/node_modules/**',
'**/dist/**',
'**/coverage/**',
'**/migrations/**',
'**/generated/**',
'yarn.lock',
],
},
// Base configs
js.configs.recommended,
...tsPlugin.configs['flat/recommended'],
reactPlugin.configs.flat.recommended,
reactHooksPlugin.configs['recommended-latest'],
jestPlugin.configs['flat/recommended'],
jestPlugin.configs['flat/style'],
// Project-wide config
{
files: ['**/*.{ts,tsx,js}'],
languageOptions: {
ecmaVersion: 2022,
sourceType: 'module',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
globals: {
...globals.browser,
...globals.node,
...globals.jest,
...globals.es2021,
},
},
settings: {
react: {
pragma: 'React',
version: 'detect',
},
},
plugins: {
'unused-imports': unusedImports,
},
rules: {
'react/prop-types': 'off',
'react/display-name': 'warn',
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/array-type': ['error', { default: 'array' }],
'@typescript-eslint/no-restricted-types': [
'error',
{
types: {
Array:
'Use a typed array instead, e.g. string[] or Array<string>',
},
},
],
'no-return-await': 'warn',
'no-trailing-spaces': ['error', { ignoreComments: true }],
'no-fallthrough': 'error',
'jest/valid-expect': ['error', { maxArgs: 2 }],
'jest/require-top-level-describe': 'error',
'@typescript-eslint/no-unused-vars': 'off',
'unused-imports/no-unused-imports': 'warn',
'unused-imports/no-unused-vars': [
'warn',
{ argsIgnorePattern: '^_', ignoreRestSiblings: true },
],
'jest/no-commented-out-tests': 'warn',
'@typescript-eslint/no-explicit-any': 'warn',
'no-console': 'warn',
'@typescript-eslint/explicit-module-boundary-types': 'warn',
'@typescript-eslint/explicit-function-return-type': [
'warn',
{ allowExpressions: true },
],
'@typescript-eslint/consistent-type-definitions': ['error', 'interface'],
curly: ['warn', 'all'],
eqeqeq: ['error', 'allow-null'],
'spaced-comment': ['error', 'always'],
},
},
// Unit tests — relaxed rules
{
files: ['**/*.{spec,test}.{ts,tsx}', '**/tests/**'],
rules: {
'no-console': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
},
},
// Libraries — stricter rules
{
files: ['libs/**'],
rules: {
'@typescript-eslint/explicit-module-boundary-types': 'error',
},
},
// JS files — allow require, no return type
{
files: ['**/*.js'],
rules: {
'@typescript-eslint/no-require-imports': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
},
},
// Prettier must be last
eslintConfigPrettier,
];