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: keep-options-order #61

Closed
Kelin2025 opened this issue Oct 20, 2021 · 7 comments · Fixed by #81
Closed

Rule: keep-options-order #61

Kelin2025 opened this issue Oct 20, 2021 · 7 comments · Fixed by #81
Labels
enhancement New feature or request

Comments

@Kelin2025
Copy link
Member

Story

For now, we can write sample/guard in any order:

sample({
  target: foo, 
  fn: (bar) => Baz, 
  source: bar, 
  clock: clock
}) 

Would be nice to enforce a more convenient order
E.g. source->clock->fn->target (or clock first)

Extra stuff

  • We also need the same thing for @sergeysova patronum I guess
@igorkamyshev igorkamyshev added the enhancement New feature or request label Oct 20, 2021
@igorkamyshev
Copy link
Member

In my opinion, clock->source->fn->target is better because clock is primary.

@doasync
Copy link
Member

doasync commented Oct 26, 2021

@igorkamyshev it's not better, it's just a different opinion. The first param in fn is source... then goes clock. I think, there should be an option to choose.

@igorkamyshev
Copy link
Member

I disagree. Linter should give your consistency, not options.

@sergeysova sergeysova changed the title Rule: keep-options-order Rule: keep-options-order Nov 9, 2021
@sergeysova
Copy link
Collaborator

Also, it should autofix

@doasync
Copy link
Member

doasync commented Nov 11, 2021

@igorkamyshev Why not use the order of fn params?

What should be the order of guard options?

Linter should give your consistency, not options.

Linter can give options, you can use default ones for consistency. Or do you want to force your opinion without a choice?

It's good for maintainer to discuss with the community before making such a decision.

@sergeysova
Copy link
Collaborator

I like the natural order of options: just like you read it.

sample({ source, clock, fn, target })
When clock is triggered, read data from source, pass it thru fn, and sent to target

As we see, order is clock, source, fn, target


The same for guard

guard({ clock, source, filter, target })

When clock is triggered, check filter for truthy, read data from source, send it to target.
Order is: clock, filter, source, target.

@doasync
Copy link
Member

doasync commented Nov 14, 2021

Yeah, I understand your point. It seems good as the default order. I could get used to that.

But you both ignore the fact that source data comes before clock data in the fn parameters. Many people are used to this alternative order. Why are you sure that the option is unacceptable here?

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

Successfully merging a pull request may close this issue.

4 participants