-
Notifications
You must be signed in to change notification settings - Fork 77
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
Add ES6 Support #33
Comments
Are you still going to do this? ESLint has a bug related to |
Oh, OK. I'll work on it on weekend :) |
semantics in ES6 spec may be mature enough :) |
They are. I've documented it in my book: https://github.com/nzakas/understandinges6/blob/master/manuscript/01-The-Basics.md#block-bindings |
This would be awesome to have! |
Just checking in - any chance you're working on this? :) |
Hi @nzakas, I'm now gradually supporting ES6 in the tools, now escodegen supports ES6 Syntax completely. Since there's significant difference between ES5 scopes and ES6 scopes, maybe I'll introduce |
That sounds awesome! |
@Constellation what's the status on this? Is there anything we can do to help out? I'm working on trying to get an ES6-supported version of ESlint using the harmony branch of esprima, so my next step is to approach ES6 support in escope and estraverse. :) |
OK, so, let's start to support ES6. |
Support ES6 traversing in estraverse. estools/estraverse@19f7a5c |
This would really help for getting eslint running on jsx |
Any update on this? Definently keen to use this for 6to5. Reference babel/babel#175 |
Currently, we're investigating the ES6 spec and Esprima AST nodes. |
Main issues you'll run into is implementing temporal dead zones. Default parameters have their own scope and you can't access let/const variables before they're initialised. |
Nice, it's very useful information. var { a, b, c } = obj; // it materialize a, b, c variables. |
And we need to ensure, for (let i = 0; i < 10; ++i) { console.log(i); } scope behavior. |
We're now implementing scopes for ES6. But be careful, it's experimental and the behavior might be changed |
Do you know the actual section in the ES6 draft (rev28)? |
@Constellation For what specifically? |
@sebmck |
@Constellation Yeah I understand that. I was referring to what section specifically that you were looking for. |
@sebmck
I'm looking for it. Now seeing 9.2.13, http://people.mozilla.org/~jorendorff/es6-draft.html#sec-functiondeclarationinstantiation |
In this commit, we fix the let/const declaration behavior. var i = 20; // (1) { i; // (1) let i = 20; // (2) i; // (2) } ref #33
If you can update 2.0.1 with the fix, I can keep testing for other incompatibilities. |
OK, so I've published it as |
Thanks! |
I found one more issue. It looks like escope isn't marking increment/decrement as write operations. For example: /*global b:false*/
b++; The |
@nzakas |
I've fixed it and released it as |
Thanks! |
@Constellation Found a couple more issues. First, when using a label, references inside the label are not counted accurately: var foo = 5;
label: while (true) {
console.log(foo);
break label;
} In this example, the variable Second, block scope references don't appear to work in loops: for (let prop in box) {
box[prop] = parseInt(box[prop]);
} The variable |
Sorry, I should have said |
Okay, nailed down the problem for the For the time being, I can avoid checking the TDZ for variables, but it seems like the TDZ logic is not quite correct. |
Oh, thank you for your pointing. |
Fix: Labeled statement ref counting (refs #33)
Yes, with ecmaVersion: 6. |
Just for reference, eslint/eslint#2405 is blocked by this issue, more concretely by "Initializers in Destructuring Assignments". |
Supporting ES6 block scopes and some special scopes (such as arraw function and method)
The text was updated successfully, but these errors were encountered: