Disallow Warning Comments (no-warning-comments)

Developers often add comments to code which is not complete or needs review. Most likely you want to fix or review the code, and then remove the comment, before you consider the code to be production ready.

// TODO: do something
// FIXME: this is not a good idea

Rule Details

This rule reports comments that include any of the predefined terms specified in its configuration.

Options

This rule has an options object literal:

Example of incorrect code for the default { "terms": ["todo", "fixme", "xxx"], "location": "start" } options:

/*eslint no-warning-comments: "error"*/

function callback(err, results) {
  if (err) {
    console.error(err);
    return;
  }
  // TODO
}

Example of correct code for the default { "terms": ["todo", "fixme", "xxx"], "location": "start" } options:

/*eslint no-warning-comments: "error"*/

function callback(err, results) {
  if (err) {
    console.error(err);
    return;
  }
  // NOT READY FOR PRIME TIME
  // but too bad, it is not a predefined warning term
}

terms and location

Examples of incorrect code for the { "terms": ["todo", "fixme", "any other term"], "location": "anywhere" } options:

/*eslint no-warning-comments: ["error", { "terms": ["todo", "fixme", "any other term"], "location": "anywhere" }]*/

// TODO: this
// todo: this too
// Even this: TODO
/* /*
 * The same goes for this TODO comment
 * Or a fixme
 * as well as any other term
 */

Examples of correct code for the { "terms": ["todo", "fixme", "any other term"], "location": "anywhere" } options:

/*eslint no-warning-comments: ["error", { "terms": ["todo", "fixme", "any other term"], "location": "anywhere" }]*/

// This is to do
// even not any other    term
// any other terminal
/*
 * The same goes for block comments
 * with any other interesting term
 * or fix me this
 */

When Not To Use It

Version

This rule was introduced in ESLint 0.4.4.

Resources