Skip to content

Commit

Permalink
Merge pull request #481 from microsoft/connor4312/prettier-and-deps
Browse files Browse the repository at this point in the history
chore: update dependencies, adopt prettier
  • Loading branch information
connor4312 authored Feb 2, 2024
2 parents 51e63f9 + 2d1d4b9 commit 604d763
Show file tree
Hide file tree
Showing 53 changed files with 4,109 additions and 3,782 deletions.
138 changes: 67 additions & 71 deletions .esbuild.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,82 +6,78 @@ const watch = process.argv.includes("--watch");
const minify = !watch || process.argv.includes("--minify");
const defineProd = process.argv.includes("--defineProd");

function build(options) {
(async () => {
if (watch) {
const context = await esbuild.context(options);
await context.watch();
} else {
await esbuild.build(options);
}
})().catch(() => process.exit(1));
}

// Build the editor provider
esbuild
.build({
entryPoints: ["src/extension.ts"],
tsconfig: "./tsconfig.json",
bundle: true,
external: ["vscode"],
sourcemap: watch,
minify,
watch,
platform: "node",
outfile: "dist/extension.js",
})
.catch(() => process.exit(1));
build({
entryPoints: ["src/extension.ts"],
tsconfig: "./tsconfig.json",
bundle: true,
external: ["vscode"],
sourcemap: watch,
minify,
platform: "node",
outfile: "dist/extension.js",
});

// Build the test cases
esbuild
.build({
entryPoints: ["src/test/index.ts"],
tsconfig: "./tsconfig.json",
bundle: true,
external: ["vscode", "mocha", "chai"],
sourcemap: watch,
minify,
watch,
platform: "node",
outfile: "dist/test.js",
})
.catch(() => process.exit(1));
build({
entryPoints: ["src/test/index.ts"],
tsconfig: "./tsconfig.json",
bundle: true,
external: ["vscode", "mocha", "chai"],
sourcemap: watch,
minify,
platform: "node",
outfile: "dist/test.js",
});

esbuild
.build({
entryPoints: ["src/extension.ts"],
tsconfig: "./tsconfig.json",
bundle: true,
format: "cjs",
external: ["vscode", "fs"],
minify,
watch,
platform: "browser",
outfile: "dist/web/extension.js",
})
.catch(() => process.exit(1));
build({
entryPoints: ["src/extension.ts"],
tsconfig: "./tsconfig.json",
bundle: true,
format: "cjs",
external: ["vscode", "fs"],
minify,
platform: "browser",
outfile: "dist/web/extension.js",
});

// Build the data inspector
esbuild
.build({
entryPoints: ["media/data_inspector/inspector.ts"],
tsconfig: "./tsconfig.json",
bundle: true,
external: ["vscode"],
sourcemap: watch ? "inline" : false,
minify,
watch,
platform: "browser",
outfile: "dist/inspector.js",
})
.catch(() => process.exit(1));
build({
entryPoints: ["media/data_inspector/inspector.ts"],
tsconfig: "./tsconfig.json",
bundle: true,
external: ["vscode"],
sourcemap: watch ? "inline" : false,
minify,
platform: "browser",
outfile: "dist/inspector.js",
});

// Build the webview editors
esbuild
.build({
entryPoints: ["media/editor/hexEdit.tsx"],
tsconfig: "./tsconfig.json",
bundle: true,
external: ["vscode"],
sourcemap: watch,
minify,
watch,
platform: "browser",
outfile: "dist/editor.js",
define: defineProd
? {
"process.env.NODE_ENV": defineProd ? '"production"' : '"development"',
}
: undefined,
plugins: [svgr(), css({ v2: true, filter: /\.css$/i })],
})
.catch(() => process.exit(1));
build({
entryPoints: ["media/editor/hexEdit.tsx"],
tsconfig: "./tsconfig.json",
bundle: true,
external: ["vscode"],
sourcemap: watch,
minify,
platform: "browser",
outfile: "dist/editor.js",
define: defineProd
? {
"process.env.NODE_ENV": defineProd ? '"production"' : '"development"',
}
: undefined,
plugins: [svgr(), css({ v2: true, filter: /\.css$/i })],
});
2 changes: 0 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
"@typescript-eslint/eslint-plugin"
],
"rules": {
"quotes": ["error", "double"],
"semi": ["error", "always"],
"no-console": "off",
"no-var": 1,
"no-case-declarations": 0,
Expand Down
4 changes: 1 addition & 3 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"dbaeumer.vscode-eslint"
]
"recommendations": ["dbaeumer.vscode-eslint", "esbenp.prettier-vscode"]
}
6 changes: 3 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Place your settings in this file to overwrite default and user settings.
{
"editor.defaultFormatter": "vscode.typescript-language-features",
"editor.defaultFormatter": "esbenp.prettier-vscode",
"files.exclude": {
"out": false // set this to true to hide the "out" folder with the compiled JS files
},
Expand All @@ -14,10 +14,10 @@
"typescript.preferences.quoteStyle": "double",
"editor.formatOnSave": true,
"[typescriptreact]": {
"editor.defaultFormatter": "vscode.typescript-language-features"
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescript]": {
"editor.defaultFormatter": "vscode.typescript-language-features"
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[css]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
Expand Down
3 changes: 2 additions & 1 deletion media/data_inspector/dataInspector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export function populateDataInspector(arrayBuffer: ArrayBuffer, littleEndian: bo
* @param {ByteData} arrayBuffer The ArrayBuffer object to represent on the data inspector
*/
export function changeEndianness(arrayBuffer: ArrayBuffer): void {
const littleEndian = (document.getElementById("endianness") as HTMLInputElement).value === "little";
const littleEndian =
(document.getElementById("endianness") as HTMLInputElement).value === "little";
populateDataInspector(arrayBuffer, littleEndian);
}
20 changes: 13 additions & 7 deletions media/data_inspector/inspector.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

import { buildDataInspectorUi, changeEndianness, clearDataInspector, populateDataInspector } from "./dataInspector";
import {
buildDataInspectorUi,
changeEndianness,
clearDataInspector,
populateDataInspector,
} from "./dataInspector";

declare const acquireVsCodeApi: any;
export const vscode = acquireVsCodeApi();
let currentByteData: ArrayBuffer;



// Self executing anonymous function
// This is the main entry point
((): void => {

buildDataInspectorUi();

// Handle messages which are sent to the inspector
window.addEventListener("message", async e => {
switch (e.data.method) {
case "update":
currentByteData = e.data.data;
populateDataInspector(currentByteData, (document.getElementById("endianness") as HTMLSelectElement).value === "little");
populateDataInspector(
currentByteData,
(document.getElementById("endianness") as HTMLSelectElement).value === "little",
);
return;
case "clear":
clearDataInspector();
Expand All @@ -34,5 +39,6 @@ let currentByteData: ArrayBuffer;
})();

// Bind an event listener to detect when the user changes the endinaness
document.getElementById("endianness")?.addEventListener("change", () => changeEndianness(currentByteData));

document
.getElementById("endianness")
?.addEventListener("change", () => changeEndianness(currentByteData));
Loading

0 comments on commit 604d763

Please sign in to comment.