forked from szymdzum/browser-debugger-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.js
More file actions
217 lines (203 loc) · 6.6 KB
/
eslint.config.js
File metadata and controls
217 lines (203 loc) · 6.6 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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
import js from '@eslint/js';
import tseslint from '@typescript-eslint/eslint-plugin';
import tsparser from '@typescript-eslint/parser';
import importPlugin from 'eslint-plugin-import';
import unusedImports from 'eslint-plugin-unused-imports';
import noRelativeImportPaths from 'eslint-plugin-no-relative-import-paths';
import tsdoc from 'eslint-plugin-tsdoc';
import prettierConfig from 'eslint-config-prettier';
import globals from 'globals';
export default [
// Apply to TypeScript files
{
files: ['src/**/*.ts'],
languageOptions: {
parser: tsparser,
parserOptions: {
project: './tsconfig.json',
ecmaVersion: 2022,
sourceType: 'module',
},
globals: {
...globals.node,
},
},
plugins: {
'@typescript-eslint': tseslint,
import: importPlugin,
'unused-imports': unusedImports,
'no-relative-import-paths': noRelativeImportPaths,
tsdoc: tsdoc,
},
rules: {
...js.configs.recommended.rules,
...tseslint.configs.recommended.rules,
...tseslint.configs['recommended-requiring-type-checking'].rules,
// Disable no-undef for TypeScript files (TypeScript handles this better)
'no-undef': 'off',
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/prefer-nullish-coalescing': 'error',
'@typescript-eslint/prefer-optional-chain': 'error',
'@typescript-eslint/consistent-type-imports': [
'error',
{
prefer: 'type-imports',
fixStyle: 'separate-type-imports',
},
],
'@typescript-eslint/consistent-type-exports': [
'error',
{ fixMixedExportsWithInlineTypeSpecifier: true },
],
'@typescript-eslint/explicit-function-return-type': [
'warn',
{
allowExpressions: true,
allowTypedFunctionExpressions: true,
allowHigherOrderFunctions: true,
},
],
// Disable base rule as it conflicts with unused-imports plugin
'@typescript-eslint/no-unused-vars': 'off',
// Use unused-imports plugin for better unused variable detection
'unused-imports/no-unused-imports': 'error',
'unused-imports/no-unused-vars': [
'error',
{
vars: 'all',
varsIgnorePattern: '^_',
args: 'after-used',
argsIgnorePattern: '^_',
},
],
// Disallow unused expressions
'@typescript-eslint/no-unused-expressions': [
'error',
{
allowShortCircuit: true,
allowTernary: true,
allowTaggedTemplates: true,
},
],
// Enhanced promise handling
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/await-thenable': 'error',
'@typescript-eslint/no-misused-promises': 'error',
'@typescript-eslint/require-await': 'warn',
// Type safety improvements
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
'@typescript-eslint/prefer-as-const': 'error',
'@typescript-eslint/no-non-null-assertion': 'warn',
// Switch exhaustiveness check
'@typescript-eslint/switch-exhaustiveness-check': [
'error',
{
allowDefaultCaseForExhaustiveSwitch: false,
requireDefaultForNonUnion: true,
},
],
// TSDoc syntax validation
'tsdoc/syntax': 'warn',
// Import path consistency - enforce @/* over relative paths
'no-relative-import-paths/no-relative-import-paths': [
'error',
{
allowSameFolder: true,
rootDir: 'src',
prefix: '@',
},
],
'import/no-unresolved': 'error',
'import/order': [
'warn',
{
groups: ['builtin', 'external', 'type', 'internal', 'parent', 'sibling', 'index'],
pathGroups: [
{
pattern: '@/**',
group: 'internal',
},
],
'newlines-between': 'always',
alphabetize: {
order: 'asc',
},
},
],
// Dependency layer enforcement - prevent architectural violations
'import/no-restricted-paths': [
'error',
{
zones: [
// Utils layer (Layer 1) cannot import from higher layers (except as noted)
{
target: './src/utils',
from: './src/commands',
message: 'Utils cannot import from commands (layer violation)',
},
{
target: './src/utils',
from: './src/daemon',
message: 'Utils cannot import from daemon (layer violation)',
},
// Note: utils → ui is allowed for messages/logging/OutputBuilder
// This is a pragmatic exception for error formatting and output building
// Connection layer (Layer 1) cannot import from session layer (Layer 2)
{
target: './src/connection',
from: './src/session',
message: 'Connection cannot import from session (creates circular dependency)',
},
// UI layer (Layer 3) cannot import from commands layer (Layer 4)
{
target: './src/ui',
from: './src/commands',
message: 'UI cannot import from commands (upward dependency)',
},
// Types module can import from connection for Protocol types, but that's it
{
target: './src/types',
from: './src/commands',
message: 'Types cannot import from commands',
},
{
target: './src/types',
from: './src/ui',
message: 'Types cannot import from UI',
},
{
target: './src/types',
from: './src/session',
message: 'Types cannot import from session',
},
{
target: './src/types',
from: './src/daemon',
message: 'Types cannot import from daemon',
},
],
},
],
},
settings: {
'import/resolver': {
typescript: {
project: './tsconfig.json',
},
},
},
},
// Test files - disable no-floating-promises for Node.js test runner
{
files: ['src/**/__tests__/**/*.test.ts', 'src/**/__tests__/**/*.contract.test.ts'],
rules: {
'@typescript-eslint/no-floating-promises': 'off',
},
},
// Prettier integration - disable conflicting rules
prettierConfig,
// Ignore patterns
{
ignores: ['dist/**', 'node_modules/**', '*.js', '!eslint.config.js'],
},
];