team_guard 1.0.2 copy "team_guard: ^1.0.2" to clipboard
team_guard: ^1.0.2 copied to clipboard

A powerful custom lint plugin for Dart and Flutter that prevents the use of forbidden widgets in your team projects. Configure which widgets are not allowed and get real-time feedback.

Team Guard #

A custom lint plugin for Dart and Flutter that helps teams enforce UI rules by blocking specific widgets/classes and suggesting approved replacements.

Features #

  • Integrates with custom_lint for live IDE feedback.
  • Supports configurable restrictions for both widgets and classes.
  • Supports info, warning, and error severities per rule.
  • Provides quick-fix suggestions with replacement names/imports.

Prerequisites #

  • Dart SDK >=3.3.0 <4.0.0
  • custom_lint installed in the target project
  • IDE plugin:
    • VS Code: Custom Lint
    • Android Studio / IntelliJ: Custom Lint

Installation #

Add dependencies to your app's pubspec.yaml:

dev_dependencies:
  team_guard: ^1.0.1
  custom_lint: ^0.8.1

Then run:

# Flutter project
flutter pub get

# Dart project
dart pub get

Setup (Required) #

  1. Enable custom_lint in analysis_options.yaml:
analyzer:
  plugins:
    - custom_lint
  1. Run the linter:
dart run custom_lint
  1. Team Guard reads (and may create) a config file in project root:

team_guard.yaml

If the file is not generated automatically, create it manually (example below).

Configuration #

Create team_guard.yaml in your project root:

widgets:
  Text:
    replacement: CustomText
    # import: package:your_app/widgets/custom_text.dart
    severity: warning

  GestureDetector:
    replacement: AppGestureDetector
    severity: error

classes:
  Colors:
    replacement: AppColors
    # import: package:your_app/theme/app_colors.dart
    severity: warning

Severity Values #

  • info
  • warning
  • error

Use error if you want violations to appear as red errors in IDE problems.

Example Violation #

If Text is restricted:

Text('Hello');

You will get a lint message suggesting CustomText instead.

Troubleshooting #

Lints appear in terminal but not in IDE #

  1. Confirm analysis_options.yaml contains:
analyzer:
  plugins:
    - custom_lint
  1. Install IDE plugin Custom Lint.
  2. Restart analysis:
    • VS Code: Dart: Restart Analysis Server
    • Android Studio/IntelliJ: restart IDE
  3. Check Problems filter is not set to errors-only if your rules are warning.

team_guard.yaml was not generated #

  • Run dart run custom_lint from the project root.
  • If still missing, create team_guard.yaml manually using the example above.

Additional Information #

6
likes
0
points
266
downloads

Publisher

unverified uploader

Weekly Downloads

A powerful custom lint plugin for Dart and Flutter that prevents the use of forbidden widgets in your team projects. Configure which widgets are not allowed and get real-time feedback.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

analyzer, custom_lint_builder, yaml

More

Packages that depend on team_guard