@vizejs/nuxt 0.507.0 → 0.508.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.
|
@@ -703,7 +703,7 @@ function mergeRules(target, source) {
|
|
|
703
703
|
Object.assign(target, prefixVizeRules(source));
|
|
704
704
|
}
|
|
705
705
|
/** Render the complete generated oxlint config, including its trailing newline. */
|
|
706
|
-
function renderNuxtOxlintConfig(items, pluginSpecifier, globBase) {
|
|
706
|
+
function renderNuxtOxlintConfig(items, pluginSpecifier, globBase, projectJsPlugins = []) {
|
|
707
707
|
if (globBase) {
|
|
708
708
|
const root = path.relative(globBase.configDir, globBase.rootDir);
|
|
709
709
|
if (root === ".." || root.startsWith(`..${path.sep}`) || path.isAbsolute(root)) throw new Error("Generated oxlint config must be in the lint root or an ancestor directory");
|
|
@@ -735,7 +735,7 @@ function renderNuxtOxlintConfig(items, pluginSpecifier, globBase) {
|
|
|
735
735
|
jsPlugins: [{
|
|
736
736
|
name: "vize",
|
|
737
737
|
specifier: pluginSpecifier
|
|
738
|
-
}],
|
|
738
|
+
}, ...projectJsPlugins.map((specifier) => rebaseJsPlugin(specifier, globBase?.configDir))],
|
|
739
739
|
settings: { vize: {
|
|
740
740
|
preset: "incremental",
|
|
741
741
|
...globBase?.owner ? { generatedBy: globBase.owner } : {}
|
|
@@ -747,6 +747,11 @@ function renderNuxtOxlintConfig(items, pluginSpecifier, globBase) {
|
|
|
747
747
|
if (overrides.length > 0) config.overrides = overrides;
|
|
748
748
|
return `${JSON.stringify(config, null, 2)}\n`;
|
|
749
749
|
}
|
|
750
|
+
function rebaseJsPlugin(specifier, configDir) {
|
|
751
|
+
if (!configDir || !path.isAbsolute(specifier)) return specifier;
|
|
752
|
+
const relative = path.relative(configDir, specifier).split(path.sep).join("/");
|
|
753
|
+
return relative.startsWith(".") ? relative : `./${relative}`;
|
|
754
|
+
}
|
|
750
755
|
function rebaseGlob(glob, base, ignore) {
|
|
751
756
|
const negated = glob.startsWith("!");
|
|
752
757
|
const body = negated ? glob.slice(1) : glob;
|
|
@@ -1171,11 +1176,13 @@ const CONFIG_PRESETS = [
|
|
|
1171
1176
|
"nuxt"
|
|
1172
1177
|
];
|
|
1173
1178
|
const RETIRED_CONFIG = /^vize\.config\.(?:pkl|[cm]?[jt]s|json)$/;
|
|
1179
|
+
const VIZE_JS_PLUGIN_SPECIFIER = "oxlint-plugin-vize";
|
|
1174
1180
|
const CONFIG_MIGRATION = "vize.config.* is no longer supported; move Vue settings to vue: in vite.config.* and TypeScript settings to tsconfig.json";
|
|
1175
1181
|
async function readProjectLintRuleSets(rootDir, loadPreset = loadPresetRules) {
|
|
1176
1182
|
const project = await readProjectConfig(rootDir);
|
|
1177
1183
|
const linter = project.linter;
|
|
1178
1184
|
const oxlint = explicitOxlintRules(project.oxlint);
|
|
1185
|
+
const jsPlugins = explicitOxlintJsPlugins(project.oxlint, project.oxlintConfigDir);
|
|
1179
1186
|
const warnings = [];
|
|
1180
1187
|
let vize;
|
|
1181
1188
|
if (linter) {
|
|
@@ -1197,20 +1204,23 @@ async function readProjectLintRuleSets(rootDir, loadPreset = loadPresetRules) {
|
|
|
1197
1204
|
}).filter((entry) => entry !== void 0);
|
|
1198
1205
|
return {
|
|
1199
1206
|
...entries.length > 0 ? { entries } : {},
|
|
1207
|
+
...jsPlugins.length > 0 ? { jsPlugins } : {},
|
|
1200
1208
|
...vize ? { vize } : {},
|
|
1201
1209
|
...Object.keys(oxlint).length > 0 ? { oxlint } : {},
|
|
1202
1210
|
...warnings.length > 0 ? { warnings } : {}
|
|
1203
1211
|
};
|
|
1204
1212
|
}
|
|
1205
1213
|
async function readProjectConfig(rootDir) {
|
|
1206
|
-
const
|
|
1207
|
-
if (!
|
|
1214
|
+
const loaded = await loadProjectViteConfigSource(rootDir);
|
|
1215
|
+
if (!loaded) return { entries: [] };
|
|
1216
|
+
const parsed = loaded.source;
|
|
1208
1217
|
const rawVue = parsed.vue && typeof parsed.vue === "object" ? parsed.vue : void 0;
|
|
1209
1218
|
const rawLinter = rawVue && "linter" in rawVue ? projectLinter(rawVue.linter) : void 0;
|
|
1210
1219
|
return {
|
|
1211
1220
|
entries: rawVue && "entries" in rawVue ? projectEntries(rawVue.entries) : [],
|
|
1212
1221
|
linter: rawLinter,
|
|
1213
|
-
oxlint: parsed.lint
|
|
1222
|
+
oxlint: parsed.lint,
|
|
1223
|
+
oxlintConfigDir: loaded.configDir
|
|
1214
1224
|
};
|
|
1215
1225
|
}
|
|
1216
1226
|
function projectLinter(value) {
|
|
@@ -1256,10 +1266,13 @@ async function loadProjectViteConfigSource(rootDir) {
|
|
|
1256
1266
|
if (!fs$1.existsSync(filePath)) continue;
|
|
1257
1267
|
const module = await importConfigModule(filePath);
|
|
1258
1268
|
if (module === null) throw new Error("Unable to load Vite configuration at " + filePath);
|
|
1259
|
-
return
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1269
|
+
return {
|
|
1270
|
+
configDir: directory,
|
|
1271
|
+
source: await resolveViteConfigSource(module.default ?? module, {
|
|
1272
|
+
command: "lint",
|
|
1273
|
+
mode: "development"
|
|
1274
|
+
})
|
|
1275
|
+
};
|
|
1263
1276
|
}
|
|
1264
1277
|
if (fs$1.existsSync(directory) && fs$1.readdirSync(directory).some((name) => RETIRED_CONFIG.test(name))) throw new Error(CONFIG_MIGRATION);
|
|
1265
1278
|
if ([
|
|
@@ -1280,6 +1293,21 @@ function explicitOxlintRules(value) {
|
|
|
1280
1293
|
for (const [id, severity] of Object.entries(rules)) if (isSeverity(severity)) result[id] = severity;
|
|
1281
1294
|
return result;
|
|
1282
1295
|
}
|
|
1296
|
+
function explicitOxlintJsPlugins(value, configDir) {
|
|
1297
|
+
if (!value || typeof value !== "object") return [];
|
|
1298
|
+
const jsPlugins = "jsPlugins" in value ? value.jsPlugins : void 0;
|
|
1299
|
+
if (!Array.isArray(jsPlugins)) return [];
|
|
1300
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1301
|
+
const result = [];
|
|
1302
|
+
for (const specifier of jsPlugins) {
|
|
1303
|
+
if (typeof specifier !== "string" || specifier.length === 0 || specifier === VIZE_JS_PLUGIN_SPECIFIER) continue;
|
|
1304
|
+
const resolved = configDir && (specifier.startsWith("./") || specifier.startsWith("../")) ? path$1.resolve(configDir, specifier) : specifier;
|
|
1305
|
+
if (seen.has(resolved)) continue;
|
|
1306
|
+
seen.add(resolved);
|
|
1307
|
+
result.push(resolved);
|
|
1308
|
+
}
|
|
1309
|
+
return result;
|
|
1310
|
+
}
|
|
1283
1311
|
async function loadPresetRules(preset, typeAware) {
|
|
1284
1312
|
const { createVizeRuleConfig } = await import("oxlint-plugin-vize");
|
|
1285
1313
|
const generated = createVizeRuleConfig({
|
|
@@ -1316,34 +1344,16 @@ function explicitRuleOptions(value) {
|
|
|
1316
1344
|
function applyRuleOptions(source, options, warnings, scope, fallback = {}) {
|
|
1317
1345
|
const rules = { ...source };
|
|
1318
1346
|
for (const [ruleId, option] of Object.entries(options)) {
|
|
1319
|
-
const arguments_ = bridgedRuleOptions(ruleId, option);
|
|
1320
|
-
if (!arguments_) {
|
|
1321
|
-
warnings.push(`${scope}.ruleOptions[${JSON.stringify(ruleId)}] is not supported by oxlint-vize`);
|
|
1322
|
-
continue;
|
|
1323
|
-
}
|
|
1324
1347
|
const configured = rules[ruleId] ?? fallback[ruleId];
|
|
1325
1348
|
const severity = Array.isArray(configured) ? configured[0] : configured;
|
|
1326
1349
|
if (!isSeverity(severity)) {
|
|
1327
1350
|
warnings.push(`${scope}.ruleOptions[${JSON.stringify(ruleId)}] has no enabled rule severity to attach to`);
|
|
1328
1351
|
continue;
|
|
1329
1352
|
}
|
|
1330
|
-
rules[ruleId] = [severity,
|
|
1353
|
+
rules[ruleId] = [severity, option];
|
|
1331
1354
|
}
|
|
1332
1355
|
return rules;
|
|
1333
1356
|
}
|
|
1334
|
-
function bridgedRuleOptions(ruleId, value) {
|
|
1335
|
-
if (ruleId === "vue/v-on-event-hyphenation" || ruleId === "vue/attribute-hyphenation") return value === "always" || value === "never" ? [value] : void 0;
|
|
1336
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
|
|
1337
|
-
const option = value;
|
|
1338
|
-
switch (ruleId) {
|
|
1339
|
-
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;
|
|
1340
|
-
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;
|
|
1341
|
-
case "vue/no-mutating-props":
|
|
1342
|
-
case "vue/sfc-element-order":
|
|
1343
|
-
case "vue/html-self-closing": return [value];
|
|
1344
|
-
default: return;
|
|
1345
|
-
}
|
|
1346
|
-
}
|
|
1347
1357
|
function isConfigPreset(value) {
|
|
1348
1358
|
return typeof value === "string" && CONFIG_PRESETS.includes(value);
|
|
1349
1359
|
}
|
|
@@ -1933,7 +1943,7 @@ async function setupNuxtLintConfigGeneration(lint, nuxt, dependencies = {}) {
|
|
|
1933
1943
|
rootDir: planRoot,
|
|
1934
1944
|
configDir: path.dirname(configFile),
|
|
1935
1945
|
owner: ownsReservedConfig ? "@vizejs/nuxt" : void 0
|
|
1936
|
-
});
|
|
1946
|
+
}, projectRules.jsPlugins);
|
|
1937
1947
|
const changed = ownsReservedConfig ? await writeOwnedNuxtConfig(configFile, artifact, writeFileIfChanged) : await writeFileIfChanged(configFile, artifact);
|
|
1938
1948
|
currentPlan = nextPlan;
|
|
1939
1949
|
return changed;
|
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-ONVFNHCT.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";
|
|
@@ -1053,6 +1053,50 @@ function patchNuxtKeyedFunctionsPlugin(plugin) {
|
|
|
1053
1053
|
};
|
|
1054
1054
|
}
|
|
1055
1055
|
//#endregion
|
|
1056
|
+
//#region src/vue-transform-bridge.ts
|
|
1057
|
+
const NUXT_VUE_TYPE_GATED_TRANSFORMS = new Set([
|
|
1058
|
+
"nuxt:route-injection-plugin",
|
|
1059
|
+
"nuxt:head:unhead-imports",
|
|
1060
|
+
"nuxt:components-loader",
|
|
1061
|
+
"nuxt:lazy-hydration-macro",
|
|
1062
|
+
"nuxt:imports-transform",
|
|
1063
|
+
"unctx:transform",
|
|
1064
|
+
"nuxt:tree-shake-composables:transform",
|
|
1065
|
+
"nuxt:vue-async-context",
|
|
1066
|
+
"nuxt:prehydrate-transform"
|
|
1067
|
+
]);
|
|
1068
|
+
/** Give Nuxt's `isVue(type)` gate a script identity while the plugin runs. */
|
|
1069
|
+
function toNuxtVueTransformId(id) {
|
|
1070
|
+
if (!isVizeGeneratedVueModuleId(id)) return id;
|
|
1071
|
+
const hasQuery = id.includes("?");
|
|
1072
|
+
const hasVueMarker = /[?&]vue(?:[=&]|$)/.test(id);
|
|
1073
|
+
return id + `${hasQuery ? "&" : "?"}${hasVueMarker ? "" : "vue&"}type=script`;
|
|
1074
|
+
}
|
|
1075
|
+
/**
|
|
1076
|
+
* Nuxt's core transforms classify Vue submodules by their `type=` query. Vize
|
|
1077
|
+
* owns a single generated JavaScript module for the complete SFC, so expose it
|
|
1078
|
+
* as the script submodule only for those transforms and retain its canonical
|
|
1079
|
+
* Vite identity everywhere else.
|
|
1080
|
+
*/
|
|
1081
|
+
function patchNuxtVueTypeGatedTransform(plugin) {
|
|
1082
|
+
if (!plugin || plugin.__vizeNuxtVueTransformPatched || !plugin.name || !NUXT_VUE_TYPE_GATED_TRANSFORMS.has(plugin.name)) return;
|
|
1083
|
+
if (typeof plugin.transform === "function") {
|
|
1084
|
+
const original = plugin.transform;
|
|
1085
|
+
plugin.transform = function(code, id, ...args) {
|
|
1086
|
+
return original.call(this, code, toNuxtVueTransformId(id), ...args);
|
|
1087
|
+
};
|
|
1088
|
+
plugin.__vizeNuxtVueTransformPatched = true;
|
|
1089
|
+
return;
|
|
1090
|
+
}
|
|
1091
|
+
const transform = plugin.transform;
|
|
1092
|
+
if (!transform || typeof transform.handler !== "function") return;
|
|
1093
|
+
const original = transform.handler;
|
|
1094
|
+
transform.handler = function(code, id, ...args) {
|
|
1095
|
+
return original.call(this, code, toNuxtVueTransformId(id), ...args);
|
|
1096
|
+
};
|
|
1097
|
+
plugin.__vizeNuxtVueTransformPatched = true;
|
|
1098
|
+
}
|
|
1099
|
+
//#endregion
|
|
1056
1100
|
//#region src/bridge-fast-path.ts
|
|
1057
1101
|
const VUE_CLIENT_RUNTIME_IMPORT = "vue/dist/vue.runtime.esm-bundler.js";
|
|
1058
1102
|
const COMPONENT_BRIDGE_RE = /(?:_?resolveComponent\s*\(|from\s+(["'])#components\1)/;
|
|
@@ -1501,6 +1545,7 @@ async function setupVizeNuxtModule(options, nuxt) {
|
|
|
1501
1545
|
if (name === "vite:vue") {
|
|
1502
1546
|
if (!patchNuxtHostVuePluginForCompilerExcludes(p, compilerOptions)) config.plugins.splice(i, 1);
|
|
1503
1547
|
} else if (bridgeOptions.stableInjectedKeys && name === "nuxt:compiler:keyed-functions") patchNuxtKeyedFunctionsPlugin(p);
|
|
1548
|
+
patchNuxtVueTypeGatedTransform(p);
|
|
1504
1549
|
if (isViteBuild && nuxt.options.experimental?.viteEnvironmentApi === true) patchNuxtClientManifestCloseBundlePlugin(p, nuxt);
|
|
1505
1550
|
if (bridgeOptions.autoImports) patchNuxtAutoImportTransformPlugin(p, isViteBuild);
|
|
1506
1551
|
}
|
package/dist/lint/index.d.mts
CHANGED
|
@@ -239,6 +239,6 @@ interface NuxtOxlintGlobBase {
|
|
|
239
239
|
owner?: "@vizejs/nuxt";
|
|
240
240
|
}
|
|
241
241
|
/** Render the complete generated oxlint config, including its trailing newline. */
|
|
242
|
-
declare function renderNuxtOxlintConfig(items: readonly NuxtLintConfigItem[], pluginSpecifier: string, globBase?: NuxtOxlintGlobBase): string;
|
|
242
|
+
declare function renderNuxtOxlintConfig(items: readonly NuxtLintConfigItem[], pluginSpecifier: string, globBase?: NuxtOxlintGlobBase, projectJsPlugins?: readonly string[]): string;
|
|
243
243
|
//#endregion
|
|
244
244
|
export { type NuxtLintAwaitable, type NuxtLintCheckerSetup, type NuxtLintCheckerSetupDependencies, type NuxtLintConfigAddon, type NuxtLintConfigAddonNuxt, type NuxtLintConfigGeneration, type NuxtLintGenerationDependencies, type NuxtLintImport, type NuxtLintSourceOptions, type NuxtLintStateOverrides, ROOT_OXLINT_CONFIG_NAMES, type ResolveNuxtLintConfigAddons, type ResolvedVizeNuxtLintCheckerOptions, VIZE_NUXT_LINT_CONFIG_ADDONS_HOOK, type VizeNuxtLintCheckerOptions, type VizeNuxtLintOptions, createNuxtLintCheckerVitePlugin, createNuxtLintCheckerWebpackPlugin, renderNuxtOxlintConfig, resolveNuxtLintCheckerOptions, setupNuxtLintChecker, setupNuxtLintConfigAddons, setupNuxtLintConfigGeneration, toNuxtLintProjectState, writeFileIfChanged };
|
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-ONVFNHCT.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.508.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.508.0",
|
|
53
|
+
"@vizejs/nuxt-lint-config": "0.508.0",
|
|
54
|
+
"@vizejs/vite-plugin": "0.508.0",
|
|
55
|
+
"@vizejs/vite-plugin-musea": "0.508.0",
|
|
56
|
+
"oxlint-plugin-vize": "0.508.0",
|
|
57
|
+
"vize": "0.508.0"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"jiti-nuxt2": "npm:jiti@1.21.7",
|