Skip to content

Add the prefer_equatable_mixin lint#503

Merged
PiotrRogulski merged 4 commits intomasterfrom
prefer-equatable-mixin-lint
Feb 26, 2026
Merged

Add the prefer_equatable_mixin lint#503
PiotrRogulski merged 4 commits intomasterfrom
prefer-equatable-mixin-lint

Conversation

@PiotrRogulski
Copy link
Member

A partial reboot of #458 (I'll split it up into several PRs)

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new analyzer warning rule to the leancode_lint plugin that flags classes directly extending Equatable and recommends using EquatableMixin instead, including an automatic fix and accompanying documentation/tests.

Changes:

  • Introduces the prefer_equatable_mixin lint with an auto-fix (ConvertToEquatableMixin).
  • Registers the new rule + fix in the plugin and adds test coverage with an equatable mock library.
  • Documents the new lint in the README and updates assist source links to lib/src/assists/....

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/leancode_lint/lib/src/lints/prefer_equatable_mixin.dart Implements the new lint and an automatic fix to convert extends Equatable to with EquatableMixin.
packages/leancode_lint/lib/plugin.dart Registers the new warning rule and fix with the plugin registry.
packages/leancode_lint/test/test_cases/prefer_equatable_mixin_test.dart Adds tests validating diagnostics for direct Equatable extension and no diagnostics for EquatableMixin.
packages/leancode_lint/test/mock_libraries/equatable.dart Adds a mocked equatable package API for analyzer tests.
packages/leancode_lint/test/mock_libraries.dart Wires the new equatable mock into the test harness via part.
packages/leancode_lint/README.md Documents prefer_equatable_mixin and fixes assist file links to point at lib/src/assists.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


None

### `prefer_equatable_mixin`
Copy link
Member

@Albert221 Albert221 Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explaining all lints in README takes much space. Maybe we could wrap them into <details>? Out of scope though

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do next 💯

@PiotrRogulski PiotrRogulski merged commit e749b3b into master Feb 26, 2026
2 checks passed
@PiotrRogulski PiotrRogulski deleted the prefer-equatable-mixin-lint branch February 26, 2026 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

p: leancode_lint Related to the leancode_lint package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants