Skip to content

Commit

Permalink
Start to enable default javscript/typescript lint rules
Browse files Browse the repository at this point in the history
This enables the recommended rules useConst and useImportType
  • Loading branch information
NigelBreslaw authored Sep 12, 2024
1 parent 8d9c041 commit 2bee820
Show file tree
Hide file tree
Showing 25 changed files with 197 additions and 185 deletions.
26 changes: 13 additions & 13 deletions api/node/__test__/api.spec.mts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ const dirname = path.dirname(fileURLToPath(import.meta.url));

// loadFile api
test("loadFile", (t) => {
let demo = loadFile(path.join(dirname, "resources/test.slint")) as any;
let test = new demo.Test();
const demo = loadFile(path.join(dirname, "resources/test.slint")) as any;
const test = new demo.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(
() => {
Expand Down Expand Up @@ -63,11 +63,11 @@ test("loadFile", (t) => {
});

test("loadFile constructor parameters", (t) => {
let demo = loadFile(
const demo = loadFile(
path.join(dirname, "resources/test-constructor.slint"),
) as any;
let hello = "";
let test = new demo.Test({
const test = new demo.Test({
say_hello: function () {
hello = "hello";
},
Expand All @@ -82,7 +82,7 @@ test("loadFile constructor parameters", (t) => {

test("loadFile component instances and modules are sealed", (t) => {
"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(
() => {
Expand All @@ -91,7 +91,7 @@ test("loadFile component instances and modules are sealed", (t) => {
{ instanceOf: TypeError },
);

let test = new demo.Test();
const test = new demo.Test();
t.is(test.check, "Test");

t.throws(
Expand All @@ -108,8 +108,8 @@ test("loadSource", (t) => {
out property <string> check: "Test";
}`;
const path = "api.spec.ts";
let demo = loadSource(source, path) as any;
let test = new demo.Test();
const demo = loadSource(source, path) as any;
const test = new demo.Test();
t.is(test.check, "Test");

const errorSource = `export component Error {
Expand Down Expand Up @@ -166,9 +166,9 @@ test("loadSource constructor parameters", (t) => {
in-out property <string> check;
}`;
const path = "api.spec.ts";
let demo = loadSource(source, path) as any;
const demo = loadSource(source, path) as any;
let hello = "";
let test = new demo.Test({
const test = new demo.Test({
say_hello: function () {
hello = "hello";
},
Expand All @@ -187,7 +187,7 @@ test("loadSource component instances and modules are sealed", (t) => {
out property <string> check: "Test";
}`;
const path = "api.spec.ts";
let demo = loadSource(source, path) as any;
const demo = loadSource(source, path) as any;

t.throws(
() => {
Expand All @@ -196,7 +196,7 @@ test("loadSource component instances and modules are sealed", (t) => {
{ instanceOf: TypeError },
);

let test = new demo.Test();
const test = new demo.Test();
t.is(test.check, "Test");

t.throws(
Expand Down
42 changes: 21 additions & 21 deletions api/node/__test__/compiler.spec.mts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import test from "ava";
import { private_api } from "../index.js";

test("get/set include paths", (t) => {
let compiler = new private_api.ComponentCompiler();
const compiler = new private_api.ComponentCompiler();

t.is(compiler.includePaths.length, 0);

Expand All @@ -20,7 +20,7 @@ test("get/set include paths", (t) => {
});

test("get/set library paths", (t) => {
let compiler = new private_api.ComponentCompiler();
const compiler = new private_api.ComponentCompiler();

compiler.libraryPaths = {
"libfile.slint": "third_party/libfoo/ui/lib.slint",
Expand All @@ -34,7 +34,7 @@ test("get/set library paths", (t) => {
});

test("get/set style", (t) => {
let compiler = new private_api.ComponentCompiler();
const compiler = new private_api.ComponentCompiler();

t.is(compiler.style, null);

Expand All @@ -43,8 +43,8 @@ test("get/set style", (t) => {
});

test("get/set build from source", (t) => {
let compiler = new private_api.ComponentCompiler();
let definition = compiler.buildFromSource(`export component App {}`, "");
const compiler = new private_api.ComponentCompiler();
const definition = compiler.buildFromSource(`export component App {}`, "");
t.not(definition.App, null);
t.is(definition.App!.name, "App");
});
Expand All @@ -68,8 +68,8 @@ test("constructor error ComponentDefinition and ComponentInstance", (t) => {
});

test("properties ComponentDefinition", (t) => {
let compiler = new private_api.ComponentCompiler();
let definition = compiler.buildFromSource(
const compiler = new private_api.ComponentCompiler();
const definition = compiler.buildFromSource(
`export struct Struct {}
export component App {
in-out property <bool> bool-property;
Expand All @@ -86,7 +86,7 @@ test("properties ComponentDefinition", (t) => {
);
t.not(definition.App, null);

let properties = definition.App!.properties;
const properties = definition.App!.properties;
t.is(properties.length, 9);

properties.sort((a, b) => {
Expand Down Expand Up @@ -125,8 +125,8 @@ test("properties ComponentDefinition", (t) => {
});

test("callbacks ComponentDefinition", (t) => {
let compiler = new private_api.ComponentCompiler();
let definition = compiler.buildFromSource(
const compiler = new private_api.ComponentCompiler();
const definition = compiler.buildFromSource(
`
export component App {
callback first-callback();
Expand All @@ -136,7 +136,7 @@ test("callbacks ComponentDefinition", (t) => {
);
t.not(definition.App, null);

let callbacks = definition.App!.callbacks;
const callbacks = definition.App!.callbacks;
t.is(callbacks.length, 2);

callbacks.sort();
Expand All @@ -146,8 +146,8 @@ test("callbacks ComponentDefinition", (t) => {
});

test("globalProperties ComponentDefinition", (t) => {
let compiler = new private_api.ComponentCompiler();
let definition = compiler.buildFromSource(
const compiler = new private_api.ComponentCompiler();
const definition = compiler.buildFromSource(
`export struct Struct {}
export global TestGlobal {
Expand All @@ -171,7 +171,7 @@ test("globalProperties ComponentDefinition", (t) => {

t.is(definition.App!.globalProperties("NonExistent"), null);

let properties = definition.App!.globalProperties("TestGlobal");
const properties = definition.App!.globalProperties("TestGlobal");
t.not(properties, null);

t.is(properties!.length, 9);
Expand Down Expand Up @@ -212,8 +212,8 @@ test("globalProperties ComponentDefinition", (t) => {
});

test("globalCallbacks ComponentDefinition", (t) => {
let compiler = new private_api.ComponentCompiler();
let definition = compiler.buildFromSource(
const compiler = new private_api.ComponentCompiler();
const definition = compiler.buildFromSource(
`
export global TestGlobal {
callback first-callback();
Expand All @@ -227,7 +227,7 @@ test("globalCallbacks ComponentDefinition", (t) => {

t.is(definition.App!.globalCallbacks("NonExistent"), null);

let callbacks = definition.App!.globalCallbacks("TestGlobal");
const callbacks = definition.App!.globalCallbacks("TestGlobal");
t.not(callbacks, null);
t.is(callbacks!.length, 2);

Expand All @@ -238,7 +238,7 @@ test("globalCallbacks ComponentDefinition", (t) => {
});

test("compiler diagnostics", (t) => {
let compiler = new private_api.ComponentCompiler();
const compiler = new private_api.ComponentCompiler();
t.deepEqual(
compiler.buildFromSource(
`export component App {
Expand All @@ -261,8 +261,8 @@ test("compiler diagnostics", (t) => {
});

test("non-existent properties and callbacks", (t) => {
let compiler = new private_api.ComponentCompiler();
let definition = compiler.buildFromSource(
const compiler = new private_api.ComponentCompiler();
const definition = compiler.buildFromSource(
`
export component App {
Expand All @@ -271,7 +271,7 @@ test("non-existent properties and callbacks", (t) => {
);
t.not(definition.App, null);

let instance = definition.App!.create();
const instance = definition.App!.create();
t.not(instance, null);

const prop_err = t.throws(() => {
Expand Down
10 changes: 5 additions & 5 deletions api/node/__test__/eventloop.spec.mts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ test.serial("merged event loops with networking", async (t) => {
await runEventLoop(() => {
const server = http.createServer(listener);
server.listen(async () => {
let host = "localhost";
let port = (server.address() as any).port;
const host = "localhost";
const port = (server.address() as any).port;
console.log(`server ready at ${host}:${port}`);

(fetch as any)(`http://${host}:${port}/`)
Expand All @@ -55,8 +55,8 @@ test.serial("merged event loops with networking", async (t) => {
test.serial(
"quit event loop on last window closed with callback",
async (t) => {
let compiler = new private_api.ComponentCompiler();
let definition = compiler.buildFromSource(
const compiler = new private_api.ComponentCompiler();
const definition = compiler.buildFromSource(
`
export component App inherits Window {
Expand All @@ -67,7 +67,7 @@ test.serial(
);
t.not(definition.App, null);

let instance = definition.App!.create() as any;
const instance = definition.App!.create() as any;
t.not(instance, null);

instance.window().show();
Expand Down
12 changes: 6 additions & 6 deletions api/node/__test__/globals.spec.mts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ import test from "ava";
import { private_api } from "../index.js";

test("get/set global properties", (t) => {
let compiler = new private_api.ComponentCompiler();
let definition = compiler.buildFromSource(
const compiler = new private_api.ComponentCompiler();
const definition = compiler.buildFromSource(
`
export global Global { in-out property <string> name: "Initial"; }
export component App {}`,
"",
);
t.not(definition.App, null);

let instance = definition.App!.create();
const instance = definition.App!.create();
t.not(instance, null);

t.is(instance!.getGlobalProperty("Global", "name"), "Initial");
Expand Down Expand Up @@ -85,8 +85,8 @@ test("get/set global properties", (t) => {
});

test("invoke global callback", (t) => {
let compiler = new private_api.ComponentCompiler();
let definition = compiler.buildFromSource(
const compiler = new private_api.ComponentCompiler();
const definition = compiler.buildFromSource(
`
export struct Person {
name: string
Expand Down Expand Up @@ -114,7 +114,7 @@ test("invoke global callback", (t) => {
);
t.not(definition.App, null);

let instance = definition.App!.create();
const instance = definition.App!.create();
t.not(instance, null);

t.throws(
Expand Down
Loading

0 comments on commit 2bee820

Please sign in to comment.