import type { Rule } from 'eslint' ; import type { Loc , Token } from 'pug-lexer' ; import { processRule } from '../utils' ; export default { meta : { type : 'problem' , docs : { description : 'require `v-bind:is` of `<component>` elements' , categories : [ 'vue3-essential' , 'essential' ] , url : 'https://eslint.vuejs.org/rules/require-component-is.html' } , fixable : undefined , schema : [ ] } , create ( context ) { return processRule ( context , ( ) => { return { tag ( token , { index , tokens } ) { if ( token . val !== 'component' ) { return ; } let foundIsBinding = false ; let subIndex = index + 1 ; for ( subIndex ; subIndex < tokens . length ; subIndex ++ ) { const element = tokens [ subIndex ] ! ; if ( element . type === 'attribute' && /^(v-bind)?:is$/ . test ( element . name ) ) { foundIsBinding = true ; break ; } if ( element ?. type === 'end-attributes' || element . type === 'tag' ) { break ; } } if ( ! foundIsBinding ) { const loc = token . loc ; const columnStart = loc . start . column - 1 ; const columnEnd = columnStart + 'component' . length ; context . report ( { node : { } as unknown as Rule . Node , loc : { line : loc . start . line , column : loc . start . column - 1 , start : { line : loc . start . line , column : columnStart } , end : { line : loc . end . line , column : columnEnd } } , message : "Expected 'component' elements to have 'v-bind:is' attribute." } ) ; } index = subIndex - 1 ; } } ; } ) ; } } as Rule . RuleModule ;