eslint-plugin-boundaries

raw JSON →
6.0.2 verified Sat Apr 25 auth: no javascript

ESLint plugin for enforcing architectural boundaries between elements in JavaScript and TypeScript projects. Current stable version is 6.0.2 (released Feb 2025) with active development. It allows defining layered architectures (e.g., controllers, models, views) with dependency rules that restrict which elements can import from others. Features object-based element selectors (v6), monorepo support, TypeScript types, and real-time ESLint feedback. Differentiators: flexible element/rule definitions, built-in recommended config, and a dedicated documentation site (jsboundaries.dev). Release cadence is roughly monthly. Requires eslint >=6.0.0 and node >=18.18.

error Cannot read properties of undefined (reading 'default')
cause Using CommonJS require() without .default in ESM-only v6
fix
Use const boundaries = require('eslint-plugin-boundaries').default;
error ESLint configuration error: Rule 'boundaries/element-types' is not found
cause Plugin not added to plugins field in flat config
fix
Add plugins: { boundaries } to the config object (see quickstart)
error Boundaries: No element matched for file '...' (settings 'boundaries/elements')
cause File path does not match any defined element pattern
fix
Add a pattern that matches the file or adjust existing patterns
error TypeError: boundaries.createConfig is not a function
cause Using named import for createConfig in CommonJS without default import
fix
Use import boundaries from 'eslint-plugin-boundaries'; boundaries.createConfig()
breaking ESM-only since v6; require() fails without .default
fix Use import or require('eslint-plugin-boundaries').default
breaking no-private rule disabled by default in recommended config since v6.0.0-beta.2
fix Explicitly enable in rules: 'boundaries/no-private': [2, { allowUncles: true }]
deprecated no-private rule is deprecated and will be removed in future major version
fix Use boundaries/element-types with appropriate rules instead
gotcha Elements selector validation error when selector is an empty array (v5.3.1 fixed this)
fix Upgrade to >=5.3.1 or ensure every element has at least one pattern
gotcha TypeScript createConfig helper types incompatible with ESLint v10 before v6.0.1
fix Update to v6.0.1 or later
deprecated Legacy string-based element selectors are deprecated in v6; use object-based selectors
fix Migrate elements definition to object form (type + pattern)
gotcha handlebars dependency had critical vulnerability GHSA-2w6w-674q-4c4q before v6.0.2
fix Upgrade to v6.0.2 or later
npm install eslint-plugin-boundaries
yarn add eslint-plugin-boundaries
pnpm add eslint-plugin-boundaries

Configures eslint-plugin-boundaries with element types and dependency rules in flat ESLint config (v9+).

// npm install eslint eslint-plugin-boundaries --save-dev
// eslint.config.js (flat config)
import boundaries from 'eslint-plugin-boundaries';

export default [
  {
    plugins: { boundaries },
    settings: {
      'boundaries/elements': [
        { type: 'controller', pattern: 'controllers/*' },
        { type: 'model', pattern: 'models/*' },
        { type: 'view', pattern: 'views/*' },
        { type: 'service', pattern: 'services/*' },
        { type: 'utility', pattern: 'utils/*' },
      ],
    },
    rules: {
      'boundaries/element-types': [2, {
        default: 'disallow',
        rules: [
          { from: 'controller', to: 'view', allow: true },
          { from: 'controller', to: 'model', allow: true },
          { from: 'view', to: 'controller', allow: false },
          { from: 'model', to: 'service', allow: true },
          { from: 'service', to: ['model', 'utility'], allow: true },
          { from: 'utility', to: ['utility', 'model'], allow: true },
        ],
      }],
    },
  },
];