add typescript linting
This commit is contained in:
parent
834afce5fc
commit
77235df31f
@ -11,6 +11,7 @@
|
|||||||
<script
|
<script
|
||||||
src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.43.2/ext-language_tools.js"
|
src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.43.2/ext-language_tools.js"
|
||||||
></script>
|
></script>
|
||||||
|
<script src="https://www.unpkg.com/ace-linters@latest/build/ace-linters.js"></script>
|
||||||
<script src="./src/index.js" type="module"></script>
|
<script src="./src/index.js" type="module"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
30
src/index.js
30
src/index.js
@ -6,8 +6,6 @@ import { CodeRunner } from "./code_runner.js";
|
|||||||
import { AssetEditor } from "./asset_editor.js";
|
import { AssetEditor } from "./asset_editor.js";
|
||||||
import { AssetProvider } from "./asset_provider.js";
|
import { AssetProvider } from "./asset_provider.js";
|
||||||
import { Gamelib } from "./gamelib.js";
|
import { Gamelib } from "./gamelib.js";
|
||||||
import { GamelibCompleter } from "./gamelib_completer.js";
|
|
||||||
import { TextCompleter } from "./text_completer.js";
|
|
||||||
import { ConsoleInput } from "./console_input.js";
|
import { ConsoleInput } from "./console_input.js";
|
||||||
import { ProjectSaveHandler } from "./project_save_handler.js";
|
import { ProjectSaveHandler } from "./project_save_handler.js";
|
||||||
|
|
||||||
@ -15,18 +13,38 @@ const editor = ace.edit("editor");
|
|||||||
editor.setTheme("ace/theme/gruvbox");
|
editor.setTheme("ace/theme/gruvbox");
|
||||||
editor.session.setMode("ace/mode/javascript");
|
editor.session.setMode("ace/mode/javascript");
|
||||||
|
|
||||||
const langTools = ace.require("ace/ext/language_tools");
|
|
||||||
|
|
||||||
editor.setOptions({
|
editor.setOptions({
|
||||||
enableBasicAutocompletion: true,
|
enableBasicAutocompletion: true,
|
||||||
enableLiveAutocompletion: true,
|
enableLiveAutocompletion: true,
|
||||||
copyWithEmptySelection: true,
|
copyWithEmptySelection: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
langTools.setCompleters([new GamelibCompleter(), new TextCompleter()]);
|
|
||||||
|
|
||||||
editor.setValue(sessionStorage.getItem("code") ?? editor.getValue(), -1);
|
editor.setValue(sessionStorage.getItem("code") ?? editor.getValue(), -1);
|
||||||
|
|
||||||
|
const languageProvider = LanguageProvider.fromCdn(
|
||||||
|
"https://www.unpkg.com/ace-linters@latest/build",
|
||||||
|
undefined,
|
||||||
|
{ typescript: true },
|
||||||
|
);
|
||||||
|
languageProvider.registerEditor(editor);
|
||||||
|
languageProvider.setGlobalOptions("typescript", {
|
||||||
|
extraLibs: {
|
||||||
|
"gamelib.js": {
|
||||||
|
content: await (await fetch("/src/gamelib.js")).text(),
|
||||||
|
version: 1,
|
||||||
|
},
|
||||||
|
"karlkoder.js": {
|
||||||
|
content: `
|
||||||
|
import { GamelibAdapter } from "./gamelib.js";
|
||||||
|
declare global {
|
||||||
|
const karlkoder: { lib: () => GamelibAdapter }
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
version: 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
const playgroundConsole = new PlaygroundConsole(
|
const playgroundConsole = new PlaygroundConsole(
|
||||||
document.querySelector("#console-code"),
|
document.querySelector("#console-code"),
|
||||||
editor,
|
editor,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user