-
Notifications
You must be signed in to change notification settings - Fork 20
/
.eslintrc.js
180 lines (158 loc) · 6.19 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
172
173
174
175
176
177
178
179
180
// @ts-check
/** @type {import('eslint').Linter.Config} */
const config = {
parser: '@typescript-eslint/parser',
parserOptions: {},
extends: [
// /!\ Order matters: the next one overrides rules from the previous one
'plugin:jest/recommended',
'plugin:unicorn/recommended',
'airbnb',
// Already done by Airbnb
//'plugin:react/recommended'
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended'
],
plugins: ['simple-import-sort', 'react-hooks'],
env: {
browser: true
},
globals: {},
rules: {
'no-console': ['error', { allow: ['error', 'info'] }],
'no-alert': 'off',
'no-underscore-dangle': 'off',
'no-plusplus': 'off',
'lines-between-class-members': 'off',
'spaced-comment': 'off',
'no-lonely-if': 'off',
'max-classes-per-file': 'off',
// [no-return-assign should be configurable to ignore arrow-functions](https://github.com/eslint/eslint/issues/9471)
'no-return-assign': 'off',
camelcase: 'off',
'prettier/prettier': 'error',
'import/no-extraneous-dependencies': 'off',
'import/no-unresolved': 'off',
// [Avoid Export Default](https://basarat.gitbook.io/typescript/main-1/defaultisbad)
'import/prefer-default-export': 'off',
'import/extensions': 'off',
'simple-import-sort/imports': [
'error',
{
// https://github.com/lydell/eslint-plugin-simple-import-sort/blob/v7.0.0/src/imports.js#L5
groups: [
// Side effect imports
['^\\u0000'],
// Packages
[
// React first
'^react$',
// Things that start with a letter (or digit or underscore), or `@` followed by a letter
'^@?\\w'
],
// Absolute imports and other imports such as Vue-style `@/foo`
// Anything not matched in another group
['^'],
// Relative imports
[
// https://github.com/lydell/eslint-plugin-simple-import-sort/issues/15
// ../whatever/
'^\\.\\./(?=.*/)',
// ../
'^\\.\\./',
// ./whatever/
'^\\./(?=.*/)',
// Anything that starts with a dot
'^\\.',
// .html are not side effect imports
'^.+\\.html$',
// .scss/.css are not side effect imports
'^.+\\.s?css$'
]
]
}
],
'simple-import-sort/exports': 'error',
// https://github.com/typescript-eslint/typescript-eslint/blob/v4.1.0/packages/eslint-plugin/docs/rules/no-use-before-define.md
'no-use-before-define': 'off',
'@typescript-eslint/no-use-before-define': 'error',
// https://github.com/typescript-eslint/typescript-eslint/blob/v4.1.0/packages/eslint-plugin/docs/rules/no-shadow.md
'no-shadow': 'off',
'@typescript-eslint/no-shadow': 'error',
// https://github.com/typescript-eslint/typescript-eslint/blob/v4.5.0/packages/eslint-plugin/docs/rules/no-empty-function.md
'no-empty-function': 'off',
'@typescript-eslint/no-empty-function': 'error',
// https://github.com/typescript-eslint/typescript-eslint/blob/v4.5.0/packages/eslint-plugin/docs/rules/no-useless-constructor.md
'no-useless-constructor': 'off',
'@typescript-eslint/no-useless-constructor': 'error',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/camelcase': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/ban-ts-ignore': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'unicorn/filename-case': 'off',
'unicorn/prevent-abbreviations': 'off',
'unicorn/catch-error-name': 'off',
// [IE does not support for...of](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of#Browser_compatibility)
'unicorn/no-for-loop': 'off',
'unicorn/no-null': 'off',
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v27.0.0/docs/rules/no-array-for-each.md
// https://github.com/github/eslint-plugin-github/blob/v4.1.1/docs/rules/array-foreach.md
// conflicts with
// https://github.com/airbnb/javascript/issues/1271
'unicorn/no-array-for-each': 'off',
// FIXME Activate when ES modules are well supported
'unicorn/prefer-module': 'off',
'unicorn/prefer-query-selector': 'off',
'unicorn/numeric-separators-style': 'off',
'unicorn/no-await-expression-member': 'off',
'jsx-a11y/label-has-associated-control': 'off',
'react/no-unescaped-entities': 'off',
'react/jsx-filename-extension': ['error', { extensions: ['.tsx', '.jsx'] }],
'react/jsx-uses-react': 'off',
'react/react-in-jsx-scope': 'off',
// FIXME https://github.com/yannickcr/eslint-plugin-react/issues/3114#issuecomment-951725512
'react/jsx-no-bind': 'off',
'react/jsx-pascal-case': 'off',
'react/jsx-props-no-spreading': 'off',
'react/static-property-placement': 'off',
'react/state-in-constructor': 'off',
'react/no-unused-class-component-methods': 'off',
'react/no-unstable-nested-components': 'off',
'react/require-default-props': 'off',
'react/default-props-match-prop-types': 'off',
'react/no-unused-prop-types': 'off',
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'error',
'jest/expect-expect': 'off'
},
// FIXME ?
// [Support for mixed JS and TS codebases - do not lint JS files](https://github.com/typescript-eslint/typescript-eslint/issues/109)
// [typescript/no-var-requires should only be enabled on ts/tsx files](https://github.com/Shopify/eslint-plugin-shopify/issues/159)
overrides: [
{
files: ['*.js'],
rules: {
'@typescript-eslint/no-var-requires': 'off'
}
},
{
files: ['examples/*/*.tsx'],
rules: {
'react/require-default-props': 'off'
}
},
{
files: ['*.test.ts', '*.test.tsx'],
rules: {
'unicorn/consistent-function-scoping': 'off',
'jsx-a11y/iframe-has-title': 'off'
}
}
]
};
module.exports = config;