π Enforce better comment content.
π« This rule is disabled in the following configs: β
recommended, βοΈ unopinionated.
π§ This rule is automatically fixable by the --fix CLI option.
This rule enforces curated replacements in comments. It is useful for common name, brand, and acronym casing corrections such as nodejs β Node.js, and for project-specific prose preferences.
This rule is not a spellchecker. It only checks known replacement patterns.
It only reports one replacement per comment at a time.
It focuses on prose-like comment text and skips obvious non-prose regions such as code snippets, including commented-out multi-line code, links, paths, structured data, and command examples.
// β
// nodejs uses javascript.
// β
// Node.js uses JavaScript.// β
// See the github issue.
// β
// See the GitHub issue.// β
// The application stores png files.
// β
// The app stores PNG files.Type: object
Type: boolean
Default: true
By default, the rule re-cases matching tokens regardless of their case, including all-lowercase (json) and all-uppercase (JSON) ones.
Pass checkUniformCase: false to only correct tokens that already mix upper- and lower-case, such as Github β GitHub. All-lowercase and all-uppercase tokens are then left alone, as their casing is often intentional. Replacements that change the actual letters (such as application β app, or your own typo fixes) still apply regardless of case.
'unicorn/comment-content': [
'error',
{
checkUniformCase: false,
},
]Type: object
You can extend the default replacements by passing the replacements option.
The key is treated as a regex. By default, custom replacements are case-sensitive.
'unicorn/comment-content': [
'error',
{
replacements: {
'\\bteh\\b': 'the',
'\\bto do\\b': {
replacement: 'TODO',
caseSensitive: false,
},
'\\bnode\\.?js\\b': false,
},
},
]Type: boolean
Default: true
Pass extendDefaultReplacements: false to override the default replacements completely.
'unicorn/comment-content': [
'error',
{
extendDefaultReplacements: false,
replacements: {
'\\bteh\\b': 'the',
},
},
]