From 74f06fe35d8f782d657b1d9570f4f2b58927fbcb Mon Sep 17 00:00:00 2001 From: Lenz Paul <34327253+lenzpaul@users.noreply.github.com> Date: Tue, 10 Sep 2024 14:33:40 -0400 Subject: [PATCH 1/2] Fixes formatting error in the rules.md table The content after the rule `invalid_runtime_check_with_js_interop_types` was not formatted in a table due to syntax error --- rules.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rules.md b/rules.md index 7aba844..729e2f8 100644 --- a/rules.md +++ b/rules.md @@ -58,8 +58,7 @@ | [`empty_statements`](https://dart.dev/lints/empty_statements) | Avoid empty statements. | ✅ | | [`exhaustive_cases`](https://dart.dev/lints/exhaustive_cases) | Define case clauses for all constants in enum-like classes. | ✅ | | [`implementation_imports`](https://dart.dev/lints/implementation_imports) | Don't import implementation files from another package. | | -| [`invalid_runtime_check_with_js_interop_types`](https://dart.dev/lints/invalid_runtime_check_with_js_interop_types) | Avoid runtime type tests with JS interop types where the result may not - be platform-consistent. | | +| [`invalid_runtime_check_with_js_interop_types`](https://dart.dev/lints/invalid_runtime_check_with_js_interop_types) | Avoid runtime type tests with JS interop types where the result may not be platform-consistent. | | | [`library_prefixes`](https://dart.dev/lints/library_prefixes) | Use `lowercase_with_underscores` when specifying a library prefix. | | | [`library_private_types_in_public_api`](https://dart.dev/lints/library_private_types_in_public_api) | Avoid using private types in public APIs. | | | [`no_leading_underscores_for_library_prefixes`](https://dart.dev/lints/no_leading_underscores_for_library_prefixes) | Avoid leading underscores for library prefixes. | ✅ | From e32d7e283ed1fdc7c74e48f1897f89b4b6acca5d Mon Sep 17 00:00:00 2001 From: Lenz Paul Date: Tue, 10 Sep 2024 16:15:10 -0400 Subject: [PATCH 2/2] Fix multiline descriptions formatting in markdown generation - Updated the `_createRuleTableRow` function to properly handle multiline descriptions by replacing line breaks with spaces - Trimmed leading/trailing whitespace and reduced consecutive spaces to a single space - This ensures that the generated markdown table rows in rules.md are correctly formatted, preventing description content from breaking across lines or having inconsistent spacing --- rules.md | 2 +- tool/gen_docs.dart | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/rules.md b/rules.md index 729e2f8..6aac54e 100644 --- a/rules.md +++ b/rules.md @@ -58,7 +58,7 @@ | [`empty_statements`](https://dart.dev/lints/empty_statements) | Avoid empty statements. | ✅ | | [`exhaustive_cases`](https://dart.dev/lints/exhaustive_cases) | Define case clauses for all constants in enum-like classes. | ✅ | | [`implementation_imports`](https://dart.dev/lints/implementation_imports) | Don't import implementation files from another package. | | -| [`invalid_runtime_check_with_js_interop_types`](https://dart.dev/lints/invalid_runtime_check_with_js_interop_types) | Avoid runtime type tests with JS interop types where the result may not be platform-consistent. | | +| [`invalid_runtime_check_with_js_interop_types`](https://dart.dev/lints/invalid_runtime_check_with_js_interop_types) | Avoid runtime type tests with JS interop types where the result may not be platform-consistent. | | | [`library_prefixes`](https://dart.dev/lints/library_prefixes) | Use `lowercase_with_underscores` when specifying a library prefix. | | | [`library_private_types_in_public_api`](https://dart.dev/lints/library_private_types_in_public_api) | Avoid using private types in public APIs. | | | [`no_leading_underscores_for_library_prefixes`](https://dart.dev/lints/no_leading_underscores_for_library_prefixes) | Avoid leading underscores for library prefixes. | ✅ | diff --git a/tool/gen_docs.dart b/tool/gen_docs.dart index d3a5732..2ecea38 100644 --- a/tool/gen_docs.dart +++ b/tool/gen_docs.dart @@ -171,7 +171,10 @@ String _createRuleTableRow( if (ruleMeta == null) { stderr.writeln("WARNING: Missing rule information for rule: $rule"); } - final description = ruleMeta?['description'] ?? ''; + final description = (ruleMeta?['description'] ?? '') + .replaceAll('\n', ' ') + .replaceAll(RegExp(r'\s+'), ' ') + .trim(); final hasFix = ruleMeta?['fixStatus'] == 'hasFix'; final fixDesc = hasFix ? '✅' : '';