capitalized-comments
Require comments to start with a capital letter, or forbid it
This is a style rule that makes every comment start the same way. By default, a comment that starts with a lowercase letter is reported.
Comments that start with something other than a letter, comments that start with a URL, and comments for tools such as eslint-disable, global or istanbul ignore are never reported.
--fix changes the case of the first letter.
Configure#
Off by default. To turn it on:
[lint.rules]
"capitalized-comments" = "error" # or "warn"Every option, set to its default. The ones that are commented out are unset by default.
[lint.rules]
"capitalized-comments" = [
"error",
"always", # "always" or "never"
{
# ignorePattern = <string>,
ignoreInlineComments = false,
ignoreConsecutiveComments = false,
# line = <object>,
# block = <object>,
},
]Examples#
// retry once, then give upComments should not begin with a lowercase character.
await send(message);// Retry once, then give up
await send(message);
// 3 attempts at most
// https://example.com/retries explains why
/* eslint-disable-next-line no-console */
console.log("sent");Options#
[lint.rules]
capitalized-comments = ["error", "always", { ignoreConsecutiveComments = true }]The first option is "always" (default), which requires a capital letter, or "never", which requires a lowercase letter.
"never"1 problem// Retry once, then give upComments should not begin with an uppercase character.
await send(message);The second option is an object:
| Option | Default | What it does |
|---|---|---|
ignorePattern | none | A regular expression. A comment that starts with a match isn't checked. |
ignoreInlineComments | false | Don't check a comment that has code before and after it on the same line. |
ignoreConsecutiveComments | false | Don't check a comment that comes right after another comment, so only the first line of a group counts. |
"always", { "ignorePattern": "webpack" }No problemsconst editor = import(/* webpackChunkName: "editor" */ "./editor.js");"always", { "ignoreInlineComments": true }No problemsfunction resize(width, /* optional */ height) {}"always", { "ignoreConsecutiveComments": true }No problems// Retry once, then give up,
// so that a slow server does not block the queue
await send(message);To use different settings for // and /* */ comments, put the same options under line and block. Here only the // comment is reported:
"always", { "block": { "ignorePattern": "webpack" } }1 problem// webpack splits the bundle hereComments should not begin with a lowercase character.
const editor = import(/* webpackChunkName: "editor" */ "./editor.js");