-
Notifications
You must be signed in to change notification settings - Fork 15
/
.eslintrc.cjs
127 lines (118 loc) · 3.48 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
121
122
123
124
125
126
127
'use strict';
module.exports = {
extends: ['airbnb', 'airbnb/hooks', 'plugin:import/typescript'],
plugins: ['compat', 'react-hooks'],
parserOptions: {
ecmaVersion: 2022,
},
rules: {
// Makes no sense
'max-classes-per-file': 'off',
'arrow-body-style': 'off',
'no-underscore-dangle': ['error', { allow: ['_id'] }],
// Modify eslint-config-airbnb's rule to allow ForOfStatement
'no-restricted-syntax': [
'error',
{
selector: 'ForInStatement',
message: 'for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array.',
},
{
selector: 'LabeledStatement',
message: 'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.',
},
{
selector: 'WithStatement',
message: '`with` is disallowed in strict mode because it makes code impossible to predict and optimize.',
},
],
'import/no-extraneous-dependencies': ['error', { devDependencies: true }],
'import/extensions': ['error', 'ignorePackages', {
js: 'never',
mjs: 'never',
jsx: 'never',
ts: 'never',
tsx: 'never',
}],
// Not true anymore
'react/react-in-jsx-scope': 'off',
'react/no-unused-prop-types': ['error', { skipShapeProps: true }],
'react/forbid-prop-types': 'off',
'react/jsx-props-no-spreading': 'off',
'react/require-default-props': 'off',
'react/static-property-placement': 'off',
'react/jsx-one-expression-per-line': 'off',
'react/function-component-definition': ['off', {
namedComponents: 'function-declaration',
unnamedComponents: 'arrow-function',
}],
'react/jsx-filename-extension': ['error', { extensions: ['.jsx', '.tsx'] }],
'jsx-a11y/control-has-associated-label': [
'warn',
require('eslint-config-airbnb/rules/react-a11y')
.rules['jsx-a11y/control-has-associated-label'][1],
],
},
settings: {
polyfills: [
'Array.from',
'Number.isFinite',
'Number.isNaN',
'Object.assign',
'Object.is',
'Object.values',
'Promise',
'AbortController',
'fetch',
'Headers',
'URL',
'CSS.escape',
],
'import/core-modules': [
'virtual:emoji-shortcodes',
],
},
overrides: [
{
files: ['**/*.{ts,tsx}'],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
extends: ['plugin:@typescript-eslint/recommended'],
},
{
files: ['src/reducers/*'],
rules: {
// Reducers use default params differently
'default-param-last': 'off',
'no-param-reassign': ['error', {
props: true,
ignorePropertyModificationsFor: ['state'],
}],
},
},
{
files: ['src/**/*.{js,jsx}'],
rules: {
'compat/compat': 'error',
},
},
{
files: ['tasks/**/*.{js,jsx}', '*.config.js', '.eslintrc.js', 'test/*.js'],
parserOptions: {
sourceType: 'script',
},
rules: {
strict: ['error', 'global'],
'no-console': 'off',
},
},
{
files: ['**/__tests__/**/*.{js,jsx}'],
plugins: ['eslint-plugin-vitest', 'eslint-plugin-jest-dom', 'eslint-plugin-testing-library'],
extends: ['plugin:vitest/recommended', 'plugin:jest-dom/recommended', 'plugin:testing-library/react'],
env: {
jest: true,
},
},
],
};