jaspr_lints 0.1.2
jaspr_lints: ^0.1.2 copied to clipboard
A collection of lints and assists for jaspr projects.
Jaspr Lints #
This package provides lints and code assists for Jaspr projects.
Code Assists: #
- Create
StatelessComponent/StatefulComponent/InheritedComponent - Convert
StatelessComponenttoStatefulComponent - Convert
StatelessComponenttoAsyncStatelessComponent - Remove component from the tree
- Wrap component with
div()/section()/ul()or any html component - Wrap component with other component
- Wrap component with
Builder - Extract subtree into
StatelessComponent - Add styles to html component
- Convert import to web-only / server-only import
Lints #
- Prefer html methods like
div(...)overDomComponent(tag: 'div', ...). (Fix available) - Sort children properties last in html component methods. (Fix available)
Setup: #
- Add
jaspr_lintsas dev dependency:
dart pub add jaspr_lints --dev
- Add the following to your
analysis_options.yamlfile:
analyzer:
plugins:
- custom_lint
After running dart pub get you now see additional Jaspr lints
when invoking code assist on a component function like div() or p() files.
Usage #
Unfortunately, running dart analyze does not pick up the custom lints.
Instead, you need to run a separate command for this: jaspr analyze
Also enabling / disabling specific lint rules works slightly different.
In analysis_options.yaml add the following section:
custom_lint:
rules:
prefer_html_methods: true
sort_children_properties_last: true