Skip to content

Commit dece36f

Browse files
committed
fix: set OXLINT_TSGOLINT_PATH env
1 parent af28a6d commit dece36f

7 files changed

Lines changed: 82 additions & 2 deletions

File tree

crates/vite_error/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ pub enum Error {
9595
#[error(transparent)]
9696
SerdeYmlError(#[from] serde_yml::Error),
9797

98-
#[error("Lint failed")]
98+
#[error("Lint failed, reason: {reason}")]
9999
LintFailed { status: Str, reason: Str },
100100

101101
#[error("Fmt failed")]

crates/vite_task/src/execute.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,8 @@ const DEFAULT_PASSTHROUGH_ENVS: &[&str] = &[
208208
"COMPOSE_*",
209209
// Token patterns
210210
"*_TOKEN",
211+
// oxc specific
212+
"OXLINT_*",
211213
];
212214

213215
const SENSITIVE_PATTERNS: &[&str] = &[
@@ -605,6 +607,7 @@ mod tests {
605607
std::env::set_var("APP1_NAME", "app1_value");
606608
std::env::set_var("APP2_NAME", "app2_value");
607609
std::env::set_var("APP1_PASSWORD", "app1_password");
610+
std::env::set_var("OXLINT_TSGOLINT_PATH", "/path/to/oxlint_tsgolint");
608611
}
609612

610613
// Resolve envs multiple times
@@ -654,6 +657,7 @@ mod tests {
654657
assert!(all_envs.contains_key("APP1_PASSWORD"));
655658
assert!(all_envs.contains_key("APP1_TOKEN"));
656659
assert!(all_envs.contains_key("APP2_TOKEN"));
660+
assert!(all_envs.contains_key("OXLINT_TSGOLINT_PATH"));
657661

658662
// VITE_TASK_EXECUTION_ENV should always be added automatically
659663
assert!(all_envs.contains_key("VITE_TASK_EXECUTION_ENV"));
@@ -674,6 +678,7 @@ mod tests {
674678
std::env::remove_var("APP1_PASSWORD");
675679
std::env::remove_var("APP1_TOKEN");
676680
std::env::remove_var("APP2_TOKEN");
681+
std::env::remove_var("OXLINT_TSGOLINT_PATH");
677682
}
678683
}
679684

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log('OXLINT_TSGOLINT_PATH=%s', process.env.OXLINT_TSGOLINT_PATH);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "check-oxlint-env",
3+
"version": "0.0.0",
4+
"private": true,
5+
"scripts": {
6+
"check": "node check.js",
7+
"check-nested": "vite run check"
8+
}
9+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
> OXLINT_TSGOLINT_PATH=/path/to/oxlint_tsgolint1 vite run check # get OXLINT_TSGOLINT_PATH env
2+
$ node check.js
3+
OXLINT_TSGOLINT_PATH=/path/to/oxlint_tsgolint1
4+
5+
6+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
7+
Vite+ Task Runner • Execution Summary
8+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
9+
10+
Statistics: 1 tasks • 0 cache hits • 1 cache misses
11+
Performance: 0% cache hit rate
12+
13+
Task Details:
14+
────────────────────────────────────────────────
15+
[1] check-oxlint-env#check ✓
16+
→ Cache miss: no previous cache entry found
17+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
18+
19+
> rm -rf node_modules # clean cache
20+
> OXLINT_TSGOLINT_PATH=/path/to/oxlint_tsgolint2 vite run check-nested # get OXLINT_TSGOLINT_PATH env in nested task
21+
$ vite run check
22+
$ node check.js
23+
OXLINT_TSGOLINT_PATH=/path/to/oxlint_tsgolint2
24+
25+
26+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
27+
Vite+ Task Runner • Execution Summary
28+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
29+
30+
Statistics: 1 tasks • 0 cache hits • 1 cache misses
31+
Performance: 0% cache hit rate
32+
33+
Task Details:
34+
────────────────────────────────────────────────
35+
[1] check-oxlint-env#check ✓
36+
→ Cache miss: no previous cache entry found
37+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
38+
39+
40+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
41+
Vite+ Task Runner • Execution Summary
42+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
43+
44+
Statistics: 1 tasks • 0 cache hits • 1 cache misses
45+
Performance: 0% cache hit rate
46+
47+
Task Details:
48+
────────────────────────────────────────────────
49+
[1] check-oxlint-env#check-nested ✓
50+
→ Cache miss: no previous cache entry found
51+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"env": {
3+
"VITE_DISABLE_AUTO_INSTALL": "1"
4+
},
5+
"commands": [
6+
"OXLINT_TSGOLINT_PATH=/path/to/oxlint_tsgolint1 vite run check # get OXLINT_TSGOLINT_PATH env",
7+
"rm -rf node_modules # clean cache",
8+
"OXLINT_TSGOLINT_PATH=/path/to/oxlint_tsgolint2 vite run check-nested # get OXLINT_TSGOLINT_PATH env in nested task"
9+
]
10+
}

packages/cli/src/lint.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@ export async function lint(): Promise<{
3131
binPath: string;
3232
envs: Record<string, string>;
3333
}> {
34+
const paths = [process.cwd(), dirname(fileURLToPath(import.meta.url))];
3435
// Resolve the oxlint binary directly (it's a native executable)
3536
const binPath = require.resolve('oxlint/bin/oxlint', {
36-
paths: [process.cwd(), dirname(fileURLToPath(import.meta.url))],
37+
paths,
3738
});
3839

3940
return {
@@ -45,6 +46,9 @@ export async function lint(): Promise<{
4546
JS_RUNTIME_NAME: process.release.name,
4647
// Indicate that vite-plus is the package manager invoking oxlint
4748
NODE_PACKAGE_MANAGER: 'vite-plus',
49+
OXLINT_TSGOLINT_PATH: require.resolve('oxlint-tsgolint/bin/tsgolint.js', {
50+
paths,
51+
}),
4852
},
4953
};
5054
}

0 commit comments

Comments
 (0)