[leancode_lint] Handle Dart 3.13 primary constructors - #564
Merged
PiotrRogulski merged 5 commits intoAug 15, 2026
Conversation
- missing_equatable_props: require fields declared by a primary constructor's declaring parameters in props, and account for superclasses declaring their fields in a primary constructor when deciding whether super.props is needed - constructor_parameters_and_fields_should_have_the_same_order: treat primary-constructor-declared fields as preceding body fields when checking other constructors - avoid_build_context_in_blocs: report BuildContext parameters declared in a bloc/cubit primary constructor header - prefer_abstract_final_class: recognize a private `._()` primary constructor as an instantiation guard and teach the fix to remove it from the class header - convert_positional_to_named_formal assist: preserve the parameter's own declaration instead of synthesizing a `this.`-prefixed one, which broke declaring and super parameters Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KiMgutpA35YKFfcHdXDt6E
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KiMgutpA35YKFfcHdXDt6E
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KiMgutpA35YKFfcHdXDt6E
…tor test Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KiMgutpA35YKFfcHdXDt6E
PiotrRogulski
marked this pull request as ready for review
August 14, 2026 09:59
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KiMgutpA35YKFfcHdXDt6E
cupofme
approved these changes
Aug 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Makes the custom lints handle Dart 3.13's primary constructors, with new test cases for every affected rule.
Lint fixes
missing_equatable_props: fields declared by a primary constructor's declaring parameters (class MyState(final int a) with Equatable) are now required inprops, and a superclass declaring its fields in a primary constructor now triggers thesuper.propsrequirement (such fields reportisOriginDeclaringFormalParameter, notisOriginDeclaration). The quick-fix handles both as well.constructor_parameters_and_fields_should_have_the_same_order: header-declared fields now participate in the field order (preceding body fields) when checking the class's other constructors. This also fixes a false positive where a factory's parameters matched the true field order but the lint only saw body fields.avoid_build_context_in_blocs:BuildContextparameters in a Bloc/Cubit's primary constructor header (plain and field-declaring) are now reported.prefer_abstract_final_class: a privateclass MyConstants._()primary constructor with no parameters and nothisbody is now recognized as an instantiation guard (includingclass const), and the fix removes it from the class header.convert_positional_to_named_formalassist: now preserves the parameter's own declaration instead of synthesizingrequired this.<name>, which corrupted a primary constructor's declaring parameters (final int x) andsuper.xparameters.Notes
add_cubit_suffix_for_cubits,bloc_related_class_naming,bloc_subclasses_naming,prefix_widgets_returning_slivers) already usenamePart.typeNameand needed no changes; a primary-constructor regression test was added foradd_cubit_suffix_for_cubits.int xwithoutfinal/var) are correctly not treated as fields.🤖 Generated with Claude Code
https://claude.ai/code/session_01KiMgutpA35YKFfcHdXDt6E
Generated by Claude Code