Skip to content

Commit 3725da2

Browse files
committed
update CI config; dartfmt files
1 parent 9e3c831 commit 3725da2

File tree

3 files changed

+42
-24
lines changed

3 files changed

+42
-24
lines changed

.github/workflows/lints.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
strategy:
2727
fail-fast: false
2828
matrix:
29-
sdk: [beta] # todo: re-add stable
29+
sdk: [dev, beta, stable]
3030

3131
steps:
3232
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
@@ -36,6 +36,7 @@ jobs:
3636

3737
- run: dart pub get
3838
- run: dart format --output=none --set-exit-if-changed .
39+
if: ${{ matrix.sdk == 'stable' }}
3940
- run: dart analyze --fatal-infos
4041
- run: dart tool/validate_lib.dart
4142
- run: dart tool/gen_docs.dart --verify

pkgs/lints/tool/gen_docs.dart

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,10 @@ void main(List<String> args) async {
4848
}
4949

5050
// Generate new documentation.
51-
var newRulesMarkdownContent =
52-
_updateMarkdown(rulesMarkdownContent, rulesJson);
51+
var newRulesMarkdownContent = _updateMarkdown(
52+
rulesMarkdownContent,
53+
rulesJson,
54+
);
5355

5456
// If no documentation change, all is up-to-date.
5557
if (newRulesMarkdownContent == rulesMarkdownContent) {
@@ -59,8 +61,10 @@ void main(List<String> args) async {
5961

6062
/// Documentation has changed.
6163
if (verifyOnly) {
62-
print('${rulesMarkdownFile.path} is not up-to-date (lint tables need to be '
63-
'regenerated).');
64+
print(
65+
'${rulesMarkdownFile.path} is not up-to-date (lint tables need to be '
66+
'regenerated).',
67+
);
6468
print('');
6569
print("Run 'dart tool/gen_docs.dart' to re-generate.");
6670
exit(1);
@@ -79,8 +83,9 @@ void main(List<String> args) async {
7983
///
8084
/// If [verifyOnly] is `true`, only reads the cached data back from
8185
/// [rulesCacheFilePath].
82-
Future<Map<String, Map<String, String>>> _fetchRulesJson(
83-
{required bool verifyOnly}) async {
86+
Future<Map<String, Map<String, String>>> _fetchRulesJson({
87+
required bool verifyOnly,
88+
}) async {
8489
final rulesJsonFile = _packageRelativeFile(rulesCacheFilePath);
8590
if (verifyOnly) {
8691
final rulesJsonText = rulesJsonFile.readAsStringSync();
@@ -91,8 +96,9 @@ Future<Map<String, Map<String, String>>> _fetchRulesJson(
9196

9297
// Re-save [rulesJsonFile] file.
9398
var newRulesJson = [...rulesJson.values];
94-
rulesJsonFile
95-
.writeAsStringSync(JsonEncoder.withIndent(' ').convert(newRulesJson));
99+
rulesJsonFile.writeAsStringSync(
100+
JsonEncoder.withIndent(' ').convert(newRulesJson),
101+
);
96102

97103
return rulesJson;
98104
}
@@ -108,8 +114,8 @@ Map<String, Map<String, String>> _readJson(String rulesJsonText) {
108114
return {
109115
for (Map<String, Object?> rule in rulesJson)
110116
rule['name'] as String: {
111-
for (var key in relevantKeys) key: rule[key] as String
112-
}
117+
for (var key in relevantKeys) key: rule[key] as String,
118+
},
113119
};
114120
}
115121

@@ -121,7 +127,9 @@ Map<String, Map<String, String>> _readJson(String rulesJsonText) {
121127
/// [rulesJson], based on the list of rules in `lib/core.yaml` and
122128
/// `lib/recommended.yaml`.
123129
String _updateMarkdown(
124-
String content, Map<String, Map<String, String>> rulesJson) {
130+
String content,
131+
Map<String, Map<String, String>> rulesJson,
132+
) {
125133
for (var ruleSetName in ['core', 'recommended']) {
126134
var ruleFile = _packageRelativeFile(p.join('lib', '$ruleSetName.yaml'));
127135
var ruleSet = _parseRules(ruleFile);
@@ -134,7 +142,10 @@ String _updateMarkdown(
134142
continue;
135143
}
136144
content = content.replaceRange(
137-
rangeStart, rangeEnd, _createRuleTable(ruleSet, rulesJson));
145+
rangeStart,
146+
rangeEnd,
147+
_createRuleTable(ruleSet, rulesJson),
148+
);
138149
}
139150
return content;
140151
}
@@ -148,7 +159,9 @@ List<String> _parseRules(File yamlFile) {
148159

149160
/// Creates markdown source for a table of lint rules.
150161
String _createRuleTable(
151-
List<String> rules, Map<String, Map<String, String>> lintMeta) {
162+
List<String> rules,
163+
Map<String, Map<String, String>> lintMeta,
164+
) {
152165
rules.sort();
153166

154167
final lines = [
@@ -166,15 +179,18 @@ String _createRuleTable(
166179
/// The row should have the same number of entires as the table format,
167180
/// and should be on a single line with no newline at the end.
168181
String _createRuleTableRow(
169-
String rule, Map<String, Map<String, String>> lintMeta) {
182+
String rule,
183+
Map<String, Map<String, String>> lintMeta,
184+
) {
170185
final ruleMeta = lintMeta[rule];
171186
if (ruleMeta == null) {
172187
stderr.writeln("WARNING: Missing rule information for rule: $rule");
173188
}
174-
final description = (ruleMeta?['description'] ?? '')
175-
.replaceAll('\n', ' ')
176-
.replaceAll(RegExp(r'\s+'), ' ')
177-
.trim();
189+
final description =
190+
(ruleMeta?['description'] ?? '')
191+
.replaceAll('\n', ' ')
192+
.replaceAll(RegExp(r'\s+'), ' ')
193+
.trim();
178194
final hasFix = ruleMeta?['fixStatus'] == 'hasFix';
179195
final fixDesc = hasFix ? '✅' : '';
180196

pkgs/lints/tool/validate_lib.dart

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ import 'package:path/path.dart' as p;
99
void main(List<String> args) {
1010
print('Validating that there are no .dart source files in lib/ ...');
1111

12-
final dartSourceFiles = Directory('lib')
13-
.listSync(recursive: true)
14-
.whereType<File>()
15-
.where((file) => p.extension(file.path) == '.dart')
16-
.toList();
12+
final dartSourceFiles =
13+
Directory('lib')
14+
.listSync(recursive: true)
15+
.whereType<File>()
16+
.where((file) => p.extension(file.path) == '.dart')
17+
.toList();
1718

1819
if (dartSourceFiles.isEmpty) {
1920
print('No Dart files found.');

0 commit comments

Comments
 (0)