22 * @author kazuya kawaguchi (a.k.a. kazupon)
33 */
44import { extname } from 'path'
5- import parse5 from 'parse5'
5+ import * as parse5 from 'parse5'
66import { defineCustomBlocksVisitor , getLocaleMessages } from '../utils/index'
77import debugBuilder from 'debug'
88import type { AST as JSONAST } from 'jsonc-eslint-parser'
99import type { AST as YAMLAST } from 'yaml-eslint-parser'
1010import type { RuleContext , RuleListener } from '../types'
1111import { createRule } from '../utils/rule'
12+ import type { DefaultTreeAdapterMap } from 'parse5'
1213
1314const debug = debugBuilder ( 'eslint-plugin-vue-i18n:no-html-messages' )
1415
15- function findHTMLNode (
16- node : parse5 . DocumentFragment
17- ) : parse5 . Element | undefined {
18- return node . childNodes . find ( ( child ) : child is parse5 . Element => {
19- if ( child . nodeName !== '#text' && ( child as parse5 . Element ) . tagName ) {
16+ type DocumentFragment = DefaultTreeAdapterMap [ 'documentFragment' ]
17+ type Element = DefaultTreeAdapterMap [ 'element' ]
18+ function findHTMLNode ( node : DocumentFragment ) : Element | undefined {
19+ return node . childNodes . find ( ( child ) : child is Element => {
20+ if ( child . nodeName !== '#text' && ( child as Element ) . tagName ) {
2021 return true
2122 }
2223 return false
@@ -36,7 +37,7 @@ function create(context: RuleContext): RuleListener {
3637 }
3738 const htmlNode = parse5 . parseFragment ( `${ node . value } ` , {
3839 sourceCodeLocationInfo : true
39- } ) as parse5 . DocumentFragment
40+ } )
4041 const foundNode = findHTMLNode ( htmlNode )
4142 if ( ! foundNode ) {
4243 return
@@ -64,7 +65,7 @@ function create(context: RuleContext): RuleListener {
6465 }
6566 const htmlNode = parse5 . parseFragment ( `${ node . value } ` , {
6667 sourceCodeLocationInfo : true
67- } ) as parse5 . DocumentFragment
68+ } )
6869 const foundNode = findHTMLNode ( htmlNode )
6970 if ( ! foundNode ) {
7071 return
0 commit comments