@vizejs/nuxt 0.502.0 → 0.503.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -411,6 +411,7 @@ interface NuxtLintConfigAddon {
|
|
|
411
411
|
}
|
|
412
412
|
/** Nuxt options that decide whether an unimport registry is actually injected. */
|
|
413
413
|
interface NuxtLintAutoImportOptions {
|
|
414
|
+
rootDir?: string;
|
|
414
415
|
imports?: false | {
|
|
415
416
|
autoImport?: boolean;
|
|
416
417
|
};
|
|
@@ -418,7 +419,17 @@ interface NuxtLintAutoImportOptions {
|
|
|
418
419
|
imports?: false | {
|
|
419
420
|
autoImport?: boolean;
|
|
420
421
|
};
|
|
422
|
+
srcDir?: string;
|
|
421
423
|
};
|
|
424
|
+
_layers?: Array<{
|
|
425
|
+
config?: {
|
|
426
|
+
rootDir?: string;
|
|
427
|
+
};
|
|
428
|
+
}>;
|
|
429
|
+
}
|
|
430
|
+
interface NuxtLintConfigAddonsOptions {
|
|
431
|
+
/** Directory generated lint globs are relative to. */
|
|
432
|
+
rootDir?: string;
|
|
422
433
|
}
|
|
423
434
|
/** The Nuxt hook surface used by lint config addons. */
|
|
424
435
|
interface NuxtLintConfigAddonNuxt {
|
|
@@ -437,6 +448,6 @@ type ResolveNuxtLintConfigAddons = () => Promise<readonly NuxtLintConfigItem[]>;
|
|
|
437
448
|
* The Vize-namespaced hook carries engine-neutral config items instead of raw
|
|
438
449
|
* ESLint source, so contributors remain compatible with the oxlint emitter.
|
|
439
450
|
*/
|
|
440
|
-
declare function setupNuxtLintConfigAddons(nuxt: NuxtLintConfigAddonNuxt): ResolveNuxtLintConfigAddons;
|
|
451
|
+
declare function setupNuxtLintConfigAddons(nuxt: NuxtLintConfigAddonNuxt, options?: NuxtLintConfigAddonsOptions): ResolveNuxtLintConfigAddons;
|
|
441
452
|
//#endregion
|
|
442
453
|
export { VizeNuxtUiOptions as C, VizeNuxtComposablesOptions as S, VizeNuxtLintCheckerOptions as _, ResolveNuxtLintConfigAddons as a, VizeNuxtCompilerOptions as b, NuxtMuseaOptions as c, VizeNuxtDevOptions as d, VizeNuxtMajorVersion as f, ResolvedVizeNuxtLintCheckerOptions as g, VizeNuxtLintOptions as h, NuxtLintImport as i, VizeNuxtBridgeOptions as l, VizeNuxtUnoCssOptions as m, NuxtLintConfigAddon as n, VIZE_NUXT_LINT_CONFIG_ADDONS_HOOK as o, VizeNuxtOptions as p, NuxtLintConfigAddonNuxt as r, setupNuxtLintConfigAddons as s, NuxtLintAwaitable as t, VizeNuxtCompatibilityOptions as u, resolveNuxtLintCheckerOptions as v, VizeNuxtVueVersion as x, VizeNuxtCompilerCompatibilityOptions as y };
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
import * as nodeModule from "node:module";
|
|
2
|
+
import { createRequire, globalPaths } from "node:module";
|
|
3
|
+
import * as fs$1 from "node:fs";
|
|
4
|
+
import { existsSync, lstatSync, realpathSync } from "node:fs";
|
|
5
|
+
import * as path$1 from "node:path";
|
|
6
|
+
import path, { dirname, extname, isAbsolute, join, relative, sep } from "node:path";
|
|
4
7
|
import { spawn } from "node:child_process";
|
|
5
|
-
import { glob, lstat, mkdir, open, readFile, rename, unlink, writeFile } from "node:fs/promises";
|
|
8
|
+
import { glob, lstat, mkdir, mkdtemp, open, readFile, realpath, rename, rm, unlink, writeFile } from "node:fs/promises";
|
|
6
9
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
7
10
|
import { Worker, isMainThread, parentPort } from "node:worker_threads";
|
|
8
11
|
import { randomBytes, randomUUID } from "node:crypto";
|
|
9
12
|
import { buildNuxtLintPlan, collectNuxtLintDirs, resolveNuxtLintFeatures } from "@vizejs/nuxt-lint-config";
|
|
13
|
+
import { tmpdir } from "node:os";
|
|
10
14
|
import { createServer } from "node:http";
|
|
11
15
|
//#region src/builder.ts
|
|
12
16
|
function getDetectedNuxtMajor(nuxt) {
|
|
@@ -187,7 +191,8 @@ function diagnosticKind(diagnostic) {
|
|
|
187
191
|
if (diagnostic.severity === 2 || diagnostic.severity === "error") return "error";
|
|
188
192
|
if (diagnostic.severity === 1 || diagnostic.severity === "warn" || diagnostic.severity === "warning") return "warning";
|
|
189
193
|
}
|
|
190
|
-
function
|
|
194
|
+
function formatNuxtLintCheckerDiagnostics(diagnostics, formatter) {
|
|
195
|
+
if (formatter === "json") return diagnostics.length > 0 ? `${JSON.stringify({ diagnostics })}\n` : "";
|
|
191
196
|
const unix = formatter === "unix";
|
|
192
197
|
const lines = diagnostics.map((diagnostic) => {
|
|
193
198
|
const span = diagnostic.labels?.find((label) => label.span)?.span;
|
|
@@ -211,8 +216,9 @@ function resultFromPayload(payload, task) {
|
|
|
211
216
|
const output = task.formatter === "json" ? diagnostics.length > 0 ? `${JSON.stringify({
|
|
212
217
|
...payload,
|
|
213
218
|
diagnostics
|
|
214
|
-
})}\n` : "" :
|
|
219
|
+
})}\n` : "" : formatNuxtLintCheckerDiagnostics(diagnostics, task.formatter);
|
|
215
220
|
return {
|
|
221
|
+
diagnostics,
|
|
216
222
|
diagnosticCount: diagnostics.length,
|
|
217
223
|
hasErrors,
|
|
218
224
|
hasWarnings,
|
|
@@ -222,6 +228,7 @@ function resultFromPayload(payload, task) {
|
|
|
222
228
|
/** Run one checker pass. This function executes inside the long-lived worker. */
|
|
223
229
|
async function runNuxtLintCheckerTask(task) {
|
|
224
230
|
if (!task.emitError && !task.emitWarning && !task.fix) return {
|
|
231
|
+
diagnostics: [],
|
|
225
232
|
diagnosticCount: 0,
|
|
226
233
|
hasErrors: false,
|
|
227
234
|
hasWarnings: false,
|
|
@@ -323,6 +330,7 @@ var NuxtLintChangeCollector = class {
|
|
|
323
330
|
draining = false;
|
|
324
331
|
closed = false;
|
|
325
332
|
overlayVisible = false;
|
|
333
|
+
diagnosticsByFile = /* @__PURE__ */ new Map();
|
|
326
334
|
config;
|
|
327
335
|
runner;
|
|
328
336
|
server;
|
|
@@ -366,12 +374,13 @@ var NuxtLintChangeCollector = class {
|
|
|
366
374
|
}
|
|
367
375
|
async drain() {
|
|
368
376
|
while (!this.closed && (this.pendingFull || this.pendingFiles.size > 0)) {
|
|
369
|
-
const
|
|
377
|
+
const full = this.pendingFull;
|
|
378
|
+
const targets = full ? [...this.config.options.include] : [...this.pendingFiles].sort();
|
|
370
379
|
this.pendingFull = false;
|
|
371
380
|
this.pendingFiles.clear();
|
|
372
381
|
try {
|
|
373
382
|
const result = await this.runner.run(this.task(targets));
|
|
374
|
-
if (!this.closed) this.report(result);
|
|
383
|
+
if (!this.closed) this.report(result, targets, full);
|
|
375
384
|
} catch (error) {
|
|
376
385
|
if (!this.closed) this.reportFailure(error);
|
|
377
386
|
}
|
|
@@ -393,13 +402,28 @@ var NuxtLintChangeCollector = class {
|
|
|
393
402
|
targets
|
|
394
403
|
};
|
|
395
404
|
}
|
|
396
|
-
|
|
405
|
+
diagnosticFile(diagnostic) {
|
|
406
|
+
const file = diagnostic.filename ?? diagnostic.filePath;
|
|
407
|
+
if (!file) return void 0;
|
|
408
|
+
return path.resolve(this.config.rootDir, file);
|
|
409
|
+
}
|
|
410
|
+
report(result, targets, full) {
|
|
397
411
|
if (result.output) {
|
|
398
412
|
if (result.hasErrors) this.server.config.logger.error(result.output);
|
|
399
413
|
else if (result.hasWarnings) this.server.config.logger.warn(result.output);
|
|
400
414
|
}
|
|
401
|
-
if (
|
|
402
|
-
|
|
415
|
+
if (full) this.diagnosticsByFile.clear();
|
|
416
|
+
else for (const target of targets) this.diagnosticsByFile.delete(path.resolve(target));
|
|
417
|
+
for (const diagnostic of result.diagnostics) {
|
|
418
|
+
const file = this.diagnosticFile(diagnostic);
|
|
419
|
+
if (!file) continue;
|
|
420
|
+
const diagnostics = this.diagnosticsByFile.get(file) ?? [];
|
|
421
|
+
diagnostics.push(diagnostic);
|
|
422
|
+
this.diagnosticsByFile.set(file, diagnostics);
|
|
423
|
+
}
|
|
424
|
+
const currentDiagnostics = [...this.diagnosticsByFile.entries()].sort(([left], [right]) => left.localeCompare(right)).flatMap(([, diagnostics]) => diagnostics);
|
|
425
|
+
if (currentDiagnostics.length > 0) {
|
|
426
|
+
this.server.ws.send(overlayError(formatNuxtLintCheckerDiagnostics(currentDiagnostics, this.config.options.formatter)));
|
|
403
427
|
this.overlayVisible = true;
|
|
404
428
|
} else if (this.overlayVisible) {
|
|
405
429
|
this.server.ws.send({
|
|
@@ -561,7 +585,18 @@ function nitroImportContext(value) {
|
|
|
561
585
|
* their latest values in the addon means every config regeneration observes
|
|
562
586
|
* the current registry rather than a module-setup-time snapshot.
|
|
563
587
|
*/
|
|
564
|
-
function
|
|
588
|
+
function toPosix(value) {
|
|
589
|
+
return value.split(path.sep).join("/");
|
|
590
|
+
}
|
|
591
|
+
function nitroImportFiles(nuxt, options) {
|
|
592
|
+
const nuxtRoot = path.resolve(nuxt.options?.rootDir ?? options.rootDir ?? ".");
|
|
593
|
+
const lintRoot = path.resolve(options.rootDir ?? nuxtRoot);
|
|
594
|
+
const directories = /* @__PURE__ */ new Set();
|
|
595
|
+
directories.add(path.resolve(nuxtRoot, nuxt.options?.nitro?.srcDir ?? "server"));
|
|
596
|
+
for (const layer of nuxt.options?._layers ?? []) if (layer.config?.rootDir) directories.add(path.resolve(layer.config.rootDir, "server"));
|
|
597
|
+
return [...directories].map((directory) => `${toPosix(path.relative(lintRoot, directory)) || "."}/**/*.{js,ts,jsx,tsx}`).sort();
|
|
598
|
+
}
|
|
599
|
+
function createNuxtImportGlobalsAddon(nuxt, options) {
|
|
565
600
|
let unimport;
|
|
566
601
|
let nitroUnimport;
|
|
567
602
|
nuxt.hook("imports:context", (context) => {
|
|
@@ -573,11 +608,19 @@ function createNuxtImportGlobalsAddon(nuxt) {
|
|
|
573
608
|
return {
|
|
574
609
|
name: "vize:lint:import-globals",
|
|
575
610
|
async getConfigs() {
|
|
576
|
-
const
|
|
611
|
+
const appAutoImports = autoImportEnabled(nuxt.options?.imports);
|
|
612
|
+
const imports = (appAutoImports ? await unimport?.getImports() ?? [] : []).sort((left, right) => left.from.localeCompare(right.from) || left.name.localeCompare(right.name));
|
|
613
|
+
const globals = Object.fromEntries(imports.map((imported) => [imported.as ?? imported.name, "readonly"]));
|
|
614
|
+
const nitroImports = (appAutoImports && autoImportEnabled(nuxt.options?.nitro?.imports) ? await nitroUnimport?.getImports() ?? [] : []).sort((left, right) => left.from.localeCompare(right.from) || left.name.localeCompare(right.name));
|
|
615
|
+
const nitroGlobals = Object.fromEntries(nitroImports.map((imported) => [imported.as ?? imported.name, "readonly"]));
|
|
577
616
|
return [{
|
|
578
617
|
name: "nuxt/import-globals",
|
|
579
|
-
globals
|
|
580
|
-
}
|
|
618
|
+
globals
|
|
619
|
+
}, ...Object.keys(nitroGlobals).length > 0 ? [{
|
|
620
|
+
name: "nitro/import-globals",
|
|
621
|
+
files: nitroImportFiles(nuxt, options),
|
|
622
|
+
globals: nitroGlobals
|
|
623
|
+
}] : []];
|
|
581
624
|
}
|
|
582
625
|
};
|
|
583
626
|
}
|
|
@@ -590,8 +633,8 @@ function createNuxtImportGlobalsAddon(nuxt) {
|
|
|
590
633
|
* The Vize-namespaced hook carries engine-neutral config items instead of raw
|
|
591
634
|
* ESLint source, so contributors remain compatible with the oxlint emitter.
|
|
592
635
|
*/
|
|
593
|
-
function setupNuxtLintConfigAddons(nuxt) {
|
|
594
|
-
const defaults = [createNuxtImportGlobalsAddon(nuxt)];
|
|
636
|
+
function setupNuxtLintConfigAddons(nuxt, options = {}) {
|
|
637
|
+
const defaults = [createNuxtImportGlobalsAddon(nuxt, options)];
|
|
595
638
|
return async () => {
|
|
596
639
|
const addons = [...defaults];
|
|
597
640
|
await nuxt.callHook(VIZE_NUXT_LINT_CONFIG_ADDONS_HOOK, addons);
|
|
@@ -664,13 +707,17 @@ function renderNuxtOxlintConfig(items, pluginSpecifier, globBase) {
|
|
|
664
707
|
const override = { files: item.files.map((glob) => rebase(glob)) };
|
|
665
708
|
if (item.ignores) override.excludeFiles = item.ignores.map((glob) => rebase(glob));
|
|
666
709
|
if (item.globals) override.globals = { ...item.globals };
|
|
667
|
-
if (item.rules) override.rules =
|
|
710
|
+
if (item.rules || item.nativeRules) override.rules = {
|
|
711
|
+
...prefixVizeRules(item.rules),
|
|
712
|
+
...item.nativeRules
|
|
713
|
+
};
|
|
668
714
|
overrides.push(override);
|
|
669
715
|
continue;
|
|
670
716
|
}
|
|
671
717
|
if (item.ignores) ignorePatterns.push(...item.ignores.map((glob) => rebase(glob, true)));
|
|
672
718
|
mergeGlobals(globals, item.globals);
|
|
673
719
|
mergeRules(rules, item.rules);
|
|
720
|
+
Object.assign(rules, item.nativeRules);
|
|
674
721
|
}
|
|
675
722
|
const config = {
|
|
676
723
|
plugins: ["vue"],
|
|
@@ -723,6 +770,374 @@ function toNuxtLintProjectState(options, overrides = {}) {
|
|
|
723
770
|
};
|
|
724
771
|
}
|
|
725
772
|
//#endregion
|
|
773
|
+
//#region ../../../crates/vize_carton/src/config/loader/module-runtime.mjs
|
|
774
|
+
const configFailureArtifacts = /* @__PURE__ */ new WeakMap();
|
|
775
|
+
const configEvaluationTimings = /* @__PURE__ */ new WeakMap();
|
|
776
|
+
function beginConfigTiming(rows, phase, boundary) {
|
|
777
|
+
const start = rows ? performance.now() : void 0;
|
|
778
|
+
let finished = false;
|
|
779
|
+
if (boundary) boundary.active = true;
|
|
780
|
+
return () => {
|
|
781
|
+
if (start !== void 0 && !finished) {
|
|
782
|
+
const end = performance.now();
|
|
783
|
+
rows.push({
|
|
784
|
+
phase,
|
|
785
|
+
elapsedMs: end - start,
|
|
786
|
+
processId: process.pid
|
|
787
|
+
});
|
|
788
|
+
if (boundary) {
|
|
789
|
+
boundary.active = false;
|
|
790
|
+
if (boundary.resolvedAt !== void 0) {
|
|
791
|
+
rows.push({
|
|
792
|
+
phase: "public_load_until_owned_resolve",
|
|
793
|
+
elapsedMs: boundary.resolvedAt - start,
|
|
794
|
+
processId: process.pid
|
|
795
|
+
});
|
|
796
|
+
rows.push({
|
|
797
|
+
phase: "public_load_after_owned_resolve",
|
|
798
|
+
elapsedMs: end - boundary.resolvedAt,
|
|
799
|
+
processId: process.pid
|
|
800
|
+
});
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
finished = true;
|
|
804
|
+
}
|
|
805
|
+
};
|
|
806
|
+
}
|
|
807
|
+
async function beginPublicLoadProfile() {
|
|
808
|
+
const started = performance.now();
|
|
809
|
+
let session;
|
|
810
|
+
const close = () => {
|
|
811
|
+
try {
|
|
812
|
+
session?.disconnect();
|
|
813
|
+
} catch {}
|
|
814
|
+
};
|
|
815
|
+
try {
|
|
816
|
+
const { Session } = await import("node:inspector/promises");
|
|
817
|
+
session = new Session();
|
|
818
|
+
session.connect();
|
|
819
|
+
await session.post("Profiler.enable");
|
|
820
|
+
await session.post("Profiler.start");
|
|
821
|
+
const setupMs = performance.now() - started;
|
|
822
|
+
return async () => {
|
|
823
|
+
const stopping = performance.now();
|
|
824
|
+
try {
|
|
825
|
+
const { profile } = await session.post("Profiler.stop");
|
|
826
|
+
return {
|
|
827
|
+
status: "recorded",
|
|
828
|
+
setupMs,
|
|
829
|
+
stopMs: performance.now() - stopping,
|
|
830
|
+
profile
|
|
831
|
+
};
|
|
832
|
+
} catch (error) {
|
|
833
|
+
return {
|
|
834
|
+
status: "unavailable",
|
|
835
|
+
setupMs,
|
|
836
|
+
reason: String(error)
|
|
837
|
+
};
|
|
838
|
+
} finally {
|
|
839
|
+
close();
|
|
840
|
+
}
|
|
841
|
+
};
|
|
842
|
+
} catch (error) {
|
|
843
|
+
close();
|
|
844
|
+
return async () => ({
|
|
845
|
+
status: "unavailable",
|
|
846
|
+
reason: String(error)
|
|
847
|
+
});
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
function configModuleImportPath(configURL, windows = process.platform === "win32") {
|
|
851
|
+
return fileURLToPath(configURL, { windows });
|
|
852
|
+
}
|
|
853
|
+
async function importConfigModule(configPath, withoutVite) {
|
|
854
|
+
return (await importConfigModuleWithDependencies(configPath, nodeModule.registerHooks, withoutVite)).namespace;
|
|
855
|
+
}
|
|
856
|
+
function failedConfigModuleObservation(error) {
|
|
857
|
+
const paths = /* @__PURE__ */ new Set();
|
|
858
|
+
let complete = false;
|
|
859
|
+
if (error?.code === "ERR_MODULE_NOT_FOUND" && typeof error.url === "string") try {
|
|
860
|
+
const url = new URL(error.url);
|
|
861
|
+
if (url.protocol === "file:") {
|
|
862
|
+
paths.add(fileURLToPath(url));
|
|
863
|
+
complete = true;
|
|
864
|
+
}
|
|
865
|
+
} catch {}
|
|
866
|
+
const diagnostics = Array.isArray(error?.errors) ? error.errors : [];
|
|
867
|
+
if (diagnostics.length) complete = true;
|
|
868
|
+
for (const diagnostic of diagnostics) {
|
|
869
|
+
let requested = false;
|
|
870
|
+
if (diagnostic?.code !== "UNRESOLVED_IMPORT" || typeof diagnostic.id !== "string" || !isAbsolute(diagnostic.id) || typeof diagnostic.exporter !== "string") {
|
|
871
|
+
complete = false;
|
|
872
|
+
continue;
|
|
873
|
+
}
|
|
874
|
+
paths.add(diagnostic.id);
|
|
875
|
+
const request = diagnostic.exporter;
|
|
876
|
+
if (!(isAbsolute(request) || request.startsWith("./") || request.startsWith("../"))) {
|
|
877
|
+
complete = false;
|
|
878
|
+
continue;
|
|
879
|
+
}
|
|
880
|
+
if (/[%#?]/.test(request)) {
|
|
881
|
+
complete = false;
|
|
882
|
+
continue;
|
|
883
|
+
}
|
|
884
|
+
try {
|
|
885
|
+
const url = isAbsolute(request) ? pathToFileURL(request) : new URL(request, pathToFileURL(diagnostic.id));
|
|
886
|
+
if (url.protocol === "file:" && extname(url.pathname)) {
|
|
887
|
+
paths.add(fileURLToPath(url));
|
|
888
|
+
requested = true;
|
|
889
|
+
}
|
|
890
|
+
} catch {}
|
|
891
|
+
complete &&= requested;
|
|
892
|
+
}
|
|
893
|
+
return {
|
|
894
|
+
paths: [...paths],
|
|
895
|
+
complete
|
|
896
|
+
};
|
|
897
|
+
}
|
|
898
|
+
/** Keep runtime imports observable until the optional export evaluator settles. */
|
|
899
|
+
async function captureConfigEvaluation(load, configPath, registerModuleHooks, evaluate, privateDirectory, observeDependencies, ownedAdapter, timings, boundary) {
|
|
900
|
+
const files = new Set([configPath]);
|
|
901
|
+
const requestedFiles = /* @__PURE__ */ new Set();
|
|
902
|
+
let complete = true;
|
|
903
|
+
let moduleGraphLoaded = false;
|
|
904
|
+
const owners = new Set([pathToFileURL(configPath).href]);
|
|
905
|
+
const isPrivate = (path) => {
|
|
906
|
+
if (!privateDirectory) return false;
|
|
907
|
+
const inside = relative(privateDirectory, path);
|
|
908
|
+
return inside !== ".." && !inside.startsWith(`..${sep}`) && !isAbsolute(inside);
|
|
909
|
+
};
|
|
910
|
+
const hooks = typeof registerModuleHooks === "function" ? registerModuleHooks({ resolve(specifier, context, nextResolve) {
|
|
911
|
+
const result = nextResolve(specifier, context);
|
|
912
|
+
if (result.url.startsWith("file:")) {
|
|
913
|
+
const path = fileURLToPath(result.url);
|
|
914
|
+
if (boundary?.active && boundary.resolvedAt === void 0 && isPrivate(path)) boundary.resolvedAt = performance.now();
|
|
915
|
+
if (owners.has(result.url) || owners.has(context.parentURL) || isPrivate(path)) {
|
|
916
|
+
owners.add(result.url);
|
|
917
|
+
if (!isPrivate(path)) files.add(path);
|
|
918
|
+
if (owners.has(context.parentURL) && (specifier.startsWith("./") || specifier.startsWith("../") || specifier.startsWith("/") || specifier.startsWith("file:"))) try {
|
|
919
|
+
const requested = new URL(specifier, context.parentURL);
|
|
920
|
+
if (requested.protocol === "file:") {
|
|
921
|
+
const requestedPath = fileURLToPath(requested);
|
|
922
|
+
if (extname(requestedPath) && !isPrivate(requestedPath)) requestedFiles.add(requestedPath);
|
|
923
|
+
}
|
|
924
|
+
} catch {}
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
return result;
|
|
928
|
+
} }) : void 0;
|
|
929
|
+
try {
|
|
930
|
+
const { namespace, dependencies = [] } = await load();
|
|
931
|
+
for (const path of dependencies) if (!isPrivate(path)) files.add(path);
|
|
932
|
+
moduleGraphLoaded = true;
|
|
933
|
+
const finish = beginConfigTiming(timings, "export_evaluation");
|
|
934
|
+
let value;
|
|
935
|
+
try {
|
|
936
|
+
value = evaluate ? await evaluate(namespace) : namespace;
|
|
937
|
+
} finally {
|
|
938
|
+
finish();
|
|
939
|
+
}
|
|
940
|
+
return {
|
|
941
|
+
namespace,
|
|
942
|
+
value,
|
|
943
|
+
dependencies: [...files]
|
|
944
|
+
};
|
|
945
|
+
} catch (error) {
|
|
946
|
+
if (ownedAdapter && error !== null && (typeof error === "object" || typeof error === "function")) configFailureArtifacts.set(error, [
|
|
947
|
+
[ownedAdapter, configPath],
|
|
948
|
+
[pathToFileURL(ownedAdapter).href, pathToFileURL(configPath).href],
|
|
949
|
+
[relative(dirname(configPath), ownedAdapter), relative(dirname(configPath), configPath)]
|
|
950
|
+
]);
|
|
951
|
+
complete = false;
|
|
952
|
+
try {
|
|
953
|
+
const observed = failedConfigModuleObservation(error);
|
|
954
|
+
complete = observed.complete && (privateDirectory === void 0 || moduleGraphLoaded);
|
|
955
|
+
for (const path of observed.paths) if (!isPrivate(path)) files.add(path);
|
|
956
|
+
} catch {}
|
|
957
|
+
throw error;
|
|
958
|
+
} finally {
|
|
959
|
+
hooks?.deregister();
|
|
960
|
+
observeDependencies?.([...files, ...requestedFiles], complete);
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
/** Await evaluate(namespace) once before sealing its graph; retain the namespace unchanged. */
|
|
964
|
+
async function importConfigModuleWithDependencies(configPath, registerModuleHooks = nodeModule.registerHooks, withoutVite, evaluate, observeDependencies, beforeRead) {
|
|
965
|
+
const timings = process.env.VIZE_TRACE_EDITOR_PREPARATION === "1" ? [] : void 0;
|
|
966
|
+
const boundary = timings ? {
|
|
967
|
+
active: false,
|
|
968
|
+
resolvedAt: void 0
|
|
969
|
+
} : void 0;
|
|
970
|
+
const finishTotal = beginConfigTiming(timings, "module_total");
|
|
971
|
+
const finishSelection = beginConfigTiming(timings, "engine_selection_with_ack");
|
|
972
|
+
let selectionFinished = false;
|
|
973
|
+
let result;
|
|
974
|
+
const watchInputs = new Set([configPath]);
|
|
975
|
+
let complete = false;
|
|
976
|
+
const observe = (paths, observedComplete) => {
|
|
977
|
+
for (const path of paths) watchInputs.add(path);
|
|
978
|
+
complete = observedComplete;
|
|
979
|
+
};
|
|
980
|
+
try {
|
|
981
|
+
const configURL = pathToFileURL(configPath);
|
|
982
|
+
const require = createRequire(configURL);
|
|
983
|
+
const searchPaths = require.resolve.paths("vite") ?? [];
|
|
984
|
+
let candidate;
|
|
985
|
+
for (const directory of searchPaths.filter((path) => !globalPaths.includes(path))) {
|
|
986
|
+
const requested = join(directory, "vite");
|
|
987
|
+
watchInputs.add(requested);
|
|
988
|
+
await beforeRead?.([requested]);
|
|
989
|
+
if (lstatSync(requested, { throwIfNoEntry: false }) !== void 0) {
|
|
990
|
+
candidate = requested;
|
|
991
|
+
watchInputs.add(join(candidate, "package.json"));
|
|
992
|
+
break;
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
if (typeof registerModuleHooks !== "function") {
|
|
996
|
+
if (evaluate) throw new Error("Tracking imports while evaluating a Vite config requires Node.js 22.15 or newer. Upgrade Node.js; installed Vite alone cannot track runtime imports.");
|
|
997
|
+
if (candidate === void 0 && !withoutVite) throw new Error("Loading a Vite config without project Vite requires Node.js 22.15 or newer to track imported configuration files. Upgrade Node.js or install Vite in the project.");
|
|
998
|
+
}
|
|
999
|
+
if (candidate === void 0) {
|
|
1000
|
+
finishSelection();
|
|
1001
|
+
selectionFinished = true;
|
|
1002
|
+
await beforeRead?.([configPath]);
|
|
1003
|
+
result = await captureConfigEvaluation(async () => ({ namespace: await (withoutVite ? withoutVite(configURL) : import(configURL.href)) }), configPath, registerModuleHooks, evaluate, void 0, observe, void 0, timings);
|
|
1004
|
+
return result;
|
|
1005
|
+
}
|
|
1006
|
+
const viteDirectory = realpathSync(candidate);
|
|
1007
|
+
watchInputs.add(join(viteDirectory, "package.json"));
|
|
1008
|
+
await beforeRead?.([join(candidate, "package.json"), join(viteDirectory, "package.json")]);
|
|
1009
|
+
const resolvedEntry = require.resolve("vite");
|
|
1010
|
+
watchInputs.add(resolvedEntry);
|
|
1011
|
+
const viteEntry = realpathSync(resolvedEntry);
|
|
1012
|
+
watchInputs.add(viteEntry);
|
|
1013
|
+
const entryPath = relative(viteDirectory, viteEntry);
|
|
1014
|
+
if (entryPath === ".." || entryPath.startsWith(`..${sep}`) || isAbsolute(entryPath)) throw new Error(`Resolved loader escapes selected project Vite: ${candidate} -> ${viteEntry}`);
|
|
1015
|
+
await beforeRead?.([resolvedEntry, viteEntry]);
|
|
1016
|
+
finishSelection();
|
|
1017
|
+
selectionFinished = true;
|
|
1018
|
+
const finishImport = beginConfigTiming(timings, "engine_import");
|
|
1019
|
+
let loadConfigFromFile;
|
|
1020
|
+
try {
|
|
1021
|
+
({loadConfigFromFile} = await import(pathToFileURL(viteEntry).href));
|
|
1022
|
+
} finally {
|
|
1023
|
+
finishImport();
|
|
1024
|
+
}
|
|
1025
|
+
const finishAdapter = beginConfigTiming(timings, "adapter_prepare");
|
|
1026
|
+
let temporary;
|
|
1027
|
+
try {
|
|
1028
|
+
temporary = await realpath(await mkdtemp(join(tmpdir(), "vize-config-module-")));
|
|
1029
|
+
} catch (error) {
|
|
1030
|
+
finishAdapter();
|
|
1031
|
+
throw error;
|
|
1032
|
+
}
|
|
1033
|
+
try {
|
|
1034
|
+
const adapter = join(temporary, "config.mjs");
|
|
1035
|
+
await writeFile(adapter, `import * as original from ${JSON.stringify(configModuleImportPath(configURL))};\nexport default { namespace: original };\n`, {
|
|
1036
|
+
flag: "wx",
|
|
1037
|
+
mode: 384
|
|
1038
|
+
});
|
|
1039
|
+
finishAdapter();
|
|
1040
|
+
result = await captureConfigEvaluation(async () => {
|
|
1041
|
+
const finishAck = beginConfigTiming(timings, "selected_before_read_ack");
|
|
1042
|
+
try {
|
|
1043
|
+
await beforeRead?.([configPath]);
|
|
1044
|
+
} finally {
|
|
1045
|
+
finishAck();
|
|
1046
|
+
}
|
|
1047
|
+
const finishProfile = timings ? await beginPublicLoadProfile() : void 0;
|
|
1048
|
+
const finishLoad = beginConfigTiming(timings, "public_load", boundary);
|
|
1049
|
+
let loaded;
|
|
1050
|
+
try {
|
|
1051
|
+
loaded = await loadConfigFromFile({
|
|
1052
|
+
mode: "development",
|
|
1053
|
+
command: "serve"
|
|
1054
|
+
}, adapter, dirname(configPath), "silent", void 0, "bundle");
|
|
1055
|
+
} finally {
|
|
1056
|
+
finishLoad();
|
|
1057
|
+
if (finishProfile) timings.find((row) => row.phase === "public_load").cpuProfile = await finishProfile();
|
|
1058
|
+
}
|
|
1059
|
+
if (!loaded) throw new Error(`Vite did not load the selected config: ${configPath}`);
|
|
1060
|
+
return {
|
|
1061
|
+
namespace: loaded.config.namespace,
|
|
1062
|
+
dependencies: loaded.dependencies
|
|
1063
|
+
};
|
|
1064
|
+
}, configPath, registerModuleHooks, evaluate, temporary, observe, adapter, timings, boundary);
|
|
1065
|
+
return result;
|
|
1066
|
+
} catch (error) {
|
|
1067
|
+
finishAdapter();
|
|
1068
|
+
throw error;
|
|
1069
|
+
} finally {
|
|
1070
|
+
const finishCleanup = beginConfigTiming(timings, "adapter_cleanup");
|
|
1071
|
+
try {
|
|
1072
|
+
await rm(temporary, {
|
|
1073
|
+
recursive: true,
|
|
1074
|
+
force: true
|
|
1075
|
+
});
|
|
1076
|
+
} finally {
|
|
1077
|
+
finishCleanup();
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
} catch (error) {
|
|
1081
|
+
if (timings && error !== null && (typeof error === "object" || typeof error === "function")) configEvaluationTimings.set(error, timings);
|
|
1082
|
+
throw error;
|
|
1083
|
+
} finally {
|
|
1084
|
+
if (!selectionFinished) finishSelection();
|
|
1085
|
+
finishTotal();
|
|
1086
|
+
if (timings && result) configEvaluationTimings.set(result, timings);
|
|
1087
|
+
observeDependencies?.([...watchInputs], complete);
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
JSON.parse("{\"type\":\"object\",\"properties\":{\"name\":{\"type\":\"string\"},\"compiler\":{\"$ref\":\"#/definitions/CompilerConfig\"},\"experimentals\":{\"type\":\"object\",\"additionalProperties\":{\"oneOf\":[{\"type\":\"boolean\"},{\"type\":\"object\",\"additionalProperties\":true},{\"type\":\"null\"}]}},\"dialect\":{\"type\":\"string\",\"enum\":[\"vue\",\"petite-vue\"]},\"vite\":{\"$ref\":\"#/definitions/VitePluginConfig\"},\"musea\":{\"$ref\":\"#/definitions/MuseaConfig\"},\"typeChecker\":{\"$ref\":\"#/definitions/TypeCheckerConfig\"},\"linter\":{\"$ref\":\"#/definitions/LinterConfig\"},\"formatter\":{\"$ref\":\"#/definitions/FormatterConfig\"},\"languageServer\":{\"$ref\":\"#/definitions/LanguageServerConfig\"},\"globalTypes\":{\"$ref\":\"#/definitions/GlobalTypesConfig\"},\"files\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}},\"ignores\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}},\"basePath\":{\"type\":\"string\"},\"lib\":{\"$ref\":\"#/definitions/LibConfig\"},\"version\":{\"$ref\":\"#/definitions/VueVersion\"},\"entries\":{\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"name\":{\"type\":\"string\"},\"basePath\":{\"type\":\"string\"},\"files\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}},\"ignores\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}},\"compiler\":{\"$ref\":\"#/definitions/CompilerConfig\"},\"linter\":{\"$ref\":\"#/definitions/LinterConfig\"}},\"additionalProperties\":false}}},\"additionalProperties\":false,\"definitions\":{\"CompilerConfig\":{\"type\":\"object\",\"properties\":{\"mode\":{\"type\":\"string\",\"enum\":[\"module\",\"function\"]},\"vapor\":{\"type\":\"boolean\"},\"jsxMode\":{\"type\":\"string\",\"enum\":[\"vdom\",\"vapor\"]},\"jsxCompat\":{\"type\":\"string\",\"enum\":[\"native\",\"babel\"]},\"customRenderer\":{\"type\":\"boolean\"},\"customElements\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}},\"ssr\":{\"type\":\"boolean\"},\"templateSyntax\":{\"type\":\"string\",\"enum\":[\"standard\",\"strict\",\"quirks\"]},\"whitespace\":{\"type\":\"string\",\"enum\":[\"condense\",\"preserve\",\"vue2-line-breaks\",\"vue2-preserve\"]},\"sourceMap\":{\"type\":\"boolean\"},\"prefixIdentifiers\":{\"type\":\"boolean\"},\"hoistStatic\":{\"type\":\"boolean\"},\"cacheHandlers\":{\"type\":\"boolean\"},\"isTs\":{\"type\":\"boolean\"},\"scriptExt\":{\"type\":\"string\",\"enum\":[\"ts\",\"js\"]},\"runtimeModuleName\":{\"type\":\"string\"},\"runtimeGlobalName\":{\"type\":\"string\"},\"compatibility\":{\"$ref\":\"#/definitions/CompilerCompatibilityConfig\"}},\"additionalProperties\":false},\"CompilerCompatibilityConfig\":{\"type\":\"object\",\"properties\":{\"vueVersion\":{\"$ref\":\"#/definitions/VueVersion\"},\"hostCompiler\":{\"type\":\"boolean\"},\"scriptSetupInStandalone\":{\"type\":\"boolean\"},\"optionsApiVapor\":{\"type\":\"boolean\"},\"nuxtVersion\":{\"type\":\"integer\",\"enum\":[2,3,4]},\"webpackVersion\":{\"type\":\"integer\",\"enum\":[4,5]}},\"additionalProperties\":false},\"VueVersion\":{\"type\":\"string\",\"enum\":[\"3\",\"2.7\",\"2\",\"1\",\"0.11\",\"0.10\"]},\"VitePluginConfig\":{\"type\":\"object\",\"properties\":{\"include\":{\"oneOf\":[{\"type\":\"string\"},{\"type\":\"array\",\"items\":{\"type\":\"string\"}}]},\"exclude\":{\"oneOf\":[{\"type\":\"string\"},{\"type\":\"array\",\"items\":{\"type\":\"string\"}}]},\"scanPatterns\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}},\"ignorePatterns\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}}},\"additionalProperties\":false},\"MuseaConfig\":{\"type\":\"object\",\"properties\":{\"include\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}},\"exclude\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}},\"basePath\":{\"type\":\"string\"},\"storybookCompat\":{\"type\":\"boolean\"},\"inlineArt\":{\"type\":\"boolean\"},\"vrt\":{\"$ref\":\"#/definitions/MuseaVrtConfig\"},\"a11y\":{\"$ref\":\"#/definitions/MuseaA11yConfig\"},\"autogen\":{\"$ref\":\"#/definitions/MuseaAutogenConfig\"}},\"additionalProperties\":false},\"MuseaVrtConfig\":{\"type\":\"object\",\"properties\":{\"threshold\":{\"type\":\"number\"},\"outDir\":{\"type\":\"string\"},\"viewports\":{\"type\":\"array\",\"items\":{\"$ref\":\"#/definitions/MuseaViewport\"}}},\"additionalProperties\":false},\"MuseaViewport\":{\"type\":\"object\",\"properties\":{\"width\":{\"type\":\"integer\"},\"height\":{\"type\":\"integer\"},\"name\":{\"type\":\"string\"}},\"additionalProperties\":false,\"required\":[\"width\",\"height\"]},\"MuseaA11yConfig\":{\"type\":\"object\",\"properties\":{\"enabled\":{\"type\":\"boolean\"},\"rules\":{\"type\":\"object\",\"additionalProperties\":{\"type\":\"boolean\"}}},\"additionalProperties\":false},\"MuseaAutogenConfig\":{\"type\":\"object\",\"properties\":{\"enabled\":{\"type\":\"boolean\"},\"maxVariants\":{\"type\":\"integer\"}},\"additionalProperties\":false},\"TypeCheckerConfig\":{\"type\":\"object\",\"properties\":{\"enabled\":{\"type\":\"boolean\"},\"strict\":{\"type\":\"boolean\"},\"checkProps\":{\"type\":\"boolean\"},\"checkEmits\":{\"type\":\"boolean\"},\"checkTemplateBindings\":{\"type\":\"boolean\"},\"checkReactivity\":{\"type\":\"boolean\"},\"checkSetupContext\":{\"type\":\"boolean\"},\"checkInvalidExports\":{\"type\":\"boolean\"},\"checkFallthroughAttrs\":{\"type\":\"boolean\"},\"optionsApi\":{\"type\":\"boolean\"},\"legacyVue2\":{\"type\":\"boolean\"},\"jsxTypecheck\":{\"type\":\"boolean\"},\"tsconfig\":{\"type\":\"string\"},\"corsaPath\":{\"type\":\"string\"},\"tsgoPath\":{\"type\":\"string\"},\"globalsFile\":{\"type\":\"string\"},\"servers\":{\"type\":\"integer\",\"minimum\":1,\"maximum\":32},\"lspRequestTimeoutMs\":{\"type\":\"integer\",\"minimum\":1}},\"additionalProperties\":false},\"LinterConfig\":{\"type\":\"object\",\"properties\":{\"enabled\":{\"type\":\"boolean\"},\"preset\":{\"type\":\"string\",\"enum\":[\"general-recommended\",\"general_recommended\",\"generalRecommended\",\"happy-path\",\"happy_path\",\"happy\",\"default\",\"recommended\",\"opinionated\",\"strict\",\"all\",\"essential\",\"incremental\",\"ecosystem\",\"nuxt\"]},\"typeAware\":{\"type\":\"boolean\"},\"crossFile\":{\"type\":\"boolean\"},\"crossFileTree\":{\"type\":\"boolean\"},\"crossFileComplexity\":{\"type\":\"boolean\"},\"strictReactivity\":{\"type\":\"boolean\"},\"maxWarnings\":{\"type\":\"integer\",\"minimum\":0},\"rules\":{\"type\":\"object\",\"additionalProperties\":{\"type\":\"string\",\"enum\":[\"off\",\"warn\",\"error\"]}},\"ruleOptions\":{\"$ref\":\"#/definitions/LintRuleOptions\"},\"categories\":{\"type\":\"object\",\"properties\":{\"correctness\":{\"type\":\"string\",\"enum\":[\"off\",\"warn\",\"error\"]},\"suspicious\":{\"type\":\"string\",\"enum\":[\"off\",\"warn\",\"error\"]},\"style\":{\"type\":\"string\",\"enum\":[\"off\",\"warn\",\"error\"]},\"perf\":{\"type\":\"string\",\"enum\":[\"off\",\"warn\",\"error\"]},\"a11y\":{\"type\":\"string\",\"enum\":[\"off\",\"warn\",\"error\"]},\"security\":{\"type\":\"string\",\"enum\":[\"off\",\"warn\",\"error\"]}},\"additionalProperties\":false}},\"additionalProperties\":false},\"LintRuleOptions\":{\"type\":\"object\",\"properties\":{\"script/define-macros-order\":{\"type\":\"object\",\"properties\":{\"order\":{\"type\":\"array\",\"items\":{\"type\":\"string\",\"minLength\":1},\"uniqueItems\":true}},\"additionalProperties\":false},\"script/define-props-destructuring\":{\"type\":\"object\",\"properties\":{\"destructure\":{\"type\":\"string\",\"enum\":[\"only-when-assigned\",\"always\",\"never\"]}},\"additionalProperties\":false},\"html/no-empty-palpable-content\":{\"type\":\"object\",\"properties\":{\"contentDirectives\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}}},\"additionalProperties\":false},\"type/strict-boolean-expressions\":{\"type\":\"object\",\"properties\":{\"allowString\":{\"type\":\"boolean\"},\"allowNumber\":{\"type\":\"boolean\"},\"allowNullableObject\":{\"type\":\"boolean\"},\"allowNullableBoolean\":{\"type\":\"boolean\"},\"allowNullableString\":{\"type\":\"boolean\"},\"allowNullableNumber\":{\"type\":\"boolean\"},\"allowNullableEnum\":{\"type\":\"boolean\"},\"allowAny\":{\"type\":\"boolean\"}},\"additionalProperties\":false},\"script/no-restricted-globals\":{\"$ref\":\"#/definitions/NoRestrictedGlobalsOptions\"},\"script/no-restricted-members\":{\"$ref\":\"#/definitions/NoRestrictedMembersOptions\"},\"vue/component-name-in-template-casing\":{\"type\":\"object\",\"properties\":{\"casing\":{\"type\":\"string\",\"enum\":[\"PascalCase\",\"kebab-case\"]},\"registeredComponentsOnly\":{\"type\":\"boolean\"},\"globals\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}}},\"additionalProperties\":false},\"script/custom-event-name-casing\":{\"type\":\"object\",\"properties\":{\"casing\":{\"type\":\"string\",\"enum\":[\"camelCase\",\"kebab-case\"]}},\"additionalProperties\":false},\"vue/no-mutating-props\":{\"type\":\"object\",\"properties\":{\"shallowOnly\":{\"type\":\"boolean\"}},\"additionalProperties\":false},\"vue/require-component-registration\":{\"type\":\"object\",\"properties\":{\"globals\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}}},\"additionalProperties\":false},\"vue/sfc-element-order\":{\"type\":\"object\",\"properties\":{\"order\":{\"type\":\"array\",\"items\":{\"oneOf\":[{\"type\":\"string\"},{\"type\":\"array\",\"items\":{\"type\":\"string\"}}]}}},\"additionalProperties\":false},\"vue/html-self-closing\":{\"type\":\"object\",\"properties\":{\"html\":{\"type\":\"object\",\"properties\":{\"void\":{\"type\":\"string\",\"enum\":[\"always\",\"never\",\"any\"]},\"normal\":{\"type\":\"string\",\"enum\":[\"always\",\"never\",\"any\"]},\"component\":{\"type\":\"string\",\"enum\":[\"always\",\"never\",\"any\"]}},\"additionalProperties\":false},\"svg\":{\"type\":\"string\",\"enum\":[\"always\",\"never\",\"any\"]},\"math\":{\"type\":\"string\",\"enum\":[\"always\",\"never\",\"any\"]}},\"additionalProperties\":false},\"vue/v-on-event-hyphenation\":{\"type\":\"string\",\"enum\":[\"always\",\"never\"]},\"vue/attribute-hyphenation\":{\"type\":\"string\",\"enum\":[\"always\",\"never\"]},\"vue/valid-v-on\":{\"type\":\"object\",\"properties\":{\"modifiers\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}}},\"additionalProperties\":false},\"vue/valid-v-slot\":{\"type\":\"object\",\"properties\":{\"allowModifiers\":{\"type\":\"boolean\"}},\"additionalProperties\":false},\"musea/prefer-design-tokens\":{\"$ref\":\"#/definitions/MuseaPreferDesignTokensOptions\"}},\"additionalProperties\":false},\"NoRestrictedGlobalsOptions\":{\"type\":\"object\",\"properties\":{\"globals\":{\"type\":\"array\",\"items\":{\"$ref\":\"#/definitions/RestrictedGlobal\"}}},\"additionalProperties\":false},\"RestrictedGlobal\":{\"type\":\"object\",\"properties\":{\"name\":{\"type\":\"string\"},\"message\":{\"type\":\"string\"}},\"additionalProperties\":false,\"required\":[\"name\"]},\"NoRestrictedMembersOptions\":{\"type\":\"object\",\"properties\":{\"members\":{\"type\":\"array\",\"items\":{\"$ref\":\"#/definitions/RestrictedMember\"}}},\"additionalProperties\":false},\"RestrictedMember\":{\"type\":\"object\",\"properties\":{\"object\":{\"type\":\"string\"},\"property\":{\"type\":\"string\"},\"message\":{\"type\":\"string\"}},\"additionalProperties\":false,\"required\":[\"object\",\"property\"]},\"MuseaPreferDesignTokensOptions\":{\"type\":\"object\",\"properties\":{\"tokens\":{\"type\":\"array\",\"items\":{\"$ref\":\"#/definitions/MuseaDesignToken\"}}},\"additionalProperties\":false},\"MuseaDesignToken\":{\"type\":\"object\",\"properties\":{\"path\":{\"type\":\"string\"},\"value\":{\"type\":\"string\"},\"tier\":{\"type\":\"string\"}},\"additionalProperties\":false,\"required\":[\"path\",\"value\"]},\"FormatterConfig\":{\"type\":\"object\",\"properties\":{\"preset\":{\"type\":\"string\",\"enum\":[\"vize\",\"prettier\"]},\"sortImports\":{\"oneOf\":[{\"type\":\"boolean\",\"enum\":[false]},{\"$ref\":\"#/definitions/SortImportsConfig\"}]},\"printWidth\":{\"type\":\"integer\"},\"tabWidth\":{\"type\":\"integer\"},\"useTabs\":{\"type\":\"boolean\"},\"semi\":{\"type\":\"boolean\"},\"singleQuote\":{\"type\":\"boolean\"},\"jsxSingleQuote\":{\"type\":\"boolean\"},\"trailingComma\":{\"type\":\"string\",\"enum\":[\"all\",\"none\",\"es5\"]},\"bracketSpacing\":{\"type\":\"boolean\"},\"bracketSameLine\":{\"type\":\"boolean\"},\"arrowParens\":{\"type\":\"string\",\"enum\":[\"always\",\"avoid\"]},\"endOfLine\":{\"type\":\"string\",\"enum\":[\"lf\",\"crlf\",\"cr\",\"auto\"]},\"quoteProps\":{\"type\":\"string\",\"enum\":[\"as-needed\",\"consistent\",\"preserve\"]},\"singleAttributePerLine\":{\"type\":\"boolean\"},\"vueIndentScriptAndStyle\":{\"type\":\"boolean\"},\"sortAttributes\":{\"type\":\"boolean\"},\"attributeSortOrder\":{\"type\":\"string\",\"enum\":[\"alphabetical\",\"as-written\"]},\"mergeBindAndNonBindAttrs\":{\"type\":\"boolean\"},\"maxAttributesPerLine\":{\"type\":\"integer\"},\"attributeGroups\":{\"type\":\"array\",\"items\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}}},\"normalizeDirectiveShorthands\":{\"type\":\"boolean\"},\"sortBlocks\":{\"type\":\"boolean\"},\"normalizeCssQuotes\":{\"type\":\"boolean\"},\"normalizeInlineStyles\":{\"type\":\"boolean\"},\"normalizeVForParens\":{\"type\":\"boolean\"},\"selfCloseVoidElements\":{\"type\":\"boolean\"},\"reindentPreprocessorStyles\":{\"type\":\"boolean\"}},\"additionalProperties\":false},\"SortImportsConfig\":{\"type\":\"object\",\"properties\":{\"partitionByNewline\":{\"type\":\"boolean\"},\"partitionByComment\":{\"type\":\"boolean\"},\"sortSideEffects\":{\"type\":\"boolean\"},\"order\":{\"type\":\"string\",\"enum\":[\"asc\",\"desc\"]},\"ignoreCase\":{\"type\":\"boolean\"},\"newlinesBetween\":{\"type\":\"boolean\"},\"internalPattern\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}},\"groups\":{\"type\":\"array\",\"items\":{\"oneOf\":[{\"type\":\"string\"},{\"type\":\"array\",\"items\":{\"type\":\"string\"}},{\"type\":\"object\",\"properties\":{\"newlinesBetween\":{\"type\":\"boolean\"}},\"additionalProperties\":false,\"required\":[\"newlinesBetween\"]}]}},\"customGroups\":{\"type\":\"array\",\"items\":{\"$ref\":\"#/definitions/ImportSortCustomGroup\"}}},\"additionalProperties\":false},\"ImportSortCustomGroup\":{\"type\":\"object\",\"properties\":{\"groupName\":{\"type\":\"string\"},\"elementNamePattern\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}},\"selector\":{\"type\":\"string\"},\"modifiers\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}}},\"additionalProperties\":false,\"required\":[\"groupName\"]},\"LanguageServerConfig\":{\"type\":\"object\",\"properties\":{\"enabled\":{\"type\":\"boolean\"},\"lint\":{\"type\":\"boolean\"},\"diagnostics\":{\"type\":\"boolean\"},\"typecheck\":{\"type\":\"boolean\"},\"editor\":{\"type\":\"boolean\"},\"ecosystem\":{\"type\":\"boolean\"},\"crossFile\":{\"type\":\"boolean\"},\"legacyVue2\":{\"type\":\"boolean\"},\"completion\":{\"type\":\"boolean\"},\"signatureHelp\":{\"type\":\"boolean\"},\"hover\":{\"type\":\"boolean\"},\"definition\":{\"type\":\"boolean\"},\"references\":{\"type\":\"boolean\"},\"documentSymbols\":{\"type\":\"boolean\"},\"workspaceSymbols\":{\"type\":\"boolean\"},\"formatting\":{\"type\":\"boolean\"},\"codeActions\":{\"type\":\"boolean\"},\"rename\":{\"type\":\"boolean\"},\"codeLens\":{\"type\":\"boolean\"},\"semanticTokens\":{\"type\":\"boolean\"},\"documentLinks\":{\"type\":\"boolean\"},\"foldingRanges\":{\"type\":\"boolean\"},\"inlayHints\":{\"type\":\"boolean\"},\"fileRename\":{\"type\":\"boolean\"},\"corsa\":{\"type\":\"boolean\"},\"tsgo\":{\"type\":\"boolean\"}},\"additionalProperties\":false},\"GlobalTypesConfig\":{\"type\":\"object\",\"additionalProperties\":{\"oneOf\":[{\"type\":\"string\"},{\"$ref\":\"#/definitions/GlobalTypeDeclaration\"}]}},\"GlobalTypeDeclaration\":{\"type\":\"object\",\"properties\":{\"type\":{\"type\":\"string\"},\"defaultValue\":{\"type\":\"string\"}},\"additionalProperties\":false,\"required\":[\"type\"]},\"LibConfig\":{\"type\":\"object\",\"properties\":{\"dir\":{\"type\":\"string\"},\"uiDir\":{\"type\":\"string\"},\"composableDir\":{\"type\":\"string\"},\"lockfile\":{\"type\":\"string\"},\"registries\":{\"type\":\"object\",\"additionalProperties\":{\"oneOf\":[{\"type\":\"string\"},{\"type\":\"object\",\"properties\":{\"source\":{\"type\":\"string\"},\"dir\":{\"type\":\"string\"}},\"additionalProperties\":false,\"required\":[\"source\"]}]},\"propertyNames\":{\"pattern\":\"^@[a-z0-9][a-z0-9._-]*$\"}}},\"additionalProperties\":false}}}");
|
|
1091
|
+
const sourceConfigKey = Symbol.for("@vizejs/vite-plugin/vite-plus/source");
|
|
1092
|
+
function object(value) {
|
|
1093
|
+
if (value === null || typeof value !== "object") return false;
|
|
1094
|
+
const prototype = Object.getPrototypeOf(value);
|
|
1095
|
+
return prototype === Object.prototype || prototype === null;
|
|
1096
|
+
}
|
|
1097
|
+
async function resolveSource(value, env, parents = /* @__PURE__ */ new Set()) {
|
|
1098
|
+
value = await value;
|
|
1099
|
+
if (parents.has(value)) throw new Error("Circular Vue configuration source");
|
|
1100
|
+
parents.add(value);
|
|
1101
|
+
try {
|
|
1102
|
+
if ((typeof value === "function" || object(value)) && sourceConfigKey in value) return await resolveSource(value[sourceConfigKey], env, parents);
|
|
1103
|
+
const config = await (typeof value === "function" ? value(env) : value);
|
|
1104
|
+
if (!object(config)) throw new Error("Vite config must export an object or a config function");
|
|
1105
|
+
rejectLegacyConfig(config);
|
|
1106
|
+
return config;
|
|
1107
|
+
} finally {
|
|
1108
|
+
parents.delete(value);
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1111
|
+
function rejectLegacyConfig(source) {
|
|
1112
|
+
if (Object.hasOwn(source, "extends")) throw new Error("Custom config extends is no longer supported; use defineConfig(vpConfig).withVue(vueConfig)");
|
|
1113
|
+
if (Object.hasOwn(source, "vize")) throw new Error("vize: configuration is no longer supported; move Vue settings to vue: in vite.config.*");
|
|
1114
|
+
for (const key of [
|
|
1115
|
+
"lint",
|
|
1116
|
+
"fmt",
|
|
1117
|
+
"pack"
|
|
1118
|
+
]) if ((Array.isArray(source[key]) ? source[key] : [source[key]]).some((value) => object(value) && Object.hasOwn(value, "vize"))) throw new Error(`${key}.vize is no longer supported; use ${key}.vue or the shared vue: settings`);
|
|
1119
|
+
}
|
|
1120
|
+
const VITE_CONFIG_FILE_NAMES = [
|
|
1121
|
+
"vite.config.ts",
|
|
1122
|
+
"vite.config.js",
|
|
1123
|
+
"vite.config.mjs",
|
|
1124
|
+
"vite.config.cjs",
|
|
1125
|
+
"vite.config.mts",
|
|
1126
|
+
"vite.config.cts"
|
|
1127
|
+
];
|
|
1128
|
+
/** Resolve an authored Vite export without projecting away Vite-owned task settings. */
|
|
1129
|
+
async function resolveViteConfigSource(exported, env) {
|
|
1130
|
+
env ??= {
|
|
1131
|
+
mode: "development",
|
|
1132
|
+
command: "serve"
|
|
1133
|
+
};
|
|
1134
|
+
if (env.command !== "build" && env.command !== "serve") env = {
|
|
1135
|
+
...env,
|
|
1136
|
+
command: "serve"
|
|
1137
|
+
};
|
|
1138
|
+
return resolveSource(exported, env);
|
|
1139
|
+
}
|
|
1140
|
+
//#endregion
|
|
726
1141
|
//#region src/lint/project-rules.ts
|
|
727
1142
|
const CONFIG_PRESETS = [
|
|
728
1143
|
"happy-path",
|
|
@@ -732,14 +1147,115 @@ const CONFIG_PRESETS = [
|
|
|
732
1147
|
"ecosystem",
|
|
733
1148
|
"nuxt"
|
|
734
1149
|
];
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
const
|
|
739
|
-
|
|
740
|
-
|
|
1150
|
+
const RETIRED_CONFIG = /^vize\.config\.(?:pkl|[cm]?[jt]s|json)$/;
|
|
1151
|
+
const CONFIG_MIGRATION = "vize.config.* is no longer supported; move Vue settings to vue: in vite.config.* and TypeScript settings to tsconfig.json";
|
|
1152
|
+
async function readProjectLintRuleSets(rootDir, loadPreset = loadPresetRules) {
|
|
1153
|
+
const project = await readProjectConfig(rootDir);
|
|
1154
|
+
const linter = project.linter;
|
|
1155
|
+
const oxlint = explicitOxlintRules(project.oxlint);
|
|
1156
|
+
const warnings = [];
|
|
1157
|
+
let vize;
|
|
1158
|
+
if (linter) {
|
|
1159
|
+
const rules = applyRuleOptions({
|
|
1160
|
+
...linter.preset && linter.preset !== "incremental" ? await loadPreset(linter.preset, linter.typeAware) : {},
|
|
1161
|
+
...linter.rules
|
|
1162
|
+
}, linter.ruleOptions, warnings, "vue.linter");
|
|
1163
|
+
if (Object.keys(rules).length > 0) vize = rules;
|
|
1164
|
+
}
|
|
1165
|
+
const entries = project.entries.map((entry, index) => {
|
|
1166
|
+
const rules = applyRuleOptions({ ...entry.rules }, entry.ruleOptions, warnings, `vue.entries[${String(index)}].linter`, vize);
|
|
1167
|
+
if (Object.keys(rules).length === 0) return void 0;
|
|
1168
|
+
return {
|
|
1169
|
+
files: entry.files,
|
|
1170
|
+
...entry.ignores ? { ignores: entry.ignores } : {},
|
|
1171
|
+
...entry.name ? { name: entry.name } : {},
|
|
1172
|
+
rules
|
|
1173
|
+
};
|
|
1174
|
+
}).filter((entry) => entry !== void 0);
|
|
1175
|
+
return {
|
|
1176
|
+
...entries.length > 0 ? { entries } : {},
|
|
1177
|
+
...vize ? { vize } : {},
|
|
1178
|
+
...Object.keys(oxlint).length > 0 ? { oxlint } : {},
|
|
1179
|
+
...warnings.length > 0 ? { warnings } : {}
|
|
1180
|
+
};
|
|
1181
|
+
}
|
|
1182
|
+
async function readProjectConfig(rootDir) {
|
|
1183
|
+
const parsed = await loadProjectViteConfigSource(rootDir);
|
|
1184
|
+
if (!parsed) return { entries: [] };
|
|
1185
|
+
const rawVue = parsed.vue && typeof parsed.vue === "object" ? parsed.vue : void 0;
|
|
1186
|
+
const rawLinter = rawVue && "linter" in rawVue ? projectLinter(rawVue.linter) : void 0;
|
|
1187
|
+
return {
|
|
1188
|
+
entries: rawVue && "entries" in rawVue ? projectEntries(rawVue.entries) : [],
|
|
1189
|
+
linter: rawLinter,
|
|
1190
|
+
oxlint: parsed.lint
|
|
741
1191
|
};
|
|
742
|
-
|
|
1192
|
+
}
|
|
1193
|
+
function projectLinter(value) {
|
|
1194
|
+
if (!value || typeof value !== "object") return void 0;
|
|
1195
|
+
const raw = value;
|
|
1196
|
+
return {
|
|
1197
|
+
preset: isConfigPreset(raw.preset) ? raw.preset : void 0,
|
|
1198
|
+
ruleOptions: explicitRuleOptions(raw.ruleOptions),
|
|
1199
|
+
typeAware: raw.typeAware === true,
|
|
1200
|
+
rules: explicitRules(raw.rules)
|
|
1201
|
+
};
|
|
1202
|
+
}
|
|
1203
|
+
function projectEntries(value) {
|
|
1204
|
+
if (!Array.isArray(value)) return [];
|
|
1205
|
+
return value.flatMap((candidate) => {
|
|
1206
|
+
if (!candidate || typeof candidate !== "object") return [];
|
|
1207
|
+
const raw = candidate;
|
|
1208
|
+
const linter = projectLinter(raw.linter);
|
|
1209
|
+
const files = scopedGlobs(raw.files, raw.basePath);
|
|
1210
|
+
if (!linter || files.length === 0) return [];
|
|
1211
|
+
const ignores = scopedGlobs(raw.ignores, raw.basePath);
|
|
1212
|
+
return [{
|
|
1213
|
+
...linter,
|
|
1214
|
+
files,
|
|
1215
|
+
...ignores.length > 0 ? { ignores } : {},
|
|
1216
|
+
...typeof raw.name === "string" && raw.name ? { name: raw.name } : {}
|
|
1217
|
+
}];
|
|
1218
|
+
});
|
|
1219
|
+
}
|
|
1220
|
+
function scopedGlobs(value, basePath) {
|
|
1221
|
+
if (!Array.isArray(value)) return [];
|
|
1222
|
+
const base = typeof basePath === "string" && basePath ? basePath : void 0;
|
|
1223
|
+
return value.flatMap((glob) => {
|
|
1224
|
+
if (typeof glob !== "string" || !glob) return [];
|
|
1225
|
+
return [base && !path$1.isAbsolute(glob) ? path$1.join(base, glob) : glob];
|
|
1226
|
+
});
|
|
1227
|
+
}
|
|
1228
|
+
async function loadProjectViteConfigSource(rootDir) {
|
|
1229
|
+
let directory = path$1.resolve(rootDir);
|
|
1230
|
+
while (true) {
|
|
1231
|
+
for (const name of VITE_CONFIG_FILE_NAMES) {
|
|
1232
|
+
const filePath = path$1.join(directory, name);
|
|
1233
|
+
if (!fs$1.existsSync(filePath)) continue;
|
|
1234
|
+
const module = await importConfigModule(filePath);
|
|
1235
|
+
if (module === null) throw new Error("Unable to load Vite configuration at " + filePath);
|
|
1236
|
+
return resolveViteConfigSource(module.default ?? module, {
|
|
1237
|
+
command: "lint",
|
|
1238
|
+
mode: "development"
|
|
1239
|
+
});
|
|
1240
|
+
}
|
|
1241
|
+
if (fs$1.existsSync(directory) && fs$1.readdirSync(directory).some((name) => RETIRED_CONFIG.test(name))) throw new Error(CONFIG_MIGRATION);
|
|
1242
|
+
if ([
|
|
1243
|
+
"package.json",
|
|
1244
|
+
"tsconfig.json",
|
|
1245
|
+
"jsconfig.json"
|
|
1246
|
+
].some((name) => fs$1.existsSync(path$1.join(directory, name)))) return null;
|
|
1247
|
+
const parent = path$1.dirname(directory);
|
|
1248
|
+
if (parent === directory) return null;
|
|
1249
|
+
directory = parent;
|
|
1250
|
+
}
|
|
1251
|
+
}
|
|
1252
|
+
function explicitOxlintRules(value) {
|
|
1253
|
+
if (!value || typeof value !== "object") return {};
|
|
1254
|
+
const rules = "rules" in value ? value.rules : void 0;
|
|
1255
|
+
if (!rules || typeof rules !== "object") return {};
|
|
1256
|
+
const result = {};
|
|
1257
|
+
for (const [id, severity] of Object.entries(rules)) if (isSeverity(severity)) result[id] = severity;
|
|
1258
|
+
return result;
|
|
743
1259
|
}
|
|
744
1260
|
async function loadPresetRules(preset, typeAware) {
|
|
745
1261
|
const { createVizeRuleConfig } = await import("oxlint-plugin-vize");
|
|
@@ -755,24 +1271,6 @@ async function loadPresetRules(preset, typeAware) {
|
|
|
755
1271
|
}
|
|
756
1272
|
return rules;
|
|
757
1273
|
}
|
|
758
|
-
async function readVizeConfigLinter(rootDir) {
|
|
759
|
-
const { loadConfig } = await import("vize/config");
|
|
760
|
-
const parsed = await loadConfig(rootDir, {
|
|
761
|
-
mode: "auto",
|
|
762
|
-
env: {
|
|
763
|
-
command: "lint",
|
|
764
|
-
mode: "development"
|
|
765
|
-
}
|
|
766
|
-
});
|
|
767
|
-
if (!parsed) return void 0;
|
|
768
|
-
if (!parsed.linter || typeof parsed.linter !== "object") return void 0;
|
|
769
|
-
const linter = parsed.linter;
|
|
770
|
-
return {
|
|
771
|
-
preset: isConfigPreset(linter.preset) ? linter.preset : void 0,
|
|
772
|
-
typeAware: linter.typeAware === true,
|
|
773
|
-
rules: explicitRules(linter.rules)
|
|
774
|
-
};
|
|
775
|
-
}
|
|
776
1274
|
function explicitRules(value) {
|
|
777
1275
|
if (!value || typeof value !== "object") return {};
|
|
778
1276
|
const rules = {};
|
|
@@ -783,6 +1281,46 @@ function explicitRules(value) {
|
|
|
783
1281
|
}
|
|
784
1282
|
return rules;
|
|
785
1283
|
}
|
|
1284
|
+
function explicitRuleOptions(value) {
|
|
1285
|
+
if (!value || typeof value !== "object") return {};
|
|
1286
|
+
const options = {};
|
|
1287
|
+
for (const [id, option] of Object.entries(value)) {
|
|
1288
|
+
const bare = id.startsWith("vize/") ? id.slice(5) : id;
|
|
1289
|
+
if (bare.length > 0) options[bare] = option;
|
|
1290
|
+
}
|
|
1291
|
+
return options;
|
|
1292
|
+
}
|
|
1293
|
+
function applyRuleOptions(source, options, warnings, scope, fallback = {}) {
|
|
1294
|
+
const rules = { ...source };
|
|
1295
|
+
for (const [ruleId, option] of Object.entries(options)) {
|
|
1296
|
+
const arguments_ = bridgedRuleOptions(ruleId, option);
|
|
1297
|
+
if (!arguments_) {
|
|
1298
|
+
warnings.push(`${scope}.ruleOptions[${JSON.stringify(ruleId)}] is not supported by oxlint-vize`);
|
|
1299
|
+
continue;
|
|
1300
|
+
}
|
|
1301
|
+
const configured = rules[ruleId] ?? fallback[ruleId];
|
|
1302
|
+
const severity = Array.isArray(configured) ? configured[0] : configured;
|
|
1303
|
+
if (!isSeverity(severity)) {
|
|
1304
|
+
warnings.push(`${scope}.ruleOptions[${JSON.stringify(ruleId)}] has no enabled rule severity to attach to`);
|
|
1305
|
+
continue;
|
|
1306
|
+
}
|
|
1307
|
+
rules[ruleId] = [severity, ...arguments_];
|
|
1308
|
+
}
|
|
1309
|
+
return rules;
|
|
1310
|
+
}
|
|
1311
|
+
function bridgedRuleOptions(ruleId, value) {
|
|
1312
|
+
if (ruleId === "vue/v-on-event-hyphenation" || ruleId === "vue/attribute-hyphenation") return value === "always" || value === "never" ? [value] : void 0;
|
|
1313
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
|
|
1314
|
+
const option = value;
|
|
1315
|
+
switch (ruleId) {
|
|
1316
|
+
case "vue/component-name-in-template-casing": return Object.keys(option).every((key) => key === "casing") && (option.casing === "PascalCase" || option.casing === "kebab-case") ? [option.casing] : void 0;
|
|
1317
|
+
case "script/custom-event-name-casing": return Object.keys(option).every((key) => key === "casing") && (option.casing === "camelCase" || option.casing === "kebab-case") ? [option.casing] : void 0;
|
|
1318
|
+
case "vue/no-mutating-props":
|
|
1319
|
+
case "vue/sfc-element-order":
|
|
1320
|
+
case "vue/html-self-closing": return [value];
|
|
1321
|
+
default: return;
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
786
1324
|
function isConfigPreset(value) {
|
|
787
1325
|
return typeof value === "string" && CONFIG_PRESETS.includes(value);
|
|
788
1326
|
}
|
|
@@ -1332,18 +1870,39 @@ async function setupNuxtLintConfigGeneration(lint, nuxt, dependencies = {}) {
|
|
|
1332
1870
|
const ownsReservedConfig = configFile === path.join(nuxtRoot, GENERATED_CONFIG_NAME);
|
|
1333
1871
|
const hasTypeScriptProbe = dependencies.hasTypeScript ?? hasTypeScript;
|
|
1334
1872
|
const resolvePluginSpecifier = dependencies.resolvePluginSpecifier ?? resolveVizePluginSpecifier;
|
|
1335
|
-
const resolveAddons = dependencies.resolveAddons ?? ("callHook" in nuxt ? setupNuxtLintConfigAddons(nuxt) : void 0);
|
|
1336
|
-
const
|
|
1873
|
+
const resolveAddons = dependencies.resolveAddons ?? ("callHook" in nuxt ? setupNuxtLintConfigAddons(nuxt, { rootDir: planRoot }) : void 0);
|
|
1874
|
+
const resolveProjectRuleSets = dependencies.resolveProjectLintRules ? async (rootDir) => {
|
|
1875
|
+
const rules = await dependencies.resolveProjectLintRules?.(rootDir);
|
|
1876
|
+
return rules && Object.keys(rules).length > 0 ? { vize: rules } : {};
|
|
1877
|
+
} : readProjectLintRuleSets;
|
|
1337
1878
|
let currentPlan = [];
|
|
1879
|
+
const emittedWarnings = /* @__PURE__ */ new Set();
|
|
1338
1880
|
const regenerate = async () => {
|
|
1339
1881
|
const plan = buildNuxtLintPlan(resolveNuxtLintFeatures(featureOptions, () => hasTypeScriptProbe(planRoot)), collectNuxtLintDirs(toNuxtLintProjectState(nuxt.options, { rootDir: planRoot })), getDetectedNuxtMajor(nuxt) ?? 3);
|
|
1340
1882
|
const addons = await resolveAddons?.() ?? [];
|
|
1341
|
-
const projectRules = await
|
|
1883
|
+
const projectRules = await resolveProjectRuleSets(planRoot);
|
|
1884
|
+
const projectItems = [];
|
|
1885
|
+
if (projectRules.vize) projectItems.push({
|
|
1886
|
+
name: "project/preset",
|
|
1887
|
+
rules: projectRules.vize
|
|
1888
|
+
});
|
|
1889
|
+
if (projectRules.oxlint) projectItems.push({
|
|
1890
|
+
name: "project/oxlint",
|
|
1891
|
+
nativeRules: projectRules.oxlint
|
|
1892
|
+
});
|
|
1893
|
+
for (const [index, entry] of (projectRules.entries ?? []).entries()) projectItems.push({
|
|
1894
|
+
name: entry.name ? `project/${entry.name}` : `project/entry-${String(index + 1)}`,
|
|
1895
|
+
files: entry.files,
|
|
1896
|
+
...entry.ignores ? { ignores: entry.ignores } : {},
|
|
1897
|
+
rules: entry.rules
|
|
1898
|
+
});
|
|
1899
|
+
for (const warning of projectRules.warnings ?? []) {
|
|
1900
|
+
if (emittedWarnings.has(warning)) continue;
|
|
1901
|
+
emittedWarnings.add(warning);
|
|
1902
|
+
(dependencies.warn ?? console.warn)(`@vizejs/nuxt lint config: ${warning}`);
|
|
1903
|
+
}
|
|
1342
1904
|
const nextPlan = [
|
|
1343
|
-
...
|
|
1344
|
-
name: "project/preset",
|
|
1345
|
-
rules: projectRules
|
|
1346
|
-
}] : [],
|
|
1905
|
+
...projectItems,
|
|
1347
1906
|
...plan,
|
|
1348
1907
|
...addons
|
|
1349
1908
|
];
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as VizeNuxtUiOptions, S as VizeNuxtComposablesOptions, _ as VizeNuxtLintCheckerOptions, b as VizeNuxtCompilerOptions, c as NuxtMuseaOptions, d as VizeNuxtDevOptions, f as VizeNuxtMajorVersion, h as VizeNuxtLintOptions, l as VizeNuxtBridgeOptions, m as VizeNuxtUnoCssOptions, n as NuxtLintConfigAddon, p as VizeNuxtOptions, u as VizeNuxtCompatibilityOptions, x as VizeNuxtVueVersion, y as VizeNuxtCompilerCompatibilityOptions } from "./addons-
|
|
1
|
+
import { C as VizeNuxtUiOptions, S as VizeNuxtComposablesOptions, _ as VizeNuxtLintCheckerOptions, b as VizeNuxtCompilerOptions, c as NuxtMuseaOptions, d as VizeNuxtDevOptions, f as VizeNuxtMajorVersion, h as VizeNuxtLintOptions, l as VizeNuxtBridgeOptions, m as VizeNuxtUnoCssOptions, n as NuxtLintConfigAddon, p as VizeNuxtOptions, u as VizeNuxtCompatibilityOptions, x as VizeNuxtVueVersion, y as VizeNuxtCompilerCompatibilityOptions } from "./addons-Dgv98GJt.mjs";
|
|
2
2
|
import { MuseaOptions } from "@vizejs/vite-plugin-musea";
|
|
3
3
|
|
|
4
4
|
//#region src/schema.d.ts
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as setupLintInspector, l as setupNuxtLintChecker, m as hasNuxtViteCompilerSupport, n as setupNuxtLintConfigGeneration, p as getDetectedNuxtMajor } from "./generation-
|
|
1
|
+
import { i as setupLintInspector, l as setupNuxtLintChecker, m as hasNuxtViteCompilerSupport, n as setupNuxtLintConfigGeneration, p as getDetectedNuxtMajor } from "./generation-Dk5P-qti.mjs";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import fs from "node:fs";
|
|
4
4
|
import path, { dirname, join, resolve } from "node:path";
|
package/dist/lint/index.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { _ as VizeNuxtLintCheckerOptions, a as ResolveNuxtLintConfigAddons, g as ResolvedVizeNuxtLintCheckerOptions, h as VizeNuxtLintOptions, i as NuxtLintImport, n as NuxtLintConfigAddon, o as VIZE_NUXT_LINT_CONFIG_ADDONS_HOOK, r as NuxtLintConfigAddonNuxt, s as setupNuxtLintConfigAddons, t as NuxtLintAwaitable, v as resolveNuxtLintCheckerOptions } from "../addons-
|
|
2
|
-
import { NuxtLintConfigItem, NuxtLintDirNames, NuxtLintLayer, NuxtLintProjectState,
|
|
1
|
+
import { _ as VizeNuxtLintCheckerOptions, a as ResolveNuxtLintConfigAddons, g as ResolvedVizeNuxtLintCheckerOptions, h as VizeNuxtLintOptions, i as NuxtLintImport, n as NuxtLintConfigAddon, o as VIZE_NUXT_LINT_CONFIG_ADDONS_HOOK, r as NuxtLintConfigAddonNuxt, s as setupNuxtLintConfigAddons, t as NuxtLintAwaitable, v as resolveNuxtLintCheckerOptions } from "../addons-Dgv98GJt.mjs";
|
|
2
|
+
import { NuxtLintConfigItem, NuxtLintDirNames, NuxtLintLayer, NuxtLintProjectState, NuxtLintRuleConfig } from "@vizejs/nuxt-lint-config";
|
|
3
3
|
export * from "@vizejs/nuxt-lint-config";
|
|
4
4
|
|
|
5
5
|
//#region src/lint/project-rules.d.ts
|
|
6
|
-
type ProjectLintRules = Record<string,
|
|
6
|
+
type ProjectLintRules = Record<string, NuxtLintRuleConfig>;
|
|
7
7
|
//#endregion
|
|
8
8
|
//#region src/lint/generation.d.ts
|
|
9
9
|
/** Root config names supported by oxlint's config discovery. */
|
|
@@ -24,6 +24,7 @@ interface NuxtLintGenerationDependencies {
|
|
|
24
24
|
resolvePluginSpecifier?: (configDir: string) => string;
|
|
25
25
|
/** Shared project rules. Tests inject this so generation never loads the native preset binding. */
|
|
26
26
|
resolveProjectLintRules?: (rootDir: string) => Awaitable$1<ProjectLintRules | undefined>;
|
|
27
|
+
warn?: (message: string) => void;
|
|
27
28
|
}
|
|
28
29
|
interface NuxtLintConfigGeneration {
|
|
29
30
|
configFile: string;
|
|
@@ -61,11 +62,25 @@ interface NuxtLintCheckerTask {
|
|
|
61
62
|
oxlintEntrypoint?: string;
|
|
62
63
|
}
|
|
63
64
|
interface NuxtLintCheckerResult {
|
|
65
|
+
diagnostics: NuxtLintCheckerDiagnostic[];
|
|
64
66
|
diagnosticCount: number;
|
|
65
67
|
hasErrors: boolean;
|
|
66
68
|
hasWarnings: boolean;
|
|
67
69
|
output: string;
|
|
68
70
|
}
|
|
71
|
+
interface NuxtLintCheckerDiagnostic {
|
|
72
|
+
code?: string;
|
|
73
|
+
filePath?: string;
|
|
74
|
+
filename?: string;
|
|
75
|
+
labels?: Array<{
|
|
76
|
+
span?: {
|
|
77
|
+
column?: number;
|
|
78
|
+
line?: number;
|
|
79
|
+
};
|
|
80
|
+
}>;
|
|
81
|
+
message?: string;
|
|
82
|
+
severity?: string | number;
|
|
83
|
+
}
|
|
69
84
|
//#endregion
|
|
70
85
|
//#region src/lint/checker/vite.d.ts
|
|
71
86
|
declare const PLUGIN_NAME = "vize:nuxt-lint-checker";
|
package/dist/lint/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as toNuxtLintProjectState, c as setupNuxtLintConfigAddons, d as createNuxtLintCheckerVitePlugin, f as resolveNuxtLintCheckerOptions, l as setupNuxtLintChecker, n as setupNuxtLintConfigGeneration, o as renderNuxtOxlintConfig, r as writeFileIfChanged, s as VIZE_NUXT_LINT_CONFIG_ADDONS_HOOK, t as ROOT_OXLINT_CONFIG_NAMES, u as createNuxtLintCheckerWebpackPlugin } from "../generation-
|
|
1
|
+
import { a as toNuxtLintProjectState, c as setupNuxtLintConfigAddons, d as createNuxtLintCheckerVitePlugin, f as resolveNuxtLintCheckerOptions, l as setupNuxtLintChecker, n as setupNuxtLintConfigGeneration, o as renderNuxtOxlintConfig, r as writeFileIfChanged, s as VIZE_NUXT_LINT_CONFIG_ADDONS_HOOK, t as ROOT_OXLINT_CONFIG_NAMES, u as createNuxtLintCheckerWebpackPlugin } from "../generation-Dk5P-qti.mjs";
|
|
2
2
|
export * from "@vizejs/nuxt-lint-config";
|
|
3
3
|
export { ROOT_OXLINT_CONFIG_NAMES, VIZE_NUXT_LINT_CONFIG_ADDONS_HOOK, createNuxtLintCheckerVitePlugin, createNuxtLintCheckerWebpackPlugin, renderNuxtOxlintConfig, resolveNuxtLintCheckerOptions, setupNuxtLintChecker, setupNuxtLintConfigAddons, setupNuxtLintConfigGeneration, toNuxtLintProjectState, writeFileIfChanged };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vizejs/nuxt",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.503.0",
|
|
4
4
|
"description": "Nuxt module for Vize - compiler, musea gallery, linter, and type checker",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"compiler",
|
|
@@ -49,12 +49,12 @@
|
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@nuxt/kit": "3.11.2",
|
|
52
|
-
"@vizejs/native": "0.
|
|
53
|
-
"@vizejs/nuxt-lint-config": "0.
|
|
54
|
-
"@vizejs/vite-plugin": "0.
|
|
55
|
-
"@vizejs/vite-plugin-musea": "0.
|
|
56
|
-
"oxlint-plugin-vize": "0.
|
|
57
|
-
"vize": "0.
|
|
52
|
+
"@vizejs/native": "0.503.0",
|
|
53
|
+
"@vizejs/nuxt-lint-config": "0.503.0",
|
|
54
|
+
"@vizejs/vite-plugin": "0.503.0",
|
|
55
|
+
"@vizejs/vite-plugin-musea": "0.503.0",
|
|
56
|
+
"oxlint-plugin-vize": "0.503.0",
|
|
57
|
+
"vize": "0.503.0"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"jiti-nuxt2": "npm:jiti@1.21.7",
|