-
Notifications
You must be signed in to change notification settings - Fork 100
/
eslint.config.mjs
128 lines (127 loc) · 3.38 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
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
import js from '@eslint/js';
import ts from 'typescript-eslint';
import reactPlugin from 'eslint-plugin-react';
import importPlugin from 'eslint-plugin-import';
import prettierConfigPlugin from 'eslint-config-prettier';
import reactHooksPlugin from 'eslint-plugin-react-hooks';
export default ts.config(
{
files: ['src/**/*.{ts,tsx}'],
extends: [
// recommended rules for JavaScript
js.configs.recommended,
// recommended rules for TypeScript, overrides some of the recommended rules for JavaScript
...ts.configs.recommended,
// recommended rules for React
reactPlugin.configs.flat.recommended,
// supports (ES6+) import/ export syntax (e.g. query strings
importPlugin.flatConfigs.recommended,
// disables rules that conflict with Prettier formatting
prettierConfigPlugin,
],
plugins: {
// JSX parsing
react: reactPlugin,
// ensure all hook dependencies are listed in the dependency array
'react-hooks': reactHooksPlugin,
},
languageOptions: {
parserOptions: {
projectService: true,
},
},
settings: {
paths: ['src'],
files: ['src/**/*.{ts,tsx}'],
react: {
version: '18.3.1',
},
'import/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx'],
},
'import/resolver': {
node: {
paths: ['src'],
extensions: ['.ts', '.tsx'],
},
typescript: {
project: './tsconfig.json',
},
},
},
rules: {
...reactHooksPlugin.configs.recommended.rules,
'no-restricted-syntax': [
'error',
{
selector: 'ExportDefaultDeclaration',
message: 'Use named exports only',
},
],
'no-restricted-imports': [
'error',
{
paths: [
{
name: 'lodash',
message: 'Use lodash-es instead',
},
{
name: 'react',
importNames: ['default'],
message: 'Use named imports only for React',
},
{
name: 'bignumber.js',
importNames: ['default'],
message: 'Use named imports only for bignumber.js',
},
],
patterns: [
{
group: ['lodash/*'],
message: 'Use lodash-es instead',
},
],
},
],
'no-mixed-operators': 'off',
'@typescript-eslint/no-inferrable-types': 'off',
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
},
],
'@typescript-eslint/no-non-null-assertion': 'off',
'react/jsx-no-target-blank': [
'error',
{
allowReferrer: true,
},
],
'react/display-name': 'warn',
'react/prop-types': 'off',
'react/react-in-jsx-scope': 'off',
'react/no-children-prop': 'off',
'react-hooks/exhaustive-deps': 'warn',
},
},
{
ignores: [
'.git/',
'.github/',
'.idea/',
'.vscode/',
'build/',
'node_modules/',
'public/',
'scripts/',
'*.*',
],
}
);