# core/converters/eslint.converter.ts

> 36 lines of code and 7 definitions.

Tree: GovLab Quality
Language: typescript
Layer: processing
Canonical: https://banes-lab.com/anatomy/quality#file-quality-core-converters-eslint-converter-ts
Source text: https://banes-lab.com/source/quality/core/converters/eslint.converter.ts.txt

Listed in [core/converters](https://banes-lab.com/api/source/quality/core/converters.md), after [core/converters/emitter.xml.converter.ts](https://banes-lab.com/source/quality/core/converters/emitter.xml.converter.ts.md) and before [core/converters/exclusions.converter.ts](https://banes-lab.com/source/quality/core/converters/exclusions.converter.ts.md).

## Definitions

- `toRulesRecord` (lexical_declaration, line 6, exported)
- `jsRulesOf` (lexical_declaration, line 40, exported)
- `pluginMap` (lexical_declaration, line 29, exported)
- `namespacesOf` (lexical_declaration, line 26, exported)
- `pluginsFromRecord` (lexical_declaration, line 16, exported)
- `out` (lexical_declaration, line 30, exported)
- `namespace` (lexical_declaration, line 32, exported)

## Contained in

- [core/converters](https://banes-lab.com/anatomy/quality/folder-quality-core-converters.md)

## Uses

- [core/predicates/eslint.predicate.ts](https://banes-lab.com/source/quality/core/predicates/eslint.predicate.ts.md)

## Used by

- [core/factories/eslint.scope.factory.ts](https://banes-lab.com/source/quality/core/factories/eslint.scope.factory.ts.md)
- [core/factories/eslint.setup.factory.ts](https://banes-lab.com/source/quality/core/factories/eslint.setup.factory.ts.md)

## Linked from

- [core/factories](https://banes-lab.com/anatomy/quality/folder-quality-core-factories.md)
- [core/predicates](https://banes-lab.com/anatomy/quality/folder-quality-core-predicates.md)

## Source

```typescript
import type { ESLint, Linter } from "eslint";
import { isPlugin, isRuleEntry } from "#core/predicates/eslint.predicate";
import type { InstalledPlugin } from "#types/eslint.types";
import { TS_PREFIX } from "#configuration/constants/eslint.constants";

export const toRulesRecord = (source: Record<string, unknown>): Linter.RulesRecord => {
    const out: Linter.RulesRecord = {};
    for (const [key, value] of Object.entries(source)) {
        if (isRuleEntry(value)) {
            out[key] = value;
        }
    }
    return out;
};

export const pluginsFromRecord = (source: Record<string, unknown>): Record<string, ESLint.Plugin> => {
    const out: Record<string, ESLint.Plugin> = {};
    for (const [key, value] of Object.entries(source)) {
        if (isPlugin(value)) {
            out[key] = value;
        }
    }
    return out;
};

export const namespacesOf = (entries: InstalledPlugin[]): string[] =>
    entries.map((entry) => entry.record.pluginNamespace).filter((ns): ns is string => typeof ns === "string");

export const pluginMap = (entries: InstalledPlugin[]): Record<string, ESLint.Plugin> => {
    const out: Record<string, ESLint.Plugin> = {};
    for (const entry of entries) {
        const namespace = entry.record.pluginNamespace;
        if (typeof namespace === "string" && isPlugin(entry.plugin)) {
            out[namespace] = entry.plugin;
        }
    }
    return out;
};

export const jsRulesOf = (rules: Linter.RulesRecord): Linter.RulesRecord =>
    Object.fromEntries(Object.entries(rules).filter(([key]) => !key.startsWith(TS_PREFIX)));
```
