-
Notifications
You must be signed in to change notification settings - Fork 169
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
Add --quiet option #55
Changes from 1 commit
3ec6762
88858a7
a2f5daa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,11 @@ function init() { | |
.description('Linter for Solidity programming language') | ||
.action(execMainAction); | ||
|
||
program | ||
.usage('[options] <file> [...other_files]') | ||
.option('-q, --quiet', 'report errors only - default: false') | ||
.action(execMainAction); | ||
|
||
program | ||
.command('stdin') | ||
.description('linting of source code data provided to STDIN') | ||
|
@@ -39,6 +44,12 @@ function execMainAction() { | |
const reportLists = program.args.filter(_.isString).map(processPath); | ||
const reports =_.flatten(reportLists); | ||
|
||
if (program.quiet) { | ||
console.log('::::Quiet mode enabled - filtering out warnings::::'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think that we should log anything here. |
||
// Setting int the report list errors only. | ||
reports[0].reports = getErrorResults(reports); | ||
} | ||
|
||
printReports(reports, program.formatter); | ||
exitWithCode(reports); | ||
} | ||
|
@@ -113,6 +124,17 @@ function processPath(path) { | |
return linter.processPath(path, readConfig()); | ||
} | ||
|
||
|
||
/** | ||
* Returns results that only contains errors. | ||
* @param {LintResult[]} reporter The results to filter. | ||
* @returns {LintResult[]} The filtered results. | ||
**/ | ||
function getErrorResults(reporter) { | ||
const reporterErrors = reporter[0].reports.filter(i => i.severity === 2); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is short and unlikely to be reused, I would do it inline. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree, its a good observation. |
||
return reporterErrors; | ||
} | ||
|
||
function printReports(reports, formatter) { | ||
const formatterName = formatter || 'stylish'; | ||
const formatterFn = require(`eslint/lib/formatters/${formatterName}`); | ||
|
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.
This is duplicating the previous block. I think you just need to add the
.option
line in that block.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.
Perfect, I will modify it.