-
Notifications
You must be signed in to change notification settings - Fork 87
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Problem Statement
When running custom_lint in CI/CD pipelines on pull requests, the tool currently analyzes entire packages even when only a few files have changed. This results in unnecessary analysis time and resource usage.
Example scenario:
- A PR changes 28 files across 2 packages
- Each package contains 125+ files
custom_lintanalyzes all 250+ files instead of just the 28 changed files- Analysis takes ~2 minutes when it could potentially take 20-30 seconds
Proposed Solution
Add CLI support for analyzing specific files, similar to how dart analyze works:
# Analyze specific files only
dart run custom_lint lib/file1.dart lib/file2.dart test/file3.dart
# Or via stdin for large file lists
echo "lib/file1.dart\nlib/file2.dart" | dart run custom_lint --stdin-filesUse Case
This feature is particularly valuable for:
- CI/CD PR checks - Only lint changed files in pull requests
- Pre-commit hooks - Only lint staged files
- IDE integrations - Faster feedback on file save
- Incremental analysis - Large monorepos with frequent small changes
Current Workaround Limitations
The existing LintRule.filesToAnalyze property filters which files to analyze within a package, but:
- ❌ Cannot limit analysis to specific file paths
- ❌ Only supports glob patterns for file matching
- ❌ Still requires analyzing the entire package structure
- ❌ No way to pass explicit file list via CLI
Using dart analyze as a fallback:
- ❌ Doesn't run custom lint rules
- ❌ Loses the value of custom_lint entirely
Proposed API
CLI Option
dart run custom_lint --files lib/a.dart,lib/b.dart,test/c.dartstdin Support (for large file lists)
dart run custom_lint --stdin-files < changed_files.txtEnvironment Variable (current melos pattern)
CUSTOM_LINT_FILES="lib/a.dart,lib/b.dart" dart run custom_lintImplementation Notes
This would likely require:
- Extending the CLI argument parser to accept file paths
- Modifying
CustomLintWorkspace.fromPaths()to support explicit file filtering - Ensuring analysis context still loads necessary package dependencies
- Maintaining compatibility with existing glob-based filtering
Benefits
- ⚡ Faster CI/CD - 60-90% reduction in analysis time for small PRs
- 💰 Cost savings - Reduced compute time in cloud CI runners
- ✅ Better DX - Faster feedback loops for developers
- 🎯 Targeted analysis - Only analyze what changed
Related Issues
- This would complement the existing
--watchmode for hot-reload - Similar to how
dart analyzeand ESLint support file-specific analysis - Aligns with incremental analysis patterns in other linters
Environment
- Tested on
custom_lintversion: 0.8.0 - Flutter monorepo with Melos
- Current workaround: Package-based filtering (sub-optimal) -- better than nothing
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request