forked from nusmodifications/nusmods
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.js
126 lines (103 loc) · 3.12 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
const warnInDevelopment = process.env.NODE_ENV === 'production' ? 'error' : 'warn';
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: './tsconfig.json',
},
root: true,
extends: ['airbnb', 'prettier', 'prettier/react'],
env: {
browser: true,
},
plugins: ['@typescript-eslint', 'prettier', 'import', 'jsx-a11y', 'react'],
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,
'no-alert': 'off',
'prefer-destructuring': 'off',
'import/extensions': [
warnInDevelopment,
'always',
{
js: 'never',
jsx: 'never',
ts: 'never',
tsx: 'never',
},
],
// Allow properties that are logically grouped together to be written
// without line breaks
'lines-between-class-members': 'off',
// Enable i++ in for loops
'no-plusplus': ['error', { allowForLoopAfterthoughts: true }],
'no-bitwise': 'off',
'react/no-array-index-key': 'off',
// SEE: https://github.com/yannickcr/eslint-plugin-react/issues
'react/no-unused-prop-types': 'off',
// Enables typing to be placed above lifecycle
'react/sort-comp': [
warnInDevelopment,
{
order: [
'type-annotations',
'instance-variables',
'static-methods',
'lifecycle',
'/^on.+$/',
'everything-else',
'render',
],
},
],
'react/require-default-props': 'off',
'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',
// TODO: Fix this
'react/no-access-state-in-setstate': 'warn',
// TODO: Replace divs with buttons, but remove all button styling.
'jsx-a11y/no-static-element-interactions': 'off',
// 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',
},
};