-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
Copy patheslint.config.mjs
134 lines (130 loc) · 4.87 KB
/
eslint.config.mjs
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
import eslint from '@eslint/js';
import eslintConfigPrettier from 'eslint-config-prettier/flat';
import playwright from 'eslint-plugin-playwright'
import reactPlugin from 'eslint-plugin-react';
import reactHooksPlugin from 'eslint-plugin-react-hooks';
import simpleImportSortPlugin from 'eslint-plugin-simple-import-sort';
import tseslint from 'typescript-eslint';
export default tseslint.config(
eslint.configs.recommended,
tseslint.configs.strict,
tseslint.configs.stylistic,
{
files: ['packages/insomnia-smoke-test/tests/**/*.ts'],
plugins: { 'playwright': playwright },
rules: {
...playwright.configs['flat/recommended'].rules,
'playwright/expect-expect': 'off',
'playwright/valid-title': 'off', //TODO: avoid using looping e2e tests
'playwright/require-soft-assertions': 'error',
'playwright/prefer-native-locators': 'error',
'playwright/prefer-to-be': 'error',
'playwright/prefer-to-contain': 'error',
}
},
{
files: ['packages/insomnia/src/**/*.{ts,tsx}'],
plugins: { 'react-hooks': reactHooksPlugin },
rules: {
'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',
}
},
{
settings: {
react: {
version: 'detect',
},
},
plugins: {
'react': reactPlugin,
'simple-import-sort': simpleImportSortPlugin,
},
rules: {
'default-case': 'error',
'default-case-last': 'error',
'eol-last': ['error', 'always'],
'eqeqeq': ['error', 'smart'],
'no-async-promise-executor': 'off',
'no-else-return': 'error',
'no-empty': ['error', { allowEmptyCatch: true }],
'no-var': 'error',
'no-trailing-spaces': 'error',
'no-multiple-empty-lines': ['error', { max: 1, maxEOF: 0 }],
'no-inner-declarations': 'off',
'no-useless-escape': 'off', // TODO: Enable this rule
'object-curly-spacing': ['error', 'always'],
'space-before-function-paren': ['error', { anonymous: 'ignore', named: 'ignore', asyncArrow: 'always' }],
'space-unary-ops': 'error',
'react/no-unescaped-entities': 'off', // TODO: Enable this rule
'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',
'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': 'error',
'react/self-closing-comp': 'error',
'@typescript-eslint/array-type': ['error', { default: 'array', readonly: 'array' }],
'@typescript-eslint/consistent-type-definitions': ['error', 'interface'],
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/no-empty-interface': ['error', { allowSingleExtends: true }],
'@typescript-eslint/no-empty-object-type': 'off', // TODO: Enable this rule
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-namespace': ['error', { allowDeclarations: true }],
'@typescript-eslint/no-redeclare': 'error',
'@typescript-eslint/no-require-imports': 'off',
'@typescript-eslint/no-unused-expressions': 'off', // TODO: Enable this rule
'@typescript-eslint/no-unused-vars': 'off', // TODO: Enable this rule
'simple-import-sort/imports': 'error',
'@typescript-eslint/no-use-before-define': 'off', // TODO: Enable this rule
'@typescript-eslint/no-explicit-any': 'off', // TODO: Enable this rule
'@typescript-eslint/no-dynamic-delete': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-invalid-void-type': 'off',
},
},
eslintConfigPrettier,
{
ignores: [
'*.md',
'**/__fixtures__/*',
'**/__snapshots__/*',
'**/.cache/*',
'**/.github/*',
'**/.idea/*',
'**/*.config.js',
'**/*.d.ts',
'**/*.min.js',
'**/bin/*',
'**/build/*',
'**/coverage/*',
'**/customSign.js',
'**/dist/*',
'**/docker/*',
'**/electron/index.js',
'**/fixtures',
'**/hidden-window-preload.js',
'**/node_modules/*',
'**/preload.js',
'**/svgr',
'**/traces/*',
'**/verify-pkg.js',
'**/__mocks__/*',
],
},
);