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

assignment operation inside an 'if' condition should be marked with a warning #507

Closed
AGiorgetti opened this issue Jul 16, 2015 · 4 comments

Comments

@AGiorgetti
Copy link

If we want to spot some more bugs at compile time, I believe that something like:

if (data.id = id) { ...

while being perfectly legal, it can be a coding bug most of the times.
it would be nice if TsLint could spot this type of code and give us a warning instead of using a custom regex that scan all our files.

@adidahiya
Copy link
Contributor

sounds good. it could be called... no-assignment-in-conditional? cc @ashwinr for thoughts on rule name

@ashwinr
Copy link
Contributor

ashwinr commented Jul 20, 2015

eslint has the same rule. even just no-conditional-assignment seems good.

@jkillian
Copy link
Contributor

ESLint has an option for the rule where they allow assignments that are wrapped in parenthesis. Do we want the same option or should we ust flag all assignments in a conditional no matter what?

@adidahiya
Copy link
Contributor

let's just do the simple thing for now and disallow all assignments in a conditional. we can add the other option later if it's requested.

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

No branches or pull requests

5 participants