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

Javascript mode cannot parse JSX #3180

Closed
SystemParadox opened this issue Jan 5, 2017 · 16 comments
Closed

Javascript mode cannot parse JSX #3180

SystemParadox opened this issue Jan 5, 2017 · 16 comments

Comments

@SystemParadox
Copy link

According to #2606, JSX support was added to the Javascript mode back in 2015. However, it does not appear to work, even in the specific version specified when the support was added:

https://rawgit.com/ajaxorg/ace/ec5a1227c43fccfb34a6a9c842d9c4b288d1bf12/kitchen-sink.html

Try entering:

var x = <div></div>;

This results in:

Expected an identifier and instead saw '<'.
Missing ";" before statement
Unclosed regular expression.
Unrecoverable syntax error. (100% scanned).

I tried various other uses of JSX but it fails on all of them.

Thanks.

@mofux
Copy link

mofux commented Jan 9, 2017

The jshint implementation is outdated and needs to be updated. I am seeing many "Too many errors (x% scanned)" warnings, mostly when using many arrow functions

@SystemParadox
Copy link
Author

This error is from jshint? I would strongly recommend replacing that with eslint and babel-eslint.

Are there any customisation hooks for the linter/parser?

@rocketinventor
Copy link

@nightwing How much work is it to update/ rebuild jshint?

@rocketinventor
Copy link

rocketinventor commented Jan 10, 2017

@SystemParadox did you check the settings? Are you sure that you have JSX mode enabled?

@SystemParadox
Copy link
Author

I have Javascript mode enabled. According to #2606, the "JSX" mode is for an obsolete and totally unrelated language. Looking at the patch, it appears that support for React JSX was added to the Javascript mode.

However, that support is only for syntax highlighting, which does appear to be working. The error is coming from jshint. Thanks to mofux for pointing this out.

For now I have disabled the jshint worker with setOption('useWorker', false).

@rocketinventor
Copy link

@SystemParadox If so, you should probably create an issue here and make sure to reference this issue.

@rocketinventor
Copy link

@SystemParadox Try looking in 'Javascript Support' for JSX in C9.

@nightwing
Copy link
Member

This is indeed caused by an old version of jshint used in ace.
The plan for the future versions is to remove jshint from ace, and allow everyone to use a version of linter they prefer.
@rocketinventor c9 documentation may not be very useful here, since i think the issue is about using ace as a standalone library, and not about cloud9 ide.

@SystemParadox
Copy link
Author

Thanks for the clarification. Feel free to close if this is covered by other issues.

@rocketinventor
Copy link

Many of the popular code editors for Sublime Text are actually written in Node.js; this might be something to look into.

@mofux
Copy link

mofux commented Jun 30, 2017

@nightwing Can I bring my own linter yet? 🤓

And if so, is there some documentation I can refer to?

@BrunoQuaresma
Copy link

Any updates?

@NGambini
Copy link

Any update ? I am looking to use ace editor to write react code.

@SystemParadox
Copy link
Author

I'd recommend vscode instead

@andrewnester
Copy link
Contributor

For now our long-term thinking is to eventually replace such type of linting with LSP support on Ace side and LSP compatible workers / servers #3124

@andrewnester
Copy link
Contributor

JSHint has been recently updated #4911 and now Ace supports JSX syntax as well

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

No branches or pull requests

7 participants