Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions playground/pages/ignored.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<template>
<a>
<a>This invalid markup should not be validated.</a>
</a>
</template>
5 changes: 4 additions & 1 deletion src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default defineNuxtModule<ModuleOptions>({

if (!nuxt.options.dev) {
const validatorPath = await resolvePath(fileURLToPath(new URL('./runtime/validator', import.meta.url)))
const { useChecker, getValidator } = await import(isWindows ? pathToFileURL(validatorPath).href : validatorPath)
const { useChecker, getValidator, isIgnored } = await import(isWindows ? pathToFileURL(validatorPath).href : validatorPath)
const validator = getValidator(options)
const { checkHTML, invalidPages } = useChecker(validator, usePrettier, logLevel)

Expand All @@ -88,6 +88,9 @@ export default defineNuxtModule<ModuleOptions>({
if (route.contents.match(NuxtRedirectHtmlRegex)) {
return
}
if (isIgnored(route.route, moduleOptions.ignore)) {
return
}
checkHTML(route.route, route.contents)
})
})
Expand Down
9 changes: 8 additions & 1 deletion test/module-prerender.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ await setup({
hooks: {
'modules:before'() {
const nuxt = useNuxt()
nuxt.options.nitro.prerender = { routes: ['/', '/redirect'] }
nuxt.options.htmlValidator = { ignore: ['/ignored'] }
nuxt.options.nitro.prerender = { routes: ['/', '/ignored', '/redirect'] }
},
},
},
Expand Down Expand Up @@ -57,4 +58,10 @@ describe('Nuxt prerender', () => {
expect.stringContaining('<html> element must have <body> as content'),
)
})

it('ignores configured pages', () => {
expect(console.error).not.toHaveBeenCalledWith(
expect.stringContaining('/ignored'),
)
})
})
Loading