From 860a08efd064dc3f6c22fb9a9a7dcc4527b4741e Mon Sep 17 00:00:00 2001 From: Andy Edwards Date: Wed, 17 Aug 2022 15:25:15 -0500 Subject: [PATCH] fix(ObjectExpression): include reference to input pattern in errors --- src/jscodeshift/compileMatcher/ObjectExpression.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/jscodeshift/compileMatcher/ObjectExpression.ts b/src/jscodeshift/compileMatcher/ObjectExpression.ts index caeeed3..d13afb5 100644 --- a/src/jscodeshift/compileMatcher/ObjectExpression.ts +++ b/src/jscodeshift/compileMatcher/ObjectExpression.ts @@ -17,6 +17,7 @@ import compileMatcher, { } from './index' import { getArrayCaptureAs } from './Capture' +import CompilePathError from '../util/CompilePathError' function getSimpleKey( property: @@ -93,8 +94,9 @@ export default function compileObjectExpressionMatcher( if (_captureRestVariable) { if (captureRestVariable) - throw new Error( - `two capture rest variables aren't allowed, found ${_captureRestVariable} and ${captureRestVariable}` + throw new CompilePathError( + `two capture rest variables aren't allowed, found ${_captureRestVariable} and ${captureRestVariable}`, + path.get('properties').get(i) ) captureRestVariable = _captureRestVariable