0
我在React.js后出现意外令牌问题,我开始使用ESlint。安装ESlint后React中的意外令牌
这里是我的.eslintrc
文件:
{
parser: "babel-eslint",
"ecmaFeatures": {
"jsx": true,
"modules": true
},
"rules": {
"max-len": [1, 120, 2, {ignoreComments: true}],
"linebreak-style": 0,
"semi": [2, "never"],
"jsx-quotes": [2, "prefer-single"],
"react/jsx-curly-spacing": [2, "always"],
"react/prefer-stateless-function": [0]
},
"globals": {
"document": true,
"localStorage": true
},
"extends": ["airbnb-base"]
}
在index.js我有这样的定义:
ReactDOM.render(<App />, document.getElementById('main'));
Syntax error (unexpected token)
为<App />
。如果我添加引号来表示这个'<App />'
,它就可以工作。为什么? 我dont't想使用组件的调用报价。 这个问题随处可见,使用JSX语法。这里也是:
const App =() => (
<Router>
<div>
<Route exact path="/" component={Landing} />
<Route path="/home" component={Home} />
<Route path="/about" component={About} />
</div>
</Router>
);
也许我必须添加一些规则.eslintrc
。你能帮助我吗?
谢谢。
您可能需要添加ESLint插件,例如,这一个:https://www.npmjs.com/package/eslint-plugin-react –
您好马特,我已经安装了这个插件,但它不工作。 –
当你写“ ”它呈现的组成部分? –
gabrielwr