ESLint: Require statement not part of import statement.(@typescript-eslint/no-var-requires)

南楼画角 提交于 2020-04-14 07:41:08

问题


I'm trying to add a background image from react native BackgroundImage which needs to add source as source={require('*--iamge path --*')}

but my eslint throw Require statement not part of import statement. error. i have tried to import image in different ways for example:

 - const image = '--image path--'
 - import image = require('--image path--')
 - <BackgroundImage source={require('--image path--')}>

回答1:


you can disable this check in eslintrc.js file

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


来源:https://stackoverflow.com/questions/59278151/eslint-require-statement-not-part-of-import-statement-typescript-eslint-no-va

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!