-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.js
128 lines (111 loc) · 3.1 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
const restrictedGlobals = require('confusing-browser-globals');
module.exports = {
parser: '@typescript-eslint/parser',
plugins: [
// Enable Typescript linting
'@typescript-eslint',
// Enable linting imports
'import',
],
extends: [
// Use default ESLint rules
'eslint:recommended',
// Use recommended TS rules
'plugin:@typescript-eslint/recommended',
// Use recommended React rules
'plugin:react/recommended',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:import/typescript',
],
env: {
// Browser conf
browser: true,
es6: true,
// Jest conf
jest: true,
node: true,
},
rules: {
// Prevent development/debugging statements
'no-console': ['error', { allow: ['warn', 'error', 'info', 'debug'] }],
'no-alert': 'error',
'no-debugger': 'error',
// Prevent usage of confusing globals
'no-restricted-globals': ['error'].concat(restrictedGlobals),
// Assignments in function returns is confusing and could lead to unwanted side-effects
'no-return-assign': ['error', 'always'],
// Strict import ordering
'import/order': [
'warn',
{
groups: ['builtin', 'external', 'parent', 'sibling', 'index'],
pathGroups: [
// Sort absolute root imports before parent imports
{
pattern: '/**',
group: 'parent',
position: 'before',
},
],
'newlines-between': 'always',
},
],
},
overrides: [
{
files: ['*.js'],
env: {
// We may still use CJS in .js files (eg. local scripts)
commonjs: true,
},
rules: {
// `require` is still allowed/recommended in JS
'@typescript-eslint/no-var-requires': 'off',
},
},
{
files: ['*.ts', '*.tsx'],
rules: {
// TypeScript 4.0 adds 'any' or 'unknown' type annotation on catch clause variables.
// We need to make sure error is of the type we are expecting
'@typescript-eslint/no-implicit-any-catch': 'error',
// These are handled by TS
'@typescript-eslint/no-explicit-any': ['warn', { ignoreRestArgs: true }],
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-inferrable-types': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'import/no-unresolved': 'off',
},
},
{
files: ['*.jsx', '*.tsx'],
plugins: [
// Enable linting React code
'react',
'react-hooks',
],
rules: {
// Help with Hooks syntax
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'error',
// Handled by Typescript
'react/prop-types': 'off',
// This rule causes too many false positives, eg. with default exports or child render function
'react/display-name': 'off',
},
},
],
settings: {
react: {
pragma: 'React',
version: '17',
},
},
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
};