coffeelint icon indicating copy to clipboard operation
coffeelint copied to clipboard

A rule to forbid using undefined in the code

Open mitar opened this issue 9 years ago • 9 comments

Feature request.

A rule to forbid using undefined in the code. null should be used instead.

mitar avatar May 16 '15 20:05 mitar

I don't think this one is a good idea. Even though the two are often interchangeable they aren't always. I don't have an example off the top of my head, but I know I've run into a situation where I had to one and couldn't use the other.

AsaAyers avatar May 16 '15 21:05 AsaAyers

You can always temporary turn off the coffeelint for that line, no? And explain the rationale for doing so? But I prefer using null and _.isUndefined everywhere in our code, while undefined is something which comes from 3rd party libraries and JavaScript.

mitar avatar May 16 '15 21:05 mitar

I think it is at the same level as missing_fat_arrows, where for some codebases it works, and for some it does not (like if you are using AngularJS or jQuery). But this really depends on the use case.

mitar avatar May 16 '15 21:05 mitar

Can you reopen this so that I can have it for my TODO. :-)

mitar avatar May 17 '15 21:05 mitar

I agree that this one isn't great. Sometimes you actually want to know if its undefined vs null and in less code.

eddiemonge avatar May 18 '15 19:05 eddiemonge

Then you do not have to use it. :-)

mitar avatar May 18 '15 19:05 mitar

I completely agree it should be enabled by default. This is really for special codebases like API providers.

mitar avatar May 18 '15 19:05 mitar

is there any update on this? been over a year or so. otherwise the issue will be closed.

swang avatar Sep 21 '16 02:09 swang

So if it is OK for me to add this rule, then I can add it. There was no clear agreement on that.

mitar avatar Sep 21 '16 04:09 mitar