# test.rules/rules/eslint/closure-types-centralized.eslint.rule.test.ts

> 32 lines of code and 0 definitions.

Tree: Codebase Testing
Language: typescript
Canonical: https://banes-lab.com/anatomy/testing#file-testing-test-rules-rules-eslint-closure-types-centralized-eslint-rule-test-ts
Source text: https://banes-lab.com/source/testing/test.rules/rules/eslint/closure-types-centralized.eslint.rule.test.ts.txt

Listed in [test.rules/rules/eslint](https://banes-lab.com/api/source/testing/test.rules/rules/eslint.md), after [test.rules/rules/eslint/closure-tests-centralized.eslint.rule.test.ts](https://banes-lab.com/source/testing/test.rules/rules/eslint/closure-tests-centralized.eslint.rule.test.ts.md) and before [test.rules/rules/eslint/factory-owned-value.eslint.rule.test.ts](https://banes-lab.com/source/testing/test.rules/rules/eslint/factory-owned-value.eslint.rule.test.ts.md).

## Contained in

- [test.rules/rules/eslint](https://banes-lab.com/anatomy/testing/folder-testing-test-rules-rules-eslint.md)

## Source

```typescript
import { describe, expect, it } from "vitest";
import { Linter } from "eslint";
import { absolutePath } from "@ssot/paths";
import rule from "@ssot/govlab/rules/eslint/closure-types-centralized.eslint.rule.ts";
import { sep } from "node:path";

const linter = new Linter();
const config = [
    {
        files: ["**/*.ts"],
        languageOptions: { ecmaVersion: 2025 as const, sourceType: "module" as const },
        plugins: { t: { rules: { r: rule } } },
        rules: { "t/r": "error" as const },
    },
];

const MEMBER = absolutePath("app.member").split(sep).join("/");

const idsFor = function idsFor(file: string): string[] {
    return linter
        .verify("const a = 1;", config, file)
        .map((message) => message.messageId)
        .filter((id): id is string => typeof id === "string");
};

describe("closure-types-centralized", () => {
    it("reports a types file outside the declared bucket", () => {
        expect(idsFor(`${MEMBER}/core/registries/probe.types.ts`)).toStrictEqual(["misplacedTypesFile"]);
    });

    it("accepts a types file inside the bucket", () => {
        expect(idsFor(`${MEMBER}/types/probe.types.ts`)).toStrictEqual([]);
    });

    it("ignores a file that carries no types tag", () => {
        expect(idsFor(`${MEMBER}/core/registries/probe.registry.ts`)).toStrictEqual([]);
    });
});
```
