Closed kaicataldo closed 8 years ago
Thanks for the kind words!
since it's part of the JSX spec
On one hand, yes, on another JSX spec just doesn't have versioning that ECMAScript does, so ecmaVersion
is used in both contexts. The thing is that ...
operator is only allowed for ES6+ on tokenizer level since that's the version where it first appeared and was allowed.
In order to change this, it would indeed require various modifications of Acorn itself (to present new ecmaVersion
checks in various places of parser instead of single check in tokenizer).
As for Babel approach mentioned in the original issue, it simply removed ecmaVersion
option when forked Acorn to Babylon, and instead always parses the latest ECMAScript version, and thus works even with only React preset. This is exactly the same as setting ecmaVersion
to 7 in Acorn.
Let me know if this makes sense to you.
Yes, it does - appreciate the explanation! Thanks for your help.
@RReverser I know it's a little over simplified, but could something like my test mentioned here: https://github.com/eslint/eslint/issues/6852#issuecomment-242461386 not work?
I know it'd need adjustments to acorn itself, but providing context for being inside JSX tags should allow thee use of the spread operator conditionally.
If there's more complexities, could you explain them?
@JakeSidSmith Acorn should stay unopinionated about its plugins. Having something like typeof this.options.plugins.jsx !== 'undefined' && this.insideJSXTag
is not acceptable in the core.
Given my explanation above, can you please tell why setting ecmaVersion
to 6 doesn't work for you? (given that it's the same what Babel, which you mentioned in the original issue, does when parsing the code).
@RReverser We've recently started using React on an older project, that's written in ES5. We don't intend to begin using ES6 any time soon.
If we must run eslint with ES6 then any bits of code that are considered okay in ES6 but not five, may slip under the radar, and are not compiled by babel (as we are only using the React preset). Babel just ignores these presumably, because it assumes you intended to use uncompiled ES6 code.
This has caused us to have bits of code get into master, that do not run in some of the browsers we support (as the ES6 spec is not completely implemented everywhere yet).
First, wanted to say thanks for working on this. I know the ESLint community really appreciates us supporting JSX out of the box!
We've run into the following issue on ESLint.
Running the following:
yields the following:
From what I've read it looks like JSX Spread Attributes should be allowed in ES5, since it's part of the JSX spec. Does that sound right to you? If so, any idea if the fix would be in this plugin or in Acorn itself?