Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# rule.forbid.barrel-imports-from-typefns

## .what

never import from `'type-fns'` barrel in this repo; always use scoped imports.

## .why

circular dependency hazard:

```
helpful-errors → type-fns (barrel)
↑ ↓
│ re-exports withAssure
│ ↓
└───── withAssure imports HelpfulError
```

the type-fns barrel re-exports `withAssure`, which imports `HelpfulError` from this package. barrel import creates a circular dependency at runtime.

## .pattern

```ts
// forbidden - barrel import triggers cycle
import { isAFunction, isAPromise } from 'type-fns';

// required - scoped imports avoid cycle
import { isAFunction } from 'type-fns/dist/checks/isAFunction';
import { isAPromise } from 'type-fns/dist/checks/isAPromise';
import { omit } from 'type-fns/dist/companions/omit';
```

## .enforcement

barrel import from type-fns = blocker
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
"test:lint:deps": "npx depcheck -c ./.depcheckrc.yml",
"test:lint:biome": "biome check --diagnostic-level=error",
"test:lint:biome:all": "biome check",
"test:lint": "npm run test:lint:biome && npm run test:lint:deps",
"test:lint:imports": "dpdm --no-warning --no-tree --exit-code circular:1 --exclude '^$' 'src/**/*.ts'",
"test:lint": "npm run test:lint:biome && npm run test:lint:imports && npm run test:lint:deps",
"test:unit": "set -eu && jest -c ./jest.unit.config.ts --forceExit --verbose --passWithNoTests $([ -n \"${CI:-}\" ] && echo '--ci') $([ -z \"${THOROUGH:-}\" ] && echo '--changedSince=main') $([ -n \"${RESNAP:-}\" ] && echo '--updateSnapshot')",
"test:integration": "set -eu && jest -c ./jest.integration.config.ts --forceExit --verbose --passWithNoTests $([ -n \"${CI:-}\" ] && echo '--ci') $([ -z \"${THOROUGH:-}\" ] && echo '--changedSince=main') $([ -n \"${RESNAP:-}\" ] && echo '--updateSnapshot')",
"test:acceptance:locally": "set -eu && npm run build && LOCALLY=true jest -c ./jest.acceptance.config.ts --forceExit --verbose --runInBand --passWithNoTests $([ -n \"${RESNAP:-}\" ] && echo '--updateSnapshot')",
Expand All @@ -65,7 +66,6 @@
},
"devDependencies": {
"@biomejs/biome": "2.3.8",
"domain-objects": "0.31.7",
"@commitlint/cli": "19.5.0",
"@commitlint/config-conventional": "19.5.0",
"@swc/core": "1.15.3",
Expand All @@ -82,6 +82,8 @@
"declastruct": "1.7.3",
"declastruct-github": "1.3.0",
"depcheck": "1.4.3",
"domain-objects": "0.31.9",
"dpdm": "4.0.1",
"esbuild-register": "3.6.0",
"husky": "8.0.3",
"jest": "30.2.0",
Expand Down
Loading
Loading