Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edit the absolute link linter #126

Merged
merged 1 commit into from
Jan 31, 2025
Merged

Conversation

ptgott
Copy link
Contributor

@ptgott ptgott commented Jan 31, 2025

Allow JavaScript code as the value of the href attribute. This allows us to import assets as MDX modules so we can refer to the asset paths in HTML tags. Otherwise, the linter encounters a runtime exception and fails even if there is a comment that ignores messages from the linter.

An example of the linter failing is gravitational/teleport#51193, which imports a bot avatar logo as a module so users can download it.

@ptgott ptgott requested a review from avatus January 31, 2025 19:32
Allow JavaScript code as the value of the `href` attribute. This allows
us to import assets as MDX modules so we can refer to the asset paths in
HTML tags. Otherwise, the linter encounters a runtime exception and
fails even if there is a comment that ignores messages from the linter.

An example of the linter failing is gravitational/teleport#51193, which
imports a bot avatar logo as a module so users can download it.
Copy link

github-actions bot commented Jan 31, 2025

Amplify deployment status

Branch Commit Job ID Status Preview Updated (UTC)
paul.gottschling/2025-01-31-href 1a3bad9 6 ⏳PENDING paul-gottschling-2025-01-31-href 2025-01-31 19:17:19

@ptgott ptgott force-pushed the paul.gottschling/2025-01-31-href branch from aae2c4e to 1a3bad9 Compare January 31, 2025 19:33
Comment on lines 26 to 32
const isAnAbsoluteDocsLink = (href: string): boolean => {
// The href is not a string value, and is likely an AST node object. Skip
// the absolute link check.
if (typeof href != "string") {
return false;
}
return (
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if typescript is doing its job, this should only be able to be called with a string anyway. but, i suppose it doesnt hurt to be extra safe

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if typescript is doing its job, this should only be able to be called with a string anyway. but, i suppose it doesnt hurt to be extra safe

👍 For some reason, TypeScript is letting remark call the link linter on non-strings, I guess because it doesn't check the site where remark calls its plugins.

@ptgott ptgott merged commit ec23b90 into main Jan 31, 2025
5 checks passed
@ptgott ptgott deleted the paul.gottschling/2025-01-31-href branch January 31, 2025 20:08
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.

2 participants