eslint-plugin-monorepo icon indicating copy to clipboard operation
eslint-plugin-monorepo copied to clipboard

monorepo/no-internal-import prevents some safe imports

Open mxmul opened this issue 4 years ago • 2 comments

My understanding of this rule is that it's meant to prevent packages in the monorepo from importing files that exist locally, but would not be present after publishing to NPM.

It's also preventing valid internal imports of files that we know do get published to NPM, e.g. anything that is listed in the files array of package.json. For example if we know that package-a has files: ["lib"] in it's package.json, we should be able to tell that an import like import foo from 'package-a/lib/foo.js' is safe.

Would you be open to a flag that allowed these sort of internal imports?

mxmul avatar Jun 03 '20 17:06 mxmul

@azz hey, we have a similar use-case in https://github.com/spotify/backstage, basically we want to allow everything included in files field inside package.json to be allowed by the rule: Example of rule error that we want to avoid - https://github.com/spotify/backstage/blob/108ce379493e8a7a805b1501a696dd79ebe1dadd/packages/app/src/index.tsx#L17-L18

Please let me know if this is something you are interested in and happy to contribute!

shmidt-i avatar Oct 07 '20 14:10 shmidt-i

@shmidt-i Absolutely! Go wild.

azz avatar Oct 08 '20 04:10 azz