Socket
Book a DemoInstallSign in
Socket

margrave

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

margrave

maintain the defense of borders of modules

latest
Source
npmnpm
Version
0.1.1
Version published
Maintainers
1
Created
Source

margrave

NPM version NPM downloads Build Status codecov

maintain the defense of borders of modules

Install

yarn global add margrave

Usage

cd path-to-project
margrave

The margrave command line scans import statements and checks some conventions about relative and absolute imports.

Conventions

  • any directory contains aa index.ts files is a territory
  • index.ts files only should contain re-exports
  • some functions, types, and variables can be re-exported from index.ts as public
  • any ts or tsx file inside a territory can import from any file inside the territory and this import should be relative
  • any ts or tsx file can import from index.ts of other territories, and this import should be absolute

Example

src
|-- app.tsx
|-- pages
|   |-- index.ts
|   `-- Page.tsx
`-- user
    |-- index.ts
    |-- type.ts
    `-- User.tsx
fileimport statementallowed
src/pages/Page.tsxsrc/user:heavy_check_mark:
src/pages/Page.tsxsrc/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.tsxsrc/user/type:x:
src/user/User.tsxsrc/user:x:

FAQs

Package last updated on 23 Sep 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts