Potential fixes for 2 code quality findings (#19640)
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
9a59059023
commit
314e61a8f3
1 file changed
+9
-3
@@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
@import {languages} from "@codemirror/language-data";
|
@import {languages} from "@codemirror/language-data";
|
||||||
@typedef {typeof languages[number]["name"] | "GraphQl"} LanguageNames
|
@typedef {typeof languages[number]["name"] | "GraphQL"} LanguageNames
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// TODO: we should be able to get this from plugin languages
|
// TODO: we should be able to get this from plugin languages
|
||||||
@@ -38,7 +38,7 @@ function getCodemirrorMode(parser) {
|
|||||||
return "SCSS";
|
return "SCSS";
|
||||||
|
|
||||||
case "graphql":
|
case "graphql":
|
||||||
return "GraphQl";
|
return "GraphQL";
|
||||||
|
|
||||||
case "json":
|
case "json":
|
||||||
case "json5":
|
case "json5":
|
||||||
@@ -74,7 +74,7 @@ function getCodemirrorMode(parser) {
|
|||||||
let languageExtensions;
|
let languageExtensions;
|
||||||
/** @param {LanguageNames} mode */
|
/** @param {LanguageNames} mode */
|
||||||
async function getLanguageExtension(mode) {
|
async function getLanguageExtension(mode) {
|
||||||
if (mode === "GraphQl") {
|
if (mode === "GraphQL") {
|
||||||
const { graphql } = await import("cm6-graphql");
|
const { graphql } = await import("cm6-graphql");
|
||||||
return graphql();
|
return graphql();
|
||||||
}
|
}
|
||||||
@@ -95,6 +95,12 @@ async function getLanguageExtension(mode) {
|
|||||||
const language =
|
const language =
|
||||||
languageExtensions.get(mode) ?? languageExtensions.get("TSX");
|
languageExtensions.get(mode) ?? languageExtensions.get("TSX");
|
||||||
|
|
||||||
|
if (!language) {
|
||||||
|
throw new Error(
|
||||||
|
`No CodeMirror language extension found for "${mode}", and fallback "TSX" is unavailable.`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return await language.loadFunc();
|
return await language.loadFunc();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user