-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy patheslint.config.shared.js
More file actions
117 lines (107 loc) · 3.17 KB
/
Copy patheslint.config.shared.js
File metadata and controls
117 lines (107 loc) · 3.17 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
const eslint = require('@eslint/js');
const tseslint = require('@typescript-eslint/eslint-plugin');
const tsParser = require('@typescript-eslint/parser');
const reactPlugin = require('eslint-plugin-react');
const prettierConfig = require('eslint-config-prettier');
const baseConfig = {
files: ['**/*.ts', '**/*.tsx'],
languageOptions: {
parser: tsParser,
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module',
},
globals: {
console: 'readonly',
process: 'readonly',
Buffer: 'readonly',
__dirname: 'readonly',
__filename: 'readonly',
exports: 'writable',
module: 'writable',
require: 'readonly',
global: 'readonly',
URL: 'readonly',
// Browser globals
window: 'readonly',
document: 'readonly',
navigator: 'readonly',
Image: 'readonly',
fetch: 'readonly',
setTimeout: 'readonly',
clearTimeout: 'readonly',
setImmediate: 'readonly',
requestAnimationFrame: 'readonly',
JSX: 'readonly',
customElements: 'readonly',
},
},
plugins: {
'@typescript-eslint': tseslint,
},
rules: {
...eslint.configs.recommended.rules,
...tseslint.configs.recommended.rules,
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/restrict-template-expressions': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unused-vars': [
'warn',
{
argsIgnorePattern: '^_',
},
],
// Fix for ESLint 9 migration issues
'@typescript-eslint/no-empty-object-type': ['error', { allowObjectTypes: 'always', allowInterfaces: 'always' }],
'@typescript-eslint/no-require-imports': 'off',
'no-empty': ['error', { allowEmptyCatch: true }],
'no-prototype-builtins': 'off',
'react/no-unescaped-entities': 'off',
'no-case-declarations': 'off',
'no-constant-binary-expression': 'off',
'valid-typeof': 'off',
'no-useless-escape': 'off',
// Disable rules that conflict with prettier
...prettierConfig.rules,
},
};
const reactConfig = {
files: ['**/*.tsx'],
plugins: {
react: reactPlugin,
},
rules: {
...reactPlugin.configs.recommended.rules,
'react/no-unescaped-entities': 'off',
},
settings: {
react: {
version: 'detect',
},
},
};
// Test files used to need a block declaring `describe`/`it`/`expect`/`jest` as
// ambient globals. Rstest keeps test globals off, so every helper arrives as an
// ordinary import and no test-runner entry belongs here.
const createConfig = (options = {}) => {
const configs = [];
// Add ignore patterns first if provided
if (options.ignorePatterns) {
options.ignorePatterns.push('eslint.*.js');
configs.push({
ignores: options.ignorePatterns,
});
}
configs.push(baseConfig);
if (options.react) {
configs.push(reactConfig);
}
if (options.project) {
baseConfig.languageOptions.parserOptions.project = options.project;
}
return configs;
};
module.exports = { createConfig };