Skip to content
pubscout

lint_staged

0.5.1, released 3 years ago by an unverified publisher

Run linters and custom commands on git staged files for Flutter and Dart projects

$ flutter pub add lint_staged
Source repository

What it does

Runs arbitrary shell commands and linters on a subset of git staged files matched by glob patterns before a commit. It supports backing up uncommitted changes via git stash and can be used as a pre-commit git hook or via Dart code.

AI-written summary of version 0.5.1, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You want to automatically run code formatters or linters like dart format on staged files before committing
  • You want to prevent errors and ensure code style consistency in git commits

Skip it when

  • You want to lint the entire project repository instead of only staged files
  • You are not using git for version control

Strengths

  • Speeds up linting by only checking files that are about to be committed
  • Supports custom glob pattern matching for file filtering
  • Provides built-in backup stashing and error recovery

Weaknesses

  • Requires manual configuration of git hooks (such as using Husky)
  • Behavior depends on external git commands and local executable environments

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
7

Add as a dev dependency via pub add, configure rules in pubspec.yaml, and set up git hooks using a tool like husky.

import 'package:lint_staged/lint_staged.dart';

try {
  final success = await lintStaged();
  print(success ? 'Linting was successful!' : 'Linting failed!');
} catch (e) {
  print(e);
}

Alternatives

Packages that do the same job and could replace lint_staged.

  • bdd_framework

    Create BDD tests in Dart code with readable error messages and Gherkin feature file export.

  • codemod

    Write and run automated code modifications and refactors on a codebase.

  • freezed_lint

    Linter plugin that enforces correct usage of freezed classes.

  • shutter

    Renders Flutter widget previews to PNG and diffs two runs pixel by pixel.

Works with

Packages commonly used together with lint_staged: ones it builds on, ones built on it, and its own family.