diff --git a/.claude/settings.json b/.claude/settings.json index 863afc795..81bdd992e 100644 --- a/.claude/settings.json +++ b/.claude/settings.json @@ -18,7 +18,6 @@ "Bash(test:*)", "Bash(sort:*)", "Bash(wc:*)", - "Bash(dcm:*)", "mcp__plugin_playwright_playwright__browser_navigate", "mcp__plugin_playwright_playwright__browser_console_messages" ] diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d4069cc49..df893719c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -54,10 +54,10 @@ jobs: timeout-minutes: 5 # Runs what maintainers run: `dart analyze --fatal-infos` over every - # package, after code generation so generated files exist. DCM is the - # other half of `melos run analyze` and is not run here yet. + # package, with the bitwild_lints plugin, after code generation so + # generated files exist. - name: Analyze - run: melos run analyze:dart --no-select + run: melos run analyze --no-select - name: Check Contract Schemas run: melos run contracts:check --no-select diff --git a/AGENTS.md b/AGENTS.md index a030eb15a..d46ea1817 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -53,9 +53,8 @@ Always work inside the FVM-provided SDK (`.fvm/flutter_sdk`) to avoid toolchain ### Analysis & Linting ```bash -fvm dart run melos run analyze # Run dart analyze + DCM analysis -fvm dart run melos run analyze:all # Full analysis including unused code/files -fvm dart run melos run fix # Apply dart fix + DCM autofixes +fvm dart run melos run analyze # Run dart analyze with the bitwild_lints plugin +fvm dart run melos run fix # Apply dart fix ``` ### Code Generation @@ -140,7 +139,7 @@ fvm dart run melos run clean # Clean all Flutter build artifacts - Keep widgets focused; colocate private helpers with their widget - Run `melos run fix` before committing -### Member Ordering (enforced by DCM) +### Member Ordering (convention; `bitwild_lints/sort_class_members` can check it) 1. Public fields 2. Private fields 3. Constructors diff --git a/analysis_options.yaml b/analysis_options.yaml new file mode 100644 index 000000000..9179db22f --- /dev/null +++ b/analysis_options.yaml @@ -0,0 +1,74 @@ +# Shared analyzer configuration for every package in the SuperDeck workspace. +# Each package's analysis_options.yaml includes this file. The presets and the +# bitwild_lints plugin come from https://github.com/btwld/lints. +# +# plugin.yaml turns on the plugin's recommended rules. plugin_all.yaml would +# also turn on the ordering and formatting conventions, which report about +# 1,700 issues on the current code. +include: + - package:bitwild_analysis/dart.yaml + - package:bitwild_analysis/plugin.yaml + +analyzer: + # The strict modes were off before the shared presets. Turning them on + # reports about 40 issues; do that in a separate change. + language: + strict-casts: false + strict-inference: false + strict-raw-types: false + errors: + invalid_annotation_target: ignore + body_might_complete_normally_nullable: ignore + exclude: + - '**/generated_plugin_registrant.dart' + - '**/*.g.dart' + - '**/*.ack.dart' + # Vendored third-party code keeps its upstream style. + - '**/vendor/**' + +linter: + rules: + public_member_api_docs: false + always_use_package_imports: false + prefer_relative_imports: true + prefer_initializing_formals: false + library_private_types_in_public_api: false + # Conflicts with unnecessary_parenthesis; bitwild_analysis 0.4.0 drops it. + no_adjacent_strings_in_list: false + # Reports 65 dynamic calls, mostly on decoded JSON and YAML. Fix them in a + # separate change. + avoid_dynamic_calls: false + +# Member order, as in AGENTS.md, for sort_class_members. The rule is in +# plugin_all.yaml, not plugin.yaml. Widgets and States use the same order, so +# `build` stays last. +bitwild_lints: + sort_class_members: + order: + - public-fields + - private-fields + - constructors + - static-methods + - private-methods + - private-getters + - private-setters + - public-getters + - public-setters + - public-methods + - overridden-public-methods + - overridden-public-getters + - build-method + widgets-order: + - public-fields + - private-fields + - constructors + - static-methods + - private-methods + - private-getters + - private-setters + - public-getters + - public-setters + - public-methods + - overridden-public-methods + - overridden-public-getters + - build-method diff --git a/demo/analysis_options.yaml b/demo/analysis_options.yaml index 8ffc0b4e6..f2a559228 100644 --- a/demo/analysis_options.yaml +++ b/demo/analysis_options.yaml @@ -1,3 +1,7 @@ +include: + - ../analysis_options.yaml + - package:bitwild_analysis/flutter.yaml + analyzer: exclude: - build/** @@ -7,7 +11,3 @@ analyzer: - windows/** - macos/** - linux/** -include: - - package:flutter_lints/flutter.yaml - - ../shared_analysis_options.yaml - diff --git a/demo/integration_test/layout_matrix_test.dart b/demo/integration_test/layout_matrix_test.dart index 961b56e26..b8d028b1e 100644 --- a/demo/integration_test/layout_matrix_test.dart +++ b/demo/integration_test/layout_matrix_test.dart @@ -760,13 +760,13 @@ List _applyBlockFlex(List blocks, List? flex) { return [ for (var index = 0; index < blocks.length; index++) switch (blocks[index]) { - ContentBlock block => ContentBlock( + final ContentBlock block => ContentBlock( block.content, align: block.align, flex: flex[index], scrollable: block.scrollable, ), - WidgetBlock block => WidgetBlock( + final WidgetBlock block => WidgetBlock( name: block.name, args: block.args, align: block.align, diff --git a/demo/integration_test/navigation_test.dart b/demo/integration_test/navigation_test.dart index 7088362bf..cf98b6e07 100644 --- a/demo/integration_test/navigation_test.dart +++ b/demo/integration_test/navigation_test.dart @@ -69,10 +69,10 @@ void main() { final controller = await tester.pumpTestAppWithSlides(makeSlides(6)); // Fire multiple goToSlide calls without awaiting each - controller.presentation.goToSlide(5); - controller.presentation.goToSlide(2); - controller.presentation.goToSlide(4); - controller.presentation.goToSlide(1); + unawaited(controller.presentation.goToSlide(5)); + unawaited(controller.presentation.goToSlide(2)); + unawaited(controller.presentation.goToSlide(4)); + unawaited(controller.presentation.goToSlide(1)); // Let the transition duration and router settle await tester.pumpFor(const Duration(seconds: 2)); diff --git a/demo/lib/src/examples/button.dart b/demo/lib/src/examples/button.dart index bca7d8ab5..815c0a94f 100644 --- a/demo/lib/src/examples/button.dart +++ b/demo/lib/src/examples/button.dart @@ -26,7 +26,7 @@ class ButtonExample extends StatelessWidget { .minWidth(100) .mainAxisAlignment(MainAxisAlignment.center) .labelLetterSpacing(0.3) - .borderRadiusAll(Radius.circular(6)) + .borderRadiusAll(const Radius.circular(6)) .scale(1) .onDisabled( RemixButtonStyler() diff --git a/demo/lib/src/examples/mix/animation.dart b/demo/lib/src/examples/mix/animation.dart index 3431c5da1..1d99d9ed7 100644 --- a/demo/lib/src/examples/mix/animation.dart +++ b/demo/lib/src/examples/mix/animation.dart @@ -23,7 +23,7 @@ class _SwitchAnimationState extends State { .color(_trigger.value ? Colors.deepPurpleAccent : Colors.grey.shade300) .height(30) .width(65) - .borderRadiusAll(Radius.circular(40)) + .borderRadiusAll(const Radius.circular(40)) .alignment( _trigger.value ? Alignment.centerRight : Alignment.centerLeft, ) @@ -41,14 +41,14 @@ class _SwitchAnimationState extends State { ) .foregroundDecoration( BoxDecorationMix().borderRadius( - BorderRadiusMix.all(Radius.circular(40)), + BorderRadiusMix.all(const Radius.circular(40)), ), ) .borderRounded(40) .scale(0.85) .shadowOnly( color: Colors.black.withValues(alpha: 0.1), - offset: Offset(2, 4), + offset: const Offset(2, 4), blurRadius: 4, spreadRadius: 3, ) diff --git a/demo/lib/src/layout_showcase/showcase_style.dart b/demo/lib/src/layout_showcase/showcase_style.dart index fca341d83..529f505bc 100644 --- a/demo/lib/src/layout_showcase/showcase_style.dart +++ b/demo/lib/src/layout_showcase/showcase_style.dart @@ -72,14 +72,14 @@ SlideStyler showcaseBaseStyle() { strong: TextStyleMix(fontWeight: FontWeight.w800, color: _ink), em: TextStyleMix(fontStyle: FontStyle.italic, color: _coral), del: TextStyleMix( - color: Color(0xFF77737D), + color: const Color(0xFF77737D), decoration: TextDecoration.lineThrough, - decorationColor: Color(0xFFAAA6AF), + decorationColor: const Color(0xFFAAA6AF), ), link: TextStyleMix( color: _teal, decoration: TextDecoration.underline, - decorationColor: Color(0x9959D6C8), + decorationColor: const Color(0x9959D6C8), ), list: MarkdownListStyler( text: TextStyler().style( diff --git a/demo/lib/src/style.dart b/demo/lib/src/style.dart index 00878dfbb..c93de7a92 100644 --- a/demo/lib/src/style.dart +++ b/demo/lib/src/style.dart @@ -99,7 +99,7 @@ SlideStyler borderedStyle() { style: BorderStyle.solid, ), ), - borderRadius: BorderRadiusMix.all(Radius.circular(16)), + borderRadius: BorderRadiusMix.all(const Radius.circular(16)), ), ), ), diff --git a/demo/lib/src/widgets/demo_widgets.dart b/demo/lib/src/widgets/demo_widgets.dart index b104e9804..af67b0497 100644 --- a/demo/lib/src/widgets/demo_widgets.dart +++ b/demo/lib/src/widgets/demo_widgets.dart @@ -1,11 +1,11 @@ import 'package:flutter/widgets.dart'; import 'package:superdeck/superdeck.dart'; +import '../examples/button.dart' as remix_button; import '../examples/mix/animation.dart' as mix_animation; import '../examples/mix/box_with_variants.dart' as mix_variants; import '../examples/mix/simple_box.dart' as mix_simple_box; import '../examples/select.dart' as naked_select; -import '../examples/button.dart' as remix_button; import 'ack_metric_card.dart'; /// Auto-registered demo widgets for Superdeck presentations. @@ -29,22 +29,28 @@ import 'ack_metric_card.dart'; /// QR codes use the built-in `@qrcode` widget. Map get demoWidgets => { 'mix-simple-box': (_) => _DemoWrapper( - child: Transform.scale(scale: 3.0, child: mix_simple_box.Example()), + child: Transform.scale(scale: 3.0, child: const mix_simple_box.Example()), ), 'mix-variants': (_) => _DemoWrapper( - child: Transform.scale(scale: 3.0, child: mix_variants.Example()), + child: Transform.scale(scale: 3.0, child: const mix_variants.Example()), ), 'mix-animation': (_) => _DemoWrapper( - child: Transform.scale(scale: 3.0, child: mix_animation.SwitchAnimation()), + child: Transform.scale( + scale: 3.0, + child: const mix_animation.SwitchAnimation(), + ), ), 'naked-select': (_) => _DemoWrapper( child: Transform.scale( scale: 2.0, - child: naked_select.SimpleSelectExample(), + child: const naked_select.SimpleSelectExample(), ), ), 'remix-button': (_) => _DemoWrapper( - child: Transform.scale(scale: 1.2, child: remix_button.ButtonExample()), + child: Transform.scale( + scale: 1.2, + child: const remix_button.ButtonExample(), + ), ), 'ack-metric-card': AckMetricCard.new, }; diff --git a/demo/pubspec.yaml b/demo/pubspec.yaml index 392d4de90..4486e058e 100644 --- a/demo/pubspec.yaml +++ b/demo/pubspec.yaml @@ -9,26 +9,25 @@ environment: resolution: workspace dependencies: - flutter: - sdk: flutter ack: ^1.6.2 ack_annotations: ^1.6.2 + flutter: + sdk: flutter google_fonts: ^8.2.1 mesh: ^0.5.0 mix: ^2.2.0-beta.0 - superdeck_core: ^1.0.0 - superdeck: ^1.0.0 - signals_flutter: ^7.1.0 naked_ui: ^1.0.0-beta.4 remix: ^1.0.0-beta.1 + signals_flutter: ^7.1.0 + superdeck: ^1.0.0 + superdeck_core: ^1.0.0 dev_dependencies: + ack_generator: ^1.6.2 + build_runner: ^2.5.4 flutter_test: sdk: flutter integration_test: sdk: flutter - flutter_lints: ^6.0.0 - build_runner: ^2.5.4 - ack_generator: ^1.6.2 superdeck_builder: ^1.0.0 superdeck_cli: ^1.0.0 superdeck_pdf: ^1.0.0 diff --git a/packages/builder/analysis_options.yaml b/packages/builder/analysis_options.yaml index 7f6b9f428..f04c6cf0f 100644 --- a/packages/builder/analysis_options.yaml +++ b/packages/builder/analysis_options.yaml @@ -1,7 +1 @@ -include: - - package:lints/recommended.yaml - - ../../shared_analysis_options.yaml - -linter: - rules: - prefer_initializing_formals: false +include: ../../analysis_options.yaml diff --git a/packages/builder/lib/src/parsers/markdown_parser.dart b/packages/builder/lib/src/parsers/markdown_parser.dart index 9265e1417..d3e28e051 100644 --- a/packages/builder/lib/src/parsers/markdown_parser.dart +++ b/packages/builder/lib/src/parsers/markdown_parser.dart @@ -58,7 +58,7 @@ class MarkdownParser { content = content.trim(); if (content.isEmpty) return []; - final lines = LineSplitter().convert(content); + final lines = const LineSplitter().convert(content); final separators = _findSeparatorLines(lines); final slides = []; @@ -156,7 +156,7 @@ class MarkdownParser { final slides = []; final usedKeys = {}; - final frontMatterExtractor = FrontmatterParser(); + const frontMatterExtractor = FrontmatterParser(); for (final rawSlide in rawSlides) { final frontmatter = frontMatterExtractor.parse(rawSlide); diff --git a/packages/builder/lib/superdeck_builder.dart b/packages/builder/lib/superdeck_builder.dart index 21c4e7eee..823f2d4d2 100644 --- a/packages/builder/lib/superdeck_builder.dart +++ b/packages/builder/lib/superdeck_builder.dart @@ -7,9 +7,8 @@ export 'package:superdeck_core/superdeck_core.dart' export 'src/build/build_event.dart'; export 'src/build/deck_build_plugin.dart'; export 'src/build/deck_builder.dart'; - export 'src/parsers/comment_parser.dart'; export 'src/parsers/markdown_parser.dart'; -export 'src/parsers/slide_assembler.dart'; export 'src/parsers/section_parser.dart'; +export 'src/parsers/slide_assembler.dart'; export 'src/parsers/slide_serializer.dart'; diff --git a/packages/builder/pubspec.yaml b/packages/builder/pubspec.yaml index 8fb2a80d6..2fe24e6c0 100644 --- a/packages/builder/pubspec.yaml +++ b/packages/builder/pubspec.yaml @@ -10,11 +10,9 @@ environment: resolution: workspace dependencies: - superdeck_core: ^1.0.0 logging: ^1.3.0 path: ^1.9.0 + superdeck_core: ^1.0.0 dev_dependencies: - lints: ^6.1.0 test: ^1.25.8 - dart_code_metrics_presets: ^2.33.0 diff --git a/packages/builder/test/public_api_test.dart b/packages/builder/test/public_api_test.dart index 061731e62..5a12a2948 100644 --- a/packages/builder/test/public_api_test.dart +++ b/packages/builder/test/public_api_test.dart @@ -4,13 +4,13 @@ import 'package:test/test.dart'; void main() { group('superdeck_builder public api', () { test('exports the supported build surface', () { - final error = DeckFormatException('invalid', '', 0); + const error = DeckFormatException('invalid', '', 0); expect(DeckBuilder, isNotNull); expect(DeckPlugin, isNotNull); expect(DeckBuildPlugin, isNotNull); expect(DeckBuildContext, isNotNull); - expect(BuildStarted(), isA()); + expect(const BuildStarted(), isA()); expect(error, isA()); }); }); diff --git a/packages/builder/test/src/parsers/block_parser_test.dart b/packages/builder/test/src/parsers/block_parser_test.dart index 54ad60c69..2d71a6f22 100644 --- a/packages/builder/test/src/parsers/block_parser_test.dart +++ b/packages/builder/test/src/parsers/block_parser_test.dart @@ -9,7 +9,7 @@ final List> testCaseTagBlock = [ @tag ''', 'expectedBlocks': [ - ParsedBlock(type: 'tag', data: {}, startIndex: 0, endIndex: 4), + const ParsedBlock(type: 'tag', data: {}, startIndex: 0, endIndex: 4), ], }, { @@ -18,7 +18,7 @@ final List> testCaseTagBlock = [ @tag {key: value} ''', 'expectedBlocks': [ - ParsedBlock( + const ParsedBlock( type: 'tag', data: {'key': 'value'}, startIndex: 0, @@ -36,7 +36,7 @@ final List> testCaseTagBlock = [ Test content ''', 'expectedBlocks': [ - ParsedBlock( + const ParsedBlock( type: 'tag', data: {'key': 'value', 'key2': 'value2'}, startIndex: 0, @@ -51,7 +51,7 @@ Test content @tag{key: value} ''', 'expectedBlocks': [ - ParsedBlock( + const ParsedBlock( type: 'tag', data: {'key': 'value'}, startIndex: 0, @@ -71,7 +71,7 @@ Test content ## Test content 2 ''', 'expectedBlocks': [ - ParsedBlock( + const ParsedBlock( type: 'tag', data: {'key': 'value', 'key2': 'value2'}, startIndex: 0, @@ -89,7 +89,7 @@ Test content } ''', 'expectedBlocks': [ - ParsedBlock( + const ParsedBlock( type: 'tag', data: {'key': 'value', 'key2': 'value2'}, startIndex: 0, @@ -108,7 +108,7 @@ Test content } ''', 'expectedBlocks': [ - ParsedBlock( + const ParsedBlock( type: 'tag', data: {'key': 1, 'key2': 2.0, 'key3': true}, startIndex: 0, @@ -124,7 +124,7 @@ Test content { key: value } ''', 'expectedBlocks': [ - ParsedBlock( + const ParsedBlock( type: 'tag', data: {'key': 'value'}, startIndex: 0, @@ -139,7 +139,7 @@ Test content @tag {label: "{value} text"} ''', 'expectedBlocks': [ - ParsedBlock( + const ParsedBlock( type: 'tag', data: {'label': '{value} text'}, startIndex: 0, @@ -159,13 +159,13 @@ Test content 1 Test content 2 ''', 'expectedBlocks': [ - ParsedBlock( + const ParsedBlock( type: 'tag1', data: {'key': 'value'}, startIndex: 0, endIndex: 18, ), - ParsedBlock( + const ParsedBlock( type: 'tag2', data: {'key2': 'value2'}, startIndex: 35, @@ -181,13 +181,13 @@ Test content 2 @tag2 {key2: value2} ''', 'expectedBlocks': [ - ParsedBlock( + const ParsedBlock( type: 'tag1', data: {'key': 'value'}, startIndex: 0, endIndex: 18, ), - ParsedBlock( + const ParsedBlock( type: 'tag2', data: {'key2': 'value2'}, startIndex: 19, diff --git a/packages/builder/test/src/parsers/comment_parser_test.dart b/packages/builder/test/src/parsers/comment_parser_test.dart index 0d8a41ede..65df2fdca 100644 --- a/packages/builder/test/src/parsers/comment_parser_test.dart +++ b/packages/builder/test/src/parsers/comment_parser_test.dart @@ -10,13 +10,13 @@ void main() { group('CommentParser', () { test('parses single line comment correctly', () { - final input = ''; + const input = ''; final result = parser.parse(input); expect(result, ['This is a comment']); }); test('parses multiple single line comments correctly', () { - final input = ''' + const input = ''' '''; @@ -25,7 +25,7 @@ void main() { }); test('handles comments with special characters', () { - final input = ''' + const input = ''' '''; @@ -38,7 +38,7 @@ void main() { }); test('ignores invalid comments', () { - final input = ''' + const input = ''' <-- Also invalid --> @@ -50,7 +50,7 @@ Text without comments }); test('handles empty comments', () { - final input = ''' + const input = ''' '''; @@ -59,7 +59,7 @@ Text without comments }); test('handles comments with leading and trailing spaces', () { - final input = ''' + const input = ''' '''; @@ -68,7 +68,7 @@ Text without comments }); test('ignores comments without proper spacing', () { - final input = ''' + const input = ''' '''; @@ -81,7 +81,7 @@ Text without comments }); test('handles mixed content correctly', () { - final input = ''' + const input = ''' Regular text More text @@ -92,7 +92,7 @@ Final text'''; }); test('handles multiline comments correctly', () { - final input = ''' + const input = '''