I am intrigued by the idea of restricting files within a specific scope from importing files from another scope. Let's consider this example:
Imagine we have the following project structure:
project/
├── node_modules/
├── test/
├── src/
│ ├── domain/
│ │ ├── SomeModelClass.ts
│ ├── application/
│ │ ├── SomeApplicationConcern.ts
│ ├── database/
│ │ ├── SomeRepository.ts
├── tsconfig.json
└── tslint.json
Here are some rules I would like to impose:
SomeApplicationConcern
can import code from anywhere.SomeRepository
cannot import code fromapplication
.SomeModelClass
cannot import code fromapplication
ordomain
.
Is there a way to achieve this using nested tsconfig.json
files? Or perhaps with customized tslint
rules?
I am unsure if implementing such restrictions is even possible, but ideally, I would like to receive a compilation error (or a tslint error, given that it is set to error severity in my project) if an unauthorized dependency is found.