oxlint-plugin-vize 0.284.0 → 0.286.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 { a as isStandaloneHtmlFile, i as hasVueLikeExtension, n as hasScriptLikeBlock, t as appendScriptlessWorkaround } from "./workaround-BKap0lsB.mjs";
1
+ import { a as isStandaloneHtmlFile, i as hasVueLikeExtension, n as hasScriptLikeBlock, t as appendScriptlessWorkaround } from "./workaround-1vv4vvr7.mjs";
2
2
  import { spawn } from "node:child_process";
3
3
  import path from "node:path";
4
4
  import fs from "node:fs";
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { c as extractSfcBlocks, l as formatBlockLabel, o as isVueLikeFile, r as resolveWorkaroundSource, s as compareLineColumn, u as getDiagnosticBlock } from "./workaround-BKap0lsB.mjs";
1
+ import { c as extractSfcBlocks, l as formatBlockLabel, o as isVueLikeFile, r as resolveWorkaroundSource, s as compareLineColumn, u as getDiagnosticBlock } from "./workaround-1vv4vvr7.mjs";
2
2
  import { createRequire } from "node:module";
3
3
  import { definePlugin, defineRule } from "@oxlint/plugins";
4
4
  import { spawnSync } from "node:child_process";
@@ -86,8 +86,9 @@ function isStandaloneHtmlFile(filename) {
86
86
  }
87
87
  //#endregion
88
88
  //#region src/workaround.ts
89
- const SCRIPTLESS_WORKAROUND_OPEN_TAG_PREFIX = `<script setup lang="ts" data-oxlint-plugin-vize-scriptless="`;
90
- const SCRIPTLESS_WORKAROUND_CLOSE_TAG = "<\/script>";
89
+ const SCRIPTLESS_WORKAROUND_MARKER = "oxlint-plugin-vize-scriptless";
90
+ const SCRIPTLESS_WORKAROUND_OPEN_TAG_PREFIX = `<script setup lang="ts" data-${SCRIPTLESS_WORKAROUND_MARKER}="`;
91
+ const SCRIPTLESS_WORKAROUND_FILENAME_ATTR = `data-${SCRIPTLESS_WORKAROUND_MARKER}="`;
91
92
  function hasScriptLikeBlock(source) {
92
93
  return extractSfcBlocks(source).some((block) => block.kind === "script" || block.kind === "script-setup");
93
94
  }
@@ -95,33 +96,41 @@ function appendScriptlessWorkaround(source, filename) {
95
96
  return `${createWorkaroundScript(source, filename)}${source}`;
96
97
  }
97
98
  function resolveWorkaroundSource(source, fallbackFilename) {
98
- if (!source.startsWith(SCRIPTLESS_WORKAROUND_OPEN_TAG_PREFIX)) return {
99
+ const workaroundBlock = getPrependedWorkaroundBlock(source);
100
+ if (workaroundBlock == null) return {
99
101
  filename: fallbackFilename,
100
102
  source,
101
103
  usesOriginalLocations: false
102
104
  };
103
- const encodedFilenameStart = SCRIPTLESS_WORKAROUND_OPEN_TAG_PREFIX.length;
104
- const encodedFilenameEnd = source.indexOf(`">`, encodedFilenameStart);
105
- if (encodedFilenameEnd === -1) return {
106
- filename: fallbackFilename,
107
- source,
108
- usesOriginalLocations: false
109
- };
110
- const closeTagStart = source.indexOf(SCRIPTLESS_WORKAROUND_CLOSE_TAG, encodedFilenameEnd + 2);
111
- if (closeTagStart === -1) return {
112
- filename: fallbackFilename,
113
- source,
114
- usesOriginalLocations: false
115
- };
116
- let strippedSourceStart = closeTagStart + 9;
105
+ let strippedSourceStart = workaroundBlock.closeTagEnd;
117
106
  if (source.charCodeAt(strippedSourceStart) === 13) strippedSourceStart += 1;
118
107
  if (source.charCodeAt(strippedSourceStart) === 10) strippedSourceStart += 1;
119
108
  return {
120
- filename: decodeWorkaroundFilename(source.slice(encodedFilenameStart, encodedFilenameEnd)) ?? fallbackFilename,
109
+ filename: decodeWorkaroundFilename(workaroundBlock.encodedFilename) ?? fallbackFilename,
121
110
  source: source.slice(strippedSourceStart),
122
111
  usesOriginalLocations: true
123
112
  };
124
113
  }
114
+ function getPrependedWorkaroundBlock(source) {
115
+ const [firstBlock] = extractSfcBlocks(source);
116
+ if (!firstBlock || firstBlock.kind !== "script-setup") return null;
117
+ if (!isWhitespaceOnly(firstBlock.content)) return null;
118
+ const contentStart = offsetFromLineColumn(source, firstBlock.contentStart);
119
+ const contentEnd = offsetFromLineColumn(source, firstBlock.contentEnd);
120
+ const encodedFilename = encodedFilenameFromWorkaroundOpenTag(source.slice(0, contentStart));
121
+ if (encodedFilename == null) return null;
122
+ return {
123
+ closeTagEnd: contentEnd + 9,
124
+ encodedFilename
125
+ };
126
+ }
127
+ function encodedFilenameFromWorkaroundOpenTag(openTag) {
128
+ if (!openTag.startsWith(SCRIPTLESS_WORKAROUND_OPEN_TAG_PREFIX)) return null;
129
+ const encodedFilenameStart = openTag.indexOf(SCRIPTLESS_WORKAROUND_FILENAME_ATTR) + SCRIPTLESS_WORKAROUND_FILENAME_ATTR.length;
130
+ const encodedFilenameEnd = openTag.indexOf("\"", encodedFilenameStart);
131
+ if (encodedFilenameStart < SCRIPTLESS_WORKAROUND_FILENAME_ATTR.length || encodedFilenameEnd === -1) return null;
132
+ return openTag.slice(encodedFilenameStart, encodedFilenameEnd);
133
+ }
125
134
  function createWorkaroundScript(source, filename) {
126
135
  return `${SCRIPTLESS_WORKAROUND_OPEN_TAG_PREFIX}${encodeWorkaroundFilename(filename)}">${createWhitespaceMirror(source)}<\/script>\n`;
127
136
  }
@@ -138,6 +147,18 @@ function decodeWorkaroundFilename(encoded) {
138
147
  return null;
139
148
  }
140
149
  }
150
+ function isWhitespaceOnly(value) {
151
+ return /^\s*$/u.test(value);
152
+ }
153
+ function offsetFromLineColumn(source, loc) {
154
+ let line = 1;
155
+ let lineStart = 0;
156
+ for (let index = 0; index < source.length && line < loc.line; index += 1) if (source.charCodeAt(index) === 10) {
157
+ line += 1;
158
+ lineStart = index + 1;
159
+ }
160
+ return lineStart + loc.column - 1;
161
+ }
141
162
  if (import.meta.vitest) {
142
163
  const { describe, expect, it } = import.meta.vitest;
143
164
  describe("scriptless workaround helpers", () => {
@@ -156,6 +177,15 @@ if (import.meta.vitest) {
156
177
  usesOriginalLocations: true
157
178
  });
158
179
  });
180
+ it("does not strip real script setup blocks that mimic the marker", () => {
181
+ const fallbackFilename = "/Users/example/fallback.vue";
182
+ const source = `${SCRIPTLESS_WORKAROUND_OPEN_TAG_PREFIX}${encodeWorkaroundFilename("/Users/example/Real.vue")}">const userCode = true;<\/script>\n<template />`;
183
+ expect(resolveWorkaroundSource(source, fallbackFilename)).toEqual({
184
+ filename: fallbackFilename,
185
+ source,
186
+ usesOriginalLocations: false
187
+ });
188
+ });
159
189
  });
160
190
  }
161
191
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oxlint-plugin-vize",
3
- "version": "0.284.0",
3
+ "version": "0.286.0",
4
4
  "description": "Oxlint JS plugin bridge for Vize Patina",
5
5
  "keywords": [
6
6
  "lint",
@@ -44,21 +44,21 @@
44
44
  "devDependencies": {
45
45
  "@tsdown/css": "0.22.0",
46
46
  "@types/node": "25.9.2",
47
- "@vizejs/native": "0.284.0",
47
+ "@vizejs/native": "0.286.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.284.0",
55
- "@vizejs/native-darwin-x64": "0.284.0",
56
- "@vizejs/native-linux-arm64-gnu": "0.284.0",
57
- "@vizejs/native-linux-arm64-musl": "0.284.0",
58
- "@vizejs/native-linux-x64-gnu": "0.284.0",
59
- "@vizejs/native-linux-x64-musl": "0.284.0",
60
- "@vizejs/native-win32-arm64-msvc": "0.284.0",
61
- "@vizejs/native-win32-x64-msvc": "0.284.0"
54
+ "@vizejs/native-darwin-arm64": "0.286.0",
55
+ "@vizejs/native-darwin-x64": "0.286.0",
56
+ "@vizejs/native-linux-arm64-gnu": "0.286.0",
57
+ "@vizejs/native-linux-arm64-musl": "0.286.0",
58
+ "@vizejs/native-linux-x64-gnu": "0.286.0",
59
+ "@vizejs/native-linux-x64-musl": "0.286.0",
60
+ "@vizejs/native-win32-arm64-msvc": "0.286.0",
61
+ "@vizejs/native-win32-x64-msvc": "0.286.0"
62
62
  },
63
63
  "engines": {
64
64
  "node": "^22 || >= 24"