Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"plugins": [
"import"
],
"rules": {
"import/no-cycle": "error"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Debugger should be shown as a warning
debugger;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// should report cycle detected
import { b } from './dep-b.ts';

b();
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// this file is also included in dep-a.ts and dep-a.ts should report a no-cycle diagnostic
import './dep-a.ts';

export function b() { /* ... */ }
33 changes: 33 additions & 0 deletions crates/oxc_language_server/src/linter/server_linter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,37 @@ mod test {
Tester::new().test_and_snapshot_single_file("fixtures/linter/vue/debugger.vue");
Tester::new().test_and_snapshot_single_file("fixtures/linter/svelte/debugger.svelte");
}

#[test]
fn test_cross_module_debugger() {
let config_store: oxc_linter::ConfigStore = ConfigStoreBuilder::from_oxlintrc(
false,
Oxlintrc::from_file(&PathBuf::from("fixtures/linter/cross_module/.oxlintrc.json"))
.unwrap(),
)
.unwrap()
.build()
.unwrap();
let linter = Linter::new(LintOptions::default(), config_store);

Tester::new_with_linter(linter)
.test_and_snapshot_single_file("fixtures/linter/cross_module/debugger.ts");
}

#[test]
// ToDo: only available with runtime oxc-project/oxc#10268
fn test_cross_module_no_cycle() {
let config_store = ConfigStoreBuilder::from_oxlintrc(
false,
Oxlintrc::from_file(&PathBuf::from("fixtures/linter/cross_module/.oxlintrc.json"))
.unwrap(),
)
.unwrap()
.build()
.unwrap();
let linter = Linter::new(LintOptions::default(), config_store);

Tester::new_with_linter(linter)
.test_and_snapshot_single_file("fixtures/linter/cross_module/dep-a.ts");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
source: crates/oxc_language_server/src/linter/tester.rs
---
code: "eslint(no-debugger)"
code_description.href: "https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-debugger"
message: "`debugger` statement is not allowed\nhelp: Remove the debugger statement"
range: Range { start: Position { line: 1, character: 0 }, end: Position { line: 1, character: 9 } }
related_information[0].message: ""
related_information[0].location.uri: "file://<variable>/fixtures/linter/cross_module/debugger.ts"
related_information[0].location.range: Range { start: Position { line: 1, character: 0 }, end: Position { line: 1, character: 9 } }
severity: Some(Warning)
source: Some("oxc")
tags: None
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
source: crates/oxc_language_server/src/linter/tester.rs
---
No diagnostic reports
Loading