title: How to fix eslint failure when requiring a file with dynamic path inside a function?
body: <p>I need to use react-int outside a component and particularly inside an util file. In order to accomplish that i'am using this code <a href="https://gist.github.com/genadyp/435f4e264cb6e377836cf63bee8987d8" rel="nofollow noreferrer">https://gist.github.com/genadyp/435f4e264cb6e377836cf63bee8987d8</a>
  But i am facing an issue with eslint that fails and it does not accept using require inside a function and using a dynamic file path too.</p>
  
  <p>here is eslint output:</p>
  
  <p>error  Unexpected require() global-require
  error  Calls to require() should use string literals  import/no-dynamic-require</p>
  
  <p>Any advice and suggestions will be greatly appreciated.</p>
  
  <pre><code>//util.js
  export function formatMessage(t, locale) {
      if (t=== 0 || t === 2400) {
          const translations 
          =require(`src/locales/${locale.toLowerCase()}.json`));
  
          const intlProvider = new IntlProvider({ locale, messages: 
          translations }, {});
          const mes = defineMessages({
              morning: {
                  id: 'greeting.morning',
                  defaultMessage: 'hello',
              },
              evening: {
                  id: 'greeting.evening',
                  defaultMessage: 'good evening',
              },
         });
         const { intl } = intlProvider.getChildContext();
  
         return t === 0 ? intl.formatMessage(mes.morning) : 
             intl.formatMessage(mes.evening);
    }
  }
  </code></pre>