DEV Community

Ivan Lesar for Bornfight

Posted on

Put up fences around your TypeScript modules

The author says it best...

"Good Fences is a tool that allows you to segment a TypeScript project into conceptual areas and manage dependencies between those areas."

https://github.com/smikula/good-fences

Define what you import or export between Typescript files, directories and subdirectories with tagged fence.json files.

{
    "tags": [ "tagA", "tagB" ],
    "exports": [
        "index",
        {
            "modules": "sample_directory/*",
            "accessibleTo": "tagX"
        }
    ],
    "imports": [
        "tagC",
        "tagD"
    ]
}
Enter fullscreen mode Exit fullscreen mode

And the most important feature... a human readable log with errors.

Good-fences violation in src/foo.ts:
    Import not allowed: src/bar.ts
    Fence: src/fence.json
Enter fullscreen mode Exit fullscreen mode

What are your goto tools? Have you stumbled upon anything new and added it to your arsenal? ๐Ÿง 

Top comments (0)