Skip to content

Commit 6c25d58

Browse files
authored
Preserve all formatter options (dart-lang#1456)
1 parent cb4108a commit 6c25d58

File tree

5 files changed

+12
-8
lines changed

5 files changed

+12
-8
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.22.21
2+
3+
- Preserve all `formatter` settings in `analysis_options.yaml` when doing `dart format`.
4+
15
## 0.22.20
26

37
- Reduced minimum description length to 50 characters.

lib/src/analysis_options.dart

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,9 @@ String updatePassthroughOptions({
110110

111111
final origFormatter = origMap['formatter'];
112112
if (origFormatter is Map) {
113-
final pageWidth = origFormatter['page_width'];
114-
if (pageWidth is int) {
115-
final customFormatter =
116-
customMap.putIfAbsent('formatter', () => <String, Object?>{}) as Map;
117-
customFormatter['page_width'] = pageWidth;
118-
}
113+
final customFormatter =
114+
customMap.putIfAbsent('formatter', () => <String, dynamic>{}) as Map;
115+
customFormatter.addAll(origFormatter.cast<String, dynamic>());
119116
}
120117

121118
return json.encode(customMap);

lib/src/version.dart

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: pana
22
description: PAckage aNAlyzer - produce a report summarizing the health and quality of a Dart package.
3-
version: 0.22.20
3+
version: 0.22.21
44
repository: https://github.com/dart-lang/pana
55
topics:
66
- tool

test/analysis_options_test.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ analyzer:
3939
formatter:
4040
unknown_key: true
4141
page_width: 123
42+
trailing_commas: preserve
4243
''', custom: '');
4344
expect(json.decode(content), {
4445
'analyzer': {
@@ -50,7 +51,9 @@ formatter:
5051
],
5152
},
5253
'formatter': {
54+
'unknown_key': true,
5355
'page_width': 123,
56+
'trailing_commas': 'preserve',
5457
},
5558
});
5659
});

0 commit comments

Comments
 (0)