@cabify/eslint-config 3.0.1-beta-16 → 3.0.1-beta-17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/configs/commonjs/base.cjs +65 -0
- package/configs/commonjs/best-practices.cjs +344 -0
- package/configs/commonjs/errors.cjs +122 -0
- package/configs/commonjs/es6.cjs +180 -0
- package/configs/commonjs/formats.cjs +6 -0
- package/configs/commonjs/imports.cjs +278 -0
- package/configs/commonjs/jest.cjs +9 -0
- package/configs/commonjs/lodash.cjs +9 -0
- package/configs/commonjs/node.cjs +40 -0
- package/configs/commonjs/postcss.cjs +7 -0
- package/configs/commonjs/promises.cjs +18 -0
- package/configs/commonjs/react-a11y.cjs +230 -0
- package/configs/commonjs/react.cjs +432 -0
- package/configs/commonjs/storybook.cjs +7 -0
- package/configs/commonjs/strict.cjs +7 -0
- package/configs/commonjs/style.cjs +319 -0
- package/configs/commonjs/ts.cjs +162 -0
- package/configs/commonjs/utils.cjs +11 -0
- package/configs/commonjs/variables.cjs +53 -0
- package/configs/{base.js → es6/base.js} +1 -1
- package/configs/es6/utils.js +11 -0
- package/package.json +7 -6
- package/recommended.cjs +5 -0
- package/recommended.js +1 -1
- package/utils.js +1 -1
- /package/configs/{best-practices.js → es6/best-practices.js} +0 -0
- /package/configs/{errors.js → es6/errors.js} +0 -0
- /package/configs/{es6.js → es6/es6.js} +0 -0
- /package/configs/{formats.js → es6/formats.js} +0 -0
- /package/configs/{imports.js → es6/imports.js} +0 -0
- /package/configs/{jest.js → es6/jest.js} +0 -0
- /package/configs/{lodash.js → es6/lodash.js} +0 -0
- /package/configs/{node.js → es6/node.js} +0 -0
- /package/configs/{postcss.js → es6/postcss.js} +0 -0
- /package/configs/{promises.js → es6/promises.js} +0 -0
- /package/configs/{react-a11y.js → es6/react-a11y.js} +0 -0
- /package/configs/{react.js → es6/react.js} +0 -0
- /package/configs/{storybook.js → es6/storybook.js} +0 -0
- /package/configs/{strict.js → es6/strict.js} +0 -0
- /package/configs/{style.js → es6/style.js} +0 -0
- /package/configs/{ts.js → es6/ts.js} +0 -0
- /package/configs/{variables.js → es6/variables.js} +0 -0
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
const jsxAllyPlugin = require('eslint-plugin-jsx-a11y');
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
name: 'react-a11y-cabify-eslint-config',
|
|
5
|
+
plugins: { 'jsx-a11y': jsxAllyPlugin },
|
|
6
|
+
languageOptions: {
|
|
7
|
+
parserOptions: {
|
|
8
|
+
ecmaFeatures: {
|
|
9
|
+
jsx: true,
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
rules: {
|
|
14
|
+
// Enforce that anchors have content
|
|
15
|
+
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-has-content.md
|
|
16
|
+
'jsx-a11y/anchor-has-content': ['error', { components: [] }],
|
|
17
|
+
|
|
18
|
+
// Require ARIA roles to be valid and non-abstract
|
|
19
|
+
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-role.md
|
|
20
|
+
'jsx-a11y/aria-role': ['error', { ignoreNonDom: false }],
|
|
21
|
+
|
|
22
|
+
// Enforce all aria-* props are valid.
|
|
23
|
+
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-props.md
|
|
24
|
+
'jsx-a11y/aria-props': 'error',
|
|
25
|
+
|
|
26
|
+
// Enforce ARIA state and property values are valid.
|
|
27
|
+
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-proptypes.md
|
|
28
|
+
'jsx-a11y/aria-proptypes': 'error',
|
|
29
|
+
|
|
30
|
+
// Enforce that elements that do not support ARIA roles, states, and
|
|
31
|
+
// properties do not have those attributes.
|
|
32
|
+
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-unsupported-elements.md
|
|
33
|
+
'jsx-a11y/aria-unsupported-elements': 'error',
|
|
34
|
+
|
|
35
|
+
// Enforce that all elements that require alternative text have meaningful information
|
|
36
|
+
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/alt-text.md
|
|
37
|
+
'jsx-a11y/alt-text': [
|
|
38
|
+
'error',
|
|
39
|
+
{
|
|
40
|
+
elements: ['img', 'object', 'area', 'input[type="image"]'],
|
|
41
|
+
img: [],
|
|
42
|
+
object: [],
|
|
43
|
+
area: [],
|
|
44
|
+
'input[type="image"]': [],
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
|
|
48
|
+
// Prevent img alt text from containing redundant words like "image", "picture", or "photo"
|
|
49
|
+
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/img-redundant-alt.md
|
|
50
|
+
'jsx-a11y/img-redundant-alt': 'error',
|
|
51
|
+
|
|
52
|
+
// require that JSX labels use "htmlFor"
|
|
53
|
+
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/label-has-for.md
|
|
54
|
+
// deprecated
|
|
55
|
+
'jsx-a11y/label-has-for': [
|
|
56
|
+
'off',
|
|
57
|
+
{
|
|
58
|
+
components: [],
|
|
59
|
+
required: {
|
|
60
|
+
every: ['nesting', 'id'],
|
|
61
|
+
},
|
|
62
|
+
allowChildren: false,
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
|
|
66
|
+
// Enforce that a label tag has a text label and an associated control.
|
|
67
|
+
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/b800f40a2a69ad48015ae9226fbe879f946757ed/docs/rules/label-has-associated-control.md
|
|
68
|
+
'jsx-a11y/label-has-associated-control': [
|
|
69
|
+
'error',
|
|
70
|
+
{
|
|
71
|
+
labelComponents: [],
|
|
72
|
+
labelAttributes: [],
|
|
73
|
+
controlComponents: [],
|
|
74
|
+
assert: 'both',
|
|
75
|
+
depth: 25,
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
|
|
79
|
+
// require that mouseover/out come with focus/blur, for keyboard-only users
|
|
80
|
+
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/mouse-events-have-key-events.md
|
|
81
|
+
'jsx-a11y/mouse-events-have-key-events': 'error',
|
|
82
|
+
|
|
83
|
+
// Prevent use of `accessKey`
|
|
84
|
+
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-access-key.md
|
|
85
|
+
'jsx-a11y/no-access-key': 'error',
|
|
86
|
+
|
|
87
|
+
// require onBlur instead of onChange
|
|
88
|
+
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-onchange.md
|
|
89
|
+
'jsx-a11y/no-onchange': 'off',
|
|
90
|
+
|
|
91
|
+
// Elements with an interactive role and interaction handlers must be focusable
|
|
92
|
+
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/interactive-supports-focus.md
|
|
93
|
+
'jsx-a11y/interactive-supports-focus': 'error',
|
|
94
|
+
|
|
95
|
+
// Enforce that elements with ARIA roles must have all required attributes
|
|
96
|
+
// for that role.
|
|
97
|
+
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/role-has-required-aria-props.md
|
|
98
|
+
'jsx-a11y/role-has-required-aria-props': 'error',
|
|
99
|
+
|
|
100
|
+
// Enforce that elements with explicit or implicit roles defined contain
|
|
101
|
+
// only aria-* properties supported by that role.
|
|
102
|
+
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/role-supports-aria-props.md
|
|
103
|
+
'jsx-a11y/role-supports-aria-props': 'error',
|
|
104
|
+
|
|
105
|
+
// Enforce tabIndex value is not greater than zero.
|
|
106
|
+
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/tabindex-no-positive.md
|
|
107
|
+
'jsx-a11y/tabindex-no-positive': 'error',
|
|
108
|
+
|
|
109
|
+
// ensure <hX> tags have content and are not aria-hidden
|
|
110
|
+
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/heading-has-content.md
|
|
111
|
+
'jsx-a11y/heading-has-content': ['error', { components: [''] }],
|
|
112
|
+
|
|
113
|
+
// require HTML elements to have a "lang" prop
|
|
114
|
+
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/html-has-lang.md
|
|
115
|
+
'jsx-a11y/html-has-lang': 'error',
|
|
116
|
+
|
|
117
|
+
// require HTML element's lang prop to be valid
|
|
118
|
+
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/lang.md
|
|
119
|
+
'jsx-a11y/lang': 'error',
|
|
120
|
+
|
|
121
|
+
// prevent distracting elements, like <marquee> and <blink>
|
|
122
|
+
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-distracting-elements.md
|
|
123
|
+
'jsx-a11y/no-distracting-elements': [
|
|
124
|
+
'error',
|
|
125
|
+
{
|
|
126
|
+
elements: ['marquee', 'blink'],
|
|
127
|
+
},
|
|
128
|
+
],
|
|
129
|
+
|
|
130
|
+
// only allow <th> to have the "scope" attr
|
|
131
|
+
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/scope.md
|
|
132
|
+
'jsx-a11y/scope': 'error',
|
|
133
|
+
|
|
134
|
+
// require onClick be accompanied by onKeyUp/onKeyDown/onKeyPress
|
|
135
|
+
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/click-events-have-key-events.md
|
|
136
|
+
'jsx-a11y/click-events-have-key-events': 'off',
|
|
137
|
+
|
|
138
|
+
// Enforce that DOM elements without semantic behavior not have interaction handlers
|
|
139
|
+
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-static-element-interactions.md
|
|
140
|
+
'jsx-a11y/no-static-element-interactions': 'off',
|
|
141
|
+
|
|
142
|
+
// A non-interactive element does not support event handlers (mouse and key handlers)
|
|
143
|
+
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-noninteractive-element-interactions.md
|
|
144
|
+
'jsx-a11y/no-noninteractive-element-interactions': 'off',
|
|
145
|
+
|
|
146
|
+
// ensure emoji are accessible
|
|
147
|
+
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/accessible-emoji.md
|
|
148
|
+
'jsx-a11y/accessible-emoji': 'error',
|
|
149
|
+
|
|
150
|
+
// elements with aria-activedescendant must be tabbable
|
|
151
|
+
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-activedescendant-has-tabindex.md
|
|
152
|
+
'jsx-a11y/aria-activedescendant-has-tabindex': 'error',
|
|
153
|
+
|
|
154
|
+
// ensure iframe elements have a unique title
|
|
155
|
+
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/iframe-has-title.md
|
|
156
|
+
'jsx-a11y/iframe-has-title': 'error',
|
|
157
|
+
|
|
158
|
+
// prohibit autoFocus prop
|
|
159
|
+
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-autofocus.md
|
|
160
|
+
'jsx-a11y/no-autofocus': ['error', { ignoreNonDOM: true }],
|
|
161
|
+
|
|
162
|
+
// ensure HTML elements do not specify redundant ARIA roles
|
|
163
|
+
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-redundant-roles.md
|
|
164
|
+
'jsx-a11y/no-redundant-roles': 'error',
|
|
165
|
+
|
|
166
|
+
// media elements must have captions
|
|
167
|
+
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/media-has-caption.md
|
|
168
|
+
'jsx-a11y/media-has-caption': [
|
|
169
|
+
'error',
|
|
170
|
+
{
|
|
171
|
+
audio: [],
|
|
172
|
+
video: [],
|
|
173
|
+
track: [],
|
|
174
|
+
},
|
|
175
|
+
],
|
|
176
|
+
|
|
177
|
+
// WAI-ARIA roles should not be used to convert an interactive element to non-interactive
|
|
178
|
+
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-interactive-element-to-noninteractive-role.md
|
|
179
|
+
'jsx-a11y/no-interactive-element-to-noninteractive-role': [
|
|
180
|
+
'error',
|
|
181
|
+
{
|
|
182
|
+
tr: ['none', 'presentation'],
|
|
183
|
+
},
|
|
184
|
+
],
|
|
185
|
+
|
|
186
|
+
// WAI-ARIA roles should not be used to convert a non-interactive element to interactive
|
|
187
|
+
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-noninteractive-element-to-interactive-role.md
|
|
188
|
+
'jsx-a11y/no-noninteractive-element-to-interactive-role': [
|
|
189
|
+
'error',
|
|
190
|
+
{
|
|
191
|
+
ul: [
|
|
192
|
+
'listbox',
|
|
193
|
+
'menu',
|
|
194
|
+
'menubar',
|
|
195
|
+
'radiogroup',
|
|
196
|
+
'tablist',
|
|
197
|
+
'tree',
|
|
198
|
+
'treegrid',
|
|
199
|
+
],
|
|
200
|
+
ol: [
|
|
201
|
+
'listbox',
|
|
202
|
+
'menu',
|
|
203
|
+
'menubar',
|
|
204
|
+
'radiogroup',
|
|
205
|
+
'tablist',
|
|
206
|
+
'tree',
|
|
207
|
+
'treegrid',
|
|
208
|
+
],
|
|
209
|
+
li: ['menuitem', 'option', 'row', 'tab', 'treeitem'],
|
|
210
|
+
table: ['grid'],
|
|
211
|
+
td: ['gridcell'],
|
|
212
|
+
},
|
|
213
|
+
],
|
|
214
|
+
|
|
215
|
+
// Tab key navigation should be limited to elements on the page that can be interacted with.
|
|
216
|
+
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-noninteractive-tabindex.md
|
|
217
|
+
'jsx-a11y/no-noninteractive-tabindex': 'off',
|
|
218
|
+
|
|
219
|
+
// ensure <a> tags are valid
|
|
220
|
+
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/0745af376cdc8686d85a361ce36952b1fb1ccf6e/docs/rules/anchor-is-valid.md
|
|
221
|
+
'jsx-a11y/anchor-is-valid': [
|
|
222
|
+
'off',
|
|
223
|
+
{
|
|
224
|
+
components: ['Link'],
|
|
225
|
+
specialLink: ['to'],
|
|
226
|
+
aspects: ['noHref', 'invalidHref', 'preferButton'],
|
|
227
|
+
},
|
|
228
|
+
],
|
|
229
|
+
},
|
|
230
|
+
};
|
|
@@ -0,0 +1,432 @@
|
|
|
1
|
+
const react = require('eslint-plugin-react');
|
|
2
|
+
const reactHooks = require('eslint-plugin-react-hooks');
|
|
3
|
+
|
|
4
|
+
module.exports = {
|
|
5
|
+
name: 'react-cabify-eslint-config',
|
|
6
|
+
plugins: {
|
|
7
|
+
react,
|
|
8
|
+
'react-hooks': reactHooks,
|
|
9
|
+
},
|
|
10
|
+
languageOptions: {
|
|
11
|
+
parserOptions: {
|
|
12
|
+
ecmaFeatures: {
|
|
13
|
+
jsx: true,
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
// View link below for react rules documentation
|
|
19
|
+
// https://github.com/yannickcr/eslint-plugin-react#list-of-supported-rules
|
|
20
|
+
rules: {
|
|
21
|
+
'class-methods-use-this': 'off',
|
|
22
|
+
|
|
23
|
+
// Prevent missing displayName in a React component definition
|
|
24
|
+
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/display-name.md
|
|
25
|
+
'react/display-name': ['off', { ignoreTranspilerName: false }],
|
|
26
|
+
|
|
27
|
+
// Forbid certain propTypes (any, array, object)
|
|
28
|
+
// https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/forbid-prop-types.md
|
|
29
|
+
'react/forbid-prop-types': [
|
|
30
|
+
'error',
|
|
31
|
+
{
|
|
32
|
+
forbid: ['any', 'array', 'object'],
|
|
33
|
+
checkContextTypes: true,
|
|
34
|
+
checkChildContextTypes: true,
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
|
|
38
|
+
// Forbid certain props on DOM Nodes
|
|
39
|
+
// https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/forbid-dom-props.md
|
|
40
|
+
'react/forbid-dom-props': ['off', { forbid: [] }],
|
|
41
|
+
|
|
42
|
+
// Enforce boolean attributes notation in JSX
|
|
43
|
+
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-boolean-value.md
|
|
44
|
+
'react/jsx-boolean-value': ['error', 'never', { always: [] }],
|
|
45
|
+
|
|
46
|
+
// Enforce event handler naming conventions in JSX
|
|
47
|
+
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-handler-names.md
|
|
48
|
+
'react/jsx-handler-names': [
|
|
49
|
+
'off',
|
|
50
|
+
{
|
|
51
|
+
eventHandlerPrefix: 'handle',
|
|
52
|
+
eventHandlerPropPrefix: 'on',
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
|
|
56
|
+
// Validate JSX has key prop when in array or iterator
|
|
57
|
+
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-key.md
|
|
58
|
+
'react/jsx-key': 'error',
|
|
59
|
+
|
|
60
|
+
// Prevent usage of .bind() in JSX props
|
|
61
|
+
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-bind.md
|
|
62
|
+
'react/jsx-no-bind': [
|
|
63
|
+
'error',
|
|
64
|
+
{
|
|
65
|
+
ignoreRefs: true,
|
|
66
|
+
allowArrowFunctions: true,
|
|
67
|
+
allowFunctions: false,
|
|
68
|
+
allowBind: false,
|
|
69
|
+
ignoreDOMComponents: true,
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
|
|
73
|
+
// Prevent duplicate props in JSX
|
|
74
|
+
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-duplicate-props.md
|
|
75
|
+
'react/jsx-no-duplicate-props': ['error', { ignoreCase: true }],
|
|
76
|
+
|
|
77
|
+
// Prevent usage of unwrapped JSX strings
|
|
78
|
+
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-literals.md
|
|
79
|
+
'react/jsx-no-literals': ['off', { noStrings: true }],
|
|
80
|
+
|
|
81
|
+
// Disallow undeclared variables in JSX
|
|
82
|
+
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-undef.md
|
|
83
|
+
'react/jsx-no-undef': 'error',
|
|
84
|
+
|
|
85
|
+
// Enforce PascalCase for user-defined JSX components
|
|
86
|
+
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-pascal-case.md
|
|
87
|
+
'react/jsx-pascal-case': [
|
|
88
|
+
'error',
|
|
89
|
+
{
|
|
90
|
+
allowAllCaps: true,
|
|
91
|
+
ignore: [],
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
|
|
95
|
+
// Enforce propTypes declarations alphabetical sorting
|
|
96
|
+
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-prop-types.md
|
|
97
|
+
'react/sort-prop-types': [
|
|
98
|
+
'error',
|
|
99
|
+
{
|
|
100
|
+
ignoreCase: true,
|
|
101
|
+
callbacksLast: false,
|
|
102
|
+
requiredFirst: false,
|
|
103
|
+
sortShapeProp: true,
|
|
104
|
+
},
|
|
105
|
+
],
|
|
106
|
+
|
|
107
|
+
// Deprecated in favor of react/jsx-sort-props
|
|
108
|
+
'react/jsx-sort-prop-types': 'off',
|
|
109
|
+
|
|
110
|
+
// Enforce props alphabetical sorting
|
|
111
|
+
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-sort-props.md
|
|
112
|
+
'react/jsx-sort-props': [
|
|
113
|
+
'error',
|
|
114
|
+
{
|
|
115
|
+
ignoreCase: true,
|
|
116
|
+
callbacksLast: false,
|
|
117
|
+
shorthandFirst: false,
|
|
118
|
+
shorthandLast: false,
|
|
119
|
+
noSortAlphabetically: false,
|
|
120
|
+
reservedFirst: false,
|
|
121
|
+
},
|
|
122
|
+
],
|
|
123
|
+
|
|
124
|
+
// Enforce defaultProps declarations alphabetical sorting
|
|
125
|
+
// https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/jsx-sort-default-props.md
|
|
126
|
+
'react/jsx-sort-default-props': [
|
|
127
|
+
'off',
|
|
128
|
+
{
|
|
129
|
+
ignoreCase: true,
|
|
130
|
+
},
|
|
131
|
+
],
|
|
132
|
+
|
|
133
|
+
// Prevent variables used in JSX to be incorrectly marked as unused
|
|
134
|
+
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-uses-vars.md
|
|
135
|
+
'react/jsx-uses-vars': 'error',
|
|
136
|
+
|
|
137
|
+
// Prevent usage of dangerous JSX properties
|
|
138
|
+
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-danger.md
|
|
139
|
+
'react/no-danger': 'off',
|
|
140
|
+
|
|
141
|
+
// Prevent usage of deprecated methods
|
|
142
|
+
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-deprecated.md
|
|
143
|
+
'react/no-deprecated': ['error'],
|
|
144
|
+
|
|
145
|
+
// Prevent usage of setState in componentDidMount
|
|
146
|
+
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-did-mount-set-state.md
|
|
147
|
+
// this is necessary for server-rendering
|
|
148
|
+
'react/no-did-mount-set-state': 'off',
|
|
149
|
+
|
|
150
|
+
// Prevent usage of setState in componentDidUpdate
|
|
151
|
+
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-did-update-set-state.md
|
|
152
|
+
'react/no-did-update-set-state': 'error',
|
|
153
|
+
|
|
154
|
+
// Prevent usage of setState in componentWillUpdate
|
|
155
|
+
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-will-update-set-state.md
|
|
156
|
+
'react/no-will-update-set-state': 'error',
|
|
157
|
+
|
|
158
|
+
// Prevent direct mutation of this.state
|
|
159
|
+
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-direct-mutation-state.md
|
|
160
|
+
'react/no-direct-mutation-state': 'off',
|
|
161
|
+
|
|
162
|
+
// Prevent usage of isMounted
|
|
163
|
+
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-is-mounted.md
|
|
164
|
+
'react/no-is-mounted': 'error',
|
|
165
|
+
|
|
166
|
+
// Prevent multiple component definition per file
|
|
167
|
+
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-multi-comp.md
|
|
168
|
+
'react/no-multi-comp': ['error', { ignoreStateless: true }],
|
|
169
|
+
|
|
170
|
+
// Prevent usage of setState
|
|
171
|
+
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-set-state.md
|
|
172
|
+
'react/no-set-state': 'off',
|
|
173
|
+
|
|
174
|
+
// Prevent using string references
|
|
175
|
+
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-string-refs.md
|
|
176
|
+
'react/no-string-refs': 'error',
|
|
177
|
+
|
|
178
|
+
// Prevent usage of unknown DOM property
|
|
179
|
+
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unknown-property.md
|
|
180
|
+
'react/no-unknown-property': 'error',
|
|
181
|
+
|
|
182
|
+
// Require ES6 class declarations over React.createClass
|
|
183
|
+
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-es6-class.md
|
|
184
|
+
'react/prefer-es6-class': ['error', 'always'],
|
|
185
|
+
|
|
186
|
+
// Require stateless functions when not using lifecycle methods, setState or ref
|
|
187
|
+
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-stateless-function.md
|
|
188
|
+
'react/prefer-stateless-function': [
|
|
189
|
+
'error',
|
|
190
|
+
{ ignorePureComponents: true },
|
|
191
|
+
],
|
|
192
|
+
|
|
193
|
+
// Prevent missing props validation in a React component definition
|
|
194
|
+
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prop-types.md
|
|
195
|
+
'react/prop-types': [
|
|
196
|
+
'error',
|
|
197
|
+
{
|
|
198
|
+
ignore: [],
|
|
199
|
+
customValidators: [],
|
|
200
|
+
skipUndeclared: false,
|
|
201
|
+
},
|
|
202
|
+
],
|
|
203
|
+
|
|
204
|
+
// Require render() methods to return something
|
|
205
|
+
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/require-render-return.md
|
|
206
|
+
'react/require-render-return': 'error',
|
|
207
|
+
|
|
208
|
+
// Prevent extra closing tags for components without children
|
|
209
|
+
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/self-closing-comp.md
|
|
210
|
+
'react/self-closing-comp': 'error',
|
|
211
|
+
|
|
212
|
+
// Enforce component methods order
|
|
213
|
+
// https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/sort-comp.md
|
|
214
|
+
'react/sort-comp': [
|
|
215
|
+
'error',
|
|
216
|
+
{
|
|
217
|
+
order: [
|
|
218
|
+
'static-methods',
|
|
219
|
+
'instance-variables',
|
|
220
|
+
'lifecycle',
|
|
221
|
+
'/^on.+$/',
|
|
222
|
+
'getters',
|
|
223
|
+
'setters',
|
|
224
|
+
'/^(get|set)(?!(InitialState$|DefaultProps$|ChildContext$)).+$/',
|
|
225
|
+
'instance-methods',
|
|
226
|
+
'everything-else',
|
|
227
|
+
'rendering',
|
|
228
|
+
],
|
|
229
|
+
groups: {
|
|
230
|
+
lifecycle: [
|
|
231
|
+
'displayName',
|
|
232
|
+
'propTypes',
|
|
233
|
+
'contextTypes',
|
|
234
|
+
'childContextTypes',
|
|
235
|
+
'mixins',
|
|
236
|
+
'statics',
|
|
237
|
+
'defaultProps',
|
|
238
|
+
'constructor',
|
|
239
|
+
'getDefaultProps',
|
|
240
|
+
'getInitialState',
|
|
241
|
+
'state',
|
|
242
|
+
'getChildContext',
|
|
243
|
+
'componentWillMount',
|
|
244
|
+
'UNSAFE_componentWillMount',
|
|
245
|
+
'componentDidMount',
|
|
246
|
+
'UNSAFE_componentDidMount',
|
|
247
|
+
'componentWillReceiveProps',
|
|
248
|
+
'UNSAFE_componentWillReceiveProps',
|
|
249
|
+
'shouldComponentUpdate',
|
|
250
|
+
'componentWillUpdate',
|
|
251
|
+
'UNSAFE_componentWillUpdate',
|
|
252
|
+
'componentDidUpdate',
|
|
253
|
+
'componentWillUnmount',
|
|
254
|
+
],
|
|
255
|
+
rendering: ['/^render.+$/', 'render'],
|
|
256
|
+
},
|
|
257
|
+
},
|
|
258
|
+
],
|
|
259
|
+
|
|
260
|
+
// Disallow target="_blank" on links
|
|
261
|
+
// https://github.com/yannickcr/eslint-plugin-react/blob/ac102885765be5ff37847a871f239c6703e1c7cc/docs/rules/jsx-no-target-blank.md
|
|
262
|
+
'react/jsx-no-target-blank': ['error', { enforceDynamicLinks: 'always' }],
|
|
263
|
+
|
|
264
|
+
// only .jsx files may have JSX
|
|
265
|
+
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-filename-extension.md
|
|
266
|
+
'react/jsx-filename-extension': 'off',
|
|
267
|
+
|
|
268
|
+
// prevent accidental JS comments from being injected into JSX as text
|
|
269
|
+
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-comment-textnodes.md
|
|
270
|
+
'react/jsx-no-comment-textnodes': 'error',
|
|
271
|
+
|
|
272
|
+
// disallow using React.render/ReactDOM.render's return value
|
|
273
|
+
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-render-return-value.md
|
|
274
|
+
'react/no-render-return-value': 'error',
|
|
275
|
+
|
|
276
|
+
// require a shouldComponentUpdate method, or PureRenderMixin
|
|
277
|
+
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/require-optimization.md
|
|
278
|
+
'react/require-optimization': ['off', { allowDecorators: [] }],
|
|
279
|
+
|
|
280
|
+
// warn against using findDOMNode()
|
|
281
|
+
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-find-dom-node.md
|
|
282
|
+
'react/no-find-dom-node': 'error',
|
|
283
|
+
|
|
284
|
+
// Forbid certain props on Components
|
|
285
|
+
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/forbid-component-props.md
|
|
286
|
+
'react/forbid-component-props': ['off', { forbid: [] }],
|
|
287
|
+
|
|
288
|
+
// Forbid certain elements
|
|
289
|
+
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/forbid-elements.md
|
|
290
|
+
'react/forbid-elements': ['off', { forbid: [] }],
|
|
291
|
+
|
|
292
|
+
// Prevent problem with children and props.dangerouslySetInnerHTML
|
|
293
|
+
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-danger-with-children.md
|
|
294
|
+
'react/no-danger-with-children': 'error',
|
|
295
|
+
|
|
296
|
+
// Prevent unused propType definitions
|
|
297
|
+
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unused-prop-types.md
|
|
298
|
+
'react/no-unused-prop-types': [
|
|
299
|
+
'error',
|
|
300
|
+
{
|
|
301
|
+
customValidators: [],
|
|
302
|
+
skipShapeProps: true,
|
|
303
|
+
},
|
|
304
|
+
],
|
|
305
|
+
|
|
306
|
+
// Require style prop value be an object or var
|
|
307
|
+
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/style-prop-object.md
|
|
308
|
+
'react/style-prop-object': 'error',
|
|
309
|
+
|
|
310
|
+
// Prevent invalid characters from appearing in markup
|
|
311
|
+
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unescaped-entities.md
|
|
312
|
+
'react/no-unescaped-entities': 'error',
|
|
313
|
+
|
|
314
|
+
// Prevent passing of children as props
|
|
315
|
+
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-children-prop.md
|
|
316
|
+
'react/no-children-prop': 'error',
|
|
317
|
+
|
|
318
|
+
// Prevent usage of Array index in keys
|
|
319
|
+
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-array-index-key.md
|
|
320
|
+
'react/no-array-index-key': 'error',
|
|
321
|
+
|
|
322
|
+
// Enforce a defaultProps definition for every prop that is not a required prop
|
|
323
|
+
// https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/require-default-props.md
|
|
324
|
+
'react/require-default-props': [
|
|
325
|
+
'error',
|
|
326
|
+
{
|
|
327
|
+
forbidDefaultForRequired: true,
|
|
328
|
+
},
|
|
329
|
+
],
|
|
330
|
+
|
|
331
|
+
// Forbids using non-exported propTypes
|
|
332
|
+
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/forbid-foreign-prop-types.md
|
|
333
|
+
// this is intentionally set to "warn". it would be "error",
|
|
334
|
+
// but it's only critical if you're stripping propTypes in production.
|
|
335
|
+
'react/forbid-foreign-prop-types': ['warn', { allowInPropTypes: true }],
|
|
336
|
+
|
|
337
|
+
// Prevent void DOM elements from receiving children
|
|
338
|
+
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/void-dom-elements-no-children.md
|
|
339
|
+
'react/void-dom-elements-no-children': 'error',
|
|
340
|
+
|
|
341
|
+
// Enforce all defaultProps have a corresponding non-required PropType
|
|
342
|
+
// https://github.com/yannickcr/eslint-plugin-react/blob/9e13ae2c51e44872b45cc15bf1ac3a72105bdd0e/docs/rules/default-props-match-prop-types.md
|
|
343
|
+
'react/default-props-match-prop-types': [
|
|
344
|
+
'error',
|
|
345
|
+
{ allowRequiredDefaults: false },
|
|
346
|
+
],
|
|
347
|
+
|
|
348
|
+
// Prevent usage of shouldComponentUpdate when extending React.PureComponent
|
|
349
|
+
// https://github.com/yannickcr/eslint-plugin-react/blob/9e13ae2c51e44872b45cc15bf1ac3a72105bdd0e/docs/rules/no-redundant-should-component-update.md
|
|
350
|
+
'react/no-redundant-should-component-update': 'error',
|
|
351
|
+
|
|
352
|
+
// Prevent unused state values
|
|
353
|
+
// https://github.com/yannickcr/eslint-plugin-react/pull/1103/
|
|
354
|
+
'react/no-unused-state': 'error',
|
|
355
|
+
|
|
356
|
+
// Enforces consistent naming for boolean props
|
|
357
|
+
// https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/boolean-prop-naming.md
|
|
358
|
+
'react/boolean-prop-naming': [
|
|
359
|
+
'off',
|
|
360
|
+
{
|
|
361
|
+
propTypeNames: ['bool', 'mutuallyExclusiveTrueProps'],
|
|
362
|
+
rule: '^(is|has)[A-Z]([A-Za-z0-9]?)+',
|
|
363
|
+
message: '',
|
|
364
|
+
},
|
|
365
|
+
],
|
|
366
|
+
|
|
367
|
+
// Prevents common casing typos
|
|
368
|
+
// https://github.com/yannickcr/eslint-plugin-react/blob/73abadb697034b5ccb514d79fb4689836fe61f91/docs/rules/no-typos.md
|
|
369
|
+
'react/no-typos': 'error',
|
|
370
|
+
|
|
371
|
+
// Enforce curly braces or disallow unnecessary curly braces in JSX props and/or children
|
|
372
|
+
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-curly-brace-presence.md
|
|
373
|
+
'react/jsx-curly-brace-presence': [
|
|
374
|
+
'error',
|
|
375
|
+
{ props: 'never', children: 'never' },
|
|
376
|
+
],
|
|
377
|
+
|
|
378
|
+
// Enforce consistent usage of destructuring assignment of props, state, and context
|
|
379
|
+
// https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/destructuring-assignment.md
|
|
380
|
+
'react/destructuring-assignment': 'off',
|
|
381
|
+
|
|
382
|
+
// Prevent using this.state within a this.setState
|
|
383
|
+
// https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/no-access-state-in-setstate.md
|
|
384
|
+
'react/no-access-state-in-setstate': 'error',
|
|
385
|
+
|
|
386
|
+
// Prevent usage of button elements without an explicit type attribute
|
|
387
|
+
// https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/button-has-type.md
|
|
388
|
+
'react/button-has-type': 'off',
|
|
389
|
+
|
|
390
|
+
// Prevent this from being used in stateless functional components
|
|
391
|
+
// https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/no-this-in-sfc.md
|
|
392
|
+
'react/no-this-in-sfc': 'error',
|
|
393
|
+
|
|
394
|
+
// Validate JSX maximum depth
|
|
395
|
+
// https://github.com/yannickcr/eslint-plugin-react/blob/abe8381c0d6748047224c430ce47f02e40160ed0/docs/rules/jsx-max-depth.md
|
|
396
|
+
'react/jsx-max-depth': 'off',
|
|
397
|
+
|
|
398
|
+
// Prevent usage of UNSAFE_ methods
|
|
399
|
+
// https://github.com/yannickcr/eslint-plugin-react/blob/157cc932be2cfaa56b3f5b45df6f6d4322a2f660/docs/rules/no-unsafe.md
|
|
400
|
+
'react/no-unsafe': 'error',
|
|
401
|
+
|
|
402
|
+
// Hooks Rules
|
|
403
|
+
// https://github.com/facebook/react/tree/master/packages/eslint-plugin-react-hooks
|
|
404
|
+
|
|
405
|
+
// General rules of hooks
|
|
406
|
+
// https://github.com/facebook/react/blob/master/packages/eslint-plugin-react-hooks/src/RulesOfHooks.js
|
|
407
|
+
'react-hooks/rules-of-hooks': 'error',
|
|
408
|
+
|
|
409
|
+
// Putting exhaustive dependencies on hooks.
|
|
410
|
+
// https://github.com/facebook/react/blob/master/packages/eslint-plugin-react-hooks/src/ExhaustiveDeps.js
|
|
411
|
+
// Your code may be correct even with this warn, check this in this case:
|
|
412
|
+
// https://github.com/facebook/react/issues/14920
|
|
413
|
+
'react-hooks/exhaustive-deps': 'warn',
|
|
414
|
+
},
|
|
415
|
+
|
|
416
|
+
settings: {
|
|
417
|
+
'import/resolver': {
|
|
418
|
+
node: {
|
|
419
|
+
extensions: ['.js', '.jsx', '.json'],
|
|
420
|
+
},
|
|
421
|
+
},
|
|
422
|
+
react: {
|
|
423
|
+
pragma: 'React',
|
|
424
|
+
version: '16.0',
|
|
425
|
+
},
|
|
426
|
+
propWrapperFunctions: [
|
|
427
|
+
'forbidExtraProps', // https://www.npmjs.com/package/airbnb-prop-types
|
|
428
|
+
'exact', // https://www.npmjs.com/package/prop-types-exact
|
|
429
|
+
'Object.freeze', // https://tc39.github.io/ecma262/#sec-object.freeze
|
|
430
|
+
],
|
|
431
|
+
},
|
|
432
|
+
};
|