oxlint-plugin-vue-sfc 0.1.2 → 0.1.3
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/package.json +1 -1
- package/utils/vue-sfc.mjs +8 -2
package/package.json
CHANGED
package/utils/vue-sfc.mjs
CHANGED
|
@@ -60,8 +60,14 @@ export function scriptStartOffset(descriptor) {
|
|
|
60
60
|
* though the squiggle is stuck on the script block.
|
|
61
61
|
*/
|
|
62
62
|
export function reportAtFileOffset(context, entry, fileStart, fileEnd, message) {
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
// An EMPTY `<script setup></script>` makes @vue/compiler-sfc report `descriptor.scriptSetup`
|
|
64
|
+
// as null, so there is no block offset to be relative to. Reading that as a base of 0 would
|
|
65
|
+
// silently take the range path below with the file offset unadjusted, putting the diagnostic
|
|
66
|
+
// at an arbitrary position instead of prefixing the real one. Treat "no block" as
|
|
67
|
+
// unrepresentable and fall through to the prefixed form.
|
|
68
|
+
const block = entry.descriptor.scriptSetup ?? entry.descriptor.script;
|
|
69
|
+
const base = block ? block.loc.start.offset : null;
|
|
70
|
+
const start = base === null ? -1 : fileStart - base;
|
|
65
71
|
if (start >= 0) {
|
|
66
72
|
context.report({
|
|
67
73
|
node: { type: "TemplateDiagnostic", range: [start, fileEnd - base] },
|