Last updated:
0 purchases
reactter lint
Reactter_lint is an analytics tool for Reactter that helps developers to encourage good coding practices and preventing frequent problems using the conventions Reactter.
Contents #
Contents
Quickstart
Lints
hook_late_convention
Bad
Good
hook_name_convention
Bad
Good
invalid_hook_position
Bad
Good
invalid_hook_register
Bad
Good
Quickstart #
Run this command in your root project:
dart pub add -d reactter_lint custom_lint
copied to clipboard
And then include these lines of code into analysis_options.yaml:
analyzer:
plugins:
- custom_lint
copied to clipboard
Then you can see suggestions in your IDE or you can run checks manually:
dart run custom_lint
copied to clipboard
Lints #
hook_late_convention #
The hook late must be attached an instance.
Bad
Cause: ReactterHook cannot be late without attaching an instance.
class AppController {
final otherState = UseState(0);
late final stateLate = UseState(otherState.value);
...
}
copied to clipboard
Good
Fix: Use Reactter.lazyState for attaching an instance.
class AppController {
final otherState = UseState(0);
late final stateLate = Reactter.lazyState(
() => UseState(otherState.value),
this,
);
...
}
copied to clipboard
hook_name_convention #
The hook name should be prefixed with use.
Bad
Cause: The hook name is not prefixed with use.
class MyHook extends ReactterHook {
...
}
copied to clipboard
Good
Fix: Name hook using use preffix.
class UseMyHook extends ReactterHook {
...
}
copied to clipboard
invalid_hook_position #
The hook must be defined after the hook register.
Bad
Cause: The hook cannot be defined before the hook register.
class UseMyHook extends ReactterHook {
final stateHook = UseState(0);
final $ = ReactterHook.$register;
...
}
copied to clipboard
Good
Fix: Define it after the hook register.
class UseMyHook extends ReactterHook {
final $ = ReactterHook.$register;
final stateHook = UseState(0);
...
}
copied to clipboard
invalid_hook_register #
The hook register('$' field) must be final only.
Bad
Cause: The hook register cannot be defined using getter.
class MyHook extends ReactterHook {
get $ => ReactterHook.$register;
...
}
copied to clipboard
Cause: The hook register cannot be defined using setter.
class UseMyHook extends ReactterHook {
set $(_) => ReactterHook.$register;
...
}
copied to clipboard
Cause: The hook register cannot be defined using var keyword.
class UseMyHook extends ReactterHook {
var $ = ReactterHook.$register;
...
}
copied to clipboard
Cause: The hook register cannot be defined using a type.
class UseMyHook extends ReactterHook {
Object $ = ReactterHook.$register;
...
}
copied to clipboard
Good
Fix: Define it using final keyword.
class UseMyHook extends ReactterHook {
final $ = ReactterHook.$register;
...
}
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.