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)
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.
Thanks @benmosher the .eslintrc settings resolved the issue. I'll look into creating the shared config and the rule
Sweet, I'ma close this and we can track via #283 or some new issue.
For using react-native-web, this works good 馃敟馃敟馃敟
"import/no-unresolved": [
2,
{
"ignore": [
"react-native"
]
}
],
Most helpful comment
I think you may be able to do this by setting the following in an
.eslintrc: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! 馃槑)
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.