Repository navigation
Expand file tree
/
Copy patheslint.config.js
More file actions
444 lines (440 loc) · 16.7 KB
/
Copy patheslint.config.js
File metadata and controls
444 lines (440 loc) · 16.7 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
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
import vuetify from 'eslint-config-vuetify'
// Shared selectors. `ts` applies to packages/0/src non-test TypeScript.
// `vue` applies to packages/0/src Vue SFCs. `both` applies to each.
// Line-level eslint-disable comments are the allowlist for the few legal sites
// (guard implementations, IN_BROWSER, the listener primitives, createContext).
const nullGuardMessage = 'Use #v0/utilities guards (isNull, isUndefined, isNullOrUndefined) instead of a raw null or undefined comparison (PHILOSOPHY §2.3).'
const syntaxSelectors = [
{ appliesTo: 'both', selector: 'BinaryExpression[operator="==="][right.raw=/^null$/]', message: nullGuardMessage },
{ appliesTo: 'both', selector: 'BinaryExpression[operator="!=="][right.raw=/^null$/]', message: nullGuardMessage },
{ appliesTo: 'both', selector: 'BinaryExpression[operator="=="][right.raw=/^null$/]', message: nullGuardMessage },
{ appliesTo: 'both', selector: 'BinaryExpression[operator="!="][right.raw=/^null$/]', message: nullGuardMessage },
{ appliesTo: 'both', selector: 'BinaryExpression[operator="==="][left.raw=/^null$/]', message: nullGuardMessage },
{ appliesTo: 'both', selector: 'BinaryExpression[operator="!=="][left.raw=/^null$/]', message: nullGuardMessage },
{ appliesTo: 'both', selector: 'BinaryExpression[operator="=="][left.raw=/^null$/]', message: nullGuardMessage },
{ appliesTo: 'both', selector: 'BinaryExpression[operator="!="][left.raw=/^null$/]', message: nullGuardMessage },
{ appliesTo: 'both', selector: 'BinaryExpression[operator="==="][left.name=/^undefined$/]', message: nullGuardMessage },
{ appliesTo: 'both', selector: 'BinaryExpression[operator="==="][right.name=/^undefined$/]', message: nullGuardMessage },
{ appliesTo: 'both', selector: 'BinaryExpression[operator="!=="][left.name=/^undefined$/]', message: nullGuardMessage },
{ appliesTo: 'both', selector: 'BinaryExpression[operator="!=="][right.name=/^undefined$/]', message: nullGuardMessage },
{
appliesTo: 'both',
selector: 'UnaryExpression[operator="typeof"][argument.name=/^(?:window|document)$/]',
message: 'Use IN_BROWSER and SUPPORTS_* from #v0/constants/globals instead of typeof window/document (PHILOSOPHY §2.10).',
},
{
appliesTo: 'both',
selector: 'UnaryExpression[operator="typeof"][argument.object.name=/^(?:window|document)$/]',
message: 'Use IN_BROWSER and SUPPORTS_* from #v0/constants/globals instead of typeof window/document (PHILOSOPHY §2.10).',
},
{
appliesTo: 'both',
selector: 'CallExpression[callee.object.name="Math"][callee.property.name="random"]',
message: 'Do not use Math.random() for ids. Use useId() from #v0/utilities (PHILOSOPHY §2.8).',
},
{
appliesTo: 'both',
selector: 'CallExpression[callee.name=/^(?:inject|provide)$/]',
message: 'Do not call Vue inject/provide directly. Use createContext (PHILOSOPHY §6.5).',
},
{
appliesTo: 'ts',
selector: 'CallExpression[callee.property.name="addEventListener"]',
message: 'Composables do not bind DOM events. The listener primitives are useEventListener, useHotkey, useClickOutside, and useMediaQuery (PHILOSOPHY §2.5).',
},
{
appliesTo: 'ts',
selector: 'CallExpression[callee.property.name="querySelector"]',
message: 'Composables must not querySelector. Pass an element in, or look it up from a component (PHILOSOPHY §2.5).',
},
{
appliesTo: 'ts',
selector: 'CallExpression[callee.property.name="querySelectorAll"]',
message: 'Composables must not querySelector. Pass an element in, or look it up from a component (PHILOSOPHY §2.5).',
},
{
appliesTo: 'ts',
selector: String.raw`ExportAllDeclaration[source.value=/\.vue$/]`,
message: 'Never export * from a .vue file. It breaks Volar slot inference (PHILOSOPHY §8.8).',
},
]
function syntaxRules (appliesTo) {
return syntaxSelectors
.filter(entry => entry.appliesTo === appliesTo || entry.appliesTo === 'both')
.map(({ selector, message }) => ({ selector, message }))
}
export default vuetify({
vue: true,
perfectionist: {
import: false,
},
autoimports: false,
test: {
runner: 'vitest',
},
},
{
rules: {
'import/first': 'off',
'curly': 'off',
'@stylistic/operator-linebreak': 'off',
// eslint-config-vuetify 4.7.2 — flood / unsafe-autofix / AST false positives.
// Keep the small correctness set (css-escape, empty lookahead, dupe
// disjunctions, unused capturing groups) and fix those in source.
'unicorn/no-this-outside-of-class': 'off',
'unicorn/no-unused-array-method-return': 'off',
'unicorn/numeric-separators-style': 'off',
'unicorn/prefer-split-limit': 'off',
'unicorn/prefer-includes-over-repeated-comparisons': 'off',
'unicorn/prefer-https': 'off',
'unicorn/prefer-string-repeat': 'off',
'unicorn/consistent-compound-words': 'off',
'unicorn/better-dom-traversing': 'off',
'regexp/use-ignore-case': 'off',
'regexp/prefer-w': 'off',
'regexp/strict': 'off',
'regexp/no-super-linear-backtracking': 'off',
'regexp/optimal-quantifier-concatenation': 'off',
'regexp/prefer-d': 'off',
'regexp/prefer-character-class': 'off',
'regexp/match-any': 'off',
'prefer-regex-literals': 'off',
},
},
{
files: ['**/*.ts', '**/*.vue'],
rules: {
'@typescript-eslint/no-explicit-any': 'error',
'import/consistent-type-specifier-style': ['error', 'prefer-top-level'],
'unicorn/no-array-callback-reference': 'off',
'unicorn/no-unreadable-array-destructuring': 'off',
'func-style': ['error', 'declaration'],
'one-var': ['error', 'never'],
'no-restricted-syntax': ['error',
{
selector: 'CallExpression[callee.name="withDefaults"]',
message: 'Use destructuring with defaults instead of withDefaults.',
},
],
'perfectionist/sort-exports': 'off',
'perfectionist/sort-imports': ['error', {
type: 'natural',
order: 'asc',
ignoreCase: true,
newlinesBetween: 1,
groups: [
'builtin',
'external',
{ newlinesBetween: 1 },
{ group: 'framework', commentAbove: 'Framework' },
{ newlinesBetween: 1 },
{ group: 'components', commentAbove: 'Components' },
{ newlinesBetween: 1 },
{ group: 'context', commentAbove: 'Context' },
{ newlinesBetween: 1 },
{ group: 'composables', commentAbove: 'Composables' },
{ newlinesBetween: 1 },
{ group: 'adapters', commentAbove: 'Adapters' },
{ newlinesBetween: 1 },
{ group: 'transformers', commentAbove: 'Transformers' },
{ newlinesBetween: 1 },
'internal',
'sibling',
'index',
{ newlinesBetween: 1 },
{ group: 'stores', commentAbove: 'Stores' },
{ newlinesBetween: 1 },
{ group: 'utilities', commentAbove: 'Utilities' },
{ newlinesBetween: 1 },
{ group: 'type', commentAbove: 'Types' },
],
customGroups: [
{ groupName: 'framework', modifiers: ['value'], elementNamePattern: '^@vuetify/v0' },
{ groupName: 'adapters', modifiers: ['value'], elementNamePattern: '/adapters' },
{ groupName: 'components', modifiers: ['value'], elementNamePattern: '/components/' },
{ groupName: 'context', modifiers: ['value'], elementNamePattern: String.raw`^\./.*\.vue$` },
{ groupName: 'transformers', modifiers: ['value'], elementNamePattern: '/to[A-Z]' },
{ groupName: 'composables', modifiers: ['value'], elementNamePattern: ['/composables/', '/use[A-Z]'] },
{ groupName: 'stores', modifiers: ['value'], elementNamePattern: ['/stores/', '/stores$', '^@vuetify/auth$'] },
{ groupName: 'utilities', modifiers: ['value'], elementNamePattern: ['/utilities', '/utils', '/helpers', '^vue$', '^vue-router$', '^pinia$', '^@vue/'] },
],
}],
},
},
{
files: ['**/*.test.ts'],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'vitest/prefer-lowercase-title': 'error',
'vitest/prefer-hooks-in-order': 'error',
'vitest/prefer-hooks-on-top': 'error',
'vitest/max-nested-describe': ['error', { max: 3 }],
'vitest/consistent-test-it': ['error', { fn: 'it' }],
},
},
{
files: ['**/scripts/**/*.ts', '**/build/**/*.ts'],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
},
},
{
// @paper/bulma conformance tests: conform() throws on mismatch — it IS the assertion
files: ['packages/bulma/**/*.browser.test.ts'],
rules: {
'vitest/expect-expect': ['error', { assertFunctionNames: ['expect', 'conform'] }],
},
},
{
files: ['**/*.vue'],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'vue/block-order': ['error', { order: ['script', 'template', 'style'] }],
'vue/v-bind-style': ['error', 'shorthand', { sameNameShorthand: 'always' }],
},
},
{
files: ['apps/docs/src/examples/**/*.vue', 'apps/docs/src/examples/**/*.ts'],
rules: {
'perfectionist/sort-imports': 'off',
},
},
{
name: 'pnpm/pnpm-workspace-yaml',
files: ['pnpm-workspace.yaml'],
rules: {
'pnpm/yaml-no-unused-catalog-item': 'error',
'pnpm/yaml-no-duplicate-catalog-item': 'error',
},
},
{
ignores: ['**/node_modules/**', '**/dist/**'],
files: ['package.json', '**/package.json'],
rules: {
'pnpm/json-enforce-catalog': 'error',
},
},
{
// The vapor test package intentionally pins Vue 3.6 beta + the Vapor runtime.
// They can't be cataloged: a second catalog entry for `vue` would duplicate
// the default catalog's 3.5.x and trip pnpm/yaml-no-duplicate-catalog-item.
// Allow these specifiers to stay un-cataloged in this one package only.
files: ['tests/vapor/package.json'],
rules: {
'pnpm/json-enforce-catalog': ['error', {
ignores: ['vue', '@vue/runtime-vapor', '@vitejs/plugin-vue'],
}],
},
},
{
ignores: ['**/export-templates/package.json'],
},
{
// Enforce V0Error over bare Error for throw sites in the core package.
// This prevents contributors from accidentally bypassing the typed error
// registry (V0ErrorDetails) that gives consumers a stable code discriminant.
name: 'vuetify/no-bare-error-throw',
files: ['packages/0/src/**/*.ts'],
ignores: ['packages/0/src/**/*.test.ts', 'packages/0/src/**/*.bench.ts'],
rules: {
'no-restricted-syntax': ['error',
{
selector: 'ThrowStatement > NewExpression[callee.name="Error"]',
message: 'Use V0Error with a code from V0ErrorDetails instead of bare Error. See packages/0/src/utilities/errors.ts.',
},
...syntaxRules('ts'),
],
},
},
{
name: 'vuetify/locale-ti-requires-fallback',
files: ['packages/0/src/**/*.vue'],
rules: {
'no-restricted-syntax': ['error',
{
selector: 'CallExpression[callee.name="withDefaults"]',
message: 'Use destructuring with defaults instead of withDefaults.',
},
{
selector: 'CallExpression[callee.property.name="ti"]:not(LogicalExpression[operator="??"] > CallExpression[callee.property.name="ti"])',
message: 'locale.ti() must be guarded with a `?? \'<inline English default>\'` so unconfigured apps get an accessible name. See packages/0/src/locale/messages/en for canonical strings.',
},
{
selector: 'CallExpression[callee.name="onUnmounted"]',
message: 'Use onBeforeUnmount for cleanup. onUnmounted runs after the context is gone (PHILOSOPHY §7.3).',
},
{
selector: 'TSAsExpression > TSAnyKeyword',
message: 'Do not use `as any`. defineSlots `=> any` and Atom\'s Record<string, any> generic are the only allowed any (PHILOSOPHY §2.2).',
},
{
selector: 'TSTypeAnnotation:not(TSFunctionType > TSTypeAnnotation) > TSAnyKeyword',
message: 'Do not annotate a value as any. Slot return `=> any` is the allowed form (PHILOSOPHY §2.2).',
},
...syntaxRules('vue'),
],
},
},
{
// Adapter DOM lookup, the createCombobox option-node getter, and useFocusTrap
// scanning descendants of a root the caller already passed in.
// TODO(ops#74): remove createCombobox/index.ts once that getter moves to the component.
name: 'vuetify/query-selector-allowlist',
files: [
'packages/0/src/composables/**/adapters/**/*.ts',
'packages/0/src/composables/createCombobox/index.ts',
'packages/0/src/composables/useFocusTrap/**/*.ts',
],
ignores: ['packages/0/src/**/*.test.ts', 'packages/0/src/**/*.bench.ts'],
rules: {
'no-restricted-syntax': ['error',
{
selector: 'ThrowStatement > NewExpression[callee.name="Error"]',
message: 'Use V0Error with a code from V0ErrorDetails instead of bare Error. See packages/0/src/utilities/errors.ts.',
},
...syntaxRules('ts').filter(entry => !entry.selector.includes('querySelector')),
],
},
},
{
name: 'vuetify/no-v0-imports',
files: ['packages/paper/**/*.{ts,js,vue}', 'app/**/*.{ts,js,vue}'],
rules: {
'no-restricted-imports': ['error', {
patterns: [{
group: [String.raw`\#v0/**`],
message: 'Use @vuetify/v0 import',
}],
}],
},
},
{
// PHILOSOPHY §9.2. Ignored files are the console implementation, not callers:
// createFallbackLogger, V0LoggerAdapter, the Layer-0 context warning, and useId's SSR warning.
name: 'vuetify/no-console',
files: ['packages/0/src/**/*.{ts,vue}'],
ignores: [
'packages/0/src/**/*.test.ts',
'packages/0/src/**/*.browser.test.ts',
'packages/0/src/**/*.bench.ts',
'packages/0/src/composables/useLogger/index.ts',
'packages/0/src/composables/useLogger/adapters/v0.ts',
'packages/0/src/composables/createContext/index.ts',
'packages/0/src/utilities/helpers.ts',
],
rules: {
'no-console': 'error',
},
},
{
name: 'vuetify/no-cross-feature-relative',
files: ['packages/0/src/**/*.{ts,vue}'],
ignores: [
'packages/0/src/**/adapters/**',
'packages/0/src/components/fixtures/**',
'packages/0/src/**/*.bench.ts',
],
rules: {
'no-restricted-imports': ['error', {
patterns: [{
group: ['..', '../*', '../**'],
message: 'Cross-feature relative imports are banned. Use #v0/. Sibling ./ imports stay legal. Adapters may import their parent with ../ (PHILOSOPHY §2.4).',
}],
}],
},
},
{
name: 'vuetify/adapter-relative-depth',
files: ['packages/0/src/**/adapters/**/*.{ts,vue}'],
rules: {
'no-restricted-imports': ['error', {
patterns: [{
group: ['../..', '../../*', '../../**'],
message: 'Adapter files may import their parent feature (../) only. Use #v0/ past that (PHILOSOPHY §2.4).',
}],
}],
},
},
{
name: 'vuetify/fixture-relative-depth',
files: ['packages/0/src/components/fixtures/**/*.{ts,vue}'],
rules: {
'no-restricted-imports': ['error', {
patterns: [{
group: ['../../..', '../../../*', '../../../**'],
message: 'Fixture imports may reach a component barrel (../ or ../../) but not higher. Use #v0/ past that (PHILOSOPHY §2.4).',
}],
}],
},
},
{
name: 'vuetify/bench-public-imports',
files: ['packages/0/src/**/*.bench.ts'],
rules: {
'no-restricted-imports': ['error', {
patterns: [
{
group: ['#v0', '#v0/*', '#v0/**'],
message: 'Benchmarks import the public @vuetify/v0 surface so the history harness measures installed versions, not source (benchmarks.md).',
},
{
group: ['./index', './index.ts', './index.js'],
message: 'Do not import ./index from a bench file. Use @vuetify/v0. Fixture imports (./fixtures) stay relative.',
},
],
}],
},
},
{
name: 'vuetify/sort-barrels',
files: [
'packages/0/src/components/index.ts',
'packages/0/src/composables/index.ts',
],
rules: {
'perfectionist/sort-exports': ['error', {
type: 'natural',
order: 'asc',
ignoreCase: true,
}],
},
},
{
// Keeps the withDefaults ban from the shared TS/Vue block. A later
// no-restricted-syntax override replaces the whole selector list.
name: 'vuetify/test-assertions',
files: ['**/*.test.ts'],
rules: {
'no-restricted-syntax': ['error',
{
selector: 'CallExpression[callee.name="withDefaults"]',
message: 'Use destructuring with defaults instead of withDefaults.',
},
{
selector: 'CallExpression[callee.property.name="toHaveBeenCalledOnce"]',
message: 'Use toHaveBeenCalledTimes(1) (testing.md).',
},
],
},
},
{
name: 'vuetify/no-marked-outside-pipeline',
files: ['apps/docs/**/*.{ts,vue}'],
ignores: [
'apps/docs/src/composables/useMarkdown.ts',
'apps/docs/src/utilities/markdown.ts',
],
rules: {
'no-restricted-syntax': ['error',
{
selector: 'CallExpression[callee.name="withDefaults"]',
message: 'Use destructuring with defaults instead of withDefaults.',
},
{
selector: 'NewExpression[callee.name="Marked"]',
message: 'Instantiate Marked only inside useMarkdown (docs.md). Extend that pipeline instead of constructing another one.',
},
],
},
},
)