oxlint-plugin-vize 0.291.0 → 0.303.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/index.mjs +46 -10
- package/package.json +11 -11
package/dist/index.mjs
CHANGED
|
@@ -116,25 +116,61 @@ function createSingleScriptMap(source, extractedScript) {
|
|
|
116
116
|
const blocks = extractSfcBlocks(source).filter((block) => block.kind === "script" || block.kind === "script-setup");
|
|
117
117
|
if (blocks.length !== 1) return null;
|
|
118
118
|
const [block] = blocks;
|
|
119
|
-
|
|
119
|
+
const skipped = countSkippedPrefix(block.content, extractedScript);
|
|
120
|
+
if (skipped === null) return null;
|
|
121
|
+
return {
|
|
122
|
+
block,
|
|
123
|
+
scriptStart: advancePosition(block.contentStart, block.content.slice(0, skipped))
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Oxlint trims the leading newline (and any indentation on that line) from a
|
|
128
|
+
* `.vue` script block before handing the program to JS plugins, so the
|
|
129
|
+
* extracted text starts partway into `block.content`. Returns how many
|
|
130
|
+
* characters were dropped, or `null` when the extracted text is not this
|
|
131
|
+
* block's body.
|
|
132
|
+
*/
|
|
133
|
+
function countSkippedPrefix(content, extractedScript) {
|
|
134
|
+
const skipped = content.length - extractedScript.length;
|
|
135
|
+
if (skipped < 0 || !content.endsWith(extractedScript)) return null;
|
|
136
|
+
return /^\s*$/u.test(content.slice(0, skipped)) ? skipped : null;
|
|
137
|
+
}
|
|
138
|
+
function advancePosition(from, text) {
|
|
139
|
+
let { line, column } = from;
|
|
140
|
+
for (const character of text) {
|
|
141
|
+
if (character === "\n") {
|
|
142
|
+
line += 1;
|
|
143
|
+
column = 1;
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
if (character !== "\r") column += 1;
|
|
147
|
+
}
|
|
148
|
+
return {
|
|
149
|
+
line,
|
|
150
|
+
column
|
|
151
|
+
};
|
|
120
152
|
}
|
|
121
153
|
function mapToScriptLoc(diagnostic, scriptMap) {
|
|
122
154
|
if (!scriptMap) return null;
|
|
123
|
-
const { block } = scriptMap;
|
|
124
|
-
if (compareLineColumn(diagnostic.location.start,
|
|
155
|
+
const { block, scriptStart } = scriptMap;
|
|
156
|
+
if (compareLineColumn(diagnostic.location.start, scriptStart) < 0 || compareLineColumn(diagnostic.location.end, block.contentEnd) > 0) return null;
|
|
125
157
|
return {
|
|
126
|
-
start: toScriptPosition(diagnostic.location.start,
|
|
127
|
-
end: toScriptPosition(diagnostic.location.end,
|
|
158
|
+
start: toScriptPosition(diagnostic.location.start, scriptStart),
|
|
159
|
+
end: toScriptPosition(diagnostic.location.end, scriptStart)
|
|
128
160
|
};
|
|
129
161
|
}
|
|
130
|
-
|
|
131
|
-
|
|
162
|
+
/**
|
|
163
|
+
* Patina reports 1-based SFC line/column; Oxlint expects 1-based lines and
|
|
164
|
+
* 0-based columns relative to the extracted program.
|
|
165
|
+
*/
|
|
166
|
+
function toScriptPosition(position, scriptStart) {
|
|
167
|
+
if (position.line === scriptStart.line) return {
|
|
132
168
|
line: 1,
|
|
133
|
-
column: position.column -
|
|
169
|
+
column: position.column - scriptStart.column
|
|
134
170
|
};
|
|
135
171
|
return {
|
|
136
|
-
line: position.line -
|
|
137
|
-
column: position.column
|
|
172
|
+
line: position.line - scriptStart.line + 1,
|
|
173
|
+
column: position.column - 1
|
|
138
174
|
};
|
|
139
175
|
}
|
|
140
176
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oxlint-plugin-vize",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.303.0",
|
|
4
4
|
"description": "Oxlint JS plugin bridge for Vize Patina",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lint",
|
|
@@ -44,28 +44,28 @@
|
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@tsdown/css": "0.22.0",
|
|
46
46
|
"@types/node": "25.9.2",
|
|
47
|
-
"@vizejs/native": "0.
|
|
47
|
+
"@vizejs/native": "0.303.0",
|
|
48
48
|
"tsdown": "0.22.0",
|
|
49
49
|
"typescript": "6.0.3",
|
|
50
50
|
"vite": "npm:@voidzero-dev/vite-plus-core@0.1.21",
|
|
51
51
|
"vite-plus": "0.1.21"
|
|
52
52
|
},
|
|
53
53
|
"optionalDependencies": {
|
|
54
|
-
"@vizejs/native-darwin-arm64": "0.
|
|
55
|
-
"@vizejs/native-darwin-x64": "0.
|
|
56
|
-
"@vizejs/native-linux-arm64-gnu": "0.
|
|
57
|
-
"@vizejs/native-linux-arm64-musl": "0.
|
|
58
|
-
"@vizejs/native-linux-x64-gnu": "0.
|
|
59
|
-
"@vizejs/native-linux-x64-musl": "0.
|
|
60
|
-
"@vizejs/native-win32-arm64-msvc": "0.
|
|
61
|
-
"@vizejs/native-win32-x64-msvc": "0.
|
|
54
|
+
"@vizejs/native-darwin-arm64": "0.303.0",
|
|
55
|
+
"@vizejs/native-darwin-x64": "0.303.0",
|
|
56
|
+
"@vizejs/native-linux-arm64-gnu": "0.303.0",
|
|
57
|
+
"@vizejs/native-linux-arm64-musl": "0.303.0",
|
|
58
|
+
"@vizejs/native-linux-x64-gnu": "0.303.0",
|
|
59
|
+
"@vizejs/native-linux-x64-musl": "0.303.0",
|
|
60
|
+
"@vizejs/native-win32-arm64-msvc": "0.303.0",
|
|
61
|
+
"@vizejs/native-win32-x64-msvc": "0.303.0"
|
|
62
62
|
},
|
|
63
63
|
"engines": {
|
|
64
64
|
"node": "^22 || >= 24"
|
|
65
65
|
},
|
|
66
66
|
"scripts": {
|
|
67
67
|
"build": "vp pack",
|
|
68
|
-
"test": "vp pack && vp test run src/file-state.test.ts && node src/test.ts",
|
|
68
|
+
"test": "vp pack && vp test run src/file-state.test.ts && node src/test.ts && node src/script-location.test.ts",
|
|
69
69
|
"check": "vp check src vite.config.ts",
|
|
70
70
|
"check:fix": "vp check --fix src vite.config.ts",
|
|
71
71
|
"fmt": "vp fmt --write src vite.config.ts"
|