Repository navigation
Expand file tree
/
Copy patheslint.config.js
More file actions
89 lines (87 loc) · 2.75 KB
/
Copy patheslint.config.js
File metadata and controls
89 lines (87 loc) · 2.75 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
import tsPlugin from '@typescript-eslint/eslint-plugin'
import tsParser from '@typescript-eslint/parser'
import prettierPlugin from 'eslint-plugin-prettier'
import simpleImportSort from 'eslint-plugin-simple-import-sort'
import {fileURLToPath} from 'url'
// Merge recommended rules from the TypeScript plugin when available so the
// flat config behaves similarly to `extends: ['plugin:@typescript-eslint/recommended']`.
const tsRecommendedRules = tsPlugin?.configs?.recommended?.rules || {}
// ESM flat-config for ESLint v9+
// Keeps config minimal and local to this project. Adjust rules as needed.
export default [
// Global ignores applied before other file-specific configs.
{
ignores: ['dist/**', 'node_modules/**', '**/*.d.ts'],
},
// Top-level tooling/config files (vite config, scripts) - parse with the TS parser
// but do NOT set `parserOptions.project` so they don't need to be part of the
// `tsconfig` used for the library sources.
{
files: ['vite.config.ts', 'scripts/**/*.ts'],
ignores: ['dist/**', 'node_modules/**'],
languageOptions: {
parser: tsParser,
parserOptions: {
sourceType: 'module',
},
},
plugins: {
'simple-import-sort': simpleImportSort,
prettier: prettierPlugin,
},
rules: {
'prettier/prettier': 'error',
'simple-import-sort/imports': 'error',
'simple-import-sort/exports': 'error',
},
},
// TypeScript files use the TypeScript parser and project-aware rules
{
// Limit to library sources so top-level config files (vite.config.ts)
// are handled by a separate block above and won't get merged with
// project-aware parserOptions.
files: ['src/**/*.ts'],
ignores: ['dist/**', 'node_modules/**'],
languageOptions: {
parser: tsParser,
parserOptions: {
project: './src/tsconfig.json',
tsconfigRootDir: fileURLToPath(new URL('.', import.meta.url)),
sourceType: 'module',
},
},
plugins: {
'@typescript-eslint': tsPlugin,
'simple-import-sort': simpleImportSort,
prettier: prettierPlugin,
},
rules: {
...tsRecommendedRules,
'prettier/prettier': 'error',
'simple-import-sort/imports': 'error',
'simple-import-sort/exports': 'error',
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': ['error', {argsIgnorePattern: '^_'}],
'@typescript-eslint/explicit-module-boundary-types': 'off',
},
},
// JavaScript files: do not use the TS project parserOptions (avoids project-file errors)
{
files: ['**/*.js'],
ignores: ['dist/**', 'node_modules/**'],
languageOptions: {
parserOptions: {
sourceType: 'module',
},
},
plugins: {
'simple-import-sort': simpleImportSort,
prettier: prettierPlugin,
},
rules: {
'prettier/prettier': 'error',
'simple-import-sort/imports': 'error',
'simple-import-sort/exports': 'error',
},
},
]