format-comment
added in: 4.11.0
style
Prefer format comments like sentences.
Use ignored-patterns
configuration, if you want to ignore comments that match the given regular expressions.
Use only-doc-comments
configuration, if you want to check only documentation comments (///
).
⚙️ Config example
dart_code_metrics:
...
rules:
...
- format-comment:
only-doc-comments: true
ignored-patterns:
- ^ cSpell.* # Ignores all the comments that start with 'cSpell' (for example: '// cSpell:disable-next-line').
Example
❌ Bad:
// prefer format comments like sentences // LINT
class Test {
/// with start space with dot. // LINT
Test() {
// with start space with dot. // LINT
}
/// With start space without dot // LINT
function() {
//Without start space without dot // LINT
}
}
/* prefer format comments
like sentences */ // LINT
✅ Good:
// Prefer format comments like sentences.
class Test {
/// With start space with dot.
Test() {
// With start space with dot.
}
/// With start space without dot.
function() {
// Without start space without dot.
}
}
/* Prefer format comments
like sentences. */