Skip to content

feat(docusaurus-types): Add UnusedDirective: 'throw' for markdown #11079

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

Closed
wants to merge 1 commit into from

Conversation

heysujal
Copy link
Contributor

@heysujal heysujal commented Apr 8, 2025

Pre-flight checklist

  • I have read the Contributing Guidelines on pull requests.
  • [] If this is a code change: I have written unit tests and/or added dogfooding pages to fully verify the new behavior.
  • [] If this is a new API or substantial change: the PR has an accompanying issue (closes #0000) and the maintainers have approved on my working plan.

Closes: #10674

Motivation

This PR adds a directive which can be added to config to throw error if there are unused directive in the markdown. At the moment we have ability to only show warnings for it.
#9394

Test Plan

I am trying to add the same config in example classic and while doing so I am getting this error.
I don't think I need to use customFields here

image

Test links

Deploy preview: https://deploy-preview-_____--docusaurus-2.netlify.app/

Related issues/PRs

@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Apr 8, 2025
Copy link

netlify bot commented Apr 8, 2025

[V2]

Built without sensitive environment variables

Name Link
🔨 Latest commit 5ff6eda
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/67f58e52b93c1d00080ebff3
😎 Deploy Preview https://deploy-preview-11079--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

github-actions bot commented Apr 8, 2025

⚡️ Lighthouse report for the deploy preview of this PR

URL Performance Accessibility Best Practices SEO Report
/ 🔴 38 🟢 98 🟢 100 🟢 100 Report
/docs/installation 🔴 48 🟢 97 🟢 100 🟢 100 Report
/docs/category/getting-started 🟠 72 🟢 100 🟢 100 🟠 86 Report
/blog 🟠 60 🟢 96 🟢 100 🟠 86 Report
/blog/preparing-your-site-for-docusaurus-v3 🔴 45 🟢 92 🟢 100 🟢 100 Report
/blog/tags/release 🟠 63 🟢 96 🟢 100 🟠 86 Report
/blog/tags 🟠 69 🟢 100 🟢 100 🟠 86 Report

@heysujal heysujal marked this pull request as draft April 9, 2025 03:31
Copy link
Collaborator

@slorber slorber left a comment

Choose a reason for hiding this comment

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

I'm not sure what you are trying to do 😅 but adding TS types is not enough to implement this feature, you have to also use JS to implement the behavior we want, ensure the new config attribute is properly validated (configValidation.ts), add unit tests for this new feature

Comment on lines +16 to +20
siteConfig: {
markdown: {
onUnusedDirective: 'throw'
}
},
Copy link
Collaborator

Choose a reason for hiding this comment

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

example sites are generated and shouldn't be modified

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added this to test my changes. I will remove these eventually. I was looking for help with testing my changes for the screenshot I have attached.

Copy link
Collaborator

Choose a reason for hiding this comment

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

You can test your changes on our own website in website/docusaurus.config.ts

@@ -19,6 +19,10 @@ export type ReportingSeverity = 'ignore' | 'log' | 'warn' | 'throw';

export type RouterType = 'browser' | 'hash';

export type SiteConfig = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We already have a DocusaurusConfig type and MarkdownConfig type

@heysujal heysujal closed this Apr 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a siteConfig.markdown.onUnusedDirective: 'throw' option
3 participants