Repository: dart-lang/pana (dart)

Issue:
Respect `formatter: page-width` setting in `analysis_options.yaml`
In the context of https://github.com/dart-lang/sdk/issues/56863
We have to make sure that we respect the page-width setting that users have set.

Pull request description:
Fixes #1405

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 96cd0b1d1..c49e835df 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,8 @@
+## 0.22.13
+
+- Pass-through for `formatter/page_width` in `analysis_options.yaml`.
+- Upgraded `lints` to `^5.0.0`
+
 ## 0.22.12
 
 - Updated report text for `wasm` readiness.
diff --git a/lib/src/analysis_options.dart b/lib/src/analysis_options.dart
index 6c2829745..435b16a56 100644
--- a/lib/src/analysis_options.dart
+++ b/lib/src/analysis_options.dart
@@ -108,5 +108,15 @@ String updatePassthroughOptions({
     }
   }
 
+  final origFormatter = origMap['formatter'];
+  if (origFormatter is Map) {
+    final pageWidth = origFormatter['page_width'];
+    if (pageWidth is int) {
+      final customFormatter =
+          customMap.putIfAbsent('formatter', () => <String, Object?>{}) as Map;
+      customFormatter['page_width'] = pageWidth;
+    }
+  }
+
   return json.encode(customMap);
 }
diff --git a/lib/src/version.dart b/lib/src/version.dart
index 76c07debd..082f85d72 100644
--- a/lib/src/version.dart
+++ b/lib/src/version.dart
@@ -1,2 +1,2 @@
 // Generated code. Do not modify.
-const packageVersion = '0.22.12';
+const packageVersion = '0.22.13';
diff --git a/pubspec.yaml b/pubspec.yaml
index db50ecb5b..6cc0d2870 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,6 +1,6 @@
 name: pana
 description: PAckage aNAlyzer - produce a report summarizing the health and quality of a Dart package.
-version: 0.22.12
+version: 0.22.13
 repository: https://github.com/dart-lang/pana
 topics:
   - tool
@@ -20,7 +20,7 @@ dependencies:
   http: ^1.0.0
   io: ^1.0.0
   json_annotation: ^4.9.0
-  lints: ^4.0.0
+  lints: '>=4.0.0 <6.0.0'
   logging: ^1.0.0
   markdown: ^7.0.0
   meta: ^1.4.0


Test patch:
diff --git a/test/analysis_options_test.dart b/test/analysis_options_test.dart
index 1b0f4d4fd..f082e9096 100644
--- a/test/analysis_options_test.dart
+++ b/test/analysis_options_test.dart
@@ -36,6 +36,9 @@ analyzer:
   enable-experiment:
     - ignored
     - macros
+formatter:
+  unknown_key: true
+  page_width: 123
 ''', custom: '');
     expect(json.decode(content), {
       'analyzer': {
@@ -46,6 +49,9 @@ analyzer:
           'macros',
         ],
       },
+      'formatter': {
+        'page_width': 123,
+      },
     });
   });
 }
diff --git a/test/goldens/end2end/async-2.11.0.json b/test/goldens/end2end/async-2.11.0.json
index c24f8e17f..fec106f91 100644
--- a/test/goldens/end2end/async-2.11.0.json
+++ b/test/goldens/end2end/async-2.11.0.json
@@ -79,7 +79,7 @@
         "grantedPoints": 10,
         "maxPoints": 20,
         "status": "failed",
-        "summary": "### [*] 10/10 points: 20% or more of the public API has dartdoc comments\n\n246 out of 263 API elements (93.5 %) have documentation comments.\n\nSome symbols that are missing documentation: `async.AsyncMemoizer.AsyncMemoizer`, `async.ChunkedStreamReader.ChunkedStreamReader`, `async.DelegatingFuture.DelegatingFuture`, `async.DelegatingStream.DelegatingStream`, `async.ErrorResult.ErrorResult`.\n\n### [x] 0/10 points: Package has an example\n\n<details>\n<summary>\nNo example found.\n</summary>\n\nSee [package layout](https://dart.dev/tools/pub/package-layout#examples) guidelines on how to add an example.\n</details>\n"
+        "summary": "### [*] 10/10 points: 20% or more of the public API has dartdoc comments\n\n246 out of 246 API elements (100.0 %) have documentation comments.\n\n### [x] 0/10 points: Package has an example\n\n<details>\n<summary>\nNo example found.\n</summary>\n\nSee [package layout](https://dart.dev/tools/pub/package-layout#examples) guidelines on how to add an example.\n</details>\n"
       },
       {
         "id": "platform",
diff --git a/test/goldens/end2end/async-2.11.0.json_report.md b/test/goldens/end2end/async-2.11.0.json_report.md
index bb097bd76..84c4e5bf3 100644
--- a/test/goldens/end2end/async-2.11.0.json_report.md
+++ b/test/goldens/end2end/async-2.11.0.json_report.md
@@ -15,9 +15,7 @@ Detected license: `BSD-3-Clause`.
 
 ### [*] 10/10 points: 20% or more of the public API has dartdoc comments
 
-246 out of 263 API elements (93.5 %) have documentation comments.
-
-Some symbols that are missing documentation: `async.AsyncMemoizer.AsyncMemoizer`, `async.ChunkedStreamReader.ChunkedStreamReader`, `async.DelegatingFuture.DelegatingFuture`, `async.DelegatingStream.DelegatingStream`, `async.ErrorResult.ErrorResult`.
+246 out of 246 API elements (100.0 %) have documentation comments.
 
 ### [x] 0/10 points: Package has an example