oxlint-plugin-vize 0.463.0 → 0.467.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-FRBXv1sV.mjs";
|
|
2
2
|
import { spawn, spawnSync } from "node:child_process";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import fs from "node:fs";
|
|
@@ -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-FRBXv1sV.mjs";
|
|
2
2
|
import { definePlugin, defineRule } from "@oxlint/plugins";
|
|
3
3
|
import fs from "node:fs";
|
|
4
4
|
//#region src/plugin-option-guards.ts
|
package/dist/eslint.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as getPatinaRules, c as isTypeAwareRuleName, d as getRuleOptions, i as formatPatinaMessage, l as createRuleSelection, n as createVizeRuleConfig, o as getActivePreset, r as plugin_default, s as getVizeSettings, t as configs } from "./configs-
|
|
2
|
-
import { d as isPatinaFile, m as loadBinding } from "./workaround-
|
|
1
|
+
import { a as getPatinaRules, c as isTypeAwareRuleName, d as getRuleOptions, i as formatPatinaMessage, l as createRuleSelection, n as createVizeRuleConfig, o as getActivePreset, r as plugin_default, s as getVizeSettings, t as configs } from "./configs-CcanGVPM.mjs";
|
|
2
|
+
import { d as isPatinaFile, m as loadBinding } from "./workaround-FRBXv1sV.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 { a as getPatinaRules, n as createVizeRuleConfig, r as plugin_default, t as configs, u as selectVizeRuleConfig } from "./configs-
|
|
1
|
+
import { a as getPatinaRules, n as createVizeRuleConfig, r as plugin_default, t as configs, u as selectVizeRuleConfig } from "./configs-CcanGVPM.mjs";
|
|
2
2
|
//#region src/vite-plus.ts
|
|
3
3
|
/**
|
|
4
4
|
* Bare specifier Oxlint uses to load this bridge as a JS plugin.
|
|
@@ -2,8 +2,8 @@ import { createRequire } from "node:module";
|
|
|
2
2
|
import { spawnSync } from "node:child_process";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import fs from "node:fs";
|
|
5
|
-
import { createHash } from "node:crypto";
|
|
6
5
|
import { isUtf8 } from "node:buffer";
|
|
6
|
+
import { createHash } from "node:crypto";
|
|
7
7
|
//#region src/native.ts
|
|
8
8
|
const require = createRequire(import.meta.url);
|
|
9
9
|
const FALLBACK_BINDING_PACKAGE = "@vizejs/native";
|
|
@@ -113,69 +113,112 @@ function isStandaloneHtmlFile(filename) {
|
|
|
113
113
|
//#endregion
|
|
114
114
|
//#region src/sfc-blocks.ts
|
|
115
115
|
function extractSfcBlocks(source) {
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
let
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
116
|
+
const binding = loadBinding();
|
|
117
|
+
if (typeof binding.parseSfc !== "function") throw new Error("Vize native binding does not expose the SFC parser.");
|
|
118
|
+
let descriptor;
|
|
119
|
+
try {
|
|
120
|
+
descriptor = binding.parseSfc(source);
|
|
121
|
+
} catch (error) {
|
|
122
|
+
if (error !== null && typeof error === "object" && "code" in error && error.code === "InvalidSfc") return [];
|
|
123
|
+
throw error;
|
|
124
|
+
}
|
|
125
|
+
return projectSfcBlocks(source, descriptor);
|
|
126
|
+
}
|
|
127
|
+
/** Project checked native geometry; never rediscover tags from the source text. */
|
|
128
|
+
function projectSfcBlocks(source, descriptor) {
|
|
129
|
+
if (descriptor.source !== source || !Array.isArray(descriptor.styles) || !Array.isArray(descriptor.customBlocks)) throw new Error("Vize SFC descriptor does not describe the complete original source.");
|
|
130
|
+
const parsed = [];
|
|
131
|
+
const add = (block, kind, name) => {
|
|
132
|
+
if (block !== null) parsed.push({
|
|
133
|
+
block,
|
|
134
|
+
kind,
|
|
135
|
+
name
|
|
135
136
|
});
|
|
136
|
-
|
|
137
|
+
};
|
|
138
|
+
add(descriptor.template, "template", "template");
|
|
139
|
+
if (descriptor.script !== null && descriptor.script.setup !== false) throw new Error("Vize SFC script descriptor has invalid setup ownership.");
|
|
140
|
+
if (descriptor.scriptSetup !== null && descriptor.scriptSetup.setup !== true) throw new Error("Vize SFC setup descriptor has invalid setup ownership.");
|
|
141
|
+
add(descriptor.script, "script", "script");
|
|
142
|
+
add(descriptor.scriptSetup, "script-setup", "script");
|
|
143
|
+
for (const block of descriptor.styles) add(block, "style", "style");
|
|
144
|
+
for (const block of descriptor.customBlocks) {
|
|
145
|
+
if (typeof block.type !== "string" || block.type.length === 0) throw new Error("Vize SFC custom descriptor has no block name.");
|
|
146
|
+
add(block, "custom", block.type);
|
|
137
147
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
148
|
+
const bytes = Buffer.from(source, "utf8");
|
|
149
|
+
if (bytes.toString("utf8") !== source) throw new Error("Vize SFC source cannot round-trip through UTF-8.");
|
|
150
|
+
for (const { block } of parsed) {
|
|
151
|
+
const loc = block.loc;
|
|
152
|
+
if (!loc || typeof block.content !== "string" || ![
|
|
153
|
+
loc.start,
|
|
154
|
+
loc.end,
|
|
155
|
+
loc.tagStart,
|
|
156
|
+
loc.tagEnd
|
|
157
|
+
].every((offset) => Number.isSafeInteger(offset) && offset >= 0 && offset <= bytes.length) || loc.tagStart > loc.start || loc.start > loc.end || loc.end > loc.tagEnd) throw new Error("Vize SFC descriptor has invalid byte geometry.");
|
|
158
|
+
}
|
|
159
|
+
parsed.sort((left, right) => left.block.loc.tagStart - right.block.loc.tagStart);
|
|
160
|
+
let previousEnd = 0;
|
|
161
|
+
for (const { block } of parsed) {
|
|
162
|
+
if (block.loc.tagStart < previousEnd) throw new Error("Vize SFC descriptor contains overlapping top-level blocks.");
|
|
163
|
+
previousEnd = block.loc.tagEnd;
|
|
164
|
+
}
|
|
165
|
+
const positions = projectPositions(bytes, parsed.flatMap(({ block }) => [
|
|
166
|
+
block.loc.tagStart,
|
|
167
|
+
block.loc.start,
|
|
168
|
+
block.loc.end,
|
|
169
|
+
block.loc.tagEnd
|
|
170
|
+
]));
|
|
171
|
+
return parsed.map(({ block, kind, name }) => {
|
|
172
|
+
const { loc, content } = block;
|
|
173
|
+
const start = positions.get(loc.start);
|
|
174
|
+
const end = positions.get(loc.end);
|
|
175
|
+
if (source.slice(start.index, end.index) !== content || loc.startLine !== start.line || loc.startColumn !== start.byteColumn || loc.endLine !== end.line || loc.endColumn !== end.byteColumn) throw new Error("Vize SFC descriptor content and geometry disagree with the original source.");
|
|
157
176
|
return {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
177
|
+
kind,
|
|
178
|
+
name,
|
|
179
|
+
content,
|
|
180
|
+
contentStart: {
|
|
181
|
+
line: start.line,
|
|
182
|
+
column: start.column
|
|
183
|
+
},
|
|
184
|
+
contentEnd: {
|
|
185
|
+
line: end.line,
|
|
186
|
+
column: end.column
|
|
187
|
+
}
|
|
161
188
|
};
|
|
162
|
-
}
|
|
189
|
+
});
|
|
163
190
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
191
|
+
/** Decode disjoint byte segments once. LF is the parser's line boundary; CR stays exact. */
|
|
192
|
+
function projectPositions(bytes, offsets) {
|
|
193
|
+
const positions = /* @__PURE__ */ new Map();
|
|
194
|
+
let previous = 0;
|
|
195
|
+
let index = 0;
|
|
196
|
+
let line = 1;
|
|
197
|
+
let column = 1;
|
|
198
|
+
let byteColumn = 1;
|
|
199
|
+
for (const offset of [...new Set(offsets)].sort((left, right) => left - right)) {
|
|
200
|
+
const segment = bytes.subarray(previous, offset);
|
|
201
|
+
if (!isUtf8(segment)) throw new Error("Vize SFC byte endpoint splits a UTF-8 scalar.");
|
|
202
|
+
const text = segment.toString("utf8");
|
|
203
|
+
index += text.length;
|
|
204
|
+
const newline = text.lastIndexOf("\n");
|
|
205
|
+
if (newline === -1) {
|
|
206
|
+
column += text.length;
|
|
207
|
+
byteColumn += segment.length;
|
|
208
|
+
} else {
|
|
209
|
+
for (const character of text) if (character === "\n") line += 1;
|
|
210
|
+
column = text.length - newline;
|
|
211
|
+
byteColumn = segment.length - segment.lastIndexOf(10);
|
|
175
212
|
}
|
|
176
|
-
|
|
213
|
+
positions.set(offset, {
|
|
214
|
+
index,
|
|
215
|
+
line,
|
|
216
|
+
column,
|
|
217
|
+
byteColumn
|
|
218
|
+
});
|
|
219
|
+
previous = offset;
|
|
177
220
|
}
|
|
178
|
-
return
|
|
221
|
+
return positions;
|
|
179
222
|
}
|
|
180
223
|
function getDiagnosticBlock(diagnostic, blocks) {
|
|
181
224
|
for (const block of blocks) if (compareLineColumn(diagnostic.location.start, block.contentStart) >= 0 && compareLineColumn(diagnostic.location.end, block.contentEnd) <= 0) return block;
|
|
@@ -195,43 +238,6 @@ function compareLineColumn(left, right) {
|
|
|
195
238
|
if (left.line !== right.line) return left.line - right.line;
|
|
196
239
|
return left.column - right.column;
|
|
197
240
|
}
|
|
198
|
-
function isAsciiLetter(code) {
|
|
199
|
-
return code >= 65 && code <= 90 || code >= 97 && code <= 122;
|
|
200
|
-
}
|
|
201
|
-
function isTagNameCharacter(code) {
|
|
202
|
-
return code >= 48 && code <= 57 || code >= 65 && code <= 90 || code === 45 || code === 95 || code >= 97 && code <= 122;
|
|
203
|
-
}
|
|
204
|
-
function isTagNameBoundary(code) {
|
|
205
|
-
return code === 9 || code === 10 || code === 12 || code === 13 || code === 32 || code === 47 || code === 62;
|
|
206
|
-
}
|
|
207
|
-
function createLineStartOffsets(source) {
|
|
208
|
-
const lineStarts = [0];
|
|
209
|
-
for (let index = 0; index < source.length; index += 1) if (source.charCodeAt(index) === 10) lineStarts.push(index + 1);
|
|
210
|
-
return lineStarts;
|
|
211
|
-
}
|
|
212
|
-
function offsetToLineColumn(lineStarts, offset) {
|
|
213
|
-
let low = 0;
|
|
214
|
-
let high = lineStarts.length - 1;
|
|
215
|
-
while (low <= high) {
|
|
216
|
-
const middle = low + high >> 1;
|
|
217
|
-
if (lineStarts[middle] <= offset) {
|
|
218
|
-
low = middle + 1;
|
|
219
|
-
continue;
|
|
220
|
-
}
|
|
221
|
-
high = middle - 1;
|
|
222
|
-
}
|
|
223
|
-
const lineIndex = Math.max(0, low - 1);
|
|
224
|
-
return {
|
|
225
|
-
line: lineIndex + 1,
|
|
226
|
-
column: offset - lineStarts[lineIndex] + 1
|
|
227
|
-
};
|
|
228
|
-
}
|
|
229
|
-
function resolveBlockKind(tagName, openTag) {
|
|
230
|
-
if (tagName === "template") return "template";
|
|
231
|
-
if (tagName === "script") return /\bsetup(?:\s|>|=)/u.test(openTag) ? "script-setup" : "script";
|
|
232
|
-
if (tagName === "style") return "style";
|
|
233
|
-
return "custom";
|
|
234
|
-
}
|
|
235
241
|
//#endregion
|
|
236
242
|
//#region src/workaround.ts
|
|
237
243
|
const SCRIPTLESS_WORKAROUND_MARKER = "oxlint-plugin-vize-scriptless";
|
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"devDependencies": {
|
|
13
13
|
"@tsdown/css": "0.22.14",
|
|
14
14
|
"@types/node": "25.9.2",
|
|
15
|
-
"@vizejs/native": "0.
|
|
15
|
+
"@vizejs/native": "0.467.0",
|
|
16
16
|
"tsdown": "0.22.14",
|
|
17
17
|
"typescript": "6.0.3",
|
|
18
18
|
"vite": "npm:@voidzero-dev/vite-plus-core@0.1.24",
|
|
@@ -53,14 +53,14 @@
|
|
|
53
53
|
},
|
|
54
54
|
"name": "oxlint-plugin-vize",
|
|
55
55
|
"optionalDependencies": {
|
|
56
|
-
"@vizejs/native-darwin-arm64": "0.
|
|
57
|
-
"@vizejs/native-darwin-x64": "0.
|
|
58
|
-
"@vizejs/native-linux-arm64-gnu": "0.
|
|
59
|
-
"@vizejs/native-linux-arm64-musl": "0.
|
|
60
|
-
"@vizejs/native-linux-x64-gnu": "0.
|
|
61
|
-
"@vizejs/native-linux-x64-musl": "0.
|
|
62
|
-
"@vizejs/native-win32-arm64-msvc": "0.
|
|
63
|
-
"@vizejs/native-win32-x64-msvc": "0.
|
|
56
|
+
"@vizejs/native-darwin-arm64": "0.467.0",
|
|
57
|
+
"@vizejs/native-darwin-x64": "0.467.0",
|
|
58
|
+
"@vizejs/native-linux-arm64-gnu": "0.467.0",
|
|
59
|
+
"@vizejs/native-linux-arm64-musl": "0.467.0",
|
|
60
|
+
"@vizejs/native-linux-x64-gnu": "0.467.0",
|
|
61
|
+
"@vizejs/native-linux-x64-musl": "0.467.0",
|
|
62
|
+
"@vizejs/native-win32-arm64-msvc": "0.467.0",
|
|
63
|
+
"@vizejs/native-win32-x64-msvc": "0.467.0"
|
|
64
64
|
},
|
|
65
65
|
"publishConfig": {
|
|
66
66
|
"access": "public"
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
},
|
|
73
73
|
"type": "module",
|
|
74
74
|
"types": "./dist/index.d.mts",
|
|
75
|
-
"version": "0.
|
|
75
|
+
"version": "0.467.0",
|
|
76
76
|
"scripts": {
|
|
77
77
|
"build": "vp pack",
|
|
78
78
|
"check": "vp check src vite.config.ts",
|