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

Function unixFormatter

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

Source from the content-addressed store, hash-verified

2import { FormatterCallback } from '../formatter'
3
4const unixFormatter: 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 [
18 event.file,
19 message.line,
20 message.col,
21 ` ${message.message} [${message.type}/${message.rule.id}]`,
22 ].join(':')
23 )
24 })
25 })
26
27 formatter.on('end', (event) => {
28 const allHintCount = event.allHintCount
29 if (allHintCount > 0) {
30 console.log('')
31 const message = '%d problems'
32 console.log(
33 nocolor ? message : chalkInstance.red(message),
34 event.allHintCount
35 )
36 }
37 })
38}
39
40module.exports = unixFormatter

Callers

nothing calls this directly

Calls 1

onMethod · 0.80

Tested by

no test coverage detected