Commit 551592d4 authored by Francis Renaud's avatar Francis Renaud
Browse files

Added eslint rules and fixed reported issues

parent 2cfd7269
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ class IDDeployScenarioDialog extends Component {
  }

  onDeployScenario() {
    if (this.state.selectedScenario == '') {
    if (this.state.selectedScenario === '') {
      // console.log('Invalid scenario name');
      // TODO: consider showing an alert
      return;
+2 −2
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ class IDExportScenarioDialog extends Component {

  exportScenario() {

    if (this.state.filename == '') {
    if (this.state.filename === '') {
      // console.log('Invalid file name provided');
      // TODO: consider showing an alert
      return;
@@ -70,7 +70,7 @@ class IDExportScenarioDialog extends Component {
          onChange={
            (e) => {
              const val = e.target.value;
              const err = (!val && val !=null)
              const err = (!val && val !== null)
                ? 'Please enter a filename'
                : '';
              this.setState({
+2 −2
Original line number Diff line number Diff line
@@ -45,13 +45,13 @@ class IDNewScenarioDialog extends Component {
     */
  getScenarioNewCb(error/*, data, response*/) {

    if (error == null) {
    if (error === null) {
      // TODO: consider showing an alert
      return;
    }

    // Validate scenario name
    if (this.state.scenarioName == '' || this.state.err != null) {
    if (this.state.scenarioName === '' || this.state.err !== null) {
      // TODO: consider showing an alert
      return;
    }
+1 −1
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@ class IDSaveScenarioDialog extends Component {
        err = 'Lowercase alphanumeric or \'-\'';
      }
    } else {
      err = 'Please enter a scenario name'
      err = 'Please enter a scenario name';
    }

    this.setState({
+10 −11
Original line number Diff line number Diff line
@@ -82,13 +82,12 @@ const validateLatency = (val) => {
    return 'Value is required';
  }
  if (val) {
    if (isNaN(val)) return 'Latency value should be a number';
    if ((val != '') && val < MIN_LATENCY_VALUE || val > MAX_LATENCY_VALUE) {
    if (isNaN(val)) {return 'Latency value should be a number';}
    if ((val !== '') && val < MIN_LATENCY_VALUE || val > MAX_LATENCY_VALUE) {
      return `Out of range (${MIN_LATENCY_VALUE}-${MAX_LATENCY_VALUE})`;
    }
    if (!isInt(val)) {
      return 'Latency value should be an integer';
    }
    if (!isInt(val)) {return 'Latency value should be an integer';}
    
  }
  return null;
};
@@ -98,8 +97,8 @@ const validateLatencyVariation = (val) => {
    return 'Value is required';
  }
  if (val) {
    if (isNaN(val)) return 'Latency variation should be a number';
    if ((val != '') && val < MIN_LATENCY_VARIATION_VALUE || val > MAX_LATENCY_VARIATION_VALUE) {
    if (isNaN(val)) {return 'Latency variation should be a number';}
    if ((val !== '') && val < MIN_LATENCY_VARIATION_VALUE || val > MAX_LATENCY_VARIATION_VALUE) {
      return `Out of range (${MIN_LATENCY_VARIATION_VALUE}-${MAX_LATENCY_VARIATION_VALUE})`;
    }
    if (!isInt(val)) {
@@ -114,8 +113,8 @@ const validatePacketLoss = (val) => {
    return 'Value is required';
  }
  if (val && val !== '0') {
    if (isNaN(val)) return 'Packet loss value should be a number';
    if ((val != '') && val < MIN_PACKET_LOSS_VALUE || val > MAX_PACKET_LOSS_VALUE) {
    if (isNaN(val)) {return 'Packet loss value should be a number';}
    if ((val !== '') && val < MIN_PACKET_LOSS_VALUE || val > MAX_PACKET_LOSS_VALUE) {
      return `Out of range (${MIN_PACKET_LOSS_VALUE}-${MAX_PACKET_LOSS_VALUE})`;
    }
    if (!Number(val) || val[val.length-1] === '.') {
@@ -133,8 +132,8 @@ const validateThroughput = (val) => {
    return 'Value is required';
  }
  if (val) {
    if (isNaN(val)) return 'Throughput value should be a number';
    if ((val != '') && val < MIN_THROUGHPUT_VALUE || val > MAX_THROUGHPUT_VALUE) {
    if (isNaN(val)) {return 'Throughput value should be a number';}
    if ((val !== '') && val < MIN_THROUGHPUT_VALUE || val > MAX_THROUGHPUT_VALUE) {
      return `Out of range (${MIN_THROUGHPUT_VALUE}-${MAX_THROUGHPUT_VALUE})`;
    }
  }
Loading