Skip to content

Commit

Permalink
Separates messsages in errors and warnings (patch)
Browse files Browse the repository at this point in the history
  • Loading branch information
zrrrzzt committed Feb 12, 2020
1 parent 91435f5 commit 5d98487
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lib/validate.js
Expand Up @@ -9,19 +9,23 @@ module.exports = async options => {
const report = htmlvalidate.validateString(data)
let { valid, errorCount, warningCount, results } = report
let isValid = valid
let messages = results.length > 0 ? results[0].messages : []
const messages = results.length > 0 ? results[0].messages : []
let errors = messages.filter(message => message.severity === 2)
let warnings = messages.filter(message => message.severity === 1)

if (ignore) {
console.log('ignore!')
messages = filterData(messages, ignore)
isValid = messages.length === 0
errorCount = messages.length
errors = filterData(errors, ignore)
warnings = filterData(warnings, ignore)
isValid = errors.length === 0
errorCount = errors.length
warningCount = warnings.length
}

return {
isValid,
errorCount,
warningCount,
messages
errors,
warnings
}
}

0 comments on commit 5d98487

Please sign in to comment.