ripplearc_linter 0.2.2
ripplearc_linter: ^0.2.2 copied to clipboard
A custom lint library following best engineering practice
Changelog #
0.2.2 AvoidTestTimeouts Analyzer Bug Fixes (patch) #
Bug Fixes #
- Fixed nested test/group block detection: The
avoid_test_timeoutsanalyzer now correctly tracks nestedtest,group, andtestWidgetsblocks using a depth counter instead of a boolean flag. Previously, timeout violations in code between nested blocks were not detected. - Added
testWidgetssupport: Flutter widget tests usingtestWidgetsare now correctly recognized and analyzed for timeout violations. - Added
setUpAllandtearDownAllsupport: These test lifecycle methods are now correctly analyzed for timeout violations, matching the existingsetUpandtearDownbehavior.
Technical Details #
- Changed
_isInTestBlockfrombooltoint _testBlockDepthwith depth tracking to properly handle nested test blocks - Added
testWidgets,setUpAll, andtearDownAllto the set of recognized test block methods - Consolidated duplicate conditional logic for cleaner, more maintainable code
- All 16 tests passing with comprehensive coverage for nested blocks and lifecycle methods
0.2.1 Theme exclusion fix and rule coverage (patch) #
Bug Fixes #
- Corrected theme exclusion paths:
avoid_static_colorsandavoid_static_typographynow skip files underlib/src/themeandtest/theme(previously missed). Applies to both production and test targets. - Path handling is normalized so the exclusions work on Windows and Unix.
Improvements #
- The two rules(avoid_static_colors and avoid_static_typography) now run on both production and test files, while still excluding theme files in both locations. This keeps color and typography enforcement consistent across the codebase.
0.2.0 Static Colors & Typography Rules #
New Features #
avoid_static_colors: New production rule that forbids using static color definitions (e.g.,CoreTextColors,Colors.white,Color(0xFF...)) in UI code and enforces theme-extension based colors for proper light/dark support.avoid_static_typography: New production rule that forbids using static typography definitions (CoreTypography.*), rawTextStyle(...)constructors, andGoogleFonts.*in UI code, enforcing typography access viaTheme.of(context).extension<TypographyExtension>().
Improvements #
- Standalone checker:
standalone_checkerhas been updated to include the new rules so they can be run via the CLI (--rules avoid_static_colors,avoid_static_typography).
0.1.4 NoOptionalOperatorsInTests Analyzer Bug Fixes #
Bug Fixes #
- Fixed nested test/group state tracking: The analyzer now correctly tracks nested
test,group, andtestWidgetsblocks using depth counters instead of boolean flags. Previously, optional operators after nested blocks were not detected. - Fixed missing
??=operator detection: The null-aware assignment operator is now correctly flagged in test blocks. - Fixed missing
?[]operator detection: The null-aware index operator is now correctly flagged in test blocks. - Fixed missing
testWidgetssupport: Flutter widget tests usingtestWidgetsare now correctly recognized as test blocks. - Fixed missing
setUpAll/tearDownAllexclusion: These lifecycle methods are now correctly excluded from linting, matching the existingsetUp/tearDownbehavior.
0.1.3 Standalone Checker Rule Filtering Fix #
Bug Fixes #
- Fixed rule filtering: Fixed
standalone_checkerto properly filter rules based on file type when both test and production rules are specified together. Test-only rules are now correctly applied only to test files, and production rules are only applied to production files, preventing incorrect rule application.
Technical Details #
- When test rules (e.g.,
avoid_test_timeouts,no_optional_operators_in_tests,prefer_fake_over_mock,document_fake_parameters,test_file_mutation_coverage) and production rules are specified together, the checker now correctly applies the appropriate rules to the correct file types. - This fix ensures that test files are only checked with test-specific rules and production files are only checked with production rules, even when both rule types are enabled in the same command.
0.1.2 Standalone Checker Enhancement #
New Features #
- Standalone command-line tool: added
standalone_checkerexecutable to run specific lint rules quickly. - Check single rule:
dart run ripplearc_linter:standalone_checker --rules prefer_fake_over_mock lib/ - Check multiple rules:
dart run ripplearc_linter:standalone_checker --rules rule1,rule2 lib/ - Check all rules:
dart run ripplearc_linter:standalone_checker lib/
Notes #
- Added convenience: test files are analyzed when the target path is
test/(or inside it), or when any test-specific rule is enabled (e.g.,avoid_test_timeouts,no_optional_operators_in_tests,prefer_fake_over_mock,document_fake_parameters).
0.1.1 Package Renaming #
Breaking Changes #
- Package Renamed: The package has been renamed from
ripplearc_lint_rulestoripplearc_linterfor better naming consistency.- Main library file renamed:
lib/ripplearc_lint_rules.dart→lib/ripplearc_linter.dart - Update your
pubspec.yamlto useripplearc_linterinstead ofripplearc_lint_rules - All documentation and examples have been updated to reflect the new package name
- Main library file renamed:
Migration Guide #
If you're upgrading from version 0.1.0, update your pubspec.yaml:
# Old
dependencies:
ripplearc_lint_rules: ^0.1.0
# New
dependencies:
ripplearc_linter: ^0.1.1
Then run dart pub get to fetch the updated package.
0.1.0 Initial Release #
A comprehensive custom lint library for Dart/Flutter projects with 13 carefully crafted lint rules to enforce best practices, improve code quality, and ensure robust testing standards.
Lint Rules #
Error-Level Rules
-
forbid_forced_unwrapping: Forbids forced unwrapping (!) in production code. Exceptions: test files,/testing/fakes, and generated files (.freezed.dart,.g.dart). -
no_optional_operators_in_tests: Forbids optional operators (?.,??,??=,?[]) in test files to ensure explicit test failures. -
no_direct_instantiation: Enforces dependency injection by forbidding direct class instantiation. Exceptions: Module and Factory classes. -
document_fake_parameters: Requires documentation on Fake classes and their non-private members. -
document_interface: Requires documentation on abstract classes and their public methods. -
test_file_mutation_coverage: Ensures every test file intest/unitshas a corresponding.xmlmutation file intest/mutations. -
private_subject: Requires Subject variables (BehaviorSubject, ReplaySubject, PublishSubject) to be private with underscore prefix. -
sealed_over_dynamic: Enforces sealed classes instead ofdynamicfor type-safe sync results. -
specific_exception_types: Requires specific exception types instead of genericException.
Warning-Level Rules
-
prefer_fake_over_mock: RecommendsFakeoverMockfor test doubles. -
todo_with_story_links: Requires TODO comments to include YouTrack story links. -
no_internal_method_docs: Forbids documentation on private methods to reduce noise. -
avoid_test_timeouts: Forbids.timeout()andFuture.delayed()in tests to prevent flaky tests.
Features #
- Clean architecture with base analyzer and lint rule classes
- Extensible framework for adding custom rules
- Comprehensive test coverage for all rules
- Example files demonstrating violations and correct usage
- Support for custom lint configuration via
custom_lint.yaml - Integration with Dart analyzer and IDE support