-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.js
169 lines (168 loc) · 4.34 KB
/
.eslintrc.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
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
const propTypeSortOrder = {
callbacksLast: false,
ignoreCase: false,
noSortAlphabetically: false,
};
module.exports = {
env: {
browser: true,
es2020: true,
jest: true,
node: true,
},
extends: [
'airbnb-typescript',
'plugin:react/recommended',
'plugin:@typescript-eslint/recommended',
'plugin:compat/recommended',
// NOTE: This has to come last
'plugin:prettier/recommended',
'next/core-web-vitals'
],
globals: {
JSX: 'readonly',
},
ignorePatterns: [
'next.config.js',
'.eslintrc.js',
],
plugins: ['@typescript-eslint', 'import', 'react', 'jest', 'prettier', 'react-hooks'],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 2020,
impliedStrict: true,
project: './tsconfig.json',
sourceType: 'module',
},
rules: {
'arrow-body-style': ['error', 'as-needed'],
'class-methods-use-this': 'off',
curly: ['error', 'multi'],
'func-style': ['error', 'expression', { allowArrowFunctions: true }],
'jest/consistent-test-it': ['error', { fn: 'it' }],
'import/extensions': [
'error',
'ignorePackages',
{
js: 'never',
jsx: 'never',
ts: 'never',
tsx: 'never',
},
],
'import/order': [
'error',
{
'newlines-between': 'always',
alphabetize: {
order: 'asc',
caseInsensitive: false,
},
},
],
'import/no-default-export': 'error',
'import/no-extraneous-dependencies': ['error', { devDependencies: true }],
'import/prefer-default-export': 'off',
'max-classes-per-file': 'off',
'max-len': [
'error',
{
code: 100,
comments: 80,
ignoreUrls: true,
ignoreStrings: true,
ignoreTemplateLiterals: true,
ignoreRegExpLiterals: true,
ignorePattern: 'eslint-disable+',
},
],
'no-undef': 'error',
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': ['warn', { ignoreRestSiblings: true }],
quotes: ['error', 'single', { allowTemplateLiterals: true }],
'react/boolean-prop-naming': ['error', { rule: '^(is|has|can)[A-Z]([A-Za-z0-9]?)+' }],
'react/button-has-type': ['error', { reset: false }],
'react/function-component-definition': [
'error',
{
namedComponents: 'arrow-function',
unnamedComponents: 'arrow-function',
},
],
'react/jsx-filename-extension': 'off',
'react/jsx-handler-names': 'error',
'react/jsx-sort-props': [
'error',
{
...propTypeSortOrder,
shorthandFirst: false,
shorthandLast: false,
reservedFirst: false,
},
],
'react/prop-types': 'off',
'react/require-default-props': 'off',
'react/sort-prop-types': [
'error',
{
...propTypeSortOrder,
requiredFirst: true,
sortShapeProp: true,
},
],
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'error',
'@typescript-eslint/explicit-function-return-type': 'error',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/member-ordering': ['error', { default: { order: 'alphabetically' } }],
'@typescript-eslint/no-explicit-any': ['error', { ignoreRestArgs: true }],
'no-console': ['warn', { allow: ['warn', 'error', 'debug'] }],
'react/react-in-jsx-scope': ['off'],
'prettier/prettier': ['warn']
},
overrides: [
{
files: ['*.js'],
rules: {
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
},
},
{
files: ['*.ts', '*.tsx'],
rules: {
'@typescript-eslint/explicit-module-boundary-types': ['error'],
},
},
{
files: ['*.d.ts', '*.stories.tsx', '.storybook/**/*'],
rules: {
'import/no-default-export': 'off',
},
},
{
files: ['*.test.tsx', '*.stories.tsx'],
rules: {
'react/jsx-props-no-spreading': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
},
},
{
files: ['pages/**/*.tsx', 'pages/**/*.ts'],
rules: {
'import/no-default-export': 'off'
}
}
],
settings: {
'import/resolver': {
typescript: {},
},
react: {
version: 'detect',
},
},
};