Search code examples
react-nativeeslintprettier

eslint prettier require file rearrage


I am trying to put the require('node-libs-react-native/globals'); on the very top of the file, but when I save the file, it uses eslint/prettier, it is rearrange it after the import.

import React, { Component } from 'react';
import { StatusBar } from 'react-native';
import { Provider } from 'react-redux';

require('node-libs-react-native/globals'); // <= put this the top.

Any place I can configure in .eslint file?


Solution

  • You could disable the import/first rule for this file to allow the 'require' statement to remain above the list of imports:

    /* eslint-disable import/first */
    require('node-libs-react-native/globals');
    
    import React, { Component } from 'react';
    import { StatusBar } from 'react-native';
    import { Provider } from 'react-redux';