Arnas
Arnas

Reputation: 327

eslint-plugin-import complains when using this little package.json trick

so in my project I am using this little neat trick with package.json file. Let's say I have images folder and inside that folder I have a package.json file with only one line: { "name":"images" }. That way, I can use imports like this:

import MarkerImage from 'images/marker.png';

And it will work just fine. The problem is that eslint-plugin-import that it's unable to resolve path module and also that "images" should be listed in the project's dependencies. Is there any way to fix this without disabling these rules?

Upvotes: 1

Views: 2899

Answers (1)

Arnas
Arnas

Reputation: 327

Okay, I've found a solution myself. I've added the dependencies to my package.json under "dependencies" as follows:

"api": "./src/api",
"core": "./src/core",
"common": "./src/common"

This will effectively create symlinks in your node_modules folder to the specified directories. And it will also resolve the warnings/errors you get.

Upvotes: 1

Related Questions