-
Notifications
You must be signed in to change notification settings - Fork 17
/
eslint.config.mjs
112 lines (109 loc) · 2.86 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
import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
// Import the necessary plugins and parser
import eslintPluginReact from 'eslint-plugin-react';
import eslintPluginReactHooks from 'eslint-plugin-react-hooks';
import eslintPluginPrettier from 'eslint-plugin-prettier';
const cfg = tseslint.config(
{
files: ['src/**/*.ts', 'src/**/*.tsx'],
},
eslint.configs.recommended,
...tseslint.configs.recommended,
{
files: ['src/**/*.ts', 'src/**/*.tsx'],
languageOptions: {
globals: {
window: 'readonly',
document: 'readonly',
console: 'readonly',
module: 'readonly',
require: 'readonly',
process: 'readonly',
},
},
plugins: {
react: eslintPluginReact,
'react-hooks': eslintPluginReactHooks,
},
rules: {
'@typescript-eslint/method-signature-style': [1, 'property'],
'@typescript-eslint/no-empty-function': 0,
'@typescript-eslint/no-explicit-any': 1, // TODO remove one day
'@typescript-eslint/no-use-before-define': 0,
'array-callback-return': 1,
curly: [1, 'all'],
eqeqeq: [1, 'allow-null'],
'no-else-return': 1,
'no-implicit-coercion': [
1,
{
boolean: false,
disallowTemplateShorthand: true,
},
],
'no-lonely-if': 1,
'no-new-object': 1,
'no-new-wrappers': 1,
'no-param-reassign': 1,
'no-return-assign': 1,
'no-unneeded-ternary': 1,
'no-unused-expressions': 1,
'object-shorthand': [1, 'always'],
'padding-line-between-statements': [
1,
{
blankLine: 'always',
next: '*',
prev: '*',
},
{
blankLine: 'any',
next: '*',
prev: 'import',
},
{
blankLine: 'any',
next: '*',
prev: 'export',
},
],
'prefer-arrow-callback': 'warn',
'prefer-spread': 'warn',
// 'no-console': 'warn',
'react-hooks/exhaustive-deps': 'warn',
'react-hooks/rules-of-hooks': 'warn',
'react/function-component-definition': 'warn',
'react/jsx-boolean-value': 'warn',
'react/jsx-curly-brace-presence': 'warn',
'react/jsx-fragments': 'warn',
'react/jsx-handler-names': 'warn',
'react/jsx-no-constructed-context-values': 'warn',
'react/jsx-no-useless-fragment': 'warn',
'react/prop-types': 'off',
'react/react-in-jsx-scope': 'off',
'react/self-closing-comp': [
1,
{
component: true,
html: true,
},
],
'@typescript-eslint/no-require-imports': 'off',
},
settings: {
react: {
version: 'detect',
},
},
},
{
plugins: {
prettier: eslintPluginPrettier,
},
rules: {
'prettier/prettier': 'error',
},
},
);
export default cfg;