-
-
Notifications
You must be signed in to change notification settings - Fork 228
Expand file tree
/
Copy patheslint.config.js
More file actions
165 lines (158 loc) · 5.27 KB
/
eslint.config.js
File metadata and controls
165 lines (158 loc) · 5.27 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
import prettierPlugin from 'eslint-plugin-prettier';
export default [
eslint.configs.recommended,
...tseslint.configs.recommended,
{
ignores: [
'node_modules/**',
'build/**',
'dist/**',
'coverage/**',
'src/core/generated-plugins.ts',
'src/core/generated-resources.ts',
],
},
{
// TypeScript files in src/ directory (covered by tsconfig.json)
files: ['src/**/*.ts'],
languageOptions: {
ecmaVersion: 2020,
sourceType: 'module',
parser: tseslint.parser,
parserOptions: {
project: ['./tsconfig.json'],
},
},
plugins: {
'@typescript-eslint': tseslint.plugin,
prettier: prettierPlugin,
},
rules: {
'prettier/prettier': 'error',
'@typescript-eslint/explicit-function-return-type': 'warn',
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: 'never',
varsIgnorePattern: 'never',
},
],
'no-console': ['warn', { allow: ['error'] }],
// Prevent dangerous type casting anti-patterns (errors)
'@typescript-eslint/consistent-type-assertions': [
'error',
{
assertionStyle: 'as',
objectLiteralTypeAssertions: 'never',
},
],
'@typescript-eslint/no-unsafe-argument': 'error',
'@typescript-eslint/no-unsafe-assignment': 'error',
'@typescript-eslint/no-unsafe-call': 'error',
'@typescript-eslint/no-unsafe-member-access': 'error',
'@typescript-eslint/no-unsafe-return': 'error',
// Prevent specific anti-patterns we found
'@typescript-eslint/ban-ts-comment': [
'error',
{
'ts-expect-error': 'allow-with-description',
'ts-ignore': true,
'ts-nocheck': true,
'ts-check': false,
},
],
// Encourage best practices (warnings - can be gradually fixed)
'@typescript-eslint/prefer-as-const': 'warn',
'@typescript-eslint/prefer-nullish-coalescing': 'warn',
'@typescript-eslint/prefer-optional-chain': 'warn',
// Prevent barrel imports to maintain architectural improvements
'no-restricted-imports': [
'error',
{
patterns: [
{
group: [
'**/utils/index.js',
'../utils/index.js',
'../../utils/index.js',
'../../../utils/index.js',
'**/utils/index.ts',
'../utils/index.ts',
'../../utils/index.ts',
'../../../utils/index.ts',
],
message:
'Barrel imports from utils/index are prohibited. Use focused facade imports instead (e.g., utils/logging/index.ts, utils/execution/index.ts).',
},
{
group: ['./**/*.js', '../**/*.js'],
message:
'Import TypeScript files with .ts extension, not .js. This ensures compatibility with native TypeScript runtimes like Bun and Deno. Change .js to .ts in your import path.',
},
],
},
],
},
},
{
// JavaScript and TypeScript files outside the main project (scripts/, etc.)
files: ['**/*.{js,ts}'],
ignores: ['src/**/*', '**/*.test.ts'],
languageOptions: {
ecmaVersion: 2020,
sourceType: 'module',
parser: tseslint.parser,
// No project reference for scripts - use standalone parsing
},
plugins: {
'@typescript-eslint': tseslint.plugin,
prettier: prettierPlugin,
},
rules: {
'prettier/prettier': 'error',
// Relaxed TypeScript rules for scripts since they're not in the main project
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-unused-vars': [
'warn',
{
argsIgnorePattern: 'never',
varsIgnorePattern: 'never',
},
],
'no-console': 'off', // Scripts are allowed to use console
// Disable project-dependent rules for scripts
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/prefer-nullish-coalescing': 'off',
'@typescript-eslint/prefer-optional-chain': 'off',
},
},
{
files: ['**/*.test.ts'],
languageOptions: {
parser: tseslint.parser,
parserOptions: {
project: './tsconfig.test.json',
},
},
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'prefer-const': 'off',
// Relax unsafe rules for tests - tests often need more flexibility
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
},
},
];