这甚至可能不是Gulp的事情。它可能是我担心或可能是我的linting设置的Webpack配置。我认为必须有一个合适的ES或TS Lint我需要绑定到Gulp所以当它为这个React Asp.net Core应用程序构建我的客户端和服务器生成的Js文件时,它不会如此挑选。我在Visual Studio Code中,通常只需右键单击并格式化文档就可以处理这样的小问题但是当我运行gulp时,它会对这个新项目感到疯狂。这是一些小错误,对于我而言,对于间距而言并非如此。有人对此有经验吗?
9:18 error A space is required after '{' object-curly-spacing
9:28 error A space is required before '}' object-curly-spacing
14:1 error Trailing spaces not allowed no-trailing-spaces
9:18 error A space is required after '{' object-curly-spacing
9:28 error A space is required before '}' object-curly-spacing
14:1 error Trailing spaces not allowed no-trailing-spaces
15:3 error handleChange should be placed after componentDidMount react/sort-comp
以下是此错误示例的示例。
import React, { Component } from 'react';
import Helmet from 'react-helmet';
// import { connect } from 'react-redux';
import { } from 'react-bootstrap';
export default class Test extends Component {
constructor(props) {
super(props);
this.state = {value: ''};
this.handleChange = this.handleChange.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
}
handleChange(event) {
this.setState({value: event.target.value});
}
handleSubmit(event) {
alert('A name was submitted: ' + this.state.value);
event.preventDefault();
}
componentDidMount() { }
render() {
return (
<div>
<Helmet title="Test" />
<form onSubmit={this.handleSubmit}>
<label>
Name:
<input type="text" value={this.state.value} onChange={this.handleChange} />
</label>
<input type="submit" value="Submit" />
</form>
</div>
);
}
}
答案 0 :(得分:2)
感谢您的建设性意见,我能够更好地了解我的eslinter配置。事实上,在这种情况下,规则对我的需求可能有点敏感。我改变了我的规则,所以他们不会使用Gulp炸毁生成我的客户端和服务器js文件。这对我来说都很新鲜。我不确定为什么右键单击格式在Visual Studio代码中没有解决大部分这些问题。我安装了最新的eslint插头,所以我认为它应该是最新的。这是我的.eslintrc文件中的当前规则。
"rules": {
"comma-dangle": 0, // not sure why airbnb turned this on. gross!
"indent": 0,
"object-curly-spacing": 0,
"no-trailing-spaces": 0,
"react/prefer-stateless-function": 0,
"react/prop-types": 0,
"react/jsx-closing-bracket-location": 0,
"react/jsx-indent": 0,
"no-console": 0,
"prefer-template": 0,
"max-len": 0,
"no-underscore-dangle": [2, {"allow": ["__data"]}],
"global-require": 0,
"no-restricted-syntax": 0,
"linebreak-style": 0,
"react/jsx-filename-extension": 0,
"import/imports-first": 0
},
感谢@Daniel Beck和@CriCri