The scopes
option of the workspaces/no-cross-imports
rule has been deprecated and will be removed in the next major version.
It was made with a specific use case in mind, but it turned out to be too inflexible and confusing.
Since there are better ways to achieve the same result, the option will be removed.
There are two ways to migrate from scopes
using basic ESLint configuration:
The overrides
key of the ESLint configuration allows you to apply rules differently to a specific set of files.
Assuming the following project structure:
project
└─── packages
└─── user-management/
└─── shared/
└─── package.json
└─── registration/
└─── package.json
└─── login/
└─── package.json
Inside project/.eslintrc.json
:
{
// ...
"rules": {
// ...
"workspaces/no-cross-imports": "error",
},
"overrides": [
{
"files": ["packages/user-management/**/*"],
"rules": {
"workspaces/no-cross-imports": [
"error",
{ "allow": ["@project/user-management-shared"] },
],
},
},
],
}
The cascading configuration files feature of ESLint allows you to create a configuration file in a subdirectory of your project.
Warning
This feature will be deprecated in the next major version of ESLint, see Flat config rollout plans.
It is recommended to use overrides
instead.
Assuming the following project structure:
project
└─── packages
└─── user-management/
└─── shared/
└─── package.json
└─── registration/
└─── package.json
└─── login/
└─── package.json
Inside project/.eslintrc.json
:
{
// ...
"rules": {
// ...
"workspaces/no-cross-imports": "error",
},
}
Inside project/packages/user-management/.eslintrc.json
:
{
"rules": {
"workspaces/no-cross-imports": [
"error",
{ "allow": ["@project/user-management-shared"] },
],
},
}