-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy patheslint.config.cjs
More file actions
97 lines (93 loc) · 2.58 KB
/
eslint.config.cjs
File metadata and controls
97 lines (93 loc) · 2.58 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
/* Flat ESLint config for ESLint v9 compatible with Svelte 5 + TypeScript */
// Flat config for ESLint v9: Svelte 5 + TypeScript
module.exports = [
// Global defaults and ignores
{
// ESLint v9 flat config `ignores` replaces the deprecated .eslintignore
ignores: ['example/**', 'node_modules/**', 'build/**', 'static/**'],
languageOptions: {
ecmaVersion: 2022,
sourceType: 'module',
},
},
// Global size limits
{
rules: {
"max-lines": ["error", { max: 300, skipBlankLines: true, skipComments: true }],
"max-lines-per-function": ["error", { max: 50, skipBlankLines: true, skipComments: true }]
}
},
// Typed JS/TS files — run project-based rules ONLY on `src/` to avoid tsconfig mismatches
{
files: ['src/**/*.{ts,js}'],
languageOptions: {
parser: require('@typescript-eslint/parser'),
parserOptions: {
ecmaVersion: 2022,
sourceType: 'module',
project: ['./tsconfig.json'],
},
},
plugins: {
'@typescript-eslint': require('@typescript-eslint/eslint-plugin'),
},
rules: {
// Minimal TS rules for typed project files
'@typescript-eslint/no-unused-vars': [
'warn',
{
args: 'after-used',
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
ignoreRestSiblings: true,
},
],
},
},
// Other JS/TS files — do not use `project` (prevents parsing errors for files outside tsconfig)
{
files: ['**/*.{ts,js}', '!src/**/*.{ts,js}'],
languageOptions: {
parser: require('@typescript-eslint/parser'),
parserOptions: {
ecmaVersion: 2022,
sourceType: 'module',
createDefaultProgram: true,
},
},
plugins: {
'@typescript-eslint': require('@typescript-eslint/eslint-plugin'),
},
rules: {
// Linting without type-aware rules to avoid TS config issues
'@typescript-eslint/no-unused-vars': [
'warn',
{
args: 'after-used',
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
ignoreRestSiblings: true,
},
],
},
},
// Svelte files
{
files: ['**/*.svelte'],
languageOptions: {
parser: require('svelte-eslint-parser'),
parserOptions: {
parser: require('@typescript-eslint/parser'),
extraFileExtensions: ['.svelte'],
ecmaVersion: 2022,
sourceType: 'module',
},
},
plugins: {
svelte: require('eslint-plugin-svelte'),
},
rules: {
// Add project-specific Svelte rules here if needed
},
},
];