oxlint-vue-sfc-harness

Shared template-AST harness for oxlint JS-plugin rules that need to read Vue SFC templates.
6,795
Install
npm install oxlint-vue-sfc-harness
Latest Version:0.1.0
License:MIT
Last Updated:Sep 3, 2026
Links: GitHub  ·  npm
Maintainer: togetic

oxlint-vue-sfc-harness

Shared template-AST harness for oxlint JS-plugin rules that need to read Vue SFC templates. Extracted from oxlint-plugin-vue-sfc and oxlint-plugin-vue-sfc-a11y, which both consume it.

oxlint parses only the <script> block of an SFC, so a rule that needs the template has to self-parse the file with @vue/compiler-sfc. This packages that escape hatch: a cached parseSfc, a walkTemplate visitor, the NodeTypes constants, and reportAtFileOffset, which translates an absolute file offset into the script-relative range oxlint expects.

import { NODE_ELEMENT, parseSfc, reportAtFileOffset, walkTemplate } from "oxlint-vue-sfc-harness";

Positions

A template offset in a template-first SFC is negative relative to the script block, and oxlint rejects negative ranges. reportAtFileOffset handles that by clamping the range and prepending the true location to the message ([template 12:5] …), so the CLI and editor problem lists still point at the right place even though the squiggle lands on the script block. oxc#26001 removes the need for this.

An SFC whose <script setup> is empty has no block offset at all (@vue/compiler-sfc reports scriptSetup as null); that is treated as unrepresentable and takes the same prefixed path, rather than silently reporting at an unadjusted offset.

./test-helpers

createLinter(rule, prefix) writes a real temp .vue file and parses its script with oxc-parser, returning lintSource / lintTemplate / cleanup. Rules read the SFC off disk, so specs need a real file rather than a string.

License

MIT

Related Packages

vite-plugin-vue-meta-layouts

vite 的 vue-router 的元信息布局系统

314,627 65
oxlint-plugin-vue-sfc

Vue SFC template rules for oxlint, as a JS plugin. Ports of eslint-plugin-vue ru...

6,895 0
oxlint-plugin-vue-sfc-a11y

Vue SFC accessibility rules for oxlint, as a JS plugin. Ports of eslint-plugin-v...

6,833 0
oxlint-vue

Vue SFC linting and formatting on the oxc toolchain. Rules reach inside , no esl...

1,592 4
vue-parser

Get contents from tags in .vue files (using AST tree).

5,013,612 20

Version History

Version Released License
0.1.0 MIT