Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rule: no-obvious-cycle #89

Open
igorkamyshev opened this issue Feb 4, 2022 · 2 comments
Open

Rule: no-obvious-cycle #89

igorkamyshev opened this issue Feb 4, 2022 · 2 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@igorkamyshev
Copy link
Member

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.

@igorkamyshev igorkamyshev added bug Something isn't working good first issue Good for newcomers labels Feb 4, 2022
@igorkamyshev igorkamyshev added enhancement New feature or request and removed bug Something isn't working labels Jun 16, 2022
@ainursharaev
Copy link
Contributor

I've discussed this rule in the effector's chat, and many people voiced their concerns that this rule is not entirely worth implementing.

  1. Simple cases like forward({ from: submit, to: submit }); are easy to detect at the early stages.
  2. Not all cases can lead to a cycle, for example sample({ clock: foo, filter, fn, target: foo })
  3. 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
})

@igorkamyshev
Copy link
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants