Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/guide/lint.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ We recommend enabling both `typeAware` and `typeCheck` in the `lint` block:

Vite+ uses [tsrs](https://github.com/oxc-project/tsrs), a Rust port of the TypeScript 7 compiler. Its `tsrs-lint` executable gives Oxlint access to type information and allows type checking directly via `vp lint` and `vp check`.

### Content Mappers

Projects that use `tsconfig.json` `contentMappers` (for example `vize` for `.vue` files) must opt in to running external mapper packages. Set the environment variable that the bundled `tsrs-lint` backend reads before running `vp lint`:

```bash
TSRS_LINT_RUN_EXTERNAL_CODE=1 vp lint
```

## JS Plugins

If you are migrating from ESLint and still depend on a few critical JavaScript-based ESLint plugins, Oxlint has [JS plugin support](https://oxc.rs/docs/guide/usage/linter/js-plugins) that can help you keep those plugins running while you complete the migration.
Expand Down
5 changes: 4 additions & 1 deletion packages/cli/binding/src/cli/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@ impl CommandHandler for VitePlusCommandHandler {
// Check is a composite command (fmt + lint) — run as a subprocess in task scripts
Ok(HandledCommand::Synthesized(command.to_synthetic_plan_request(
UserCacheConfig::with_config(EnabledCacheConfig {
env: Some(Box::new([Str::from("OXLINT_TSGOLINT_PATH")])),
env: Some(Box::new([
Str::from("OXLINT_TSGOLINT_PATH"),
Str::from("TSRS_LINT_RUN_EXTERNAL_CODE"),
])),
untracked_env: None,
input: Some(check_cache_inputs()),
output: None,
Expand Down
29 changes: 28 additions & 1 deletion packages/cli/binding/src/cli/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@ impl SubcommandResolver {
.chain(args.into_iter().map(Str::from))
.collect(),
cache_config: UserCacheConfig::with_config(EnabledCacheConfig {
env: Some(Box::new([Str::from("OXLINT_TSGOLINT_PATH")])),
env: Some(Box::new([
Str::from("OXLINT_TSGOLINT_PATH"),
Str::from("TSRS_LINT_RUN_EXTERNAL_CODE"),
])),
untracked_env: None,
input: None,
output: None,
Expand Down Expand Up @@ -425,4 +428,28 @@ mod tests {
}
}
}

#[tokio::test]
async fn lint_tracks_backend_env_vars_for_caching() {
let temp = tempfile::tempdir().unwrap();
let root = AbsolutePathBuf::new(temp.path().to_path_buf()).unwrap();
let resolver = SubcommandResolver::new(root.clone().into())
.with_cli_options(cli_options(Arc::from(OsStr::new("node"))));
let envs = Arc::new(EnvMap::default());

let resolved = resolver
.resolve(SynthesizableSubcommand::Lint { args: vec![] }, &envs, &root)
.await
.unwrap();

let tracked_envs: Vec<String> = resolved
.cache_config
.into_enabled()
.and_then(|cfg| {
cfg.env.map(|envs| envs.iter().map(|env| env.as_str().to_string()).collect())
})
.unwrap_or_default();
assert!(tracked_envs.iter().any(|env| env == "OXLINT_TSGOLINT_PATH"));
assert!(tracked_envs.iter().any(|env| env == "TSRS_LINT_RUN_EXTERNAL_CODE"));
}
}
Loading