Skip to content
This repository was archived by the owner on Jul 16, 2023. It is now read-only.

Commit d1d7dd8

Browse files
authored
fix: correctly support dartdoc tags for format-comment (#1182)
1 parent 7c62edf commit d1d7dd8

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
* fix: correctly support dartdoc tags for [`format-comment`](https://dcm.dev/docs/individuals/rules/common/format-comment).
6+
37
## 5.6.0-dev.1
48

59
* docs: remove old website

lib/src/analyzers/lint_analyzer/rules/rules_list/format_comment/visitor.dart

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ part of 'format_comment_rule.dart';
33
const _punctuation = ['.', '!', '?', ':'];
44

55
final _sentencesRegExp = RegExp(r'(?<=([\.|:](?=\s|\n|$)))');
6-
final _regMacrosExp = RegExp('{@(template|macro) .+}');
7-
const _macrosEndExp = '{@endtemplate}';
6+
final _regMacrosExp = RegExp('{@.+}');
87
const _ignoreExp = 'ignore:';
98
const _ignoreForFileExp = 'ignore_for_file:';
109

@@ -141,16 +140,14 @@ class _Visitor extends RecursiveAstVisitor<void> {
141140
final trimmed = text.trim();
142141

143142
return _regMacrosExp.hasMatch(text) ||
144-
text.contains(_macrosEndExp) ||
145143
_isIgnoreComment(trimmed) ||
146144
_isIgnoredPattern(trimmed);
147145
}
148146

149147
bool _isIgnoreComment(String text) =>
150148
text.startsWith(_ignoreExp) || text.startsWith(_ignoreForFileExp);
151149

152-
bool _isMacros(String text) =>
153-
_regMacrosExp.hasMatch(text) || text == _macrosEndExp;
150+
bool _isMacros(String text) => _regMacrosExp.hasMatch(text);
154151

155152
bool _isIgnoredPattern(String text) =>
156153
_ignoredPatterns.any((regExp) => regExp.hasMatch(text));

test/src/analyzers/lint_analyzer/rules/rules_list/format_comment/examples/example_documentation.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,6 @@ void f3() {}
2828

2929
/// {@template my_project.my_class.my_method}
3030
void f4() {}
31+
32+
/// {@nodoc}
33+
void f5() {}

0 commit comments

Comments
 (0)