@@ -4,7 +4,7 @@ import { normalize } from 'pathe'
4
4
import { isWindows } from 'std-env'
5
5
import { genArrayFromRaw , genObjectFromRawEntries } from 'knitwork'
6
6
7
- import { createResolver , defineNuxtModule , isNuxt2 , logger , resolvePath } from '@nuxt/kit'
7
+ import { createResolver , defineNuxtModule , logger , resolvePath } from '@nuxt/kit'
8
8
import { DEFAULTS , NuxtRedirectHtmlRegex } from './config'
9
9
import type { ModuleOptions } from './config'
10
10
@@ -15,7 +15,7 @@ export default defineNuxtModule<ModuleOptions>({
15
15
name : '@nuxtjs/html-validator' ,
16
16
configKey : 'htmlValidator' ,
17
17
compatibility : {
18
- nuxt : '^2.0.0 || >=3.0.0-rc.7' ,
18
+ nuxt : '>=3.0.0-rc.7' ,
19
19
} ,
20
20
} ,
21
21
defaults : nuxt => ( {
@@ -30,10 +30,9 @@ export default defineNuxtModule<ModuleOptions>({
30
30
logger . info ( `Using ${ colors . bold ( 'html-validate' ) } to validate server-rendered HTML` )
31
31
32
32
const { usePrettier, failOnError, options, logLevel } = moduleOptions as Required < ModuleOptions >
33
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
34
- if ( ( nuxt . options as any ) . htmlValidator ?. options ?. extends ) {
35
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
36
- options . extends = ( nuxt . options as any ) . htmlValidator . options . extends
33
+
34
+ if ( nuxt . options . htmlValidator ?. options ?. extends ) {
35
+ options . extends = nuxt . options . htmlValidator . options . extends
37
36
}
38
37
39
38
const { resolve } = createResolver ( import . meta. url )
@@ -63,7 +62,7 @@ export default defineNuxtModule<ModuleOptions>({
63
62
} )
64
63
}
65
64
66
- if ( ! nuxt . options . dev || isNuxt2 ( ) ) {
65
+ if ( ! nuxt . options . dev ) {
67
66
const validatorPath = await resolvePath ( fileURLToPath ( new URL ( './runtime/validator' , import . meta. url ) ) )
68
67
const { useChecker, getValidator } = await import ( isWindows ? pathToFileURL ( validatorPath ) . href : validatorPath )
69
68
const validator = getValidator ( options )
@@ -75,13 +74,10 @@ export default defineNuxtModule<ModuleOptions>({
75
74
throw new Error ( 'html-validator found errors' )
76
75
}
77
76
}
78
-
79
- // @ts -expect-error TODO: use @nuxt/bridge-schema
80
- nuxt . hook ( 'generate:done' , errorIfNeeded )
81
77
nuxt . hook ( 'close' , errorIfNeeded )
82
78
}
83
79
84
- // Nuxt 3/Nuxt Bridge prerendering
80
+ // Prerendering
85
81
86
82
nuxt . hook ( 'nitro:init' , ( nitro ) => {
87
83
nitro . hooks . hook ( 'prerender:generate' , ( route ) => {
@@ -94,15 +90,6 @@ export default defineNuxtModule<ModuleOptions>({
94
90
checkHTML ( route . route , route . contents )
95
91
} )
96
92
} )
97
-
98
- // Nuxt 2
99
-
100
- if ( isNuxt2 ( ) ) {
101
- // @ts -expect-error TODO: use @nuxt/bridge-schema
102
- nuxt . hook ( 'render:route' , ( url : string , result : { html : string } ) => checkHTML ( url , result . html ) )
103
- // @ts -expect-error TODO: use @nuxt/bridge-schema
104
- nuxt . hook ( 'generate:page' , ( { path, html } : { path : string , html : string } ) => checkHTML ( path , html ) )
105
- }
106
93
}
107
94
} ,
108
95
} )
0 commit comments