Skip to main content

Terminology Suite

Validate glossary components against a source glossary page with registerTerminologySuite.

Summary

  • Scans content directories for glossary component usages and checks each one's attributes.
  • Confirms every component links to the glossary page and resolves to a real anchor on it.
  • Treats the glossary page headings as the valid-anchor set and skips quietly when the page is absent.

Why Use This Suite?

  1. Guarantees every glossary reference points at a definition that actually exists.
  2. Catches a renamed glossary heading before it leaves a dangling term link.
  3. Adapts to any project through configurable component name, glossary path, and route base.

Examples

Usage

src/tests/terminology.test.ts
ts
import { registerTerminologySuite } from '@cbnventures/nova/rules/vitest';
import * as vitest from 'vitest';

registerTerminologySuite({
  vitest,
  enable: 'all',
});

The suite no-ops when the glossary page is absent, so a project without a glossary stays green. Point terminologyPath, expectedBase, and componentName at your own glossary, route, and component when they differ.

Configuration

FieldTypeDefaultDescription
contentDirsstring[]['docs', 'blog']Directories, relative to rootDir, scanned for component usages.
terminologyPathstring<rootDir>/docs/quickstart/terminology.mdxGlossary page (resolved against rootDir) whose headings define the valid-anchor set.
expectedBasestring'/docs/quickstart/terminology'Route every component must equal or prefix with an anchor.
rootDirstringprocess.cwd()Base directory the content and glossary paths resolve against.
componentNamestring'Terminology'Name of the JSX component to validate.
enable'all' | ToggleKey[]requiredWhich checks run. Use 'all' for every check, or a list to freeze a set.

Toggle Keys

Toggle KeyDescription
terminology-title-attr-presentRequires each component to declare a title attribute.
terminology-to-attr-presentRequires each component to declare a to attribute.
terminology-children-nonemptyRequires each component to wrap non-empty text.
terminology-to-points-to-baseRequires the to attribute to equal or prefix the expected base.
terminology-anchor-resolvesRequires the to anchor to match a heading on the glossary page.
terminology-component-validationUmbrella marker: registers one test confirming validation is active (asserts the glossary page exists); no-ops when the page is absent.

Troubleshooting

  • The suite finds nothing to check — The glossary page is absent, so the suite no-ops. Set terminologyPath to your glossary page to enable the checks.
  • A differently named component is ignored — Set componentName to your component so the suite matches it.
  • An anchor fails to resolve — Update the component anchor to match a heading on the glossary page named by terminologyPath.