[英]How to remove eslint Parsing error on ES6 export statement
npm v3.10.10
node v6.11.0
eslint v4.2.0
npm v3.10.10
节点v6.11.0
eslint v4.2.0
You can pull the repo here . 你可以在这里拉回购 。 Just npm install
then npm run lint
只需npm install
然后npm run lint
I'm trying to use the following export statement (comment works, but is ugly): 我正在尝试使用以下导出语句(注释有效,但是很丑):
export MainContainer from './Main/MainContainer'
// export { default as MainContainer } from './Main/MainContainer'
import React from 'react'
import { Route, HashRouter, browserHistory } from 'react-router-dom'
import { MainContainer } from '../containers'
const routes = (
<HashRouter history={browserHistory}>
<Route path="/" component={MainContainer} />
</HashRouter>
)
export default routes
I installed the following package: 我安装了以下软件包:
npm install babel-eslint@next --save-dev
{
parser: "babel-eslint",
en: {
es6: true,
browser: true
},
extends: ["eslint:recommended", "plugin:react/recommended", "standard"],
plugins: [
"react"
]
}
{
"env": {
"browser": true,
"es6": true
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaFeatures": {
"experimentalObjectRestSpread": true,
"jsx": true
},
"sourceType": "module"
},
"plugins": [
"react"
],
"rules": {
"indent": [
"error",
2
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"single"
],
"semi": [
"off",
"always"
]
}
}
However even with that installed I still get the error about the MainContainer when I npm run lint
但是即使安装了该程序,当我npm run lint
时,我仍然会收到有关MainContainer的错误
"scripts": {
"start": "webpack-dev-server",
"production": "webpack -p",
"lint": "eslint app/.; exit 0",
"fix": "eslint --fix app/.; exit 0"
},
"devDependencies": {
"babel-core": "^6.25.0",
"babel-eslint": "^8.0.0-alpha.13",
"babel-loader": "^7.1.1",
"babel-plugin-transform-export-extensions": "^6.22.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
"css-loader": "^0.28.4",
"eslint": "^4.2.0",
"eslint-config-standard": "^10.2.1",
"eslint-plugin-promise": "^3.5.0",
"eslint-plugin-react": "^7.1.0",
"eslint-plugin-standard": "^3.0.1",
"html-webpack-plugin": "^2.29.0",
"style-loader": "^0.18.2",
"webpack": "^3.2.0",
"webpack-dev-server": "^2.5.1"
}
Figured it out! 弄清楚了! I needed to edit my .eslintrc.json file, not the .eslintrc 我需要编辑.eslintrc.json文件,而不是.eslintrc
https://github.com/babel/babel-eslint/issues/6 https://github.com/babel/babel-eslint/issues/6
{
...
"extends": [
"eslint:recommended",
"plugin:react/recommended"
],
...
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.