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

yoda expressions #175

Closed
nichdiekuh opened this issue Jun 27, 2015 · 5 comments

Comments

@nichdiekuh
Copy link

commented Jun 27, 2015

Hi,

I was wanted to apply the standard rules on my codebase, but then I hit the yoda rule and felt strongly discouraged. Are there any strong arguments against using yoda expressions?
I can get the rid of semicolons and everything, but for some reason I'm struggeling to give up on yoda expressions.
Is it possible to add an exception for this case?

@feross

This comment has been minimized.

Copy link
Member

commented Jun 27, 2015

Yoda expressions are less readable because they're backwards from how an english sentence works. You can read more at the eslint rule page.

If you really want, you can fork standard and change the rule. Or, you can use the eslint shareable config and .eslintrc to customize the rules:

{
  "extends": ["standard", "standard-react"],
  "rules": {
    "yoda": 0
  }
}

But really, the point of standard is to eliminate these types of style discussions. If you care so strongly about one rule, standard might not be for you.

@feross feross closed this Jun 27, 2015

@nichdiekuh

This comment has been minimized.

Copy link
Author

commented Jun 27, 2015

I see your point, thank you for the explanation!

@feross

This comment has been minimized.

Copy link
Member

commented Jun 27, 2015

No problem!

@dcousens

This comment has been minimized.

Copy link
Member

commented Jul 1, 2015

@nichdiekuh remembering, the primary principle behind using a yoda expression is to avoid the mistake of [accidentally] writing if (myVar = "something").
This mistake is already caught by other rules in standard IIRC, so yoda expressions don't serve their intended purpose.

@feross

This comment has been minimized.

Copy link
Member

commented Jul 1, 2015

@dcousens Yep, you're correct.

@lock lock bot locked as resolved and limited conversation to collaborators May 11, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
3 participants
You can’t perform that action at this time.