Skip to main content

cobalt_lint 1.5.0 copy "cobalt_lint: ^1.5.0" to clipboard
cobalt_lint: ^1.5.0 copied to clipboard

Analyzer plugin with lint rules for Cobalt. Catches invalid annotations in the IDE instead of at build time.

example/example.md

cobalt_lint example #

An analyzer plugin. Add it to analysis_options.yaml at the root of the package or workspace:

plugins:
  cobalt_lint: ^1.0.0

Then dart analyze and the IDE report Cobalt mistakes where you make them, instead of when build_runner runs:

@cobaltInject
abstract class Broken {}
// warning: Cobalt cannot construct 'Broken': it is abstract.
//          — cobalt_injectable_must_be_constructible

@cobaltInject
class Controller {
  @injected
  Repository repository;
  // warning: Controller.repository must be declared "late final" to receive
  //          property injection. — cobalt_injected_field_must_be_late_final
}

@CobaltInit()
class Telemetry {}
// warning: Telemetry is annotated with @CobaltInit but declares no
//          'Future<void> init()' method. — cobalt_init_requires_init_method

Every rule reads annotations through cobalt_analyzer, the same layer the generator uses; the README lists them all.

Note that plugins only works at the root of a package or workspace, and that the analysis server resolves plugins from pub.dev rather than from your pubspec — see the README if you need to point it at local sources.

0
likes
0
points
1.6k
downloads

Publisher

unverified uploader

Weekly Downloads

Analyzer plugin with lint rules for Cobalt. Catches invalid annotations in the IDE instead of at build time.

Repository (GitHub)
View/report issues

Topics

#dependency-injection #lints #analyzer-plugin #di

License

unknown (license)

Dependencies

analysis_server_plugin, analyzer, analyzer_plugin, cobalt_analyzer

More

Packages that depend on cobalt_lint