-
Notifications
You must be signed in to change notification settings - Fork 3
/
.eslintrc.js
178 lines (172 loc) · 6.74 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
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
const OFF = 'off'; // 0
const WARN = 'warn'; // 1
const ERROR = 'error'; // 2
const INDENTATION_SIZE = 4;
module.exports = {
parser: '@typescript-eslint/parser', // Specifies the ESLint parser
plugins: ['@typescript-eslint', 'import'],
extends: [
'airbnb',
'airbnb/hooks',
'plugin:@typescript-eslint/recommended',
'airbnb-typescript',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:import/typescript',
],
env: {
es6: true,
jest: true,
},
parserOptions: {
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
sourceType: 'module', // Allows for the use of imports
project: './tsconfig.json',
tsconfigRootDir: __dirname,
},
settings: {
"import/resolver": {
"typescript": {},
},
},
globals: {
window: 'readonly',
document: 'readonly',
navigator: 'readonly'
},
rules: {
// Javascript Rules
'arrow-parens': [ERROR, 'always'],
'function-paren-newline': [ERROR, 'consistent'],
'implicit-arrow-linebreak': [OFF],
'indent': [WARN, INDENTATION_SIZE, { SwitchCase: 1 } ],
'max-len': [ERROR, 120],
'no-console': [OFF],
'no-nested-ternary': [OFF],
'no-plusplus': [ERROR, { allowForLoopAfterthoughts: true }],
'no-unused-expressions': [ERROR, { allowShortCircuit: true, allowTernary: true }],
'no-unused-vars': [OFF],
'no-use-before-define': [OFF],
'object-curly-newline': [OFF],
// 'operator-linebreak': [ERROR, 'after', { overrides: { '?': 'before', ':': 'before' } } ],
'operator-linebreak': [OFF],
// JSX Rules
'jsx-a11y/label-has-for': [OFF],
// React Rules
'react/destructuring-assignment': [OFF],
'react/jsx-curly-newline': [OFF],
'react/jsx-indent': [ERROR, INDENTATION_SIZE],
'react/jsx-indent-props': [ERROR, INDENTATION_SIZE],
'react/jsx-filename-extension': [ERROR, { extensions: ['.jsx', '.tsx'] }],
'react/jsx-one-expression-per-line': [OFF],
'react/jsx-props-no-spreading': [OFF],
'react/prop-types': [OFF],
'react/jsx-no-bind': [OFF],
'react/sort-comp': [ERROR, {
order: [
'static-variables',
'static-methods',
'instance-variables',
'lifecycle',
'render',
'everything-else',
],
groups: {
lifecycle: [
'displayName',
'propTypes',
'contextTypes',
'childContextTypes',
'mixins',
'statics',
'defaultProps',
'constructor',
'getDefaultProps',
'state',
'getInitialState',
'getChildContext',
'getDerivedStateFromProps',
'componentWillMount',
'UNSAFE_componentWillMount',
'componentDidMount',
'componentWillReceiveProps',
'UNSAFE_componentWillReceiveProps',
'shouldComponentUpdate',
'componentWillUpdate',
'UNSAFE_componentWillUpdate',
'getSnapshotBeforeUpdate',
'componentDidUpdate',
'componentDidCatch',
'componentWillUnmount'
]
}
}],
'react/require-default-props': [OFF],
'react/jsx-props-no-multi-spaces': [OFF],
'react/no-unused-prop-types': [OFF],
// Import Rules
'import/extensions': [ERROR, 'never' , {
json: 'always',
}],
'import/prefer-default-export': [OFF],
// Typescript rules
/** "explicit-function-return-type" can be off for apps, but should be on for libraries! */
// '@typescript-eslint/explicit-function-return-type': [ERROR],
'@typescript-eslint/indent': [ERROR, INDENTATION_SIZE, {
SwitchCase: 1,
VariableDeclarator: 1,
outerIIFEBody: 1,
MemberExpression: 1,
FunctionDeclaration: { parameters: 'first', body: 1 },
FunctionExpression: { parameters: 'first', body: 1 },
CallExpression: { arguments: 'first' },
ArrayExpression: 'first',
ObjectExpression: 'first',
ImportDeclaration: 'first',
flatTernaryExpressions: false,
}],
'@typescript-eslint/camelcase': [OFF],
"@typescript-eslint/naming-convention": [ERROR, {
"selector": "interface",
"format": ["PascalCase"],
"custom": {
"regex": "^I[A-Z]",
"match": true // true is to enforce that interfaces start with an I
}
}],
'@typescript-eslint/no-use-before-define': [ERROR, { functions: false, classes: true, enums: false, typedefs: false }],
"@typescript-eslint/explicit-module-boundary-types": [OFF], // disable the rule for all files
"@typescript-eslint/no-unused-vars": [ERROR, { vars: 'all', args: 'after-used', ignoreRestSiblings: true }],
"@typescript-eslint/comma-dangle": [ERROR, {
arrays: 'always-multiline',
objects: 'always-multiline',
imports: 'always-multiline',
exports: 'always-multiline',
functions: 'always-multiline',
enums: 'always-multiline',
generics: 'always-multiline',
tuples: 'always-multiline',
}],
"@typescript-eslint/lines-between-class-members": [OFF],
"@typescript-eslint/ban-types": [ERROR, {
types: {
/**
* By default, '{}' is already not allowed, but we override the message
* as we do allow the use of 'object'.
*/
"{}": {
message: '`{}` actually means "any non-nullish value". Use "object" instead.',
fixWith: 'object',
},
/**
* By default, 'object' is not allowed.
* -->
* Don't use `object` as a type. The `object` type is currently hard to use
* ([see this issue](https://github.com/microsoft/TypeScript/issues/21732)).
* Consider using `Record<string, unknown>` instead, as it allows you to more easily inspect and use the keys.
*/
"object": false, // false to disable the inherited rule (and thus allow the use of 'object')
},
}],
}
};