import type { AST , Rule } from 'eslint' ; import type { Loc } from 'pug-lexer' ; import { processRule } from '../utils' ; export default { meta : { type : 'problem' , docs : { description : 'disallow using deprecated `$scopedSlots` (in Vue.js 3.0.0+)' , categories : [ 'vue3-essential' ] , url : 'https://eslint.vuejs.org/rules/no-deprecated-dollar-scopedslots-api.html' } , fixable : 'code' , schema : [ ] , messages : { deprecated : 'The `$scopedSlots` is deprecated.' } } , create ( context ) { return processRule ( context , ( ) => { return { attribute ( token ) { if ( typeof token . val === 'string' && token . val . includes ( '$scopedSlots' ) ) { if ( token . name === 'v-for' && ! /in\s\$scopedSlots/ . test ( token . val ) ) { return ; } const loc = token . loc ; const columnStart = loc . start . column - 1 + token . name . length + '=' . length + token . val . indexOf ( '$scopedSlots' ) ; const columnEnd = columnStart + '$scopedSlots' . 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 } } , messageId : 'deprecated' , fix ( fixer ) { const range = token . range ; const textSlice = context . getSourceCode ( ) . text . slice ( range [ 0 ] , range [ 1 ] ) ; const columnOffset = textSlice . indexOf ( '$scopedSlots' ) ; const removeFrom = range [ 0 ] + columnOffset ; const removeTo = removeFrom + '$scopedSlots' . length ; return fixer . replaceTextRange ( [ removeFrom , removeTo ] , '$slots' ) ; } } ) ; } } } ; } ) ; } } as Rule . RuleModule ;