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?
- Guarantees every glossary reference points at a definition that actually exists.
- Catches a renamed glossary heading before it leaves a dangling term link.
- Adapts to any project through configurable component name, glossary path, and route base.
Examples
Usage
src/tests/terminology.test.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
| Field | Type | Default | Description |
|---|---|---|---|
contentDirs | string[] | ['docs', 'blog'] | Directories, relative to rootDir, scanned for component usages. |
terminologyPath | string | <rootDir>/docs/quickstart/terminology.mdx | Glossary page (resolved against rootDir) whose headings define the valid-anchor set. |
expectedBase | string | '/docs/quickstart/terminology' | Route every component must equal or prefix with an anchor. |
rootDir | string | process.cwd() | Base directory the content and glossary paths resolve against. |
componentName | string | 'Terminology' | Name of the JSX component to validate. |
enable | 'all' | ToggleKey[] | required | Which checks run. Use 'all' for every check, or a list to freeze a set. |
Toggle Keys
| Toggle Key | Description |
|---|---|
terminology-title-attr-present | Requires each component to declare a title attribute. |
terminology-to-attr-present | Requires each component to declare a to attribute. |
terminology-children-nonempty | Requires each component to wrap non-empty text. |
terminology-to-points-to-base | Requires the to attribute to equal or prefix the expected base. |
terminology-anchor-resolves | Requires the to anchor to match a heading on the glossary page. |
terminology-component-validation | Umbrella 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
terminologyPathto your glossary page to enable the checks. - A differently named component is ignored — Set
componentNameto 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.