✨ Add controls for relative link checking and suggestion depth#28
Merged
Conversation
Two new action inputs give finer control over how relative file links are handled: - check-relative (default true): when false, relative links (../x.md, ./x.md, folder/x.md) are skipped entirely. Root-relative links and anchors are still checked. - relative-suggestion-depth (default 0, max 5): relative links that traverse this many directory levels or fewer are not offered a root-relative conversion suggestion. 0 preserves the previous behaviour (only same-folder links exempt); 1 also exempts ../x.md and folder/x.md. Broken links are still reported regardless of depth.
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.
What
Two new action inputs give finer control over how relative file links are handled.
check-relative(bool, defaulttrue)When set to
false, relative file links (../x.md,./x.md,folder/x.md) are skipped entirely: no broken-link detection and no conversion suggestions. Root-relative links (/x.md) and anchors are still checked.relative-suggestion-depth(int0–5, default0)Relative links that traverse this many directory levels or fewer are not offered a root-relative conversion suggestion. A link's depth counts each
..(up) or named directory (down) segment, ignoring the filename:readme.md,./readme.md../readme.md,folder/readme.md../../readme.md,../folder/readme.md0preserves the previous behaviour (only same-folder links exempt);1also exempts../x.mdandfolder/x.md. The maximum is5(values above clamp with a warning pointing tocheck-relative: false). This only suppresses the suggestion: genuinely broken relative links are still reported regardless of depth.Why
Links that stay close to the file they live in often "belong together" and move in tandem, so the root-relative conversion nudge is just noise. These levers let a repo silence that nudge by proximity, or opt out of relative-link checking altogether.
Changes
src/types.ts,src/index.ts: input parsing + validation (clamp to max 5)src/check.ts: relative-link skip toggle and depth-gated suggestion (newrelativeLinkDepthhelper)action.yml,README.md,docs/configuration.md(new "Relative link checking" section),docs/how-it-works.mdtests/snapshot.ts+tests/expected-output.txt: newrunRelativeControlsTestlocking in both leversdist/index.js: rebuilt bundleVerification
npm run typecheckpassesnpm run test:snapshotpasses (existing snapshot lines unchanged; default behaviour preserved)