-
Notifications
You must be signed in to change notification settings - Fork 122
Expand file tree
/
Copy patheslint.config.mjs
More file actions
263 lines (251 loc) · 8.5 KB
/
eslint.config.mjs
File metadata and controls
263 lines (251 loc) · 8.5 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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
import js from '@eslint/js';
import { configs as tseslintConfigs } from 'typescript-eslint';
import prettierConfig from 'eslint-config-prettier';
import { importX } from 'eslint-plugin-import-x';
export default [
js.configs.recommended,
...tseslintConfigs.recommended,
importX.flatConfigs.recommended,
importX.flatConfigs.typescript,
prettierConfig,
{
ignores: [
'**/dist/**',
'**/dist-types/**',
'**/node_modules/**',
// Generated/vendor files that shouldn't be linted
'**/pdfjs.js',
'**/worker.js',
'**/pdfjs-worker.js',
'**/*.min.js',
'**/vendor/**',
'**/lib/**/*.umd.js',
'packages/preset-geometry/**',
// Generated TypeScript declaration files (auto-generated by tsc)
'**/src/**/*.d.ts',
'**/src/**/*.d.ts.map',
// Test files
'**/*.test.js',
'**/*.test.ts',
'**/*.test.tsx',
'**/*.spec.js',
'**/tests/**',
'**/test/**',
// Docs (Mintlify site with its own conventions)
'apps/docs/**',
// Examples (different environments and coding styles)
'examples/**',
'**/examples/**',
// Demos (different environments and dependency sets)
'demos/**',
'**/demos/**',
// Config files (CommonJS/different environments)
'**/*.config.js',
'**/*.cjs',
'**/commitlint.config.js',
// E2E tests
'e2e-tests/**',
// SDK scripts — ESM parsed incorrectly by typescript-eslint
'packages/sdk/scripts/**',
],
},
{
settings: {
'import-x/resolver': {
// Prefer repo source entrypoints during lint so workspace packages do
// not depend on generated dist artifacts before the build step runs.
node: {
conditionNames: ['source', 'import', 'require', 'node', 'default'],
mainFields: ['source', 'module', 'main'],
},
typescript: {
conditionNames: ['source', 'types', 'import', 'require', 'node', 'default'],
mainFields: ['source', 'module', 'main'],
},
},
},
},
{
languageOptions: {
// Globals for mixed browser/Node.js codebase
globals: {
// Universal APIs (available in both environments)
console: 'readonly',
fetch: 'readonly',
AbortSignal: 'readonly',
setTimeout: 'readonly',
clearTimeout: 'readonly',
setInterval: 'readonly',
clearInterval: 'readonly',
// Browser APIs (client-side code)
window: 'readonly',
document: 'readonly',
navigator: 'readonly',
File: 'readonly',
URL: 'readonly',
Blob: 'readonly',
DOMParser: 'readonly',
atob: 'readonly',
screen: 'readonly',
requestAnimationFrame: 'readonly',
URLSearchParams: 'readonly',
TextDecoder: 'readonly',
FileReader: 'readonly',
DOMRect: 'readonly',
// DOM APIs (text editing, clipboard, elements)
HTMLElement: 'readonly',
Node: 'readonly',
DataTransfer: 'readonly',
ClipboardEvent: 'readonly',
TextSelection: 'readonly',
CustomEvent: 'readonly',
// Prosemirror library APIs
ReplaceAroundStep: 'readonly',
mergeAttributes: 'readonly',
splitCell: 'readonly',
// Utility functions and constants
dateFormat: 'readonly',
fontSize: 'readonly',
nodeListHandler: 'readonly',
node: 'readonly',
// Node.js APIs (server-side code)
Buffer: 'readonly',
__dirname: 'readonly',
process: 'readonly',
global: 'readonly',
// Build constants
__IS_DEBUG__: 'readonly',
__APP_VERSION__: 'readonly',
version: 'readonly',
superdoc: 'readonly',
},
},
rules: {
'no-unused-vars': ['warn', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }], // See warnings but don't block
// Relax these rules - they're more style than bugs
'no-empty': ['warn', { allowEmptyCatch: true }], // Allow empty catch blocks
'no-case-declarations': 'off', // Common pattern in switch statements
'no-control-regex': 'off', // Sometimes needed for text processing
'no-useless-escape': 'warn', // Warn but don't error
// Keep as warnings to address gradually
'no-unsafe-optional-chaining': 'warn', // Important but not critical
'no-unused-private-class-members': 'warn', // Clean up when refactoring
// Prevent imports across package boundaries
'import-x/no-relative-packages': [
'error',
{
// Allow importing top-level vitest.baseConfig and vite.sourceResolve
ignore: [
'^.*/vitest.baseConfig$',
'^.*/vite.sourceResolve$',
],
}
],
'import-x/no-unresolved': [
'error',
{
// Temporarily all "@"-prefixed imports. This should likely be changed to use https://github.com/pzmosquito/eslint-import-resolver-vite to properly resolve these aliases
ignore: [
'^@.*$',
'^bun:.*$', // Bun built-in modules
'^superdoc$',
'^superdoc/.*$',
'^\\..*/generated/', // Generated files (codegen artifacts, not in git)
],
}
]
},
},
// TypeScript-specific configuration
{
files: ['**/*.ts', '**/*.tsx'],
rules: {
// TypeScript handles these better than ESLint
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': [
'warn',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
},
],
// Relax some TypeScript rules for incremental adoption
'@typescript-eslint/no-explicit-any': 'warn', // Gradually remove 'any'
'@typescript-eslint/no-non-null-assertion': 'off', // Used carefully in adapters
'@typescript-eslint/no-empty-function': 'warn', // Allow for test mocks
},
},
// Mock files configuration (JavaScript files in __mocks__ directories)
{
files: ['**/__mocks__/**/*.js'],
rules: {
// Disable TypeScript rule for JavaScript mock files
'@typescript-eslint/no-unused-vars': 'off',
// JavaScript rule with underscore pattern already applied
},
},
// Parts boundary enforcement: prevent direct writes to convertedXml outside part-store.ts
{
files: [
'packages/super-editor/src/editors/v1/**/*.ts',
'packages/super-editor/src/editors/v1/**/*.js',
],
ignores: [
'packages/super-editor/src/editors/v1/core/parts/store/part-store.ts',
// Test helpers set up mock convertedXml for part tests
'packages/super-editor/src/editors/v1/core/parts/testing/**',
// Import/export phases are exempt (initial document load and final export)
'packages/super-editor/src/editors/v1/core/super-converter/**',
// Validator normalizes rels key paths during document load
'packages/super-editor/src/editors/v1/core/super-validator/**',
],
rules: {
'no-restricted-syntax': [
'warn',
{
selector: "AssignmentExpression > MemberExpression[property.name='convertedXml']",
message:
'Direct assignment to convertedXml is prohibited. Use setPart/removePart from core/parts/store/part-store.ts, or mutatePart/mutateParts for mutations.',
},
{
selector: "AssignmentExpression > MemberExpression[object.property.name='convertedXml'][computed=true]",
message:
'Direct assignment to convertedXml[...] is prohibited. Use setPart/removePart from core/parts/store/part-store.ts, or mutatePart/mutateParts for mutations.',
},
],
},
},
{
files: ['packages/super-editor/src/editors/v1/extensions/**/*.js'],
rules: {
'@typescript-eslint/ban-ts-comment': 'off',
'no-unused-vars': [
'warn',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
},
],
'@typescript-eslint/no-unused-vars': 'off',
},
},
{
files: ['packages/super-editor/src/editors/v1/extensions/types/**/*.ts'],
rules: {
'@typescript-eslint/no-empty-object-type': [
'off',
{
allowInterfacesWithSingleExtends: true,
},
],
},
},
{
files: ['packages/super-editor/src/editors/v1/core/types/ChainedCommands.ts'],
rules: {
// These empty interfaces are intentionally used for declaration merging
// Extensions augment them via module augmentation to add typed commands
'@typescript-eslint/no-empty-object-type': 'off',
},
},
];