Eslint-plugin-import: no-unresolved | Allow `@` for image size naming

Created on 13 Feb 2018  Β·  2Comments  Β·  Source: benmosher/eslint-plugin-import

Allow for the use of iOS sizing when naming image files using @ (i.e. [IMAGE]@3x.png) with react-native

Example folder structure

β”‚   test.js
└───images
β”‚   β”‚   [email protected]
β”‚   β”‚   [email protected]
β”‚   β”‚   [email protected]

Example uses

// test.js

// wrong usage and no linting error
const sun2 = require('./images/[email protected]');

// correct usage but throws linting error
const sun1 = require('./images/sun.png');

Example error in linter

image

resolver

Most helpful comment

Sounds like you need a custom resolver to teach eslint that your nonexistent path should pretend to exist.

All 2 comments

Sounds like you need a custom resolver to teach eslint that your nonexistent path should pretend to exist.

@ljharb is right, this is the domain of custom resolvers. check out https://github.com/benmosher/eslint-plugin-import/tree/master/resolvers for more info, and peek at the core resolvers or one of the third-party ones linked from the wiki. cheers!

Was this page helpful?
0 / 5 - 0 ratings