facebook / facebook/jscodeshift

Better error message when trying to replace CallExpressions instead of ExpressionStatement or VariableDeclarator

Open
#214 2 comments 1 reaction 0 assignees View on GitHub
improvement
Dominant language
JavaScript
Stars
10k
Forks
498
PR merge metrics
No merged PRs in 30d

Description

I hit a vague "Could not replace path" error today: http://astexplorer.net/#/gist/cfb2f93a39c4a80a1ecf44930092b59f/edca9a554a9aad19c62f098b07ee024a9c418241

After digging around for a while, I found #157, where @fkling wrote:

> You should not be looking for CallExpressions but for ExpressionStatements that contain a CallExpression that matches your constraints.

This was exactly my issue! Changing the script to instead look for the `ExpressionStatement` worked fine: http://astexplorer.net/#/gist/cfb2f93a39c4a80a1ecf44930092b59f/7b4a6f22da67d31cb18e768e0da975f26244ea1e

Can we make the "Could not replace path" error better?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.