strict-component-boundaries
Blocks relative imports that reach into another component folder.
Rule details Problem
Section titled “Rule details ”ProblemThis rule only checks relative imports.
It resolves the import path, looks for PascalCase component directories in the target path, and reports deep imports that reach into another component’s internals instead of importing from that component’s boundary.
By default, maxDepth is 1, which means imports can reach the component root but not deeper nested files. Imports to
an index file are allowed, fixture paths under fixtures are allowed in the expected cases, and you can add regex
patterns to allow for local exceptions.
Examples
Section titled “Examples” Incorrect
import { helper } from "../UserCard/utils/helper";import { useProfile } from "../UserProfile/hooks/useProfile"; Correct
import { UserCard } from "../UserCard";import { localHelper } from "./utils/localHelper";Options
Section titled “Options”| Option | Type | Default | Notes |
|---|---|---|---|
allow | string[] | [] | Regex patterns matched case-insensitively against the import source. |
maxDepth | number | 1 | Maximum allowed depth into another component path. |
Related rules
Section titled “Related rules” require-module-level-instantiation Keeps shared runtime objects in one place