softarc-consulting / sheriff

Lightweight Modularity for TypeScript Projects
https://softarc-consulting.github.io/sheriff/
MIT License
205 stars 16 forks source link

Wildcards in tsconfig path mapping #17

Open raphaelmeyer opened 1 year ago

raphaelmeyer commented 1 year ago

We have a setup where we make heavy use of secondary entry points with ng-packagr. In tsconfig.json we make use of the following:

{
  "compilerOptions": {
    "paths": {
      "@some/name/*": ["some/path/*/src"]
    }
  }
}

With this setup, e.g. @some/name/foo maps to some/path/foo/src.

I've seen that sheriff already has support, when the wildcard is at the end. But I could not get it working with the wildcard in the middle of the path.

Otherwise the plugin looks very promising, because we are looking for some linter rule to prevent to import from another entry point with a relative path instead of using the name.

rainerhahnekamp commented 1 year ago

Hey Raphael, wow! I was not aware that one can have these kinds of paths. I guess, there could also be the possibility for something like some/path/**/src or even some/path/*/src/*lib.

I will take a look into it. There are special unit tests for the matching algorithm. So it should hopefully not take too much time.