eslint-plugin-scope-boundaries
v0.2.0
Published
ESLint plugin for Nx monorepos that enforces scope-based import boundaries, with configurable cross-scope exceptions and ignored target scopes.
Maintainers
Readme
eslint-plugin-scope-boundaries
ESLint plugin for Nx monorepos that enforces scope-based import boundaries, with configurable cross-scope exceptions and ignored target scopes.
Installation
npm install --save-dev eslint-plugin-scope-boundariesPeer dependencies expected in consumer project:
eslint@typescript-eslint/utils@nx/devkit@nx/eslint-pluginnx
Usage
{
"overrides": [
{
"files": ["*.ts", "*.js"],
"plugins": ["scope-boundaries"],
"rules": {
"scope-boundaries/same-scope-imports": [
"warn",
{
"crossScopeAllowedTags": ["type:shell", "type:composition"],
"scopePrefix": "scope:",
"checkExports": true,
"reportMissingScopeTags": true,
"ignoredTargetScopes": ["scope:shared", "scope:foundation"]
}
]
}
}
]
}Rule: same-scope-imports
Behavior:
- A library can import another library only when both share the same scope tag prefix (for example
scope:billing->scope:billing). - Specific source tags can be allowed to import across scopes via
crossScopeAllowedTags. - Optional target scopes can be ignored via
ignoredTargetScopes. - Libraries without a scope tag are reported when
reportMissingScopeTagsis enabled.
Options:
crossScopeAllowedTags(required): non-empty array of source tags that can import across scopes.scopePrefix(required): prefix used to detect scope tags, e.g.scope:.checkExports(optional, defaulttrue): includeexport ... fromandexport * fromin checks.reportMissingScopeTags(optional, defaulttrue): report missing scope tags on source/target projects.ignoredTargetScopes(optional, default[]): skip cross-scope validation when the imported target scope is listed.
Minimal examples:
crossScopeAllowedTags:["type:shell"]scopePrefix:"scope:"checkExports:truereportMissingScopeTags:falseignoredTargetScopes:["scope:shared"]
Development
Run tests:
npm testLicense
MIT
