-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.js
More file actions
118 lines (116 loc) · 3.18 KB
/
eslint.config.js
File metadata and controls
118 lines (116 loc) · 3.18 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
118
// @ts-check
import tseslint from '@typescript-eslint/eslint-plugin';
import tsParser from '@typescript-eslint/parser';
import eslintConfigPrettier from 'eslint-config-prettier';
import * as jsonc from 'eslint-plugin-jsonc';
import jsoncParser from 'jsonc-eslint-parser';
import { fileURLToPath } from 'node:url';
import { dirname } from 'node:path';
const __dirname = dirname(fileURLToPath(import.meta.url));
/** @type {import('eslint').Linter.FlatConfig[]} */
export default [
// Ignore patterns
{
ignores: ['dist/**', 'coverage/**', 'node_modules/**', 'sbom.cdx.json'],
},
// Base configuration for all JS/TS files
{
files: ['**/*.{ts,tsx,js}'],
languageOptions: {
parser: tsParser,
parserOptions: {
ecmaVersion: 2024,
sourceType: 'module',
},
},
plugins: { '@typescript-eslint': tseslint },
rules: {
...tseslint.configs['recommended'].rules,
'no-console': 'warn',
'no-debugger': 'error',
},
},
// Type-aware rules for TypeScript files only
{
files: ['src/**/*.ts', 'tests/**/*.ts'],
languageOptions: {
parser: tsParser,
parserOptions: {
ecmaVersion: 2024,
sourceType: 'module',
project: true,
tsconfigRootDir: __dirname,
},
},
rules: {
...tseslint.configs['recommended-type-checked'].rules,
},
},
// JSON/JSONC/JSON5 linting configuration
{
files: ['**/*.json', '**/*.json5', '**/*.jsonc'],
languageOptions: {
parser: jsoncParser,
},
plugins: {
jsonc,
},
rules: {
...jsonc.configs['recommended-with-json'].rules,
'jsonc/sort-keys': 'off', // Keep keys in logical order, not alphabetical
'jsonc/indent': ['error', 2], // Enforce 2-space indentation in JSON files
'jsonc/key-spacing': 'error', // Enforce consistent spacing between keys and values
'jsonc/comma-dangle': ['error', 'never'], // No trailing commas in JSON
'jsonc/quotes': ['error', 'double'], // Enforce double quotes in JSON
'jsonc/quote-props': ['error', 'always'], // Always quote property names
'jsonc/no-comments': 'off', // Allow comments in JSONC files
},
},
// Specific rules for package.json
{
files: ['**/package.json'],
rules: {
'jsonc/sort-keys': [
'error',
{
pathPattern: '^$', // Root object
order: [
'name',
'version',
'description',
'keywords',
'author',
'license',
'repository',
'bugs',
'homepage',
'private',
'type',
'main',
'module',
'exports',
'files',
'bin',
'packageManager',
'engines',
'scripts',
'lint-staged',
'dependencies',
'devDependencies',
'peerDependencies',
'optionalDependencies',
],
},
],
},
},
// Specific rules for tsconfig files
{
files: ['**/tsconfig*.json'],
rules: {
'jsonc/no-comments': 'off', // Allow comments in tsconfig files
},
},
// Keep Prettier last
eslintConfigPrettier,
];