Skip to content

✨ Add controls for relative link checking and suggestion depth#28

Merged
dvdstelt merged 1 commit into
mainfrom
feature/relative-link-controls
Jun 10, 2026
Merged

✨ Add controls for relative link checking and suggestion depth#28
dvdstelt merged 1 commit into
mainfrom
feature/relative-link-controls

Conversation

@dvdstelt

@dvdstelt dvdstelt commented Jun 5, 2026

Copy link
Copy Markdown
Owner

What

Two new action inputs give finer control over how relative file links are handled.

check-relative (bool, default true)

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 (int 05, default 0)

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:

Link Depth
readme.md, ./readme.md 0 (same folder)
../readme.md, folder/readme.md 1
../../readme.md, ../folder/readme.md 2

0 preserves the previous behaviour (only same-folder links exempt); 1 also exempts ../x.md and folder/x.md. The maximum is 5 (values above clamp with a warning pointing to check-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 (new relativeLinkDepth helper)
  • action.yml, README.md, docs/configuration.md (new "Relative link checking" section), docs/how-it-works.md
  • tests/snapshot.ts + tests/expected-output.txt: new runRelativeControlsTest locking in both levers
  • dist/index.js: rebuilt bundle

Verification

  • npm run typecheck passes
  • npm run test:snapshot passes (existing snapshot lines unchanged; default behaviour preserved)

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.
@dvdstelt dvdstelt merged commit dea27a2 into main Jun 10, 2026
3 checks passed
@dvdstelt dvdstelt deleted the feature/relative-link-controls branch June 10, 2026 07:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant