The Wayback Machine - http://web.archive.org/web/20200908001456/https://github.com/wix/vscode-glean/issues/48/
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

offers two code actions even in JSON file #48

Open
capaj opened this issue Dec 21, 2018 · 4 comments
Open

offers two code actions even in JSON file #48

capaj opened this issue Dec 21, 2018 · 4 comments

Comments

@capaj
Copy link

@capaj capaj commented Dec 21, 2018

These two code actions should not be offered outside js/jsx/tsx:
image

@borislit
Copy link
Collaborator

@borislit borislit commented Dec 22, 2018

Hmmm. interesting. Should be an easy fix. Care for a PR? I can point you in the right direction :)

@capaj
Copy link
Author

@capaj capaj commented Dec 23, 2018

for the JSON fix shoud be easy, but currently it suggests these two actions everywhere. Ideally it would only suggested them if a JSX code block is selected.

@borislit
Copy link
Collaborator

@borislit borislit commented Dec 24, 2018

@capaj As far as i can remember, it relies on babel to check if its a JSX string.
This is the place to start investigating: https://github.com/wix/vscode-glean/blob/master/src/extension.ts#L18

@capaj
Copy link
Author

@capaj capaj commented Dec 24, 2018

I think this will always succeed:

ast = templateToAst(`<>${code}</>`);

JSX doesn't really impose any restrictions as to what can be inserted inside {}. Any JS expression is valid so I think this would be better refactored into just checking if there is a JSX node inside the selection. Will try to whip up some alternative solution for isJSX over the next few days/weeks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.