javierbrea / eslint-plugin-boundaries

Eslint plugin checking architecture boundaries between elements
MIT License
473 stars 9 forks source link

Feature request: support for import subpath patterns #309

Closed jbrunton closed 9 months ago

jbrunton commented 9 months ago

Big fan of this plugin. I've been using it in various projects for a while.

Is your feature request related to a problem? Please describe.

In a new project I'm using Node import subpath patterns to organise my imports. For example, in my package.json I have the following:

{
  // ...
  "imports": {
    "#entities/*": "./src/domain/entities/*",
    "#usecases/*": "./src/domain/usecases/*",
    "#app/*": "./src/app/*",
    "#data/*": "./src/data/*"
  },
}

Describe the solution you'd like

I would like to be able to import code using subpath patterns (e.g. import { whatever } from "#usecases/whatever";).

Instead, I get Importing ignored files is not allowed.

Describe alternatives you've considered

Usually I use TypeScript path aliases to help organise my code, which worked with eslint-plugin-boundaries. However, path aliases don't work with ts-node and ES Modules.

Additional context

Sample repo to reproduce here: https://github.com/jbrunton/eslint-plugin-boundaries-import-subpaths.

It's possible there's a solution to this but I didn't see anything in the docs.

Assuming I've not missed anything obvious and this requires a code change, I'd be happy to contribute if there is a reasonable solution to this, but I'd need some guidance.

jbrunton commented 9 months ago

Update: after further testing I realised that eslint-import-resolver-typescript appears to support subpath patterns.

I wonder if there's a good solution for JS only projects. However, I'm using TypeScript, so this meets my own needs. I'll close this issue.

javierbrea commented 9 months ago

@jbrunton , for JS projects import aliases can also be defined using the configuration of import/resolver. I'm glad you like the plugin, by the way 😃