oxlint-plugin-vize 0.754.0 → 0.756.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.
package/dist/cli.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { m as loadBinding, n as prepareWorkaroundSource, p as isStandaloneHtmlFile, s as extractSfcBlocks, u as hasVueLikeExtension } from "./workaround-
|
|
1
|
+
import { m as loadBinding, n as prepareWorkaroundSource, p as isStandaloneHtmlFile, s as extractSfcBlocks, u as hasVueLikeExtension } from "./workaround-BYmipPq3.mjs";
|
|
2
2
|
import fs from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { spawn, spawnSync } from "node:child_process";
|
|
@@ -397,38 +397,43 @@ function prepareScriptlessWorkaroundFiles(cwd, filenames) {
|
|
|
397
397
|
const pathReplacements = /* @__PURE__ */ new Map();
|
|
398
398
|
const locations = /* @__PURE__ */ new Map();
|
|
399
399
|
let counter = 0;
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
400
|
+
const cleanup = () => {
|
|
401
|
+
if (tempDir == null) return;
|
|
402
|
+
fs.rmSync(tempDir, {
|
|
403
|
+
force: true,
|
|
404
|
+
recursive: true
|
|
405
|
+
});
|
|
406
|
+
removeEmptyDirectory(tempRoot);
|
|
407
|
+
removeEmptyDirectory(path.dirname(tempRoot));
|
|
408
|
+
if (createdNodeModules) removeEmptyDirectory(nodeModulesDir);
|
|
409
|
+
};
|
|
410
|
+
try {
|
|
411
|
+
for (const filename of filenames) {
|
|
412
|
+
const source = fs.readFileSync(filename, "utf8");
|
|
413
|
+
const isStandaloneHtml = isStandaloneHtmlFile(filename);
|
|
414
|
+
const relativeFilename = path.relative(cwd, filename);
|
|
415
|
+
if (tempDir == null) {
|
|
416
|
+
const created = createWorkaroundTempDir(nodeModulesDir, tempRoot);
|
|
417
|
+
tempDir = created.tempDir;
|
|
418
|
+
createdNodeModules = created.createdNodeModules;
|
|
419
|
+
}
|
|
420
|
+
const tempBasename = isStandaloneHtml ? `${path.basename(filename)}.vue` : path.basename(filename);
|
|
421
|
+
const tempFilename = path.join(tempDir, `${counter}-${tempBasename}`);
|
|
422
|
+
counter += 1;
|
|
423
|
+
const bridge = prepareWorkaroundSource(source, filename);
|
|
424
|
+
fs.writeFileSync(tempFilename, bridge.source);
|
|
425
|
+
ignoreArgs.push("--ignore-pattern", toCliPath$1(relativeFilename));
|
|
426
|
+
tempArgs.push(tempFilename);
|
|
427
|
+
registerPathReplacementVariants(pathReplacements, cwd, tempFilename, filename);
|
|
428
|
+
registerLocationVariants(locations, cwd, tempFilename, bridge.locations);
|
|
408
429
|
}
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
fs.mkdirSync(path.dirname(tempFilename), { recursive: true });
|
|
413
|
-
const bridge = prepareWorkaroundSource(source, filename);
|
|
414
|
-
fs.writeFileSync(tempFilename, bridge.source);
|
|
415
|
-
ignoreArgs.push("--ignore-pattern", toCliPath$1(relativeFilename));
|
|
416
|
-
tempArgs.push(tempFilename);
|
|
417
|
-
registerPathReplacementVariants(pathReplacements, cwd, tempFilename, filename);
|
|
418
|
-
registerLocationVariants(locations, cwd, tempFilename, bridge.locations);
|
|
430
|
+
} catch (error) {
|
|
431
|
+
cleanup();
|
|
432
|
+
throw error;
|
|
419
433
|
}
|
|
420
434
|
return {
|
|
421
435
|
appendedArgs: [...ignoreArgs, ...tempArgs],
|
|
422
|
-
cleanup
|
|
423
|
-
if (tempDir == null) return;
|
|
424
|
-
fs.rmSync(tempDir, {
|
|
425
|
-
force: true,
|
|
426
|
-
recursive: true
|
|
427
|
-
});
|
|
428
|
-
removeEmptyDirectory(tempRoot);
|
|
429
|
-
removeEmptyDirectory(path.dirname(tempRoot));
|
|
430
|
-
if (createdNodeModules) removeEmptyDirectory(nodeModulesDir);
|
|
431
|
-
},
|
|
436
|
+
cleanup,
|
|
432
437
|
pathReplacements,
|
|
433
438
|
locations,
|
|
434
439
|
usedScriptlessWorkaround: pathReplacements.size > 0
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as validateWorkaroundAuthority, c as formatBlockLabel, d as isPatinaFile, f as isScriptLikeFile, i as resolveWorkaroundSource, l as getDiagnosticBlock, m as loadBinding, o as compareLineColumn, r as readOriginalWorkaroundSource, s as extractSfcBlocks, t as isLocationBridgeProgram } from "./workaround-
|
|
1
|
+
import { a as validateWorkaroundAuthority, c as formatBlockLabel, d as isPatinaFile, f as isScriptLikeFile, i as resolveWorkaroundSource, l as getDiagnosticBlock, m as loadBinding, o as compareLineColumn, r as readOriginalWorkaroundSource, s as extractSfcBlocks, t as isLocationBridgeProgram } from "./workaround-BYmipPq3.mjs";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import { definePlugin, defineRule } from "@oxlint/plugins";
|
|
4
4
|
import fs from "node:fs";
|
package/dist/eslint.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as getPatinaRules, d as isTypeAwareRuleName, f as createRuleSelection, i as formatPatinaMessage, l as getActivePreset, m as getRuleOptions, n as createVizeRuleConfig, o as diagnosticsForRule, r as plugin_default, s as indexDiagnosticsByRule, t as configs, u as getVizeSettings } from "./configs-
|
|
2
|
-
import { d as isPatinaFile, m as loadBinding } from "./workaround-
|
|
1
|
+
import { c as getPatinaRules, d as isTypeAwareRuleName, f as createRuleSelection, i as formatPatinaMessage, l as getActivePreset, m as getRuleOptions, n as createVizeRuleConfig, o as diagnosticsForRule, r as plugin_default, s as indexDiagnosticsByRule, t as configs, u as getVizeSettings } from "./configs-CCzoZxe_.mjs";
|
|
2
|
+
import { d as isPatinaFile, m as loadBinding } from "./workaround-BYmipPq3.mjs";
|
|
3
3
|
import { definePlugin, defineRule, eslintCompatPlugin } from "@oxlint/plugins";
|
|
4
4
|
//#region src/eslint-source.ts
|
|
5
5
|
/** Native UTF-8 text cannot preserve an unpaired UTF-16 surrogate. */
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as getPatinaRules, n as createVizeRuleConfig, p as selectVizeRuleConfig, r as plugin_default, t as configs } from "./configs-
|
|
1
|
+
import { c as getPatinaRules, n as createVizeRuleConfig, p as selectVizeRuleConfig, r as plugin_default, t as configs } from "./configs-CCzoZxe_.mjs";
|
|
2
2
|
//#region src/vite-plus.ts
|
|
3
3
|
/**
|
|
4
4
|
* Bare specifier Oxlint uses to load this bridge as a JS plugin.
|
|
@@ -245,6 +245,7 @@ const SCRIPTLESS_WORKAROUND_OPEN_TAG_PREFIX = `<script setup lang="ts" data-${SC
|
|
|
245
245
|
const SCRIPTLESS_WORKAROUND_FILENAME_ATTR = `data-${SCRIPTLESS_WORKAROUND_MARKER}="`;
|
|
246
246
|
const LOCATION_BRIDGE_MARKER = "/*vize-location-bridge*/";
|
|
247
247
|
const ORIGINAL_PAYLOAD_PREFIX = "<!--vize-original-source:";
|
|
248
|
+
const ORIGINAL_REFERENCE_PREFIX = "<!--vize-original-file:";
|
|
248
249
|
/** Validate the original bytes before decoding reuse can enter native linting. */
|
|
249
250
|
function readOriginalWorkaroundSource(filename) {
|
|
250
251
|
const bytes = fs.readFileSync(filename);
|
|
@@ -260,12 +261,12 @@ function hasScriptLikeBlock(source) {
|
|
|
260
261
|
function appendScriptlessWorkaround(source, filename) {
|
|
261
262
|
return prepareWorkaroundSource(source, filename).source;
|
|
262
263
|
}
|
|
263
|
-
/** Keep original coordinates in one safe host script and
|
|
264
|
+
/** Keep original coordinates in one safe host script and a bound reference to the source file. */
|
|
264
265
|
function prepareWorkaroundSource(source, filename) {
|
|
265
266
|
const openTag = `${SCRIPTLESS_WORKAROUND_OPEN_TAG_PREFIX}${encodeWorkaroundFilename(filename)}">`;
|
|
266
267
|
const script = `${openTag}${createWhitespaceMirror(source)}${LOCATION_BRIDGE_MARKER}<\/script>\n`;
|
|
267
268
|
return {
|
|
268
|
-
source: `${script}${
|
|
269
|
+
source: `${script}${ORIGINAL_REFERENCE_PREFIX}${valueDigest(filename)}:${valueDigest(source)}-->`,
|
|
269
270
|
locations: {
|
|
270
271
|
source,
|
|
271
272
|
scriptStart: openTag.length,
|
|
@@ -287,8 +288,13 @@ function resolveWorkaroundSource(source, fallbackFilename, readOriginalSource) {
|
|
|
287
288
|
if (source.charCodeAt(strippedSourceStart) === 13) strippedSourceStart += 1;
|
|
288
289
|
if (source.charCodeAt(strippedSourceStart) === 10) strippedSourceStart += 1;
|
|
289
290
|
const decodedFilename = decodeWorkaroundFilename(workaroundBlock.encodedFilename) ?? fallbackFilename;
|
|
290
|
-
|
|
291
|
-
if (
|
|
291
|
+
let strippedSource;
|
|
292
|
+
if (workaroundBlock.referencesOriginal) {
|
|
293
|
+
if (readOriginalSource == null) throw new Error("Vize original-file carrier requires an original source reader.");
|
|
294
|
+
strippedSource = readOriginalSource(decodedFilename);
|
|
295
|
+
if (valueDigest(strippedSource) !== workaroundBlock.referenceSourceDigest || workaroundBlock.mirror !== createWhitespaceMirror(strippedSource) + LOCATION_BRIDGE_MARKER) throw new Error("Vize carrier source no longer matches the original file bytes.");
|
|
296
|
+
} else strippedSource = workaroundBlock.originalSource ?? source.slice(strippedSourceStart);
|
|
297
|
+
if (!workaroundBlock.referencesOriginal && readOriginalSource && readOriginalSource(decodedFilename) !== strippedSource) throw new Error("Vize carrier source no longer matches the original file bytes.");
|
|
292
298
|
return {
|
|
293
299
|
filename: decodedFilename,
|
|
294
300
|
source: strippedSource,
|
|
@@ -309,18 +315,31 @@ function getPrependedWorkaroundBlock(source) {
|
|
|
309
315
|
if (strippedSourceStart == null) return null;
|
|
310
316
|
const tail = source.slice(strippedSourceStart);
|
|
311
317
|
let originalSource;
|
|
318
|
+
let referenceSourceDigest;
|
|
319
|
+
let referencesOriginal = false;
|
|
312
320
|
if (tail.startsWith(ORIGINAL_PAYLOAD_PREFIX)) {
|
|
313
321
|
const payload = /^<!--vize-original-source:([a-f0-9]{64}):([A-Za-z0-9_-]*)-->$/u.exec(tail);
|
|
314
322
|
if (payload == null) throw new Error("Invalid Vize original-source carrier payload.");
|
|
315
323
|
const originalFilename = decodeWorkaroundFilename(encodedFilename);
|
|
316
324
|
if (originalFilename == null || encodeWorkaroundFilename(originalFilename) !== encodedFilename) throw new Error("Invalid Vize original-source carrier filename.");
|
|
317
325
|
originalSource = Buffer.from(payload[2], "base64url").toString("utf8");
|
|
318
|
-
if (Buffer.from(originalSource, "utf8").toString("base64url") !== payload[2] ||
|
|
326
|
+
if (Buffer.from(originalSource, "utf8").toString("base64url") !== payload[2] || carrierDigest(originalFilename, originalSource) !== payload[1] || firstBlock.content !== createWhitespaceMirror(originalSource) + LOCATION_BRIDGE_MARKER) throw new Error("Vize original-source carrier bytes do not match their complete source mirror.");
|
|
327
|
+
} else if (tail.startsWith(ORIGINAL_REFERENCE_PREFIX)) {
|
|
328
|
+
const reference = /^<!--vize-original-file:([a-f0-9]{64}):([a-f0-9]{64})-->$/u.exec(tail);
|
|
329
|
+
if (reference == null) throw new Error("Invalid Vize original-file carrier reference.");
|
|
330
|
+
const originalFilename = decodeWorkaroundFilename(encodedFilename);
|
|
331
|
+
if (originalFilename == null || encodeWorkaroundFilename(originalFilename) !== encodedFilename) throw new Error("Invalid Vize original-file carrier filename.");
|
|
332
|
+
if (valueDigest(originalFilename) !== reference[1]) throw new Error("Invalid Vize original-file carrier filename digest.");
|
|
333
|
+
referenceSourceDigest = reference[2];
|
|
334
|
+
referencesOriginal = true;
|
|
319
335
|
} else if (firstBlock.content !== createWhitespaceMirror(tail) + LOCATION_BRIDGE_MARKER) return null;
|
|
320
336
|
return {
|
|
321
337
|
closeTagEnd,
|
|
322
338
|
encodedFilename,
|
|
323
|
-
|
|
339
|
+
mirror: firstBlock.content,
|
|
340
|
+
originalSource,
|
|
341
|
+
referenceSourceDigest,
|
|
342
|
+
referencesOriginal
|
|
324
343
|
};
|
|
325
344
|
}
|
|
326
345
|
function sourceStartAfterSyntheticBlock(source, closeTagEnd) {
|
|
@@ -336,7 +355,13 @@ function encodedFilenameFromWorkaroundOpenTag(openTag) {
|
|
|
336
355
|
return openTag.slice(encodedFilenameStart, encodedFilenameEnd);
|
|
337
356
|
}
|
|
338
357
|
function createWhitespaceMirror(source) {
|
|
339
|
-
return source.replaceAll(/[^\r\n]
|
|
358
|
+
return source.replaceAll(/[^\r\n]+/g, (run) => " ".repeat(run.length));
|
|
359
|
+
}
|
|
360
|
+
function carrierDigest(filename, source) {
|
|
361
|
+
return createHash("sha256").update(filename).update("\0").update(source).digest("hex");
|
|
362
|
+
}
|
|
363
|
+
function valueDigest(value) {
|
|
364
|
+
return createHash("sha256").update(value).digest("hex");
|
|
340
365
|
}
|
|
341
366
|
function encodeWorkaroundFilename(filename) {
|
|
342
367
|
return Buffer.from(filename, "utf8").toString("base64url");
|
|
@@ -372,7 +397,7 @@ if (import.meta.vitest) {
|
|
|
372
397
|
const filename = "/Users/example/Hello.vue";
|
|
373
398
|
const appended = appendScriptlessWorkaround(source, filename);
|
|
374
399
|
expect(appended).toMatch(/oxlint-plugin-vize-scriptless/u);
|
|
375
|
-
expect(resolveWorkaroundSource(appended, "/Users/example/fallback.vue")).toEqual({
|
|
400
|
+
expect(resolveWorkaroundSource(appended, "/Users/example/fallback.vue", () => source)).toEqual({
|
|
376
401
|
filename,
|
|
377
402
|
source,
|
|
378
403
|
usesOriginalLocations: true
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oxlint-plugin-vize",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.756.0",
|
|
4
4
|
"description": "Oxlint JS plugin bridge for Vize Patina",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lint",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@tsdown/css": "0.22.14",
|
|
52
52
|
"@types/node": "25.9.2",
|
|
53
53
|
"@typescript-eslint/parser": "8.72.1",
|
|
54
|
-
"@vizejs/native": "0.
|
|
54
|
+
"@vizejs/native": "0.756.0",
|
|
55
55
|
"ajv": "8.20.0",
|
|
56
56
|
"eslint": "10.14.0",
|
|
57
57
|
"eslint-plugin-vue": "10.12.0",
|
|
@@ -63,14 +63,14 @@
|
|
|
63
63
|
"vue-eslint-parser": "10.4.2"
|
|
64
64
|
},
|
|
65
65
|
"optionalDependencies": {
|
|
66
|
-
"@vizejs/native-darwin-arm64": "0.
|
|
67
|
-
"@vizejs/native-darwin-x64": "0.
|
|
68
|
-
"@vizejs/native-linux-arm64-gnu": "0.
|
|
69
|
-
"@vizejs/native-linux-arm64-musl": "0.
|
|
70
|
-
"@vizejs/native-linux-x64-gnu": "0.
|
|
71
|
-
"@vizejs/native-linux-x64-musl": "0.
|
|
72
|
-
"@vizejs/native-win32-arm64-msvc": "0.
|
|
73
|
-
"@vizejs/native-win32-x64-msvc": "0.
|
|
66
|
+
"@vizejs/native-darwin-arm64": "0.756.0",
|
|
67
|
+
"@vizejs/native-darwin-x64": "0.756.0",
|
|
68
|
+
"@vizejs/native-linux-arm64-gnu": "0.756.0",
|
|
69
|
+
"@vizejs/native-linux-arm64-musl": "0.756.0",
|
|
70
|
+
"@vizejs/native-linux-x64-gnu": "0.756.0",
|
|
71
|
+
"@vizejs/native-linux-x64-musl": "0.756.0",
|
|
72
|
+
"@vizejs/native-win32-arm64-msvc": "0.756.0",
|
|
73
|
+
"@vizejs/native-win32-x64-msvc": "0.756.0"
|
|
74
74
|
},
|
|
75
75
|
"engines": {
|
|
76
76
|
"node": "^22 || >= 24"
|