diff --git a/apps/oxlint/fixtures/tsgolint/config-test.json b/apps/oxlint/fixtures/tsgolint/config-test.json new file mode 100644 index 0000000000000..a2db3b3de9073 --- /dev/null +++ b/apps/oxlint/fixtures/tsgolint/config-test.json @@ -0,0 +1,3 @@ +{ + "extends": ["./extended-config.json"] +} diff --git a/apps/oxlint/fixtures/tsgolint/extended-config.json b/apps/oxlint/fixtures/tsgolint/extended-config.json new file mode 100644 index 0000000000000..bcf8a41eeafb5 --- /dev/null +++ b/apps/oxlint/fixtures/tsgolint/extended-config.json @@ -0,0 +1,16 @@ +{ + "categories": { + "correctness": "off" + }, + "rules": { + "no-debugger": "error" + }, + "overrides": [ + { + "files": ["*.ts"], + "rules": { + "typescript/no-floating-promises": "warn" + } + } + ] +} diff --git a/apps/oxlint/src/lint.rs b/apps/oxlint/src/lint.rs index f277ad9771949..d342bbfb4482b 100644 --- a/apps/oxlint/src/lint.rs +++ b/apps/oxlint/src/lint.rs @@ -1221,4 +1221,11 @@ mod test { let args = &["--type-aware"]; Tester::new().with_cwd("fixtures/tsgolint".into()).test_and_snapshot(args); } + + #[test] + #[cfg(not(any(target_os = "windows", target_endian = "big")))] + fn test_tsgolint_config() { + let args = &["--type-aware", "-c", "config-test.json"]; + Tester::new().with_cwd("fixtures/tsgolint".into()).test_and_snapshot(args); + } } diff --git a/apps/oxlint/src/snapshots/fixtures__tsgolint_--type-aware -c config-test.json@oxlint.snap b/apps/oxlint/src/snapshots/fixtures__tsgolint_--type-aware -c config-test.json@oxlint.snap new file mode 100644 index 0000000000000..422151d271304 --- /dev/null +++ b/apps/oxlint/src/snapshots/fixtures__tsgolint_--type-aware -c config-test.json@oxlint.snap @@ -0,0 +1,116 @@ +--- +source: apps/oxlint/src/tester.rs +--- +########## +arguments: --type-aware -c config-test.json +working directory: fixtures/tsgolint +---------- + + ! 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` + | operator. + ,-[no-floating-promises/index.ts:2:1] + 1 | const promise = new Promise((resolve, _reject) => resolve("value")); + 2 | promise; + : ^^^^^^^^ + 3 | + `---- + + ! 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` + | operator. + ,-[no-floating-promises/index.ts:8:1] + 7 | + 8 | returnsPromise().then(() => {}); + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 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` + | operator. + ,-[no-floating-promises/index.ts:10:1] + 9 | + 10 | Promise.reject("value").catch(); + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 11 | + `---- + + ! 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` + | operator. + ,-[no-floating-promises/index.ts:12:1] + 11 | + 12 | Promise.reject("value").finally(); + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 13 | + `---- + + ! 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 + | the expression as ignored with the `void` operator. + ,-[no-floating-promises/index.ts:14:1] + 13 | + 14 | [1, 2, 3].map(async (x) => x + 1); + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + ! 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` + | operator. + ,-[no-floating-promises/src/index.ts:2:1] + 1 | const promise = new Promise((resolve, _reject) => resolve("value")); + 2 | promise; + : ^^^^^^^^ + 3 | + `---- + + ! 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` + | operator. + ,-[no-floating-promises/src/index.ts:8:1] + 7 | + 8 | returnsPromise().then(() => {}); + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 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` + | operator. + ,-[no-floating-promises/src/index.ts:10:1] + 9 | + 10 | Promise.reject("value").catch(); + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 11 | + `---- + + ! 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` + | operator. + ,-[no-floating-promises/src/index.ts:12:1] + 11 | + 12 | Promise.reject("value").finally(); + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 13 | + `---- + + ! 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 + | the expression as ignored with the `void` operator. + ,-[no-floating-promises/src/index.ts:14:1] + 13 | + 14 | [1, 2, 3].map(async (x) => x + 1); + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + ! 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` + | operator. + ,-[no-floating-promises/src/overrides.ts:4:1] + 3 | } + 4 | returnsPromise().then(() => {}); + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-debugger.html\eslint(no-debugger)]8;;\: `debugger` statement is not allowed + ,-[non-tsgolint.ts:1:1] + 1 | debugger; + : ^^^^^^^^^ + `---- + help: Remove the debugger statement + +Found 11 warnings and 1 error. +Finished in ms on 4 files with 1 rules using 1 threads. +---------- +CLI result: LintFoundErrors +----------