-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Description
Bug Report or Feature Request (mark with an x
)
- [ ] bug report -> please search issues before submitting
- [x] feature request
Desired functionality.
Currently, ng lint
analyzes all files in the project. I work on a project that has ~260 .ts files in a single project (multiple modules), and to lint all of them takes a while and the output can be hard to digest if there are errors across many files. I think a feature flag (ng lint --staged
or similar) to lint only the files that have changed would be a great addition. This is a pretty common feature (eg. lint-staged
).
This would also help another specific use case: if a dev/team wants to run lint as a precommit hook, linting just the changed files would make a lot of sense without the burden of analyzing extra files.
Alternative
I could see an argument for not incorporating this into the CLI because it would either be dependent on a single version control system or have support all of them (maybe just git at first, others incrementally). A great alternative would be to expose a --files
flag so that consumers can have control over which files are linted. This way would work easily with lint-staged
. Below would be an example of how a sample config inside package.json might look (from lint-staged docs):
{
"scripts": {
"precommit": "lint-staged"
...
},
"lint-staged": {
"src/**/*.ts": ["ng lint --fix", "git add"]
}
}
The lint-staged docs seem to suggest that tslint already works but the way the CLI retrieves files doesn't seem to make this possible at the moment. Would love to be wrong! If I am wrong, perhaps it could be added to docs in some way showing how it could be done.