Ace: [JavaScript Linting] Support ESNext (async/await, class properties, etc)

Created on 6 Dec 2016  ·  11Comments  ·  Source: ajaxorg/ace

I'm suggesting to change the javascript hinting to use ESLint for better support of ES6+ features.

I'd like to be able to use class properties and async/await the most, but there are also tons of other linting rules that it does much better than jshint.

class Foo {
    bar = 'baz';
}
async function foo () {
    const bar = await baz();
}

I haven't looked into how difficult this might be to swap out the javascript linter, so I don't know how realistic of a request this is.

linters

Most helpful comment

Pleaaaase work on this issue.

All 11 comments

This is a good idea and also needed for #3180.
We could base it off of the web demo files for ESLint.

Pleaaaase work on this issue.

New JSHint version 2.10.0 has been released with support for the new features.

As temp workaround - I've used ACE typescript, it already have await/async.

Typescript doesn't show an error.. but then it misses a lot of other errors.

its not just async/await its all es6 syntax including new math operators like 8**2

As of today, this issue is 3 years old. React has been out awhile now so surely the demand is increasing for this. The project is still pretty active, but there is no indication of this being on any official roadmap and just seems like it's a, "yea that's what we need to do, and we're probably gonna do it."

Can we _please_ get some sort of update here? @nightwing ? @adamjimenez ?

I found this while trying to find the linter for CSS files, and jury rig something of my own, _/mode/javascript_worker.js_ 🔗

This config seems to suggest that it is already set up for ESNext support , at least when working in Javascript worker mode for the javascript worker. Personally this didn't shed any light, but maybe this can help out one of y'all

I tried re-building ace after replacing the jshint.js file with the latest. This prevents an error being shown for async/await. However it also stops errors being shown for other scenarios (missing brackets, unclosed strings, etc). Very frustrating, I suppose the ace project is dead.

I've been fiddling with this too and I was able to make it work. Documentation could be updated, it was rather painful to dig out how the whole ecosystem works (took several hours) and then learned that all change was needed is one line... :/

There are a couple of options:
1) if you just imported the packaged/minified version - need to replace: "esnext:!0" with "esversion:9"
https://raw.githubusercontent.com/ajaxorg/ace-builds/master/src-min/worker-javascript.js
2) you can check out the repo and build yourself. (It takes about 1 minute, so this also rather easy)

git clone [email protected]:ajaxorg/ace.git
npm install
nano +82 lib/ace/mode/javascript_worker.js // replace "esnext: true," with "esversion: 9"
node Makefile.dryice.js full --target ../ace-builds

UPDATE: Since my last comment found another way:

var editor = ace.edit("editor");
editor.session.on('changeMode', function(e, session){
    if ("ace/mode/javascript" === session.getMode().$id) {
        if (!!session.$worker) {
            session.$worker.send("setOptions", [{
                "esversion": 9,
                "esnext": false,
            }]);
        }
    }
});
editor.session.setMode("ace/mode/javascript");

Awesome!! Any indication if you could specify other versions, like 6 for ES6 and so on?

I'll also add, in case others are new to git or haven't set up their SSH with Github, you can also clone it with: git clone https://github.com/ajaxorg/ace.git/. _Stumbled on that one more times than I'd like to admit_

Was this page helpful?
0 / 5 - 0 ratings