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";
|
||||
@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
|
||||
@@ -38,7 +38,7 @@ function getCodemirrorMode(parser) {
|
||||
return "SCSS";
|
||||
|
||||
case "graphql":
|
||||
return "GraphQl";
|
||||
return "GraphQL";
|
||||
|
||||
case "json":
|
||||
case "json5":
|
||||
@@ -74,7 +74,7 @@ function getCodemirrorMode(parser) {
|
||||
let languageExtensions;
|
||||
/** @param {LanguageNames} mode */
|
||||
async function getLanguageExtension(mode) {
|
||||
if (mode === "GraphQl") {
|
||||
if (mode === "GraphQL") {
|
||||
const { graphql } = await import("cm6-graphql");
|
||||
return graphql();
|
||||
}
|
||||
@@ -95,6 +95,12 @@ async function getLanguageExtension(mode) {
|
||||
const language =
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user