我有一个反应应用程序,用的是eslint 7+更漂亮的+ webpack (BUt,我认为webpack不是问题)
我有这样的错误:
["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配置
{
"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
"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"
}
发布于 2021-03-21 05:06:45
错误创建:.prettierc解析器选项应该是babel,我有流程。
https://stackoverflow.com/questions/66732112
复制相似问题