A walkthrough of enforcing Node.js subpath imports as the sole import style in a codebase. It covers setting up subpath mappings in package.json for TypeScript and runtime resolution, using ESLint's no-restricted-imports rule to block relative and alias-style imports, and using the perfectionist/sort-imports rule to keep import

4m read timeFrom johnnyreilly.com
Post cover image
Table of contents
First a warning ​Node.js subpaths only ​Block alternatives with no-restricted-imports ​Keep import groups predictable with perfectionist/sort-imports ​Does this work with TypeScript? ​Is this actually a good idea? ​Conclusion ​

Sort: