structlint

raw JSON →
1.0.0-beta.1 verified Fri May 01 auth: no javascript

Lint your project structure against architecture rules. Currently at version 1.0.0-beta.1 with no stable release yet and uncertain release cadence. Defines allowed and disallowed imports per directory using glob patterns in .structlintrc configs. Differentiates by enabling per-folder configs and recursive linting, acting as an 'ESLint for folder structure'.

error structlint: command not found
cause Global install not done or not in PATH.
fix
Run npx structlint instead, or install globally: npm install -g structlint
error TypeError: Cannot read property 'structure' of undefined
cause Missing or malformed .structlintrc file.
fix
Create a .structlintrc file with a 'structure' array.
gotcha Beta version: API may change in future releases.
fix Pin version and test before upgrading.
gotcha Configs in subdirectories are relative to their own location.
fix Always use paths relative to the .structlintrc file location.
gotcha Recursive linting is enabled by default; may cause performance issues on large projects.
fix Set recursive: false in config if only top-level is needed.
npm install structlint
yarn add structlint
pnpm add structlint

Installs structlint, creates a config disallowing tests imports in src/, then runs lint.

npm install --save-dev structlint
echo '{"structure":[{"path":"./src","disallowedImports":["./tests/**/*"]}]}' > .structlintrc
mkdir -p src tests
npx structlint