Add support for arrow functions #952

Closed
valueof opened this Issue Mar 22, 2013 · 8 comments

Comments

Projects
None yet
5 participants
Owner

valueof commented Mar 22, 2013

ES6 implements arrow functions that look something like this:

function test() {
  return x () => { ... };
}

One major browser (Firefox) had already shipped support for this type of functions and, since they're officially in ES6, we also need to support them under the esnext flag.

What needs to be done

JSHint should correctly parse arrow functions (as per spec) keeping in mind the new scope, etc.

There's bounty on this bug

You can get paid to fix this bug! See our page on BountySource for more info.

Owner

rwaldron commented Mar 22, 2013

+1

guyzmo referenced this issue Mar 28, 2013

Merged

fixes #952 #971

Contributor

guyzmo commented Mar 29, 2013

done

Owner

valueof commented Apr 9, 2013

Landed!

valueof closed this Apr 9, 2013

Contributor

mgol commented Nov 20, 2013

@antonkovalyov I don't see it... Using the jsHint 2.3.0 the following code:

const g = x => x * x;

produces an error:

'x' is not defined

And yes, I have esnext turned on and it shows since jsHint doesn't complain about const here.

Owner

valueof commented Nov 20, 2013

This is a known bug with our arrow function support which I intend to fix very soon.

Contributor

mgol commented Nov 21, 2013

@antonkovalyov Got it. What works, then? i tried wrapping 'x' in params and it didn't help.

Btw, I believe your example from the initial post is incorrect, arrow functions cannot be named in this way.

EDIT: oh well, it seems arrow functions can be named. I wonder why I haven't seen any examples of that before.

Mithgol commented Dec 25, 2013

@mzgol Fixed in #1363, I presume.

Contributor

mgol commented Dec 25, 2013

@Mithgol Yes, it's fixed now. :) Thanks, @antonkovalyov!

@wiredearp wiredearp added a commit to Tradeshift/tradeshift-ui that referenced this issue Dec 6, 2016

@wiredearp wiredearp JSHint :)
Update package to survive jshint/jshint#952
5648f42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment