-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy path.eslintrc.cjs
120 lines (106 loc) · 3.1 KB
/
.eslintrc.cjs
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
/*
* "Note that ESLint does not support ESM configuration at this time."
* ref: https://eslint.org/docs/latest/use/configure/configuration-files
*/
module.exports = {
settings: {
react: {
version: "detect",
},
},
env: {
browser: true,
node: true,
es2020: true,
},
overrides: [
{
files: ['**/*.test.js'],
env: {
jest: true, // now **/*.test.js files' env has both es6 *and* jest
},
// Can't extend in overrides: https://github.com/eslint/eslint/issues/8813
// "extends": ["plugin:jest/recommended"]
plugins: ['jest'],
rules: {
'jest/no-disabled-tests': 'off',
'jest/no-focused-tests': 'error',
'jest/no-identical-title': 'error',
'jest/prefer-to-have-length': 'warn',
'jest/valid-expect': 'error',
'jest/no-commented-out-tests': 'off',
},
},
{
files: ['**/*.{ts,tsx}'],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
parserOptions: {
project: './tsconfig.json',
},
rules: {
'no-use-before-define': 'off',
'@typescript-eslint/no-use-before-define': 'error',
'arrow-body-style': 'off',
},
},
],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react/recommended',
"plugin:jsx-a11y/recommended",
'plugin:react/jsx-runtime',
'prettier',
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 12,
sourceType: 'module',
project: './tsconfig.json',
},
plugins: ['react', 'jest', '@typescript-eslint'],
rules: {
'linebreak-style': ['error', 'unix'],
'@typescript-eslint/no-unused-vars': ['error', { varsIgnorePattern: '^_', argsIgnorePattern: '^_' }],
"@typescript-eslint/no-explicit-any": "off",
// 2 space indentation
'indent': ['error', 2],
// Style
'quotes': ['error', 'single', { avoidEscape: true }],
// Cannot import from the same module twice
'no-duplicate-imports': ['error'],
// Cannot shadow names
'no-shadow': ['error'],
// Required spacing in property declarations (copied from TSLint, defaults are good)
'key-spacing': ['error'],
// Require semicolons
'semi': ['error', 'always'],
// Don't unnecessarily quote properties
'quote-props': ['error', 'consistent-as-needed'],
// No multiple empty lines
'no-multiple-empty-lines': ['error'],
// Max line lengths
'max-len': [
'error',
{
code: 120,
ignoreUrls: true, // Most common reason to disable it
ignoreStrings: true, // These are not fantastic but necessary for error messages
ignoreTemplateLiterals: true,
ignoreRegExpLiterals: true,
},
],
// Useless diff results
'no-trailing-spaces': ['error'],
// Must use foo.bar instead of foo['bar'] if possible
'dot-notation': ['error'],
// Are you sure | is not a typo for || ?
'no-bitwise': ['error'],
// Not enforcing props validation for React
'react/prop-types': 'off',
},
};