Skip to content

Commit

Permalink
fix: make default factories check stricter
Browse files Browse the repository at this point in the history
  • Loading branch information
kireevmp committed Sep 28, 2024
1 parent ce70ffe commit 48113f4
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/grumpy-buses-push.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@effector/swc-plugin": patch
---

Make default factories check stricter
4 changes: 3 additions & 1 deletion src/visitors/analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,13 @@ impl Analyzer {
if INTERNAL
.factories
.iter()
.any(|factory| import.starts_with(factory))
.filter_map(|&factory| import.strip_prefix(factory))
.any(|import| import.is_empty() || import.starts_with('/'))
{
return true;
}

// Strict rules for custom factories
if self
.config
.factories
Expand Down
1 change: 1 addition & 0 deletions tests/fixtures/factories/default-are-strict/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
5 changes: 5 additions & 0 deletions tests/fixtures/factories/default-are-strict/input.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { createFake } from "patronum-fake";
import { createOtherFake } from "patronum-fake/other";

const fake = createFake();
const other = createOtherFake();
4 changes: 4 additions & 0 deletions tests/fixtures/factories/default-are-strict/output.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { createFake } from "patronum-fake";
import { createOtherFake } from "patronum-fake/other";
const fake = createFake();
const other = createOtherFake();

0 comments on commit 48113f4

Please sign in to comment.