Skip to content

Commit

Permalink
feat: migrate to TypeScript (#1134)
Browse files Browse the repository at this point in the history
* feat: Allow to use TypeScript

* Add `prepack` script

* Add back `import` eslint plugin

* Shorten async function constructor syntax

Co-authored-by: Queen Vinyl Da.i'gyu-Kazotetsu <vinyldarkscratch@gmail.com>

* Use SWC

* Add swc dependency

---------

Co-authored-by: Queen Vinyl Da.i'gyu-Kazotetsu <vinyldarkscratch@gmail.com>
  • Loading branch information
NiedziolkaMichal and queengooborg authored Mar 9, 2023
1 parent 077d020 commit 9e7b619
Show file tree
Hide file tree
Showing 16 changed files with 1,013 additions and 69 deletions.
24 changes: 16 additions & 8 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
{
"extends": ["eslint:recommended", "plugin:import/errors", "prettier"],
"plugins": ["import"],
"parser": "@babel/eslint-parser",
"parserOptions": {
"ecmaVersion": 2021,
"sourceType": "module",
"requireConfigFile": false
},
"env": {
"es6": true,
"browser": true,
"node": true
},
"plugins": ["@typescript-eslint", "import"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:import/errors",
"prettier"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module"
},
"rules": {
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-unused-expressions": "error"
}
}
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ docs
node_modules
# This can be removed after https://github.com/googleapis/release-please/issues/1802 is fixed
CHANGELOG.md
# TSC output:
webpack.config.js
lib/*.js
6 changes: 2 additions & 4 deletions __tests__/console-utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,11 @@ describe("console utils", () => {

describe("formatArray", () => {
test("Array formatting", () => {
expect(consoleUtils.formatArray(new Array(1, 2, 3, 4))).toBe(
"1, 2, 3, 4"
);
expect(consoleUtils.formatArray([1, 2, 3, 4])).toBe("1, 2, 3, 4");
});
test("Mixed array", () => {
expect(
consoleUtils.formatArray(new Array(1, "a", { x: 2 }, null, undefined))
consoleUtils.formatArray([1, "a", { x: 2 }, null, undefined])
).toBe('1, "a", Object { x: 2 }, null, undefined');
});
});
Expand Down
5 changes: 2 additions & 3 deletions editor/js/editable-wat.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,8 @@ import {
// Create an new async function from the code, and immediately execute it.
// using an async function since WebAssembly.instantiate is async and
// we need to await in order to capture errors
const AsyncFunction = Object.getPrototypeOf(
async function () {}
).constructor;
// eslint-disable-next-line @typescript-eslint/no-empty-function
const AsyncFunction = async function () {}.constructor;
await new AsyncFunction(exampleCode)();
} catch (error) {
console.error(error);
Expand Down
2 changes: 0 additions & 2 deletions lib/config.js → lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ function getConfig() {
const configFile = path.join(__dirname, "../.bobconfigrc");
const cosmiConfig = cosmiconfigSync("bobconfig", {
cache: false,
format: "json",
sync: true,
});

const config = cosmiConfig.load(configFile).config;
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion lib/mdn-bob.js → lib/mdn-bob.ts
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function doWebpack() {
}
}

resolve();
resolve(undefined);
});
});
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 9e7b619

Please sign in to comment.