Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/utils/queries/constants.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
// This is the perma-link within the API docs that reference the Stability Index
export const DOC_API_STABILITY_SECTION_REF_URL =
'documentation.html#stability-index';

export const VALID_JAVASCRIPT_PROPERTY = /^[a-z0-9$_]+$/i;
18 changes: 11 additions & 7 deletions src/utils/queries/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
import { u as createTree } from 'unist-builder';
import { SKIP } from 'unist-util-visit';

import { DOC_API_STABILITY_SECTION_REF_URL } from './constants.mjs';
import {
DOC_API_STABILITY_SECTION_REF_URL,
VALID_JAVASCRIPT_PROPERTY,
} from './constants.mjs';
import {
extractYamlContent,
parseHeadingIntoMetadata,
Expand Down Expand Up @@ -278,15 +281,15 @@ createQueries.UNIST = {
const [node, ...contentNodes] =
list?.children?.[0]?.children?.[0]?.children ?? [];

// Exit if no content nodes
if (!node) {
const possibleProperty = node?.value?.trimStart();

// Exit if no content in node (or if no node exists)
if (!possibleProperty) {
return false;
}

// Check for other starters
if (
node.value?.trimStart().match(createQueries.QUERIES.typedListStarters)
) {
if (possibleProperty.match(createQueries.QUERIES.typedListStarters)) {
return true;
}

Expand All @@ -298,7 +301,8 @@ createQueries.UNIST = {
// Check for inline code + space + type link pattern
if (
node.type === 'inlineCode' &&
contentNodes[0]?.value.trim() === '' &&
possibleProperty.match(VALID_JAVASCRIPT_PROPERTY) &&
contentNodes[0]?.value?.trim() === '' &&
contentNodes[1]?.type === 'link' &&
contentNodes[1]?.children?.[0]?.value?.[0] === '<'
) {
Expand Down
Loading