fix: require name key in each toc.yaml entry#1965
Open
kings9527 wants to merge 1 commit into
Open
Conversation
Implements the lint rule from diplodoc-platform#1400 that requires every toc.yaml item to have a required 'name' key. Changes: - Add checkTocItemNames() in src/core/toc/loader.ts to recursively validate that every toc item has a 'name' key. - Update validateToc() to throw Error when any item is missing 'name', causing the build to fail fast with a clear error message. - Add 'required: [name]' to TocItem schema in schemas/toc-schema.yaml. - Add unit tests covering both direct and nested missing-name scenarios. - Fix existing tests/watch tests that had toc items without 'name' keys to comply with the new requirement. Closes diplodoc-platform#1400
reazy015
requested changes
Jun 2, 2026
Contributor
reazy015
left a comment
There was a problem hiding this comment.
We've updated our infra package. Please rebase your fork to trigger the CI checks.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Every table of contents item must have a human-readable
namefield. Currently, the loader silently accepts items without anamekey, which leads to broken navigation or empty TOC labels at render time.Fixes #1400
Changes
required: ['name']to theTocItemdefinition inschemas/toc-schema.yaml.checkTocItemNames()insrc/core/toc/loader.tsthat recursively validates every item (including nested ones) has anamekey.validateToc()to throwErrorimmediately when any item is missingname, failing the build with a clear message:Invalid toc structure in <path>: N toc item(s) missing required 'name' key.namekey so they comply with the new requirement.Verification
All 1186 tests pass (52 test files).