-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.js
More file actions
126 lines (123 loc) · 4.9 KB
/
eslint.config.js
File metadata and controls
126 lines (123 loc) · 4.9 KB
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
const js = require('@eslint/js'),
tseslint = require('typescript-eslint'),
tsParser = require('@typescript-eslint/parser'),
react = require('eslint-plugin-react'),
reactHooks = require('eslint-plugin-react-hooks'),
globals = require('globals');
module.exports = tseslint.config(
js.configs.recommended,
{
files: ['**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx'],
plugins: {
react,
'react-hooks': reactHooks,
'@typescript-eslint': tseslint.plugin
},
languageOptions: {
parser: tsParser,
parserOptions: {
sourceType: 'module',
babelOptions: {
configFile: '@xh/eslint-config/babel.config.js'
}
},
globals: {
// Browser is deliberately omitted to catch errors where a missing import falls back
// to a global without that being obvious - e.g. lodash `find` vs `window.find`.
// Selected browser globals are then whitelisted below.
...globals.node,
...globals.commonjs,
...globals.es2015,
// Setting to "readonly" here means "don't warn" - these are expected/valid globals.
// See Tip in https://eslint.org/docs/latest/use/configure/language-options
AbortController: 'readonly',
Blob: 'readonly',
DOMRect: 'readonly',
Element: 'readonly',
Event: 'readonly',
File: 'readonly',
FileReader: 'readonly',
FocusEvent: 'readonly',
FormData: 'readonly',
Headers: 'readonly',
HTMLButtonElement: 'readonly',
HTMLElement: 'readonly',
HTMLDivElement: 'readonly',
HTMLImageElement: 'readonly',
HTMLInputElement: 'readonly',
HTMLTextAreaElement: 'writable',
Intl: 'readonly',
JSX: 'writable',
KeyboardEvent: 'readonly',
MouseEvent: 'readonly',
WebSocket: 'readonly',
document: 'readonly',
fetch: 'readonly',
window: 'readonly',
xhAgGridLicenseKey: 'readonly',
xhAppBuild: 'readonly',
xhAppBuildTimestamp: 'readonly',
xhAppCode: 'readonly',
xhAppName: 'readonly',
xhAppVersion: 'readonly',
xhBaseUrl: 'readonly',
xhBuildTimestamp: 'readonly',
xhIsDevelopmentMode: 'readonly',
// Flag use of `window.isFinite`. Not handled by `browser:false` config above and is a
// similar case where we more likely intend to use the lodash version (which yields a
// different result for `null`).
isFinite: 'off'
}
},
rules: {
// Hoist - disabled
'eqeqeq': 'off',
'no-console': 'off',
'no-empty': 'off',
'no-prototype-builtins': 'off',
'no-underscore-dangle': 'off',
'strict': 'off',
// React + Hooks
'react/jsx-uses-react': 'error',
'react/jsx-uses-vars': 'error',
'react-hooks/exhaustive-deps': 'warn',
// Linter unable to interpret our factory pattern w/hook calls in render fn config.
'react-hooks/rules-of-hooks': 'off',
// Hoist - enabled / customized
'no-unused-vars': ['error', {
ignoreRestSiblings: true,
caughtErrors: 'none',
args: 'none'
}],
'curly': ['error', 'multi-line'],
'no-spaced-func': 'error',
'block-scoped-var': 'error',
'no-return-await': 'error'
}
},
// Run typescript-specific rules only on typescript files
{
files: ['**/*.ts', '**/*.tsx'],
languageOptions: {
parserOptions: {projectService: ['./tsconfig.json']}
},
// Note: Remember to disable the base rules when enabling the ts version
rules: {
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': ['error', {
ignoreRestSiblings: true,
caughtErrors: 'none',
args: 'none'
}],
// Sets 'return-await' to 'in-try-catch' mode
'no-return-await': 'off',
'@typescript-eslint/return-await': ['error', 'in-try-catch'],
// Allow for multiple method signatures in TS (which appear as dupe class members)
'no-dupe-class-members': 'off',
'no-redeclare': 'off',
'@typescript-eslint/no-redeclare': ['error', {
ignoreDeclarationMerge: true
}]
}
}
);