This is no longer supported. Consider using dependency-cruiser instead.
You want full control of your imports? Not each file is allowed to import another file from a different folder? Especially if you are following "The Clean Architecture" it is important to have these rule somehow configured.
This TSLint rule will help you with that!
npm install --save-dev tslint-import-control-rule
To make the rule works as intended you need to configure an alias
in your package.json
, e.g.:
{
"alias": {
"src": "./src"
}
}
In your tslint.json
file, source the rule from this package, e.g.:
{
"rules": {
"import-control": [
true,
{
"rootDir": "string",
"whitelist": [
"string"
],
"overrides": [
{
"rootDir": "string",
"whitelist": [
"string"
]
}
]
}
]
},
"rulesDirectory": [
"node_modules/tslint-import-control-rule/src"
]
}
{
"rules": {
"import-control": [
true,
{
"rootDir": "src",
"whitelist": [
"src/shared"
],
"overrides": [
{
"rootDir": "src/infrastructure",
"whitelist": [
"src/application",
"src/domain"
]
},
{
"rootDir": "src/application",
"whitelist": [
"src/domain"
]
}
]
}
]
},
"rulesDirectory": [
"node_modules/tslint-import-control-rule/src"
]
}
With this rule we can achieve the following:
- Domain has only access to
src/shared
- Application has access to
src/shared
andsrc/domain
- Infrastructure has access to
src/shared
,src/domain
andsrc/application
Bugs, rules requests, doubts etc., open a Github Issue.
MIT