【发布时间】:2018-11-27 18:42:17
【问题描述】:
在玩弄一个简单的 react-native 设置时,我突然发现了一些(也许不是这样)奇怪的 ESLint 东西。
这是我的 Javascript 文件:
import React from 'react';
import { Text, View } from 'react-native';
const Header = () => {
const { textStyle } = styles;
return (
<View>
<Text style={textStyle}>App Header!</Text>
<View/>
);
};
const styles = {
textStyle: {
fontSize: 20
}
};
export default Header;
问题来自textStyle: { 行中的以下 ESLint 错误:
Parsing error: Unexpected token, expected "}" (Fatal)
我在Atom 中安装了最新的linter (v2.2.0) 和linter-eslint (v8.4.1) 软件包。
我正在使用npm 包rally-coding 中的一组预定义规则,我已将其作为开发依赖项安装在项目中,这是我的.eslintrc 文件:
{
"extends": "rallycoding",
"parser": "babel-eslint",
"ecmaFeatures": {
"jsx": true
}
}
任何想法可能来自哪里?到目前为止,(许多)Github 问题线程中建议的解决方法都没有帮助。
【问题讨论】:
-
<View/>应该是</View> -
@bennygenel 很好发现,谢谢。据称,这个 linter 让我相互转身,实际上阻止了我更早地发现真正的错误位置。我的意思是说真的……
-
@bennygenel 这应该是答案,如果你能把它变成一个答案,那么我可以接受它。
标签: react-native atom-editor eslint