diff --git a/crates/oxc_language_server/src/linter/server_linter.rs b/crates/oxc_language_server/src/linter/server_linter.rs index 0f679ac75f6f7..6a430086d640c 100644 --- a/crates/oxc_language_server/src/linter/server_linter.rs +++ b/crates/oxc_language_server/src/linter/server_linter.rs @@ -562,9 +562,7 @@ mod test { #[test] fn test_cross_module_no_cycle_nested_config() { Tester::new("fixtures/linter/cross_module_nested_config", None) - .test_and_snapshot_single_file("dep-a.ts"); - Tester::new("fixtures/linter/cross_module_nested_config", None) - .test_and_snapshot_single_file("folder/folder-dep-a.ts"); + .test_and_snapshot_multiple_file(&["dep-a.ts", "folder/folder-dep-a.ts"]); } #[test] @@ -603,8 +601,10 @@ mod test { #[test] fn test_root_ignore_patterns() { let tester = Tester::new("fixtures/linter/ignore_patterns", None); - tester.test_and_snapshot_single_file("ignored-file.ts"); - tester.test_and_snapshot_single_file("another_config/not-ignored-file.ts"); + tester.test_and_snapshot_multiple_file(&[ + "ignored-file.ts", + "another_config/not-ignored-file.ts", + ]); } #[test] diff --git a/crates/oxc_language_server/src/snapshots/fixtures_linter_astro@debugger.astro.snap b/crates/oxc_language_server/src/snapshots/fixtures_linter_astro@debugger.astro.snap index 35121d21b506e..2543ae92e5a33 100644 --- a/crates/oxc_language_server/src/snapshots/fixtures_linter_astro@debugger.astro.snap +++ b/crates/oxc_language_server/src/snapshots/fixtures_linter_astro@debugger.astro.snap @@ -1,7 +1,10 @@ --- source: crates/oxc_language_server/src/tester.rs -input_file: crates/oxc_language_server/fixtures/linter/astro/debugger.astro --- +########## +file: fixtures/linter/astro/debugger.astro +---------- + code: "eslint(no-debugger)" code_description.href: "https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-debugger.html" message: "`debugger` statement is not allowed\nhelp: Remove the debugger statement" diff --git a/crates/oxc_language_server/src/snapshots/fixtures_linter_cross_module@debugger.ts.snap b/crates/oxc_language_server/src/snapshots/fixtures_linter_cross_module@debugger.ts.snap index 45a5cbf047e57..64f9851996faa 100644 --- a/crates/oxc_language_server/src/snapshots/fixtures_linter_cross_module@debugger.ts.snap +++ b/crates/oxc_language_server/src/snapshots/fixtures_linter_cross_module@debugger.ts.snap @@ -1,7 +1,10 @@ --- source: crates/oxc_language_server/src/tester.rs -input_file: crates/oxc_language_server/fixtures/linter/cross_module/debugger.ts --- +########## +file: fixtures/linter/cross_module/debugger.ts +---------- + code: "eslint(no-debugger)" code_description.href: "https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-debugger.html" message: "`debugger` statement is not allowed\nhelp: Remove the debugger statement" diff --git a/crates/oxc_language_server/src/snapshots/fixtures_linter_cross_module@dep-a.ts.snap b/crates/oxc_language_server/src/snapshots/fixtures_linter_cross_module@dep-a.ts.snap index 03bc924989aee..4e87629705d0a 100644 --- a/crates/oxc_language_server/src/snapshots/fixtures_linter_cross_module@dep-a.ts.snap +++ b/crates/oxc_language_server/src/snapshots/fixtures_linter_cross_module@dep-a.ts.snap @@ -1,7 +1,10 @@ --- source: crates/oxc_language_server/src/tester.rs -input_file: crates/oxc_language_server/fixtures/linter/cross_module/dep-a.ts --- +########## +file: fixtures/linter/cross_module/dep-a.ts +---------- + code: "eslint-plugin-import(no-cycle)" code_description.href: "https://oxc.rs/docs/guide/usage/linter/rules/import/no-cycle.html" message: "Dependency cycle detected\nhelp: These paths form a cycle: \n-> ./dep-b.ts - fixtures/linter/cross_module/dep-b.ts\n-> ./dep-a.ts - fixtures/linter/cross_module/dep-a.ts" diff --git a/crates/oxc_language_server/src/snapshots/fixtures_linter_cross_module_extended_config@dep-a.ts.snap b/crates/oxc_language_server/src/snapshots/fixtures_linter_cross_module_extended_config@dep-a.ts.snap index bd5bce624476e..f3bfbaa540109 100644 --- a/crates/oxc_language_server/src/snapshots/fixtures_linter_cross_module_extended_config@dep-a.ts.snap +++ b/crates/oxc_language_server/src/snapshots/fixtures_linter_cross_module_extended_config@dep-a.ts.snap @@ -1,7 +1,10 @@ --- source: crates/oxc_language_server/src/tester.rs -input_file: crates/oxc_language_server/fixtures/linter/cross_module_extended_config/dep-a.ts --- +########## +file: fixtures/linter/cross_module_extended_config/dep-a.ts +---------- + code: "eslint-plugin-import(no-cycle)" code_description.href: "https://oxc.rs/docs/guide/usage/linter/rules/import/no-cycle.html" message: "Dependency cycle detected\nhelp: These paths form a cycle: \n-> ./dep-b.ts - fixtures/linter/cross_module_extended_config/dep-b.ts\n-> ./dep-a.ts - fixtures/linter/cross_module_extended_config/dep-a.ts" diff --git a/crates/oxc_language_server/src/snapshots/fixtures_linter_cross_module_nested_config@dep-a.ts.snap b/crates/oxc_language_server/src/snapshots/fixtures_linter_cross_module_nested_config@dep-a.ts.snap deleted file mode 100644 index 39dea74a73f66..0000000000000 --- a/crates/oxc_language_server/src/snapshots/fixtures_linter_cross_module_nested_config@dep-a.ts.snap +++ /dev/null @@ -1,5 +0,0 @@ ---- -source: crates/oxc_language_server/src/tester.rs -input_file: crates/oxc_language_server/fixtures/linter/cross_module_nested_config/dep-a.ts ---- -No diagnostic reports diff --git a/crates/oxc_language_server/src/snapshots/fixtures_linter_cross_module_nested_config@folder_folder-dep-a.ts.snap b/crates/oxc_language_server/src/snapshots/fixtures_linter_cross_module_nested_config@dep-a.ts_folder__folder-dep-a.ts.snap similarity index 81% rename from crates/oxc_language_server/src/snapshots/fixtures_linter_cross_module_nested_config@folder_folder-dep-a.ts.snap rename to crates/oxc_language_server/src/snapshots/fixtures_linter_cross_module_nested_config@dep-a.ts_folder__folder-dep-a.ts.snap index 6d7e5edeb8ce2..b5970ee66f7ea 100644 --- a/crates/oxc_language_server/src/snapshots/fixtures_linter_cross_module_nested_config@folder_folder-dep-a.ts.snap +++ b/crates/oxc_language_server/src/snapshots/fixtures_linter_cross_module_nested_config@dep-a.ts_folder__folder-dep-a.ts.snap @@ -1,7 +1,14 @@ --- source: crates/oxc_language_server/src/tester.rs -input_file: crates/oxc_language_server/fixtures/linter/cross_module_nested_config/folder/folder-dep-a.ts --- +########## +file: fixtures/linter/cross_module_nested_config/dep-a.ts +---------- +No diagnostic reports +########## +file: fixtures/linter/cross_module_nested_config/folder/folder-dep-a.ts +---------- + code: "eslint-plugin-import(no-cycle)" code_description.href: "https://oxc.rs/docs/guide/usage/linter/rules/import/no-cycle.html" message: "Dependency cycle detected\nhelp: These paths form a cycle: \n-> ./folder-dep-b.ts - fixtures/linter/cross_module_nested_config/folder/folder-dep-b.ts\n-> ./folder-dep-a.ts - fixtures/linter/cross_module_nested_config/folder/folder-dep-a.ts" diff --git a/crates/oxc_language_server/src/snapshots/fixtures_linter_deny_no_console@hello_world.js.snap b/crates/oxc_language_server/src/snapshots/fixtures_linter_deny_no_console@hello_world.js.snap index 72830443424d0..cc6783346767a 100644 --- a/crates/oxc_language_server/src/snapshots/fixtures_linter_deny_no_console@hello_world.js.snap +++ b/crates/oxc_language_server/src/snapshots/fixtures_linter_deny_no_console@hello_world.js.snap @@ -1,7 +1,10 @@ --- source: crates/oxc_language_server/src/tester.rs -input_file: crates/oxc_language_server/fixtures/linter/deny_no_console/hello_world.js --- +########## +file: fixtures/linter/deny_no_console/hello_world.js +---------- + code: "eslint(no-console)" code_description.href: "https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-console.html" message: "Unexpected console statement.\nhelp: Delete this console statement." diff --git a/crates/oxc_language_server/src/snapshots/fixtures_linter_ignore_patterns@ignored-file.ts.snap b/crates/oxc_language_server/src/snapshots/fixtures_linter_ignore_patterns@ignored-file.ts.snap deleted file mode 100644 index 16dc41deb8a5c..0000000000000 --- a/crates/oxc_language_server/src/snapshots/fixtures_linter_ignore_patterns@ignored-file.ts.snap +++ /dev/null @@ -1,5 +0,0 @@ ---- -source: crates/oxc_language_server/src/tester.rs -input_file: crates/oxc_language_server/fixtures/linter/ignore_patterns/ignored-file.ts ---- -File is ignored diff --git a/crates/oxc_language_server/src/snapshots/fixtures_linter_ignore_patterns@another_config_not-ignored-file.ts.snap b/crates/oxc_language_server/src/snapshots/fixtures_linter_ignore_patterns@ignored-file.ts_another_config__not-ignored-file.ts.snap similarity index 82% rename from crates/oxc_language_server/src/snapshots/fixtures_linter_ignore_patterns@another_config_not-ignored-file.ts.snap rename to crates/oxc_language_server/src/snapshots/fixtures_linter_ignore_patterns@ignored-file.ts_another_config__not-ignored-file.ts.snap index f6e01a9b62e16..78922b319beb1 100644 --- a/crates/oxc_language_server/src/snapshots/fixtures_linter_ignore_patterns@another_config_not-ignored-file.ts.snap +++ b/crates/oxc_language_server/src/snapshots/fixtures_linter_ignore_patterns@ignored-file.ts_another_config__not-ignored-file.ts.snap @@ -1,7 +1,14 @@ --- source: crates/oxc_language_server/src/tester.rs -input_file: crates/oxc_language_server/fixtures/linter/ignore_patterns/another_config/not-ignored-file.ts --- +########## +file: fixtures/linter/ignore_patterns/ignored-file.ts +---------- +File is ignored +########## +file: fixtures/linter/ignore_patterns/another_config/not-ignored-file.ts +---------- + code: "eslint(no-debugger)" code_description.href: "https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-debugger.html" message: "`debugger` statement is not allowed\nhelp: Remove the debugger statement" diff --git a/crates/oxc_language_server/src/snapshots/fixtures_linter_invalid_syntax@debugger.ts.snap b/crates/oxc_language_server/src/snapshots/fixtures_linter_invalid_syntax@debugger.ts.snap index d7ba5f5c203d4..ee3385228e0f5 100644 --- a/crates/oxc_language_server/src/snapshots/fixtures_linter_invalid_syntax@debugger.ts.snap +++ b/crates/oxc_language_server/src/snapshots/fixtures_linter_invalid_syntax@debugger.ts.snap @@ -1,7 +1,10 @@ --- source: crates/oxc_language_server/src/tester.rs -input_file: crates/oxc_language_server/fixtures/linter/invalid_syntax/debugger.ts --- +########## +file: fixtures/linter/invalid_syntax/debugger.ts +---------- + code: "" code_description.href: "None" message: "Unexpected token" diff --git a/crates/oxc_language_server/src/snapshots/fixtures_linter_issue_9958@issue.ts.snap b/crates/oxc_language_server/src/snapshots/fixtures_linter_issue_9958@issue.ts.snap index 0497ae70bc2b9..94207d06b1512 100644 --- a/crates/oxc_language_server/src/snapshots/fixtures_linter_issue_9958@issue.ts.snap +++ b/crates/oxc_language_server/src/snapshots/fixtures_linter_issue_9958@issue.ts.snap @@ -1,7 +1,10 @@ --- source: crates/oxc_language_server/src/tester.rs -input_file: crates/oxc_language_server/fixtures/linter/issue_9958/issue.ts --- +########## +file: fixtures/linter/issue_9958/issue.ts +---------- + code: "eslint(no-extra-boolean-cast)" code_description.href: "https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-extra-boolean-cast.html" message: "Redundant double negation\nhelp: Remove the double negation as it will already be coerced to a boolean" diff --git a/crates/oxc_language_server/src/snapshots/fixtures_linter_lint_on_run_on_save@on-save.ts.snap b/crates/oxc_language_server/src/snapshots/fixtures_linter_lint_on_run_on_save@on-save.ts.snap index 49bd8796b0f76..b79fb5d1b473c 100644 --- a/crates/oxc_language_server/src/snapshots/fixtures_linter_lint_on_run_on_save@on-save.ts.snap +++ b/crates/oxc_language_server/src/snapshots/fixtures_linter_lint_on_run_on_save@on-save.ts.snap @@ -1,7 +1,10 @@ --- source: crates/oxc_language_server/src/tester.rs -input_file: crates/oxc_language_server/fixtures/linter/lint_on_run/on_save/on-save.ts --- +########## +file: fixtures/linter/lint_on_run/on_save/on-save.ts +---------- + code: "typescript-eslint(no-floating-promises)" code_description.href: "None" message: "Promises must be awaited.\nhelp: The promise must end with a call to .catch, or end with a call to .then with a rejection handler, or be explicitly marked as ignored with the `void` operator." diff --git a/crates/oxc_language_server/src/snapshots/fixtures_linter_lint_on_run_on_save@on-type.ts.snap b/crates/oxc_language_server/src/snapshots/fixtures_linter_lint_on_run_on_save@on-type.ts.snap index ec053ebe9330f..dfced02e27672 100644 --- a/crates/oxc_language_server/src/snapshots/fixtures_linter_lint_on_run_on_save@on-type.ts.snap +++ b/crates/oxc_language_server/src/snapshots/fixtures_linter_lint_on_run_on_save@on-type.ts.snap @@ -1,5 +1,7 @@ --- source: crates/oxc_language_server/src/tester.rs -input_file: crates/oxc_language_server/fixtures/linter/lint_on_run/on_save/on-type.ts --- +########## +file: fixtures/linter/lint_on_run/on_save/on-type.ts +---------- File is ignored diff --git a/crates/oxc_language_server/src/snapshots/fixtures_linter_lint_on_run_on_type@on-save-no-type-aware.ts.snap b/crates/oxc_language_server/src/snapshots/fixtures_linter_lint_on_run_on_type@on-save-no-type-aware.ts.snap index 90415976a0380..e2d3269a67f6b 100644 --- a/crates/oxc_language_server/src/snapshots/fixtures_linter_lint_on_run_on_type@on-save-no-type-aware.ts.snap +++ b/crates/oxc_language_server/src/snapshots/fixtures_linter_lint_on_run_on_type@on-save-no-type-aware.ts.snap @@ -1,5 +1,7 @@ --- source: crates/oxc_language_server/src/tester.rs -input_file: crates/oxc_language_server/fixtures/linter/lint_on_run/on_type/on-save-no-type-aware.ts --- +########## +file: fixtures/linter/lint_on_run/on_type/on-save-no-type-aware.ts +---------- File is ignored diff --git a/crates/oxc_language_server/src/snapshots/fixtures_linter_lint_on_run_on_type@on-save.ts.snap b/crates/oxc_language_server/src/snapshots/fixtures_linter_lint_on_run_on_type@on-save.ts.snap index 319a56cd5dc2a..9e82447af607e 100644 --- a/crates/oxc_language_server/src/snapshots/fixtures_linter_lint_on_run_on_type@on-save.ts.snap +++ b/crates/oxc_language_server/src/snapshots/fixtures_linter_lint_on_run_on_type@on-save.ts.snap @@ -1,7 +1,10 @@ --- source: crates/oxc_language_server/src/tester.rs -input_file: crates/oxc_language_server/fixtures/linter/lint_on_run/on_type/on-save.ts --- +########## +file: fixtures/linter/lint_on_run/on_type/on-save.ts +---------- + code: "eslint(no-debugger)" code_description.href: "https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-debugger.html" message: "`debugger` statement is not allowed\nhelp: Remove the debugger statement" diff --git a/crates/oxc_language_server/src/snapshots/fixtures_linter_lint_on_run_on_type@on-type.ts.snap b/crates/oxc_language_server/src/snapshots/fixtures_linter_lint_on_run_on_type@on-type.ts.snap index a3ad066ff3c33..fbe7b694f7881 100644 --- a/crates/oxc_language_server/src/snapshots/fixtures_linter_lint_on_run_on_type@on-type.ts.snap +++ b/crates/oxc_language_server/src/snapshots/fixtures_linter_lint_on_run_on_type@on-type.ts.snap @@ -1,7 +1,10 @@ --- source: crates/oxc_language_server/src/tester.rs -input_file: crates/oxc_language_server/fixtures/linter/lint_on_run/on_type/on-type.ts --- +########## +file: fixtures/linter/lint_on_run/on_type/on-type.ts +---------- + code: "eslint(no-debugger)" code_description.href: "https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-debugger.html" message: "`debugger` statement is not allowed\nhelp: Remove the debugger statement" diff --git a/crates/oxc_language_server/src/snapshots/fixtures_linter_multiple_suggestions@forward_ref.ts.snap b/crates/oxc_language_server/src/snapshots/fixtures_linter_multiple_suggestions@forward_ref.ts.snap index d378963bd1dc6..bf711ae766ccc 100644 --- a/crates/oxc_language_server/src/snapshots/fixtures_linter_multiple_suggestions@forward_ref.ts.snap +++ b/crates/oxc_language_server/src/snapshots/fixtures_linter_multiple_suggestions@forward_ref.ts.snap @@ -1,7 +1,10 @@ --- source: crates/oxc_language_server/src/tester.rs -input_file: crates/oxc_language_server/fixtures/linter/multiple_suggestions/forward_ref.ts --- +########## +file: fixtures/linter/multiple_suggestions/forward_ref.ts +---------- + code: "eslint-plugin-react(forward-ref-uses-ref)" code_description.href: "https://oxc.rs/docs/guide/usage/linter/rules/react/forward-ref-uses-ref.html" message: "Components wrapped with `forwardRef` must have a `ref` parameter\nhelp: Add a `ref` parameter, or remove `forwardRef`" diff --git a/crates/oxc_language_server/src/snapshots/fixtures_linter_no_errors@hello_world.js.snap b/crates/oxc_language_server/src/snapshots/fixtures_linter_no_errors@hello_world.js.snap index ac3818198bf62..cde1767321f06 100644 --- a/crates/oxc_language_server/src/snapshots/fixtures_linter_no_errors@hello_world.js.snap +++ b/crates/oxc_language_server/src/snapshots/fixtures_linter_no_errors@hello_world.js.snap @@ -1,5 +1,7 @@ --- source: crates/oxc_language_server/src/tester.rs -input_file: crates/oxc_language_server/fixtures/linter/no_errors/hello_world.js --- +########## +file: fixtures/linter/no_errors/hello_world.js +---------- No diagnostic reports diff --git a/crates/oxc_language_server/src/snapshots/fixtures_linter_regexp_feature@index.ts.snap b/crates/oxc_language_server/src/snapshots/fixtures_linter_regexp_feature@index.ts.snap index 7093e9cf0bc34..6e5c3f548fd85 100644 --- a/crates/oxc_language_server/src/snapshots/fixtures_linter_regexp_feature@index.ts.snap +++ b/crates/oxc_language_server/src/snapshots/fixtures_linter_regexp_feature@index.ts.snap @@ -1,7 +1,10 @@ --- source: crates/oxc_language_server/src/tester.rs -input_file: crates/oxc_language_server/fixtures/linter/regexp_feature/index.ts --- +########## +file: fixtures/linter/regexp_feature/index.ts +---------- + code: "eslint(no-control-regex)" code_description.href: "https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-control-regex.html" message: "Unexpected control character\nhelp: '\\u0000' is a control character." diff --git a/crates/oxc_language_server/src/snapshots/fixtures_linter_svelte@debugger.svelte.snap b/crates/oxc_language_server/src/snapshots/fixtures_linter_svelte@debugger.svelte.snap index 8db8e490734b1..7bab73a3bc470 100644 --- a/crates/oxc_language_server/src/snapshots/fixtures_linter_svelte@debugger.svelte.snap +++ b/crates/oxc_language_server/src/snapshots/fixtures_linter_svelte@debugger.svelte.snap @@ -1,7 +1,10 @@ --- source: crates/oxc_language_server/src/tester.rs -input_file: crates/oxc_language_server/fixtures/linter/svelte/debugger.svelte --- +########## +file: fixtures/linter/svelte/debugger.svelte +---------- + code: "eslint(no-unassigned-vars)" code_description.href: "https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-unassigned-vars.html" message: "'title' is always 'undefined' because it's never assigned.\nhelp: Variable declared without assignment. Either assign a value or remove the declaration." diff --git a/crates/oxc_language_server/src/snapshots/fixtures_linter_ts_path_alias@deep_src_dep-a.ts.snap b/crates/oxc_language_server/src/snapshots/fixtures_linter_ts_path_alias@deep__src__dep-a.ts.snap similarity index 90% rename from crates/oxc_language_server/src/snapshots/fixtures_linter_ts_path_alias@deep_src_dep-a.ts.snap rename to crates/oxc_language_server/src/snapshots/fixtures_linter_ts_path_alias@deep__src__dep-a.ts.snap index 466fc3f3abb3b..66e26da914d61 100644 --- a/crates/oxc_language_server/src/snapshots/fixtures_linter_ts_path_alias@deep_src_dep-a.ts.snap +++ b/crates/oxc_language_server/src/snapshots/fixtures_linter_ts_path_alias@deep__src__dep-a.ts.snap @@ -1,7 +1,10 @@ --- source: crates/oxc_language_server/src/tester.rs -input_file: crates/oxc_language_server/fixtures/linter/ts_path_alias/deep/src/dep-a.ts --- +########## +file: fixtures/linter/ts_path_alias/deep/src/dep-a.ts +---------- + code: "eslint-plugin-import(no-cycle)" code_description.href: "https://oxc.rs/docs/guide/usage/linter/rules/import/no-cycle.html" message: "Dependency cycle detected\nhelp: These paths form a cycle: \n-> @/dep-b - fixtures/linter/ts_path_alias/deep/src/dep-b.ts\n-> ./dep-a.ts - fixtures/linter/ts_path_alias/deep/src/dep-a.ts" diff --git a/crates/oxc_language_server/src/snapshots/fixtures_linter_tsgolint@no-floating-promises_index.ts.snap b/crates/oxc_language_server/src/snapshots/fixtures_linter_tsgolint@no-floating-promises__index.ts.snap similarity index 98% rename from crates/oxc_language_server/src/snapshots/fixtures_linter_tsgolint@no-floating-promises_index.ts.snap rename to crates/oxc_language_server/src/snapshots/fixtures_linter_tsgolint@no-floating-promises__index.ts.snap index 2464aa1d443f3..cf5ffe41bc6a4 100644 --- a/crates/oxc_language_server/src/snapshots/fixtures_linter_tsgolint@no-floating-promises_index.ts.snap +++ b/crates/oxc_language_server/src/snapshots/fixtures_linter_tsgolint@no-floating-promises__index.ts.snap @@ -1,7 +1,10 @@ --- source: crates/oxc_language_server/src/tester.rs -input_file: crates/oxc_language_server/fixtures/linter/tsgolint/no-floating-promises/index.ts --- +########## +file: fixtures/linter/tsgolint/no-floating-promises/index.ts +---------- + code: "typescript-eslint(no-floating-promises)" code_description.href: "None" message: "Promises must be awaited.\nhelp: The promise must end with a call to .catch, or end with a call to .then with a rejection handler, or be explicitly marked as ignored with the `void` operator." diff --git a/crates/oxc_language_server/src/snapshots/fixtures_linter_unused_disabled_directives@test.js.snap b/crates/oxc_language_server/src/snapshots/fixtures_linter_unused_disabled_directives@test.js.snap index f55f5e8f96340..404ce24a3c44a 100644 --- a/crates/oxc_language_server/src/snapshots/fixtures_linter_unused_disabled_directives@test.js.snap +++ b/crates/oxc_language_server/src/snapshots/fixtures_linter_unused_disabled_directives@test.js.snap @@ -1,7 +1,10 @@ --- source: crates/oxc_language_server/src/tester.rs -input_file: crates/oxc_language_server/fixtures/linter/unused_disabled_directives/test.js --- +########## +file: fixtures/linter/unused_disabled_directives/test.js +---------- + code: "eslint(no-console)" code_description.href: "https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-console.html" message: "Unexpected console statement.\nhelp: Delete this console statement." diff --git a/crates/oxc_language_server/src/snapshots/fixtures_linter_vue@debugger.vue.snap b/crates/oxc_language_server/src/snapshots/fixtures_linter_vue@debugger.vue.snap index c4f2946f3ffa6..23456c2bc83f1 100644 --- a/crates/oxc_language_server/src/snapshots/fixtures_linter_vue@debugger.vue.snap +++ b/crates/oxc_language_server/src/snapshots/fixtures_linter_vue@debugger.vue.snap @@ -1,7 +1,10 @@ --- source: crates/oxc_language_server/src/tester.rs -input_file: crates/oxc_language_server/fixtures/linter/vue/debugger.vue --- +########## +file: fixtures/linter/vue/debugger.vue +---------- + code: "eslint(no-debugger)" code_description.href: "https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-debugger.html" message: "`debugger` statement is not allowed\nhelp: Remove the debugger statement" diff --git a/crates/oxc_language_server/src/tester.rs b/crates/oxc_language_server/src/tester.rs index f4460f588493d..2f52c30e5691b 100644 --- a/crates/oxc_language_server/src/tester.rs +++ b/crates/oxc_language_server/src/tester.rs @@ -129,46 +129,68 @@ impl Tester<'_> { ); } - #[expect(clippy::disallowed_methods)] + pub fn test_and_snapshot_multiple_file(&self, relative_file_paths: &[&str]) { + self.test_and_snapshot_multiple_file_with_run_type( + relative_file_paths, + self.options.as_ref().map_or(Run::default(), |o| o.run), + ); + } + pub fn test_and_snapshot_single_file_with_run_type( &self, relative_file_path: &str, run_type: Run, ) { - let uri = get_file_uri(&format!("{}/{}", self.relative_root_dir, relative_file_path)); - let reports = tokio::runtime::Runtime::new().unwrap().block_on(async { - self.create_workspace_worker() - .await - .lint_file( - &uri, - None, - match run_type { - Run::OnSave => ServerLinterRun::OnSave, - Run::OnType => ServerLinterRun::OnType, - }, - ) - .await - }); - let snapshot = if let Some(reports) = reports { - if reports.is_empty() { - "No diagnostic reports".to_string() + self.test_and_snapshot_multiple_file_with_run_type(&[relative_file_path], run_type); + } + + #[expect(clippy::disallowed_methods)] + pub fn test_and_snapshot_multiple_file_with_run_type( + &self, + relative_file_paths: &[&str], + run_type: Run, + ) { + let mut snapshot_result = String::new(); + for relative_file_path in relative_file_paths { + let uri = get_file_uri(&format!("{}/{}", self.relative_root_dir, relative_file_path)); + let reports = tokio::runtime::Runtime::new().unwrap().block_on(async { + self.create_workspace_worker() + .await + .lint_file( + &uri, + None, + match run_type { + Run::OnSave => ServerLinterRun::OnSave, + Run::OnType => ServerLinterRun::OnType, + }, + ) + .await + }); + + let snapshot = if let Some(reports) = reports { + if reports.is_empty() { + "No diagnostic reports".to_string() + } else { + reports.iter().map(get_snapshot_from_report).collect::>().join("\n") + } } else { - reports.iter().map(get_snapshot_from_report).collect::>().join("\n") - } - } else { - "File is ignored".to_string() - }; + "File is ignored".to_string() + }; + + let _ = write!( + snapshot_result, + "########## \nfile: {}/{relative_file_path}\n----------\n{snapshot}\n", + self.relative_root_dir + ); + } let snapshot_name = self.relative_root_dir.replace('/', "_"); let mut settings = insta::Settings::clone_current(); settings.set_prepend_module_to_snapshot(false); settings.set_omit_expression(true); - if let Some(path) = uri.to_file_path() { - settings.set_input_file(path.as_ref()); - } - settings.set_snapshot_suffix(relative_file_path.replace('/', "_")); + settings.set_snapshot_suffix(relative_file_paths.join("_").replace('\\', "/")); settings.bind(|| { - insta::assert_snapshot!(snapshot_name, snapshot); + insta::assert_snapshot!(snapshot_name, snapshot_result); }); } }