-
-
Notifications
You must be signed in to change notification settings - Fork 412
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Verbose as CLI flag #319
feat: Verbose as CLI flag #319
Conversation
@@ -36,9 +36,14 @@ module.exports = function lintStaged(injectedLogger, configPath) { | |||
.then(result => { | |||
if (result == null) throw errConfigNotFound | |||
|
|||
const configResult = { | |||
verbose, | |||
...result.config |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are not transpiling the source code and destructuring objects isn't supported in node v4 and v6. Additionally, at this point the result.config
isn't normalized. So it could be in the simple or advanced format. You can refer https://github.com/okonet/lint-staged#configuration to know more about configuration. If the type is simple, then adding the verbose flag to it would be incorrect.
@montogeek do you mind fixing the PR? I'd love to merge it! |
@sudo-suhas I do not understand what you mean, if the configuration have |
@montogeek Sorry I wasn't clear. So here's an example of a simple config: {
"*.js": ["my-cmd"]
} And an advanced one: {
"linters": {
"*.js": ["my-cmd"]
},
"verbose": true
} The simple one is converted to the advanced format in And this would be the right place to introduce the verbose flag if we got it in the command line args. ------------------------------- src/getConfig.js -------------------------------
index 7d0a0bb..e087ed9 100644
@@ -91,9 +91,9 @@ function unknownValidationReporter(config, example, option, options) {
* concurrent: boolean, chunkSize: number, gitDir: string, globOptions: {matchBase: boolean, dot: boolean}, linters: {}, subTaskConcurrency: number, renderer: string, verbose: boolean
* }}
*/
-function getConfig(sourceConfig) {
+function getConfig(sourceConfig, verbose) {
const config = defaultsDeep(
- {}, // Do not mutate sourceConfig!!!
+ { verbose }, // Do not mutate sourceConfig!!!
isSimple(sourceConfig) ? { linters: sourceConfig } : sourceConfig,
defaultConfig
) This should also ensure that the command line flag overrides config if applicable. |
@montogeek any updates on this one? It would be really great to have this. I'd also suggest to remove the config option |
@okonet Why not support both? |
@sudo-suhas I think it doesn't belong to the config, TBH. |
What you are saying makes sense. But I have in fact, used the |
As discussed on #126, I added verbose mode as CLI flag.
I am not sure about variables naming, but it works and tests pass.
I think it need more tests, let me know if should be necessary.