no-import-private â
âšī¸ This rule is not included in the recommended rules.
This rule disallows importing modules from private
directories at different hierarchical levels.
The private directory is intended to contain internal implementation that should only be used within its parent directory.
By disallowing imports from a different hierarchy, it promotes proper modularization and encapsulation.
đ§ How to use â
js
// eslint.config.mjs
export default [
{
// ... some configs
rules: {
"cdk/no-import-private": "error",
},
},
];
â Correct Example â
ts
// src/constructs/my-construct.ts
import { MyConstruct } from "./private/my-construct";
â Incorrect Example â
ts
// src/constructs/my-construct.ts
import { MyConstruct } from "../private/my-construct";
import { MyConstruct } from "../my-app/private/my-construct";