MCPcopy
hub / github.com/htmlhint/HTMLHint / compactFormatter

Function compactFormatter

src/cli/formatters/compact.ts:4–39  ·  view source on GitHub ↗
(
  formatter,
  HTMLHint,
  options
)

Source from the content-addressed store, hash-verified

2import { FormatterCallback } from '../formatter'
3
4const 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
41module.exports = compactFormatter

Callers

nothing calls this directly

Calls 1

onMethod · 0.80

Tested by

no test coverage detected