Gulp 当我 运行 时给出很多 syntax/lint 错误。为什么?

Gulp giving a lot of syntax/lint errors when I run it. Why?

这甚至可能不是 Gulp 的事情。这可能与我担心的 Webpack 配置有关,也可能是我的 linting 设置。我认为必须有一个合适的 ES 或 TS Lint 我需要绑定到 Gulp 所以当它为这个 React Asp.net 核心应用程序构建我的客户端和服务器生成的 Js 文件时它不会那么挑剔。我在 Visual Studio 代码中,通常只需右键单击并格式化文档即可解决此类小问题,但当我 运行 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>
);
  }
 }

感谢您的建设性意见,我能够更好地理解我的 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