question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

eslint 6.2.0 unexpected token = and /

See original GitHub issue

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)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:53 (39 by maintainers)

github_iconTop GitHub Comments

3reactions
mysticateacommented, Aug 22, 2019

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 self token type objects to plugins, this problem will disappear.

3reactions
SimenBcommented, Aug 20, 2019

espree depends on acorn@7 and acorn-jsx@5 - however acorn-jsx@5 has a peer dependency on acorn@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 of acorn. https://github.com/acornjs/acorn/blob/aedbc56b86c086fcbee3214a6516f59794c2a99c/acorn/CHANGELOG.md#700-2019-08-13

Read more comments on GitHub >

github_iconTop Results From Across the Web

ESLINT: Parsing error: Unexpected token in package.json
ESLint is for validating JavaScript, not JSON. From the website: ESLint. The pluggable linting utility for JavaScript and JSX.
Read more >
eslint/eslint - Gitter
... eslint-config-airbnb-base@latest Unexpected token { in JSON at position 139 SyntaxError: ... I'm running eslint version 6.2.0, npm 6.10.3, node 10.16.0; ...
Read more >
ESLint: "Parsing error: Unexpected token" in Visual Studio Code
Unexpected token errors are caused by incompatibilities in your parser options and the code you're writing. In this case, I'm using a number...
Read more >
React Scripts Syntax Error on Build - Netlify Support Forums
5:58:38 PM: > @fortawesome/fontawesome-common-types@6.2.0 ... 5:58:46 PM: ^ 5:58:46 PM: SyntaxError: Unexpected token ; 5:58:46 PM: at ...
Read more >
SyntaxError: Unexpected token '<' when dockerizing react app
云原生 SyntaxError: Unexpected token '<' when dockerizing react app ... "build": "cross-env NODE_ENV=production webpack", "lint": "eslint .
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found