kaisel_lint 0.2.0
kaisel_lint: ^0.2.0 copied to clipboard
Custom lint rules, quick fixes, and assists for the kaisel router (require route props, avoid modal route on the main stack, prefer pushOrReplaceTop), built on the first-party analysis_server_plugin API.
Changelog #
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).