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

feat(eslint-plugin): [no-unnece-cond] Add allowConstantLoopConditions #1029

Conversation

a-tarasyuk
Copy link
Contributor

Fixes #1015

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @a-tarasyuk!

typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community.

The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately.

Thanks again!


🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint. As a thank you, your profile/company logo will be added to our main README which receives thousands of unique visitors per day.

@codecov
Copy link

codecov bot commented Oct 1, 2019

Codecov Report

Merging #1029 into master will increase coverage by <.01%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master    #1029      +/-   ##
==========================================
+ Coverage   94.23%   94.24%   +<.01%     
==========================================
  Files         126      126              
  Lines        5377     5384       +7     
  Branches     1510     1513       +3     
==========================================
+ Hits         5067     5074       +7     
  Misses        177      177              
  Partials      133      133
Impacted Files Coverage Δ
...slint-plugin/src/rules/no-unnecessary-condition.ts 100% <100%> (ø) ⬆️

@bradzacher
Copy link
Member

I haven't reviewed the code yet - but I think I'd rather it if the option was named "allowConstantLoopConditions". To me "checkLoops" implies that you're turning off checks for loops entirely.

@bradzacher bradzacher added the enhancement: plugin rule option New rule option for an existing eslint-plugin rule label Oct 1, 2019
@Retsam
Copy link
Contributor

Retsam commented Oct 21, 2019

Do we need to have this behavior behind an option? I know it's consistent with no-constant-condition to put this behavior behind and option, but it almost seems unnecessary. If someone's writing while(true) it seems pretty clear that it's intentional and not an unnecessary condition.

Certainly, some people would like a linter error on that line, because they want the linter to forbid infinite loops; but that seems like a stylistic preference that's a bit tangential to the purpose of this rule. (Which is intended to be a correctness rule, more than stylistic) Maybe forbidding infinite loops should be the purview of some other rule - maybe a rule specific to that purpose.

@bradzacher
Copy link
Member

Do we need to have this behavior behind an option

Enhancements need to be backward compatible.
Removing the check is a breaking change, so it needs to be behind a default false option, or else this PR will have to wait for the 3.0 release.

@a-tarasyuk a-tarasyuk closed this Oct 24, 2019
@a-tarasyuk a-tarasyuk reopened this Nov 18, 2019
Copy link
Member

@bradzacher bradzacher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code and test mostly LGTM.
one comment to address and then we can merge this in.

@bradzacher bradzacher added the awaiting response Issues waiting for a reply from the OP or another party label Nov 21, 2019
@bradzacher bradzacher changed the title feat(eslint-plugin): [no-unnecessary-condition] Add an option to allow `while (true) feat(eslint-plugin): [no-unnecessary-condition] Add option allowConstantLoopConditions Nov 21, 2019
Copy link
Member

@bradzacher bradzacher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - thanks for this!

@bradzacher bradzacher removed the awaiting response Issues waiting for a reply from the OP or another party label Nov 21, 2019
@bradzacher bradzacher changed the title feat(eslint-plugin): [no-unnecessary-condition] Add option allowConstantLoopConditions feat(eslint-plugin): [no-unnece-cond] Add allowConstantLoopConditions Nov 21, 2019
@bradzacher bradzacher merged commit ceb6f1c into typescript-eslint:master Nov 21, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement: plugin rule option New rule option for an existing eslint-plugin rule
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[no-unnecessary-condition] Add an option to allow while (true)
3 participants