Eslint:jsx上的“意外令牌/”

时间:2019-03-27 19:39:07

标签: reactjs eslint

我正在尝试将eslint配置为可与react配合使用:

这是我的.eslintrc文件:

module.exports = {
  env: {
    browser: true,
    es6: true,
    amd: true,
    node: true,
  },
  extends: ["eslint:recommended"],
  globals: {
    Atomics: "readonly",
    SharedArrayBuffer: "readonly",
  },
  parserOptions: {
    ecmaFeatures: {
      jsx: true,
    },
    ecmaVersion: 2018,
    sourceType: "module",
  },
  plugins: ["react"],
  rules: {
    "react/jsx-uses-vars": [2],
    indent: ["warn", 2],
    "linebreak-style": ["warn", "unix"],
    quotes: ["warn", "double"],
    semi: ["warn", "always"],
  },
};

这是我的index.js

import React from "react";
import ReactDOM from "react-dom";

import App from "./App.js";

ReactDOM.render(<App />, document.getElementById("root"));

事情不断抱怨<App />上的斜杠:

6:22  error  Parsing error: Unexpected token /

我不确定发生了什么。如何摆脱该错误?

0 个答案:

没有答案