Visual Studio中的EsLint-无法在javascript文件上使用静态道具
节点模块:Visual Studio中的EsLint-无法在javascript文件上使用静态道具,javascript,ecmascript-6,babeljs,eslint,ecmascript-next,Javascript,Ecmascript 6,Babeljs,Eslint,Ecmascript Next,节点模块: EsLint 1.10.3 Babel EsLint 4.1.6 Eslint插件react 3.15.0 正在删除的示例文件: class NotepadComponent extends React.Component { static displayName = 'NotepadComponent' static defaultProps = { activeTab: 'type' } } 在命令行下,我可以使用babel进行li
- EsLint 1.10.3
- Babel EsLint 4.1.6
- Eslint插件react 3.15.0
class NotepadComponent extends React.Component {
static displayName = 'NotepadComponent'
static defaultProps = {
activeTab: 'type'
}
}
在命令行下,我可以使用babel进行lint和transpile,没有任何问题。问题是试图从VisualStudio中删除lint。我使用的是内部使用esLint的
此visual studio模块在C:\Users\My Username
下定义了一个.eslintrc
文件,我已经使用此配置更新了此文件以及节点模块的主文件夹:
"parser": "babel-eslint",
"ecmaFeatures": {
"jsx": true,
"classes": true
},
"plugins": [
"react"
],
"env": {
"browser": true,
"node": true,
"es6": true,
"jquery": true
},
但我仍然得到了“JSX解析器:意外令牌=“错误:
关于让Web Analyzer以与命令行工具相同的方式运行,有什么想法吗
实际上,在Es6中,对于defaultProps,您必须在类外设置它,例如:
class NotepadComponent extends React.Component {
constructor(props){
super(props);
}
}
NotepadComponent.defaultProps ={
activeTab:'type'
}
NotepadComponent.displayName = 'NotepadComponent'
我不确定您是否在寻找它,但这可能会帮助您我在与TSLint和Web Analyzer的组合中遇到同样的问题。事实证明,Web Analyzer在C:\Users\[User]\AppData\Local\Temp\WebAnalyzer1.7.75中使用了自己的节点模块安装。在这里您还可以找到一个nodeJS服务器(.js),它将lint结果传递给visualstudio。我能够在VisualStudio中调整此服务器以获得更多错误反馈。这个反馈告诉我应该在C:\Users\[User]\AppData\Local\Temp\WebAnalyzer1.7.75中安装缺少的npm包。和C:\ProgramFiles(x86)\Microsoft Visual Studio 14.0\Common7\IDE。也许你也可以对ESLint这样做。另请参见静态关键字是ecmascript 2015定义的一部分: