5 of 6 standards met
This PR introduces ESLint rules for Docusaurus best practices. Added Rules no-dynamic-i18n-messages no-untranslated-text prefer-docusaurus-link no-hardcoded-src prefer-ideal-image Features AST-based rule implementation Auto-fix support Unit tests using RuleTester Motivation These rules help enforce best practices and improve i18n consistency.
Repository: facebook/docusaurus. Description: Easy to maintain open source documentation websites. Stars: 63944, Forks: 9747. Primary language: TypeScript. Languages: TypeScript (95.8%), JavaScript (2%), CSS (1.8%), XSLT (0.2%), AppleScript (0.1%). License: MIT. Homepage: https://docusaurus.io Topics: documentation, hacktoberfest, javascript, open-source, react, website. Latest release: v3.9.2 (4mo ago). Open PRs: 60, open issues: 292. Last activity: 1d ago. Community health: 87%. Top contributors: slorber, lex111, endiliey, Josh-Cena, yangshun, JoelMarcey, dependabot[bot], deltice, ericnakagawa, SamChou19815 and others.
TypeScript
Last 12 weeks · 52 commits
Pre-flight checklist [X] I have read the Contributing Guidelines on pull requests. [X] If this is a code change: I have written unit tests and/or added dogfooding pages to fully verify the new behavior. [X] 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. Motivation This PR address the concerns brought up in issue #6472, and enforces the use of @theme/IdealImage component instead of tags. Following feedback from @slorber in previous discussions (#8826, #11416), this rule adopts a tiered approach to minimize false positives and noise: Error Tier: Triggered for . Since the asset is explicitly required, we are certain it is a local file that would benefit from the Ideal Image optimization pipeline. Warning Tier: Triggered for static relative paths (e.g., ) or root-relative paths (). This nudges the user to optimize if the file is indeed local. Silent/Ignored:* External URLs () and protocol-relative links (). Dynamic values (e.g., or ) to avoid annoying users in generic components. SVGs: Since does not support vector formats, these are explicitly ignored to prevent useless warnings. Test Plan I have implemented a comprehensive test suite in covering the following: Valid cases: External HTTPS links, template literals with external prefixes, dynamic props/variables, and files. Invalid cases:** Standard `require()srcsetyarn jest packages/docusaurus-eslint-plugin` with all cases passing. Related issues/PRs Fixes #6472 sub-issue Credits to @Devansu-Yadav: this PR builds on the logic and feedback from #8826. Incorporates feedback from #11416 regarding noise reduction and ambiguity.
Have you read the Contributing Guidelines on issues? [x] I have read the Contributing Guidelines on issues. Description This is all the rage now. Example: https://mintlify.com/docs/quickstart Ideally we could have the same options, or a configurable set of LLMs. Considerations: 1. Need to strip comments and images from final markdown before it's exposed to people. 2. Could either load the whole thing into the built page as data on the copy button, or use the mintlify approach of building a clean .md exposed publicly. Has this been requested on Canny? _No response_ Motivation Getting popular in doc systems. API design _No response_ Have you tried building it? _No response_ Self-service [ ] I'd be willing to contribute this feature to Docusaurus myself.
Pre-flight checklist [x] I have read the Contributing Guidelines on pull requests. [x] 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. Motivation This PR addresses a security vulnerability and code quality issue: Security**: The Algolia search theme was rendering HTML from search results using without proper sanitization. While Algolia's search results are generally trusted, this creates a potential XSS vulnerability if: Malicious content is indexed by Algolia The Algolia index is compromised Search results contain unexpected HTML This PR adds comprehensive HTML sanitization to prevent XSS attacks while preserving search highlighting functionality, and modernizes deprecated JavaScript methods. Test Plan Security Testing Created comprehensive test suite with 14 test cases covering: Safe tag preservation (`onclickonloadonerrorjavascript:data:``bash Run sanitizer tests yarn test htmlSanitizer All 14 tests passing ✓ No TypeScript errors ✓ No ESLint errors ✓
Motivation Our historical syntax is invalid MDX syntax since MDX v2+ (although various MD tools support that syntax for heading ids) This implements an alternative syntax based on comments, and compatible with MDX: For CommonMark, we also support `#{#id}markdown.mdx1Compat.headingIdsdocusaurus write-heading-ids#`) Test Plan CI + unit tests Test links https://deploy-preview-11755--docusaurus-2.netlify.app/