-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathindex.js
169 lines (159 loc) · 5.32 KB
/
index.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
const jsTsCommonRules = {
// Do not force destructuring.
"react/destructuring-assignment": 0,
"prefer-destructuring": 0,
// require trailing commas for multiline (arrays, objects, imports, exports & functions), disallowed for same line
"comma-dangle": [2, "always-multiline"],
// require function expressions to have a name
"func-names": 0,
// this option sets a specific tab width for your code, VariableDeclarator indents are for nice alignment of multi-line var declaration
"indent": [
2,
2,
{ "SwitchCase": 1, "VariableDeclarator": { "var": 2, "let": 2, "const": 3 } },
],
// disallow trailing whitespace at the end of lines, except empty lines
"no-trailing-spaces": 2,
// No warnings about _ prefixed methods
"no-underscore-dangle": [1, { "allowAfterThis": true }],
// No warnings about max length
"max-len": 0,
// Warn for templates
"prefer-template": 1,
// Allow long version
"object-shorthand": 0,
"class-methods-use-this": 0,
"no-pluspls": 0,
// Require padding on the class level
"padded-blocks": [1, { "classes": "always" }],
// Disallow Assignment in return Statement, except if wrapped in parentheses
"no-return-assign": [2, "except-parens"],
// Prevent missing displayName in a React component definition
"react/display-name": 1,
// Enforce boolean attributes notation in JSX
"react/jsx-boolean-value": [2, "never"],
// Enforce or disallow spaces inside of curly braces in JSX attributes
"react/jsx-curly-spacing": [2, "never"],
// Do not remove curly braces from children.
"react/jsx-curly-brace-presence": [
2,
{ "props": "never", "children": "ignore" },
],
// Prevent duplicate props in JSX
"react/jsx-no-duplicate-props": 2,
// Prevent React to be incorrectly marked as unused - covered by no-unused-vars
"react/jsx-uses-react": 2,
// Prevent usage of dangerous JSX properties
"react/no-danger": 2,
// Prevent multiple component definition per file
"react/no-multi-comp": [2, { "ignoreStateless": true }],
// Allow props on the same line
"react/jsx-first-prop-new-line": 0,
"react/jsx-max-props-per-line": 0,
// require to sort props alphabetically in the prop-type declaration
"react/sort-prop-types": 2,
// short hand props must be listed after all other props (Component, not prop declaration)
"react/jsx-sort-props": [
2,
{ "shorthandLast": true, "noSortAlphabetically": true },
],
// do not allow deprecated lifecycle methods according to the react version provided above
"react/no-deprecated": 2,
// We only have a11ly as it's a required dependency
"jsx-a11y/click-events-have-key-events": 0,
"jsx-a11y/interactive-supports-focus": 0,
"jsx-a11y/label-has-for": 0,
"jsx-a11y/mouse-events-have-key-events": 0,
"jsx-a11y/no-static-element-interactions": 0,
"jsx-a11y/role-has-required-aria-props": 0,
"jsx-a11y/anchor-is-valid": 0,
// Our imports work differently in MC
"import/no-extraneous-dependencies": 0,
"import/no-unresolved": 0,
"import/extensions": 0,
// warn on disabled tests
"jest/no-disabled-tests": "warn",
// do not allow .only in tests
"jest/no-focused-tests": "error",
// do not allow tests with the same name
"jest/no-identical-title": "error",
// expect(files).toHaveLength(1); instead of expect(files.length).toBe(1);
"jest/prefer-to-have-length": "warn",
// Ensure expect() is called with a single argument
"jest/valid-expect": "error",
}
module.exports = {
"extends": ["eslint-config-airbnb", "airbnb/hooks"],
"env": {
"browser": "true",
"es2017": "true",
"jest": "true",
},
"globals": {
"shallow": "true",
"mount": "true",
},
"parser": "@babel/eslint-parser",
"parserOptions": {
"ecmaFeatures": {
"jsx": true,
},
},
"settings": {
"react": {
"pragma": "React",
"version": "detect",
},
},
"rules": jsTsCommonRules,
"plugins": ["jest", "react", "react-hooks"],
"overrides": [
{
"files": ["*.ts", "*.tsx"],
"extends": [
"airbnb-typescript",
"airbnb/hooks",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module",
"project": "./tsconfig.json"
},
"plugins": ["react", "@typescript-eslint"],
"rules": {
...jsTsCommonRules,
"no-use-before-define": "off",
"@typescript-eslint/no-use-before-define": "error",
"react/jsx-props-no-spreading": "off",
"react/jsx-filename-extension": [
2,
{
"extensions": [
".tsx"
]
}
],
"react/prop-types": "off",
"@typescript-eslint/no-explicit-any": 0,
"comma-dangle": "off",
"@typescript-eslint/comma-dangle": ["error"],
"@typescript-eslint/unbound-method": [
"error",
{
"ignoreStatic": true
}
]
},
},
// Special rules for tests
{
"files": ["*.spec.jsx", "*.spec.tsx"],
"rules": {
"react/jsx-props-no-spreading": "off",
},
},
],
};