Rule: `no-obvious-cycle`
igorkamyshev opened this issue · 2 comments
I've found a code in some codebases like this:
forward({ from: submit, to: submit });
Of course, it leads to bug. We can detect such cases in linter.
I've discussed this rule in the effector's chat, and many people voiced their concerns that this rule is not entirely worth implementing.
- Simple cases like
forward({ from: submit, to: submit });
are easy to detect at the early stages. - Not all cases can lead to a cycle, for example
sample({ clock: foo, filter, fn, target: foo })
- Some cases are really hard to detect, for example
const foo = createEvent();
const $bar = createStore("bar");
const foobar = sample({
clock: foo,
source: $bar
})
// somewhere in another module
sample({
clock: foobar,
target: foo
})
I do not get it 🤔
Original example (which I saw in real codebase) in the issue is definitely a buggy code, and we can detect it statically.
forward({ from: submit, to: submit });
Why should we remove this rule? Of course, it cannot detect any bug, as well as any other rule. For me, it is not a reason to remove the whole rule.
This plugin does not aim to fix only "smart" bugs, it is trying to help developers introduce fewer bugs. So, this rule would help to find "stupid" bug earlier, event before build.