2017-08-17 129 views
0

我有这样的功能:ESlint:分析错误:意外标记<

import React from 'react'; 
import FilterList from './Filter/FilterList'; 

export default function Sidebar() { 
    return (
    <div> 
     <FilterList /> 
    </div> 
); 
} 

而且包括这些软件包:

"dependencies": { 
"bootstrap": "^3.3.7", 
"font-awesome": "^4.7.0", 
"i18n-react": "^0.4.0", 
"react": "^15.6.1", 
"react-bootstrap": "^0.31.2", 
"react-dom": "^15.6.1", 
"react-fontawesome": "^1.6.1", 
"react-router-dom": "^4.1.2", 
"rxjs": "^5.4.3", 
"superagent": "^3.5.2", 
"webpack": "^3.5.4"}, 

"devDependencies": { 
"eslint": "^4.4.1", 
"eslint-config-airbnb-base": "^11.3.1", 
"eslint-plugin-import": "^2.7.0", 
"nwb": "0.18.x", 
"nwb-less": "^0.6.0", 
"yaml-loader": "^0.5.0"}, 

但运行皮棉,当我得到这个错误: 错误解析错误:意外令牌<

我.eslintrc文件:

module.exports = { 
"extends": "airbnb-base", 
"plugins": [ 
    "import" 
]}; 

我在做什么错?

+0

请添加您的预置,插件的更多信息,你可以分享你.babelrc?你在使用eslint-babel吗? – locropulenton

+0

Q用我的eslint文件更新。 – Kristoffer

+0

这似乎更像是从您的.babelrc或webpack配置中产生的错误,然后ESlint –

回答

1

由于eslint不知道如何处理JSX语法,因此您需要使用eslint-plugin-react

但是你也缺少airbnb-eslint-config工作所需的其他插件。难道他们在文档说这是:

npm info "[email protected]" peerDependencies

并安装打印依赖(如开发依赖)。

截至今天我得到这个名单:

{ eslint: '^3.19.0 || ^4.3.0', 
    'eslint-plugin-jsx-a11y': '^5.1.1', 
    'eslint-plugin-import': '^2.7.0', 
    'eslint-plugin-react': '^7.1.0' } 
+0

非常感谢。这是Tomasz @自由灵魂答案的组合。我需要安装缺少的对等依赖关系,并将插件添加到我的eslintrc.js文件中。 – Kristoffer

相关问题