margrave
v0.1.1
Published
maintain the defense of borders of modules
Readme
margrave
maintain the defense of borders of modules
Install
yarn global add margraveUsage
cd path-to-project
margraveThe margrave command line scans import statements and checks some conventions about relative and absolute imports.
Conventions
- any directory contains aa
index.tsfiles is a territory index.tsfiles only should contain re-exports- some functions, types, and variables can be re-exported from
index.tsas public - any
tsortsxfile inside a territory can import from any file inside the territory and this import should be relative - any
tsortsxfile can import fromindex.tsof other territories, and this import should be absolute
Example
src
|-- app.tsx
|-- pages
| |-- index.ts
| `-- Page.tsx
`-- user
|-- index.ts
|-- type.ts
`-- User.tsx| file | import statement | allowed |
| -------------------- | ---------------- | :----------------: |
| src/pages/Page.tsx | src/user | :heavy_check_mark: |
| src/pages/Page.tsx | src/user/type | :x: |
| src/pages/Page.tsx | ../user | :x: |
| src/pages/Page.tsx | ../user/type | :x: |
| src/user/User.tsx | ./type | :heavy_check_mark: |
| src/user/User.tsx | . | :x: |
| src/user/User.tsx | src/user/type | :x: |
| src/user/User.tsx | src/user | :x: |
