reactter_lint 0.1.0 copy "reactter_lint: ^0.1.0" to clipboard
reactter_lint: ^0.1.0 copied to clipboard

Reactter_lint is an analytics tool for Reactter that helps developers to encourage good coding practices and preventing frequent problems.

Reactter


Pub Publisher Reactter Lint Pub points MIT License

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 #

Quickstart #

Run this command in your root project:

dart pub add -d reactter_lint custom_lint

And then include these lines of code into analysis_options.yaml:

analyzer:
  plugins:
    - custom_lint

Then you can see suggestions in your IDE or you can run checks manually:

dart run custom_lint

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);
  ...
}

Good

Fix: Use Reactter.lazyState for attaching a instance.

class AppController {
  final otherState = UseState(0);
  late final stateLate = Reactter.lazyState(
    () => UseState(otherState.value),
    this,
  );
  ...
}

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 {
  ...
}

Good

Fix: Name hook using use preffix.

class UseMyHook extends ReactterHook {
  ...
}

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;
  ...
}

Good

Fix: Define it after the hook register.

class UseMyHook extends ReactterHook {
  final $ = ReactterHook.$register;
  final stateHook = UseState(0);
  ...
}

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;
  ...
}

Cause: The hook register cannot be defined using setter.

class UseMyHook extends ReactterHook {
  set $(_) => ReactterHook.$register;
  ...
}

Cause: The hook register cannot be defined using var keyword.

class UseMyHook extends ReactterHook {
  var $ = ReactterHook.$register;
  ...
}

Cause: The hook register cannot be defined using a type.

class UseMyHook extends ReactterHook {
  Object $ = ReactterHook.$register;
  ...
}

Good

Fix: Define it using final keyword.

class UseMyHook extends ReactterHook {
  final $ = ReactterHook.$register;
  ...
}
2
likes
120
pub points
6%
popularity

Publisher

unverified uploader

Reactter_lint is an analytics tool for Reactter that helps developers to encourage good coding practices and preventing frequent problems.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

analyzer, analyzer_plugin, custom_lint_builder

More

Packages that depend on reactter_lint