Repository navigation
Expand file tree
/
Copy patheslint.config.ts
More file actions
107 lines (97 loc) · 2.96 KB
/
Copy patheslint.config.ts
File metadata and controls
107 lines (97 loc) · 2.96 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
/**
* ESLint flat config for this repository; TypeScript-first rules, Prettier
* formatting enforcement, and targeted overrides for tests and JSON.
* @module
*/
import eslint from '@eslint/js';
import prettierPlugin from 'eslint-plugin-prettier';
import simpleImportSortPlugin from 'eslint-plugin-simple-import-sort';
import prettierConfig from 'eslint-config-prettier';
import tsdoc from 'eslint-plugin-tsdoc';
import vitest from '@vitest/eslint-plugin';
import jsonc from 'eslint-plugin-jsonc';
import jsoncParser from 'jsonc-eslint-parser';
import tseslint from 'typescript-eslint';
import { dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
const tsconfigRootDir = dirname(fileURLToPath(import.meta.url));
const TS_FILES = ['src/**/*.ts', 'src/**/*.tsx'];
const config = [
// Ignore generated and third‑party artifacts
{
ignores: [
'dist/**',
'.rollup.cache/**',
'coverage/**',
'node_modules/**',
'docs/**',
'rollup.config-*.mjs',
'.stan/**',
],
},
// Base JS
eslint.configs.recommended,
// TypeScript presets (scoped to TS files only)
...tseslint.configs.strictTypeChecked.map((c) => ({
// Scope each preset to our TS globs; avoid applying typed rules to JSON/etc.
...(c as Record<string, unknown>),
files: TS_FILES,
})),
// Our project override (parser/project + plugins/rules)
{
files: TS_FILES,
languageOptions: {
parser: tseslint.parser,
parserOptions: {
project: ['./tsconfig.json'],
tsconfigRootDir,
},
},
plugins: {
prettier: prettierPlugin,
'simple-import-sort': simpleImportSortPlugin,
tsdoc,
},
rules: {
// Formatting via Prettier
'prettier/prettier': ['error'],
// Import ordering
'simple-import-sort/imports': ['error'],
'simple-import-sort/exports': ['error'],
// TS preferences (parity with prior JS config)
'@typescript-eslint/no-explicit-any': ['error'],
'@typescript-eslint/consistent-type-definitions': ['error', 'type'],
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
// TSDoc hygiene (quiet)
'tsdoc/syntax': ['warn'],
},
},
// Disable stylistic conflicts with Prettier
prettierConfig,
// Tests
{
files: ['**/*.test.ts', '**/*.test.tsx'],
plugins: { vitest },
languageOptions: {
globals: vitest.environments.env.globals,
},
// Adopt Vitest’s recommended rule set in test files.
// Cast required to satisfy FlatConfig typing in this project.
rules: {
...(vitest.configs.recommended?.rules as Record<string, unknown>),
},
},
// JSON (no nested extends)
{
files: ['**/*.json'],
languageOptions: { parser: jsoncParser },
plugins: { jsonc },
rules: {
...(jsonc.configs['recommended-with-json']?.rules as Record<string, unknown>),
},
},
];
/**
* Flat ESLint configuration for this repository.
*/
export default config;