-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patheslint.config.cjs
More file actions
67 lines (62 loc) · 2.07 KB
/
Copy patheslint.config.cjs
File metadata and controls
67 lines (62 loc) · 2.07 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
// eslint.config.cjs — ESLint 9 (flat config)
const js = require('@eslint/js'); // core ESLint rules
const tseslint = require('typescript-eslint'); // TS parser + plugin + shareable configs
const importPlugin = require('eslint-plugin-import'); // import rules
const globals = require('globals'); // environment globals (node, ES2021)
module.exports = tseslint.config(
// 1) Base: ESLint recommended
js.configs.recommended,
// 2) Global language options (ECMAScript + Node env)
{
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
// Use typescript-eslint's parser for TS files only (below),
// default JS parser is fine for *.js/*.cjs/*.mjs
globals: {
...globals.node,
...globals.es2021,
},
},
plugins: {
import: importPlugin,
},
rules: {
// Your original rules (applied to all files unless overridden later)
// Turn off core rule; use TS-specific variant in TS section
'no-unused-vars': 'off',
'import/no-unresolved': 'off',
},
},
// 3) TypeScript-specific config (applies only to TS/TSX)
{
files: ['**/*.ts', '**/*.tsx'],
languageOptions: {
parser: tseslint.parser,
parserOptions: {
// use your project's tsconfig if you need type-aware rules later
// project: true, // uncomment when enabling "typed" rules
},
},
plugins: {
'@typescript-eslint': tseslint.plugin,
import: importPlugin,
},
// Use shareable configs from typescript-eslint (recommended)
extends: [
tseslint.configs.recommended, // base TS rules
// You can optionally add:
// tseslint.configs.strict,
// tseslint.configs.stylistic,
],
rules: {
// Mirror your original TS rule settings
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
'@typescript-eslint/no-explicit-any': 'off',
},
},
// 4) Optional: ignore-output folders
{
ignores: ['node_modules/**', 'dist/**', 'coverage/**'],
}
);