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

Feature request, prefer-less-than rule: Add exception for literals, be consistent with eslint native "yoda" rule #40

Open
iliubinskii opened this issue Feb 18, 2022 · 0 comments

Comments

@iliubinskii
Copy link

I just added this rule and getting warning for a code like this:

if (datetime.create(datetimeString).hours() >= 12) ...

According to the rule I should rewrite it as:

if (12  <= datetime.create(datetimeString).hours()) ...

However in this case I get warning from "yoda" rule:

image

I think in this case yoda approach is better.

Is it possible to add exception for literal (yodaStyleForLiterals option):

if (x > 3) ...

Also there might be separate option for ranges (outsideOrderForRanges option):

if (1 < x && x > 3)

or insideOrderForRanges

if (x > 1 && 3 < x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant