Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no-warning-comments to match on whole words only #1709

Closed
spadgos opened this issue Jan 24, 2015 · 2 comments

Comments

Projects
None yet
3 participants
@spadgos
Copy link
Contributor

commented Jan 24, 2015

The no-warning-comments rule just does an indexOf check to find the specified terms in the comments, which means it matches on parts of words. This isn't such a problem for terms such as "todo", "fixme", etc, but if you want to use other words in there, then you can get a lot of false positives. For example, the term "he" is found in "the". Surrounding the term with spaces doesn't help either, since it might be followed by punctuation.

My proposal: change the check to use word boundaries around each of the terms. In essence, this would make this change:

commentText.toLowerCase().indexOf('term');
// becomes
/\bterm\b/i.test(commentText);
@lo1tuma

This comment has been minimized.

Copy link
Member

commented Jan 24, 2015

Sounds like a good idea.

@nzakas

This comment has been minimized.

Copy link
Member

commented Jan 24, 2015

👍

@nzakas nzakas closed this in 9185bf3 Jan 24, 2015

nzakas added a commit that referenced this issue Jan 24, 2015

Merge pull request #1710 from spadgos/whole-word-matches
Update: no-warning-comments matches on whole word only (fixes #1709)

@eslint eslint bot locked and limited conversation to collaborators Feb 7, 2018

@eslint eslint bot added the archived due to age label Feb 7, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.