Intellicode / eslint-plugin-react-native

React Native plugin for ESLint
MIT License
718 stars 128 forks source link

no-unresolved for react native #32

Open damusnet opened 8 years ago

damusnet commented 8 years ago

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"]
      }
    }
  }
Intellicode commented 8 years ago

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

bbrock25 commented 7 years ago

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

ie: files that are named as follows:

"file-name@1x.png", "file-name@2x.png", "file-name@3x.png"

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

xareelee commented 7 years ago

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?

gustavjf commented 7 years ago

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

@bbrock25 Have you found a solution for this?

bbrock25 commented 7 years ago

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

mjmaix commented 6 years ago

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

fgeorgsson commented 5 years ago

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

sturmenta commented 5 years ago

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

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