From fcbd2a987a9169c6a77fdf5ac9ac24f27d4cb8ac Mon Sep 17 00:00:00 2001 From: xiaokhkh <727070793@qq.com> Date: Sun, 14 Sep 2025 03:10:44 +0800 Subject: [PATCH 1/2] feat(linter): add `preserve-caught-error` rule Introduced a new linting rule `preserve-caught-error` to enforce the preservation of original errors when re-throwing exceptions. This rule helps maintain error context by requiring the use of the 'cause' property in error objects. Updated relevant snapshots and tests to reflect the new rule's functionality. --- ...gnore fixtures__linter__nan.js@oxlint.snap | 2 +- ...ern _____.vue fixtures__linter@oxlint.snap | 2 +- ...l -D no-cycle fixtures__flow__@oxlint.snap | 2 +- ...ugin fixtures__flow__index.mjs@oxlint.snap | 2 +- ...rc_vitest_replace__foo.test.js@oxlint.snap | 2 +- ... fixtures__linter__debugger.js@oxlint.snap | 2 +- ... fixtures__linter__debugger.js@oxlint.snap | 2 +- ...ixtures__eslintrc_env__test.js@oxlint.snap | 2 +- ...on fixtures__no_undef__test.js@oxlint.snap | 2 +- ...ore_patterns__ignore_extension@oxlint.snap | 2 +- ...rns__ignore_extension__main.js@oxlint.snap | 2 +- ...ixtures__eslintrc_env__test.js@oxlint.snap | 2 +- ...ixtures__eslintrc_off__test.js@oxlint.snap | 2 +- ...rc_vitest_replace__foo.test.js@oxlint.snap | 2 +- ... fixtures__linter__debugger.js@oxlint.snap | 2 +- ...tures__no_console_off__test.js@oxlint.snap | 2 +- ...pty_allow_empty_catch__test.js@oxlint.snap | 2 +- ..._disallow_empty_catch__test.js@oxlint.snap | 2 +- ...fixtures__overrides__other.jsx@oxlint.snap | 6 +- ...onfig.json fixtures__overrides@oxlint.snap | 2 +- ...es__typescript_eslint__test.ts@oxlint.snap | 2 +- ...es__typescript_eslint__test.ts@oxlint.snap | 2 +- ...ixtures__astro__debugger.astro@oxlint.snap | 2 +- .../snapshots/_fixtures__linter@oxlint.snap | 2 +- ...er.js fixtures__linter__nan.js@oxlint.snap | 2 +- ..._fixtures__linter__debugger.js@oxlint.snap | 2 +- ...fixtures__linter__js_as_jsx.js@oxlint.snap | 2 +- ...tures__svelte__debugger.svelte@oxlint.snap | 2 +- .../_fixtures__vue__debugger.vue@oxlint.snap | 2 +- .../_fixtures__vue__empty.vue@oxlint.snap | 2 +- .../src/snapshots/_foo.asdf@oxlint.snap | 2 +- ...ore_directory_-c eslintrc.json@oxlint.snap | 2 +- ...c.json --ignore-pattern _.ts .@oxlint.snap | 2 +- ....oxlintrc-unicorn.json test.js@oxlint.snap | 4 +- .../fixtures__dot_folder_@oxlint.snap | 2 +- ...s_rules_config.json console.js@oxlint.snap | 2 +- ...extends_config.json console.js@oxlint.snap | 2 +- ...config_--disable-nested-config@oxlint.snap | 2 +- ...ort-plugin -D import__no-cycle@oxlint.snap | 2 +- ...oxlintrc-import-x.json test.js@oxlint.snap | 4 +- ..._issue_10394_-c .oxlintrc.json@oxlint.snap | 2 +- ..._issue_11054_-c .oxlintrc.json@oxlint.snap | 2 +- ..._issue_11644_-c .oxlintrc.json@oxlint.snap | 2 +- .../fixtures__linter_debugger.js@oxlint.snap | 2 +- ...nv_globals_-c .oxlintrc.json .@oxlint.snap | 2 +- ..._with_plugin_-c .oxlintrc.json@oxlint.snap | 2 +- ...sed-disable-directives test.js@oxlint.snap | 2 +- ...name_-c .oxlintrc.json test.js@oxlint.snap | 2 +- .../src/generated/rule_runner_impls.rs | 5 + crates/oxc_linter/src/rules.rs | 2 + .../src/rules/eslint/preserve_caught_error.rs | 591 ++++++++++++++++++ .../eslint_preserve_caught_error.snap | 246 ++++++++ 52 files changed, 896 insertions(+), 52 deletions(-) create mode 100644 crates/oxc_linter/src/rules/eslint/preserve_caught_error.rs create mode 100644 crates/oxc_linter/src/snapshots/eslint_preserve_caught_error.snap diff --git a/apps/oxlint/src/snapshots/_--ignore-path fixtures__linter__.customignore --no-ignore fixtures__linter__nan.js@oxlint.snap b/apps/oxlint/src/snapshots/_--ignore-path fixtures__linter__.customignore --no-ignore fixtures__linter__nan.js@oxlint.snap index 14d5edc37b894..96f5f42b881a6 100644 --- a/apps/oxlint/src/snapshots/_--ignore-path fixtures__linter__.customignore --no-ignore fixtures__linter__nan.js@oxlint.snap +++ b/apps/oxlint/src/snapshots/_--ignore-path fixtures__linter__.customignore --no-ignore fixtures__linter__nan.js@oxlint.snap @@ -14,7 +14,7 @@ working directory: help: Use the isNaN function to compare with NaN. Found 1 warning and 0 errors. -Finished in ms on 1 file with 88 rules using 1 threads. +Finished in ms on 1 file with 89 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/_--ignore-pattern _____.js --ignore-pattern _____.vue fixtures__linter@oxlint.snap b/apps/oxlint/src/snapshots/_--ignore-pattern _____.js --ignore-pattern _____.vue fixtures__linter@oxlint.snap index 4df9f6236759d..6f72f11c56089 100644 --- a/apps/oxlint/src/snapshots/_--ignore-pattern _____.js --ignore-pattern _____.vue fixtures__linter@oxlint.snap +++ b/apps/oxlint/src/snapshots/_--ignore-pattern _____.js --ignore-pattern _____.vue fixtures__linter@oxlint.snap @@ -6,7 +6,7 @@ arguments: --ignore-pattern **/*.js --ignore-pattern **/*.vue fixtures/linter working directory: ---------- Found 0 warnings and 0 errors. -Finished in ms on 0 files with 88 rules using 1 threads. +Finished in ms on 0 files with 89 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/_--import-plugin -A all -D no-cycle fixtures__flow__@oxlint.snap b/apps/oxlint/src/snapshots/_--import-plugin -A all -D no-cycle fixtures__flow__@oxlint.snap index 6b279aaf7880d..91b8e3942dc74 100644 --- a/apps/oxlint/src/snapshots/_--import-plugin -A all -D no-cycle fixtures__flow__@oxlint.snap +++ b/apps/oxlint/src/snapshots/_--import-plugin -A all -D no-cycle fixtures__flow__@oxlint.snap @@ -6,7 +6,7 @@ arguments: --import-plugin -A all -D no-cycle fixtures/flow/ working directory: ---------- Found 0 warnings and 0 errors. -Finished in ms on 2 files with 90 rules using 1 threads. +Finished in ms on 2 files with 91 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/_--import-plugin fixtures__flow__index.mjs@oxlint.snap b/apps/oxlint/src/snapshots/_--import-plugin fixtures__flow__index.mjs@oxlint.snap index cfceefea6e34f..8374a8a41ed5a 100644 --- a/apps/oxlint/src/snapshots/_--import-plugin fixtures__flow__index.mjs@oxlint.snap +++ b/apps/oxlint/src/snapshots/_--import-plugin fixtures__flow__index.mjs@oxlint.snap @@ -6,7 +6,7 @@ arguments: --import-plugin fixtures/flow/index.mjs working directory: ---------- Found 0 warnings and 0 errors. -Finished in ms on 1 file with 90 rules using 1 threads. +Finished in ms on 1 file with 91 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/_--vitest-plugin -c fixtures__eslintrc_vitest_replace__eslintrc.json fixtures__eslintrc_vitest_replace__foo.test.js@oxlint.snap b/apps/oxlint/src/snapshots/_--vitest-plugin -c fixtures__eslintrc_vitest_replace__eslintrc.json fixtures__eslintrc_vitest_replace__foo.test.js@oxlint.snap index c4d380529edec..8d8ea6722e75a 100644 --- a/apps/oxlint/src/snapshots/_--vitest-plugin -c fixtures__eslintrc_vitest_replace__eslintrc.json fixtures__eslintrc_vitest_replace__foo.test.js@oxlint.snap +++ b/apps/oxlint/src/snapshots/_--vitest-plugin -c fixtures__eslintrc_vitest_replace__eslintrc.json fixtures__eslintrc_vitest_replace__foo.test.js@oxlint.snap @@ -23,7 +23,7 @@ working directory: help: Remove the appending `.skip` Found 1 warning and 1 error. -Finished in ms on 1 file with 100 rules using 1 threads. +Finished in ms on 1 file with 101 rules using 1 threads. ---------- CLI result: LintFoundErrors ---------- diff --git a/apps/oxlint/src/snapshots/_-D correctness fixtures__linter__debugger.js@oxlint.snap b/apps/oxlint/src/snapshots/_-D correctness fixtures__linter__debugger.js@oxlint.snap index e8a7439a56489..7455b2d26efd0 100644 --- a/apps/oxlint/src/snapshots/_-D correctness fixtures__linter__debugger.js@oxlint.snap +++ b/apps/oxlint/src/snapshots/_-D correctness fixtures__linter__debugger.js@oxlint.snap @@ -14,7 +14,7 @@ working directory: help: Remove the debugger statement Found 0 warnings and 1 error. -Finished in ms on 1 file with 88 rules using 1 threads. +Finished in ms on 1 file with 89 rules using 1 threads. ---------- CLI result: LintFoundErrors ---------- diff --git a/apps/oxlint/src/snapshots/_-W correctness -A no-debugger fixtures__linter__debugger.js@oxlint.snap b/apps/oxlint/src/snapshots/_-W correctness -A no-debugger fixtures__linter__debugger.js@oxlint.snap index 7d865615b1c26..25b62837f3535 100644 --- a/apps/oxlint/src/snapshots/_-W correctness -A no-debugger fixtures__linter__debugger.js@oxlint.snap +++ b/apps/oxlint/src/snapshots/_-W correctness -A no-debugger fixtures__linter__debugger.js@oxlint.snap @@ -6,7 +6,7 @@ arguments: -W correctness -A no-debugger fixtures/linter/debugger.js working directory: ---------- Found 0 warnings and 0 errors. -Finished in ms on 1 file with 87 rules using 1 threads. +Finished in ms on 1 file with 88 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/_-W no-undef -c fixtures__eslintrc_env__eslintrc_no_env.json fixtures__eslintrc_env__test.js@oxlint.snap b/apps/oxlint/src/snapshots/_-W no-undef -c fixtures__eslintrc_env__eslintrc_no_env.json fixtures__eslintrc_env__test.js@oxlint.snap index 0d3edb0f3f202..a759468185a81 100644 --- a/apps/oxlint/src/snapshots/_-W no-undef -c fixtures__eslintrc_env__eslintrc_no_env.json fixtures__eslintrc_env__test.js@oxlint.snap +++ b/apps/oxlint/src/snapshots/_-W no-undef -c fixtures__eslintrc_env__eslintrc_no_env.json fixtures__eslintrc_env__test.js@oxlint.snap @@ -13,7 +13,7 @@ working directory: `---- Found 1 warning and 0 errors. -Finished in ms on 1 file with 89 rules using 1 threads. +Finished in ms on 1 file with 90 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/_-W no-undef -c fixtures__no_undef__eslintrc.json fixtures__no_undef__test.js@oxlint.snap b/apps/oxlint/src/snapshots/_-W no-undef -c fixtures__no_undef__eslintrc.json fixtures__no_undef__test.js@oxlint.snap index d8e1263173caa..2ec8506bdf335 100644 --- a/apps/oxlint/src/snapshots/_-W no-undef -c fixtures__no_undef__eslintrc.json fixtures__no_undef__test.js@oxlint.snap +++ b/apps/oxlint/src/snapshots/_-W no-undef -c fixtures__no_undef__eslintrc.json fixtures__no_undef__test.js@oxlint.snap @@ -13,7 +13,7 @@ working directory: `---- Found 1 warning and 0 errors. -Finished in ms on 1 file with 89 rules using 1 threads. +Finished in ms on 1 file with 90 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/_-c fixtures__config_ignore_patterns__ignore_extension__eslintrc.json fixtures__config_ignore_patterns__ignore_extension@oxlint.snap b/apps/oxlint/src/snapshots/_-c fixtures__config_ignore_patterns__ignore_extension__eslintrc.json fixtures__config_ignore_patterns__ignore_extension@oxlint.snap index 94ff47a62435e..cb5da05408814 100644 --- a/apps/oxlint/src/snapshots/_-c fixtures__config_ignore_patterns__ignore_extension__eslintrc.json fixtures__config_ignore_patterns__ignore_extension@oxlint.snap +++ b/apps/oxlint/src/snapshots/_-c fixtures__config_ignore_patterns__ignore_extension__eslintrc.json fixtures__config_ignore_patterns__ignore_extension@oxlint.snap @@ -12,7 +12,7 @@ working directory: help: Delete this file or add some code to it. Found 1 warning and 0 errors. -Finished in ms on 1 file with 88 rules using 1 threads. +Finished in ms on 1 file with 89 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/_-c fixtures__config_ignore_patterns__ignore_extension__eslintrc.json fixtures__config_ignore_patterns__ignore_extension__main.js@oxlint.snap b/apps/oxlint/src/snapshots/_-c fixtures__config_ignore_patterns__ignore_extension__eslintrc.json fixtures__config_ignore_patterns__ignore_extension__main.js@oxlint.snap index 27a14f783d989..97815492fafaa 100644 --- a/apps/oxlint/src/snapshots/_-c fixtures__config_ignore_patterns__ignore_extension__eslintrc.json fixtures__config_ignore_patterns__ignore_extension__main.js@oxlint.snap +++ b/apps/oxlint/src/snapshots/_-c fixtures__config_ignore_patterns__ignore_extension__eslintrc.json fixtures__config_ignore_patterns__ignore_extension__main.js@oxlint.snap @@ -6,7 +6,7 @@ arguments: -c fixtures/config_ignore_patterns/ignore_extension/eslintrc.json fix working directory: ---------- Found 0 warnings and 0 errors. -Finished in ms on 0 files with 88 rules using 1 threads. +Finished in ms on 0 files with 89 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/_-c fixtures__eslintrc_env__eslintrc_env_browser.json fixtures__eslintrc_env__test.js@oxlint.snap b/apps/oxlint/src/snapshots/_-c fixtures__eslintrc_env__eslintrc_env_browser.json fixtures__eslintrc_env__test.js@oxlint.snap index 25501e80c4580..8394a14d71b68 100644 --- a/apps/oxlint/src/snapshots/_-c fixtures__eslintrc_env__eslintrc_env_browser.json fixtures__eslintrc_env__test.js@oxlint.snap +++ b/apps/oxlint/src/snapshots/_-c fixtures__eslintrc_env__eslintrc_env_browser.json fixtures__eslintrc_env__test.js@oxlint.snap @@ -6,7 +6,7 @@ arguments: -c fixtures/eslintrc_env/eslintrc_env_browser.json fixtures/eslintrc_ working directory: ---------- Found 0 warnings and 0 errors. -Finished in ms on 1 file with 89 rules using 1 threads. +Finished in ms on 1 file with 90 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/_-c fixtures__eslintrc_off__eslintrc.json fixtures__eslintrc_off__test.js@oxlint.snap b/apps/oxlint/src/snapshots/_-c fixtures__eslintrc_off__eslintrc.json fixtures__eslintrc_off__test.js@oxlint.snap index f4589994fed67..c1765a94085f4 100644 --- a/apps/oxlint/src/snapshots/_-c fixtures__eslintrc_off__eslintrc.json fixtures__eslintrc_off__test.js@oxlint.snap +++ b/apps/oxlint/src/snapshots/_-c fixtures__eslintrc_off__eslintrc.json fixtures__eslintrc_off__test.js@oxlint.snap @@ -12,7 +12,7 @@ working directory: help: Delete this file or add some code to it. Found 1 warning and 0 errors. -Finished in ms on 1 file with 88 rules using 1 threads. +Finished in ms on 1 file with 89 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/_-c fixtures__eslintrc_vitest_replace__eslintrc.json fixtures__eslintrc_vitest_replace__foo.test.js@oxlint.snap b/apps/oxlint/src/snapshots/_-c fixtures__eslintrc_vitest_replace__eslintrc.json fixtures__eslintrc_vitest_replace__foo.test.js@oxlint.snap index fa6cb18220a4b..3d9e2534b2042 100644 --- a/apps/oxlint/src/snapshots/_-c fixtures__eslintrc_vitest_replace__eslintrc.json fixtures__eslintrc_vitest_replace__foo.test.js@oxlint.snap +++ b/apps/oxlint/src/snapshots/_-c fixtures__eslintrc_vitest_replace__eslintrc.json fixtures__eslintrc_vitest_replace__foo.test.js@oxlint.snap @@ -6,7 +6,7 @@ arguments: -c fixtures/eslintrc_vitest_replace/eslintrc.json fixtures/eslintrc_v working directory: ---------- Found 0 warnings and 0 errors. -Finished in ms on 1 file with 88 rules using 1 threads. +Finished in ms on 1 file with 89 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/_-c fixtures__linter__eslintrc.json fixtures__linter__debugger.js@oxlint.snap b/apps/oxlint/src/snapshots/_-c fixtures__linter__eslintrc.json fixtures__linter__debugger.js@oxlint.snap index afa75f25536d0..555c316648462 100644 --- a/apps/oxlint/src/snapshots/_-c fixtures__linter__eslintrc.json fixtures__linter__debugger.js@oxlint.snap +++ b/apps/oxlint/src/snapshots/_-c fixtures__linter__eslintrc.json fixtures__linter__debugger.js@oxlint.snap @@ -14,7 +14,7 @@ working directory: help: Remove the debugger statement Found 0 warnings and 1 error. -Finished in ms on 1 file with 88 rules using 1 threads. +Finished in ms on 1 file with 89 rules using 1 threads. ---------- CLI result: LintFoundErrors ---------- diff --git a/apps/oxlint/src/snapshots/_-c fixtures__no_console_off__eslintrc.json fixtures__no_console_off__test.js@oxlint.snap b/apps/oxlint/src/snapshots/_-c fixtures__no_console_off__eslintrc.json fixtures__no_console_off__test.js@oxlint.snap index ec9911f1422e1..3d521921ff354 100644 --- a/apps/oxlint/src/snapshots/_-c fixtures__no_console_off__eslintrc.json fixtures__no_console_off__test.js@oxlint.snap +++ b/apps/oxlint/src/snapshots/_-c fixtures__no_console_off__eslintrc.json fixtures__no_console_off__test.js@oxlint.snap @@ -6,7 +6,7 @@ arguments: -c fixtures/no_console_off/eslintrc.json fixtures/no_console_off/test working directory: ---------- Found 0 warnings and 0 errors. -Finished in ms on 1 file with 88 rules using 1 threads. +Finished in ms on 1 file with 89 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/_-c fixtures__no_empty_allow_empty_catch__eslintrc.json -W no-empty fixtures__no_empty_allow_empty_catch__test.js@oxlint.snap b/apps/oxlint/src/snapshots/_-c fixtures__no_empty_allow_empty_catch__eslintrc.json -W no-empty fixtures__no_empty_allow_empty_catch__test.js@oxlint.snap index 44e6c594b0c26..3143d3c2efb85 100644 --- a/apps/oxlint/src/snapshots/_-c fixtures__no_empty_allow_empty_catch__eslintrc.json -W no-empty fixtures__no_empty_allow_empty_catch__test.js@oxlint.snap +++ b/apps/oxlint/src/snapshots/_-c fixtures__no_empty_allow_empty_catch__eslintrc.json -W no-empty fixtures__no_empty_allow_empty_catch__test.js@oxlint.snap @@ -6,7 +6,7 @@ arguments: -c fixtures/no_empty_allow_empty_catch/eslintrc.json -W no-empty fixt working directory: ---------- Found 0 warnings and 0 errors. -Finished in ms on 1 file with 89 rules using 1 threads. +Finished in ms on 1 file with 90 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/_-c fixtures__no_empty_disallow_empty_catch__eslintrc.json -W no-empty fixtures__no_empty_disallow_empty_catch__test.js@oxlint.snap b/apps/oxlint/src/snapshots/_-c fixtures__no_empty_disallow_empty_catch__eslintrc.json -W no-empty fixtures__no_empty_disallow_empty_catch__test.js@oxlint.snap index aee8e702efcca..5dccb075c282e 100644 --- a/apps/oxlint/src/snapshots/_-c fixtures__no_empty_disallow_empty_catch__eslintrc.json -W no-empty fixtures__no_empty_disallow_empty_catch__test.js@oxlint.snap +++ b/apps/oxlint/src/snapshots/_-c fixtures__no_empty_disallow_empty_catch__eslintrc.json -W no-empty fixtures__no_empty_disallow_empty_catch__test.js@oxlint.snap @@ -14,7 +14,7 @@ working directory: help: Remove this block or add a comment inside it Found 1 warning and 0 errors. -Finished in ms on 1 file with 89 rules using 1 threads. +Finished in ms on 1 file with 90 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/_-c fixtures__overrides__.oxlintrc.json fixtures__overrides__test.js -c fixtures__overrides__.oxlintrc.json fixtures__overrides__test.ts -c fixtures__overrides__.oxlintrc.json fixtures__overrides__other.jsx@oxlint.snap b/apps/oxlint/src/snapshots/_-c fixtures__overrides__.oxlintrc.json fixtures__overrides__test.js -c fixtures__overrides__.oxlintrc.json fixtures__overrides__test.ts -c fixtures__overrides__.oxlintrc.json fixtures__overrides__other.jsx@oxlint.snap index db17dd6cea37a..8fdeaf3a58cda 100644 --- a/apps/oxlint/src/snapshots/_-c fixtures__overrides__.oxlintrc.json fixtures__overrides__test.js -c fixtures__overrides__.oxlintrc.json fixtures__overrides__test.ts -c fixtures__overrides__.oxlintrc.json fixtures__overrides__other.jsx@oxlint.snap +++ b/apps/oxlint/src/snapshots/_-c fixtures__overrides__.oxlintrc.json fixtures__overrides__test.js -c fixtures__overrides__.oxlintrc.json fixtures__overrides__test.ts -c fixtures__overrides__.oxlintrc.json fixtures__overrides__other.jsx@oxlint.snap @@ -15,7 +15,7 @@ working directory: help: Replace var with let or const Found 0 warnings and 1 error. -Finished in ms on 1 file with 90 rules using 1 threads. +Finished in ms on 1 file with 91 rules using 1 threads. ---------- CLI result: LintFoundErrors ---------- @@ -42,7 +42,7 @@ working directory: help: Delete this console statement. Found 1 warning and 1 error. -Finished in ms on 1 file with 90 rules using 1 threads. +Finished in ms on 1 file with 91 rules using 1 threads. ---------- CLI result: LintFoundErrors ---------- @@ -61,7 +61,7 @@ working directory: help: Replace var with let or const Found 0 warnings and 1 error. -Finished in ms on 1 file with 90 rules using 1 threads. +Finished in ms on 1 file with 91 rules using 1 threads. ---------- CLI result: LintFoundErrors ---------- diff --git a/apps/oxlint/src/snapshots/_-c fixtures__overrides__directories-config.json fixtures__overrides@oxlint.snap b/apps/oxlint/src/snapshots/_-c fixtures__overrides__directories-config.json fixtures__overrides@oxlint.snap index f114ad02fc06c..3663fce39d5e0 100644 --- a/apps/oxlint/src/snapshots/_-c fixtures__overrides__directories-config.json fixtures__overrides@oxlint.snap +++ b/apps/oxlint/src/snapshots/_-c fixtures__overrides__directories-config.json fixtures__overrides@oxlint.snap @@ -35,7 +35,7 @@ working directory: help: Remove the debugger statement Found 2 warnings and 2 errors. -Finished in ms on 7 files with 87 rules using 1 threads. +Finished in ms on 7 files with 88 rules using 1 threads. ---------- CLI result: LintFoundErrors ---------- diff --git a/apps/oxlint/src/snapshots/_-c fixtures__typescript_eslint__eslintrc.json --disable-typescript-plugin fixtures__typescript_eslint__test.ts@oxlint.snap b/apps/oxlint/src/snapshots/_-c fixtures__typescript_eslint__eslintrc.json --disable-typescript-plugin fixtures__typescript_eslint__test.ts@oxlint.snap index 65110c0de93a7..6b567eafca17b 100644 --- a/apps/oxlint/src/snapshots/_-c fixtures__typescript_eslint__eslintrc.json --disable-typescript-plugin fixtures__typescript_eslint__test.ts@oxlint.snap +++ b/apps/oxlint/src/snapshots/_-c fixtures__typescript_eslint__eslintrc.json --disable-typescript-plugin fixtures__typescript_eslint__test.ts@oxlint.snap @@ -23,7 +23,7 @@ working directory: `---- Found 1 warning and 1 error. -Finished in ms on 1 file with 51 rules using 1 threads. +Finished in ms on 1 file with 52 rules using 1 threads. ---------- CLI result: LintFoundErrors ---------- diff --git a/apps/oxlint/src/snapshots/_-c fixtures__typescript_eslint__eslintrc.json fixtures__typescript_eslint__test.ts@oxlint.snap b/apps/oxlint/src/snapshots/_-c fixtures__typescript_eslint__eslintrc.json fixtures__typescript_eslint__test.ts@oxlint.snap index eab9dad447078..2b2d2bc4843ef 100644 --- a/apps/oxlint/src/snapshots/_-c fixtures__typescript_eslint__eslintrc.json fixtures__typescript_eslint__test.ts@oxlint.snap +++ b/apps/oxlint/src/snapshots/_-c fixtures__typescript_eslint__eslintrc.json fixtures__typescript_eslint__test.ts@oxlint.snap @@ -31,7 +31,7 @@ working directory: `---- Found 2 warnings and 1 error. -Finished in ms on 1 file with 63 rules using 1 threads. +Finished in ms on 1 file with 64 rules using 1 threads. ---------- CLI result: LintFoundErrors ---------- diff --git a/apps/oxlint/src/snapshots/_fixtures__astro__debugger.astro@oxlint.snap b/apps/oxlint/src/snapshots/_fixtures__astro__debugger.astro@oxlint.snap index 4e6ea777724c3..f894a60f2dfb8 100644 --- a/apps/oxlint/src/snapshots/_fixtures__astro__debugger.astro@oxlint.snap +++ b/apps/oxlint/src/snapshots/_fixtures__astro__debugger.astro@oxlint.snap @@ -43,7 +43,7 @@ working directory: help: Remove the debugger statement Found 4 warnings and 0 errors. -Finished in ms on 1 file with 88 rules using 1 threads. +Finished in ms on 1 file with 89 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/_fixtures__linter@oxlint.snap b/apps/oxlint/src/snapshots/_fixtures__linter@oxlint.snap index c4f6832be41cb..7e23e8196cb4c 100644 --- a/apps/oxlint/src/snapshots/_fixtures__linter@oxlint.snap +++ b/apps/oxlint/src/snapshots/_fixtures__linter@oxlint.snap @@ -29,7 +29,7 @@ working directory: help: Use the isNaN function to compare with NaN. Found 3 warnings and 0 errors. -Finished in ms on 3 files with 88 rules using 1 threads. +Finished in ms on 3 files with 89 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/_fixtures__linter__debugger.js fixtures__linter__nan.js@oxlint.snap b/apps/oxlint/src/snapshots/_fixtures__linter__debugger.js fixtures__linter__nan.js@oxlint.snap index 7abab6af6a633..225b6fa3155e3 100644 --- a/apps/oxlint/src/snapshots/_fixtures__linter__debugger.js fixtures__linter__nan.js@oxlint.snap +++ b/apps/oxlint/src/snapshots/_fixtures__linter__debugger.js fixtures__linter__nan.js@oxlint.snap @@ -21,7 +21,7 @@ working directory: help: Use the isNaN function to compare with NaN. Found 2 warnings and 0 errors. -Finished in ms on 2 files with 88 rules using 1 threads. +Finished in ms on 2 files with 89 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/_fixtures__linter__debugger.js@oxlint.snap b/apps/oxlint/src/snapshots/_fixtures__linter__debugger.js@oxlint.snap index dc5b0018fb3fb..322a6991bc45e 100644 --- a/apps/oxlint/src/snapshots/_fixtures__linter__debugger.js@oxlint.snap +++ b/apps/oxlint/src/snapshots/_fixtures__linter__debugger.js@oxlint.snap @@ -14,7 +14,7 @@ working directory: help: Remove the debugger statement Found 1 warning and 0 errors. -Finished in ms on 1 file with 88 rules using 1 threads. +Finished in ms on 1 file with 89 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/_fixtures__linter__js_as_jsx.js@oxlint.snap b/apps/oxlint/src/snapshots/_fixtures__linter__js_as_jsx.js@oxlint.snap index 6f10c0e933022..58f9eeb45e9b7 100644 --- a/apps/oxlint/src/snapshots/_fixtures__linter__js_as_jsx.js@oxlint.snap +++ b/apps/oxlint/src/snapshots/_fixtures__linter__js_as_jsx.js@oxlint.snap @@ -15,7 +15,7 @@ working directory: help: Remove the debugger statement Found 1 warning and 0 errors. -Finished in ms on 1 file with 88 rules using 1 threads. +Finished in ms on 1 file with 89 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/_fixtures__svelte__debugger.svelte@oxlint.snap b/apps/oxlint/src/snapshots/_fixtures__svelte__debugger.svelte@oxlint.snap index 10d430a9d26ee..a92865b47cc81 100644 --- a/apps/oxlint/src/snapshots/_fixtures__svelte__debugger.svelte@oxlint.snap +++ b/apps/oxlint/src/snapshots/_fixtures__svelte__debugger.svelte@oxlint.snap @@ -34,7 +34,7 @@ working directory: help: Variable declared without assignment. Either assign a value or remove the declaration. Found 3 warnings and 0 errors. -Finished in ms on 1 file with 88 rules using 1 threads. +Finished in ms on 1 file with 89 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/_fixtures__vue__debugger.vue@oxlint.snap b/apps/oxlint/src/snapshots/_fixtures__vue__debugger.vue@oxlint.snap index 923455acb9d95..6fe80af145242 100644 --- a/apps/oxlint/src/snapshots/_fixtures__vue__debugger.vue@oxlint.snap +++ b/apps/oxlint/src/snapshots/_fixtures__vue__debugger.vue@oxlint.snap @@ -25,7 +25,7 @@ working directory: help: Remove the debugger statement Found 2 warnings and 0 errors. -Finished in ms on 1 file with 88 rules using 1 threads. +Finished in ms on 1 file with 89 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/_fixtures__vue__empty.vue@oxlint.snap b/apps/oxlint/src/snapshots/_fixtures__vue__empty.vue@oxlint.snap index 9bc332a438637..fc458c656cd06 100644 --- a/apps/oxlint/src/snapshots/_fixtures__vue__empty.vue@oxlint.snap +++ b/apps/oxlint/src/snapshots/_fixtures__vue__empty.vue@oxlint.snap @@ -6,7 +6,7 @@ arguments: fixtures/vue/empty.vue working directory: ---------- Found 0 warnings and 0 errors. -Finished in ms on 1 file with 88 rules using 1 threads. +Finished in ms on 1 file with 89 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/_foo.asdf@oxlint.snap b/apps/oxlint/src/snapshots/_foo.asdf@oxlint.snap index b318daf82400b..1ac700cd30329 100644 --- a/apps/oxlint/src/snapshots/_foo.asdf@oxlint.snap +++ b/apps/oxlint/src/snapshots/_foo.asdf@oxlint.snap @@ -6,7 +6,7 @@ arguments: foo.asdf working directory: ---------- Found 0 warnings and 0 errors. -Finished in ms on 0 files with 88 rules using 1 threads. +Finished in ms on 0 files with 89 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/fixtures__config_ignore_patterns__ignore_directory_-c eslintrc.json@oxlint.snap b/apps/oxlint/src/snapshots/fixtures__config_ignore_patterns__ignore_directory_-c eslintrc.json@oxlint.snap index e8714e8681f0d..24165e78ad716 100644 --- a/apps/oxlint/src/snapshots/fixtures__config_ignore_patterns__ignore_directory_-c eslintrc.json@oxlint.snap +++ b/apps/oxlint/src/snapshots/fixtures__config_ignore_patterns__ignore_directory_-c eslintrc.json@oxlint.snap @@ -14,7 +14,7 @@ working directory: fixtures/config_ignore_patterns/ignore_directory help: Delete this file or add some code to it. Found 1 warning and 0 errors. -Finished in ms on 1 file with 88 rules using 1 threads. +Finished in ms on 1 file with 89 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/fixtures__config_ignore_patterns__with_oxlintrc_-c .__test__eslintrc.json --ignore-pattern _.ts .@oxlint.snap b/apps/oxlint/src/snapshots/fixtures__config_ignore_patterns__with_oxlintrc_-c .__test__eslintrc.json --ignore-pattern _.ts .@oxlint.snap index 5fe1e852820ba..0c25b00e41462 100644 --- a/apps/oxlint/src/snapshots/fixtures__config_ignore_patterns__with_oxlintrc_-c .__test__eslintrc.json --ignore-pattern _.ts .@oxlint.snap +++ b/apps/oxlint/src/snapshots/fixtures__config_ignore_patterns__with_oxlintrc_-c .__test__eslintrc.json --ignore-pattern _.ts .@oxlint.snap @@ -6,7 +6,7 @@ arguments: -c ./test/eslintrc.json --ignore-pattern *.ts . working directory: fixtures/config_ignore_patterns/with_oxlintrc ---------- Found 0 warnings and 0 errors. -Finished in ms on 0 files with 88 rules using 1 threads. +Finished in ms on 0 files with 89 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/fixtures__disable_eslint_and_unicorn_alias_rules_-c .oxlintrc-eslint.json test.js -c .oxlintrc-unicorn.json test.js@oxlint.snap b/apps/oxlint/src/snapshots/fixtures__disable_eslint_and_unicorn_alias_rules_-c .oxlintrc-eslint.json test.js -c .oxlintrc-unicorn.json test.js@oxlint.snap index ac5e7f74d9118..ea4c1acbde57a 100644 --- a/apps/oxlint/src/snapshots/fixtures__disable_eslint_and_unicorn_alias_rules_-c .oxlintrc-eslint.json test.js -c .oxlintrc-unicorn.json test.js@oxlint.snap +++ b/apps/oxlint/src/snapshots/fixtures__disable_eslint_and_unicorn_alias_rules_-c .oxlintrc-eslint.json test.js -c .oxlintrc-unicorn.json test.js@oxlint.snap @@ -6,7 +6,7 @@ arguments: -c .oxlintrc-eslint.json test.js working directory: fixtures/disable_eslint_and_unicorn_alias_rules ---------- Found 0 warnings and 0 errors. -Finished in ms on 1 file with 51 rules using 1 threads. +Finished in ms on 1 file with 52 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- @@ -16,7 +16,7 @@ arguments: -c .oxlintrc-unicorn.json test.js working directory: fixtures/disable_eslint_and_unicorn_alias_rules ---------- Found 0 warnings and 0 errors. -Finished in ms on 1 file with 64 rules using 1 threads. +Finished in ms on 1 file with 65 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/fixtures__dot_folder_@oxlint.snap b/apps/oxlint/src/snapshots/fixtures__dot_folder_@oxlint.snap index 79cbb96f4041b..3c3c8c8952bdd 100644 --- a/apps/oxlint/src/snapshots/fixtures__dot_folder_@oxlint.snap +++ b/apps/oxlint/src/snapshots/fixtures__dot_folder_@oxlint.snap @@ -14,7 +14,7 @@ working directory: fixtures/dot_folder help: Remove the debugger statement Found 1 warning and 0 errors. -Finished in ms on 1 file with 88 rules using 1 threads. +Finished in ms on 1 file with 89 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/fixtures__extends_config_--config extends_rules_config.json console.js@oxlint.snap b/apps/oxlint/src/snapshots/fixtures__extends_config_--config extends_rules_config.json console.js@oxlint.snap index 2c5078e8ae2cf..b893f937717fc 100644 --- a/apps/oxlint/src/snapshots/fixtures__extends_config_--config extends_rules_config.json console.js@oxlint.snap +++ b/apps/oxlint/src/snapshots/fixtures__extends_config_--config extends_rules_config.json console.js@oxlint.snap @@ -14,7 +14,7 @@ working directory: fixtures/extends_config help: Delete this console statement. Found 0 warnings and 1 error. -Finished in ms on 1 file with 89 rules using 1 threads. +Finished in ms on 1 file with 90 rules using 1 threads. ---------- CLI result: LintFoundErrors ---------- diff --git a/apps/oxlint/src/snapshots/fixtures__extends_config_--config relative_paths__extends_extends_config.json console.js@oxlint.snap b/apps/oxlint/src/snapshots/fixtures__extends_config_--config relative_paths__extends_extends_config.json console.js@oxlint.snap index 2560d77f56c60..57087bc5f4956 100644 --- a/apps/oxlint/src/snapshots/fixtures__extends_config_--config relative_paths__extends_extends_config.json console.js@oxlint.snap +++ b/apps/oxlint/src/snapshots/fixtures__extends_config_--config relative_paths__extends_extends_config.json console.js@oxlint.snap @@ -14,7 +14,7 @@ working directory: fixtures/extends_config help: Delete this console statement. Found 0 warnings and 1 error. -Finished in ms on 1 file with 89 rules using 1 threads. +Finished in ms on 1 file with 90 rules using 1 threads. ---------- CLI result: LintFoundErrors ---------- diff --git a/apps/oxlint/src/snapshots/fixtures__extends_config_--disable-nested-config@oxlint.snap b/apps/oxlint/src/snapshots/fixtures__extends_config_--disable-nested-config@oxlint.snap index 5f3ad63228d56..e9e54b6e0eab5 100644 --- a/apps/oxlint/src/snapshots/fixtures__extends_config_--disable-nested-config@oxlint.snap +++ b/apps/oxlint/src/snapshots/fixtures__extends_config_--disable-nested-config@oxlint.snap @@ -31,7 +31,7 @@ working directory: fixtures/extends_config help: Remove the debugger statement Found 3 warnings and 0 errors. -Finished in ms on 4 files with 88 rules using 1 threads. +Finished in ms on 4 files with 89 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/fixtures__import-cycle_--import-plugin -D import__no-cycle@oxlint.snap b/apps/oxlint/src/snapshots/fixtures__import-cycle_--import-plugin -D import__no-cycle@oxlint.snap index 0124f24f7b2c9..011c6f95fcc41 100644 --- a/apps/oxlint/src/snapshots/fixtures__import-cycle_--import-plugin -D import__no-cycle@oxlint.snap +++ b/apps/oxlint/src/snapshots/fixtures__import-cycle_--import-plugin -D import__no-cycle@oxlint.snap @@ -27,7 +27,7 @@ working directory: fixtures/import-cycle -> ./b - fixtures/import-cycle/b.ts Found 0 warnings and 2 errors. -Finished in ms on 2 files with 91 rules using 1 threads. +Finished in ms on 2 files with 92 rules using 1 threads. ---------- CLI result: LintFoundErrors ---------- diff --git a/apps/oxlint/src/snapshots/fixtures__import_-c .oxlintrc.json test.js -c .oxlintrc-import-x.json test.js@oxlint.snap b/apps/oxlint/src/snapshots/fixtures__import_-c .oxlintrc.json test.js -c .oxlintrc-import-x.json test.js@oxlint.snap index b34ccae5c72fe..05fcf131dd43a 100644 --- a/apps/oxlint/src/snapshots/fixtures__import_-c .oxlintrc.json test.js -c .oxlintrc-import-x.json test.js@oxlint.snap +++ b/apps/oxlint/src/snapshots/fixtures__import_-c .oxlintrc.json test.js -c .oxlintrc-import-x.json test.js@oxlint.snap @@ -15,7 +15,7 @@ working directory: fixtures/import `---- Found 0 warnings and 1 error. -Finished in ms on 1 file with 53 rules using 1 threads. +Finished in ms on 1 file with 54 rules using 1 threads. ---------- CLI result: LintFoundErrors ---------- @@ -34,7 +34,7 @@ working directory: fixtures/import `---- Found 0 warnings and 1 error. -Finished in ms on 1 file with 53 rules using 1 threads. +Finished in ms on 1 file with 54 rules using 1 threads. ---------- CLI result: LintFoundErrors ---------- diff --git a/apps/oxlint/src/snapshots/fixtures__issue_10394_-c .oxlintrc.json@oxlint.snap b/apps/oxlint/src/snapshots/fixtures__issue_10394_-c .oxlintrc.json@oxlint.snap index de60c8e2330d0..aa1360e8034f6 100644 --- a/apps/oxlint/src/snapshots/fixtures__issue_10394_-c .oxlintrc.json@oxlint.snap +++ b/apps/oxlint/src/snapshots/fixtures__issue_10394_-c .oxlintrc.json@oxlint.snap @@ -15,7 +15,7 @@ working directory: fixtures/issue_10394 help: "Write a meaningful title for your test" Found 1 warning and 0 errors. -Finished in ms on 1 file with 88 rules using 1 threads. +Finished in ms on 1 file with 89 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/fixtures__issue_11054_-c .oxlintrc.json@oxlint.snap b/apps/oxlint/src/snapshots/fixtures__issue_11054_-c .oxlintrc.json@oxlint.snap index 021cd19d338c5..2e5d872ebf147 100644 --- a/apps/oxlint/src/snapshots/fixtures__issue_11054_-c .oxlintrc.json@oxlint.snap +++ b/apps/oxlint/src/snapshots/fixtures__issue_11054_-c .oxlintrc.json@oxlint.snap @@ -6,7 +6,7 @@ arguments: -c .oxlintrc.json working directory: fixtures/issue_11054 ---------- Found 0 warnings and 0 errors. -Finished in ms on 1 file with 88 rules using 1 threads. +Finished in ms on 1 file with 89 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/fixtures__issue_11644_-c .oxlintrc.json@oxlint.snap b/apps/oxlint/src/snapshots/fixtures__issue_11644_-c .oxlintrc.json@oxlint.snap index 9fa98d0346d17..4eaedefe525c9 100644 --- a/apps/oxlint/src/snapshots/fixtures__issue_11644_-c .oxlintrc.json@oxlint.snap +++ b/apps/oxlint/src/snapshots/fixtures__issue_11644_-c .oxlintrc.json@oxlint.snap @@ -6,7 +6,7 @@ arguments: -c .oxlintrc.json working directory: fixtures/issue_11644 ---------- Found 0 warnings and 0 errors. -Finished in ms on 1 file with 160 rules using 1 threads. +Finished in ms on 1 file with 161 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/fixtures__linter_debugger.js@oxlint.snap b/apps/oxlint/src/snapshots/fixtures__linter_debugger.js@oxlint.snap index 9d6d855ef3212..7e47887164c7e 100644 --- a/apps/oxlint/src/snapshots/fixtures__linter_debugger.js@oxlint.snap +++ b/apps/oxlint/src/snapshots/fixtures__linter_debugger.js@oxlint.snap @@ -14,7 +14,7 @@ working directory: fixtures/linter help: Remove the debugger statement Found 1 warning and 0 errors. -Finished in ms on 1 file with 88 rules using 1 threads. +Finished in ms on 1 file with 89 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/fixtures__overrides_env_globals_-c .oxlintrc.json .@oxlint.snap b/apps/oxlint/src/snapshots/fixtures__overrides_env_globals_-c .oxlintrc.json .@oxlint.snap index efad408ad3993..4903ee7637f33 100644 --- a/apps/oxlint/src/snapshots/fixtures__overrides_env_globals_-c .oxlintrc.json .@oxlint.snap +++ b/apps/oxlint/src/snapshots/fixtures__overrides_env_globals_-c .oxlintrc.json .@oxlint.snap @@ -51,7 +51,7 @@ working directory: fixtures/overrides_env_globals `---- Found 5 warnings and 0 errors. -Finished in ms on 3 files with 88 rules using 1 threads. +Finished in ms on 3 files with 89 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/fixtures__overrides_with_plugin_-c .oxlintrc.json@oxlint.snap b/apps/oxlint/src/snapshots/fixtures__overrides_with_plugin_-c .oxlintrc.json@oxlint.snap index cfba320384f06..ce0d0fbc19104 100644 --- a/apps/oxlint/src/snapshots/fixtures__overrides_with_plugin_-c .oxlintrc.json@oxlint.snap +++ b/apps/oxlint/src/snapshots/fixtures__overrides_with_plugin_-c .oxlintrc.json@oxlint.snap @@ -42,7 +42,7 @@ working directory: fixtures/overrides_with_plugin help: Consider removing this declaration. Found 2 warnings and 2 errors. -Finished in ms on 2 files with 88 rules using 1 threads. +Finished in ms on 2 files with 89 rules using 1 threads. ---------- CLI result: LintFoundErrors ---------- diff --git a/apps/oxlint/src/snapshots/fixtures__report_unused_directives_-c .oxlintrc.json --report-unused-disable-directives test.js@oxlint.snap b/apps/oxlint/src/snapshots/fixtures__report_unused_directives_-c .oxlintrc.json --report-unused-disable-directives test.js@oxlint.snap index c2676e8ae1418..08643d98e03f0 100644 --- a/apps/oxlint/src/snapshots/fixtures__report_unused_directives_-c .oxlintrc.json --report-unused-disable-directives test.js@oxlint.snap +++ b/apps/oxlint/src/snapshots/fixtures__report_unused_directives_-c .oxlintrc.json --report-unused-disable-directives test.js@oxlint.snap @@ -64,7 +64,7 @@ working directory: fixtures/report_unused_directives `---- Found 7 warnings and 0 errors. -Finished in ms on 1 file with 89 rules using 1 threads. +Finished in ms on 1 file with 90 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/fixtures__two_rules_with_same_rule_name_-c .oxlintrc.json test.js@oxlint.snap b/apps/oxlint/src/snapshots/fixtures__two_rules_with_same_rule_name_-c .oxlintrc.json test.js@oxlint.snap index e21514d45fc3f..36d0766f8748d 100644 --- a/apps/oxlint/src/snapshots/fixtures__two_rules_with_same_rule_name_-c .oxlintrc.json test.js@oxlint.snap +++ b/apps/oxlint/src/snapshots/fixtures__two_rules_with_same_rule_name_-c .oxlintrc.json test.js@oxlint.snap @@ -6,7 +6,7 @@ arguments: -c .oxlintrc.json test.js working directory: fixtures/two_rules_with_same_rule_name ---------- Found 0 warnings and 0 errors. -Finished in ms on 1 file with 64 rules using 1 threads. +Finished in ms on 1 file with 65 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/crates/oxc_linter/src/generated/rule_runner_impls.rs b/crates/oxc_linter/src/generated/rule_runner_impls.rs index 9c12119fafc7e..81faababcbb33 100644 --- a/crates/oxc_linter/src/generated/rule_runner_impls.rs +++ b/crates/oxc_linter/src/generated/rule_runner_impls.rs @@ -633,6 +633,11 @@ impl RuleRunner for crate::rules::eslint::prefer_template::PreferTemplate { Some(&AstTypesBitset::from_types(&[AstType::BinaryExpression])); } +impl RuleRunner for crate::rules::eslint::preserve_caught_error::PreserveCaughtError { + const NODE_TYPES: Option<&AstTypesBitset> = + Some(&AstTypesBitset::from_types(&[AstType::TryStatement])); +} + impl RuleRunner for crate::rules::eslint::radix::Radix { const NODE_TYPES: Option<&AstTypesBitset> = Some(&AstTypesBitset::from_types(&[AstType::CallExpression])); diff --git a/crates/oxc_linter/src/rules.rs b/crates/oxc_linter/src/rules.rs index e829278b1a511..eca840b366a84 100644 --- a/crates/oxc_linter/src/rules.rs +++ b/crates/oxc_linter/src/rules.rs @@ -177,6 +177,7 @@ pub(crate) mod eslint { pub mod prefer_rest_params; pub mod prefer_spread; pub mod prefer_template; + pub mod preserve_caught_error; pub mod radix; pub mod require_await; pub mod require_yield; @@ -771,6 +772,7 @@ oxc_macros::declare_all_lint_rules! { eslint::prefer_object_spread, eslint::prefer_rest_params, eslint::prefer_spread, + eslint::preserve_caught_error, eslint::radix, eslint::require_await, eslint::require_yield, diff --git a/crates/oxc_linter/src/rules/eslint/preserve_caught_error.rs b/crates/oxc_linter/src/rules/eslint/preserve_caught_error.rs new file mode 100644 index 0000000000000..f2de008b19509 --- /dev/null +++ b/crates/oxc_linter/src/rules/eslint/preserve_caught_error.rs @@ -0,0 +1,591 @@ +use oxc_ast::AstKind; +use oxc_ast::ast::{ + Argument, BindingPattern, CatchClause, Expression, ObjectExpression, ObjectPropertyKind, + PropertyKey, Statement, ThrowStatement, TryStatement, +}; +use oxc_diagnostics::OxcDiagnostic; +use oxc_macros::declare_oxc_lint; +use oxc_semantic::IsGlobalReference; +use oxc_span::Span; +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; + +use crate::{AstNode, context::LintContext, rule::Rule}; + +fn preserve_caught_error_diagnostic(span: Span) -> OxcDiagnostic { + OxcDiagnostic::warn("preserve-caught-error") + .with_help( + "When re-throwing an error, preserve the original error using the 'cause' property", + ) + .with_label(span) +} + +fn missing_catch_parameter_diagnostic(span: Span) -> OxcDiagnostic { + OxcDiagnostic::warn("preserve-caught-error") + .with_help("Catch clause must have a parameter when 'requireCatchParameter' is enabled") + .with_label(span) +} + +#[derive(Debug, Default, Clone, Serialize, Deserialize, JsonSchema)] +#[schemars(rename_all = "camelCase")] +#[serde(rename_all = "camelCase")] +struct ConfigElement0 { + require_catch_parameter: bool, +} + +#[derive(Debug, Default, Clone, Serialize, Deserialize, JsonSchema)] +pub struct PreserveCaughtError(ConfigElement0); + +// Helper functions - global scope for better reusability and testing + +// Recursively check statements for throw expressions +fn check_statement<'a>( + stmt: &Statement<'a>, + catch_param: &BindingPattern<'a>, + ctx: &LintContext<'a>, +) { + match stmt { + Statement::ThrowStatement(throw_stmt) => { + check_throw_statement(throw_stmt, catch_param, ctx); + } + Statement::IfStatement(if_stmt) => { + check_statement(&if_stmt.consequent, catch_param, ctx); + if let Some(alternate) = &if_stmt.alternate { + check_statement(alternate, catch_param, ctx); + } + } + Statement::WhileStatement(while_stmt) => { + check_statement(&while_stmt.body, catch_param, ctx); + } + Statement::ForStatement(for_stmt) => { + check_statement(&for_stmt.body, catch_param, ctx); + } + Statement::BlockStatement(block_stmt) => { + for stmt in &block_stmt.body { + check_statement(stmt, catch_param, ctx); + } + } + Statement::SwitchStatement(switch_stmt) => { + for case in &switch_stmt.cases { + for stmt in &case.consequent { + check_statement(stmt, catch_param, ctx); + } + } + } + Statement::LabeledStatement(label_stmt) => { + check_statement(&label_stmt.body, catch_param, ctx); + } + _ => {} + } +} + +// Check if a throw statement re-throws built-in errors without preserving the original +fn check_throw_statement<'a>( + throw_stmt: &ThrowStatement<'a>, + catch_param: &BindingPattern<'a>, + ctx: &LintContext<'a>, +) { + let (callee, args) = match &throw_stmt.argument { + Expression::NewExpression(new_expr) => (&new_expr.callee, &new_expr.arguments), + Expression::CallExpression(call_expr) => (&call_expr.callee, &call_expr.arguments), + _ => return, + }; + + if !is_builtin_error_constructor(callee, ctx) { + return; + } + + // Check if second argument has proper cause property + if let Some(Argument::ObjectExpression(obj_expr)) = args.get(1) { + if has_cause_property(obj_expr, catch_param, ctx) { + return; + } + } + + // Allow spread arguments - they may contain cause property + if args.iter().any(|arg| matches!(arg, Argument::SpreadElement(_))) { + return; + } + + ctx.diagnostic(preserve_caught_error_diagnostic(throw_stmt.span)); +} + +// Check if expression is a built-in Error constructor +fn is_builtin_error_constructor(expr: &Expression, ctx: &LintContext) -> bool { + let Expression::Identifier(ident) = expr else { + return false; + }; + + ident.is_global_reference_name("Error", ctx.scoping()) + || ident.is_global_reference_name("TypeError", ctx.scoping()) + || ident.is_global_reference_name("AggregateError", ctx.scoping()) +} + +// Check if object expression has a 'cause' property with the catch parameter +fn has_cause_property( + obj_expr: &ObjectExpression, + catch_param: &BindingPattern, + ctx: &LintContext, +) -> bool { + for prop in &obj_expr.properties { + match prop { + ObjectPropertyKind::ObjectProperty(prop) => { + let PropertyKey::StaticIdentifier(ident) = &prop.key else { + continue; + }; + if ident.name == "cause" { + return is_catch_parameter(&prop.value, catch_param, ctx); + } + } + // Spread properties might contain cause + ObjectPropertyKind::SpreadProperty(_) => return true, + } + } + false +} + +// Check if expression references the catch parameter +fn is_catch_parameter(expr: &Expression, catch_param: &BindingPattern, ctx: &LintContext) -> bool { + // Only handle simple identifier catch parameters for now + let oxc_ast::ast::BindingPatternKind::BindingIdentifier(binding) = &catch_param.kind else { + return false; // Destructuring patterns not supported + }; + + let Some(catch_symbol_id) = binding.symbol_id.get() else { + return false; + }; + + let Expression::Identifier(ident) = expr else { + return false; + }; + + let Some(reference_id) = ident.reference_id.get() else { + return false; + }; + + let reference = ctx.scoping().get_reference(reference_id); + let Some(symbol_id) = reference.symbol_id() else { + return false; + }; + + symbol_id == catch_symbol_id +} + +declare_oxc_lint!( + /// ### What it does + /// + /// Enforces that when re-throwing an error in a catch block, the original error + /// is preserved using the 'cause' property. + /// + /// ### Why is this bad? + /// + /// Re-throwing an error without preserving the original error loses important + /// debugging information and makes it harder to trace the root cause of issues. + /// + /// ### Examples + /// + /// Examples of **incorrect** code for this rule: + /// ```js + /// try { + /// doSomething(); + /// } catch (err) { + /// throw new Error("Something failed"); + /// } + /// ``` + /// + /// Examples of **correct** code for this rule: + /// ```js + /// try { + /// doSomething(); + /// } catch (err) { + /// throw new Error("Something failed", { cause: err }); + /// } + /// ``` + PreserveCaughtError, + eslint, + correctness, + pending, + config = ConfigElement0, +); +impl PreserveCaughtError { + fn check_try_statement<'a>(&self, try_stmt: &TryStatement<'a>, ctx: &LintContext<'a>) { + if let Some(catch_clause) = &try_stmt.handler { + self.check_catch_clause(catch_clause, ctx); + } + } + + fn check_catch_clause<'a>(&self, catch_clause: &CatchClause<'a>, ctx: &LintContext<'a>) { + if let Some(catch_param) = &catch_clause.param { + for stmt in &catch_clause.body.body { + check_statement(stmt, &catch_param.pattern, ctx); + } + } else if self.0.require_catch_parameter { + ctx.diagnostic(missing_catch_parameter_diagnostic(catch_clause.span)); + } + } +} + +impl Rule for PreserveCaughtError { + fn from_configuration(value: serde_json::Value) -> Self { + if value.is_null() { + return Self::default(); + } + + let Some(config_array) = value.as_array() else { + return serde_json::from_value(value).unwrap_or_default(); + }; + + let Some(config_obj) = config_array.first() else { + return Self::default(); + }; + + serde_json::from_value(config_obj.clone()).unwrap_or_default() + } + + fn run<'a>(&self, node: &AstNode<'a>, ctx: &LintContext<'a>) { + let AstKind::TryStatement(try_stmt) = node.kind() else { + return; + }; + self.check_try_statement(try_stmt, ctx); + } +} + +#[test] +fn test() { + use crate::tester::Tester; + + let pass = vec![ + ( + r#"try { + throw new Error("Original error"); + } catch (error) { + throw new Error("Failed to perform error prone operations", { cause: error }); + }"#, + None, + ), + ( + "try { + doSomething(); + } catch (e) { + console.error(e); + }", + None, + ), + ( + r#"try { + doSomething(); + } catch (err) { + throw new Error("Failed", { cause: err, extra: 42 }); + }"#, + None, + ), + ( + r#"try { + doSomething(); + } catch (error) { + switch (error.code) { + case "A": + throw new Error("Type A", { cause: error }); + case "B": + throw new Error("Type B", { cause: error }); + default: + throw new Error("Other", { cause: error }); + } + }"#, + None, + ), + ( + r#"try { + // ... + } catch (err) { + const opts = { cause: err } + throw new Error("msg", { ...opts }); + } + "#, + None, + ), + ( + "try { + } catch (error) { + foo = { + bar() { + throw new Error(); + } + }; + }", + None, + ), + ( + "try { + doSomething(); + } catch (error) { + const args = []; + throw new Error(...args); + }", + None, + ), + ( + r#"import { Error } from "./my-custom-error.js"; + try { + doSomething(); + } catch (error) { + throw Error("Failed to perform error prone operations"); + }"#, + None, + ), + ( + r#"try { + doSomething(); + } catch { + throw new Error("Something went wrong"); + }"#, + Some(serde_json::json!([{ "requireCatchParameter": false }])), + ), + ]; + + let fail = vec![ + ( + r#"try { + doSomething(); + } catch (err) { + throw new Error("Something failed"); + }"#, + None, + ), + ( + r#"try { + doSomething(); + } catch (err) { + const unrelated = new Error("other"); + throw new Error("Something failed", { cause: unrelated }); + }"#, + None, + ), + ( + r#"try { + doSomething(); + } catch (err) { + const e = err; + throw new Error("Failed", { cause: e }); + }"#, + None, + ), + ( + r#"try { + doSomething(); + } catch (error) { + throw new Error("Failed", { cause: error.message }); + }"#, + None, + ), + ( + r#"try { + doSomething(); + } catch (error) { + if (shouldThrow) { + while (true) { + if (Math.random() > 0.5) { + throw new Error("Failed without cause"); + } + } + } + }"#, + None, + ), + ( + r#"try { + doSomething(); + } catch (error) { + switch (error.code) { + case "A": + throw new Error("Type A"); + case "B": + throw new Error("Type B", { cause: error }); + default: + throw new Error("Other", { cause: error }); + } + }"#, + None, + ), + ( + r#"try { + doSomething(); + } catch (error) { + throw new Error(`The certificate key "${chalk.yellow(keyFile)}" is invalid. + ${err.message}`); + }"#, + None, + ), + ( + r#"try { + doSomething(); + } catch (error) { + const errorMessage = "Operation failed"; + throw new Error(errorMessage); + }"#, + None, + ), + ( + r#"try { + doSomething(); + } catch (error) { + const errorMessage = "Operation failed"; + throw new Error(errorMessage, { existingOption: true, complexOption: { moreOptions: {} } }); + }"#, + None, + ), + ( + r#"try { + doSomething(); + } catch (err) { + if (err.code === "A") { + throw new Error("Type A"); + } + throw new TypeError("Fallback error"); + }"#, + None, + ), + ( + r#"try { + doSomething(); + } catch (err) { + throw Error("Something failed"); + }"#, + None, + ), + ( + r#"try { + } catch (err) { + my_label: + throw new Error("Failed without cause"); + }"#, + None, + ), + ( + r#"try { + } catch (err) { + { + throw new Error("Something went wrong"); + } + }"#, + None, + ), + ( + "try { + } catch (err) { + { + throw new Error(); + } + }", + None, + ), + ( + r#"try { + } catch (err) { + { + throw new AggregateError([], "Lorem ipsum"); + } + }"#, + None, + ), + ( + "try { + } catch (err) { + { + throw new AggregateError(); + } + }", + None, + ), + ( + "try { + } catch (err) { + { + throw new AggregateError([]); + } + }", + None, + ), + ( + r#"try { + doSomething(); + } catch { + throw new Error("Something went wrong"); + }"#, + Some(serde_json::json!([{ "requireCatchParameter": true }])), + ), + ( + r#"try { + doSomething(); + } catch (err) { + throw new Error("Something failed", { cause }); + }"#, + None, + ), + ( + "try { + doSomething(); + } catch ({ message }) { + throw new Error(message); + }", + None, + ), + ( + "try { + doSomethingElse(); + } catch ({ ...error }) { + throw new Error(error.message); + }", + None, + ), + ( + r#"try { + doSomething(); + } catch (error) { + if (whatever) { + const error = anotherError; + throw new Error("Something went wrong", { cause: error }); + } + }"#, + None, + ), + ( + r#"try { + doSomething(); + } catch (error) { + throw new Error( + "Something went wrong" // some comments + ); + }"#, + None, + ), + ( + r#"try { + doSomething(); + } catch (err) { + throw new Error("Something failed", {}); + }"#, + None, + ), + ( + r#"try { + doSomething(); + } catch (error) { + const cause = "desc"; + throw new Error("Something failed", { [cause]: "Some error" }); + }"#, + None, + ), + ( + r#"try { + doSomething(); + } catch (error) { + throw new Error("Something failed", { cause() { /* do something */ } }); + }"#, + None, + ), + ]; + + Tester::new(PreserveCaughtError::NAME, PreserveCaughtError::PLUGIN, pass, fail) + .test_and_snapshot(); +} diff --git a/crates/oxc_linter/src/snapshots/eslint_preserve_caught_error.snap b/crates/oxc_linter/src/snapshots/eslint_preserve_caught_error.snap new file mode 100644 index 0000000000000..ffed53bde38dc --- /dev/null +++ b/crates/oxc_linter/src/snapshots/eslint_preserve_caught_error.snap @@ -0,0 +1,246 @@ +--- +source: crates/oxc_linter/src/tester.rs +--- + ⚠ eslint(preserve-caught-error): preserve-caught-error + ╭─[preserve_caught_error.tsx:4:16] + 3 │ } catch (err) { + 4 │ throw new Error("Something failed"); + · ──────────────────────────────────── + 5 │ } + ╰──── + help: When re-throwing an error, preserve the original error using the 'cause' property + + ⚠ eslint(preserve-caught-error): preserve-caught-error + ╭─[preserve_caught_error.tsx:5:16] + 4 │ const unrelated = new Error("other"); + 5 │ throw new Error("Something failed", { cause: unrelated }); + · ────────────────────────────────────────────────────────── + 6 │ } + ╰──── + help: When re-throwing an error, preserve the original error using the 'cause' property + + ⚠ eslint(preserve-caught-error): preserve-caught-error + ╭─[preserve_caught_error.tsx:5:16] + 4 │ const e = err; + 5 │ throw new Error("Failed", { cause: e }); + · ──────────────────────────────────────── + 6 │ } + ╰──── + help: When re-throwing an error, preserve the original error using the 'cause' property + + ⚠ eslint(preserve-caught-error): preserve-caught-error + ╭─[preserve_caught_error.tsx:4:16] + 3 │ } catch (error) { + 4 │ throw new Error("Failed", { cause: error.message }); + · ──────────────────────────────────────────────────── + 5 │ } + ╰──── + help: When re-throwing an error, preserve the original error using the 'cause' property + + ⚠ eslint(preserve-caught-error): preserve-caught-error + ╭─[preserve_caught_error.tsx:7:28] + 6 │ if (Math.random() > 0.5) { + 7 │ throw new Error("Failed without cause"); + · ──────────────────────────────────────── + 8 │ } + ╰──── + help: When re-throwing an error, preserve the original error using the 'cause' property + + ⚠ eslint(preserve-caught-error): preserve-caught-error + ╭─[preserve_caught_error.tsx:6:24] + 5 │ case "A": + 6 │ throw new Error("Type A"); + · ────────────────────────── + 7 │ case "B": + ╰──── + help: When re-throwing an error, preserve the original error using the 'cause' property + + ⚠ eslint(preserve-caught-error): preserve-caught-error + ╭─[preserve_caught_error.tsx:4:16] + 3 │ } catch (error) { + 4 │ ╭─▶ throw new Error(`The certificate key "${chalk.yellow(keyFile)}" is invalid. + 5 │ ╰─▶ ${err.message}`); + 6 │ } + ╰──── + help: When re-throwing an error, preserve the original error using the 'cause' property + + ⚠ eslint(preserve-caught-error): preserve-caught-error + ╭─[preserve_caught_error.tsx:5:16] + 4 │ const errorMessage = "Operation failed"; + 5 │ throw new Error(errorMessage); + · ────────────────────────────── + 6 │ } + ╰──── + help: When re-throwing an error, preserve the original error using the 'cause' property + + ⚠ eslint(preserve-caught-error): preserve-caught-error + ╭─[preserve_caught_error.tsx:5:16] + 4 │ const errorMessage = "Operation failed"; + 5 │ throw new Error(errorMessage, { existingOption: true, complexOption: { moreOptions: {} } }); + · ──────────────────────────────────────────────────────────────────────────────────────────── + 6 │ } + ╰──── + help: When re-throwing an error, preserve the original error using the 'cause' property + + ⚠ eslint(preserve-caught-error): preserve-caught-error + ╭─[preserve_caught_error.tsx:5:20] + 4 │ if (err.code === "A") { + 5 │ throw new Error("Type A"); + · ────────────────────────── + 6 │ } + ╰──── + help: When re-throwing an error, preserve the original error using the 'cause' property + + ⚠ eslint(preserve-caught-error): preserve-caught-error + ╭─[preserve_caught_error.tsx:7:16] + 6 │ } + 7 │ throw new TypeError("Fallback error"); + · ────────────────────────────────────── + 8 │ } + ╰──── + help: When re-throwing an error, preserve the original error using the 'cause' property + + ⚠ eslint(preserve-caught-error): preserve-caught-error + ╭─[preserve_caught_error.tsx:4:16] + 3 │ } catch (err) { + 4 │ throw Error("Something failed"); + · ──────────────────────────────── + 5 │ } + ╰──── + help: When re-throwing an error, preserve the original error using the 'cause' property + + ⚠ eslint(preserve-caught-error): preserve-caught-error + ╭─[preserve_caught_error.tsx:4:16] + 3 │ my_label: + 4 │ throw new Error("Failed without cause"); + · ──────────────────────────────────────── + 5 │ } + ╰──── + help: When re-throwing an error, preserve the original error using the 'cause' property + + ⚠ eslint(preserve-caught-error): preserve-caught-error + ╭─[preserve_caught_error.tsx:4:20] + 3 │ { + 4 │ throw new Error("Something went wrong"); + · ──────────────────────────────────────── + 5 │ } + ╰──── + help: When re-throwing an error, preserve the original error using the 'cause' property + + ⚠ eslint(preserve-caught-error): preserve-caught-error + ╭─[preserve_caught_error.tsx:4:20] + 3 │ { + 4 │ throw new Error(); + · ────────────────── + 5 │ } + ╰──── + help: When re-throwing an error, preserve the original error using the 'cause' property + + ⚠ eslint(preserve-caught-error): preserve-caught-error + ╭─[preserve_caught_error.tsx:4:20] + 3 │ { + 4 │ throw new AggregateError([], "Lorem ipsum"); + · ──────────────────────────────────────────── + 5 │ } + ╰──── + help: When re-throwing an error, preserve the original error using the 'cause' property + + ⚠ eslint(preserve-caught-error): preserve-caught-error + ╭─[preserve_caught_error.tsx:4:20] + 3 │ { + 4 │ throw new AggregateError(); + · ─────────────────────────── + 5 │ } + ╰──── + help: When re-throwing an error, preserve the original error using the 'cause' property + + ⚠ eslint(preserve-caught-error): preserve-caught-error + ╭─[preserve_caught_error.tsx:4:20] + 3 │ { + 4 │ throw new AggregateError([]); + · ───────────────────────────── + 5 │ } + ╰──── + help: When re-throwing an error, preserve the original error using the 'cause' property + + ⚠ eslint(preserve-caught-error): preserve-caught-error + ╭─[preserve_caught_error.tsx:3:8] + 2 │ doSomething(); + 3 │ ╭─▶ } catch { + 4 │ │ throw new Error("Something went wrong"); + 5 │ ╰─▶ } + ╰──── + help: Catch clause must have a parameter when 'requireCatchParameter' is enabled + + ⚠ eslint(preserve-caught-error): preserve-caught-error + ╭─[preserve_caught_error.tsx:4:16] + 3 │ } catch (err) { + 4 │ throw new Error("Something failed", { cause }); + · ─────────────────────────────────────────────── + 5 │ } + ╰──── + help: When re-throwing an error, preserve the original error using the 'cause' property + + ⚠ eslint(preserve-caught-error): preserve-caught-error + ╭─[preserve_caught_error.tsx:4:8] + 3 │ } catch ({ message }) { + 4 │ throw new Error(message); + · ───────────────────────── + 5 │ } + ╰──── + help: When re-throwing an error, preserve the original error using the 'cause' property + + ⚠ eslint(preserve-caught-error): preserve-caught-error + ╭─[preserve_caught_error.tsx:4:8] + 3 │ } catch ({ ...error }) { + 4 │ throw new Error(error.message); + · ─────────────────────────────── + 5 │ } + ╰──── + help: When re-throwing an error, preserve the original error using the 'cause' property + + ⚠ eslint(preserve-caught-error): preserve-caught-error + ╭─[preserve_caught_error.tsx:6:9] + 5 │ const error = anotherError; + 6 │ throw new Error("Something went wrong", { cause: error }); + · ────────────────────────────────────────────────────────── + 7 │ } + ╰──── + help: When re-throwing an error, preserve the original error using the 'cause' property + + ⚠ eslint(preserve-caught-error): preserve-caught-error + ╭─[preserve_caught_error.tsx:4:8] + 3 │ } catch (error) { + 4 │ ╭─▶ throw new Error( + 5 │ │ "Something went wrong" // some comments + 6 │ ╰─▶ ); + 7 │ } + ╰──── + help: When re-throwing an error, preserve the original error using the 'cause' property + + ⚠ eslint(preserve-caught-error): preserve-caught-error + ╭─[preserve_caught_error.tsx:4:8] + 3 │ } catch (err) { + 4 │ throw new Error("Something failed", {}); + · ──────────────────────────────────────── + 5 │ } + ╰──── + help: When re-throwing an error, preserve the original error using the 'cause' property + + ⚠ eslint(preserve-caught-error): preserve-caught-error + ╭─[preserve_caught_error.tsx:5:7] + 4 │ const cause = "desc"; + 5 │ throw new Error("Something failed", { [cause]: "Some error" }); + · ─────────────────────────────────────────────────────────────── + 6 │ } + ╰──── + help: When re-throwing an error, preserve the original error using the 'cause' property + + ⚠ eslint(preserve-caught-error): preserve-caught-error + ╭─[preserve_caught_error.tsx:4:7] + 3 │ } catch (error) { + 4 │ throw new Error("Something failed", { cause() { /* do something */ } }); + · ───────────────────────────────────────────────────────────────────────── + 5 │ } + ╰──── + help: When re-throwing an error, preserve the original error using the 'cause' property From abba09ef81055c0dc8ed76199360bc0a9bc67182 Mon Sep 17 00:00:00 2001 From: xiaokhkh <727070793@qq.com> Date: Mon, 15 Sep 2025 23:50:54 +0800 Subject: [PATCH 2/2] refactor: use visitor insteadof iterator. modify category to suspicious --- ...gnore fixtures__linter__nan.js@oxlint.snap | 2 +- ...ern _____.vue fixtures__linter@oxlint.snap | 2 +- ...l -D no-cycle fixtures__flow__@oxlint.snap | 2 +- ...ugin fixtures__flow__index.mjs@oxlint.snap | 2 +- ...rc_vitest_replace__foo.test.js@oxlint.snap | 2 +- ... fixtures__linter__debugger.js@oxlint.snap | 2 +- ... fixtures__linter__debugger.js@oxlint.snap | 2 +- ...ixtures__eslintrc_env__test.js@oxlint.snap | 2 +- ...on fixtures__no_undef__test.js@oxlint.snap | 2 +- ...ore_patterns__ignore_extension@oxlint.snap | 2 +- ...rns__ignore_extension__main.js@oxlint.snap | 2 +- ...ixtures__eslintrc_env__test.js@oxlint.snap | 2 +- ...ixtures__eslintrc_off__test.js@oxlint.snap | 2 +- ...rc_vitest_replace__foo.test.js@oxlint.snap | 2 +- ... fixtures__linter__debugger.js@oxlint.snap | 2 +- ...tures__no_console_off__test.js@oxlint.snap | 2 +- ...pty_allow_empty_catch__test.js@oxlint.snap | 2 +- ..._disallow_empty_catch__test.js@oxlint.snap | 2 +- ...fixtures__overrides__other.jsx@oxlint.snap | 6 +- ...onfig.json fixtures__overrides@oxlint.snap | 2 +- ...es__typescript_eslint__test.ts@oxlint.snap | 2 +- ...es__typescript_eslint__test.ts@oxlint.snap | 2 +- ...ixtures__astro__debugger.astro@oxlint.snap | 2 +- .../snapshots/_fixtures__linter@oxlint.snap | 2 +- ...er.js fixtures__linter__nan.js@oxlint.snap | 2 +- ..._fixtures__linter__debugger.js@oxlint.snap | 2 +- ...fixtures__linter__js_as_jsx.js@oxlint.snap | 2 +- ...tures__svelte__debugger.svelte@oxlint.snap | 2 +- .../_fixtures__vue__debugger.vue@oxlint.snap | 2 +- .../_fixtures__vue__empty.vue@oxlint.snap | 2 +- .../src/snapshots/_foo.asdf@oxlint.snap | 2 +- ...ore_directory_-c eslintrc.json@oxlint.snap | 2 +- ...c.json --ignore-pattern _.ts .@oxlint.snap | 2 +- ....oxlintrc-unicorn.json test.js@oxlint.snap | 4 +- .../fixtures__dot_folder_@oxlint.snap | 2 +- ...s_rules_config.json console.js@oxlint.snap | 2 +- ...extends_config.json console.js@oxlint.snap | 2 +- ...config_--disable-nested-config@oxlint.snap | 2 +- ...ort-plugin -D import__no-cycle@oxlint.snap | 2 +- ...oxlintrc-import-x.json test.js@oxlint.snap | 4 +- ..._issue_10394_-c .oxlintrc.json@oxlint.snap | 2 +- ..._issue_11054_-c .oxlintrc.json@oxlint.snap | 2 +- ..._issue_11644_-c .oxlintrc.json@oxlint.snap | 2 +- .../fixtures__linter_debugger.js@oxlint.snap | 2 +- ...nv_globals_-c .oxlintrc.json .@oxlint.snap | 2 +- ..._with_plugin_-c .oxlintrc.json@oxlint.snap | 2 +- ...sed-disable-directives test.js@oxlint.snap | 2 +- ...name_-c .oxlintrc.json test.js@oxlint.snap | 2 +- .../src/rules/eslint/preserve_caught_error.rs | 113 ++++++------------ 49 files changed, 87 insertions(+), 130 deletions(-) diff --git a/apps/oxlint/src/snapshots/_--ignore-path fixtures__linter__.customignore --no-ignore fixtures__linter__nan.js@oxlint.snap b/apps/oxlint/src/snapshots/_--ignore-path fixtures__linter__.customignore --no-ignore fixtures__linter__nan.js@oxlint.snap index 96f5f42b881a6..14d5edc37b894 100644 --- a/apps/oxlint/src/snapshots/_--ignore-path fixtures__linter__.customignore --no-ignore fixtures__linter__nan.js@oxlint.snap +++ b/apps/oxlint/src/snapshots/_--ignore-path fixtures__linter__.customignore --no-ignore fixtures__linter__nan.js@oxlint.snap @@ -14,7 +14,7 @@ working directory: help: Use the isNaN function to compare with NaN. Found 1 warning and 0 errors. -Finished in ms on 1 file with 89 rules using 1 threads. +Finished in ms on 1 file with 88 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/_--ignore-pattern _____.js --ignore-pattern _____.vue fixtures__linter@oxlint.snap b/apps/oxlint/src/snapshots/_--ignore-pattern _____.js --ignore-pattern _____.vue fixtures__linter@oxlint.snap index 6f72f11c56089..4df9f6236759d 100644 --- a/apps/oxlint/src/snapshots/_--ignore-pattern _____.js --ignore-pattern _____.vue fixtures__linter@oxlint.snap +++ b/apps/oxlint/src/snapshots/_--ignore-pattern _____.js --ignore-pattern _____.vue fixtures__linter@oxlint.snap @@ -6,7 +6,7 @@ arguments: --ignore-pattern **/*.js --ignore-pattern **/*.vue fixtures/linter working directory: ---------- Found 0 warnings and 0 errors. -Finished in ms on 0 files with 89 rules using 1 threads. +Finished in ms on 0 files with 88 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/_--import-plugin -A all -D no-cycle fixtures__flow__@oxlint.snap b/apps/oxlint/src/snapshots/_--import-plugin -A all -D no-cycle fixtures__flow__@oxlint.snap index 91b8e3942dc74..6b279aaf7880d 100644 --- a/apps/oxlint/src/snapshots/_--import-plugin -A all -D no-cycle fixtures__flow__@oxlint.snap +++ b/apps/oxlint/src/snapshots/_--import-plugin -A all -D no-cycle fixtures__flow__@oxlint.snap @@ -6,7 +6,7 @@ arguments: --import-plugin -A all -D no-cycle fixtures/flow/ working directory: ---------- Found 0 warnings and 0 errors. -Finished in ms on 2 files with 91 rules using 1 threads. +Finished in ms on 2 files with 90 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/_--import-plugin fixtures__flow__index.mjs@oxlint.snap b/apps/oxlint/src/snapshots/_--import-plugin fixtures__flow__index.mjs@oxlint.snap index 8374a8a41ed5a..cfceefea6e34f 100644 --- a/apps/oxlint/src/snapshots/_--import-plugin fixtures__flow__index.mjs@oxlint.snap +++ b/apps/oxlint/src/snapshots/_--import-plugin fixtures__flow__index.mjs@oxlint.snap @@ -6,7 +6,7 @@ arguments: --import-plugin fixtures/flow/index.mjs working directory: ---------- Found 0 warnings and 0 errors. -Finished in ms on 1 file with 91 rules using 1 threads. +Finished in ms on 1 file with 90 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/_--vitest-plugin -c fixtures__eslintrc_vitest_replace__eslintrc.json fixtures__eslintrc_vitest_replace__foo.test.js@oxlint.snap b/apps/oxlint/src/snapshots/_--vitest-plugin -c fixtures__eslintrc_vitest_replace__eslintrc.json fixtures__eslintrc_vitest_replace__foo.test.js@oxlint.snap index 8d8ea6722e75a..c4d380529edec 100644 --- a/apps/oxlint/src/snapshots/_--vitest-plugin -c fixtures__eslintrc_vitest_replace__eslintrc.json fixtures__eslintrc_vitest_replace__foo.test.js@oxlint.snap +++ b/apps/oxlint/src/snapshots/_--vitest-plugin -c fixtures__eslintrc_vitest_replace__eslintrc.json fixtures__eslintrc_vitest_replace__foo.test.js@oxlint.snap @@ -23,7 +23,7 @@ working directory: help: Remove the appending `.skip` Found 1 warning and 1 error. -Finished in ms on 1 file with 101 rules using 1 threads. +Finished in ms on 1 file with 100 rules using 1 threads. ---------- CLI result: LintFoundErrors ---------- diff --git a/apps/oxlint/src/snapshots/_-D correctness fixtures__linter__debugger.js@oxlint.snap b/apps/oxlint/src/snapshots/_-D correctness fixtures__linter__debugger.js@oxlint.snap index 7455b2d26efd0..e8a7439a56489 100644 --- a/apps/oxlint/src/snapshots/_-D correctness fixtures__linter__debugger.js@oxlint.snap +++ b/apps/oxlint/src/snapshots/_-D correctness fixtures__linter__debugger.js@oxlint.snap @@ -14,7 +14,7 @@ working directory: help: Remove the debugger statement Found 0 warnings and 1 error. -Finished in ms on 1 file with 89 rules using 1 threads. +Finished in ms on 1 file with 88 rules using 1 threads. ---------- CLI result: LintFoundErrors ---------- diff --git a/apps/oxlint/src/snapshots/_-W correctness -A no-debugger fixtures__linter__debugger.js@oxlint.snap b/apps/oxlint/src/snapshots/_-W correctness -A no-debugger fixtures__linter__debugger.js@oxlint.snap index 25b62837f3535..7d865615b1c26 100644 --- a/apps/oxlint/src/snapshots/_-W correctness -A no-debugger fixtures__linter__debugger.js@oxlint.snap +++ b/apps/oxlint/src/snapshots/_-W correctness -A no-debugger fixtures__linter__debugger.js@oxlint.snap @@ -6,7 +6,7 @@ arguments: -W correctness -A no-debugger fixtures/linter/debugger.js working directory: ---------- Found 0 warnings and 0 errors. -Finished in ms on 1 file with 88 rules using 1 threads. +Finished in ms on 1 file with 87 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/_-W no-undef -c fixtures__eslintrc_env__eslintrc_no_env.json fixtures__eslintrc_env__test.js@oxlint.snap b/apps/oxlint/src/snapshots/_-W no-undef -c fixtures__eslintrc_env__eslintrc_no_env.json fixtures__eslintrc_env__test.js@oxlint.snap index a759468185a81..0d3edb0f3f202 100644 --- a/apps/oxlint/src/snapshots/_-W no-undef -c fixtures__eslintrc_env__eslintrc_no_env.json fixtures__eslintrc_env__test.js@oxlint.snap +++ b/apps/oxlint/src/snapshots/_-W no-undef -c fixtures__eslintrc_env__eslintrc_no_env.json fixtures__eslintrc_env__test.js@oxlint.snap @@ -13,7 +13,7 @@ working directory: `---- Found 1 warning and 0 errors. -Finished in ms on 1 file with 90 rules using 1 threads. +Finished in ms on 1 file with 89 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/_-W no-undef -c fixtures__no_undef__eslintrc.json fixtures__no_undef__test.js@oxlint.snap b/apps/oxlint/src/snapshots/_-W no-undef -c fixtures__no_undef__eslintrc.json fixtures__no_undef__test.js@oxlint.snap index 2ec8506bdf335..d8e1263173caa 100644 --- a/apps/oxlint/src/snapshots/_-W no-undef -c fixtures__no_undef__eslintrc.json fixtures__no_undef__test.js@oxlint.snap +++ b/apps/oxlint/src/snapshots/_-W no-undef -c fixtures__no_undef__eslintrc.json fixtures__no_undef__test.js@oxlint.snap @@ -13,7 +13,7 @@ working directory: `---- Found 1 warning and 0 errors. -Finished in ms on 1 file with 90 rules using 1 threads. +Finished in ms on 1 file with 89 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/_-c fixtures__config_ignore_patterns__ignore_extension__eslintrc.json fixtures__config_ignore_patterns__ignore_extension@oxlint.snap b/apps/oxlint/src/snapshots/_-c fixtures__config_ignore_patterns__ignore_extension__eslintrc.json fixtures__config_ignore_patterns__ignore_extension@oxlint.snap index cb5da05408814..94ff47a62435e 100644 --- a/apps/oxlint/src/snapshots/_-c fixtures__config_ignore_patterns__ignore_extension__eslintrc.json fixtures__config_ignore_patterns__ignore_extension@oxlint.snap +++ b/apps/oxlint/src/snapshots/_-c fixtures__config_ignore_patterns__ignore_extension__eslintrc.json fixtures__config_ignore_patterns__ignore_extension@oxlint.snap @@ -12,7 +12,7 @@ working directory: help: Delete this file or add some code to it. Found 1 warning and 0 errors. -Finished in ms on 1 file with 89 rules using 1 threads. +Finished in ms on 1 file with 88 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/_-c fixtures__config_ignore_patterns__ignore_extension__eslintrc.json fixtures__config_ignore_patterns__ignore_extension__main.js@oxlint.snap b/apps/oxlint/src/snapshots/_-c fixtures__config_ignore_patterns__ignore_extension__eslintrc.json fixtures__config_ignore_patterns__ignore_extension__main.js@oxlint.snap index 97815492fafaa..27a14f783d989 100644 --- a/apps/oxlint/src/snapshots/_-c fixtures__config_ignore_patterns__ignore_extension__eslintrc.json fixtures__config_ignore_patterns__ignore_extension__main.js@oxlint.snap +++ b/apps/oxlint/src/snapshots/_-c fixtures__config_ignore_patterns__ignore_extension__eslintrc.json fixtures__config_ignore_patterns__ignore_extension__main.js@oxlint.snap @@ -6,7 +6,7 @@ arguments: -c fixtures/config_ignore_patterns/ignore_extension/eslintrc.json fix working directory: ---------- Found 0 warnings and 0 errors. -Finished in ms on 0 files with 89 rules using 1 threads. +Finished in ms on 0 files with 88 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/_-c fixtures__eslintrc_env__eslintrc_env_browser.json fixtures__eslintrc_env__test.js@oxlint.snap b/apps/oxlint/src/snapshots/_-c fixtures__eslintrc_env__eslintrc_env_browser.json fixtures__eslintrc_env__test.js@oxlint.snap index 8394a14d71b68..25501e80c4580 100644 --- a/apps/oxlint/src/snapshots/_-c fixtures__eslintrc_env__eslintrc_env_browser.json fixtures__eslintrc_env__test.js@oxlint.snap +++ b/apps/oxlint/src/snapshots/_-c fixtures__eslintrc_env__eslintrc_env_browser.json fixtures__eslintrc_env__test.js@oxlint.snap @@ -6,7 +6,7 @@ arguments: -c fixtures/eslintrc_env/eslintrc_env_browser.json fixtures/eslintrc_ working directory: ---------- Found 0 warnings and 0 errors. -Finished in ms on 1 file with 90 rules using 1 threads. +Finished in ms on 1 file with 89 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/_-c fixtures__eslintrc_off__eslintrc.json fixtures__eslintrc_off__test.js@oxlint.snap b/apps/oxlint/src/snapshots/_-c fixtures__eslintrc_off__eslintrc.json fixtures__eslintrc_off__test.js@oxlint.snap index c1765a94085f4..f4589994fed67 100644 --- a/apps/oxlint/src/snapshots/_-c fixtures__eslintrc_off__eslintrc.json fixtures__eslintrc_off__test.js@oxlint.snap +++ b/apps/oxlint/src/snapshots/_-c fixtures__eslintrc_off__eslintrc.json fixtures__eslintrc_off__test.js@oxlint.snap @@ -12,7 +12,7 @@ working directory: help: Delete this file or add some code to it. Found 1 warning and 0 errors. -Finished in ms on 1 file with 89 rules using 1 threads. +Finished in ms on 1 file with 88 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/_-c fixtures__eslintrc_vitest_replace__eslintrc.json fixtures__eslintrc_vitest_replace__foo.test.js@oxlint.snap b/apps/oxlint/src/snapshots/_-c fixtures__eslintrc_vitest_replace__eslintrc.json fixtures__eslintrc_vitest_replace__foo.test.js@oxlint.snap index 3d9e2534b2042..fa6cb18220a4b 100644 --- a/apps/oxlint/src/snapshots/_-c fixtures__eslintrc_vitest_replace__eslintrc.json fixtures__eslintrc_vitest_replace__foo.test.js@oxlint.snap +++ b/apps/oxlint/src/snapshots/_-c fixtures__eslintrc_vitest_replace__eslintrc.json fixtures__eslintrc_vitest_replace__foo.test.js@oxlint.snap @@ -6,7 +6,7 @@ arguments: -c fixtures/eslintrc_vitest_replace/eslintrc.json fixtures/eslintrc_v working directory: ---------- Found 0 warnings and 0 errors. -Finished in ms on 1 file with 89 rules using 1 threads. +Finished in ms on 1 file with 88 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/_-c fixtures__linter__eslintrc.json fixtures__linter__debugger.js@oxlint.snap b/apps/oxlint/src/snapshots/_-c fixtures__linter__eslintrc.json fixtures__linter__debugger.js@oxlint.snap index 555c316648462..afa75f25536d0 100644 --- a/apps/oxlint/src/snapshots/_-c fixtures__linter__eslintrc.json fixtures__linter__debugger.js@oxlint.snap +++ b/apps/oxlint/src/snapshots/_-c fixtures__linter__eslintrc.json fixtures__linter__debugger.js@oxlint.snap @@ -14,7 +14,7 @@ working directory: help: Remove the debugger statement Found 0 warnings and 1 error. -Finished in ms on 1 file with 89 rules using 1 threads. +Finished in ms on 1 file with 88 rules using 1 threads. ---------- CLI result: LintFoundErrors ---------- diff --git a/apps/oxlint/src/snapshots/_-c fixtures__no_console_off__eslintrc.json fixtures__no_console_off__test.js@oxlint.snap b/apps/oxlint/src/snapshots/_-c fixtures__no_console_off__eslintrc.json fixtures__no_console_off__test.js@oxlint.snap index 3d521921ff354..ec9911f1422e1 100644 --- a/apps/oxlint/src/snapshots/_-c fixtures__no_console_off__eslintrc.json fixtures__no_console_off__test.js@oxlint.snap +++ b/apps/oxlint/src/snapshots/_-c fixtures__no_console_off__eslintrc.json fixtures__no_console_off__test.js@oxlint.snap @@ -6,7 +6,7 @@ arguments: -c fixtures/no_console_off/eslintrc.json fixtures/no_console_off/test working directory: ---------- Found 0 warnings and 0 errors. -Finished in ms on 1 file with 89 rules using 1 threads. +Finished in ms on 1 file with 88 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/_-c fixtures__no_empty_allow_empty_catch__eslintrc.json -W no-empty fixtures__no_empty_allow_empty_catch__test.js@oxlint.snap b/apps/oxlint/src/snapshots/_-c fixtures__no_empty_allow_empty_catch__eslintrc.json -W no-empty fixtures__no_empty_allow_empty_catch__test.js@oxlint.snap index 3143d3c2efb85..44e6c594b0c26 100644 --- a/apps/oxlint/src/snapshots/_-c fixtures__no_empty_allow_empty_catch__eslintrc.json -W no-empty fixtures__no_empty_allow_empty_catch__test.js@oxlint.snap +++ b/apps/oxlint/src/snapshots/_-c fixtures__no_empty_allow_empty_catch__eslintrc.json -W no-empty fixtures__no_empty_allow_empty_catch__test.js@oxlint.snap @@ -6,7 +6,7 @@ arguments: -c fixtures/no_empty_allow_empty_catch/eslintrc.json -W no-empty fixt working directory: ---------- Found 0 warnings and 0 errors. -Finished in ms on 1 file with 90 rules using 1 threads. +Finished in ms on 1 file with 89 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/_-c fixtures__no_empty_disallow_empty_catch__eslintrc.json -W no-empty fixtures__no_empty_disallow_empty_catch__test.js@oxlint.snap b/apps/oxlint/src/snapshots/_-c fixtures__no_empty_disallow_empty_catch__eslintrc.json -W no-empty fixtures__no_empty_disallow_empty_catch__test.js@oxlint.snap index 5dccb075c282e..aee8e702efcca 100644 --- a/apps/oxlint/src/snapshots/_-c fixtures__no_empty_disallow_empty_catch__eslintrc.json -W no-empty fixtures__no_empty_disallow_empty_catch__test.js@oxlint.snap +++ b/apps/oxlint/src/snapshots/_-c fixtures__no_empty_disallow_empty_catch__eslintrc.json -W no-empty fixtures__no_empty_disallow_empty_catch__test.js@oxlint.snap @@ -14,7 +14,7 @@ working directory: help: Remove this block or add a comment inside it Found 1 warning and 0 errors. -Finished in ms on 1 file with 90 rules using 1 threads. +Finished in ms on 1 file with 89 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/_-c fixtures__overrides__.oxlintrc.json fixtures__overrides__test.js -c fixtures__overrides__.oxlintrc.json fixtures__overrides__test.ts -c fixtures__overrides__.oxlintrc.json fixtures__overrides__other.jsx@oxlint.snap b/apps/oxlint/src/snapshots/_-c fixtures__overrides__.oxlintrc.json fixtures__overrides__test.js -c fixtures__overrides__.oxlintrc.json fixtures__overrides__test.ts -c fixtures__overrides__.oxlintrc.json fixtures__overrides__other.jsx@oxlint.snap index 8fdeaf3a58cda..db17dd6cea37a 100644 --- a/apps/oxlint/src/snapshots/_-c fixtures__overrides__.oxlintrc.json fixtures__overrides__test.js -c fixtures__overrides__.oxlintrc.json fixtures__overrides__test.ts -c fixtures__overrides__.oxlintrc.json fixtures__overrides__other.jsx@oxlint.snap +++ b/apps/oxlint/src/snapshots/_-c fixtures__overrides__.oxlintrc.json fixtures__overrides__test.js -c fixtures__overrides__.oxlintrc.json fixtures__overrides__test.ts -c fixtures__overrides__.oxlintrc.json fixtures__overrides__other.jsx@oxlint.snap @@ -15,7 +15,7 @@ working directory: help: Replace var with let or const Found 0 warnings and 1 error. -Finished in ms on 1 file with 91 rules using 1 threads. +Finished in ms on 1 file with 90 rules using 1 threads. ---------- CLI result: LintFoundErrors ---------- @@ -42,7 +42,7 @@ working directory: help: Delete this console statement. Found 1 warning and 1 error. -Finished in ms on 1 file with 91 rules using 1 threads. +Finished in ms on 1 file with 90 rules using 1 threads. ---------- CLI result: LintFoundErrors ---------- @@ -61,7 +61,7 @@ working directory: help: Replace var with let or const Found 0 warnings and 1 error. -Finished in ms on 1 file with 91 rules using 1 threads. +Finished in ms on 1 file with 90 rules using 1 threads. ---------- CLI result: LintFoundErrors ---------- diff --git a/apps/oxlint/src/snapshots/_-c fixtures__overrides__directories-config.json fixtures__overrides@oxlint.snap b/apps/oxlint/src/snapshots/_-c fixtures__overrides__directories-config.json fixtures__overrides@oxlint.snap index 3663fce39d5e0..f114ad02fc06c 100644 --- a/apps/oxlint/src/snapshots/_-c fixtures__overrides__directories-config.json fixtures__overrides@oxlint.snap +++ b/apps/oxlint/src/snapshots/_-c fixtures__overrides__directories-config.json fixtures__overrides@oxlint.snap @@ -35,7 +35,7 @@ working directory: help: Remove the debugger statement Found 2 warnings and 2 errors. -Finished in ms on 7 files with 88 rules using 1 threads. +Finished in ms on 7 files with 87 rules using 1 threads. ---------- CLI result: LintFoundErrors ---------- diff --git a/apps/oxlint/src/snapshots/_-c fixtures__typescript_eslint__eslintrc.json --disable-typescript-plugin fixtures__typescript_eslint__test.ts@oxlint.snap b/apps/oxlint/src/snapshots/_-c fixtures__typescript_eslint__eslintrc.json --disable-typescript-plugin fixtures__typescript_eslint__test.ts@oxlint.snap index 6b567eafca17b..65110c0de93a7 100644 --- a/apps/oxlint/src/snapshots/_-c fixtures__typescript_eslint__eslintrc.json --disable-typescript-plugin fixtures__typescript_eslint__test.ts@oxlint.snap +++ b/apps/oxlint/src/snapshots/_-c fixtures__typescript_eslint__eslintrc.json --disable-typescript-plugin fixtures__typescript_eslint__test.ts@oxlint.snap @@ -23,7 +23,7 @@ working directory: `---- Found 1 warning and 1 error. -Finished in ms on 1 file with 52 rules using 1 threads. +Finished in ms on 1 file with 51 rules using 1 threads. ---------- CLI result: LintFoundErrors ---------- diff --git a/apps/oxlint/src/snapshots/_-c fixtures__typescript_eslint__eslintrc.json fixtures__typescript_eslint__test.ts@oxlint.snap b/apps/oxlint/src/snapshots/_-c fixtures__typescript_eslint__eslintrc.json fixtures__typescript_eslint__test.ts@oxlint.snap index 2b2d2bc4843ef..eab9dad447078 100644 --- a/apps/oxlint/src/snapshots/_-c fixtures__typescript_eslint__eslintrc.json fixtures__typescript_eslint__test.ts@oxlint.snap +++ b/apps/oxlint/src/snapshots/_-c fixtures__typescript_eslint__eslintrc.json fixtures__typescript_eslint__test.ts@oxlint.snap @@ -31,7 +31,7 @@ working directory: `---- Found 2 warnings and 1 error. -Finished in ms on 1 file with 64 rules using 1 threads. +Finished in ms on 1 file with 63 rules using 1 threads. ---------- CLI result: LintFoundErrors ---------- diff --git a/apps/oxlint/src/snapshots/_fixtures__astro__debugger.astro@oxlint.snap b/apps/oxlint/src/snapshots/_fixtures__astro__debugger.astro@oxlint.snap index f894a60f2dfb8..4e6ea777724c3 100644 --- a/apps/oxlint/src/snapshots/_fixtures__astro__debugger.astro@oxlint.snap +++ b/apps/oxlint/src/snapshots/_fixtures__astro__debugger.astro@oxlint.snap @@ -43,7 +43,7 @@ working directory: help: Remove the debugger statement Found 4 warnings and 0 errors. -Finished in ms on 1 file with 89 rules using 1 threads. +Finished in ms on 1 file with 88 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/_fixtures__linter@oxlint.snap b/apps/oxlint/src/snapshots/_fixtures__linter@oxlint.snap index 7e23e8196cb4c..c4f6832be41cb 100644 --- a/apps/oxlint/src/snapshots/_fixtures__linter@oxlint.snap +++ b/apps/oxlint/src/snapshots/_fixtures__linter@oxlint.snap @@ -29,7 +29,7 @@ working directory: help: Use the isNaN function to compare with NaN. Found 3 warnings and 0 errors. -Finished in ms on 3 files with 89 rules using 1 threads. +Finished in ms on 3 files with 88 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/_fixtures__linter__debugger.js fixtures__linter__nan.js@oxlint.snap b/apps/oxlint/src/snapshots/_fixtures__linter__debugger.js fixtures__linter__nan.js@oxlint.snap index 225b6fa3155e3..7abab6af6a633 100644 --- a/apps/oxlint/src/snapshots/_fixtures__linter__debugger.js fixtures__linter__nan.js@oxlint.snap +++ b/apps/oxlint/src/snapshots/_fixtures__linter__debugger.js fixtures__linter__nan.js@oxlint.snap @@ -21,7 +21,7 @@ working directory: help: Use the isNaN function to compare with NaN. Found 2 warnings and 0 errors. -Finished in ms on 2 files with 89 rules using 1 threads. +Finished in ms on 2 files with 88 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/_fixtures__linter__debugger.js@oxlint.snap b/apps/oxlint/src/snapshots/_fixtures__linter__debugger.js@oxlint.snap index 322a6991bc45e..dc5b0018fb3fb 100644 --- a/apps/oxlint/src/snapshots/_fixtures__linter__debugger.js@oxlint.snap +++ b/apps/oxlint/src/snapshots/_fixtures__linter__debugger.js@oxlint.snap @@ -14,7 +14,7 @@ working directory: help: Remove the debugger statement Found 1 warning and 0 errors. -Finished in ms on 1 file with 89 rules using 1 threads. +Finished in ms on 1 file with 88 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/_fixtures__linter__js_as_jsx.js@oxlint.snap b/apps/oxlint/src/snapshots/_fixtures__linter__js_as_jsx.js@oxlint.snap index 58f9eeb45e9b7..6f10c0e933022 100644 --- a/apps/oxlint/src/snapshots/_fixtures__linter__js_as_jsx.js@oxlint.snap +++ b/apps/oxlint/src/snapshots/_fixtures__linter__js_as_jsx.js@oxlint.snap @@ -15,7 +15,7 @@ working directory: help: Remove the debugger statement Found 1 warning and 0 errors. -Finished in ms on 1 file with 89 rules using 1 threads. +Finished in ms on 1 file with 88 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/_fixtures__svelte__debugger.svelte@oxlint.snap b/apps/oxlint/src/snapshots/_fixtures__svelte__debugger.svelte@oxlint.snap index a92865b47cc81..10d430a9d26ee 100644 --- a/apps/oxlint/src/snapshots/_fixtures__svelte__debugger.svelte@oxlint.snap +++ b/apps/oxlint/src/snapshots/_fixtures__svelte__debugger.svelte@oxlint.snap @@ -34,7 +34,7 @@ working directory: help: Variable declared without assignment. Either assign a value or remove the declaration. Found 3 warnings and 0 errors. -Finished in ms on 1 file with 89 rules using 1 threads. +Finished in ms on 1 file with 88 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/_fixtures__vue__debugger.vue@oxlint.snap b/apps/oxlint/src/snapshots/_fixtures__vue__debugger.vue@oxlint.snap index 6fe80af145242..923455acb9d95 100644 --- a/apps/oxlint/src/snapshots/_fixtures__vue__debugger.vue@oxlint.snap +++ b/apps/oxlint/src/snapshots/_fixtures__vue__debugger.vue@oxlint.snap @@ -25,7 +25,7 @@ working directory: help: Remove the debugger statement Found 2 warnings and 0 errors. -Finished in ms on 1 file with 89 rules using 1 threads. +Finished in ms on 1 file with 88 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/_fixtures__vue__empty.vue@oxlint.snap b/apps/oxlint/src/snapshots/_fixtures__vue__empty.vue@oxlint.snap index fc458c656cd06..9bc332a438637 100644 --- a/apps/oxlint/src/snapshots/_fixtures__vue__empty.vue@oxlint.snap +++ b/apps/oxlint/src/snapshots/_fixtures__vue__empty.vue@oxlint.snap @@ -6,7 +6,7 @@ arguments: fixtures/vue/empty.vue working directory: ---------- Found 0 warnings and 0 errors. -Finished in ms on 1 file with 89 rules using 1 threads. +Finished in ms on 1 file with 88 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/_foo.asdf@oxlint.snap b/apps/oxlint/src/snapshots/_foo.asdf@oxlint.snap index 1ac700cd30329..b318daf82400b 100644 --- a/apps/oxlint/src/snapshots/_foo.asdf@oxlint.snap +++ b/apps/oxlint/src/snapshots/_foo.asdf@oxlint.snap @@ -6,7 +6,7 @@ arguments: foo.asdf working directory: ---------- Found 0 warnings and 0 errors. -Finished in ms on 0 files with 89 rules using 1 threads. +Finished in ms on 0 files with 88 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/fixtures__config_ignore_patterns__ignore_directory_-c eslintrc.json@oxlint.snap b/apps/oxlint/src/snapshots/fixtures__config_ignore_patterns__ignore_directory_-c eslintrc.json@oxlint.snap index 24165e78ad716..e8714e8681f0d 100644 --- a/apps/oxlint/src/snapshots/fixtures__config_ignore_patterns__ignore_directory_-c eslintrc.json@oxlint.snap +++ b/apps/oxlint/src/snapshots/fixtures__config_ignore_patterns__ignore_directory_-c eslintrc.json@oxlint.snap @@ -14,7 +14,7 @@ working directory: fixtures/config_ignore_patterns/ignore_directory help: Delete this file or add some code to it. Found 1 warning and 0 errors. -Finished in ms on 1 file with 89 rules using 1 threads. +Finished in ms on 1 file with 88 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/fixtures__config_ignore_patterns__with_oxlintrc_-c .__test__eslintrc.json --ignore-pattern _.ts .@oxlint.snap b/apps/oxlint/src/snapshots/fixtures__config_ignore_patterns__with_oxlintrc_-c .__test__eslintrc.json --ignore-pattern _.ts .@oxlint.snap index 0c25b00e41462..5fe1e852820ba 100644 --- a/apps/oxlint/src/snapshots/fixtures__config_ignore_patterns__with_oxlintrc_-c .__test__eslintrc.json --ignore-pattern _.ts .@oxlint.snap +++ b/apps/oxlint/src/snapshots/fixtures__config_ignore_patterns__with_oxlintrc_-c .__test__eslintrc.json --ignore-pattern _.ts .@oxlint.snap @@ -6,7 +6,7 @@ arguments: -c ./test/eslintrc.json --ignore-pattern *.ts . working directory: fixtures/config_ignore_patterns/with_oxlintrc ---------- Found 0 warnings and 0 errors. -Finished in ms on 0 files with 89 rules using 1 threads. +Finished in ms on 0 files with 88 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/fixtures__disable_eslint_and_unicorn_alias_rules_-c .oxlintrc-eslint.json test.js -c .oxlintrc-unicorn.json test.js@oxlint.snap b/apps/oxlint/src/snapshots/fixtures__disable_eslint_and_unicorn_alias_rules_-c .oxlintrc-eslint.json test.js -c .oxlintrc-unicorn.json test.js@oxlint.snap index ea4c1acbde57a..ac5e7f74d9118 100644 --- a/apps/oxlint/src/snapshots/fixtures__disable_eslint_and_unicorn_alias_rules_-c .oxlintrc-eslint.json test.js -c .oxlintrc-unicorn.json test.js@oxlint.snap +++ b/apps/oxlint/src/snapshots/fixtures__disable_eslint_and_unicorn_alias_rules_-c .oxlintrc-eslint.json test.js -c .oxlintrc-unicorn.json test.js@oxlint.snap @@ -6,7 +6,7 @@ arguments: -c .oxlintrc-eslint.json test.js working directory: fixtures/disable_eslint_and_unicorn_alias_rules ---------- Found 0 warnings and 0 errors. -Finished in ms on 1 file with 52 rules using 1 threads. +Finished in ms on 1 file with 51 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- @@ -16,7 +16,7 @@ arguments: -c .oxlintrc-unicorn.json test.js working directory: fixtures/disable_eslint_and_unicorn_alias_rules ---------- Found 0 warnings and 0 errors. -Finished in ms on 1 file with 65 rules using 1 threads. +Finished in ms on 1 file with 64 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/fixtures__dot_folder_@oxlint.snap b/apps/oxlint/src/snapshots/fixtures__dot_folder_@oxlint.snap index 3c3c8c8952bdd..79cbb96f4041b 100644 --- a/apps/oxlint/src/snapshots/fixtures__dot_folder_@oxlint.snap +++ b/apps/oxlint/src/snapshots/fixtures__dot_folder_@oxlint.snap @@ -14,7 +14,7 @@ working directory: fixtures/dot_folder help: Remove the debugger statement Found 1 warning and 0 errors. -Finished in ms on 1 file with 89 rules using 1 threads. +Finished in ms on 1 file with 88 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/fixtures__extends_config_--config extends_rules_config.json console.js@oxlint.snap b/apps/oxlint/src/snapshots/fixtures__extends_config_--config extends_rules_config.json console.js@oxlint.snap index b893f937717fc..2c5078e8ae2cf 100644 --- a/apps/oxlint/src/snapshots/fixtures__extends_config_--config extends_rules_config.json console.js@oxlint.snap +++ b/apps/oxlint/src/snapshots/fixtures__extends_config_--config extends_rules_config.json console.js@oxlint.snap @@ -14,7 +14,7 @@ working directory: fixtures/extends_config help: Delete this console statement. Found 0 warnings and 1 error. -Finished in ms on 1 file with 90 rules using 1 threads. +Finished in ms on 1 file with 89 rules using 1 threads. ---------- CLI result: LintFoundErrors ---------- diff --git a/apps/oxlint/src/snapshots/fixtures__extends_config_--config relative_paths__extends_extends_config.json console.js@oxlint.snap b/apps/oxlint/src/snapshots/fixtures__extends_config_--config relative_paths__extends_extends_config.json console.js@oxlint.snap index 57087bc5f4956..2560d77f56c60 100644 --- a/apps/oxlint/src/snapshots/fixtures__extends_config_--config relative_paths__extends_extends_config.json console.js@oxlint.snap +++ b/apps/oxlint/src/snapshots/fixtures__extends_config_--config relative_paths__extends_extends_config.json console.js@oxlint.snap @@ -14,7 +14,7 @@ working directory: fixtures/extends_config help: Delete this console statement. Found 0 warnings and 1 error. -Finished in ms on 1 file with 90 rules using 1 threads. +Finished in ms on 1 file with 89 rules using 1 threads. ---------- CLI result: LintFoundErrors ---------- diff --git a/apps/oxlint/src/snapshots/fixtures__extends_config_--disable-nested-config@oxlint.snap b/apps/oxlint/src/snapshots/fixtures__extends_config_--disable-nested-config@oxlint.snap index e9e54b6e0eab5..5f3ad63228d56 100644 --- a/apps/oxlint/src/snapshots/fixtures__extends_config_--disable-nested-config@oxlint.snap +++ b/apps/oxlint/src/snapshots/fixtures__extends_config_--disable-nested-config@oxlint.snap @@ -31,7 +31,7 @@ working directory: fixtures/extends_config help: Remove the debugger statement Found 3 warnings and 0 errors. -Finished in ms on 4 files with 89 rules using 1 threads. +Finished in ms on 4 files with 88 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/fixtures__import-cycle_--import-plugin -D import__no-cycle@oxlint.snap b/apps/oxlint/src/snapshots/fixtures__import-cycle_--import-plugin -D import__no-cycle@oxlint.snap index 011c6f95fcc41..0124f24f7b2c9 100644 --- a/apps/oxlint/src/snapshots/fixtures__import-cycle_--import-plugin -D import__no-cycle@oxlint.snap +++ b/apps/oxlint/src/snapshots/fixtures__import-cycle_--import-plugin -D import__no-cycle@oxlint.snap @@ -27,7 +27,7 @@ working directory: fixtures/import-cycle -> ./b - fixtures/import-cycle/b.ts Found 0 warnings and 2 errors. -Finished in ms on 2 files with 92 rules using 1 threads. +Finished in ms on 2 files with 91 rules using 1 threads. ---------- CLI result: LintFoundErrors ---------- diff --git a/apps/oxlint/src/snapshots/fixtures__import_-c .oxlintrc.json test.js -c .oxlintrc-import-x.json test.js@oxlint.snap b/apps/oxlint/src/snapshots/fixtures__import_-c .oxlintrc.json test.js -c .oxlintrc-import-x.json test.js@oxlint.snap index 05fcf131dd43a..b34ccae5c72fe 100644 --- a/apps/oxlint/src/snapshots/fixtures__import_-c .oxlintrc.json test.js -c .oxlintrc-import-x.json test.js@oxlint.snap +++ b/apps/oxlint/src/snapshots/fixtures__import_-c .oxlintrc.json test.js -c .oxlintrc-import-x.json test.js@oxlint.snap @@ -15,7 +15,7 @@ working directory: fixtures/import `---- Found 0 warnings and 1 error. -Finished in ms on 1 file with 54 rules using 1 threads. +Finished in ms on 1 file with 53 rules using 1 threads. ---------- CLI result: LintFoundErrors ---------- @@ -34,7 +34,7 @@ working directory: fixtures/import `---- Found 0 warnings and 1 error. -Finished in ms on 1 file with 54 rules using 1 threads. +Finished in ms on 1 file with 53 rules using 1 threads. ---------- CLI result: LintFoundErrors ---------- diff --git a/apps/oxlint/src/snapshots/fixtures__issue_10394_-c .oxlintrc.json@oxlint.snap b/apps/oxlint/src/snapshots/fixtures__issue_10394_-c .oxlintrc.json@oxlint.snap index aa1360e8034f6..de60c8e2330d0 100644 --- a/apps/oxlint/src/snapshots/fixtures__issue_10394_-c .oxlintrc.json@oxlint.snap +++ b/apps/oxlint/src/snapshots/fixtures__issue_10394_-c .oxlintrc.json@oxlint.snap @@ -15,7 +15,7 @@ working directory: fixtures/issue_10394 help: "Write a meaningful title for your test" Found 1 warning and 0 errors. -Finished in ms on 1 file with 89 rules using 1 threads. +Finished in ms on 1 file with 88 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/fixtures__issue_11054_-c .oxlintrc.json@oxlint.snap b/apps/oxlint/src/snapshots/fixtures__issue_11054_-c .oxlintrc.json@oxlint.snap index 2e5d872ebf147..021cd19d338c5 100644 --- a/apps/oxlint/src/snapshots/fixtures__issue_11054_-c .oxlintrc.json@oxlint.snap +++ b/apps/oxlint/src/snapshots/fixtures__issue_11054_-c .oxlintrc.json@oxlint.snap @@ -6,7 +6,7 @@ arguments: -c .oxlintrc.json working directory: fixtures/issue_11054 ---------- Found 0 warnings and 0 errors. -Finished in ms on 1 file with 89 rules using 1 threads. +Finished in ms on 1 file with 88 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/fixtures__issue_11644_-c .oxlintrc.json@oxlint.snap b/apps/oxlint/src/snapshots/fixtures__issue_11644_-c .oxlintrc.json@oxlint.snap index 4eaedefe525c9..9fa98d0346d17 100644 --- a/apps/oxlint/src/snapshots/fixtures__issue_11644_-c .oxlintrc.json@oxlint.snap +++ b/apps/oxlint/src/snapshots/fixtures__issue_11644_-c .oxlintrc.json@oxlint.snap @@ -6,7 +6,7 @@ arguments: -c .oxlintrc.json working directory: fixtures/issue_11644 ---------- Found 0 warnings and 0 errors. -Finished in ms on 1 file with 161 rules using 1 threads. +Finished in ms on 1 file with 160 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/fixtures__linter_debugger.js@oxlint.snap b/apps/oxlint/src/snapshots/fixtures__linter_debugger.js@oxlint.snap index 7e47887164c7e..9d6d855ef3212 100644 --- a/apps/oxlint/src/snapshots/fixtures__linter_debugger.js@oxlint.snap +++ b/apps/oxlint/src/snapshots/fixtures__linter_debugger.js@oxlint.snap @@ -14,7 +14,7 @@ working directory: fixtures/linter help: Remove the debugger statement Found 1 warning and 0 errors. -Finished in ms on 1 file with 89 rules using 1 threads. +Finished in ms on 1 file with 88 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/fixtures__overrides_env_globals_-c .oxlintrc.json .@oxlint.snap b/apps/oxlint/src/snapshots/fixtures__overrides_env_globals_-c .oxlintrc.json .@oxlint.snap index 4903ee7637f33..efad408ad3993 100644 --- a/apps/oxlint/src/snapshots/fixtures__overrides_env_globals_-c .oxlintrc.json .@oxlint.snap +++ b/apps/oxlint/src/snapshots/fixtures__overrides_env_globals_-c .oxlintrc.json .@oxlint.snap @@ -51,7 +51,7 @@ working directory: fixtures/overrides_env_globals `---- Found 5 warnings and 0 errors. -Finished in ms on 3 files with 89 rules using 1 threads. +Finished in ms on 3 files with 88 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/fixtures__overrides_with_plugin_-c .oxlintrc.json@oxlint.snap b/apps/oxlint/src/snapshots/fixtures__overrides_with_plugin_-c .oxlintrc.json@oxlint.snap index ce0d0fbc19104..cfba320384f06 100644 --- a/apps/oxlint/src/snapshots/fixtures__overrides_with_plugin_-c .oxlintrc.json@oxlint.snap +++ b/apps/oxlint/src/snapshots/fixtures__overrides_with_plugin_-c .oxlintrc.json@oxlint.snap @@ -42,7 +42,7 @@ working directory: fixtures/overrides_with_plugin help: Consider removing this declaration. Found 2 warnings and 2 errors. -Finished in ms on 2 files with 89 rules using 1 threads. +Finished in ms on 2 files with 88 rules using 1 threads. ---------- CLI result: LintFoundErrors ---------- diff --git a/apps/oxlint/src/snapshots/fixtures__report_unused_directives_-c .oxlintrc.json --report-unused-disable-directives test.js@oxlint.snap b/apps/oxlint/src/snapshots/fixtures__report_unused_directives_-c .oxlintrc.json --report-unused-disable-directives test.js@oxlint.snap index 08643d98e03f0..c2676e8ae1418 100644 --- a/apps/oxlint/src/snapshots/fixtures__report_unused_directives_-c .oxlintrc.json --report-unused-disable-directives test.js@oxlint.snap +++ b/apps/oxlint/src/snapshots/fixtures__report_unused_directives_-c .oxlintrc.json --report-unused-disable-directives test.js@oxlint.snap @@ -64,7 +64,7 @@ working directory: fixtures/report_unused_directives `---- Found 7 warnings and 0 errors. -Finished in ms on 1 file with 90 rules using 1 threads. +Finished in ms on 1 file with 89 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/apps/oxlint/src/snapshots/fixtures__two_rules_with_same_rule_name_-c .oxlintrc.json test.js@oxlint.snap b/apps/oxlint/src/snapshots/fixtures__two_rules_with_same_rule_name_-c .oxlintrc.json test.js@oxlint.snap index 36d0766f8748d..e21514d45fc3f 100644 --- a/apps/oxlint/src/snapshots/fixtures__two_rules_with_same_rule_name_-c .oxlintrc.json test.js@oxlint.snap +++ b/apps/oxlint/src/snapshots/fixtures__two_rules_with_same_rule_name_-c .oxlintrc.json test.js@oxlint.snap @@ -6,7 +6,7 @@ arguments: -c .oxlintrc.json test.js working directory: fixtures/two_rules_with_same_rule_name ---------- Found 0 warnings and 0 errors. -Finished in ms on 1 file with 65 rules using 1 threads. +Finished in ms on 1 file with 64 rules using 1 threads. ---------- CLI result: LintSucceeded ---------- diff --git a/crates/oxc_linter/src/rules/eslint/preserve_caught_error.rs b/crates/oxc_linter/src/rules/eslint/preserve_caught_error.rs index f2de008b19509..506be2ddbadb8 100644 --- a/crates/oxc_linter/src/rules/eslint/preserve_caught_error.rs +++ b/crates/oxc_linter/src/rules/eslint/preserve_caught_error.rs @@ -1,11 +1,12 @@ use oxc_ast::AstKind; use oxc_ast::ast::{ - Argument, BindingPattern, CatchClause, Expression, ObjectExpression, ObjectPropertyKind, - PropertyKey, Statement, ThrowStatement, TryStatement, + Argument, BindingPattern, CatchClause, Expression, Function, ObjectExpression, + ObjectPropertyKind, PropertyKey, ThrowStatement, TryStatement, }; +use oxc_ast_visit::Visit; use oxc_diagnostics::OxcDiagnostic; use oxc_macros::declare_oxc_lint; -use oxc_semantic::IsGlobalReference; +use oxc_semantic::{IsGlobalReference, ScopeFlags}; use oxc_span::Span; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -36,81 +37,41 @@ struct ConfigElement0 { #[derive(Debug, Default, Clone, Serialize, Deserialize, JsonSchema)] pub struct PreserveCaughtError(ConfigElement0); -// Helper functions - global scope for better reusability and testing - -// Recursively check statements for throw expressions -fn check_statement<'a>( - stmt: &Statement<'a>, - catch_param: &BindingPattern<'a>, - ctx: &LintContext<'a>, -) { - match stmt { - Statement::ThrowStatement(throw_stmt) => { - check_throw_statement(throw_stmt, catch_param, ctx); - } - Statement::IfStatement(if_stmt) => { - check_statement(&if_stmt.consequent, catch_param, ctx); - if let Some(alternate) = &if_stmt.alternate { - check_statement(alternate, catch_param, ctx); - } - } - Statement::WhileStatement(while_stmt) => { - check_statement(&while_stmt.body, catch_param, ctx); - } - Statement::ForStatement(for_stmt) => { - check_statement(&for_stmt.body, catch_param, ctx); - } - Statement::BlockStatement(block_stmt) => { - for stmt in &block_stmt.body { - check_statement(stmt, catch_param, ctx); - } - } - Statement::SwitchStatement(switch_stmt) => { - for case in &switch_stmt.cases { - for stmt in &case.consequent { - check_statement(stmt, catch_param, ctx); - } - } - } - Statement::LabeledStatement(label_stmt) => { - check_statement(&label_stmt.body, catch_param, ctx); - } - _ => {} - } +struct ThrowFinder<'a, 'ctx> { + catch_param: &'a BindingPattern<'a>, + ctx: &'ctx LintContext<'a>, } -// Check if a throw statement re-throws built-in errors without preserving the original -fn check_throw_statement<'a>( - throw_stmt: &ThrowStatement<'a>, - catch_param: &BindingPattern<'a>, - ctx: &LintContext<'a>, -) { - let (callee, args) = match &throw_stmt.argument { - Expression::NewExpression(new_expr) => (&new_expr.callee, &new_expr.arguments), - Expression::CallExpression(call_expr) => (&call_expr.callee, &call_expr.arguments), - _ => return, - }; +impl<'a> Visit<'a> for ThrowFinder<'a, '_> { + fn visit_throw_statement(&mut self, throw_stmt: &ThrowStatement<'a>) { + let (callee, args) = match &throw_stmt.argument { + Expression::NewExpression(new_expr) => (&new_expr.callee, &new_expr.arguments), + Expression::CallExpression(call_expr) => (&call_expr.callee, &call_expr.arguments), + _ => return, + }; - if !is_builtin_error_constructor(callee, ctx) { - return; - } + if !is_builtin_error_constructor(callee, self.ctx) { + return; + } - // Check if second argument has proper cause property - if let Some(Argument::ObjectExpression(obj_expr)) = args.get(1) { - if has_cause_property(obj_expr, catch_param, ctx) { + if let Some(Argument::ObjectExpression(obj_expr)) = args.get(1) { + if has_cause_property(obj_expr, self.catch_param, self.ctx) { + return; + } + } + + // Allow spread arguments - they may contain cause property + if args.iter().any(|arg| matches!(arg, Argument::SpreadElement(_))) { return; } - } - // Allow spread arguments - they may contain cause property - if args.iter().any(|arg| matches!(arg, Argument::SpreadElement(_))) { - return; + self.ctx.diagnostic(preserve_caught_error_diagnostic(throw_stmt.span)); } - ctx.diagnostic(preserve_caught_error_diagnostic(throw_stmt.span)); + // Do not traverse into nested functions/closures within the catch block + fn visit_function(&mut self, _func: &Function<'a>, _flags: ScopeFlags) {} } -// Check if expression is a built-in Error constructor fn is_builtin_error_constructor(expr: &Expression, ctx: &LintContext) -> bool { let Expression::Identifier(ident) = expr else { return false; @@ -121,7 +82,6 @@ fn is_builtin_error_constructor(expr: &Expression, ctx: &LintContext) -> bool { || ident.is_global_reference_name("AggregateError", ctx.scoping()) } -// Check if object expression has a 'cause' property with the catch parameter fn has_cause_property( obj_expr: &ObjectExpression, catch_param: &BindingPattern, @@ -137,18 +97,15 @@ fn has_cause_property( return is_catch_parameter(&prop.value, catch_param, ctx); } } - // Spread properties might contain cause ObjectPropertyKind::SpreadProperty(_) => return true, } } false } -// Check if expression references the catch parameter fn is_catch_parameter(expr: &Expression, catch_param: &BindingPattern, ctx: &LintContext) -> bool { - // Only handle simple identifier catch parameters for now let oxc_ast::ast::BindingPatternKind::BindingIdentifier(binding) = &catch_param.kind else { - return false; // Destructuring patterns not supported + return false; }; let Some(catch_symbol_id) = binding.symbol_id.get() else { @@ -203,22 +160,22 @@ declare_oxc_lint!( /// ``` PreserveCaughtError, eslint, - correctness, + suspicious, pending, config = ConfigElement0, ); impl PreserveCaughtError { - fn check_try_statement<'a>(&self, try_stmt: &TryStatement<'a>, ctx: &LintContext<'a>) { + fn check_try_statement<'a>(&self, try_stmt: &'a TryStatement<'a>, ctx: &LintContext<'a>) { if let Some(catch_clause) = &try_stmt.handler { self.check_catch_clause(catch_clause, ctx); } } - fn check_catch_clause<'a>(&self, catch_clause: &CatchClause<'a>, ctx: &LintContext<'a>) { + fn check_catch_clause<'a>(&self, catch_clause: &'a CatchClause<'a>, ctx: &LintContext<'a>) { if let Some(catch_param) = &catch_clause.param { - for stmt in &catch_clause.body.body { - check_statement(stmt, &catch_param.pattern, ctx); - } + let mut finder: ThrowFinder<'a, '_> = + ThrowFinder { catch_param: &catch_param.pattern, ctx }; + finder.visit_block_statement(catch_clause.body.as_ref()); } else if self.0.require_catch_parameter { ctx.diagnostic(missing_catch_parameter_diagnostic(catch_clause.span)); }