This repository has been archived by the owner on Jul 27, 2020. It is now read-only.
/
react.js
202 lines (186 loc) Β· 6.01 KB
/
react.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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
const OFF = 0, WARN = 1, ERROR = 2
const REACT_RULES = {
// React in general
// https://www.npmjs.com/package/eslint-plugin-react#list-of-supported-rules
'react/boolean-prop-naming': OFF,
'react/button-has-type': OFF,
'react/default-props-match-prop-types': OFF,
'react/destructuring-assignment': OFF,
'react/display-name': OFF,
'react/forbid-component-props': OFF,
'react/forbid-dom-props': OFF,
'react/forbid-elements': OFF,
'react/forbid-prop-types': OFF,
'react/forbid-foreign-prop-types': OFF,
'react/no-access-state-in-setstate': OFF,
'react/no-array-index-key': OFF,
'react/no-children-prop': OFF,
'react/no-danger': OFF,
'react/no-danger-with-children': OFF,
'react/no-did-mount-set-state': OFF,
'react/no-did-update-set-state': OFF,
'react/no-direct-mutation-state': OFF,
'react/no-find-dom-node': OFF,
'react/no-is-mounted': OFF,
'react/no-multi-comp': OFF,
'react/no-redundant-should-component-update': OFF,
'react/no-render-return-value': OFF,
'react/no-set-state': OFF,
'react/no-string-refs': OFF,
'react/no-this-in-sfc': OFF,
'react/no-unescaped-entities': OFF,
'react/no-unsafe': OFF,
'react/no-unused-state': OFF,
'react/no-will-update-set-state': OFF,
'react/prefer-es6-class': OFF,
'react/prefer-read-only-props': OFF,
'react/prefer-stateless-function': OFF,
'react/require-default-props': OFF,
'react/require-optimization': OFF,
'react/require-render-return': OFF,
'react/sort-comp': OFF,
'react/state-in-constructor': OFF,
'react/static-property-placement': OFF,
'react/no-unused-prop-types': WARN,
'react/no-deprecated': WARN,
'react/no-typos': WARN,
'react/react-in-jsx-scope': WARN,
'react/self-closing-comp': WARN,
'react/sort-prop-types': WARN,
'react/no-unknown-property': ERROR,
'react/prop-types': ERROR,
'react/style-prop-object': ERROR,
'react/void-dom-elements-no-children': ERROR,
// JSX related
// https://www.npmjs.com/package/eslint-plugin-react#jsx-specific-rules
'react/jsx-child-element-spacing': OFF,
'react/jsx-curly-newline': OFF,
'react/jsx-first-prop-new-line': OFF,
'react/jsx-filename-extension': OFF,
'react/jsx-no-literals': OFF,
'react/jsx-max-depth': OFF,
'react/jsx-max-props-per-line': OFF,
'react/jsx-one-expression-per-line': OFF,
'react/jsx-space-before-closing': OFF,
'react/jsx-handler-names': OFF,
'react/jsx-no-comment-textnodes': OFF,
'react/jsx-no-bind': OFF,
'react/jsx-no-undef': OFF,
'react/jsx-pascal-case': OFF,
'react/jsx-props-no-spreading': OFF,
'react/jsx-sort-default-props': OFF,
'react/jsx-curly-brace-presence': OFF,
'react/jsx-boolean-value': WARN,
'react/jsx-closing-bracket-location': [WARN, 'after-props'],
'react/jsx-closing-tag-location': WARN,
'react/jsx-curly-spacing': [WARN, { when: 'never' }],
'react/jsx-equals-spacing': [WARN, 'never'],
'react/jsx-fragments': [WARN, 'syntax'],
'react/jsx-indent': [WARN, 2, { checkAttributes: true, indentLogicalExpressions: true }],
'react/jsx-indent-props': [WARN, 2],
'react/jsx-key': WARN,
'react/jsx-uses-vars': WARN,
'react/jsx-props-no-multi-spaces': WARN,
'react/jsx-sort-props': [
WARN,
{
callbacksLast: true,
reservedFirst: true,
noSortAlphabetically: true
}
],
'react/jsx-tag-spacing': [
WARN,
{
closingSlash: 'never',
beforeSelfClosing: 'always',
afterOpening: 'never',
beforeClosing: 'never'
}
],
'react/jsx-wrap-multilines': [
WARN,
{
declaration: 'parens-new-line',
assignment: 'parens-new-line',
return: 'parens-new-line',
arrow: 'parens-new-line',
condition: 'parens-new-line',
logical: 'parens-new-line'
}
],
'react/jsx-no-duplicate-props': ERROR,
'react/jsx-no-target-blank': [ERROR, { 'enforceDynamicLinks': 'always' }],
'react/jsx-uses-react': ERROR,
}
const REACT_HOOKS_RULES = {
//https://www.npmjs.com/package/eslint-plugin-react-hooks#valid-and-invalid-examples
'react-hooks/exhaustive-deps': OFF,
'react-hooks/rules-of-hooks': ERROR
}
const JSX_A11Y_RULES = {
// https://www.npmjs.com/package/eslint-plugin-jsx-a11y#supported-rules
'jsx-a11y/anchor-is-valid': OFF,
'jsx-a11y/click-events-have-key-events': OFF,
'jsx-a11y/html-has-lang': OFF,
'jsx-a11y/interactive-supports-focus': OFF,
'jsx-a11y/label-has-associated-control': OFF,
'jsx-a11y/media-has-caption': OFF,
'jsx-a11y/mouse-events-have-key-events': OFF,
'jsx-a11y/no-autofocus': OFF,
'jsx-a11y/no-interactive-element-to-noninteractive-role': OFF,
'jsx-a11y/no-noninteractive-element-interactions': OFF,
'jsx-a11y/no-noninteractive-element-to-interactive-role': OFF,
'jsx-a11y/no-noninteractive-tabindex': OFF,
'jsx-a11y/no-onchange': OFF,
'jsx-a11y/no-static-element-interactions': OFF,
'jsx-a11y/tabindex-no-positive': OFF,
'jsx-a11y/accessible-emoji': ERROR,
'jsx-a11y/alt-text': ERROR,
'jsx-a11y/anchor-has-content': ERROR,
'jsx-a11y/aria-activedescendant-has-tabindex': ERROR,
'jsx-a11y/aria-props': ERROR,
'jsx-a11y/aria-proptypes': ERROR,
'jsx-a11y/aria-role': ERROR,
'jsx-a11y/aria-unsupported-elements': ERROR,
'jsx-a11y/heading-has-content': ERROR,
'jsx-a11y/iframe-has-title': ERROR,
'jsx-a11y/img-redundant-alt': ERROR,
'jsx-a11y/no-access-key': ERROR,
'jsx-a11y/no-distracting-elements': ERROR,
'jsx-a11y/no-redundant-roles': ERROR,
'jsx-a11y/role-has-required-aria-props': ERROR,
'jsx-a11y/role-supports-aria-props': ERROR,
'jsx-a11y/scope': ERROR,
}
const TYPESCRIPT_OVERRIDE = {
files: ['*.ts', '*.tsx'],
rules: {
'react/default-props-match-prop-types': OFF,
'react/forbid-prop-types': OFF,
'react/forbid-foreign-prop-types': OFF,
'react/no-unused-prop-types': OFF,
'react/sort-prop-types': OFF,
'react/prop-types': OFF,
}
}
module.exports = {
plugins: [
'react',
'react-hooks',
'jsx-a11y'
],
rules: {
...REACT_RULES,
...REACT_HOOKS_RULES,
...JSX_A11Y_RULES
},
overrides: [
TYPESCRIPT_OVERRIDE
],
'settings': {
'react': {
'version': 'detect'
}
}
}