From 41bb09002ce58c4e7ad416dafcc932fd79dafa3a Mon Sep 17 00:00:00 2001 From: Ammar Najjar Date: Fri, 23 Dec 2022 05:51:00 +0100 Subject: [PATCH] fix actions exact matching regex --- src/generator.ts | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/generator.ts b/src/generator.ts index 27f30a9..1b11e31 100644 --- a/src/generator.ts +++ b/src/generator.ts @@ -155,8 +155,7 @@ export class Generator { actions = [ ...actions, ...this.allActions.filter((action: string) => - // eslint-disable-next-line no-useless-escape - mapNode.getText().match(new RegExp(`[^\w]${action}\\(`)), + mapNode.getText().match(new RegExp(`[^\\w]${action}\\(`)), ), ]; } @@ -190,12 +189,9 @@ export class Generator { actions = [ ...actions, ...this.allActions.filter((action: string) => { - return ( - callable - .getText() - // eslint-disable-next-line no-useless-escape - .match(new RegExp(`[^\w]${action}[^\w]`)) - ); + return callable + .getText() + .match(new RegExp(`[^\\w]${action}[^\\w]`)); }), ]; } @@ -249,7 +245,8 @@ export class Generator { ...new Set( this.allActions.filter( (action: string) => - nodes.filter(node => node.includes(action)).length, + nodes.filter(node => node.match(new RegExp(`[^\\w]${action}\\(`))) + .length, ), ), ];