Closed ledamint closed 11 months ago
Hi @ledamint , could you please provide a repository with a reproducible example? I'm sorry but I don't have enough context to see what can be wrong in the config. I suppose you are in a monorepo, and you have aliases for imports... is the eslint config being able to interpret aliases? Is the plugin config detecting properly each type of file as the type you pretend to assign to it?
@javierbrea Thanks for response. I created an example https://github.com/ledamint/monorepo-example-boundaries/tree/main
import all2 from '@monorepo-example/example2'
import all3 from '@monorepo-example/example3'
example2 is located inside entities example3 is located inside features
I allow all packages inside entities to import only libs and shared {from: 'entities', allow: ['libs', 'shared']},
So for this file I cant import from entities and features and want to get 2 errors with these imports. But I get only 1 error - with example3 (features) and not getting an error with example2 (entities).
@ledamint , the problem seems to be in the pattern that you are using to detect each entity. It produces to detect all code in the entities folder as the same entity, because of the double asterisk. Just replace it by a single asterisk corresponding to the folder of the entity name, or you can even be more specific and capture the name of the matching folder as package "name" in order to improve the logs:
{
type: 'features',
pattern: 'features/packages/*',
mode: 'folder',
capture: ["name"]
},
{
type: 'entities',
pattern: 'entities/packages/*',
mode: 'folder',
capture: ["name"]
}
I have tested this configuration in your example repository, and it works. You can also see here how logs improve:
Thanks, that helps
Describe the bug monorepo entities-package1
entities/packages/package1
entities-package2entities/packages/package2
features-package1features/packages/package1
I want to restrict import entities packages from all other packages in entities. For example
In config I allowed imports from libs and shared without entities -
{from: 'entities', allow: ['libs', 'shared']}
but I don't get the error.For example if I try to import from features folder I get the error.
To Reproduce Set up monorepo and add one eslint config (attached below) to root of repository.
Expected behavior Want to restrict imports from the same boundary element in monorepo.
Operating system
Additional context eslint config