VOOZH about

URL: https://pub.dev/packages/leancode_lint

⇱ leancode_lint | Dart package


👁 Image

leancode_lint 24.0.0 👁 Copy "leancode_lint: ^24.0.0" to clipboard
leancode_lint: ^24.0.0 copied to clipboard

Metadata

Robust and high-quality lint rules used at LeanCode.

leancode_lint #

👁 leancode_lint pub.dev badge

An opinionated set of high-quality, robust, and up-to-date lint rules used at LeanCode.

Usage #

There are two supported ways to use this package:

  1. As-is (default configuration) – enable the built-in leancode_lint analyzer plugin. This uses const LeanCodeLintConfig() defaults.
  2. With custom configuration – create your own analyzer plugin package that instantiates LeanCodeLintPlugin with your LeanCodeLintConfig, then enable your plugin instead (see “Configuration (custom plugin package)” below).

If you only want to toggle individual rules on/off, you can do that in analysis_options.yaml (see “Custom lint rules”).

Installation #

  1. Add leancode_lint as a dev dependency in your project's pubspec.yaml.

    dart pub add leancode_lint --dev
    
  2. In your analysis_options.yaml add include: package:leancode_lint/analysis_options.yaml. You might want to exclude some files (e.g generated json serializable) from analysis.

  3. Enable the analyzer plugin in analysis_options.yaml.

  4. Run flutter pub get in your project main directory and restart the analysis server in your IDE. You're ready to go!

Example analysis_options.yaml:

include: package:leancode_lint/analysis_options.yaml

plugins:
 leancode_lint: ^20.0.0

analyzer:
 exclude:
 - '**/*.g.dart'

Tip

See the example/ directory for complete, runnable examples with both default and custom configuration.

Configuration (custom plugin package) #

This section is optional. You only need it if you want to customize the behavior of configurable rules beyond the built-in defaults.

To configure leancode_lint rules programmatically, create your own analyzer plugin package (e.g. my_lints) that depends on leancode_lint and exposes a top-level plugin variable.

my_lints/lib/main.dart:

import 'package:leancode_lint/plugin.dart';

final plugin = LeanCodeLintPlugin(
 name: 'my_lints',
 config: LeanCodeLintConfig(
 applicationPrefix: 'Lncd',
 catchParameterNames: CatchParameterNamesConfig(
 exception: 'error',
 stackTrace: 'stackTrace',
 ),
 designSystemItemReplacements: {
 'AppText': [
 DesignSystemForbiddenItem(name: 'Text', packageName: 'flutter'),
 DesignSystemForbiddenItem(name: 'RichText', packageName: 'flutter'),
 ],
 'AppScaffold': [
 DesignSystemForbiddenItem(name: 'Scaffold', packageName: 'flutter'),
 ],
 },
 ),
);

Then enable your plugin in the consuming project’s analysis_options.yaml:

include: package:leancode_lint/analysis_options.yaml

plugins:
 my_lints:
 path: ./path/to/my_lints

Usage in libraries #

If your package is a library rather than a binary application, you will expose some public API for users of your library. Therefore, you should use lint rules optimized for this case by just changing your include entry in analysis_options.yaml:

include: package:leancode_lint/analysis_options_package.yaml

Custom lint rules #

Disabling custom lint rules #

To disable a particular custom lint rule, set the rule to false in analysis_options.yaml. For example, to disable prefix_widgets_returning_slivers:

plugins:
 leancode_lint:
 version: ^20.0.0
 diagnostics:
 prefix_widgets_returning_slivers: false

Assists #

Assists are IDE refactorings not related to a particular issue. They can be triggered by placing your cursor over a relevant piece of code and opening the code actions dialog. For instance, in VSCode this is done with + or +.

See linked source code containing explanation in dart doc.


🛠️ Maintained by LeanCode #

This package is built with 💙 by LeanCode. We are top-tier experts focused on Flutter Enterprise solutions.

Why LeanCode? #

  • Creators of Patrol – the next-gen testing framework for Flutter.

  • Production-Ready – We use this package in apps with millions of users.

  • Full-Cycle Product Development – We take your product from scratch to long-term maintenance.


Need help with your Flutter project?

👉 Hire our team   •   Check our other packages

Metadata

75
likes
160
points
38.7k
downloads

Documentation

API reference

Publisher

👁 Published by a pub.dev verified publisher
leancode.co

Weekly Downloads

Metadata

Robust and high-quality lint rules used at LeanCode.

Homepage
Repository (GitHub)
View/report issues

Topics

#analysis #analyzer #code-style #lint #lints

License

👁 Image
Apache-2.0 (license)

Dependencies

analysis_server_plugin, analyzer, analyzer_plugin, meta, path, source_span, yaml

More

Packages that depend on leancode_lint