Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no-unresolved for react native #279

Closed
flipchart opened this issue Apr 27, 2016 · 4 comments
Closed

no-unresolved for react native #279

flipchart opened this issue Apr 27, 2016 · 4 comments

Comments

@flipchart
Copy link

In react native, you can have an import statement import Foo from "./foo" which could refer to the file

foo.js
foo.android.js
foo.ios.js

(and I imagine they'll be adding another with Windows Universal platform support coming).

no-unresolved gives an error when foo.js doesn't exist, but foo.android.js and foo.ios.js does. I think that it should accept the platform specific files if they exist, but perhaps could warm if one or more are missing (i.e. you have foo.android.js but not foo.ios.js)

@benmosher
Copy link
Member

I think you may be able to do this by setting the following in an .eslintrc:

settings:
  import/resolver:
    node:
      extensions:
        # if unset, default is just '.js', but it must be re-added explicitly if set 
        - .js
        - .android.js
        - .ios.js

See the Node resolver README for more details.

Also see #283; if this works, would be good to capture in a shared config. (PR welcome! 😎)

but perhaps could warm if one or more are missing (i.e. you have foo.android.js but not foo.ios.js)

It won't do this, it will only ensure at least one of them exists. I can imagine a rule that could enforce that all of some list exist, though. That would be cool.

@flipchart
Copy link
Author

Thanks @benmosher the .eslintrc settings resolved the issue. I'll look into creating the shared config and the rule

@benmosher
Copy link
Member

Sweet, I'ma close this and we can track via #283 or some new issue.

@sturmenta
Copy link

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

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

mrtnzlml added a commit to kiwicom/eslint-config-kiwicom that referenced this issue Apr 3, 2019
Source: import-js/eslint-plugin-import#279 (comment)

kiwicom-source-id: a4546579be39cecce2f8335963d2f0e4b96884b3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants