React native ESLint:Require语句不是import语句的一部分。(@typescript ESLint/no var requires)

React native ESLint:Require语句不是import语句的一部分。(@typescript ESLint/no var requires),react-native,eslint,React Native,Eslint,我正在尝试从react nativeBackgroundImage添加背景图像,它需要将源添加为source={require('*--iamge path--*')} 但是我的eslint throwRequire语句不是import语句的一部分。错误。我尝试过以不同的方式导入图像,例如: - const image = '--image path--' - import image = require('--image path--') - <BackgroundImage so

我正在尝试从react nativeBackgroundImage添加背景图像,它需要将源添加为
source={require('*--iamge path--*')}

但是我的eslint throwRequire语句不是import语句的一部分。错误。我尝试过以不同的方式导入图像,例如:

 - const image = '--image path--'
 - import image = require('--image path--')
 - <BackgroundImage source={require('--image path--')}>
-const image='--映像路径--'
-导入映像=需要('--映像路径--')
- 

您可以在
eslintrc.js
文件中禁用此签入

module.exports = {
  ...
  rules: {
    ...
    '@typescript-eslint/no-var-requires': 0,
  }
}

也可以对单个文件禁用它,而不是对整个项目全局禁用它

在文件顶部添加:

/* eslint @typescript-eslint/no-var-requires: "off" */

typescript lint出现相同错误,请在require语句对我有效之前添加此行,本地禁用此规则:

/* tslint:disable no-var-requires */

你能提供这方面的文件吗?据我所知,他对此完全沉默。你可以在这里查看@samurai_jane。没有理由eslint.org对此发表任何评论。org告诉您关于如何启用和禁用规则的一般表单。如下所示:
rulename:value
。这些规则来自一个外部包,typescript eslint,那么为什么eslint.org会对它说些什么呢?每个人都可以创建自己的规则。或者
/*eslint disable@typescript eslint/no var requires*/
这不适用于eslint 7tslint,自2019年以来已被弃用。不要用这个。