Start to enable default javscript/typescript lint rules

This enables the recommended rules useConst and useImportType
This commit is contained in:
Nigel Breslaw 2024-09-12 16:08:52 +02:00 committed by GitHub
parent 8d9c041aa4
commit 2bee820ccf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
25 changed files with 197 additions and 185 deletions

View file

@ -11,11 +11,11 @@ const dirname = path.dirname(fileURLToPath(import.meta.url));
// loadFile api // loadFile api
test("loadFile", (t) => { test("loadFile", (t) => {
let demo = loadFile(path.join(dirname, "resources/test.slint")) as any; const demo = loadFile(path.join(dirname, "resources/test.slint")) as any;
let test = new demo.Test(); const test = new demo.Test();
t.is(test.check, "Test"); t.is(test.check, "Test");
let errorPath = path.join(dirname, "resources/error.slint"); const errorPath = path.join(dirname, "resources/error.slint");
const error = t.throws( const error = t.throws(
() => { () => {
@ -63,11 +63,11 @@ test("loadFile", (t) => {
}); });
test("loadFile constructor parameters", (t) => { test("loadFile constructor parameters", (t) => {
let demo = loadFile( const demo = loadFile(
path.join(dirname, "resources/test-constructor.slint"), path.join(dirname, "resources/test-constructor.slint"),
) as any; ) as any;
let hello = ""; let hello = "";
let test = new demo.Test({ const test = new demo.Test({
say_hello: function () { say_hello: function () {
hello = "hello"; hello = "hello";
}, },
@ -82,7 +82,7 @@ test("loadFile constructor parameters", (t) => {
test("loadFile component instances and modules are sealed", (t) => { test("loadFile component instances and modules are sealed", (t) => {
"use strict"; "use strict";
let demo = loadFile(path.join(dirname, "resources/test.slint")) as any; const demo = loadFile(path.join(dirname, "resources/test.slint")) as any;
t.throws( t.throws(
() => { () => {
@ -91,7 +91,7 @@ test("loadFile component instances and modules are sealed", (t) => {
{ instanceOf: TypeError }, { instanceOf: TypeError },
); );
let test = new demo.Test(); const test = new demo.Test();
t.is(test.check, "Test"); t.is(test.check, "Test");
t.throws( t.throws(
@ -108,8 +108,8 @@ test("loadSource", (t) => {
out property <string> check: "Test"; out property <string> check: "Test";
}`; }`;
const path = "api.spec.ts"; const path = "api.spec.ts";
let demo = loadSource(source, path) as any; const demo = loadSource(source, path) as any;
let test = new demo.Test(); const test = new demo.Test();
t.is(test.check, "Test"); t.is(test.check, "Test");
const errorSource = `export component Error { const errorSource = `export component Error {
@ -166,9 +166,9 @@ test("loadSource constructor parameters", (t) => {
in-out property <string> check; in-out property <string> check;
}`; }`;
const path = "api.spec.ts"; const path = "api.spec.ts";
let demo = loadSource(source, path) as any; const demo = loadSource(source, path) as any;
let hello = ""; let hello = "";
let test = new demo.Test({ const test = new demo.Test({
say_hello: function () { say_hello: function () {
hello = "hello"; hello = "hello";
}, },
@ -187,7 +187,7 @@ test("loadSource component instances and modules are sealed", (t) => {
out property <string> check: "Test"; out property <string> check: "Test";
}`; }`;
const path = "api.spec.ts"; const path = "api.spec.ts";
let demo = loadSource(source, path) as any; const demo = loadSource(source, path) as any;
t.throws( t.throws(
() => { () => {
@ -196,7 +196,7 @@ test("loadSource component instances and modules are sealed", (t) => {
{ instanceOf: TypeError }, { instanceOf: TypeError },
); );
let test = new demo.Test(); const test = new demo.Test();
t.is(test.check, "Test"); t.is(test.check, "Test");
t.throws( t.throws(

View file

@ -6,7 +6,7 @@ import test from "ava";
import { private_api } from "../index.js"; import { private_api } from "../index.js";
test("get/set include paths", (t) => { test("get/set include paths", (t) => {
let compiler = new private_api.ComponentCompiler(); const compiler = new private_api.ComponentCompiler();
t.is(compiler.includePaths.length, 0); t.is(compiler.includePaths.length, 0);
@ -20,7 +20,7 @@ test("get/set include paths", (t) => {
}); });
test("get/set library paths", (t) => { test("get/set library paths", (t) => {
let compiler = new private_api.ComponentCompiler(); const compiler = new private_api.ComponentCompiler();
compiler.libraryPaths = { compiler.libraryPaths = {
"libfile.slint": "third_party/libfoo/ui/lib.slint", "libfile.slint": "third_party/libfoo/ui/lib.slint",
@ -34,7 +34,7 @@ test("get/set library paths", (t) => {
}); });
test("get/set style", (t) => { test("get/set style", (t) => {
let compiler = new private_api.ComponentCompiler(); const compiler = new private_api.ComponentCompiler();
t.is(compiler.style, null); t.is(compiler.style, null);
@ -43,8 +43,8 @@ test("get/set style", (t) => {
}); });
test("get/set build from source", (t) => { test("get/set build from source", (t) => {
let compiler = new private_api.ComponentCompiler(); const compiler = new private_api.ComponentCompiler();
let definition = compiler.buildFromSource(`export component App {}`, ""); const definition = compiler.buildFromSource(`export component App {}`, "");
t.not(definition.App, null); t.not(definition.App, null);
t.is(definition.App!.name, "App"); t.is(definition.App!.name, "App");
}); });
@ -68,8 +68,8 @@ test("constructor error ComponentDefinition and ComponentInstance", (t) => {
}); });
test("properties ComponentDefinition", (t) => { test("properties ComponentDefinition", (t) => {
let compiler = new private_api.ComponentCompiler(); const compiler = new private_api.ComponentCompiler();
let definition = compiler.buildFromSource( const definition = compiler.buildFromSource(
`export struct Struct {} `export struct Struct {}
export component App { export component App {
in-out property <bool> bool-property; in-out property <bool> bool-property;
@ -86,7 +86,7 @@ test("properties ComponentDefinition", (t) => {
); );
t.not(definition.App, null); t.not(definition.App, null);
let properties = definition.App!.properties; const properties = definition.App!.properties;
t.is(properties.length, 9); t.is(properties.length, 9);
properties.sort((a, b) => { properties.sort((a, b) => {
@ -125,8 +125,8 @@ test("properties ComponentDefinition", (t) => {
}); });
test("callbacks ComponentDefinition", (t) => { test("callbacks ComponentDefinition", (t) => {
let compiler = new private_api.ComponentCompiler(); const compiler = new private_api.ComponentCompiler();
let definition = compiler.buildFromSource( const definition = compiler.buildFromSource(
` `
export component App { export component App {
callback first-callback(); callback first-callback();
@ -136,7 +136,7 @@ test("callbacks ComponentDefinition", (t) => {
); );
t.not(definition.App, null); t.not(definition.App, null);
let callbacks = definition.App!.callbacks; const callbacks = definition.App!.callbacks;
t.is(callbacks.length, 2); t.is(callbacks.length, 2);
callbacks.sort(); callbacks.sort();
@ -146,8 +146,8 @@ test("callbacks ComponentDefinition", (t) => {
}); });
test("globalProperties ComponentDefinition", (t) => { test("globalProperties ComponentDefinition", (t) => {
let compiler = new private_api.ComponentCompiler(); const compiler = new private_api.ComponentCompiler();
let definition = compiler.buildFromSource( const definition = compiler.buildFromSource(
`export struct Struct {} `export struct Struct {}
export global TestGlobal { export global TestGlobal {
@ -171,7 +171,7 @@ test("globalProperties ComponentDefinition", (t) => {
t.is(definition.App!.globalProperties("NonExistent"), null); t.is(definition.App!.globalProperties("NonExistent"), null);
let properties = definition.App!.globalProperties("TestGlobal"); const properties = definition.App!.globalProperties("TestGlobal");
t.not(properties, null); t.not(properties, null);
t.is(properties!.length, 9); t.is(properties!.length, 9);
@ -212,8 +212,8 @@ test("globalProperties ComponentDefinition", (t) => {
}); });
test("globalCallbacks ComponentDefinition", (t) => { test("globalCallbacks ComponentDefinition", (t) => {
let compiler = new private_api.ComponentCompiler(); const compiler = new private_api.ComponentCompiler();
let definition = compiler.buildFromSource( const definition = compiler.buildFromSource(
` `
export global TestGlobal { export global TestGlobal {
callback first-callback(); callback first-callback();
@ -227,7 +227,7 @@ test("globalCallbacks ComponentDefinition", (t) => {
t.is(definition.App!.globalCallbacks("NonExistent"), null); t.is(definition.App!.globalCallbacks("NonExistent"), null);
let callbacks = definition.App!.globalCallbacks("TestGlobal"); const callbacks = definition.App!.globalCallbacks("TestGlobal");
t.not(callbacks, null); t.not(callbacks, null);
t.is(callbacks!.length, 2); t.is(callbacks!.length, 2);
@ -238,7 +238,7 @@ test("globalCallbacks ComponentDefinition", (t) => {
}); });
test("compiler diagnostics", (t) => { test("compiler diagnostics", (t) => {
let compiler = new private_api.ComponentCompiler(); const compiler = new private_api.ComponentCompiler();
t.deepEqual( t.deepEqual(
compiler.buildFromSource( compiler.buildFromSource(
`export component App { `export component App {
@ -261,8 +261,8 @@ test("compiler diagnostics", (t) => {
}); });
test("non-existent properties and callbacks", (t) => { test("non-existent properties and callbacks", (t) => {
let compiler = new private_api.ComponentCompiler(); const compiler = new private_api.ComponentCompiler();
let definition = compiler.buildFromSource( const definition = compiler.buildFromSource(
` `
export component App { export component App {
@ -271,7 +271,7 @@ test("non-existent properties and callbacks", (t) => {
); );
t.not(definition.App, null); t.not(definition.App, null);
let instance = definition.App!.create(); const instance = definition.App!.create();
t.not(instance, null); t.not(instance, null);
const prop_err = t.throws(() => { const prop_err = t.throws(() => {

View file

@ -32,8 +32,8 @@ test.serial("merged event loops with networking", async (t) => {
await runEventLoop(() => { await runEventLoop(() => {
const server = http.createServer(listener); const server = http.createServer(listener);
server.listen(async () => { server.listen(async () => {
let host = "localhost"; const host = "localhost";
let port = (server.address() as any).port; const port = (server.address() as any).port;
console.log(`server ready at ${host}:${port}`); console.log(`server ready at ${host}:${port}`);
(fetch as any)(`http://${host}:${port}/`) (fetch as any)(`http://${host}:${port}/`)
@ -55,8 +55,8 @@ test.serial("merged event loops with networking", async (t) => {
test.serial( test.serial(
"quit event loop on last window closed with callback", "quit event loop on last window closed with callback",
async (t) => { async (t) => {
let compiler = new private_api.ComponentCompiler(); const compiler = new private_api.ComponentCompiler();
let definition = compiler.buildFromSource( const definition = compiler.buildFromSource(
` `
export component App inherits Window { export component App inherits Window {
@ -67,7 +67,7 @@ test.serial(
); );
t.not(definition.App, null); t.not(definition.App, null);
let instance = definition.App!.create() as any; const instance = definition.App!.create() as any;
t.not(instance, null); t.not(instance, null);
instance.window().show(); instance.window().show();

View file

@ -6,8 +6,8 @@ import test from "ava";
import { private_api } from "../index.js"; import { private_api } from "../index.js";
test("get/set global properties", (t) => { test("get/set global properties", (t) => {
let compiler = new private_api.ComponentCompiler(); const compiler = new private_api.ComponentCompiler();
let definition = compiler.buildFromSource( const definition = compiler.buildFromSource(
` `
export global Global { in-out property <string> name: "Initial"; } export global Global { in-out property <string> name: "Initial"; }
export component App {}`, export component App {}`,
@ -15,7 +15,7 @@ test("get/set global properties", (t) => {
); );
t.not(definition.App, null); t.not(definition.App, null);
let instance = definition.App!.create(); const instance = definition.App!.create();
t.not(instance, null); t.not(instance, null);
t.is(instance!.getGlobalProperty("Global", "name"), "Initial"); t.is(instance!.getGlobalProperty("Global", "name"), "Initial");
@ -85,8 +85,8 @@ test("get/set global properties", (t) => {
}); });
test("invoke global callback", (t) => { test("invoke global callback", (t) => {
let compiler = new private_api.ComponentCompiler(); const compiler = new private_api.ComponentCompiler();
let definition = compiler.buildFromSource( const definition = compiler.buildFromSource(
` `
export struct Person { export struct Person {
name: string name: string
@ -114,7 +114,7 @@ test("invoke global callback", (t) => {
); );
t.not(definition.App, null); t.not(definition.App, null);
let instance = definition.App!.create(); const instance = definition.App!.create();
t.not(instance, null); t.not(instance, null);
t.throws( t.throws(

View file

@ -12,14 +12,14 @@ const filename = fileURLToPath(import.meta.url);
const dirname = path.dirname(filename); const dirname = path.dirname(filename);
test("get/set string properties", (t) => { test("get/set string properties", (t) => {
let compiler = new private_api.ComponentCompiler(); const compiler = new private_api.ComponentCompiler();
let definition = compiler.buildFromSource( const definition = compiler.buildFromSource(
`export component App { in-out property <string> name: "Initial"; }`, `export component App { in-out property <string> name: "Initial"; }`,
"", "",
); );
t.not(definition.App, null); t.not(definition.App, null);
let instance = definition.App!.create(); const instance = definition.App!.create();
t.not(instance, null); t.not(instance, null);
t.is(instance!.getProperty("name"), "Initial"); t.is(instance!.getProperty("name"), "Initial");
@ -49,8 +49,8 @@ test("get/set string properties", (t) => {
}); });
test("get/set number properties", (t) => { test("get/set number properties", (t) => {
let compiler = new private_api.ComponentCompiler(); const compiler = new private_api.ComponentCompiler();
let definition = compiler.buildFromSource( const definition = compiler.buildFromSource(
` `
export component App { export component App {
in-out property <float> age: 42; in-out property <float> age: 42;
@ -59,7 +59,7 @@ test("get/set number properties", (t) => {
); );
t.not(definition.App, null); t.not(definition.App, null);
let instance = definition.App!.create(); const instance = definition.App!.create();
t.not(instance, null); t.not(instance, null);
t.is(instance!.getProperty("age"), 42); t.is(instance!.getProperty("age"), 42);
@ -89,14 +89,14 @@ test("get/set number properties", (t) => {
}); });
test("get/set bool properties", (t) => { test("get/set bool properties", (t) => {
let compiler = new private_api.ComponentCompiler(); const compiler = new private_api.ComponentCompiler();
let definition = compiler.buildFromSource( const definition = compiler.buildFromSource(
`export component App { in-out property <bool> ready: true; }`, `export component App { in-out property <bool> ready: true; }`,
"", "",
); );
t.not(definition.App, null); t.not(definition.App, null);
let instance = definition.App!.create(); const instance = definition.App!.create();
t.not(instance, null); t.not(instance, null);
t.is(instance!.getProperty("ready"), true); t.is(instance!.getProperty("ready"), true);
@ -126,8 +126,8 @@ test("get/set bool properties", (t) => {
}); });
test("set struct properties", (t) => { test("set struct properties", (t) => {
let compiler = new private_api.ComponentCompiler(); const compiler = new private_api.ComponentCompiler();
let definition = compiler.buildFromSource( const definition = compiler.buildFromSource(
` `
export struct Player { export struct Player {
name: string, name: string,
@ -146,7 +146,7 @@ test("set struct properties", (t) => {
); );
t.not(definition.App, null); t.not(definition.App, null);
let instance = definition.App!.create(); const instance = definition.App!.create();
t.not(instance, null); t.not(instance, null);
t.deepEqual(instance!.getProperty("player"), { t.deepEqual(instance!.getProperty("player"), {
@ -190,8 +190,8 @@ test("set struct properties", (t) => {
}); });
test("get/set image properties", async (t) => { test("get/set image properties", async (t) => {
let compiler = new private_api.ComponentCompiler(); const compiler = new private_api.ComponentCompiler();
let definition = compiler.buildFromSource( const definition = compiler.buildFromSource(
` `
export component App { export component App {
in-out property <image> image: @image-url("resources/rgb.png"); in-out property <image> image: @image-url("resources/rgb.png");
@ -202,16 +202,16 @@ test("get/set image properties", async (t) => {
); );
t.not(definition.App, null); t.not(definition.App, null);
let instance = definition.App!.create(); const instance = definition.App!.create();
t.not(instance, null); t.not(instance, null);
let slintImage = instance!.getProperty("image"); const slintImage = instance!.getProperty("image");
if (t.true(slintImage instanceof private_api.SlintImageData)) { if (t.true(slintImage instanceof private_api.SlintImageData)) {
t.deepEqual((slintImage as private_api.SlintImageData).width, 64); t.deepEqual((slintImage as private_api.SlintImageData).width, 64);
t.deepEqual((slintImage as private_api.SlintImageData).height, 64); t.deepEqual((slintImage as private_api.SlintImageData).height, 64);
t.true((slintImage as ImageData).path.endsWith("rgb.png")); t.true((slintImage as ImageData).path.endsWith("rgb.png"));
let image = await Jimp.read(path.join(dirname, "resources/rgb.png")); const image = await Jimp.read(path.join(dirname, "resources/rgb.png"));
// Sanity check: setProperty fails when passed definitely a non-image // Sanity check: setProperty fails when passed definitely a non-image
t.throws( t.throws(
@ -273,8 +273,8 @@ test("get/set image properties", async (t) => {
}); });
test("get/set brush properties", (t) => { test("get/set brush properties", (t) => {
let compiler = new private_api.ComponentCompiler(); const compiler = new private_api.ComponentCompiler();
let definition = compiler.buildFromSource( const definition = compiler.buildFromSource(
` `
export component App { export component App {
in-out property <brush> black: #000000; in-out property <brush> black: #000000;
@ -289,37 +289,37 @@ test("get/set brush properties", (t) => {
); );
t.not(definition.App, null); t.not(definition.App, null);
let instance = definition.App!.create(); const instance = definition.App!.create();
t.not(instance, null); t.not(instance, null);
let black = instance!.getProperty("black"); const black = instance!.getProperty("black");
t.is((black as private_api.SlintBrush).toString(), "#000000ff"); t.is((black as private_api.SlintBrush).toString(), "#000000ff");
if (t.true(black instanceof private_api.SlintBrush)) { if (t.true(black instanceof private_api.SlintBrush)) {
let blackSlintRgbaColor = (black as private_api.SlintBrush).color; const blackSlintRgbaColor = (black as private_api.SlintBrush).color;
t.deepEqual(blackSlintRgbaColor.red, 0); t.deepEqual(blackSlintRgbaColor.red, 0);
t.deepEqual(blackSlintRgbaColor.green, 0); t.deepEqual(blackSlintRgbaColor.green, 0);
t.deepEqual(blackSlintRgbaColor.blue, 0); t.deepEqual(blackSlintRgbaColor.blue, 0);
} }
instance?.setProperty("black", "#ffffff"); instance?.setProperty("black", "#ffffff");
let white = instance!.getProperty("black"); const white = instance!.getProperty("black");
if (t.true(white instanceof private_api.SlintBrush)) { if (t.true(white instanceof private_api.SlintBrush)) {
let whiteSlintRgbaColor = (white as private_api.SlintBrush).color; const whiteSlintRgbaColor = (white as private_api.SlintBrush).color;
t.deepEqual(whiteSlintRgbaColor.red, 255); t.deepEqual(whiteSlintRgbaColor.red, 255);
t.deepEqual(whiteSlintRgbaColor.green, 255); t.deepEqual(whiteSlintRgbaColor.green, 255);
t.deepEqual(whiteSlintRgbaColor.blue, 255); t.deepEqual(whiteSlintRgbaColor.blue, 255);
} }
let transparent = instance!.getProperty("trans"); const transparent = instance!.getProperty("trans");
if (t.true(black instanceof private_api.SlintBrush)) { if (t.true(black instanceof private_api.SlintBrush)) {
t.assert((transparent as private_api.SlintBrush).isTransparent); t.assert((transparent as private_api.SlintBrush).isTransparent);
} }
let ref = new private_api.SlintBrush({ const ref = new private_api.SlintBrush({
red: 100, red: 100,
green: 110, green: 110,
blue: 120, blue: 120,
@ -330,7 +330,7 @@ test("get/set brush properties", (t) => {
let instance_ref = instance!.getProperty("ref"); let instance_ref = instance!.getProperty("ref");
if (t.true(instance_ref instanceof private_api.SlintBrush)) { if (t.true(instance_ref instanceof private_api.SlintBrush)) {
let ref_color = (instance_ref as private_api.SlintBrush).color; const ref_color = (instance_ref as private_api.SlintBrush).color;
t.deepEqual(ref_color.red, 100); t.deepEqual(ref_color.red, 100);
t.deepEqual(ref_color.green, 110); t.deepEqual(ref_color.green, 110);
t.deepEqual(ref_color.blue, 120); t.deepEqual(ref_color.blue, 120);
@ -344,7 +344,7 @@ test("get/set brush properties", (t) => {
instance_ref = instance!.getProperty("ref"); instance_ref = instance!.getProperty("ref");
if (t.true(instance_ref instanceof private_api.SlintBrush)) { if (t.true(instance_ref instanceof private_api.SlintBrush)) {
let ref_color = (instance_ref as private_api.SlintBrush).color; const ref_color = (instance_ref as private_api.SlintBrush).color;
t.deepEqual(ref_color.red, 110); t.deepEqual(ref_color.red, 110);
t.deepEqual(ref_color.green, 120); t.deepEqual(ref_color.green, 120);
t.deepEqual(ref_color.blue, 125); t.deepEqual(ref_color.blue, 125);
@ -361,7 +361,7 @@ test("get/set brush properties", (t) => {
instance_ref = instance!.getProperty("ref"); instance_ref = instance!.getProperty("ref");
if (t.true(instance_ref instanceof private_api.SlintBrush)) { if (t.true(instance_ref instanceof private_api.SlintBrush)) {
let ref_color = (instance_ref as private_api.SlintBrush).color; const ref_color = (instance_ref as private_api.SlintBrush).color;
t.deepEqual(ref_color.red, 110); t.deepEqual(ref_color.red, 110);
t.deepEqual(ref_color.green, 120); t.deepEqual(ref_color.green, 120);
t.deepEqual(ref_color.blue, 125); t.deepEqual(ref_color.blue, 125);
@ -373,14 +373,14 @@ test("get/set brush properties", (t) => {
instance_ref = instance!.getProperty("ref"); instance_ref = instance!.getProperty("ref");
if (t.true(instance_ref instanceof private_api.SlintBrush)) { if (t.true(instance_ref instanceof private_api.SlintBrush)) {
let ref_color = (instance_ref as private_api.SlintBrush).color; const ref_color = (instance_ref as private_api.SlintBrush).color;
t.deepEqual(ref_color.red, 0); t.deepEqual(ref_color.red, 0);
t.deepEqual(ref_color.green, 0); t.deepEqual(ref_color.green, 0);
t.deepEqual(ref_color.blue, 0); t.deepEqual(ref_color.blue, 0);
t.deepEqual(ref_color.alpha, 0); t.deepEqual(ref_color.alpha, 0);
} }
let radialGradient = instance!.getProperty("radial-gradient"); const radialGradient = instance!.getProperty("radial-gradient");
if (t.true(radialGradient instanceof private_api.SlintBrush)) { if (t.true(radialGradient instanceof private_api.SlintBrush)) {
t.is( t.is(
@ -389,7 +389,7 @@ test("get/set brush properties", (t) => {
); );
} }
let linearGradient = instance!.getProperty("linear-gradient"); const linearGradient = instance!.getProperty("linear-gradient");
if (t.true(linearGradient instanceof private_api.SlintBrush)) { if (t.true(linearGradient instanceof private_api.SlintBrush)) {
t.is( t.is(
@ -484,7 +484,7 @@ test("get/set brush properties", (t) => {
instance_ref = instance!.getProperty("ref-color"); instance_ref = instance!.getProperty("ref-color");
if (t.true(instance_ref instanceof private_api.SlintBrush)) { if (t.true(instance_ref instanceof private_api.SlintBrush)) {
let ref_color = (instance_ref as private_api.SlintBrush).color; const ref_color = (instance_ref as private_api.SlintBrush).color;
t.deepEqual(ref_color.red, 0); t.deepEqual(ref_color.red, 0);
t.deepEqual(ref_color.green, 0); t.deepEqual(ref_color.green, 0);
t.deepEqual(ref_color.blue, 0); t.deepEqual(ref_color.blue, 0);
@ -493,8 +493,8 @@ test("get/set brush properties", (t) => {
}); });
test("ArrayModel", (t) => { test("ArrayModel", (t) => {
let compiler = new private_api.ComponentCompiler(); const compiler = new private_api.ComponentCompiler();
let definition = compiler.buildFromSource( const definition = compiler.buildFromSource(
` `
export struct Player { export struct Player {
name: string, name: string,
@ -510,14 +510,14 @@ test("ArrayModel", (t) => {
); );
t.not(definition.App, null); t.not(definition.App, null);
let instance = definition.App!.create(); const instance = definition.App!.create();
t.not(instance, null); t.not(instance, null);
t.deepEqual(Array.from(new ArrayModel([3, 2, 1])), [3, 2, 1]); t.deepEqual(Array.from(new ArrayModel([3, 2, 1])), [3, 2, 1]);
instance!.setProperty("int-model", new ArrayModel([10, 9, 8])); instance!.setProperty("int-model", new ArrayModel([10, 9, 8]));
let intArrayModel = instance!.getProperty( const intArrayModel = instance!.getProperty(
"int-model", "int-model",
) as ArrayModel<number>; ) as ArrayModel<number>;
t.deepEqual(intArrayModel.rowCount(), 3); t.deepEqual(intArrayModel.rowCount(), 3);
@ -528,7 +528,7 @@ test("ArrayModel", (t) => {
new ArrayModel(["Simon", "Olivier", "Auri", "Tobias", "Florian"]), new ArrayModel(["Simon", "Olivier", "Auri", "Tobias", "Florian"]),
); );
let stringArrayModel = instance!.getProperty( const stringArrayModel = instance!.getProperty(
"string-model", "string-model",
) as ArrayModel<number>; ) as ArrayModel<number>;
t.deepEqual( t.deepEqual(
@ -550,7 +550,7 @@ test("ArrayModel", (t) => {
]), ]),
); );
let structArrayModel = instance!.getProperty( const structArrayModel = instance!.getProperty(
"struct-model", "struct-model",
) as ArrayModel<object>; ) as ArrayModel<object>;
t.deepEqual( t.deepEqual(
@ -563,8 +563,8 @@ test("ArrayModel", (t) => {
}); });
test("MapModel", (t) => { test("MapModel", (t) => {
let compiler = new private_api.ComponentCompiler(); const compiler = new private_api.ComponentCompiler();
let definition = compiler.buildFromSource( const definition = compiler.buildFromSource(
` `
export component App { export component App {
in-out property <[string]> model; in-out property <[string]> model;
@ -573,7 +573,7 @@ test("MapModel", (t) => {
); );
t.not(definition.App, null); t.not(definition.App, null);
let instance = definition.App!.create(); const instance = definition.App!.create();
t.not(instance, null); t.not(instance, null);
interface Name { interface Name {
@ -602,10 +602,10 @@ test("MapModel", (t) => {
}); });
test("MapModel undefined rowData sourcemodel", (t) => { test("MapModel undefined rowData sourcemodel", (t) => {
const nameModel: ArrayModel<Number> = new ArrayModel([1, 2, 3]); const nameModel: ArrayModel<number> = new ArrayModel([1, 2, 3]);
let mapFunctionCallCount = 0; let mapFunctionCallCount = 0;
const mapModel = new private_api.MapModel<Number, String>( const mapModel = new private_api.MapModel<number, string>(
nameModel, nameModel,
(data) => { (data) => {
mapFunctionCallCount++; mapFunctionCallCount++;
@ -625,8 +625,8 @@ test("MapModel undefined rowData sourcemodel", (t) => {
}); });
test("ArrayModel rowCount", (t) => { test("ArrayModel rowCount", (t) => {
let compiler = new private_api.ComponentCompiler(); const compiler = new private_api.ComponentCompiler();
let definition = compiler.buildFromSource( const definition = compiler.buildFromSource(
` `
export component App { export component App {
out property <int> model-length: model.length; out property <int> model-length: model.length;
@ -636,10 +636,10 @@ test("ArrayModel rowCount", (t) => {
); );
t.not(definition.App, null); t.not(definition.App, null);
let instance = definition.App!.create(); const instance = definition.App!.create();
t.not(instance, null); t.not(instance, null);
let model = new ArrayModel([10, 9, 8]); const model = new ArrayModel([10, 9, 8]);
instance!.setProperty("model", model); instance!.setProperty("model", model);
t.is(3, model.rowCount()); t.is(3, model.rowCount());
@ -647,8 +647,8 @@ test("ArrayModel rowCount", (t) => {
}); });
test("ArrayModel rowData/setRowData", (t) => { test("ArrayModel rowData/setRowData", (t) => {
let compiler = new private_api.ComponentCompiler(); const compiler = new private_api.ComponentCompiler();
let definition = compiler.buildFromSource( const definition = compiler.buildFromSource(
` `
export component App { export component App {
callback data(int) -> int; callback data(int) -> int;
@ -663,10 +663,10 @@ test("ArrayModel rowData/setRowData", (t) => {
); );
t.not(definition.App, null); t.not(definition.App, null);
let instance = definition.App!.create(); const instance = definition.App!.create();
t.not(instance, null); t.not(instance, null);
let model = new ArrayModel([10, 9, 8]); const model = new ArrayModel([10, 9, 8]);
instance!.setProperty("model", model); instance!.setProperty("model", model);
t.is(9, model.rowData(1)); t.is(9, model.rowData(1));
@ -678,8 +678,8 @@ test("ArrayModel rowData/setRowData", (t) => {
}); });
test("Model notify", (t) => { test("Model notify", (t) => {
let compiler = new private_api.ComponentCompiler(); const compiler = new private_api.ComponentCompiler();
let definition = compiler.buildFromSource( const definition = compiler.buildFromSource(
` `
export component App { export component App {
width: 300px; width: 300px;
@ -704,10 +704,10 @@ test("Model notify", (t) => {
); );
t.not(definition.App, null); t.not(definition.App, null);
let instance = definition.App!.create(); const instance = definition.App!.create();
t.not(instance, null); t.not(instance, null);
let model = new ArrayModel([100, 0]); const model = new ArrayModel([100, 0]);
instance!.setProperty("fixed-height-model", model); instance!.setProperty("fixed-height-model", model);
t.is(100, instance!.getProperty("layout-height") as number); t.is(100, instance!.getProperty("layout-height") as number);
@ -720,8 +720,8 @@ test("Model notify", (t) => {
}); });
test("model from array", (t) => { test("model from array", (t) => {
let compiler = new private_api.ComponentCompiler(); const compiler = new private_api.ComponentCompiler();
let definition = compiler.buildFromSource( const definition = compiler.buildFromSource(
` `
export component App { export component App {
in-out property <[int]> int-array; in-out property <[int]> int-array;
@ -731,11 +731,11 @@ test("model from array", (t) => {
); );
t.not(definition.App, null); t.not(definition.App, null);
let instance = definition.App!.create(); const instance = definition.App!.create();
t.not(instance, null); t.not(instance, null);
instance!.setProperty("int-array", [10, 9, 8]); instance!.setProperty("int-array", [10, 9, 8]);
let wrapped_int_model = instance!.getProperty("int-array"); const wrapped_int_model = instance!.getProperty("int-array");
t.deepEqual(Array.from(wrapped_int_model), [10, 9, 8]); t.deepEqual(Array.from(wrapped_int_model), [10, 9, 8]);
t.deepEqual(wrapped_int_model.rowCount(), 3); t.deepEqual(wrapped_int_model.rowCount(), 3);
t.deepEqual(wrapped_int_model.rowData(0), 10); t.deepEqual(wrapped_int_model.rowData(0), 10);
@ -750,7 +750,7 @@ test("model from array", (t) => {
"Tobias", "Tobias",
"Florian", "Florian",
]); ]);
let wrapped_string_model = instance!.getProperty("string-array"); const wrapped_string_model = instance!.getProperty("string-array");
t.deepEqual(wrapped_string_model.rowCount(), 5); t.deepEqual(wrapped_string_model.rowCount(), 5);
t.deepEqual(wrapped_string_model.rowData(0), "Simon"); t.deepEqual(wrapped_string_model.rowData(0), "Simon");
t.deepEqual(wrapped_string_model.rowData(1), "Olivier"); t.deepEqual(wrapped_string_model.rowData(1), "Olivier");
@ -760,8 +760,8 @@ test("model from array", (t) => {
}); });
test("invoke callback", (t) => { test("invoke callback", (t) => {
let compiler = new private_api.ComponentCompiler(); const compiler = new private_api.ComponentCompiler();
let definition = compiler.buildFromSource( const definition = compiler.buildFromSource(
` `
export struct Person { export struct Person {
name: string name: string
@ -787,7 +787,7 @@ test("invoke callback", (t) => {
); );
t.not(definition.App, null); t.not(definition.App, null);
let instance = definition.App!.create(); const instance = definition.App!.create();
t.not(instance, null); t.not(instance, null);
let speakTest; let speakTest;

View file

@ -6,7 +6,7 @@ import test from "ava";
import { private_api, ArrayModel } from "../index.js"; import { private_api, ArrayModel } from "../index.js";
test("SlintColor from fromRgb", (t) => { test("SlintColor from fromRgb", (t) => {
let color = private_api.SlintRgbaColor.fromRgb(100, 110, 120); const color = private_api.SlintRgbaColor.fromRgb(100, 110, 120);
t.deepEqual(color.red, 100); t.deepEqual(color.red, 100);
t.deepEqual(color.green, 110); t.deepEqual(color.green, 110);
@ -14,7 +14,7 @@ test("SlintColor from fromRgb", (t) => {
}); });
test("SlintColor from fromArgb", (t) => { test("SlintColor from fromArgb", (t) => {
let color = private_api.SlintRgbaColor.fromArgb(120, 100, 110, 120); const color = private_api.SlintRgbaColor.fromArgb(120, 100, 110, 120);
t.deepEqual(color.red, 100); t.deepEqual(color.red, 100);
t.deepEqual(color.green, 110); t.deepEqual(color.green, 110);
@ -22,7 +22,9 @@ test("SlintColor from fromArgb", (t) => {
}); });
test("SlintColor brighter", (t) => { test("SlintColor brighter", (t) => {
let color = private_api.SlintRgbaColor.fromRgb(100, 110, 120).brighter(0.1); const color = private_api.SlintRgbaColor.fromRgb(100, 110, 120).brighter(
0.1,
);
t.deepEqual(color.red, 110); t.deepEqual(color.red, 110);
t.deepEqual(color.green, 121); t.deepEqual(color.green, 121);
@ -30,7 +32,7 @@ test("SlintColor brighter", (t) => {
}); });
test("SlintColor darker", (t) => { test("SlintColor darker", (t) => {
let color = private_api.SlintRgbaColor.fromRgb(100, 110, 120).darker(0.1); const color = private_api.SlintRgbaColor.fromRgb(100, 110, 120).darker(0.1);
t.deepEqual(color.red, 91); t.deepEqual(color.red, 91);
t.deepEqual(color.green, 100); t.deepEqual(color.green, 100);
@ -38,7 +40,7 @@ test("SlintColor darker", (t) => {
}); });
test("private_api.SlintBrush from RgbaColor", (t) => { test("private_api.SlintBrush from RgbaColor", (t) => {
let brush = new private_api.SlintBrush({ const brush = new private_api.SlintBrush({
red: 100, red: 100,
green: 110, green: 110,
blue: 120, blue: 120,
@ -66,7 +68,7 @@ test("private_api.SlintBrush from RgbaColor", (t) => {
}); });
test("private_api.SlintBrush from Brush", (t) => { test("private_api.SlintBrush from Brush", (t) => {
let brush = private_api.SlintBrush.fromBrush({ const brush = private_api.SlintBrush.fromBrush({
color: { red: 100, green: 110, blue: 120, alpha: 255 }, color: { red: 100, green: 110, blue: 120, alpha: 255 },
}); });
@ -88,7 +90,7 @@ test("private_api.SlintBrush from Brush", (t) => {
}); });
test("ArrayModel push", (t) => { test("ArrayModel push", (t) => {
let arrayModel = new ArrayModel([0]); const arrayModel = new ArrayModel([0]);
t.is(arrayModel.rowCount(), 1); t.is(arrayModel.rowCount(), 1);
t.is(arrayModel.rowData(0), 0); t.is(arrayModel.rowData(0), 0);
@ -99,7 +101,7 @@ test("ArrayModel push", (t) => {
}); });
test("ArrayModel setRowData", (t) => { test("ArrayModel setRowData", (t) => {
let arrayModel = new ArrayModel([0]); const arrayModel = new ArrayModel([0]);
t.is(arrayModel.rowCount(), 1); t.is(arrayModel.rowCount(), 1);
t.is(arrayModel.rowData(0), 0); t.is(arrayModel.rowData(0), 0);
@ -110,7 +112,7 @@ test("ArrayModel setRowData", (t) => {
}); });
test("ArrayModel remove", (t) => { test("ArrayModel remove", (t) => {
let arrayModel = new ArrayModel([0, 2, 1]); const arrayModel = new ArrayModel([0, 2, 1]);
t.is(arrayModel.rowCount(), 3); t.is(arrayModel.rowCount(), 3);
t.is(arrayModel.rowData(0), 0); t.is(arrayModel.rowData(0), 0);

View file

@ -18,8 +18,8 @@ test("Window constructor", (t) => {
}); });
test("Window show / hide", (t) => { test("Window show / hide", (t) => {
let compiler = new private_api.ComponentCompiler(); const compiler = new private_api.ComponentCompiler();
let definition = compiler.buildFromSource( const definition = compiler.buildFromSource(
` `
export component App inherits Window { export component App inherits Window {
@ -30,10 +30,10 @@ test("Window show / hide", (t) => {
); );
t.not(definition.App, null); t.not(definition.App, null);
let instance = definition.App!.create(); const instance = definition.App!.create();
t.not(instance, null); t.not(instance, null);
let window = instance!.window(); const window = instance!.window();
t.is(window.visible, false); t.is(window.visible, false);
window.show(); window.show();
t.is(window.visible, true); t.is(window.visible, true);

View file

@ -11,7 +11,7 @@
"useArrowFunction": "off", "useArrowFunction": "off",
"noForEach": "off", "noForEach": "off",
"noUselessConstructor": "off", "noUselessConstructor": "off",
"noBannedTypes": "off" "noBannedTypes": "warn"
}, },
"style": { "style": {
"noNonNullAssertion": "off", "noNonNullAssertion": "off",
@ -29,7 +29,6 @@
"noExplicitAny": "off", "noExplicitAny": "off",
"noAssignInExpressions": "off", "noAssignInExpressions": "off",
"noImplicitAnyLet": "off", "noImplicitAnyLet": "off",
"noDoubleEquals": "warn",
"noRedundantUseStrict": "off" "noRedundantUseStrict": "off"
} }
} }

View file

@ -126,7 +126,7 @@ class ModelIterator<T> implements Iterator<T> {
public next(): IteratorResult<T> { public next(): IteratorResult<T> {
if (this.row < this.model.rowCount()) { if (this.row < this.model.rowCount()) {
let row = this.row; const row = this.row;
this.row++; this.row++;
return { return {
done: false, done: false,
@ -341,7 +341,7 @@ export class ArrayModel<T> extends Model<T> {
* @param values list of values that will be pushed to the array. * @param values list of values that will be pushed to the array.
*/ */
push(...values: T[]) { push(...values: T[]) {
let size = this.#array.length; const size = this.#array.length;
Array.prototype.push.apply(this.#array, values); Array.prototype.push.apply(this.#array, values);
this.notifyRowAdded(size, arguments.length); this.notifyRowAdded(size, arguments.length);
} }
@ -352,7 +352,7 @@ export class ArrayModel<T> extends Model<T> {
* @returns The removed element or undefined if the array is empty. * @returns The removed element or undefined if the array is empty.
*/ */
pop(): T | undefined { pop(): T | undefined {
let last = this.#array.pop(); const last = this.#array.pop();
if (last !== undefined) { if (last !== undefined) {
this.notifyRowRemoved(this.#array.length, 1); this.notifyRowRemoved(this.#array.length, 1);
} }
@ -367,7 +367,7 @@ export class ArrayModel<T> extends Model<T> {
* @param size number of rows to remove. * @param size number of rows to remove.
*/ */
remove(index: number, size: number) { remove(index: number, size: number) {
let r = this.#array.splice(index, size); const r = this.#array.splice(index, size);
this.notifyRowRemoved(index, size); this.notifyRowRemoved(index, size);
} }
@ -535,7 +535,7 @@ export namespace private_api {
* @returns undefined if row is out of range otherwise the data. * @returns undefined if row is out of range otherwise the data.
*/ */
rowData(row: number): U | undefined { rowData(row: number): U | undefined {
let data = this.sourceModel.rowData(row); const data = this.sourceModel.rowData(row);
if (data === undefined) { if (data === undefined) {
return undefined; return undefined;
} }
@ -692,7 +692,7 @@ type LoadData =
function loadSlint(loadData: LoadData): Object { function loadSlint(loadData: LoadData): Object {
const { filePath, options } = loadData.fileData; const { filePath, options } = loadData.fileData;
let compiler = new napi.ComponentCompiler(); const compiler = new napi.ComponentCompiler();
if (typeof options !== "undefined") { if (typeof options !== "undefined") {
if (typeof options.style !== "undefined") { if (typeof options.style !== "undefined") {
@ -706,14 +706,14 @@ function loadSlint(loadData: LoadData): Object {
} }
} }
let definitions = const definitions =
loadData.from === "file" loadData.from === "file"
? compiler.buildFromPath(filePath) ? compiler.buildFromPath(filePath)
: compiler.buildFromSource(loadData.fileData.source, filePath); : compiler.buildFromSource(loadData.fileData.source, filePath);
let diagnostics = compiler.diagnostics; const diagnostics = compiler.diagnostics;
if (diagnostics.length > 0) { if (diagnostics.length > 0) {
let warnings = diagnostics.filter( const warnings = diagnostics.filter(
(d) => d.level === napi.DiagnosticLevel.Warning, (d) => d.level === napi.DiagnosticLevel.Warning,
); );
@ -721,7 +721,7 @@ function loadSlint(loadData: LoadData): Object {
warnings.forEach((w) => console.warn("Warning: " + w)); warnings.forEach((w) => console.warn("Warning: " + w));
} }
let errors = diagnostics.filter( const errors = diagnostics.filter(
(d) => d.level === napi.DiagnosticLevel.Error, (d) => d.level === napi.DiagnosticLevel.Error,
); );
@ -730,17 +730,17 @@ function loadSlint(loadData: LoadData): Object {
} }
} }
let slint_module = Object.create({}); const slint_module = Object.create({});
Object.keys(definitions).forEach((key) => { Object.keys(definitions).forEach((key) => {
let definition = definitions[key]; const definition = definitions[key];
Object.defineProperty( Object.defineProperty(
slint_module, slint_module,
definition.name.replace(/-/g, "_"), definition.name.replace(/-/g, "_"),
{ {
value: function (properties: any) { value: function (properties: any) {
let instance = definition.create(); const instance = definition.create();
if (instance == null) { if (instance == null) {
throw Error( throw Error(
@ -750,7 +750,7 @@ function loadSlint(loadData: LoadData): Object {
} }
for (var key in properties) { for (var key in properties) {
let value = properties[key]; const value = properties[key];
if (value instanceof Function) { if (value instanceof Function) {
instance.setCallback(key, value); instance.setCallback(key, value);
@ -759,9 +759,9 @@ function loadSlint(loadData: LoadData): Object {
} }
} }
let componentHandle = new Component(instance!); const componentHandle = new Component(instance!);
instance!.definition().properties.forEach((prop) => { instance!.definition().properties.forEach((prop) => {
let propName = prop.name.replace(/-/g, "_"); const propName = prop.name.replace(/-/g, "_");
if (componentHandle[propName] !== undefined) { if (componentHandle[propName] !== undefined) {
console.warn( console.warn(
@ -781,7 +781,7 @@ function loadSlint(loadData: LoadData): Object {
}); });
instance!.definition().callbacks.forEach((cb) => { instance!.definition().callbacks.forEach((cb) => {
let callbackName = cb.replace(/-/g, "_"); const callbackName = cb.replace(/-/g, "_");
if (componentHandle[callbackName] !== undefined) { if (componentHandle[callbackName] !== undefined) {
console.warn( console.warn(
@ -810,7 +810,7 @@ function loadSlint(loadData: LoadData): Object {
}); });
instance!.definition().functions.forEach((cb) => { instance!.definition().functions.forEach((cb) => {
let functionName = cb.replace(/-/g, "_"); const functionName = cb.replace(/-/g, "_");
if (componentHandle[functionName] !== undefined) { if (componentHandle[functionName] !== undefined) {
console.warn( console.warn(
@ -842,13 +842,16 @@ function loadSlint(loadData: LoadData): Object {
"Duplicated property name " + globalName, "Duplicated property name " + globalName,
); );
} else { } else {
let globalObject = Object.create({}); const globalObject = Object.create({});
instance! instance!
.definition() .definition()
.globalProperties(globalName) .globalProperties(globalName)
.forEach((prop) => { .forEach((prop) => {
let propName = prop.name.replace(/-/g, "_"); const propName = prop.name.replace(
/-/g,
"_",
);
if (globalObject[propName] !== undefined) { if (globalObject[propName] !== undefined) {
console.warn( console.warn(
@ -885,7 +888,7 @@ function loadSlint(loadData: LoadData): Object {
.definition() .definition()
.globalCallbacks(globalName) .globalCallbacks(globalName)
.forEach((cb) => { .forEach((cb) => {
let callbackName = cb.replace(/-/g, "_"); const callbackName = cb.replace(/-/g, "_");
if ( if (
globalObject[callbackName] !== undefined globalObject[callbackName] !== undefined
@ -929,7 +932,7 @@ function loadSlint(loadData: LoadData): Object {
.definition() .definition()
.globalFunctions(globalName) .globalFunctions(globalName)
.forEach((cb) => { .forEach((cb) => {
let functionName = cb.replace(/-/g, "_"); const functionName = cb.replace(/-/g, "_");
if ( if (
globalObject[functionName] !== undefined globalObject[functionName] !== undefined
@ -1089,7 +1092,7 @@ class EventLoop {
// Give the nodejs event loop 16 ms to tick. This polling is sub-optimal, but it's the best we // Give the nodejs event loop 16 ms to tick. This polling is sub-optimal, but it's the best we
// can do right now. // can do right now.
const nodejsPollInterval = 16; const nodejsPollInterval = 16;
let id = setInterval(() => { const id = setInterval(() => {
if ( if (
napi.processEvents() === napi.ProcessEventsResult.Exited || napi.processEvents() === napi.ProcessEventsResult.Exited ||
this.#quit_loop this.#quit_loop

View file

@ -22,9 +22,10 @@
"style": { "style": {
"useBlockStatements": "warn", "useBlockStatements": "warn",
"noUselessElse": "off", "noUselessElse": "off",
"useConst": "warn" "useConst": "error",
"useImportType": "error"
}, },
"suspicious": { "noDoubleEquals": "warn" } "suspicious": { "noDoubleEquals": "error" }
} }
}, },
"javascript": { "javascript": {

View file

@ -12,8 +12,8 @@ import * as lsp_commands from "./lsp_commands";
import * as snippets from "./snippets"; import * as snippets from "./snippets";
import { import {
BaseLanguageClient, type BaseLanguageClient,
LanguageClientOptions, type LanguageClientOptions,
NotificationType, NotificationType,
} from "vscode-languageclient"; } from "vscode-languageclient";

View file

@ -1,7 +1,7 @@
// Copyright © SixtyFPS GmbH <info@slint.dev> // Copyright © SixtyFPS GmbH <info@slint.dev>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0 // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
import { URI as LspURI } from "vscode-languageserver-types"; import type { URI as LspURI } from "vscode-languageserver-types";
import * as vscode from "vscode"; import * as vscode from "vscode";
// Use the auto-registered VSCode command for the custom executables offered // Use the auto-registered VSCode command for the custom executables offered

View file

@ -13,7 +13,7 @@
// cSpell: ignore Tuppeny // cSpell: ignore Tuppeny
import * as vscode from "vscode"; import * as vscode from "vscode";
import { import type {
ClientCapabilities, ClientCapabilities,
FeatureState, FeatureState,
StaticFeature, StaticFeature,

View file

@ -4,7 +4,7 @@
import { Uri } from "vscode"; import { Uri } from "vscode";
import * as vscode from "vscode"; import * as vscode from "vscode";
import { BaseLanguageClient } from "vscode-languageclient"; import type { BaseLanguageClient } from "vscode-languageclient";
let previewPanel: vscode.WebviewPanel | null = null; let previewPanel: vscode.WebviewPanel | null = null;
let to_lsp_queue: object[] = []; let to_lsp_queue: object[] = [];

View file

@ -7,27 +7,30 @@ import * as monaco from "monaco-editor";
import { slint_language } from "./highlighting"; import { slint_language } from "./highlighting";
import { import {
LspPosition, type LspPosition,
LspRange, type LspRange,
editor_position_to_lsp_position, editor_position_to_lsp_position,
lsp_range_to_editor_range, lsp_range_to_editor_range,
} from "./lsp_integration"; } from "./lsp_integration";
import { Lsp } from "./lsp"; import type { Lsp } from "./lsp";
import { PositionChangeCallback, VersionedDocumentAndPosition } from "./text"; import type {
PositionChangeCallback,
VersionedDocumentAndPosition,
} from "./text";
import * as github from "./github"; import * as github from "./github";
import { BoxLayout, TabBar, Title, Widget } from "@lumino/widgets"; import { BoxLayout, TabBar, type Title, Widget } from "@lumino/widgets";
import { Message as LuminoMessage } from "@lumino/messaging"; import type { Message as LuminoMessage } from "@lumino/messaging";
import { MonacoLanguageClient } from "monaco-languageclient"; import type { MonacoLanguageClient } from "monaco-languageclient";
import { createConfiguredEditor } from "vscode/monaco"; import { createConfiguredEditor } from "vscode/monaco";
import { initialize as initializeMonacoServices } from "vscode/services"; import { initialize as initializeMonacoServices } from "vscode/services";
import getConfigurationServiceOverride from "@codingame/monaco-vscode-configuration-service-override"; import getConfigurationServiceOverride from "@codingame/monaco-vscode-configuration-service-override";
import getEditorServiceOverride, { import getEditorServiceOverride, {
IReference, type IReference,
IEditorOptions, type IEditorOptions,
IResolvedTextEditorModel, type IResolvedTextEditorModel,
} from "@codingame/monaco-vscode-editor-service-override"; } from "@codingame/monaco-vscode-editor-service-override";
import getSnippetServiceOverride from "@codingame/monaco-vscode-snippets-service-override"; import getSnippetServiceOverride from "@codingame/monaco-vscode-snippets-service-override";
import getStorageServiceOverride from "@codingame/monaco-vscode-storage-service-override"; import getStorageServiceOverride from "@codingame/monaco-vscode-storage-service-override";

View file

@ -1,7 +1,11 @@
// Copyright © SixtyFPS GmbH <info@slint.dev> // Copyright © SixtyFPS GmbH <info@slint.dev>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0 // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
import { EditorWidget, UrlMapper, KnownUrlMapper } from "./editor_widget"; import {
type EditorWidget,
type UrlMapper,
KnownUrlMapper,
} from "./editor_widget";
import { modal_dialog } from "./dialogs"; import { modal_dialog } from "./dialogs";
import { version as slint_version } from "../package.json"; import { version as slint_version } from "../package.json";

View file

@ -3,7 +3,7 @@
// cSpell: ignore abfnrtv // cSpell: ignore abfnrtv
import * as monaco from "monaco-editor"; import type * as monaco from "monaco-editor";
export const slint_language = <monaco.languages.IMonarchLanguage>{ export const slint_language = <monaco.languages.IMonarchLanguage>{
defaultToken: "invalid", defaultToken: "invalid",

View file

@ -4,7 +4,7 @@
// cSpell: ignore cupertino lumino permalink // cSpell: ignore cupertino lumino permalink
import { EditorWidget, initialize as initializeEditor } from "./editor_widget"; import { EditorWidget, initialize as initializeEditor } from "./editor_widget";
import { LspWaiter, Lsp } from "./lsp"; import { LspWaiter, type Lsp } from "./lsp";
import { PreviewWidget } from "./preview_widget"; import { PreviewWidget } from "./preview_widget";
import { import {

View file

@ -5,22 +5,22 @@ import { FilterProxyReader } from "./proxy";
import { import {
CloseAction, CloseAction,
ErrorAction, ErrorAction,
Message, type Message,
MessageTransports, type MessageTransports,
NotificationMessage, type NotificationMessage,
RequestMessage, type RequestMessage,
ResponseMessage, type ResponseMessage,
ShowDocumentParams, type ShowDocumentParams,
} from "vscode-languageclient"; } from "vscode-languageclient";
import { MonacoLanguageClient } from "monaco-languageclient"; import { MonacoLanguageClient } from "monaco-languageclient";
import { import {
BrowserMessageReader, BrowserMessageReader,
BrowserMessageWriter, BrowserMessageWriter,
MessageReader, type MessageReader,
MessageWriter, type MessageWriter,
} from "vscode-languageserver-protocol/browser"; } from "vscode-languageserver-protocol/browser";
import { LspPosition } from "./lsp_integration"; import type { LspPosition } from "./lsp_integration";
import slint_init, * as slint_preview from "@lsp/slint_lsp_wasm.js"; import slint_init, * as slint_preview from "@lsp/slint_lsp_wasm.js";

View file

@ -6,12 +6,12 @@ export {
Range as LspRange, Range as LspRange,
URI as LspURI, URI as LspURI,
} from "vscode-languageserver-types"; } from "vscode-languageserver-types";
import { import type {
Position as LspPosition, Position as LspPosition,
Range as LspRange, Range as LspRange,
} from "vscode-languageserver-types"; } from "vscode-languageserver-types";
import { TextRange, TextPosition } from "./text"; import type { TextRange, TextPosition } from "./text";
import * as monaco from "monaco-editor"; import * as monaco from "monaco-editor";

View file

@ -3,10 +3,10 @@
// cSpell: ignore bindgen lumino // cSpell: ignore bindgen lumino
import { Message } from "@lumino/messaging"; import type { Message } from "@lumino/messaging";
import { Widget } from "@lumino/widgets"; import { Widget } from "@lumino/widgets";
import { Previewer, Lsp, ResourceUrlMapperFunction } from "./lsp"; import type { Previewer, Lsp, ResourceUrlMapperFunction } from "./lsp";
const canvas_id = "canvas"; const canvas_id = "canvas";

View file

@ -1,7 +1,7 @@
// Copyright © SixtyFPS GmbH <info@slint.dev> // Copyright © SixtyFPS GmbH <info@slint.dev>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0 // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
import { import type {
MessageReader, MessageReader,
DataCallback, DataCallback,
Message, Message,

View file

@ -2,13 +2,13 @@
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0 // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
// import * as monaco from "monaco-editor/esm/vs/editor/editor.api"; // import * as monaco from "monaco-editor/esm/vs/editor/editor.api";
import * as monaco from "monaco-editor"; import type * as monaco from "monaco-editor";
export type TextRange = monaco.IRange; export type TextRange = monaco.IRange;
export type TextPosition = monaco.IPosition; export type TextPosition = monaco.IPosition;
export type Uri = monaco.Uri; export type Uri = monaco.Uri;
import { LspRange, LspPosition } from "./lsp_integration"; import type { LspRange, LspPosition } from "./lsp_integration";
export type DocumentAndPosition = { uri: string; position: LspPosition }; export type DocumentAndPosition = { uri: string; position: LspPosition };
export type VersionedDocumentAndPosition = { export type VersionedDocumentAndPosition = {

View file

@ -2,7 +2,7 @@
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0 // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
import slint_init, * as slint_lsp from "@lsp/slint_lsp_wasm.js"; import slint_init, * as slint_lsp from "@lsp/slint_lsp_wasm.js";
import { InitializeParams, InitializeResult } from "vscode-languageserver"; import type { InitializeParams, InitializeResult } from "vscode-languageserver";
import { import {
createConnection, createConnection,
BrowserMessageReader, BrowserMessageReader,

View file

@ -3,7 +3,7 @@
// cSpell: ignore lumino // cSpell: ignore lumino
import { defineConfig, UserConfig } from "vite"; import { defineConfig, type UserConfig } from "vite";
import { resolve } from "path"; import { resolve } from "path";
export default defineConfig(() => { export default defineConfig(() => {