biome icon indicating copy to clipboard operation
biome copied to clipboard

feat(biome_js_analyze): noRestrictedImports - Added option to allow import from specific locations

Open ziongh opened this issue 9 months ago • 7 comments

Summary

Sometimes we want to forbid the use of a module in the application but allow in specific places.

One great example of this is when we want to define a linear folder structure and enforce that a folder should not reference the folders above it, but allow referencing all the folders below.

Test Plan

{
    "noRestrictedImports": {
        "options": {
            "paths": {
                "@/features": {
                   "message": "Using lodash is not encouraged",
                   "allowedFrom": ["./src/routes"]
                },
                "underscore": {
                   "message": "Using underscore is not encouraged",
                }
            }
        }
    }
}

In the example above we would be able to allow using @/features module from within ./src/routes but not from other places.

ziongh avatar May 24 '24 22:05 ziongh