Javascript 使用redux时出现eslint奇怪错误

Javascript 使用redux时出现eslint奇怪错误,javascript,reactjs,ecmascript-6,redux,eslint,Javascript,Reactjs,Ecmascript 6,Redux,Eslint,我从eslint收到这个警告,我正在使用CreateReact应用程序 ./src/components/auth.js Line 24: Unexpected labeled statement no-labels Line 24: 'authenticated:' is defined but never used no-unused-lab

我从eslint收到这个警告,我正在使用CreateReact应用程序

./src/components/auth.js
  Line 24:  Unexpected labeled statement                                           no-labels
  Line 24:  'authenticated:' is defined but never used                             no-unused-labels
  Line 24:  Expected an assignment or function call and instead saw an expression  no-unused-expressions
我想我下面的组件没有任何问题,它太烦人了

import React, { Component } from 'react';
import { connect } from 'react-redux';

export default function(ComposedComponent) {
  class Authentication extends Component {

    componentWillMount() {
      if (!this.props.authenticated) {
        this.props.history.replace('/login');
      }
    }

    componentWillUpdate(nextProps) {
      if (!nextProps.authenticated) {
        this.props.history.replace('/login');
      }
    }

    render() {
      return <ComposedComponent {...this.props} />
    }
  }

  return connect(state => {authenticated: state.auth.authenticated})(Authentication);
}
import React,{Component}来自'React';
从'react redux'导入{connect};
导出默认函数(ComposedComponent){
类身份验证扩展了组件{
组件willmount(){
如果(!this.props.authenticated){
this.props.history.replace('/login');
}
}
组件将更新(下一步){
如果(!nextrops.authenticated){
this.props.history.replace('/login');
}
}
render(){
返回
}
}
返回连接(状态=>{authenticated:state.auth.authenticated})(身份验证);
}

第一次使用eslint时,我不知道应该解决什么问题。

写这篇文章时,javascript很混乱

它看到一个箭头函数返回指令
authenticated:state.auth.authenticated
,这是一条错误的指令


您可以编写以下内容之一:

connect(state => ({ 
     authenticated: state.auth.authenticated,
}));
我们添加括号告诉javascript这不是指令而是json


您好,Madeline,请显示您的.eslintrc或package.json(如果您使用该方法存储您的eslint配置)。
connect((state) => { 
   return {
     authenticated: state.auth.authenticated,
   };
});