Repository navigation
Description
Summary
vp lint should let a project configure the type-aware backend it launches, tsrs-lint: pass it options or flags from vite.config.ts (and the vp lint command line), the same way the project already configures tsrs for its type check.
Motivation
Since 1.7, vp lint runs Oxlint's type-aware rules on the bundled tsrs-lint (it sets OXLINT_TSGOLINT_PATH itself). Oxlint launches the backend as <path> headless with no extra arguments, and neither the lint block nor vp lint has a way to add any. So nothing a project passes to tsrs as a flag can reach the lint run from the lint config:
- Content mappers (
--runExternalCode). A tsconfig declaringcontentMappers(e.g.vizefor.vue, or any Nuxt project's generated tsconfig that names one) makes every type-aware run fail.tsrs-lint headlessaccepts the flag itself (Usage: tsrs-lint headless [--fix] [--fix-suggestions] [--runExternalCode] [--debug timings]); only the wiring cannot ask for it. - Performance presets (
--fast/TSRS_FAST). A project that runstsrs --fastfor its type check wants its lint on the same checker settings by statement, not by whatever default the bundledtsrs-lintships (it turned the preset on in feat(lint): enable fast mode by default oxc-project/tsrs#989). - Anything else
tsrs-lintgrows — per-feature overrides, debug timings, memory tuning — has the same problem, and will keep having it while the only channel is the backend's own argv.
Today the only route is the environment variables tsrs-lint happens to read (TSRS_LINT_RUN_EXTERNAL_CODE, TSRS_FAST, …). They are undocumented in the lint guide, and to reach the editor's lint as well as the CLI they have to be assigned to process.env from inside the config file — a workaround, not a setting.
Proposal
A way to hand options to the type-aware backend from the lint config, forwarded by vp lint (and vp check, and the editor integration) as flags or environment. Either shape would cover it:
// typed, for the options vite-plus knows about
lint: {
options: {
typeAware: { runExternalCode: true, fast: true },
},
},// or an escape hatch passed through verbatim
lint: {
options: {
typeAware: true,
typeAwareArgs: ["--runExternalCode"],
typeAwareEnv: { TSRS_FAST: "1" },
},
},plus a matching CLI form (e.g. vp lint --type-aware-arg=--runExternalCode). Short of either, documenting the supported environment variables in the type-aware section of the lint guide would make the failure below discoverable from its error.
Reproduction (the content-mapper case)
package.json
{
"name": "repro-vp-mapper",
"private": true,
"type": "module",
"devDependencies": { "vite-plus": "1.7.0", "vize": "0.777.0", "vue": "3.5.45" }
}tsconfig.json
{
"compilerOptions": { "strict": true, "module": "esnext", "moduleResolution": "bundler", "target": "esnext", "noEmit": true },
"contentMappers": [{ "package": "vize", "extensions": [".vue"] }],
"include": ["src/**/*.ts", "src/**/*.vue"]
}vite.config.ts
import { defineConfig } from "vite-plus";
export default defineConfig({
lint: {
options: { typeAware: true },
rules: { "typescript/restrict-template-expressions": "error" },
},
});src/index.ts
const value = { a: 1 };
export const text = `${value}`;-
pnpm install -
pnpm exec vp lint src→ exit 1, no type-aware diagnostics:x typescript(tsconfig-error): Invalid tsconfig ,-[tsconfig.json:3:3] 3 | "contentMappers": [{ "package": "vize", "extensions": [".vue"] }], : ^^^^^^^^^^^^^^^^ help: Content mappers require the '--runExternalCode' command line flag to be enabled. -
TSRS_LINT_RUN_EXTERNAL_CODE=1 pnpm exec vp lint src→typescript(restrict-template-expressions)reported as expected. -
Removing the
contentMappersline also makes step 2 report the rule normally.
Reproduced three times out of three.
System info
- vite-plus 1.7.0 (bundled tsrs 7.1.0-beta.tsrs2, oxlint 1.94.0)
- vize 0.777.0
- Node v26.13.1, macOS (arm64)
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Effort
Target date
Start date
Activity
chore(deps): vite-plus 1.7 runs the type-aware lint on tsrs-lint, and…
[-]`vp lint` type-aware fails with `tsconfig-error` on a tsconfig with `contentMappers`: no way to pass `--runExternalCode` to `tsrs-lint`[/-][+]`vp lint` cannot configure the `tsrs-lint` type-aware backend: content-mapper projects fail with `tsconfig-error` (no `--runExternalCode`)[/+][-]`vp lint` cannot configure the `tsrs-lint` type-aware backend: content-mapper projects fail with `tsconfig-error` (no `--runExternalCode`)[/-][+]`vp lint`: allow configuring the type-aware backend (`tsrs-lint`) — pass options such as `--runExternalCode` and `--fast` from the lint config[/+]fengmk2 commentedon Nov 17, 2026
We need to refer to oxlint’s solution. @camc314
voidzero-bot commentedon Nov 17, 2026
packages/cli/binding/src/cli/resolver.rs(lint_tracks_backend_env_vars_for_caching)tsconfig.jsoncontentMappersbecause the bundledtsrs-lintbackend is invoked without--runExternalCode, but the equivalentTSRS_LINT_RUN_EXTERNAL_CODE=1environment variable already works around the failure.vp lintwires Oxlint to the bundledtsrs-lintbackend viaOXLINT_TSGOLINT_PATH, but it never documented or tracked theTSRS_LINT_RUN_EXTERNAL_CODEopt-in thattsrs-lintalso reads. As a result, any project that declares acontentMappersentry in itstsconfig.jsonhits atypescript(tsconfig-error): Invalid tsconfigbefore any source diagnostics are reported.I found a potential fix for this issue. The branch documents
TSRS_LINT_RUN_EXTERNAL_CODEindocs/guide/lint.mdand adds it to the task-cache environment fingerprints inpackages/cli/binding/src/cli/resolver.rsandpackages/cli/binding/src/cli/handler.rs, sovp run lintandvp run checkcorrectly invalidate cached results when the opt-in changes.Full Triage Report
Triage Report: #3476
Summary
vp lintwith type-aware rules enabled fails whentsconfig.jsoncontains acontentMappersentry. Oxlint launches the bundledtsrs-lintbackend in headless mode without--runExternalCode, so TSRS rejects the tsconfig as invalid. There is currently no documented/ configurable way inlint.optionsto pass--runExternalCodeto the backend.Expected vs Actual
typescript/restrict-template-expressionserror.typescript(tsconfig-error)ontsconfig.jsonbefore any source diagnostics are reported.Environment
Reproduction Path
Created a minimal project at
/tmp/vite-plus-triage/gh-3476/reprowith the files from the issue report.Trigger command
Trigger output
Control command (remove
contentMappers)Control output
Additional attempt
Setting
TSRS_LINT_RUN_EXTERNAL_CODE=1changed the tsconfig error location but did not fully recover type-aware linting with the availablevizeversion (column 35–41, the.vueextension incontentMappers). The original failure without the env var is consistent with the issue report.Result
Reproduced. The current checkout of vite-plus still launches
tsrs-lintwithout a way to forward--runExternalCode, causingtypescript(tsconfig-error)as soon ascontentMappersis present intsconfig.json.Diagnosis
Affected code path
packages/cli/src/resolve-lint.ts— resolves theoxlintbinary and the environment passed to it.packages/cli/binding/src/cli/resolver.rs— assembles thevp lintsubprocess and records which env vars affectvp runcaching.node_modules/oxlint/dist/index.d.ts—OxlintOptionsonly exposestypeAwareandtypeCheck; there is norunExternalCode(or equivalent) option recognised by oxlint itself.Incorrect logic
resolve-lint.tssets onlyOXLINT_TSGOLINT_PATH(pointing at the bundledtsrs-lint) andCONFIG_METADATA_ENVwhen launching oxlint:There is no code that:
lint.options.runExternalCode(or any other opt-in) fromvite.config.ts,TSRS_LINT_RUN_EXTERNAL_CODE=1for thetsrs-lintbackend, or--runExternalCodeto the backend.resolver.rsalso only tracksOXLINT_TSGOLINT_PATHas a cache input forvp run; a config-drivenTSRS_LINT_RUN_EXTERNAL_CODEwould need to be tracked too.Why it causes the observed failure
With
typeAware: trueoxlint executes the bundledtsrs-lintbackend. That backend rejects atsconfig.jsoncontainingcontentMappersunless it is started with--runExternalCode(or the equivalent environment variable), because loading mapper packages means executing external project code.Since vp never signals the backend to enable external code, the tsconfig is reported as invalid and lint stops before checking source files. The control run (removing
contentMappers) confirms type-aware rules would otherwise report the expected diagnostic.Evidence that env propagation works
Running with
TSRS_LINT_RUN_EXTERNAL_CODE=1changed the reported error location intsconfig.json(from thecontentMapperskey to the.vueextension inside it), proving the variable reaches the backend through vp -> oxlint -> tsrs-lint. With a compatible mapper package this is the reporter's workaround.Suggested fix approach
TSRS_LINT_RUN_EXTERNAL_CODE=1when it resolves the lint command. BecauseOxlintOptionsdoes not currently define arunExternalCodekey, augment the type (module augmentation or a new Vite+ option namespace) and read the value before spawning oxlint.vp lintinsidevp run, and includeTSRS_LINT_RUN_EXTERNAL_CODEin thecache_config.envlist.TSRS_LINT_RUN_EXTERNAL_CODEenvironment variable in the type-aware lint guide.Edge cases
runExternalCodeexecutes project-installed mapper packages, so it should remain opt-in and not default to on.tsrs-lint. The Gooxlint-tsgolintbackend may not honour the same env variable; vp always routes totsrs-linthere.vp run lintcache must be invalidated when the opt-in changes, otherwise results from a run that enabled mappers could be reused without them.Confidence
High. The failing path is limited to the env vars prepared in
resolve-lint.ts, and the observedtypescript(tsconfig-error)exactly matches the tsrs-lint help text from the issue.Verification
Claim
vp lint srcwithlint.options.typeAware: trueandtsconfig.jsoncontentMappersexits withtypescript(tsconfig-error): Invalid tsconfig.--runExternalCodeto thetsrs-lintbackend (e.g., alint.optionskey) or documentation of the existingTSRS_LINT_RUN_EXTERNAL_CODEenvironment variable.Research
docs/guide/lint.mddocuments type-aware linting as using the bundledtsrs-lintbackend, but does not mentioncontentMappers,--runExternalCode, orTSRS_LINT_RUN_EXTERNAL_CODE.rfcs/check-command.mddescribes theOXLINT_TSGOLINT_PATHoverride and thevp checkcache including that variable. It does not mention a way to pass backend arguments such as--runExternalCode.packages/cli/src/resolve-lint.tshas a// TODO: provide envs inference APIcomment, indicating the env forwarding is known to be incomplete.packages/cli/src/resolve-lint.tsshows the env map has stayed focused onOXLINT_TSGOLINT_PATHandCONFIG_METADATA_ENV; no commit added arunExternalCodeopt-in.voidzero-dev/vite-plusmentionsrunExternalCodeorcontentMappers.crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_oxlint_envonly verifiesOXLINT_TSGOLINT_PATHbehaviour.Verdict
bug
Vite+ explicitly replaces the type-aware backend with
tsrs-lintand documents type-aware linting as a supported feature. The inability to opt intotsrs-lint's--runExternalCodemode makes the integration fail for any project that uses tsconfigcontentMappers, which is a supportedtsrsfeature. There is no documentation or code signal that this was intentionally left unsupported; the TODO inresolve-lint.tsand the undocumented env-variable workaround both point to an unfinished integration.Confidence
high
Fix
Changed files
docs/guide/lint.md— documentedTSRS_LINT_RUN_EXTERNAL_CODEin the Type-Aware Linting/Content Mappers section.packages/cli/binding/src/cli/resolver.rs— addedTSRS_LINT_RUN_EXTERNAL_CODEto the environment variables tracked forvp lint(and the lint phase ofvp check) when computing task-cache fingerprints.packages/cli/binding/src/cli/handler.rs— addedTSRS_LINT_RUN_EXTERNAL_CODEto the tracked env list for the compositevp checkcommand in task scripts.Rationale
The reporter's first choice — a
lint.options.runExternalCodekey invite.config.ts— is not viable without an upstream Oxlint change. Oxlint loadsvite.config.tsto read thelintblock and validatesoptionsagainst its own schema; adding an unknown key producesunknown field \runExternalCode`` before linting starts.The existing
TSRS_LINT_RUN_EXTERNAL_CODEenvironment variable already reaches the bundledtsrs-lintbackend through Oxlint. The minimal Vite+ change is therefore:vp run lint/vp run checkcorrectly invalidates cached results when the opt-in changes.Trying
lint.options.runExternalCode(reverted)I implemented the config-key approach first, including type augmentation and config loading in
packages/cli/src/resolve-lint.ts. A test run withrunExternalCode: trueinvite.config.tsimmediately failed with:That confirmed the option must be introduced in Oxlint's schema before Vite+ can expose it in the
lintblock. I reverted all TypeScript/source changes and switched to the env-variable fix.Validation
pnpm -F vite-plus test --run resolve-lint.spec— passed (7 tests).cargo test -p vite-plus-cli cli::resolver:: --release— passed (3 tests).cargo clippy -p vite-plus-cli --release -- -D warnings— no warnings.cargo fmt --all --check— clean after formatting.pnpm exec vp lint srcstill reportstypescript(tsconfig-error)oncontentMappers(expected without the env var).TSRS_LINT_RUN_EXTERNAL_CODE=1 pnpm exec vp lint srcreaches the backend (error column moves from thecontentMapperskey to the.vueextension, as it did in the reproduce step).contentMappersreportstypescript(restrict-template-expressions)normally.Repro project after fix
vite.config.ts:Users now follow the docs and run:
Diff summary
Skipped checks
vp check/just check/ repository-wide snapshot suite were not run because the changed layer is the Rust CLI binding plus a documentation line; focused Rust tests, clippy, and fmt cover the code change, and the reproduction verifies end-to-end behavior.Commit message
fix(cli): track TSRS_LINT_RUN_EXTERNAL_CODE for type-aware lint caching and document it
This report was made by an LLM. The analysis may be wrong, and the potential fix might not work, but is intended as a starting point for exploring the issue.
I've opened a pull request with this fix: #3477