Skip to content
NewBun 1.4.5 is out. Release notes
AphrodyBun

Linter · Rules

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:

bunfig.toml
[lint.rules]
"capitalized-comments" = "error" # or "warn"

Every option, set to its default. The ones that are commented out are unset by default.

bunfig.toml
[lint.rules]
"capitalized-comments" = [
  "error",
  "always", # "always" or "never"
  {
    # ignorePattern = <string>,
    ignoreInlineComments = false,
    ignoreConsecutiveComments = false,
    # line = <object>,
    # block = <object>,
  },
]

Examples

Reported:

// retry once, then give up
await send(message);

Not reported:

// 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

bunfig.toml
[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.

// Retry once, then give up
await send(message);

The second option is an object:

OptionDefaultWhat it does
ignorePatternnoneA regular expression. A comment that starts with a match isn't checked.
ignoreInlineCommentsfalseDon't check a comment that has code before and after it on the same line.
ignoreConsecutiveCommentsfalseDon't check a comment that comes right after another comment, so only the first line of a group counts.
const editor = import(/* webpackChunkName: "editor" */ "./editor.js");
function resize(width, /* optional */ height) {}
// 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:

// webpack splits the bundle here
const editor = import(/* webpackChunkName: "editor" */ "./editor.js");