import * as _$eslint from "eslint"; import { Linter, Rule } from "eslint"; //#region src/shared/types.d.ts /** * One boundary entry in user configuration. * * Files resolve to the **deepest** matching `dir` when boundaries nest. */ interface BoundaryConfig { /** * Stable label used in allow/deny lists and diagnostics. * * Convention: match {@link alias} when using alias imports (for example both `'@domain'`). */ identifier: string; /** Directory path under {@link RuleOptions.rootDir} (for example `'domain'` or `'application/internal'`). */ dir: string; /** * Import alias prefix for this boundary (for example `'@domain'`). * * Required when `crossBoundaryStyle` is `'alias'`, or when inference picks alias style for TypeScript files. */ alias?: string; /** * Identifiers this boundary may import from (deny-by-default when used alone). * * Values are other boundaries' {@link identifier} strings. */ allowImportsFrom?: string[]; /** * Identifiers this boundary must not import from (allow-by-default when used alone). * * If both allow and deny lists are present, deny wins on conflicts. */ denyImportsFrom?: string[]; /** * Identifiers allowed for `import type` even when value imports are denied. * * Overrides {@link allowImportsFrom} for type-only imports. */ allowTypeImportsFrom?: string[]; /** * When this nested boundary imports from its parent boundary, choose import spelling. * * See {@link Boundary.nestedPathFormat} for semantics. */ nestedPathFormat?: 'alias' | 'relative' | 'inherit'; /** Per-boundary severity override (defaults to rule severity). */ severity?: 'error' | 'warn'; } /** * Options for barrel-related rules (`no-wildcard-barrel`, `index-sibling-only`). */ interface BarrelFileRuleOptions { /** * Basename of index files to treat as directory interfaces (without extension). * * Must stay `'index'` to match runtime module resolution and `enforce` behavior. */ barrelFileName?: string; } /** * Options for `import-boundaries/enforce`. */ interface RuleOptions { /** * Source root directory containing boundary folders. * * Defaults to `'src'`. */ rootDir?: string; /** Boundary definitions; at least one entry is required. */ boundaries: BoundaryConfig[]; /** * Cross-boundary import spelling style. * * Omit to infer from the linted file extension (TypeScript → `alias`, JavaScript → `absolute`). * * @deprecated `'absolute'` is deprecated and scheduled for removal in v0.9.0; prefer alias imports with matching TS/bundler path mappings. */ crossBoundaryStyle?: 'alias' | 'absolute'; /** Default severity for boundary violations when not overridden per-boundary. */ defaultSeverity?: 'error' | 'warn'; /** * Allow imports whose resolved targets fall outside every configured boundary directory. * * Default `false` reports unknown-boundary imports. */ allowUnknownBoundaries?: boolean; /** * When `false`, skip allow/deny checks but still enforce canonical import paths. * * Useful for tests or gradual rollout. */ enforceBoundaries?: boolean; /** * Skip `enforce` entirely for index files (`index.*`). * * Pair with `index-sibling-only` / `no-wildcard-barrel` to avoid overlapping checks. */ skipIndexFiles?: boolean; /** * Extensions treated as code imports for boundary and path rules. * * Non-code specifiers (assets, styles, query strings) are skipped separately. */ fileExtensions?: string[]; /** * Maximum number of `../` segments allowed before switching to boundary-root style paths. * * Default `1`. */ maxRelativeDepth?: number; /** * Recognise root-relative alias imports like `@/foo` as `/foo`. * * Set to `''` to disable. Default `'@'`. */ rootDirAlias?: string; } //#endregion //#region src/eslintRuleTypes.d.ts /** * Default export shape of this package — for typing `plugins['import-boundaries']`. */ interface ImportBoundariesPlugin { rules: { enforce: Rule.RuleModule; 'no-wildcard-barrel': Rule.RuleModule; 'index-sibling-only': Rule.RuleModule; }; } /** * Typed `rules` keys for this plugin. Use with `satisfies Partial<...>` (or * `Pick`) when composing a `rules` object alongside other plugins. */ interface ImportBoundariesRules { 'import-boundaries/enforce': Linter.RuleEntry<[RuleOptions]>; 'import-boundaries/no-wildcard-barrel': Linter.RuleEntry<[BarrelFileRuleOptions]>; 'import-boundaries/index-sibling-only': Linter.RuleEntry<[BarrelFileRuleOptions]>; } //#endregion //#region src/config.d.ts /** * Define a type-safe boundaries configuration. * This is a pure identity function — it exists solely to provide type inference * and IDE autocompletion when defining your config in a separate TS file. * * @param config - The rule options to type-check * @returns The same config object unchanged */ declare function defineConfig(config: RuleOptions): RuleOptions; /** * Type-check only the `boundaries` array in a file such as `boundaries.ts` * (when the rest of the rule options live in `eslint.config`). * * @param boundaries - The boundary list to validate * @returns The same array, for convenient `export default defineBoundaries([...])` */ declare function defineBoundaries(boundaries: readonly BoundaryConfig[]): BoundaryConfig[]; //#endregion //#region src/index.d.ts declare const _default: { rules: { enforce: _$eslint.Rule.RuleModule; 'no-wildcard-barrel': _$eslint.Rule.RuleModule; 'index-sibling-only': _$eslint.Rule.RuleModule; }; }; //#endregion export { type BarrelFileRuleOptions, type BoundaryConfig, type ImportBoundariesPlugin, type ImportBoundariesRules, type RuleOptions, _default as default, defineBoundaries, defineConfig };