Skip to content

Commit 530d2f0

Browse files
committed
perf: remove dependency on chalk
1 parent 89ffcd9 commit 530d2f0

File tree

5 files changed

+45
-76
lines changed

5 files changed

+45
-76
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
},
4242
"dependencies": {
4343
"@nuxt/kit": "^3.12.4",
44-
"chalk": "^5.3.0",
44+
"consola": "^3.2.3",
4545
"html-validate": "~8.27.0",
4646
"knitwork": "^1.1.0",
4747
"pathe": "^1.1.2",

pnpm-lock.yaml

Lines changed: 32 additions & 63 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { fileURLToPath, pathToFileURL } from 'node:url'
2-
import chalk from 'chalk'
2+
import { colors } from 'consola/utils'
33
import { normalize } from 'pathe'
44
import { isWindows } from 'std-env'
55
import { genArrayFromRaw, genObjectFromRawEntries } from 'knitwork'
@@ -27,7 +27,7 @@ export default defineNuxtModule<ModuleOptions>({
2727
return
2828
}
2929

30-
logger.info(`Using ${chalk.bold('html-validate')} to validate server-rendered HTML`)
30+
logger.info(`Using ${colors.bold('html-validate')} to validate server-rendered HTML`)
3131

3232
const { usePrettier, failOnError, options, logLevel } = moduleOptions as Required<ModuleOptions>
3333
// eslint-disable-next-line @typescript-eslint/no-explicit-any

src/runtime/validator.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import chalk from 'chalk'
1+
import { colors } from 'consola/utils'
22

33
import type { ConfigData } from 'html-validate'
44
import { HtmlValidate, formatterFactory } from 'html-validate'
@@ -34,7 +34,7 @@ export const useChecker = (
3434

3535
if (valid && !results.length) {
3636
if (logLevel === 'verbose') {
37-
console.log(`No HTML validation errors found for ${chalk.bold(url)}`)
37+
console.log(`No HTML validation errors found for ${colors.bold(url)}`)
3838
}
3939

4040
return { valid, results }
@@ -48,7 +48,7 @@ export const useChecker = (
4848

4949
const formattedResult = formatter?.(results)
5050
const message = [
51-
`HTML validation errors found for ${chalk.bold(url)}`,
51+
`HTML validation errors found for ${colors.bold(url)}`,
5252
formattedResult,
5353
].filter(Boolean).join('\n')
5454

test/checker.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import chalk from 'chalk'
1+
import { colors } from 'consola/utils'
22
import { describe, it, expect, vi, afterEach } from 'vitest'
33

44
import { useChecker } from '../src/runtime/validator'
@@ -29,7 +29,7 @@ describe('useChecker', () => {
2929

3030
await checker('https://test.com/', Symbol as any)
3131
expect(console.log).toHaveBeenCalledWith(
32-
`No HTML validation errors found for ${chalk.bold('https://test.com/')}`,
32+
`No HTML validation errors found for ${colors.bold('https://test.com/')}`,
3333
)
3434
expect(console.warn).not.toHaveBeenCalled()
3535
expect(console.error).not.toHaveBeenCalled()
@@ -41,7 +41,7 @@ describe('useChecker', () => {
4141

4242
await checker('https://test.com/', Symbol as any)
4343
expect(console.log).toHaveBeenCalledWith(
44-
`No HTML validation errors found for ${chalk.bold('https://test.com/')}`,
44+
`No HTML validation errors found for ${colors.bold('https://test.com/')}`,
4545
)
4646
expect(console.warn).not.toHaveBeenCalled()
4747
expect(console.error).not.toHaveBeenCalled()
@@ -91,7 +91,7 @@ describe('useChecker', () => {
9191
expect(console.log).not.toHaveBeenCalled()
9292
expect(console.warn).not.toHaveBeenCalled()
9393
expect(console.error).toHaveBeenCalledWith(
94-
`HTML validation errors found for ${chalk.bold('https://test.com/')}`,
94+
`HTML validation errors found for ${colors.bold('https://test.com/')}`,
9595
)
9696
})
9797
}
@@ -116,7 +116,7 @@ describe('useChecker', () => {
116116
'<a>Link</a>',
117117
)
118118
expect(console.log).toHaveBeenCalledWith(
119-
`No HTML validation errors found for ${chalk.bold('https://test.com/')}`,
119+
`No HTML validation errors found for ${colors.bold('https://test.com/')}`,
120120
)
121121
expect(console.warn).not.toHaveBeenCalled()
122122
expect(console.error).not.toHaveBeenCalled()
@@ -134,7 +134,7 @@ describe('useChecker', () => {
134134
'<a style="color:red" class="xxx">Link</a>',
135135
)
136136
expect(console.log).toHaveBeenCalledWith(
137-
`No HTML validation errors found for ${chalk.bold('https://test.com/')}`,
137+
`No HTML validation errors found for ${colors.bold('https://test.com/')}`,
138138
)
139139
expect(console.warn).not.toHaveBeenCalled()
140140
expect(console.error).not.toHaveBeenCalled()
@@ -162,7 +162,7 @@ describe('useChecker', () => {
162162
expect(console.log).not.toHaveBeenCalled()
163163
expect(console.warn).not.toHaveBeenCalled()
164164
expect(console.error).toHaveBeenCalledWith(
165-
`HTML validation errors found for ${chalk.bold('https://test.com/')}`,
165+
`HTML validation errors found for ${colors.bold('https://test.com/')}`,
166166
)
167167

168168
const validate = await import('html-validate')

0 commit comments

Comments
 (0)