# types/rule.types.ts

> 25 lines of code and 10 definitions.

Tree: Governance tree
Language: typescript
Layer: infrastructure
Canonical: https://banes-lab.com/anatomy/governance#file-governance-types-rule-types-ts
Source text: https://banes-lab.com/source/governance/types/rule.types.ts.txt

Listed in [types](https://banes-lab.com/api/source/governance/types.md), after [types/manifest.types.ts](https://banes-lab.com/source/governance/types/manifest.types.ts.md) and before [types/sink.types.ts](https://banes-lab.com/source/governance/types/sink.types.ts.md).

## Definitions

- `NodeHandler` (type_alias_declaration, line 5, exported)
- `NodeHandlers` (type_alias_declaration, line 7, exported)
- `RuleContext` (type_alias_declaration, line 9, exported)
- `RuleListener` (type_alias_declaration, line 10, exported)
- `RuleFixer` (type_alias_declaration, line 11, exported)
- `RuleNode` (type_alias_declaration, line 12, exported)
- `LocalRuleMeta` (interface_declaration, line 14, exported)
- `LocalRule` (interface_declaration, line 18, exported)
- `RuleFileShape` (interface_declaration, line 23, exported)
- `RuleObjectShape` (interface_declaration, line 29, exported)

## Source

```typescript
import type { AstNode } from "./syntax.types.ts";
import type { CheckDeclaration } from "@govlab/context";
import type { Rule } from "eslint";

export type NodeHandler = (node: AstNode, raw: Rule.Node) => void;

export type NodeHandlers = Record<string, NodeHandler>;

export type RuleContext = Rule.RuleContext;
export type RuleListener = Rule.RuleListener;
export type RuleFixer = Rule.RuleFixer;
export type RuleNode = Rule.Node;

export interface LocalRuleMeta extends Omit<Rule.RuleMetaData, "docs"> {
    docs: Rule.RuleMetaData["docs"] & { checks: CheckDeclaration; workspaceWide?: boolean };
}

export interface LocalRule {
    meta: LocalRuleMeta;
    create: (context: RuleContext) => RuleListener;
}

export interface RuleFileShape {
    anyNodes: AstNode[];
    guards: AstNode[];
    ruleObjects: AstNode[];
}

export interface RuleObjectShape {
    meta: AstNode | null;
    metaProperty: AstNode | null;
}
```
