@@ -87,7 +87,7 @@ export const createMockPlugin = (ctx: MockPluginContext) => createUnplugin(() =>
8787 startOf ( node ) ,
8888 )
8989 }
90- const importName = node . arguments [ 0 ]
90+ const importName = node . arguments [ 0 ] !
9191 if ( ! isLiteral ( importName ) || typeof importName . value !== 'string' ) {
9292 return this . error (
9393 new Error (
@@ -106,18 +106,18 @@ export const createMockPlugin = (ctx: MockPluginContext) => createUnplugin(() =>
106106 s . overwrite (
107107 isExpressionStatement ( parent )
108108 ? startOf ( parent )
109- : startOf ( node . arguments [ 0 ] ) ,
109+ : startOf ( node . arguments [ 0 ] ! ) ,
110110 isExpressionStatement ( parent )
111111 ? endOf ( parent )
112- : endOf ( node . arguments [ 1 ] ) ,
112+ : endOf ( node . arguments [ 1 ] ! ) ,
113113 '' ,
114114 )
115115 mocksImport . push ( {
116116 name,
117117 import : importItem ,
118118 factory : code . slice (
119- startOf ( node . arguments [ 1 ] ) ,
120- endOf ( node . arguments [ 1 ] ) ,
119+ startOf ( node . arguments [ 1 ] ! ) ,
120+ endOf ( node . arguments [ 1 ] ! ) ,
121121 ) ,
122122 } )
123123 }
@@ -134,7 +134,7 @@ export const createMockPlugin = (ctx: MockPluginContext) => createUnplugin(() =>
134134 startOf ( node ) ,
135135 )
136136 }
137- const componentName = node . arguments [ 0 ]
137+ const componentName = node . arguments [ 0 ] !
138138 if ( ! isLiteral ( componentName ) || typeof componentName . value !== 'string' ) {
139139 return this . error (
140140 new Error (
@@ -152,17 +152,17 @@ export const createMockPlugin = (ctx: MockPluginContext) => createUnplugin(() =>
152152 s . overwrite (
153153 isExpressionStatement ( parent )
154154 ? startOf ( parent )
155- : startOf ( node . arguments [ 1 ] ) ,
155+ : startOf ( node . arguments [ 1 ] ! ) ,
156156 isExpressionStatement ( parent )
157157 ? endOf ( parent )
158- : endOf ( node . arguments [ 1 ] ) ,
158+ : endOf ( node . arguments [ 1 ] ! ) ,
159159 '' ,
160160 )
161161 mocksComponent . push ( {
162162 path : path ,
163163 factory : code . slice (
164- startOf ( node . arguments [ 1 ] ) ,
165- endOf ( node . arguments [ 1 ] ) ,
164+ startOf ( node . arguments [ 1 ] ! ) ,
165+ endOf ( node . arguments [ 1 ] ! ) ,
166166 ) ,
167167 } )
168168 }
@@ -263,7 +263,7 @@ export const createMockPlugin = (ctx: MockPluginContext) => createUnplugin(() =>
263263 const vitestPlugins = plugins . filter ( p => ( p . name === 'vite:mocks' || p . name . startsWith ( 'vitest:' ) ) && ( p . enforce || ( 'order' in p && p . order ) ) === 'post' )
264264 const lastNuxt = findLastIndex (
265265 plugins ,
266- i => i . name ?. startsWith ( 'nuxt:' ) ,
266+ i => ! ! i ? .name ?. startsWith ( 'nuxt:' ) ,
267267 )
268268 if ( lastNuxt === - 1 ) return
269269 for ( const plugin of vitestPlugins ) {
@@ -279,7 +279,7 @@ export const createMockPlugin = (ctx: MockPluginContext) => createUnplugin(() =>
279279} )
280280
281281// Polyfill Array.prototype.findLastIndex for legacy Node.js
282- function findLastIndex < T > ( arr : T [ ] , predicate : ( item : T ) => boolean ) {
282+ function findLastIndex < T > ( arr : T [ ] , predicate : ( item ? : T ) => boolean ) {
283283 for ( let i = arr . length - 1 ; i >= 0 ; i -- ) {
284284 if ( predicate ( arr [ i ] ) ) return i
285285 }
0 commit comments