Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

no-conditional-assignment: rewrite and check conditional expressions #2629

Merged
merged 3 commits into from Sep 13, 2017
Merged

no-conditional-assignment: rewrite and check conditional expressions #2629

merged 3 commits into from Sep 13, 2017

Conversation

ajafff
Copy link
Contributor

@ajafff ajafff commented Apr 23, 2017

PR checklist

  • Addresses an existing issue: #0000
  • New feature, bugfix, or enhancement
    • Includes tests
  • Documentation update

Overview of change:

Rewrite to walker function.

Is there anything you'd like reviewers to focus on?

The rule now allows intentional assignments like if (foo(a = b)); or if ((a || (a = b)).foo);. If this is a typo the compiler should reveal that error.

CHANGELOG.md entry:

[bugfix] no-conditional-assignment: exclude intentional assignments, e.g. inside functions
[enhancement] no-conditional-assignment added check for conditional (ternary) expressions

@adidahiya adidahiya merged commit ff1cafe into palantir:master Sep 13, 2017
@adidahiya adidahiya added this to the TSLint v5.8 milestone Sep 13, 2017
@ajafff ajafff deleted the no-conditional-assignment branch October 30, 2017 14:39
@ajafff
Copy link
Contributor Author

ajafff commented Oct 30, 2017

@seokirill the rule only forbids assignments inside of conditions.
Your first code snippet assigns a value according to the condition.
Your second example assigns a value in the condition. That's most likely a bug.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants