forked from Kong/insomnia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.js
158 lines (153 loc) · 5.42 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
const {
ERROR,
OFF,
SUCCESSOR,
TYPESCRIPT_CONVERSION,
TYPESCRIPT_EXTENSION,
UNKNOWN,
WARN,
} = require('eslint-config-helpers');
/** @type { import('eslint').Linter.Config } */
module.exports = {
settings: {
react: {
version: 'detect',
},
},
parser: '@typescript-eslint/parser',
parserOptions: {
tsconfigRootDir: __dirname,
ecmaFeatures: {
jsx: true,
},
},
extends: [
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react/recommended',
'plugin:react-hooks/recommended',
],
plugins: [
'@typescript-eslint',
'react',
'jest',
'html',
'json',
'filenames',
'react-hooks',
'import',
'simple-import-sort',
],
globals: {
__DEV__: true,
fail: true,
NodeJS: true,
HTMLDivElement: true,
HTMLElement: true,
HTMLInputElement: true,
HTMLSelectElement: true,
JSX: true,
},
env: {
browser: true,
commonjs: true,
es6: true,
'jest/globals': true,
node: true,
},
overrides: [
{
files: ['*.js'],
rules: {
'@typescript-eslint/no-var-requires': OFF(UNKNOWN),
},
},
],
rules: {
'array-bracket-spacing': ERROR,
'brace-style': SUCCESSOR(TYPESCRIPT_EXTENSION),
'block-spacing': ERROR,
'comma-dangle': [ERROR, 'always-multiline'],
'comma-spacing': ERROR,
'consistent-return': OFF('found to be too many false positives'),
'curly': ERROR,
'default-case': ERROR,
'default-case-last': ERROR,
'eol-last': [ERROR, 'always'],
'eqeqeq': [ERROR, 'smart'],
'arrow-parens': [ERROR, 'as-needed'],
'arrow-spacing': ERROR,
'keyword-spacing': SUCCESSOR(TYPESCRIPT_EXTENSION),
'no-async-promise-executor': OFF(UNKNOWN),
'no-case-declarations': OFF(UNKNOWN),
'no-duplicate-imports': OFF(UNKNOWN),
'no-prototype-builtins': OFF(UNKNOWN),
'no-redeclare': OFF(UNKNOWN),
'no-unused-vars': OFF(UNKNOWN),
'no-use-before-define': OFF(UNKNOWN),
'no-var': ERROR,
'no-trailing-spaces': ERROR,
'no-multiple-empty-lines': [ERROR, { 'max': 1, 'maxEOF': 0 }],
'object-curly-spacing': [ERROR, 'always'],
'quotes': OFF(UNKNOWN),
'semi': SUCCESSOR(TYPESCRIPT_EXTENSION),
'space-before-blocks': ERROR, // TODO: use the @typescript-eslint/space-before-blocks once we typescript-eslint past 5.13
'space-before-function-paren': [ERROR, { anonymous: 'never', named: 'never', asyncArrow: 'always' }],
'space-infix-ops': SUCCESSOR(TYPESCRIPT_EXTENSION),
'space-unary-ops': ERROR,
'space-in-parens': ERROR,
'spaced-comment': [ERROR, 'always', {
exceptions: ['/', '*', '-', '* '], // for ASCII art :)
markers: [
'/', // for TypeScript directives, doxygen, vsdoc, etc. (which use `///`)
'?', // for Quokka
],
}],
'react/no-unescaped-entities': OFF(TYPESCRIPT_CONVERSION),
'react/jsx-first-prop-new-line': [ERROR, 'multiline'],
'react/jsx-max-props-per-line': [ERROR, { maximum: 1, when: 'multiline' }],
'react/jsx-uses-react': ERROR,
'react/jsx-uses-vars': ERROR,
'react/jsx-indent-props': [ERROR, 2],
'react/prop-types': OFF(UNKNOWN),
'react/function-component-definition': [ERROR, {
'namedComponents': 'arrow-function',
'unnamedComponents': 'arrow-function',
}],
'react/jsx-closing-bracket-location': [ERROR, 'line-aligned'],
'react/prefer-stateless-function': ERROR,
'react/jsx-key': [ERROR, { 'checkFragmentShorthand': true }],
'react/no-array-index-key': WARN(UNKNOWN),
'react/self-closing-comp': ERROR,
'react-hooks/exhaustive-deps': [ERROR, {
// From react-use https://github.com/streamich/react-use/issues/1703#issuecomment-770972824
'additionalHooks': '^use(Async|AsyncFn|AsyncRetry|Debounce|UpdateEffect|IsomorphicLayoutEffect|DeepCompareEffect|ShallowCompareEffect)$',
}],
'react-hooks/rules-of-hooks': ERROR,
'@typescript-eslint/array-type': [ERROR, { default: 'array', readonly: 'array' }],
'@typescript-eslint/ban-types': OFF(UNKNOWN),
'@typescript-eslint/brace-style': [ERROR, '1tbs'],
'@typescript-eslint/consistent-type-definitions': [ERROR, 'interface'],
'@typescript-eslint/explicit-module-boundary-types': OFF(UNKNOWN),
'@typescript-eslint/keyword-spacing': ERROR,
'@typescript-eslint/member-delimiter-style': ERROR,
'@typescript-eslint/no-empty-function': OFF(UNKNOWN),
'@typescript-eslint/no-empty-interface': [ERROR, { 'allowSingleExtends': true }],
'@typescript-eslint/no-namespace': [ERROR, { allowDeclarations: true }],
'@typescript-eslint/no-redeclare': ERROR,
'@typescript-eslint/no-unused-vars': [ERROR, { ignoreRestSiblings: true }],
'@typescript-eslint/space-infix-ops': ERROR,
'@typescript-eslint/semi': [ERROR, 'always'],
'@typescript-eslint/quotes': [ERROR, 'single', { avoidEscape: true }],
'simple-import-sort/imports': ERROR,
'filenames/match-exported': OFF(UNKNOWN),
camelcase: OFF(UNKNOWN),
'@typescript-eslint/no-use-before-define': OFF(TYPESCRIPT_CONVERSION),
'@typescript-eslint/no-explicit-any': OFF(TYPESCRIPT_CONVERSION),
'react/no-find-dom-node': OFF(UNKNOWN),
'no-restricted-properties': [ERROR, {
property: 'openExternal',
message: 'use the `window.main.openInBrowser` function instead. see https://security.stackexchange.com/questions/225799/dangers-of-electrons-shell-openexternal-on-untrusted-content for more information.',
}],
},
};