Skip to content

Commit

Permalink
feat: add policyUrl and policyInfo in the default output.
Browse files Browse the repository at this point in the history
  • Loading branch information
Neil Zhao committed Sep 26, 2022
1 parent e42d542 commit fb81866
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion formatters/symbol_formatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,33 @@ class SymbolFormatter {
*
* @param {Result} result The result to format, must be valid
* @param {string} ruleName The name of the rule this result is from
* @param {string} rulePolicyUrl The policyUrl of the rule this result is from
* @param {string} rulePolicyInfo The policyInfo of the rule this result is from
* @param {string} errorSymbol The symbol to use if the result did not pass
* @param {string} okSymbol The symbol to use if the result passed
* @returns {string} The formatted string
*/
static formatResult(
result,
ruleName,
rulePolicyUrl = undefined,
rulePolicyInfo = undefined,
errorSymbol,
okSymbol = logSymbols.success
) {
// format lint output
let policyLines = ''
if (!result.passed) {
if (rulePolicyUrl)
policyLines += `\n\t${logSymbols.info} PolicyUrl: ${rulePolicyUrl}`
if (rulePolicyInfo)
policyLines += `\n\t${logSymbols.info} PolicyInfo: ${rulePolicyInfo}`
}
const formatbase = `\n${
result.passed ? okSymbol : errorSymbol
} ${ruleName}:${frontSpace(result.message)}`
} ${ruleName}:${frontSpace(result.message)}${
!result.passed ? policyLines : ''
}`
// condensed one-line version for rules with no targets
if (result.targets.length === 0) {
return formatbase
Expand Down Expand Up @@ -136,6 +149,8 @@ class SymbolFormatter {
return SymbolFormatter.formatResult(
result.lintResult,
result.ruleInfo.name,
result.ruleInfo.policyUrl,
result.ruleInfo.policyInfo,
SymbolFormatter.getSymbol(result.ruleInfo.level)
)
})
Expand All @@ -150,6 +165,8 @@ class SymbolFormatter {
SymbolFormatter.formatResult(
result.fixResult,
result.ruleInfo.name,
result.ruleInfo.policyUrl,
result.ruleInfo.policyInfo,
SymbolFormatter.getSymbol(result.ruleInfo.level),
dryRun ? logSymbols.info : logSymbols.success
)
Expand Down

0 comments on commit fb81866

Please sign in to comment.