diff --git a/rules/no-duplicate-on/examples/correct-with-factories.ts b/rules/no-duplicate-on/examples/correct-with-factories.ts new file mode 100644 index 0000000..878820c --- /dev/null +++ b/rules/no-duplicate-on/examples/correct-with-factories.ts @@ -0,0 +1,17 @@ +// Example was found in production code-base with false-positive. + +import { createEvent, createStore } from "effector"; + +function createField() { + return { + $value: createStore(""), + }; +} + +const change = createEvent<{ first: string; second: string }>(); + +const firstField = createField(); +const secondField = createField(); + +firstField.$value.on(change, (_, { first }) => first); +secondField.$value.on(change, (_, { second }) => second); diff --git a/rules/no-duplicate-on/no-duplicate-on.ts.test.js b/rules/no-duplicate-on/no-duplicate-on.ts.test.js index a80260e..b5b7ad3 100644 --- a/rules/no-duplicate-on/no-duplicate-on.ts.test.js +++ b/rules/no-duplicate-on/no-duplicate-on.ts.test.js @@ -24,6 +24,7 @@ ruleTester.run("effector/no-duplicate-on.ts.test", rule, { valid: [ "correct.ts", "correct-with-scopes.ts", + "correct-with-factories.ts", "correct-with-nesting.ts", "correct-with-empty-on.ts", ].map(readExampleForTheRule),