Special-casing non-standard import syntax in no-extraneous-dependencies
See original GitHub issueI’m using eslint-plugin-import
with Parcel v2, which allows the definition of named pipelines such that I can import assets using a line like
import logoPng from "data-url:./logo.png";
I can make these imports resolvable by eslint-plugin-import
by using the eslint-import-resolver-parcel2
package, and it works fine.
However, if I want to load an asset from an package installed in node_modules
, e.g.:
import layersPng from "url:leaflet/dist/images/layers.png";
I get an error:'url:leaflet' should be listed in the project's dependencies. Run 'npm i -S url:leaflet' to add it
.
Likewise if I try:
import layersPng from "url:./node_modules/leaflet/dist/images/layers.png";
then I get 'url:.' should be listed in the project's dependencies. Run 'npm i -S url:.' to add it
.
I think the difference is that the resolved file name passes the external
check here:
https://github.com/benmosher/eslint-plugin-import/blob/master/src/rules/no-extraneous-dependencies.js#L125-L127
in the first case, and not in the second?
Is there anything I can do about this? Perhaps in the eslint-import-resolver-parcel2
plugin?
Related: an ignore facility à la #903 would provide a useful workaround in this case.
Issue Analytics
- State:
- Created 3 years ago
- Comments:18 (9 by maintainers)
@ljharb It used to work for us prior to 2.20.1. At least it didn’t trigger eslint errors, so maybe such values were simply ignored.
I’m not 100% au fait with what’s available in a Node.js environment, so I’ll do a bit of reading and then take a first pass at this.