# codemods/entrypoints/location.entrypoint.ts

> 37 lines of code and 4 definitions.

Tree: Governance tree
Language: typescript
Layer: runtime
Canonical: https://banes-lab.com/anatomy/governance#file-governance-codemods-entrypoints-location-entrypoint-ts
Source text: https://banes-lab.com/source/governance/codemods/entrypoints/location.entrypoint.ts.txt

Listed in [codemods/entrypoints](https://banes-lab.com/api/source/governance/codemods/entrypoints.md), after [codemods/entrypoints/literal.entrypoint.ts](https://banes-lab.com/source/governance/codemods/entrypoints/literal.entrypoint.ts.md) and before [codemods/entrypoints/specifier.entrypoint.ts](https://banes-lab.com/source/governance/codemods/entrypoints/specifier.entrypoint.ts.md).

## Definitions

- `RULE_ID` (lexical_declaration, line 8)
- `SSOT_IMPORT` (lexical_declaration, line 9)
- `buildEdits` (lexical_declaration, line 11)
- `byFile` (lexical_declaration, line 12)

## Records this file checks

- [Single Source of Truth](https://banes-lab.com/records/architecture/single-source-of-truth.md)
- [Hardcoded Configuration](https://banes-lab.com/records/architecture/hardcoded-configuration.md)

## Source

```typescript
import { CODEMOD_TSCONFIGS } from "../selectors/program.selector.ts";
import type { Edit } from "../../types/codemod.types.ts";
import type { LocationFinding } from "../../types/analyzer.types.ts";
import { applyCodemod } from "../selectors/codemod.selector.ts";
import { collectLocationFindings } from "../analyzers/location.analyzer.ts";
import { defineCheck } from "@govlab/context/check";

const RULE_ID = "closure-paths-via-ssot";
const SSOT_IMPORT = 'import { relativePath } from "@ssot/paths";\n';

const buildEdits = function buildEdits(findings: readonly LocationFinding[]): Map<string, Edit[]> {
    const byFile = new Map<string, Edit[]>();
    for (const finding of findings) {
        byFile.set(finding.file, [
            ...(byFile.get(finding.file) ?? []),
            { end: finding.end, replacement: finding.to, start: finding.start },
        ]);
    }
    for (const [file, edits] of byFile) {
        if (findings.some((finding) => finding.file === file && finding.needsImport)) {
            byFile.set(file, [{ end: 0, replacement: SSOT_IMPORT, start: 0 }, ...edits]);
        }
    }
    return byFile;
};

applyCodemod({
    appliedNoun: "hardcoded workspace location(s) resolved through the paths SSOT",
    blockedMessage: (finding) => finding.reason ?? "",
    checks: defineCheck({
        detects: ["architecture:hardcoded-configuration"],
        enforces: ["architecture:single-source-of-truth"],
    }),
    editsByFile: buildEdits,
    findings: collectLocationFindings(),
    gateOnBlocked: false,
    label: (finding) => `"${finding.from}" → ${finding.to}`,
    programCount: CODEMOD_TSCONFIGS.length,
    ruleId: RULE_ID,
});
```
