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
eslint 6.2.0 unexpected token = and / #12119
Comments
Hi @y0y0z , it seems that there is something wrong with your configuration file. The value of |
@g-plane i think that's a red herring; i'm getting the same in https://github.com/airbnb/react-dates when i try to upgrade to eslint 6, and i have it as a number. |
@g-plane: clear to me that the lint should not fail, as this is the case with the previous version (6.1.0). also, i am not sure that the link that you posted coincide with the configuration excert above. |
The demo is running ESLint 6.2.0. It's the same version as you're using. Also, the parser options of the demo above are same with yours. |
@g-plane: i did not see that the online linting respect my configuration. but if you are insisting it is, then we should not argue about it :) |
@g-plane it's possible that something in eslint's dep tree isn't deterministic, such that deduping might cause the wrong version of espree and/or acorn to be used. This was the case in eslint 5 as well; there's another closed issue about it. |
@ljharb So can we try removing the |
@g-plane my issue is reproducible both locally and in CI (where node_modules is always fresh). |
possible duplicate of #11018, could you try |
$ npm ls espree
react-app@1.0.0 /Users/foo/react
└─┬ eslint@6.2.0
└── espree@6.1.0
$ npm ls acorn
react-app@1.0.0 /Users/foo/react
├─┬ eslint@6.2.0
│ └─┬ espree@6.1.0
│ └── acorn@7.0.0
├─┬ jest@24.9.0
│ └─┬ jest-cli@24.9.0
│ └─┬ jest-config@24.9.0
│ └─┬ jest-environment-jsdom@24.9.0
│ └─┬ jsdom@11.12.0
│ ├── acorn@5.7.3
│ └─┬ acorn-globals@4.3.2
│ └── acorn@6.1.1
└─┬ webpack@4.39.2
└── acorn@6.3.0 |
We saw this when releasing espree over the weekend and trying to release ESLint yesterday. This is an npm issue. Npm does not deduplicate the dependency tree correctly in some cases, and as a result, an old version of Acorn (espree dependency) is pulled into espree. The only way we've found to for sure avoid this is to Another option that could maybe work in your case is to add acorn 7.0.0 as a dependency or devDependency in your project (updating ESLint's direct dependency on Acorn was what got us out the door yesterday). Again, the root cause is an npm@>=3 deduplication bug. |
@platinumazure: forcing npm to un-flatten dependencies: $ rm -rf node_modules && npm install --legacy-bundling also tried
by executing $ npm install acorn@latest --save-dev both did not work for me. |
Hmm... Then I'm not sure what's going on... We'll need to investigate further. |
FWIW, I've tried with Yarn, and it works well. |
The Travis log i linked included using the legacy bundles option, so that’s not it. If espree added acorn as both a peer and a regular dep, that might fix it, however. |
@ljharb Why would adding a peer dep help here? |
Oh, i assumed the issue was that it was already a peer dep. it’s a regular dep now? |
@ljharb espree declares acorn as a dependency, because it uses acorn to do the initial parse. (Basically, espree calls acorn, and then converts the output to ESTree.) ESLint declares acorn as a devDependency. The reason for this is because we use acorn to create a loose parser for some tests (i.e., to handle recoverable errors as recoverable, which espree currently does not support). Neither project declares acorn as a peer dependency. That seems correct to me, since espree does not expect an acorn instance to be passed in by consumers. But if you think that's incorrect, please let us know what you suggest we should do. |
I guess I’m unclear then on how this bug happens. If espree declares acorn as a regular dep, and then npm gives it the wrong version, it should make |
This bug is:
Anyway, I'm closing this issue because this is a duplicate of #11018. |
@mysticatea: thank you for the details explanation. could you please offer a bypass without pinning eslint to version 6.1.0? |
Please read #11018 :) The solution is different per environments because the reason that npm doesn't hoist acorn is different per environments. The most reliable solution is to use npm Inc. has noticed this problem and they have a plan to fix. I hope |
As i said above tho, npm 2 style install doesn’t fix the issue on react-dates. |
Oh, sorry. |
@ljharb: can you bump the version of your npm and check? i am using npm version 6.10.3. |
@SimenB: this is what i did in order to verify whether bumping eslint to version 6.2.1 solved my issue: $ rm -rf node_modules package-lock.json
$ npm install
$ npx eslint src/**/**.js
$ echo $?
0 |
@y0y0z npm is automatically bumped to latest in Travis-CI on react-dates using nvm install-latest-npm, so that has no impact. |
@y0y0z I think it's because |
Still broken: https://travis-ci.org/airbnb/react-dates/jobs/574535275 `npm ls acorn acorn-jsx`react-dates@20.3.0 /Users/ljharb/Dropbox/git/react-dates.git
├─┬ eslint@6.2.1
│ └─┬ espree@6.1.0
│ ├── acorn@7.0.0
│ └── acorn-jsx@5.0.2
├─┬ react-with-styles-interface-css-compiler@2.0.0
│ └─┬ jsdom@11.12.0
│ ├── acorn@5.7.3
│ └─┬ acorn-globals@4.3.3
│ └── acorn@6.3.0
└─┬ webpack@4.39.2
└── acorn@6.3.0 acorn v6.3 is at the top level of node_modules, as is acorn-jsx v5.0.2. |
@mysticatea: do you consider this issue as resolved? |
@ljharb I guess it's working now -- acorn-jsx published a new version with peerDependency: acorn v7. can you rerun it? |
@aladdin-add See this comment, I think Jordan was saying his CI is still not fixed. |
I’ll rerun the job and try it again. |
Still failed, same error. |
i am not experiencing the issue any more. this is my current environment and i hope it helps. $ node -v
v12.9.0
$ npm -v
6.11.1
$ rm -rf node_modules package-lock.json
$ npm install
...
$ npx eslint src/**/**.js
...
$ echo $?
0
$ npm ls espree acorn
react-app@1.0.0 /Users/foo/react
├── acorn@7.0.0
├─┬ eslint@6.2.1
│ └─┬ espree@6.1.0
│ └── acorn@7.0.0 deduped
├─┬ jest@24.9.0
│ └─┬ jest-cli@24.9.0
│ └─┬ jest-config@24.9.0
│ └─┬ jest-environment-jsdom@24.9.0
│ └─┬ jsdom@11.12.0
│ ├── acorn@5.7.3
│ └─┬ acorn-globals@4.3.3
│ └── acorn@6.3.0
└─┬ webpack@4.39.2
└── acorn@6.3.0 |
The CI job I linked to includes a git branch; you can all clone it yourself and look into whatever you like :-) |
@ljharb it's working well to use npm2-style installing🎉. see https://travis-ci.org/airbnb/react-dates/builds/575135825?utm_source=github_status&utm_medium=notification |
@aladdin-add wow, thanks. it was failing for me before, but i'll take the w. For the record, npm bug or not, I'm still convinced that this is something eslint's dep graph can fix on its own - otherwise this same bug would be occurring in babel and react, both ecosystems that make heavy use of peer deps. |
I really would like to see if we can figure out why we're seeing this issue more than other projects. |
One possible option is: bundling eslint/espree(using something like ncc), it also brings a faster bootup(https://zeit.co/blog/ncc#faster-bootup) |
Webpack and Rollup have the same problem. If this is not a bug of npm then this is the problem in Acorn. This problem appears when two Acorns are different entities: (1) Acorn that plugins loaded, (2) Acorn that is using the plugins. If Acorn did pass |
I have opened an issue on acorn: acornjs/acorn#870 I'm closing this issue because of duplicate. Please track on #11018 and acornjs/acorn#870. |
My environment
$ uname -a Darwin foo.baz 18.7.0 Darwin Kernel Version 18.7.0: Thu Jun 20 18:42:21 PDT 2019; root:xnu-4903.270.47~4/RELEASE_X86_64 x86_64
Please show your full configuration:
What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.
What did you expect to happen?
that all linting will pass.
when running eslint@6.1.0, it passes fine.
when running eslint@6.2.0 it fails as above.
What actually happened? Please include the actual, raw output from ESLint.
The text was updated successfully, but these errors were encountered: