How to fix ESLint errors on @expo imports?


#1

I just finished setting up Prettier and ESLint, with airbnb rules, in my project. It works great.
However, I’m getting one Expo specific error and I’m not sure the best approach to fix it.

@expo/vector-icons' should be listed in the project's dependencies.

I tried adding a rule to my .eslintrc with no luck.

rules: {
    'import/no-unresolved': ['error', {ignore: '@expo/'}],
}

How do I set up the rule correctly?
Is there a better way to do this than creating a rule?


#2

Answered in slack:

@expo/vector-icons is a sub-dependency of the expo-sdk so in this case it works, but if you’re importing it you should add it to package.json


#3

Any help with this problem? how to hide this eslint message,
@expo/vector-icons’ should be listed in the project’s dependencies.

Thanks


#4
import { Icon } from 'expo';

then you can do Icon.Ionicons if you want. you could also just turn that rule off in your project.


#5

Thanks!!