kaisel_lint 0.5.1
kaisel_lint: ^0.5.1 copied to clipboard
Lint rules, quick fixes, and assists for the kaisel Flutter router, built on the first-party analysis_server_plugin API.
Changelog #
0.5.1 #
Fixed #
- Lints now actually load in IDEs and
dart analyzeon current stable SDKs.analysis_server_plugin0.3.16 dropped the legacyanalysis.setContextRootshandler that current stable SDK analysis servers still send, so a plugin built against 0.3.16+ would load, pass the version check, then reject the request and sit idle — zero diagnostics, no visible error. The dependency is now capped to>=0.3.15 <0.3.16, the last version speaking the server's dialect. The cap lifts when the SDK server moves toanalysis.setAnalysisRoots(expected around Dart 3.13, alongside thedart analyzeplugin fixes tracked in dart-lang/sdk#38407).
Note #
- Gate lints in CI with
dart analyze, notflutter analyze— flutter_tools' analysis client exits before plugin diagnostics arrive (flutter/flutter#28327 reproduces on current stable despite being closed).
0.5.0 #
Dependencies #
- Bump
analyzerto>=13.0.0 <14.0.0(withanalyzer_plugin >=0.14.9,analysis_server_plugin >=0.3.15,analyzer_testing >=0.2.6). Migrated for analyzer 13:ArgumentList.argumentsnow yieldsArgumentnodes, so an argument's static type is read viaargument.argumentExpression.staticType. kaisel_lintleft the Flutter workspace and dropped itsflutterSDK constraint. It is pure Dart and tracks the latest analyzer, which needs a newertest_apithan the Flutter SDK'sflutter_testpins; it now resolves independently — rundart pub getin this package.
0.4.0 #
Dependencies #
- Bump the analyzer toolchain to
analyzer >=12.1.0 <13.0.0,analyzer_plugin >=0.14.8 <0.15.0,analysis_server_plugin >=0.3.14 <0.4.0, andanalyzer_testing >=0.2.5 <0.3.0(needs Flutter ≥ 3.38.0). Migrated the rules to the analyzer's new element model:Element.isSynthetic→isOriginDeclaration, andClassDeclaration.name→namePart.typeName.
0.3.0 #
Tooling #
- Ship
package:kaisel_lint/recommended.yaml. Apps can opt in with one line —include: package:kaisel_lint/recommended.yamlinanalysis_options.yaml(plus thedev_dependenciesentry) — which activates the plugin with the correctness baseline (require_route_props,avoid_modal_route_on_main_stack) on and the stylistic/adaptive rules off.
Lint rules #
unused_guard_redirect(info, off by default) — flags a guard-shaped closure that returns the proposed stack unchanged on every path (a no-op). Conservative: only fires when the body is purely returns and control flow, so guards kept for a side effect are left alone. No quick fix.
0.2.0 #
Lint rules #
prefer_const_route_constructors(info, off by default) — flags aKaiselRouteconstruction that could beconstbut isn't. A route-scoped variant ofprefer_const_constructors, so you can enforce const routes without const-ing every class in the project.prefer_pattern_match_over_is_check(info, off by default) — flagsroute is SomeRoutetype tests (where both sides areKaiselRoutesubtypes), which aswitch/pattern match expresses better. No quick fix — the safe rewrite is contextual.
Quick fixes #
- Add
constfor the const-route lint (inserts the keyword, or replaces a leadingnew).
0.1.0 — Initial release #
First public version. Built as an analysis server plugin on
analysis_server_plugin: 0.3.7 (analyzer 10.0.1); requires Dart ^3.9.0.
Lint rules #
avoid_modal_route_on_main_stack(warning, enabled by default) — flagsrouter.push(modalRoute)where the argument's static type implementsKaiselModalRoute<T>. Pushing a flow loses its typed completion contract.require_route_props(warning, enabled by default) — flagsKaiselRoutesubclasses that declare instance fields without overridingprops. Value equality is implicit in the library's contract; withoutpropsthe stack treats equal routes as distinct.prefer_push_or_replace_top_in_adaptive(info, off by default) — flagsrouter.push(route)calls; opt-in per project where adaptive master-detail is in use.
Quick fixes #
- Convert
push()→run<T>()for the modal-route lint, withTrecovered from the route'sKaiselModalRoute<T>implementation. - Add
@override List<Object?> get props => [...]for the props lint, generating the list from the class's declared instance fields. - Convert
push()→pushOrReplaceTop()for the adaptive lint.
Assists #
- Convert
push()→run<T>()(cursor-driven). - Add
propsoverride (cursor-driven; usable before adding fields). - Convert
push()→pushOrReplaceTop()(cursor-driven).