javierbrea / eslint-plugin-boundaries

Eslint plugin checking architecture boundaries between elements
MIT License
506 stars 9 forks source link

External Imports Ignored Due To Cache #260

Closed jablonnc closed 1 year ago

jablonnc commented 1 year ago

Describe the bug

When I define 2+ custom externals (i.e. not npm packages, but externals that I have created and am loading in at the runtime), it appears this linting rule picks up the first one and ignores all subsequent imports. After investigating, it appears to be related to the caching mechanism.

To Reproduce

In the boundaryTest.ts file I setup I only have two imports shown here:

Screen Shot 2022-11-23 at 10 22 13 AM

For the two imports above, I have these added to the import/no-unresolved rule as shown here since they are modules consumed at the runtime:

Screen Shot 2022-11-23 at 3 33 38 PM

I have a relatively simple setup when it comes to the boundary rule:

Screen Shot 2022-11-23 at 10 21 26 AM

Upon running yarn lint, I only ever see an error message around the first external import I disallowed (in this case web-runtime-commons-constants):

Screen Shot 2022-11-23 at 10 23 41 AM

Expected behavior

I would expect it to show an error message for both external imports.

Additional context

After debugging the issue, it seems related to the following PR where the cache was added. Specifically the isExternal prop is never added to the second import because after the cache is hit the first time (using the key src/boundaryTest.ts) it never proceeds to the second import in which it would get added:

Screen Shot 2022-11-23 at 10 27 30 AM

I am actually able to fix this using the following approaches:

javierbrea commented 1 year ago

Hi @jablonnc, thank you very much for the detailed information about the issue. It has been fixed and will be released in v3.1.0.