forked from nusmodifications/nusmods
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.js
129 lines (103 loc) · 3.38 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
const warnInDevelopment = process.env.NODE_ENV === 'production' ? 'error' : 'warn';
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
tsconfigRootDir: __dirname,
project: 'tsconfig.json',
},
root: true,
extends: ['airbnb', 'prettier', 'prettier/react'],
plugins: ['@typescript-eslint', 'prettier', 'import', 'jsx-a11y', 'react', 'react-hooks'],
settings: {
'import/resolver': {
webpack: {
config: 'webpack/webpack.config.common.js',
},
},
'import/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx'],
},
},
rules: {
'prettier/prettier': warnInDevelopment,
// Allow debugger and console statement in development
'no-debugger': warnInDevelopment,
'no-console': warnInDevelopment,
'import/extensions': [
warnInDevelopment,
'always',
{
js: 'never',
jsx: 'never',
ts: 'never',
tsx: 'never',
},
],
// Enable i++ in for loops
'no-plusplus': ['error', { allowForLoopAfterthoughts: true }],
'react/no-unescaped-entities': 'off',
'react/no-array-index-key': 'off',
// Enables typing to be placed above lifecycle
'react/sort-comp': [
warnInDevelopment,
{
order: [
'type-annotations',
'instance-variables',
'static-methods',
'lifecycle',
'/^on.+$/',
'everything-else',
'render',
],
},
],
// These lints are not useful
'react/jsx-props-no-spreading': 'off',
'react/state-in-constructor': 'off',
// Defaults to outside, which is pretty ugly
'react/static-property-placement': ['error', 'static public field'],
'react/jsx-filename-extension': ['error', { extensions: ['.tsx', '.jsx'] }],
'react/default-props-match-prop-types': ['error', { allowRequiredDefaults: true }],
// TypeScript lints this for us
'react/prop-types': 'off',
// Too verbose, creates too many variables
'react/destructuring-assignment': 'off',
'react-hooks/rules-of-hooks': 'error', // Checks rules of Hooks
'react-hooks/exhaustive-deps': 'warn', // Checks effect dependencies
// Unnecessary with JSX transform
'react/react-in-jsx-scope': 'off',
// TODO: Replace divs with buttons, but remove all button styling.
'jsx-a11y/no-static-element-interactions': 'off',
// Seem to be triggering on th, so setting to warn for now
// TODO: Wait for https://github.com/evcohen/eslint-plugin-jsx-a11y/issues/637
'jsx-a11y/control-has-associated-label': 'warn',
// The default option requires BOTH id and nesting, which is excessive,
// especially with checkboxes and radiobuttons. This changes it to EITHER
'jsx-a11y/label-has-for': [
'error',
{
required: {
some: ['nesting', 'id'],
},
},
],
// Link fails this rule as it has no "href" prop.
'jsx-a11y/anchor-is-valid': [
'error',
{
components: ['Link'],
specialLink: ['to'],
},
],
// Rule appear to be buggy when used with @typescript-eslint/parser
'jsx-a11y/label-has-associated-control': 'off',
// For use with immer
'no-param-reassign': [
'error',
{ props: true, ignorePropertyModificationsFor: ['draft', 'draftState'] },
],
// Let git handle the linebreaks instead.
'linebreak-style': 'off',
},
};