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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oxlint-plugin-vue-sfc",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "type": "module",
5
5
  "description": "Vue SFC template rules for oxlint, as a JS plugin. Ports of eslint-plugin-vue rules oxlint has no native equivalent for.",
6
6
  "license": "MIT",
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
- const base = scriptStartOffset(entry.descriptor);
64
- const start = fileStart - base;
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] },