mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 20:28:58 +00:00
feat(linter): import/no-cycle should turn on ignore_types by default (#6761)
closes #6759
This commit is contained in:
parent
8387bac51f
commit
dbe1972283
2 changed files with 6 additions and 15 deletions
|
|
@ -37,7 +37,7 @@ impl Default for NoCycle {
|
|||
fn default() -> Self {
|
||||
Self {
|
||||
max_depth: u32::MAX,
|
||||
ignore_types: false,
|
||||
ignore_types: true,
|
||||
ignore_external: false,
|
||||
allow_unsafe_dynamic_cyclic_dependency: false,
|
||||
}
|
||||
|
|
@ -93,24 +93,25 @@ declare_oxc_lint!(
|
|||
impl Rule for NoCycle {
|
||||
fn from_configuration(value: serde_json::Value) -> Self {
|
||||
let obj = value.get(0);
|
||||
let default = NoCycle::default();
|
||||
Self {
|
||||
max_depth: obj
|
||||
.and_then(|v| v.get("maxDepth"))
|
||||
.and_then(serde_json::Value::as_number)
|
||||
.and_then(serde_json::Number::as_u64)
|
||||
.map_or(u32::MAX, |n| n as u32),
|
||||
.map_or(default.max_depth, |n| n as u32),
|
||||
ignore_types: obj
|
||||
.and_then(|v| v.get("ignoreTypes"))
|
||||
.and_then(serde_json::Value::as_bool)
|
||||
.unwrap_or_default(),
|
||||
.unwrap_or(default.ignore_types),
|
||||
ignore_external: obj
|
||||
.and_then(|v| v.get("ignoreExternal"))
|
||||
.and_then(serde_json::Value::as_bool)
|
||||
.unwrap_or_default(),
|
||||
.unwrap_or(default.ignore_external),
|
||||
allow_unsafe_dynamic_cyclic_dependency: obj
|
||||
.and_then(|v| v.get("allowUnsafeDynamicCyclicDependency"))
|
||||
.and_then(serde_json::Value::as_bool)
|
||||
.unwrap_or_default(),
|
||||
.unwrap_or(default.allow_unsafe_dynamic_cyclic_dependency),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -356,7 +357,6 @@ fn test() {
|
|||
// (r#"import { bar } from "./flow-types-depth-one""#, None),
|
||||
(r#"import { foo } from "./intermediate-ignore""#, None),
|
||||
(r#"import { foo } from "./ignore""#, None),
|
||||
(r#"import { foo } from "./typescript/ts-types-only-importing-type";"#, None),
|
||||
(
|
||||
r#"import { foo } from "./typescript/ts-types-some-type-imports";"#,
|
||||
Some(json!([{"ignoreTypes":true}])),
|
||||
|
|
|
|||
|
|
@ -262,15 +262,6 @@ source: crates/oxc_linter/src/tester.rs
|
|||
-> ./ignore - fixtures/import/cycles/ignore/index.js
|
||||
-> ../depth-zero - fixtures/import/cycles/depth-zero.js
|
||||
|
||||
⚠ eslint-plugin-import(no-cycle): Dependency cycle detected
|
||||
╭─[cycles/depth-zero.js:1:21]
|
||||
1 │ import { foo } from "./typescript/ts-types-only-importing-type";
|
||||
· ───────────────────────────────────────────
|
||||
╰────
|
||||
help: These paths form a cycle:
|
||||
-> ./typescript/ts-types-only-importing-type - fixtures/import/cycles/typescript/ts-types-only-importing-type.ts
|
||||
-> ../depth-zero - fixtures/import/cycles/depth-zero.js
|
||||
|
||||
⚠ eslint-plugin-import(no-cycle): Dependency cycle detected
|
||||
╭─[cycles/depth-zero.js:1:21]
|
||||
1 │ import { foo } from "./typescript/ts-types-some-type-imports";
|
||||
|
|
|
|||
Loading…
Reference in a new issue