solana_kit_lints

pub package docs website CI coverage

Shared lint rules for all packages in the Solana Kit Dart SDK.

This is an internal package (publish_to: none) that centralizes the analysis configuration for the monorepo. It is not published to pub.dev.

Installation

Install with:

dart pub add --dev solana_kit_lints

Within the solana_kit monorepo, the package resolves through the Dart workspace. This package is not intended for use outside the monorepo.

Documentation

Usage

Including the lint rules

Create or update your package's analysis_options.yaml to include the shared rules:

include: package:solana_kit_lints/analysis_options.yaml

This single line gives your package the full set of lint rules used across the Solana Kit SDK. No additional configuration is needed in most cases.

For Flutter packages, include the Flutter preset instead:

include: package:solana_kit_lints/flutter_analysis_options.yaml

The Flutter preset uses flutter_lints as its base, then reapplies the Solana Kit analyzer severities and project-specific lint policy.

Adding package-specific overrides

If a specific package needs to adjust a rule, add overrides after the include:

include: package:solana_kit_lints/analysis_options.yaml

linter:
  rules:
    avoid_print: false # Allow print in example/CLI packages

Configuration

The shared analysis_options.yaml provided by this package includes very_good_analysis as its base and applies the following customizations:

Base

include: package:very_good_analysis/analysis_options.yaml

Flutter packages use a separate preset because Dart analysis options only allow one top-level include:

include: package:flutter_lints/flutter.yaml

That Flutter preset then layers the Solana Kit rules back on top.

Analyzer error severity

The following diagnostics are promoted to errors to catch problems early:

Diagnostic Severity
missing_return error
dead_code error
unused_element error
unused_import error
unused_local_variable error
todo ignore

Lint rule customizations

The following rules from the base presets are customized for this project:

Rule Value Reason
public_member_api_docs true Published packages should document public API.
lines_longer_than_80_chars false Disabled because many error messages, type signatures, and constant names in the SDK naturally exceed 80 characters.
cancel_subscriptions true Catch leaked stream subscriptions.
close_sinks true Catch leaked sinks and controllers.
avoid_equals_and_hash_code_on_mutable_classes false Value-like mutable classes are allowed where package APIs require them.

Full configuration

For reference, the complete shared analysis options file:

include: package:very_good_analysis/analysis_options.yaml

analyzer:
  errors:
    missing_return: error
    dead_code: error
    unused_element: error
    unused_import: error
    unused_local_variable: error
    todo: ignore

linter:
  rules:
    public_member_api_docs: true
    lines_longer_than_80_chars: false
    cancel_subscriptions: true
    close_sinks: true
    avoid_equals_and_hash_code_on_mutable_classes: false

API Reference

Provided files

  • lib/analysis_options.yaml -- The shared analysis options file that all Dart packages include. Built on top of very_good_analysis with project-specific customizations.
  • lib/flutter_analysis_options.yaml -- The shared analysis options file for Flutter packages. Built on top of flutter_lints with the Solana Kit analyzer severities and project-specific customizations layered back in.

Example

Use example/README.md as a runnable starting point for solana_kit_lints.

  • Import path: N/A (lint package)
  • This section is centrally maintained with mdt to keep package guidance aligned.
  • After updating shared docs templates, run docs:update from the repo root.

Maintenance

  • Validate docs in CI and locally with docs:check.
  • Keep examples focused on one workflow and reference package README sections for deeper API details.

Libraries