Appearance
Enforces or disallows capitalization of the first letter of a comment.
Inconsistent capitalization of comments can make code harder to read. This rule helps enforce a consistent style across the codebase.
Examples of incorrect code for this rule with the default "always" option:
"always"
// lowercase comment /* lowercase block comment */
Examples of correct code for this rule with the default "always" option:
// Capitalized comment /* Capitalized block comment */ // 123 - comments starting with non-letters are ignored
Configuration for the capitalized-comments rule.
The first element specifies whether comments should "always" or "never" begin with a capital letter. The second element is an optional object containing additional options.
"never"
type: "always" | "never"
"always" | "never"
This option is an object with the following properties:
type: boolean
boolean
If true, consecutive comments will be ignored after the first comment.
If true, inline comments (comments in the middle of code) will be ignored.
type: string
string
A regex pattern. Comments that match the pattern will not cause violations.
To enable this rule using the config file or in the CLI, you can use:
{ "rules": { "capitalized-comments": "error" } }
import { defineConfig } from "oxlint"; export default defineConfig({ rules: { "capitalized-comments": "error", }, });
oxlint --deny capitalized-comments
This rule was added in v1.34.0.
eslint/capitalized-comments Style
What it does
Enforces or disallows capitalization of the first letter of a comment.
Why is this bad?
Inconsistent capitalization of comments can make code harder to read. This rule helps enforce a consistent style across the codebase.
Examples
Examples of incorrect code for this rule with the default
"always"option:Examples of correct code for this rule with the default
"always"option:Configuration
Configuration for the capitalized-comments rule.
The first element specifies whether comments should
"always"or"never"begin with a capital letter. The second element is an optional object containing additional options.The 1st option
type:
"always" | "never"The 2nd option
This option is an object with the following properties:
ignoreConsecutiveComments
type:
booleanIf true, consecutive comments will be ignored after the first comment.
ignoreInlineComments
type:
booleanIf true, inline comments (comments in the middle of code) will be ignored.
ignorePattern
type:
stringA regex pattern. Comments that match the pattern will not cause violations.
How to use
To enable this rule using the config file or in the CLI, you can use:
Version
This rule was added in v1.34.0.
References