@@ -439,3 +439,48 @@ it('unwraps non-null asserted options, alone and nested in other wrappers', () =
439439 `await rm(root, ({ ${ recursiveTrue } , maxRetries: 5 } as const)!);` ,
440440 ] ) ) ) . toEqual ( [ ] ) ;
441441} ) ;
442+
443+ it ( 'flags fs.promises.rm and wrapped callees or callee objects' , ( ) => {
444+ const flaggedLines = ( count : number ) => Array . from (
445+ { length : count } ,
446+ ( _ , index ) => expect . objectContaining ( { hasRetries : false , line : index + 4 } ) ,
447+ ) ;
448+
449+ expect ( recursiveRmCalls ( sample ( [
450+ "import fs from 'node:fs';" ,
451+ "import * as nodeFs from 'node:fs';" ,
452+ "import fsp from 'node:fs/promises';" ,
453+ `await fs.promises.rm(root, { ${ recursiveTrue } });` ,
454+ `await nodeFs.promises.rm(root, { ${ recursiveTrue } });` ,
455+ `await fs.promises!.rm(root, { ${ recursiveTrue } });` ,
456+ `await (fs.promises as typeof fsp).rm(root, { ${ recursiveTrue } });` ,
457+ `await fsp.rm(root, { ${ recursiveTrue } });` ,
458+ ] ) ) ) . toEqual ( flaggedLines ( 5 ) ) ;
459+
460+ expect ( recursiveRmCalls ( sample ( [
461+ "import { rm } from 'node:fs/promises';" ,
462+ "import * as fs from 'node:fs/promises';" ,
463+ '' ,
464+ `await (rm)(root, { ${ recursiveTrue } });` ,
465+ `await rm!(root, { ${ recursiveTrue } });` ,
466+ `await (rm as typeof rm)(root, { ${ recursiveTrue } });` ,
467+ `await (rm satisfies Remove)(root, { ${ recursiveTrue } });` ,
468+ `await (<Remove>rm)(root, { ${ recursiveTrue } });` ,
469+ `await ((rm)!)(root, { ${ recursiveTrue } });` ,
470+ `await fs!.rm(root, { ${ recursiveTrue } });` ,
471+ `await (fs as typeof fs).rm(root, { ${ recursiveTrue } });` ,
472+ `await (fs.rm)(root, { ${ recursiveTrue } });` ,
473+ `await fs?.rm(root, { ${ recursiveTrue } });` ,
474+ `await rm?.(root, { ${ recursiveTrue } });` ,
475+ ] ) ) ) . toEqual ( flaggedLines ( 11 ) ) ;
476+
477+ expect ( recursiveRmCalls ( sample ( [
478+ "import fs from 'node:fs';" ,
479+ "import { rm } from 'node:fs/promises';" ,
480+ `function cleanup(fs) { return fs.promises.rm(root, { ${ recursiveTrue } }); }` ,
481+ `{ const rm = mockRm; await (rm)!(root, { ${ recursiveTrue } }); }` ,
482+ `const reset = (fs) => (fs as Mock)!.rm(root, { ${ recursiveTrue } });` ,
483+ `await other.promises.rm(root, { ${ recursiveTrue } });` ,
484+ `await fs.other.rm(root, { ${ recursiveTrue } });` ,
485+ ] ) ) ) . toEqual ( [ ] ) ;
486+ } ) ;
0 commit comments