# test.govlab/quality/core/predicates/eslint.predicate.test.ts

> 36 lines of code and 0 definitions.

Tree: Codebase Testing
Language: typescript
Canonical: https://banes-lab.com/anatomy/testing#file-testing-test-govlab-quality-core-predicates-eslint-predicate-test-ts
Source text: https://banes-lab.com/source/testing/test.govlab/quality/core/predicates/eslint.predicate.test.ts.txt

Listed in [test.govlab/quality/core/predicates](https://banes-lab.com/api/source/testing/test.govlab/quality/core/predicates.md), after [test.govlab/quality/core/predicates/css.predicate.test.ts](https://banes-lab.com/source/testing/test.govlab/quality/core/predicates/css.predicate.test.ts.md) and before [test.govlab/quality/core/predicates/failure.predicate.test.ts](https://banes-lab.com/source/testing/test.govlab/quality/core/predicates/failure.predicate.test.ts.md).

## Contained in

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

## Source

```typescript
import { expect, test } from "vitest";
import {
    inHostScope,
    isCorePlugin,
    isParser,
    isPlugin,
    isRuleEntry,
    isRuleModule,
    underAny,
} from "@govlab/quality/core/predicates/eslint.predicate.ts";
import type { ScopeCarrier } from "@govlab/quality/types/eslint.types.ts";

const contextFor = function contextFor(filename: string, layout: Record<string, string[]>): ScopeCarrier {
    return { filename, settings: { govlab: { layout } } };
};

test("underAny matches a fragment of the linted filename and refuses an empty fragment list", () => {
    const context = contextFor("src/app/page.ts", {});
    expect(underAny(context, ["/app/"])).toBe(true);
    expect(underAny(context, [])).toBe(false);
    expect(underAny(context)).toBe(false);
});

test("inHostScope holds under a frontend marker unless a backend marker also matches", () => {
    const layout = { backendMarkers: ["/server/"], frontendMarkers: ["/app/"] };
    expect(inHostScope(contextFor("src/app/page.ts", layout))).toBe(true);
    expect(inHostScope(contextFor("src/app/server/page.ts", layout))).toBe(false);
    expect(inHostScope(contextFor("src/lib/page.ts", layout))).toBe(false);
});

test("the module guards recognize plugins, parsers, rule entries and core plugins", () => {
    expect(isPlugin({})).toBe(true);
    expect(isParser(null)).toBe(false);
    expect(isRuleEntry("error")).toBe(true);
    expect(isRuleEntry({})).toBe(false);
    expect(isCorePlugin("@govlab/quality/eslint-plugin")).toBe(true);
    expect(isCorePlugin("eslint-plugin-sonarjs")).toBe(false);
    expect(isRuleModule({ create: (): Record<string, never> => ({}) })).toBe(true);
    expect(isRuleModule({ meta: {} })).toBe(false);
});
```
