Repository navigation
Expand file tree
/
Copy patheslint.config.js
More file actions
474 lines (457 loc) · 15.4 KB
/
Copy patheslint.config.js
File metadata and controls
474 lines (457 loc) · 15.4 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
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
import js from "@eslint/js";
import { defineConfigWithVueTs, vueTsConfigs } from "@vue/eslint-config-typescript";
import importPlugin from "eslint-plugin-import";
import nounsanitized from "eslint-plugin-no-unsanitized";
import prettierPlugin from "eslint-plugin-prettier/recommended";
import sonarjs from "eslint-plugin-sonarjs";
import sortExportAll from "eslint-plugin-sort-export-all";
import sortExports from "eslint-plugin-sort-exports";
import storybook from "eslint-plugin-storybook";
import tailwindcss from "eslint-plugin-tailwindcss";
import vuejsAccessibility from "eslint-plugin-vuejs-accessibility";
import globals from "globals";
import tseslint from "typescript-eslint";
import vueParser from "vue-eslint-parser";
const tsconfigRootDir = import.meta.dirname;
const tsconfigs = {
app: "./tsconfig.app.json",
node: "./tsconfig.node.json",
storybook: "./tsconfig.storybook.json",
vitest: "./tsconfig.vitest.json",
examples: "./examples/tsconfig.json",
};
export default defineConfigWithVueTs(
{
ignores: [
"**/node_modules/",
"dist/",
// Generated, self-contained @vc-frontend/core type contract (see client-app/core-api/README.md).
"client-app/core-api/contract/",
// Outside the host tsconfig projects; build-types.mjs type-checks them against the contract.
"client-app/core-api/manifest.d.mts",
"client-app/core-api/contract-checks/",
".certificates/",
"artifacts/",
"storybook-static/",
"storybook-styles/dist/",
"client-app/public/fcm-service-worker-*.js",
".deployment/",
".github/",
".husky/",
".vscode/",
".yarn/",
"assets/",
"content/",
"client-app/modules/**/api/graphql/types.ts",
"client-app/core/api/graphql/**/types.ts",
"coverage/",
".history/",
],
},
// Base configurations
js.configs.recommended,
sonarjs.configs.recommended,
...storybook.configs["flat/recommended"],
...vuejsAccessibility.configs["flat/recommended"],
...tailwindcss.configs["flat/recommended"],
vueTsConfigs.recommended,
// General configuration for all files
{
linterOptions: {
reportUnusedDisableDirectives: "error",
},
languageOptions: {
ecmaVersion: "latest",
sourceType: "module",
globals: {
...globals.browser,
...globals.node,
...globals.worker,
Accept: "readonly",
},
},
plugins: {
import: importPlugin,
"sort-export-all": sortExportAll,
"sort-exports": sortExports,
tailwindcss,
"vuejs-accessibility": vuejsAccessibility,
},
rules: {
// General rules
// Error-level rules
"@typescript-eslint/no-misused-promises": [
"error",
{
checksVoidReturn: {
arguments: false,
},
},
],
"@typescript-eslint/no-shadow": "error",
"@typescript-eslint/no-unsafe-argument": "error",
"@typescript-eslint/no-unsafe-assignment": "error",
"@typescript-eslint/no-unsafe-call": "error",
"@typescript-eslint/no-unsafe-enum-comparison": "error",
"@typescript-eslint/no-unsafe-member-access": "error",
"@typescript-eslint/no-unsafe-return": "error",
"@typescript-eslint/no-unnecessary-type-assertion": "error",
curly: "error",
"import/no-cycle": "error",
"import/no-unresolved": "error",
"no-debugger": process.env.NODE_ENV === "production" ? "error" : "warn",
"vue/block-lang": ["error", { script: { lang: "ts" } }],
"vue/no-duplicate-attr-inheritance": "error",
"vue/no-irregular-whitespace": "error",
"vue/no-setup-props-reactivity-loss": "error",
"vue/prefer-prop-type-boolean-first": "error",
"vue/prefer-true-attribute-shorthand": "error",
"vue/v-for-delimiter-style": "error",
"vue/valid-define-options": "error",
"vuejs-accessibility/anchor-has-content": [
"error",
{
accessibleChildren: ["i", "img", "VcIcon"],
accessibleDirectives: ["t"],
},
],
"vuejs-accessibility/heading-has-content": [
"error",
{
components: ["VcTypography"],
accessibleDirectives: ["t"],
},
],
// Warning-level rules
"@typescript-eslint/consistent-type-imports": ["warn", { disallowTypeAnnotations: false }],
"@typescript-eslint/naming-convention": [
"warn",
{ selector: "interface", format: ["PascalCase"], prefix: ["I"] },
{ selector: "typeAlias", format: ["PascalCase"], suffix: ["Type"] },
],
"@typescript-eslint/no-floating-promises": "warn",
"@typescript-eslint/no-redundant-type-constituents": "warn",
"import/consistent-type-specifier-style": "warn",
"import/order": [
"warn",
{
groups: ["builtin", "external", "internal", "unknown", "parent", "sibling", "index", "object", "type"],
pathGroups: [
{ pattern: "**/*.scss", group: "type", position: "after" },
{ pattern: "**/*.vue", group: "type", position: "after" },
],
alphabetize: { order: "asc", orderImportKind: "asc" },
"newlines-between": "never",
},
],
"no-console": "warn",
"sort-export-all/sort-export-all": "warn",
"vue/block-order": ["warn", { order: ["template", "script[setup]", "style:not([scoped])", "style[scoped]"] }],
"vue/component-api-style": "warn",
"vue/component-name-in-template-casing": [
"warn",
"PascalCase",
{
registeredComponentsOnly: false,
ignores: [
"/^custom-/",
"keep-alive",
"component",
"transition",
"transition-group",
"teleport",
"suspense",
"router-view",
"router-link",
"i18n-t",
],
},
],
"vue/custom-event-name-casing": [
"warn",
"camelCase",
{
ignores: ["/^[a-z]+:[a-z]+(?:[A-Z][a-z]+)*$/u"],
},
],
"vue/define-emits-declaration": "warn",
"vue/define-macros-order": ["warn", { order: ["defineOptions", "defineEmits", "defineProps", "defineSlots"] }],
"vue/define-props-declaration": ["warn", "type-based"],
"vue/html-button-has-type": "warn",
"vue/no-multiple-objects-in-class": "warn",
"vue/no-required-prop-with-default": "warn",
"vue/no-static-inline-styles": "warn",
"vue/no-useless-v-bind": "warn",
"vue/padding-line-between-blocks": "warn",
"vue/padding-lines-in-component-definition": "warn",
"vue/prefer-define-options": "warn",
"vue/require-emit-validator": "warn",
"vue/padding-line-between-tags": ["error", [{ blankLine: "always", prev: "*", next: "*" }]],
"vue/no-restricted-html-elements": [
"warn",
{
element: "VcLineItemProperty",
message: "VcLineItemProperty is deprecated. Use VcProperty or VcProductProperties instead.",
},
{
element: "VcPriceDisplayCatalog",
message: "VcPriceDisplayCatalog is deprecated. Use VcPriceDisplay or VcProductPrice instead.",
},
{ element: "VcItemPriceCatalog", message: "VcItemPriceCatalog is deprecated. Use VcProductPrice instead." },
{
element: "VcExpansionPanel",
message: "VcExpansionPanel is deprecated. Use VcWidget with `collapsible` instead.",
},
{
element: "VcExpansionPanels",
message: "VcExpansionPanels is deprecated. Use VcWidget with `collapsible` instead.",
},
{
element: "VcDateSelector",
message:
"VcDateSelector is deprecated. Use VcDatePicker for typed date entry with calendar popover, or VcDateInput for input-only.",
},
],
"vuejs-accessibility/click-events-have-key-events": "warn",
"vuejs-accessibility/no-static-element-interactions": "warn",
"@typescript-eslint/no-empty-object-type": "warn",
"@typescript-eslint/no-require-imports": "warn",
"@typescript-eslint/no-unused-expressions": "warn",
"sonarjs/array-callback-without-return": "warn",
"sonarjs/deprecation": "warn",
"sonarjs/different-types-comparison": "warn",
"sonarjs/function-return-type": "warn",
"sonarjs/no-ignored-exceptions": "warn",
"sonarjs/no-nested-assignment": "warn",
"sonarjs/no-os-command-from-path": "warn",
"sonarjs/no-selector-parameter": "warn",
"sonarjs/prefer-regexp-exec": "warn",
"sonarjs/slow-regex": "warn",
"sonarjs/todo-tag": "warn",
"sonarjs/void-use": "warn",
// Newly promoted to `error` by the recommended config in eslint-plugin-sonarjs v4; demoted to
// `warn` to keep the major bump behavior-neutral. Fixing the findings is tracked separately.
"sonarjs/null-dereference": "warn",
"sonarjs/no-redundant-optional": "warn",
"sonarjs/prefer-specific-assertions": "warn",
"sonarjs/prefer-native-lodash-alternative": "warn",
"sonarjs/parameterized-tests": "warn",
"sonarjs/super-linear-regex": "warn",
"sonarjs/vitest-mock-at-module-scope": "warn",
// Disabled rules
"@typescript-eslint/no-non-null-assertion": "off",
// False-positives repo-wide on generic methods (e.g. Array.prototype.includes), reporting the
// unsubstituted type parameter "T"; vue-tsc already type-checks these. Known eslint-plugin-sonarjs regression.
"sonarjs/argument-type": "off",
"sonarjs/no-duplicate-string": "off",
"tailwindcss/no-custom-classname": "off",
"vue/multi-word-component-names": "off",
"vue/require-default-prop": "off",
"vuejs-accessibility/form-control-has-label": "off",
"vuejs-accessibility/label-has-for": "off",
},
},
// Security rules (VCST-5292): flag unsafe DOM sinks (XSS).
// Set to `warn` to establish a baseline without breaking existing code;
// promote to `error` once the flagged sinks are remediated.
{
files: ["**/*.{js,ts,vue}"],
plugins: { "no-unsanitized": nounsanitized },
rules: {
"no-unsanitized/method": "warn", // e.g. document.write, insertAdjacentHTML
"no-unsanitized/property": "warn", // e.g. innerHTML, outerHTML
"vue/no-v-html": "warn", // raw v-html; prefer v-html-safe / {{ }}
},
},
// Type-aware configuration for application files
{
files: ["client-app/**/*.ts", "client-app/**/*.vue"],
ignores: ["client-app/**/*.test.ts", "client-app/**/*.spec.ts", "**/*.stories.ts"],
languageOptions: {
parser: vueParser,
parserOptions: {
parser: tseslint.parser,
tsconfigRootDir,
extraFileExtensions: [".vue"],
},
},
settings: {
"import/resolver": {
typescript: {
project: tsconfigs.app,
},
},
},
rules: {
"no-restricted-imports": [
"error",
{
paths: [
{
name: "@apollo/client",
message:
"@apollo/client is for React only. Please import from @apollo/client/* or @vue/apollo-composable",
},
{
name: "@vueuse/core",
importNames: ["useFetch"],
message: "Please import useFetch from @/core/api/common instead",
},
{
name: "@vueuse/integrations/useAxios",
importNames: ["useAxios"],
message: "Please import useAxios from @/core/api/common instead",
},
{
name: "axios",
importNames: ["default"],
message: "Please use useAxios from @/core/api/common instead",
},
],
},
],
"no-restricted-exports": [
"warn",
{
restrictDefaultExports: {
direct: true,
named: true,
defaultFrom: true,
namedFrom: true,
namespaceFrom: true,
},
},
],
},
},
// Type-aware configuration for test files
{
files: ["client-app/**/*.test.ts", "client-app/**/*.spec.ts"],
languageOptions: {
parserOptions: {
tsconfigRootDir,
},
},
settings: {
"import/resolver": {
typescript: {
project: tsconfigs.vitest,
},
},
},
rules: {
"sonarjs/assertions-in-tests": "off",
},
},
// Configuration for Storybook files
{
files: [".storybook/preview.ts", ".storybook/docs-page.ts", "**/*.stories.ts"],
languageOptions: {
parserOptions: {
tsconfigRootDir,
},
},
settings: {
"import/resolver": {
typescript: {
project: tsconfigs.storybook,
},
},
},
rules: {
"storybook/no-renderer-packages": "off",
},
},
// Type-aware configuration for Node.js scripts and config files
{
files: [
"*.config.js",
"*.config.ts",
"vite.federation*.ts",
"vite.site-builder*.ts",
"scripts/**/*.ts",
".storybook/main.ts",
],
languageOptions: {
parserOptions: {
tsconfigRootDir,
},
},
settings: {
"import/resolver": {
typescript: {
project: tsconfigs.node,
},
},
},
rules: {
"no-console": "off",
},
},
// @vc-frontend/core node CLI tooling (build-types, bump-version, create-plugin, ...):
// - console output is their UX, same as scripts/** above.
// - import/order is disabled: these scripts use CommonJS interop (createRequire + dynamic
// `require(resolve(...))` that can't be static imports), and import/order misreads those
// in-body require() calls as a second import group, emitting an unfixable false
// "empty line between import groups" on the ESM block above them.
{
files: ["client-app/core-api/*.mjs"],
rules: {
"no-console": "off",
"import/order": "off",
},
},
// Type-aware configuration for examples files
{
files: ["examples/**/*.ts", "examples/**/*.vue"],
languageOptions: {
parserOptions: {
tsconfigRootDir,
},
},
settings: {
"import/resolver": {
typescript: {
project: tsconfigs.examples,
},
},
},
},
// Specific overrides
{
files: ["**/*.vue"],
rules: {
"no-undef": "off",
},
},
{
files: ["**/components/**/index.ts"],
rules: {
"padding-line-between-statements": ["warn", { blankLine: "never", prev: "export", next: "export" }],
"sort-exports/sort-exports": "warn",
},
},
{
files: ["client-app/ui-kit/*"],
rules: {
"no-console": ["off", { allow: ["warn", "error"] }],
},
},
{
// typescript-eslint's typed-rule config matches `cts` as well, but its project service does not
// associate the extension, so a single `.cts` file aborts the WHOLE run with "you have used a
// rule which requires type information" — no findings printed, exit 2. Waiving type-aware rules
// for the extension is what keeps the gate alive; the only `.cts` here is a declaration file.
files: ["**/*.js", "**/*.cjs", "**/*.cts"],
...tseslint.configs.disableTypeChecked,
},
// Prettier must be last to disable conflicting formatting rules
prettierPlugin,
// `curly` does not conflict with Prettier, but eslint-config-prettier disables it anyway.
// Re-enable it here as recommended: https://github.com/prettier/eslint-config-prettier#curly
{
rules: {
curly: "error",
},
},
);