-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eslintrc.js
171 lines (170 loc) · 6.2 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
170
171
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
parser: '@babel/eslint-parser',
ecmaVersion: 2020, // 支援 ECMAScript2020
sourceType: 'module', // 使用 ECMAScript ****module
ecmaFeatures: {
jsx: true, // 支援 JSX
experimentalObjectRestSpread: true,
},
project: './tsconfig.eslint.json',
},
// 加上 ts 相關規則
overrides: [
{
files: ['*.ts', '*.tsx', '**/*.ts', '**/*.tsx'],
extends: [
'airbnb',
'airbnb-typescript',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:import/recommended',
],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
rules: {
camelcase: ['error', { properties: 'never' }],
'object-curly-newline': 'off',
'react/jsx-props-no-spreading': 'off',
'no-console': 'error',
'no-restricted-imports': ['error', { patterns: ['..*'] }],
'tailwindcss/no-contradicting-classname': 'error',
'tailwindcss/classnames-order': 'off',
'tailwindcss/enforces-negative-arbitrary-values': 'error',
'tailwindcss/enforces-shorthand': 'off',
'tailwindcss/migration-from-tailwind-2': 'error',
'tailwindcss/no-arbitrary-value': 'error',
'tailwindcss/no-custom-classname': 'warn',
'react/react-in-jsx-scope': 'off',
'max-len': 'off',
'jsx-a11y/click-events-have-key-events': 'off',
'jsx-a11y/no-static-element-interactions': 'off',
'jsx-a11y/no-noninteractive-element-interactions': 'off',
'operator-linebreak': 'off',
'prefer-template': 'off',
'react/jsx-one-expression-per-line': 'off',
'jsx-a11y/control-has-associated-label': 'off',
// 'arrow-parens': 'off',
'react/self-closing-comp': 'off',
'react/function-component-definition': 'off',
'arrow-body-style': 'off',
'@typescript-eslint/indent': 'off',
'@typescript-eslint/comma-dangle': 'off',
'react/jsx-curly-brace-presence': 'off',
'import/prefer-default-export': 'off',
'@typescript-eslint/quotes': 'off',
// 關閉 Airbnb 排版相關的規則
'react/jsx-closing-bracket-location': 'off',
'react/jsx-closing-tag-location': 'off',
'react/jsx-curly-spacing': 'off',
'react/jsx-equals-spacing': 'off',
'react/jsx-first-prop-new-line': 'off',
'react/jsx-indent': 'off',
'react/jsx-indent-props': 'off',
'react/jsx-max-props-per-line': 'off',
'react/jsx-tag-spacing': 'off',
'react/jsx-wrap-multilines': 'off',
'no-else-return': 'off',
'import/no-extraneous-dependencies': [
'error',
{ devDependencies: false, optionalDependencies: false, peerDependencies: false },
],
'no-nested-ternary': 'off',
'react/require-default-props': 'off',
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'function',
format: ['camelCase', 'PascalCase'],
leadingUnderscore: 'allow',
},
],
'implicit-arrow-linebreak': 'off',
'react/no-is-mounted': 'off',
},
},
],
extends: [
'airbnb',
'airbnb-typescript',
'plugin:import/typescript',
'plugin:tailwindcss/recommended',
'plugin:@next/next/recommended',
'plugin:react/recommended',
],
rules: {
camelcase: ['error', { properties: 'never' }],
'object-curly-newline': 'off',
'react/jsx-props-no-spreading': 'off',
'no-console': 'error',
'no-restricted-imports': ['error', { patterns: ['..*'] }],
'tailwindcss/no-contradicting-classname': 'error',
'tailwindcss/classnames-order': 'off',
'tailwindcss/enforces-negative-arbitrary-values': 'error',
'tailwindcss/enforces-shorthand': 'off',
'tailwindcss/migration-from-tailwind-2': 'error',
'tailwindcss/no-arbitrary-value': 'error',
'tailwindcss/no-custom-classname': 'warn',
'react/react-in-jsx-scope': 'off',
'max-len': 'off',
'jsx-a11y/click-events-have-key-events': 'off',
'jsx-a11y/no-static-element-interactions': 'off',
'jsx-a11y/no-noninteractive-element-interactions': 'off',
'operator-linebreak': 'off',
'prefer-template': 'off',
'react/jsx-one-expression-per-line': 'off',
'jsx-a11y/control-has-associated-label': 'off',
// 'arrow-parens': 'off',
'react/self-closing-comp': 'off',
'react/function-component-definition': 'off',
'arrow-body-style': 'off',
'@typescript-eslint/indent': 'off',
'@typescript-eslint/comma-dangle': 'off',
'react/jsx-curly-brace-presence': 'off',
'import/prefer-default-export': 'off',
'@typescript-eslint/quotes': 'off',
// 關閉 Airbnb 排版相關的規則
'react/jsx-closing-bracket-location': 'off',
'react/jsx-closing-tag-location': 'off',
'react/jsx-curly-spacing': 'off',
'react/jsx-equals-spacing': 'off',
'react/jsx-first-prop-new-line': 'off',
'react/jsx-indent': 'off',
'react/jsx-indent-props': 'off',
'react/jsx-max-props-per-line': 'off',
'react/jsx-tag-spacing': 'off',
'react/jsx-wrap-multilines': 'off',
'no-nested-ternary': 'off',
'react/require-default-props': 'off',
'no-eval': 'error',
'no-new-func': 'error',
'react/no-is-mounted': 'off',
},
// 整合 prettier 和解決 prettier 衝突問題
plugins: ['tailwindcss', '@babel', 'prettier', 'react'],
settings: {
tailwindcss: {
// These are the default values but feel free to customize
callees: ['classnames', 'clsx', 'ctl'],
config: 'tailwind.config.ts',
cssFiles: ['**/*.css', '!**/node_modules', '!**/.*', '!**/dist', '!**/build'],
cssFilesRefreshRate: '5_000',
removeDuplicates: true,
whitelist: [],
},
react: {
version: 'detect',
},
'import/resolver': {
node: {
extensions: ['.js', '.jsx', '.ts', '.tsx'],
},
typescript: {
project: 'tsconfig.json',
},
},
},
// 讓 eslint 知道我們在使用 jest ,這樣在跑 test.js 時 eslint 就不會報 jest 關鍵字的錯誤了
env: { browser: true, node: true, es6: true, jest: true },
};