lint_kit 0.0.2 copy "lint_kit: ^0.0.2" to clipboard
lint_kit: ^0.0.2 copied to clipboard

Define your own lint rules, provide quick fixes, and debug your analyzer in real time.

lint_kit #

Warning

This package is still under active development and is not yet ready for public use.

lint_kit is the core package used to build custom Dart lints and quick actions for use with the Dart Lint Kit VSCode extension. It empowers you to define your own Lints and CodeActions within your project — complete with real-time debugging, editor integration, and zero-config setup.

Note

✨ This toolkit enhances Dart's linting capabilities, allowing you to augment your development workflow with project-specific rules, quick fixes, and more — it does not replace the Dart analyzer.


🎯 What Can You Build? #

With lint_kit, you can define:

  • Custom Lints with severity levels:
    • hint
    • info
    • warning
    • error
  • Code Actions to create quick fixes or refactor suggestions.

🚀 Getting Started #

  1. Install the Extension Search for Dart Lint Kit in the Extensions Marketplace and install it.

  2. Create a Lint Kit Package Open the command palette and run: Dart Lint Kit: Create Lint Kit Package

    This will generate a fully configured lint_kit package in the root of your workspace, complete with an example analyzer.

  3. Start Writing Lints Once the package exists, VSCode will automatically detect it and integrate it into the analyzer — no additional setup needed.


🔍 Live Debugging #

A key feature of lint_kit is interactive analyzer debugging.

Use the command: Dart Lint Kit: Debug Analyzer

This launches your analyzer in debug mode. You can set breakpoints and inspect values just like any other Dart application. When debugging ends, the extension automatically restarts your analyzer with the latest changes — no reload required.


🧪 Example: Custom Analyzer #

Here’s a simple example of an analyzer that finds usages of const:

import 'package:lint_kit/lint_kit.dart';

class MyPerformAnalysis implements LintKitAnalyzer {
  const MyPerformAnalysis();

  @override
  Future<List<Message>> analyze(
    AnalyzedFile file,
    AnalysisOptions? options,
  ) async {
    final lines = file.content.split('\n');

    Iterable<Message> lints() sync* {
      for (final (index, line) in lines.indexed) {
        if (!line.contains('const')) continue;

        final constIndex = line.indexOf('const');

        yield Lint(
          range: Range(
            start: Position(line: index, character: constIndex),
            end: Position(line: index, character: constIndex + 5),
          ),
          code: 'example_lint',
          message: 'This is a const',
          path: file.path,
          severity: Severity.info, // Options: hint, info, warning, error
        );
      }
    }

    return lints().toList();
  }

  @override
  String get packageName => 'my_lints';

  @override
  List<LintKitAnalyzer> get plugins => [];
}

🧩 Using Plugins #

The plugins getter allows you to import external community analyzers into your project:

@override
List<LintKitAnalyzer> get plugins => [
  const CommunityLints(),
  const AccessibilityRules(),
];

This is useful for expanding your analyzer with reusable lints and actions developed by others.


🧠 Design Philosophy #

lint_kit is built for extension, not replacement. It works alongside the Dart analyzer, giving you the power to:

  • Define project-specific conventions.
  • Rapidly test and debug lint rules.
  • Share lints across teams or packages.
  • Automate repetitive refactorings and suggestions.

🙌 Contributions #

Have ideas for improving lint_kit? We welcome feedback, contributions, and plugin proposals. Feel free to open an issue or start a discussion.

0
likes
140
points
58
downloads

Publisher

verified publisherlintkit.dev

Weekly Downloads

Define your own lint rules, provide quick fixes, and debug your analyzer in real time.

View/report issues

Topics

#linter #analyzer #code-quality #code-actions

Documentation

API reference

License

MIT (license)

Dependencies

analyzer, equatable, json_annotation, lint_kit_domain

More

Packages that depend on lint_kit