【问题标题】:eslint prettier require file rearrageeslint prettier 需要文件重排
【发布时间】:2019-12-24 21:10:10
【问题描述】:

我试图将require('node-libs-react-native/globals'); 放在文件的最顶部,但是当我保存文件时,它使用 eslint/prettier,它在导入后重新排列。

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.

我可以在 .eslint 文件中配置的任何地方?

【问题讨论】:

    标签: react-native eslint prettier


    【解决方案1】:

    您可以禁用此文件的 import/first 规则,以允许 'require' 语句保留在导入列表之上:

    /* 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';
    

    【讨论】:

      猜你喜欢
      • 2022-07-06
      • 2017-11-25
      • 2021-05-06
      • 2020-12-25
      • 2020-12-04
      • 2020-11-19
      • 2018-08-22
      • 2018-09-18
      • 2020-03-15
      相关资源
      最近更新 更多