| 2 | import { FormatterCallback } from '../formatter' |
| 3 | |
| 4 | const compactFormatter: FormatterCallback = function ( |
| 5 | formatter, |
| 6 | HTMLHint, |
| 7 | options |
| 8 | ) { |
| 9 | const nocolor = options.nocolor |
| 10 | |
| 11 | const chalkInstance = |
| 12 | nocolor !== false ? new chalk.Instance({ level: 1 }) : chalk |
| 13 | |
| 14 | formatter.on('file', (event) => { |
| 15 | event.messages.forEach((message) => { |
| 16 | console.log( |
| 17 | '%s: line %d, col %d, %s - %s (%s)', |
| 18 | event.file, |
| 19 | message.line, |
| 20 | message.col, |
| 21 | message.type, |
| 22 | message.message, |
| 23 | message.rule.id |
| 24 | ) |
| 25 | }) |
| 26 | }) |
| 27 | |
| 28 | formatter.on('end', (event) => { |
| 29 | const allHintCount = event.allHintCount |
| 30 | if (allHintCount > 0) { |
| 31 | console.log('') |
| 32 | const message = '%d problems' |
| 33 | console.log( |
| 34 | nocolor ? message : chalkInstance.red(message), |
| 35 | event.allHintCount |
| 36 | ) |
| 37 | } |
| 38 | }) |
| 39 | } |
| 40 | |
| 41 | module.exports = compactFormatter |