eslint: eslint 6.2.0 unexpected token = and /
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
- ESLint Version: 6.2.0
$ cat package.json | jq '.devDependencies.eslint'
"^6.2.0"
$ cat node_modules/eslint/package.json | jq '.version'
"6.2.0"
- Node Version: 12.8.1
$ node --version
v12.8.1
- npm Version: 6.10.3
$ npm --version
6.10.3
Please show your full configuration:
$ cat .eslintrc.js
module.exports = {
env: {
browser: true,
es6: true,
node: true,
jest: true,
},
extends: [
"eslint:recommended",
"plugin:react/recommended",
"plugin:jest/recommended",
"plugin:jsx-a11y/recommended"
],
parserOptions: {
ecmaFeatures: {
jsx: true
},
ecmaVersion: "2018",
sourceType: "module",
},
plugins: [
"react",
"jest",
"jsx-a11y"
],
rules: {
indent: [
"error",
2
],
"linebreak-style": [
"error",
"unix"
],
quotes: [
"error",
"double"
],
semi: [
"error",
"always"
],
"key-spacing": [
"error",
{align: "value"}
],
"no-console": "off",
"no-debugger": "warn",
"no-alert": "warn",
"object-curly-spacing": [
"error",
"never"
],
"array-bracket-spacing": [
"error",
"never"
]
},
overrides: [
{
files: ["*.test.js"],
rules: {
"react/no-find-dom-node": "off"
}
}
],
settings: {
react: {
version: "detect"
}
}
};
What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.
$ cat src/components/App/App.js
"use strict";
import React from "react";
class App extends React.Component {
render() {
return (
<div id="container">
<p>
hello internet!
</p>
</div>
);
}
}
export default App;
$ cat src/index.js
"use strict";
import React from "react";
import ReactDOM from "react-dom";
import App from "./components/App/App";
ReactDOM.render(
<App />,
document.getElementById("root")
);
$ npx eslint src/**/**.js
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.
$ npx eslint src/**/**.js
/Users/foo/react/src/components/App/App.js
8:14 error Parsing error: Unexpected token =
/Users/foo/react/src/index.js
8:8 error Parsing error: Unexpected token /
✖ 2 problems (2 errors, 0 warnings)
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 2
- Comments: 53 (39 by maintainers)
Commits related to this issue
- build: fix linting (refs eslint/eslint#12119) — committed to react-dates/react-dates by aladdin-add 5 years ago
- build: fix linting (refs eslint/eslint#12119) — committed to devs-cloud/react-date by aladdin-add 5 years ago
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
selftoken type objects to plugins, this problem will disappear.espree
depends onacorn@7
andacorn-jsx@5
- howeveracorn-jsx@5
has a peer dependency onacorn@6
. Yarn also prints a warning, but it doesn’t fail at runtime.warning "eslint > espree > acorn-jsx@5.0.1" has incorrect peer dependency "acorn@^6.0.0".
https://github.com/eslint/espree/blob/c0635bac4cd891cb612fb81655012e2579f4e2b1/package.json#L21-L22 https://github.com/RReverser/acorn-jsx/blob/6697d3407221a58e23d040b4059f20eb045247a5/package.json#L21-L26
Should just be a warning though, no? Might be worth PR-ing
acorn-jsx
allowing v7 ofacorn
. https://github.com/acornjs/acorn/blob/aedbc56b86c086fcbee3214a6516f59794c2a99c/acorn/CHANGELOG.md#700-2019-08-13I have opened an issue on acorn: https://github.com/acornjs/acorn/pull/870
I’m closing this issue because of duplicate. Please track on #11018 and https://github.com/acornjs/acorn/pull/870.
I really would like to see if we can figure out why we’re seeing this issue more than other projects.
@y0y0z I think it’s because
acorn-jsx
just published v5.0.2 😄 https://github.com/RReverser/acorn-jsx/releases/tag/5.0.2The CI job I linked to includes a git branch; you can all clone it yourself and look into whatever you like 😃
Still failed, same error.
@aladdin-add See this comment, I think Jordan was saying his CI is still not fixed.
@y0y0z npm is automatically bumped to latest in Travis-CI on react-dates using nvm install-latest-npm, so that has no impact.
@SimenB \ @aladdin-add \ @mysticatea: i’ve upgraded to version 6.2.1 and my issues are gone! 😃
@g-plane my issue is reproducible both locally and in CI (where node_modules is always fresh).
See https://travis-ci.org/airbnb/react-dates/jobs/572611629