# rules/eslint/strings-harness-neutral.eslint.rule.ts

> 50 lines of code and 8 definitions.

Tree: Governance tree
Language: typescript
Canonical: https://banes-lab.com/anatomy/governance#file-governance-rules-eslint-strings-harness-neutral-eslint-rule-ts
Source text: https://banes-lab.com/source/governance/rules/eslint/strings-harness-neutral.eslint.rule.ts.txt

Listed in [rules/eslint](https://banes-lab.com/api/source/governance/rules/eslint.md), after [rules/eslint/strings-diagram-identifiers.eslint.rule.ts](https://banes-lab.com/source/governance/rules/eslint/strings-diagram-identifiers.eslint.rule.ts.md) and before [rules/eslint/strings-lesson-fields.eslint.rule.ts](https://banes-lab.com/source/governance/rules/eslint/strings-lesson-fields.eslint.rule.ts.md).

## Definitions

- `report` (lexical_declaration, line 22, exported)
- `quasiTexts` (lexical_declaration, line 13)
- `templateLiteral` (method_definition, line 35, exported)
- `create` (method_definition, line 18, exported)
- `literal` (method_definition, line 29, exported)
- `STRINGS_SUFFIX` (lexical_declaration, line 11)
- `token` (lexical_declaration, line 23, exported)
- `text` (lexical_declaration, line 30, exported)

## Uses

- [shared/factories/listener.factory.ts](https://banes-lab.com/source/governance/shared/factories/listener.factory.ts.md)
- [shared/selectors/syntax.selector.ts](https://banes-lab.com/source/governance/shared/selectors/syntax.selector.ts.md)

## Records this file checks

- [Platform Independence](https://banes-lab.com/records/architecture/platform-independence.md)

## Source

```typescript
import type { LocalRule, RuleContext, RuleListener } from "../../types/rule.types.ts";
import { literalString, locOf, nodesAt, recordAt, stringIn } from "../../shared/selectors/syntax.selector.ts";
import type { AstNode } from "../../types/syntax.types.ts";
import { HARNESS_TOKENS } from "../../shared/manifests/vocabulary.manifest.ts";
import { basenameOf } from "../../shared/resolvers/anchor.resolver.ts";
import { concernSuffix } from "../../shared/manifests/taxonomy.manifest.ts";
import { defineCheck } from "@govlab/context/check";
import { firstTermIn } from "../../shared/matchers/vocabulary.matcher.ts";
import { listener } from "../../shared/factories/listener.factory.ts";

const STRINGS_SUFFIX = concernSuffix("strings");

const quasiTexts = function quasiTexts(node: AstNode): string[] {
    return nodesAt(node, "quasis").map((part) => stringIn(recordAt(part, "value"), "cooked"));
};

export default {
    create(context: RuleContext): RuleListener {
        if (!basenameOf(context.filename).endsWith(STRINGS_SUFFIX)) {
            return {};
        }
        const report = function report(node: AstNode, text: string): void {
            const token = firstTermIn(text, HARNESS_TOKENS);
            if (token !== null) {
                context.report({ data: { token }, loc: locOf(node), messageId: "harnessToken" });
            }
        };
        return listener({
            literal(view) {
                const text = literalString(view);
                if (text !== null) {
                    report(view, text);
                }
            },
            templateLiteral(view) {
                report(view, quasiTexts(view).join(" "));
            },
        });
    },
    meta: {
        docs: {
            checks: defineCheck({ detects: [], enforces: ["architecture:platform-independence"] }),
            description:
                "A user-visible string names no feature of one harness. Public copy and its samples state semantic operations and slots that a binding resolves to whichever harness runs them, so a tool name, a configuration file, a hook event or a product name of one harness in a strings module locks the published practice to that harness. The registry holds the classified names as data; the rule matches each at word boundaries inside every literal and template quasi of a strings module, code samples included, because a sample is where the lock-in lives.",
        },
        messages: {
            harnessToken:
                "'{{token}}' names a feature of one harness. Restate it as the semantic operation or the slot a binding resolves, and keep the harness name out of user-visible copy; the registry is data, so widening it is a maintainer edit, never a rewrite of this rule.",
        },
        schema: [],
        type: "problem",
    },
} satisfies LocalRule;
```
