Skip to content

Commit

Permalink
build: fix TypeError in prism-eslint-hooks.js (#18209)
Browse files Browse the repository at this point in the history
* fix: TypeError in prism-eslint-hooks.js

* check if `token` is a string
  • Loading branch information
fasttime committed Mar 18, 2024
1 parent 4769c86 commit b91f9dc
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion docs/tools/prism-eslint-hook.js
Expand Up @@ -305,6 +305,10 @@ function installPrismESLintMarkerHook() {
*/
function *splitTokensByLineFeed(tokens) {
for (const token of tokens) {
if (typeof token === "string") {
yield token;
continue;
}

const content = getTokenContent(token);

Expand All @@ -317,7 +321,7 @@ function installPrismESLintMarkerHook() {
continue;
}

if (Array.isArray(token.content) || typeof token.content !== "string") {
if (typeof token.content !== "string") {
token.content = [...splitTokensByLineFeed([token.content].flat())];
}
yield token;
Expand Down

0 comments on commit b91f9dc

Please sign in to comment.