Javascript ESLint具有分析错误和意外标记/
我有如下代码:Javascript ESLint具有分析错误和意外标记/,javascript,reactjs,eslint,Javascript,Reactjs,Eslint,我有如下代码: import 'app/css/normalize.css' import 'app/css/app.css' import React from 'react' import ReactDOM from 'react-dom' const App = () => { return ( <div> <h1>Finances</h1> <a href="/test.txt" target="_b
import 'app/css/normalize.css'
import 'app/css/app.css'
import React from 'react'
import ReactDOM from 'react-dom'
const App = () => {
return (
<div>
<h1>Finances</h1>
<a href="/test.txt" target="_blank">Test</a>
</div>
)
}
ReactDOM.render(
<App />,
document.getElementById('app')
)
ESLint输出
> finances-web@1.0.0 lint /home/jiewmeng/Dropbox/finances2019/web
> eslint scripts/**/*.js
/home/jiewmeng/Dropbox/finances2019/web/scripts/app.js
10:20 error Parsing error: Unexpected token /
✖ 1 problem (1 error, 0 warnings)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! finances-web@1.0.0 lint: `eslint scripts/**/*.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the finances-web@1.0.0 lint script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/jiewmeng/.npm/_logs/2018-12-23T04_08_42_410Z-debug.log
这可能与我的反应版本有关吗
{
"name": "finances-web",
"version": "1.0.0",
"description": "",
"main": "index.html",
"scripts": {
"lint": "eslint scripts/**/*.js",
"build": "webpack --config webpack.config.js",
"dev": "webpack-dev-server --hot --color --history-api-fallback --config webpack.config.js"
},
"author": "Jiew Meng <jiewmeng@gmail.com>",
"license": "MIT",
"devDependencies": {
"@babel/core": "^7.2.2",
"@babel/preset-env": "^7.2.0",
"@babel/preset-react": "^7.0.0",
"babel-loader": "^8.0.4",
"copy-webpack-plugin": "^4.6.0",
"css-loader": "^2.0.1",
"eslint": "^5.10.0",
"eslint-plugin-react": "^7.11.1",
"html-webpack-plugin": "^3.2.0",
"mini-css-extract-plugin": "^0.5.0",
"postcss-loader": "^3.0.0",
"postcss-preset-env": "^6.5.0",
"react-hot-loader": "^4.6.1",
"style-loader": "^0.23.1",
"webpack": "^4.27.1",
"webpack-cli": "^3.1.2",
"webpack-dev-server": "^3.1.10"
},
"dependencies": {
"@babel/polyfill": "^7.0.0",
"lodash": "^4.17.11",
"react": "^16.6.3",
"react-dom": "^16.6.3"
}
}
{
“名称”:“财务网”,
“版本”:“1.0.0”,
“说明”:“,
“main”:“index.html”,
“脚本”:{
“lint”:“eslint scripts/***.js”,
“构建”:“webpack--config webpack.config.js”,
“dev”:“webpack dev server--hot--color--history api fallback--config webpack.config.js”
},
“作者”:“解梦”,
“许可证”:“麻省理工学院”,
“依赖性”:{
“@babel/core”:“^7.2.2”,
“@babel/preset env”:“^7.2.0”,
“@babel/preset react”:“^7.0.0”,
“巴别塔加载器”:“^8.0.4”,
“复制网页包插件”:“^4.6.0”,
“css加载器”:“^2.0.1”,
“eslint”:“^5.10.0”,
“eslint插件反应”:“^7.11.1”,
“html网页包插件”:“^3.2.0”,
“迷你css提取插件”:“^0.5.0”,
“邮政编码加载器”:“^3.0.0”,
“邮政编码预设环境”:“^6.5.0”,
“反应热加载程序”:“^4.6.1”,
“样式加载器”:“^0.23.1”,
“网页包”:“^4.27.1”,
“webpack cli”:“^3.1.2”,
网页包开发服务器“^3.1.10”
},
“依赖项”:{
“@babel/polyfill”:“^7.0.0”,
“lodash”:“^4.17.11”,
“反应”:“^16.6.3”,
“反应dom”:“^16.6.3”
}
}
好的。。。意识到我的错误。在eslintrc中,我需要添加
"parser": "babel-eslint",
您是否也可以发布实际的ESLint输出?react是否导入到该文件中?我刚刚用您相同的规则和代码创建了一个基本应用程序,没有收到任何错误。我怀疑您收到的错误具有误导性,并且与另一行代码有关。@AnonymousSB用该文件的完整源代码更新了我的OP。Webpack能够编译和运行文件,很高兴听到你解决了它!我怀疑这可能就是问题所在
"parser": "babel-eslint",