bahmutov/eslint-rules

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

DrewML opened this issue · 3 comments

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.

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

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

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.