bahmutov / eslint-rules

My custom eslint rules in addition to the ones provided at http://eslint.org/
97 stars 16 forks source link

False-positive in rule "no-commented-out-code" #10

Open DrewML opened 8 years ago

DrewML commented 8 years ago

To start with, thanks for your hard work on these rules - it's greatly appreciated!

We're seeing a false-positive in our project with comments in the following format:

// TODO: test

The issue goes away once you remove the colon. I assume the rule is equating that comment to being a property assignment inside an object literal, but I haven't dug into it yet.

DrewML commented 8 years ago

My assumption was wrong: Just ran the comment (without //) through Espree, and it's (correctly) identifying it as a LabeledStatement.

Any chance you're willing to treat an AST with only a top-level node in the body of LabeledStatement as not being code? I would guess that people more-often use the pattern TODO: or FIX: with comments than they use labels, but that's a big assumption

bahmutov commented 8 years ago

if you could implement this (with unit tests as a plus), I would gladly merge the code for you

DylanVann commented 6 years ago

I would just change the comment to something like:

// TODO: Add test for x functionality.

I think even TODO: test. passes. More like a sentence, less like code.