Skip to content

Commit 765cda1

Browse files
committed
fix(audits): keep JSX template literals intact when skipping MDX inline code
1 parent c4f55aa commit 765cda1

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

‎scripts/check-source-text.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,12 @@ const EXECUTABLE_SCRIPT_TYPES = new Set([
5959
const NEXT_SCRIPT_IMPORT =
6060
/import\s+(?:(\w+)\s*(?:,\s*\{[^}]*\}\s*)?|\{[^}]*\bdefault\s+as\s+(\w+)[^}]*\}\s*)from\s*['"]next\/script['"]/
6161

62-
/** MDX fenced and inline code, which a docs page displays rather than renders. */
63-
const MDX_CODE = /```[\s\S]*?```|`[^`\n]*`/g
62+
/**
63+
* MDX fenced and inline code, which a docs page displays rather than renders. An inline span
64+
* directly inside a JSX expression (`{`…`}`, `=`…, `(`…) is a template literal, not code, so it
65+
* is left intact for the `type` check.
66+
*/
67+
const MDX_CODE = /```[\s\S]*?```|(?<![{=($\w])`[^`\n]*`/g
6468
/** The start of the element's own `type` prop — not a suffix like `data-type`. */
6569
const TYPE_PROP = /(?:^|\s)type\s*=\s*/
6670
/** A statically known `type` value right after {@link TYPE_PROP}. */

0 commit comments

Comments
 (0)