Skip to content

Commit d7cca12

Browse files
committed
test(linter): add test for extended configs and overrides for tsgolint (#12924)
- addresses #12886 (comment)
1 parent 784796d commit d7cca12

File tree

4 files changed

+142
-0
lines changed

4 files changed

+142
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": ["./extended-config.json"]
3+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"categories": {
3+
"correctness": "off"
4+
},
5+
"rules": {
6+
"no-debugger": "error"
7+
},
8+
"overrides": [
9+
{
10+
"files": ["*.ts"],
11+
"rules": {
12+
"typescript/no-floating-promises": "warn"
13+
}
14+
}
15+
]
16+
}

apps/oxlint/src/lint.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,4 +1221,11 @@ mod test {
12211221
let args = &["--type-aware"];
12221222
Tester::new().with_cwd("fixtures/tsgolint".into()).test_and_snapshot(args);
12231223
}
1224+
1225+
#[test]
1226+
#[cfg(not(any(target_os = "windows", target_endian = "big")))]
1227+
fn test_tsgolint_config() {
1228+
let args = &["--type-aware", "-c", "config-test.json"];
1229+
Tester::new().with_cwd("fixtures/tsgolint".into()).test_and_snapshot(args);
1230+
}
12241231
}
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
---
2+
source: apps/oxlint/src/tester.rs
3+
---
4+
##########
5+
arguments: --type-aware -c config-test.json
6+
working directory: fixtures/tsgolint
7+
----------
8+
9+
! typescript-eslint(no-floating-promises): Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void`
10+
| operator.
11+
,-[no-floating-promises/index.ts:2:1]
12+
1 | const promise = new Promise((resolve, _reject) => resolve("value"));
13+
2 | promise;
14+
: ^^^^^^^^
15+
3 |
16+
`----
17+
18+
! typescript-eslint(no-floating-promises): Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void`
19+
| operator.
20+
,-[no-floating-promises/index.ts:8:1]
21+
7 |
22+
8 | returnsPromise().then(() => {});
23+
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
24+
9 |
25+
`----
26+
27+
! typescript-eslint(no-floating-promises): Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void`
28+
| operator.
29+
,-[no-floating-promises/index.ts:10:1]
30+
9 |
31+
10 | Promise.reject("value").catch();
32+
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
33+
11 |
34+
`----
35+
36+
! typescript-eslint(no-floating-promises): Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void`
37+
| operator.
38+
,-[no-floating-promises/index.ts:12:1]
39+
11 |
40+
12 | Promise.reject("value").finally();
41+
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
42+
13 |
43+
`----
44+
45+
! typescript-eslint(no-floating-promises): An array of Promises may be unintentional. Consider handling the promises' fulfillment or rejection with Promise.all or similar, or explicitly marking
46+
| the expression as ignored with the `void` operator.
47+
,-[no-floating-promises/index.ts:14:1]
48+
13 |
49+
14 | [1, 2, 3].map(async (x) => x + 1);
50+
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
51+
`----
52+
53+
! typescript-eslint(no-floating-promises): Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void`
54+
| operator.
55+
,-[no-floating-promises/src/index.ts:2:1]
56+
1 | const promise = new Promise((resolve, _reject) => resolve("value"));
57+
2 | promise;
58+
: ^^^^^^^^
59+
3 |
60+
`----
61+
62+
! typescript-eslint(no-floating-promises): Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void`
63+
| operator.
64+
,-[no-floating-promises/src/index.ts:8:1]
65+
7 |
66+
8 | returnsPromise().then(() => {});
67+
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
68+
9 |
69+
`----
70+
71+
! typescript-eslint(no-floating-promises): Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void`
72+
| operator.
73+
,-[no-floating-promises/src/index.ts:10:1]
74+
9 |
75+
10 | Promise.reject("value").catch();
76+
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
77+
11 |
78+
`----
79+
80+
! typescript-eslint(no-floating-promises): Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void`
81+
| operator.
82+
,-[no-floating-promises/src/index.ts:12:1]
83+
11 |
84+
12 | Promise.reject("value").finally();
85+
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
86+
13 |
87+
`----
88+
89+
! typescript-eslint(no-floating-promises): An array of Promises may be unintentional. Consider handling the promises' fulfillment or rejection with Promise.all or similar, or explicitly marking
90+
| the expression as ignored with the `void` operator.
91+
,-[no-floating-promises/src/index.ts:14:1]
92+
13 |
93+
14 | [1, 2, 3].map(async (x) => x + 1);
94+
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
95+
`----
96+
97+
! typescript-eslint(no-floating-promises): Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void`
98+
| operator.
99+
,-[no-floating-promises/src/overrides.ts:4:1]
100+
3 | }
101+
4 | returnsPromise().then(() => {});
102+
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
103+
`----
104+
105+
x ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-debugger.html\eslint(no-debugger)]8;;\: `debugger` statement is not allowed
106+
,-[non-tsgolint.ts:1:1]
107+
1 | debugger;
108+
: ^^^^^^^^^
109+
`----
110+
help: Remove the debugger statement
111+
112+
Found 11 warnings and 1 error.
113+
Finished in <variable>ms on 4 files with 1 rules using 1 threads.
114+
----------
115+
CLI result: LintFoundErrors
116+
----------

0 commit comments

Comments
 (0)