首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >每次导入时出现更漂亮的语法错误

每次导入时出现更漂亮的语法错误
EN

Stack Overflow用户
提问于 2021-03-21 12:09:03
回答 1查看 472关注 0票数 0

我有一个反应应用程序,用的是eslint 7+更漂亮的+ webpack (BUt,我认为webpack不是问题)

我有这样的错误:

代码语言:javascript
运行
复制
["ERROR" - 1:04:07 PM] Unexpected token (1:8)
> 1 | import { useState } from 'react';
    |        ^
  2 | 
  3 | import arrowIosDownwardFill from '@iconify-icons/eva/arrow-ios-downward-fill';
  4 | import arrowIosForwardFill from '@iconify-icons/eva/arrow-ios-forward-fill';
SyntaxError: Unexpected token (1:8)
> 1 | import React, { Suspense, Fragment, lazy, useEffect } from 'react';
|    
  4 | import arrowIosForwardFill from '@iconify-icons/eva/arrow-ios-forward-fill';

我对eslint插件或扩展有什么问题吗?

这是我的.eslint.json配置

代码语言:javascript
运行
复制
{
  "parser": "babel-eslint",
  "plugins": ["react"],
  "env": {
    "browser": true,
    "es6": true,
    "jest/globals": true
  },
  "extends": ["plugin:react/recommended", "plugin:prettier/recommended", "airbnb", "airbnb/hooks"],
  "parserOptions": {
    "project": ["jsconfig.json"],
    "ecmaVersion": 2020,
    "sourceType": "module",
    "ecmaFeatures": {
      "jsx": true
    }
  },
  "rules": {
    "no-console": "off",
    "implicit-arrow-linebreak": "off",
    "no-danger-with-children": "off",
    "comma-dangle": "off",
    "no-plusplus": "off",
    "import/no-unresolved": "off",
    "react/jsx-filename-extension": "off",
    "react/no-array-index-key": "off",
    "react/prop-types": "off",
    "react/jsx-uses-react": "off",
    "react/react-in-jsx-scope": "off",
    "react/jsx-props-no-spreading": "off",
    "react/require-default-props": "off",
    "react/forbid-prop-types": "off",
    "jsx-a11y/click-events-have-key-events": "off",
    "jsx-a11y/no-static-element-interactions": "off",
    "jsx-a11y/control-has-associated-label": "off",
    "jsx-a11y/anchor-is-valid": "off",
    "max-len": "off",
    "import/no-extraneous-dependencies": [
      "error",
      {
        "devDependencies": true
      }
    ],
    "jest/no-disabled-tests": "warn",
    "jest/no-focused-tests": "error",
    "jest/no-identical-title": "error",
    "jest/prefer-to-have-length": "warn",
    "jest/valid-expect": "error",
    "import/order": [
      "error",
      {
        "groups": ["builtin", "external", "internal", ["parent", "sibling"]],
        "pathGroups": [
          {
            "pattern": "react",
            "group": "external",
            "position": "before"
          }
        ],
        "pathGroupsExcludedImportTypes": ["react"],
        "newlines-between": "always",
        "alphabetize": {
          "order": "asc",
          "caseInsensitive": true
        }
      }
    ]
  },
  "settings": {
    "react": {
      "version": "detect"
    },
    "import/resolver": {
      "node": {
        "paths": ["src"],
        "extensions": [".js", ".jsx"]
      }
    }
  }
}

和package.json

代码语言:javascript
运行
复制
"eslint": "^7.22.0",
"eslint-config-airbnb": "^18.1.0",
"eslint-config-prettier": "^8.1.0",
"eslint-config-react-app": "^6.0.0",
"eslint-plugin-flowtype": "^5.4.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jest": "^24.3.1",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-react": "^7.22.0",
"eslint-plugin-react-hooks": "^4.2.0",
"eslint-plugin-testing-library": "^3.10.1",
"eslint-webpack-plugin": "^2.5.2",

"eslintConfig": {
    "extends": "react-app"
  }
EN

回答 1

Stack Overflow用户

发布于 2021-03-21 13:06:45

错误创建:.prettierc解析器选项应该是babel,我有流程。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66732112

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档