npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

eslint-plugin-internal-boundaries

v0.1.0

Published

ESLint plugin to enforce internal module boundaries (no imports from another module's internal/)

Readme

eslint-plugin-internal-boundaries

ESLint plugin that enforces internal module boundaries: do not import from another module's internal/.

Install

npm install -D eslint-plugin-internal-boundaries

Usage

Add the plugin (without the eslint-plugin- prefix) and enable the single rule:

// .eslintrc.js (or .cjs/.json)
module.exports = {
  plugins: ['internal-boundaries'],
  rules: {
    'internal-boundaries/no-outside-imports': 'error',
  },
};

Rule: internal-boundaries/no-outside-imports

  • Blocks importing from any path that contains /internal/ unless the importer lives under the same directory tree root.
  • Works with CommonJS require(), static imports, and dynamic import() with string literals.
  • Resolution is delegated to eslint-plugin-import resolvers configured via import/resolver settings.

Examples

Given a project structure:

./app
├── module-a
│   ├── internal
│   │   ├── helper-a.ts
│   │   └── config-a.ts
│   └── service-a.ts
├── module-b
│   ├── internal
│   │   └── helper-b.ts
│   └── service-b.ts
└── common
    └── utils.ts

Valid (allowed):

  • app/module-a/service-a.ts → ./internal/helper-a.ts
  • app/module-b/service-b.ts → ./internal/helper-b.ts

Invalid (blocked):

  • app/module-a/service-a.ts → ../module-b/internal/helper-b.ts
  • app/common/utils.ts → ../module-a/internal/helper-a.ts

How it determines the boundary

If an import path resolves to something that includes /internal/, the rule finds the path root up to, but not including, internal/ and only allows imports from files whose absolute path starts with that same root.

Aliases

If you use path aliases (for example via tsconfig paths), they will be resolved before applying the boundary check. That means these are considered equivalent and enforced correctly:

  • #alias/module-a/internal/helper-a
  • ~/app/module-a/internal/helper-a

Resolvers

This rule resolves imports using the same mechanism as eslint-plugin-import, via eslint-module-utils/resolve. Configure resolvers in ESLint settings and install the resolver packages you reference.

Legacy config example:

// .eslintrc.js (or .cjs/.json)
module.exports = {
  plugins: ['internal-boundaries'],
  settings: {
    'import/resolver': {
      // You must install these in your project:
      //   npm i -D eslint-import-resolver-typescript eslint-import-resolver-node
      typescript: true,
      node: true,
    },
  },
  rules: {
    'internal-boundaries/no-outside-imports': 'error',
  },
};

ESLint v9 flat config example:

// eslint.config.js
import tseslint from 'typescript-eslint';
import internalBoundaries from 'eslint-plugin-internal-boundaries';

export default [
  ...tseslint.configs.recommended, // sets @typescript-eslint/parser for .ts/.tsx
  {
    plugins: { 'internal-boundaries': internalBoundaries },
    settings: { 'import/resolver': { typescript: true, node: true } },
    rules: { 'internal-boundaries/no-outside-imports': 'error' },
  },
];

Notes:

  • Install the resolver packages you configure: eslint-import-resolver-typescript (for TS path aliases, etc.) and eslint-import-resolver-node (for Node-style resolution), if you use them.
  • This plugin bundles the call to eslint-module-utils/resolve; you don’t need to install eslint-module-utils separately.

TypeScript parser

If you lint .ts/.tsx files, ESLint needs @typescript-eslint/parser to parse them. The resolver is independent of parsing, but the rule still needs a valid AST.

Quick example (legacy config):

module.exports = {
  parser: '@typescript-eslint/parser',
  plugins: ['internal-boundaries'],
  settings: { 'import/resolver': { typescript: true, node: true } },
  rules: { 'internal-boundaries/no-outside-imports': 'error' },
};

Debugging

You can inspect decisions by enabling the debug logger:

DEBUG=internal-boundaries eslint .

Why enforce internal boundaries?

  • Encourages encapsulation and modular design.
  • Makes refactors safer by preventing cross-module coupling on internals.
  • Keeps architectural boundaries clear and intentional.

Background

This rule is inspired by Go's "internal" packages design. In Go, any code placed under an internal/ directory can only be imported by code within the same parent directory tree. This plugin brings that simple and effective encapsulation concept to JavaScript/TypeScript projects.

Further reading on Go's design:

  • Go 1.4 release notes: https://golang.org/doc/go1.4#internalpackages
  • cmd/go docs (Internal Directories): https://golang.org/cmd/go/#hdr-Internal_Directories

Configuration

This rule has no options. It's either on or off:

{
  "rules": {
    "internal-boundaries/no-outside-imports": "error"
  }
}

Contributing & Developing

  • Build: npm run build
  • Tests: npm test
  • Watch tests: npm run test:watch

MIT © Contributors