Skip to content
Esc

@noctcore/eslint-plugin-architecture

v1.1.010 rules0 recommended6 strict only4 opt-innamespace noctcore-architecture

A bad fit for a codebase organised by technical layer (hooks/, components/, utils/ at the top) rather than by feature, and for a small app where a component folder with five siblings is ceremony.

Folder-per-component, barrels and feature boundaries, anchored on a configurable directory.

Folder structure that nobody enforces decays one convenient shortcut at a time: a barrel that grows a helper function, a component folder missing its test, a feature importing another feature’s internals, a relative import that climbs five parents. These rules make the layout a checked property of the codebase instead of a paragraph in a contributing guide.

It will yell at you about file layout, and several rules read the file system: component-folder-structure wants every <Name>/<Name>.tsx to ship its full sibling set, colocated-test-required wants a test next to each source file it covers. Run ESLint on real file paths, not virtual sources. Every rule anchors on a directory segment (default components) instead of an absolute path, so it behaves the same from the repo root or a package. It is a bad fit for a codebase organised by technical layer (hooks/, components/, utils/ at the top) rather than by feature, and for a small app where a component folder with five siblings is ceremony. colocated-test-required and single-semantic-module ship off because they are opinions many good codebases do not share. file-naming-pattern also ships off: it does nothing until folders and pattern are set.

Install
npm install --save-dev @noctcore/eslint-plugin-architecture @typescript-eslint/parser
# or: bun add -D / pnpm add -D @noctcore/eslint-plugin-architecture @typescript-eslint/parser

The recommended preset turns none of its 10 rules on: each is a house convention or needs options, so the board starts from strict, which enables 6. The rules board below builds the flat config: start from a preset, switch single rules between error and off, and copy the result.

Each rule links to its page, with the options it takes and Incorrect and Correct examples. A good first read is no-cross-feature-imports.

6 of 10 at error

--fixsuggestionsneeds optionstype infoEach switch sets a rule to error or off.

barrel-purity
A barrel (an index.* file with an export … from re-export) must contain only re-exports, never local declarations, side effects, or default-exported values.
strict only
colocated-test-required
A source file matching an include glob must have a colocated *.test.* / *.spec.* sibling on disk.
Needs options
opt-in
component-folder-structure
A component <Name>/<Name>.tsx under <componentRoot>/<feature>/... must have its sibling set (.hooks.ts, .types.ts, .stories.tsx, .test.tsx, index.ts) present on disk.
strict only
file-naming-pattern
In a folder matched by folders, a file's basename must match pattern, a regular expression built from the folder's name.
Needs options
opt-in
filename-matches-export
A file's basename must match its primary export (a default export, or the sole named export).
Editor suggestions
strict only
index-must-reexport-default
A component folder's index.ts must re-export the component default (export { default as <Name> } from './<Name>').
strict only
max-import-depth
A relative import may not climb more than max parent levels (default 3). Autofixed to a path alias when one is configured.
Fixable with --fix
strict only
no-cross-feature-imports
A file in one feature may not import runtime code from another feature. Move shared code to a shared module or a shared feature.
strict only
no-restricted-imports-layered
Import bans declared once as named sets and assigned to file layers, merged per file instead of overridden, covering static imports, re-exports and dynamic import().
Needs options
opt-in
single-semantic-module
Require each module to export only one semantic concern (types, constants, functions, classes, components, hooks, schemas or enums).
opt-in