Skip to content

Commit 7b4ce74

Browse files
committed
feat: support references-empty rule.(fix #17)
1 parent ca161c9 commit 7b4ce74

File tree

4 files changed

+25
-1
lines changed

4 files changed

+25
-1
lines changed

lib/src/ensure.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ bool ensureEmpty(dynamic raw) {
7474
if (raw is String) {
7575
return raw.isEmpty;
7676
}
77-
if (raw is Iterable<String>) {
77+
if (raw is Iterable) {
7878
return raw.isEmpty;
7979
}
8080
return false;

lib/src/rules.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ Map<String, RuleFunction> get supportedRules => {
3636
'footer-max-length': maxLengthRule(CommitComponent.footer),
3737
'footer-max-line-length': maxLineLengthRule(CommitComponent.footer),
3838
'footer-min-length': minLengthRule(CommitComponent.footer),
39+
'references-empty': emptyRule(CommitComponent.references),
3940
};
4041

4142
/// Build full stop rule for commit component.

lib/src/types/commit.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ class Commit {
5353
return body as T?;
5454
case CommitComponent.footer:
5555
return footer as T?;
56+
case CommitComponent.references:
57+
return references as T?;
5658
}
5759
}
5860
}
@@ -64,6 +66,7 @@ enum CommitComponent {
6466
header,
6567
body,
6668
footer,
69+
references,
6770
}
6871

6972
/// Commit Note

test/lint_test.dart

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,26 @@ void main() {
9292
throwsRangeError);
9393
});
9494

95+
test('succeds for issue', () async {
96+
final result = await lint('somehting #1', {
97+
'references-empty': Rule(
98+
severity: RuleSeverity.error,
99+
condition: RuleCondition.never,
100+
),
101+
});
102+
expect(result.valid, true);
103+
});
104+
105+
test('fails for issue', () async {
106+
final result = await lint('somehting #1', {
107+
'references-empty': Rule(
108+
severity: RuleSeverity.error,
109+
condition: RuleCondition.always,
110+
),
111+
});
112+
expect(result.valid, false);
113+
});
114+
95115
test('positive on multi-line body message', () async {
96116
final message = '''chore(deps): bump commitlint_cli from 0.5.0 to 0.6.0
97117
Bumps [commitlint_cli](https://github.com/hyiso/commitlint) from 0.5.0 to 0.6.0.

0 commit comments

Comments
 (0)