jaspr_lints 0.6.0
jaspr_lints: ^0.6.0 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)
- Sort styles properties. (Fix available)
- Prefer styles getter over (final) variable. (Fix available)
Setup: #
- Add
jaspr_lintsas a plugin to youranalysis_options.yamlfile:
plugins:
jaspr_lints:
diagnostics:
sort_children_last: true
prefer_html_components: true
styles_ordering: true
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
styles_ordering: true
prefer_styles_getter: true