<commit_before>import axios from 'axios';
import { API_URL } from '../constants';

export type HitReturnStatus = 'repeat' | 'success' | 'error';

export const sendReturnHitRequest = async (hitId: string) => {
  try {
    const response = await axios.get(`${API_URL}/mturk/return`, {
      params: {
        hitId,
        inPipeline: false
      },
      responseType: 'document'
    });
    const html: Document = response.data;
    return validateHitReturn(html);
  } catch (e) {
    throw new Error('Unknown problem with returning Hit.')
  }
};

const validateHitReturn = (html: Document): HitReturnStatus => {
  const noAssignedHitsContainer = html.querySelector('td.error_title');

  if (!!noAssignedHitsContainer) {
    return 'success';
  }

  const alertBox = html.querySelector('#alertboxHeader');
  return !!alertBox ? validateAlertBoxText(alertBox) : 'error';
};

const validateAlertBoxText = (el: Element | undefined): HitReturnStatus => {
  if (el === undefined) {
    return 'error';
  }

  const text = (el as HTMLSpanElement).innerText.trim();
  switch (text) {
    case 'The HIT has been returned.':
      return 'success';
    case 'You have already returned this HIT.':
      return 'repeat';
    default:
      return 'error';
  }
};
<commit_msg>Fix linting error.<commit_after>import axios from 'axios';
import { API_URL } from '../constants';

export type HitReturnStatus = 'repeat' | 'success' | 'error';

export const sendReturnHitRequest = async (hitId: string) => {
  try {
    const response = await axios.get(`${API_URL}/mturk/return`, {
      params: {
        hitId,
        inPipeline: false
      },
      responseType: 'document'
    });
    const html: Document = response.data;
    return validateHitReturn(html);
  } catch (e) {
    throw new Error('Unknown problem with returning Hit.');
  }
};

const validateHitReturn = (html: Document): HitReturnStatus => {
  const noAssignedHitsContainer = html.querySelector('td.error_title');

  if (!!noAssignedHitsContainer) {
    return 'success';
  }

  const alertBox = html.querySelector('#alertboxHeader');
  return !!alertBox ? validateAlertBoxText(alertBox) : 'error';
};

const validateAlertBoxText = (el: Element | undefined): HitReturnStatus => {
  if (el === undefined) {
    return 'error';
  }

  const text = (el as HTMLSpanElement).innerText.trim();
  switch (text) {
    case 'The HIT has been returned.':
      return 'success';
    case 'You have already returned this HIT.':
      return 'repeat';
    default:
      return 'error';
  }
};

{'fraction_non_alphanumeric': 0.12993920972644377, 'fraction_numerical': 0.0, 'mean_word_length': 2.9653614457831323, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1162604', 'n_tokens_mistral': 779, 'n_tokens_neox': 771, 'n_words': 208}