team_guard 1.0.7
team_guard: ^1.0.7 copied to clipboard
Custom lint plugin to block forbidden Flutter widgets across team projects.
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_lintfor live IDE feedback. - Supports configurable restrictions for both widgets and classes.
- Supports
info,warning, anderrorseverities per rule. - Provides quick-fix suggestions with replacement names/imports.
Prerequisites #
- Dart SDK
>=3.3.0 <4.0.0 custom_lintinstalled in the target project- IDE plugin:
- VS Code:
Custom Lint - Android Studio / IntelliJ:
Custom Lint
- VS Code:
Installation #
Add dependencies to your app's pubspec.yaml:
dev_dependencies:
team_guard: ^1.0.6
custom_lint: ^0.8.1
Then run:
# Flutter project
flutter pub get
# Dart project
dart pub get
Uninstall #
flutter pub remove team_guard custom_lint
Setup (Required) #
- Initialize Team Guard in your project root:
dart run team_guard:init
This command:
- creates
team_guard.yamlif missing - creates
analysis_options.yamlif missing - adds
custom_lintplugin underanalyzer.pluginsif missing
- Run the linter:
dart run custom_lint
- If your IDE still does not show lints, restart analysis server/IDE.
Configuration #
Create team_guard.yaml in your project root:
widgets:
Text:
replacement: CustomText
# import: package:your_app/widgets/custom_text.dart
severity: error
GestureDetector:
replacement: AppGestureDetector
severity: error
classes:
Colors:
replacement: AppColors
# import: package:your_app/theme/app_colors.dart
severity: error
Full setup example: example/team_guard_example.dart
Import Field Format #
import in team_guard.yaml must be a package path only.
Correct:
import: package:your_app/widgets/custom_text.dart
or
import: "package:your_app/widgets/custom_text.dart"
Wrong:
import: "import 'package:your_app/widgets/custom_text.dart';"
Severity Values #
infowarningerror
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 #
- Confirm
analysis_options.yamlcontains:
analyzer:
plugins:
- custom_lint
- Install IDE plugin
Custom Lint. - Restart analysis:
- VS Code:
Dart: Restart Analysis Server - Android Studio/IntelliJ: restart IDE
- VS Code:
- Check Problems filter is not set to errors-only if your rules are
warning.
team_guard.yaml was not generated #
- Run
dart run custom_lintfrom the project root. - If still missing, create
team_guard.yamlmanually using the example above.
Additional Information #
- Package: https://pub.dev/packages/team_guard
- custom_lint docs: https://pub.dev/packages/custom_lint
- Issues and contributions: https://github.com/HazemHamdy7/team_guard