-
Notifications
You must be signed in to change notification settings - Fork 5
/
.eslintrc.js
82 lines (80 loc) · 2.64 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
const path = require('path');
const fs = require('fs');
/**
* TypeScript configuration for ESLint:
*
* Determine whether a `tsconfig.json` file exists in the root folder of the consuming
* project. If it exists, ensure ESLint is configured for TypeScript appropriately.
*/
const typeScriptParserOptions = {};
const typeScriptExtensions = [];
const tsConfigPath = path.resolve(process.cwd(), 'tsconfig.json');
if (fs.existsSync(tsConfigPath)) {
typeScriptParserOptions.project = tsConfigPath;
typeScriptExtensions.push('airbnb-typescript');
}
/* End TypeScript configuration for ESLint */
module.exports = {
env: {
es6: true,
browser: true,
jest: true,
es2020: true,
},
extends: [
// The airbnb config includes configuraton for import, react, and jsx-a11y.
// That means it's the only thing we need here. We still need to
// have those eslint-config plugins installed, though - it defines them
// as peer dependencies.
'airbnb',
'airbnb/hooks',
...typeScriptExtensions,
],
parserOptions: {
...typeScriptParserOptions,
},
// If you add rule overrides here, add code to test.js that proves you formatted it right.
rules: {
'class-methods-use-this': 'off',
curly: ['error', 'all'],
'max-len': [
'error',
120,
2,
{
ignoreUrls: true,
ignoreComments: false,
ignoreRegExpLiterals: true,
ignoreStrings: true,
ignoreTemplateLiterals: true,
},
],
'arrow-parens': 'off',
// Avoiding default exports is recommended (https://dev.to/phuocng/avoid-using-default-exports-a1c)
// but we had 'prefer-default-export' on for a long time so we can't turn on 'no-default-export' without causing
// a large refactor.
'import/prefer-default-export': 'off',
// There is no reason to disallow this syntax anymore; we don't use regenerator-runtime in new browsers
'no-restricted-syntax': 'off',
'jsx-a11y/label-has-associated-control': ['error', {
labelComponents: [],
labelAttributes: [],
controlComponents: [],
assert: 'htmlFor',
depth: 25,
}],
'react/jsx-props-no-spreading': 'off',
'react/react-in-jsx-scope': 'off',
'react/jsx-one-expression-per-line': 'off',
'react/destructuring-assignment': 'off',
'no-plusplus': 'off',
strict: 'off',
// We don't require 'defaultProps' for function components (they're
// deprecated: https://github.com/facebook/react/pull/16210).
// It's better to use native JavaScript/TypeScript defaults and TS types.
'react/require-default-props': ['error', {
classes: 'defaultProps',
functions: 'ignore',
}],
},
};