<commit_before>// @flow

import React from 'react'
import PropTypes from 'prop-types';

class ScriptLoader extends React.Component {
  static propTypes = {
    src: PropTypes.string.isRequired,
    onLoad: PropTypes.func.isRequired,
  };
  loadFired: boolean;
  invokeOnLoad() {
    if (!this.loadFired) {
      setTimeout(() => {
        this.loadFired = true
        this.props.onLoad()
      }, 0)
    }
  }
  componentDidMount() {
    const scriptSrc = this.props.src
    const scripts = Array.from(document.querySelectorAll('script'))
    if (scripts.find(script => script.src === scriptSrc)) {
      this.invokeOnLoad()
      return
    }
    const script = document.createElement('script')
    script.src = scriptSrc
    script.onload = () => this.invokeOnLoad()
    document.body.appendChild(script)
  }
  render() {
    return <span style={{ display: 'none' }} data-purpose="Dummy element created by react-isomorphic-scriptloader" />
  }
}

module.exports = ScriptLoader<commit_msg>Changes to satisfty new lint rules<commit_after>// @flow

import React from 'react'
import PropTypes from 'prop-types'

class ScriptLoader extends React.Component {
  static propTypes = {
    src: PropTypes.string.isRequired,
    onLoad: PropTypes.func.isRequired,
  }

  componentDidMount() {
    const { src: scriptSrc } = this.props
    const scripts = Array.from(document.querySelectorAll('script'))
    if (scripts.find(script => script.src === scriptSrc)) {
      this.invokeOnLoad()
      return
    }
    const script = document.createElement('script')
    script.src = scriptSrc
    script.onload = () => this.invokeOnLoad()
    document.body.appendChild(script)
  }
  loadFired: boolean
  invokeOnLoad() {
    if (!this.loadFired) {
      setTimeout(() => {
        this.loadFired = true
        const { onLoad } = this.props
        onLoad()
      }, 0)
    }
  }

  render() {
    return <span style={{ display: 'none' }} data-purpose="Dummy element created by react-isomorphic-scriptloader" />
  }
}

module.exports = ScriptLoader
{'fraction_non_alphanumeric': 0.12831858407079647, 'fraction_numerical': 0.0009832841691248771, 'mean_word_length': 3.0945674044265594, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '4387308', 'n_tokens_mistral': 611, 'n_tokens_neox': 615, 'n_words': 136}