eslint-plugin-react-native icon indicating copy to clipboard operation
eslint-plugin-react-native copied to clipboard

no-unresolved for react native

Open damusnet opened this issue 9 years ago • 8 comments

Basically, could the settings in this issue be included in the eslint-plugin-react-native?

  "settings": {
    "import/resolver": {
      "node": {
        "extensions": [".js", ".ios.js", ".android.js"]
      }
    }
  }

damusnet avatar Jul 09 '16 09:07 damusnet

@damusnet That sounds useful, let me look into it!

Intellicode avatar Jul 10 '16 09:07 Intellicode

additionally, is there a way to have eslint pick up on the Static Image Resources

ie: files that are named as follows:

"[email protected]", "[email protected]", "[email protected]"

but referenced as: require("./file-name.png")

bbrock25 avatar Sep 08 '16 13:09 bbrock25

Hi, I encounter a problem with require() for images.

const flagImg = require('./img/Login_flag_1.png');

and ESLint reports the error (import/no-unresolved):

12:25  error  Unable to resolve path to module './img/Login_flag_1.png'    import/no-unresolved

How do I do to resolve this problem to suppress this error if the image resource is found?

Can it report if the image resource is not found?

xareelee avatar Mar 08 '17 03:03 xareelee

additionally, is there a way to have eslint pick up on the Static Image Resources

@bbrock25 Have you found a solution for this?

gustavjf avatar Apr 18 '17 11:04 gustavjf

@gustavjf I haven't been working in RN lately, I'm pretty sure we ended up ignoring those imports 😢

bbrock25 avatar Apr 20 '17 00:04 bbrock25

@gustavjf for now I'm using 'import/no-unresolved': [2, { ignore: ['.png$', '.webp$', '.jpg$'] }], to ignore until this issue is fixed.

mjmaix avatar Apr 07 '18 09:04 mjmaix

This plugin works for me: https://www.npmjs.com/package/eslint-import-resolver-react-native Linked from here: https://github.com/benmosher/eslint-plugin-import/wiki/Resolvers

fgeorgsson avatar Jan 07 '19 10:01 fgeorgsson

For using react-native-web, this works good 🔥🔥🔥

 "import/no-unresolved": [
      2,
      {
        "ignore": [
          "react-native"
        ]
      }
    ],

sturmenta avatar Mar 05 '19 05:03 sturmenta