comment-one-sentence-per-line
Enforce one sentence per comment line, collapse simple block comments to one line, and optionally require ending punctuation.
- Rule ID:
tai-kun/comment-one-sentence-per-line - Auto-fix: Partial (line joins and single-line block comments)
Joins sentences that wrap across several comment lines. Simple /** */ block comments without JSDoc tags that contain a single sentence are collapsed to one line. When requireEndPunctuation is enabled, prose lines that do not end with punctuation such as 。 or . are also reported. Lines ending with : or : are treated as sentence ends.
Configuration
Add the rule to lint.rules in vite.config.ts to enable it.
"tai-kun/comment-one-sentence-per-line": ["error", { requireEndPunctuation: true }],
Options
| Option | Type | Default | Description |
|---|---|---|---|
requireEndPunctuation |
boolean |
false |
Require ending punctuation on the last prose line of a comment. |
Examples
Invalid
// This is a sentence that
// wraps across two lines
/**
* This is a sentence.
*/
Valid
// This is a sentence that wraps across two lines.
/** This is a sentence. */
Notes
- Directives, JSDoc tags, lists, code, code fences, and
@exampleblocks are ignored. - Lines ending with
:or:(such as label lines) are treated as sentence ends and are not joined with the next line. - Simple block comments without JSDoc tags are collapsed to a single
/** ... */line when they contain only one sentence. Comments with multiple sentences or blank lines are left unchanged. - Line joins and block comment collapsing are auto-fixed, but missing ending punctuation is not.
requireEndPunctuationdefaults tofalse.