Skip to content

Commit e32f760

Browse files
committed
chore: renew NodeJs linting
Fix found errors with new linting system
1 parent c67d49b commit e32f760

29 files changed

Lines changed: 729 additions & 726 deletions

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
* text=auto eol=lf
12
*_pb2.py eol=lf
23
*_pb*.[tj]s eol=lf

node/.prettierrc.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
module.exports = {
22
semi: true,
3-
trailingComma: "all",
3+
trailingComma: 'all',
44
singleQuote: true,
55
printWidth: 120,
6-
tabWidth: 4
7-
};
6+
tabWidth: 4,
7+
endOfLine: 'lf',
8+
};

node/build.testapp.js

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,37 @@
11
#!/usr/bin/env node
22

33
const esbuild = require('esbuild');
4-
const { nodeExternalsPlugin } = require('esbuild-node-externals');
54
const fs = require('fs');
6-
const path = require('path')
5+
const path = require('path');
76

8-
const distPath = path.resolve(__dirname, './dynamic-test-app/dist')
7+
const distPath = path.resolve(__dirname, './dynamic-test-app/dist');
98

109
if (!fs.existsSync(distPath)) {
11-
fs.mkdirSync(distPath);
10+
fs.mkdirSync(distPath);
1211
}
1312

14-
const indexHtmlSource = path.resolve(__dirname, './dynamic-test-app/static/index.html')
15-
const indexHtmlTarget = path.resolve(distPath, './index.html')
16-
fs.copyFileSync(indexHtmlSource, indexHtmlTarget)
13+
const indexHtmlSource = path.resolve(__dirname, './dynamic-test-app/static/index.html');
14+
const indexHtmlTarget = path.resolve(distPath, './index.html');
15+
fs.copyFileSync(indexHtmlSource, indexHtmlTarget);
1716

1817
/* Build testApp frontend */
19-
esbuild.build(
20-
{
21-
logLevel: "info",
22-
entryPoints: ['./node/dynamic-test-app/src/index.tsx'],
23-
bundle: true,
24-
platform: "browser",
25-
outfile: "./node/dynamic-test-app/dist/index.js",
26-
}
27-
).catch(() => process.exit(1));
18+
esbuild
19+
.build({
20+
logLevel: 'info',
21+
entryPoints: ['./node/dynamic-test-app/src/index.tsx'],
22+
bundle: true,
23+
platform: 'browser',
24+
outfile: './node/dynamic-test-app/dist/index.js',
25+
})
26+
.catch(() => process.exit(1));
2827
/* Build testApp backend */
29-
esbuild.build(
30-
{
31-
logLevel: "info",
32-
entryPoints: ["./node/dynamic-test-app/src/server.ts"],
33-
bundle: true,
34-
platform: "node",
35-
outfile: "./node/dynamic-test-app/dist/server.js",
36-
/* plugins: [nodeExternalsPlugin()], */
37-
}
38-
).catch(() => process.exit(1));
28+
esbuild
29+
.build({
30+
logLevel: 'info',
31+
entryPoints: ['./node/dynamic-test-app/src/server.ts'],
32+
bundle: true,
33+
platform: 'node',
34+
outfile: './node/dynamic-test-app/dist/server.js',
35+
/* plugins: [nodeExternalsPlugin()], */
36+
})
37+
.catch(() => process.exit(1));

node/build.wrapper.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22
const esbuild = require('esbuild');
33
const { nodeExternalsPlugin } = require('esbuild-node-externals');
44

5-
esbuild.build(
6-
{
7-
logLevel: "info",
8-
entryPoints: ["./node/playwright-wrapper/index.ts"],
9-
bundle: true,
10-
platform: "node",
11-
outfile: "./Browser/wrapper/index.js",
12-
plugins: [nodeExternalsPlugin({
13-
// Allow UUID to be bundled instead of external
14-
// Needed when building with pkg
15-
allowList: ['uuid']
16-
})],
17-
external: [
18-
'playwright-core/*',
19-
],
20-
}
21-
).catch(() => process.exit(1));
5+
esbuild
6+
.build({
7+
logLevel: 'info',
8+
entryPoints: ['./node/playwright-wrapper/index.ts'],
9+
bundle: true,
10+
platform: 'node',
11+
outfile: './Browser/wrapper/index.js',
12+
plugins: [
13+
nodeExternalsPlugin({
14+
// Allow UUID to be bundled instead of external
15+
// Needed when building with pkg
16+
allowList: ['uuid'],
17+
}),
18+
],
19+
external: ['playwright-core/*'],
20+
})
21+
.catch(() => process.exit(1));

node/dynamic-test-app/src/app.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
import React from 'react';
12
import { HashRouter, Route, Routes } from 'react-router-dom';
3+
24
import DragGame from './draggame';
35
import EventsPage from './events';
46
import Login from './login';
5-
import React from 'react';
67

78
const App: React.FC = () => {
89
return (

node/dynamic-test-app/src/draggame.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// Created by Copilot
22
// This code is a simple drag-and-drop game using React and react-dnd.
3+
import React, { useCallback, useEffect, useState } from 'react';
34
import { DndProvider, useDrag, useDrop } from 'react-dnd';
45
import { HTML5Backend } from 'react-dnd-html5-backend';
5-
import React, { useCallback, useEffect, useState } from 'react';
66

77
const ItemTypes = {
88
CIRCLE: 'circle',

node/dynamic-test-app/src/events.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,9 @@ function EventLogger() {
150150
const handler = (e: Event) => {
151151
const data = buildEventSummary(e);
152152
// Show both wall-clock and monotonic in the visual log
153-
pushVisual(`[${data.time} | ${Math.round(data.mono as number)}ms] ${data.type} on #${data.targetId}`);
153+
pushVisual(
154+
`[${String(data.time)} | ${Math.round(data.mono as number)}ms] ${String(data.type)} on #${String(data.targetId)}`,
155+
);
154156
// Persist full JSON line
155157
pushText(data);
156158
};

node/dynamic-test-app/src/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as React from 'react';
22
import { createRoot } from 'react-dom/client';
3+
34
import App from './app';
45

56
const container = document.getElementById('root');

node/dynamic-test-app/src/login.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,16 @@ function fileUploaded(uploadResultElement: React.RefObject<HTMLElement>, event:
7676
fileNames = files[i].name;
7777
}
7878
}
79-
uploadResultElement.current!.innerHTML = fileNames;
79+
uploadResultElement.current.innerHTML = fileNames;
8080
} else {
81-
uploadResultElement.current!.innerHTML = 'no uploaded file';
81+
uploadResultElement.current.innerHTML = 'no uploaded file';
8282
}
8383
}
8484

8585
function testPrompt(promptResultElement: React.RefObject<HTMLElement>) {
8686
const input = prompt('Enter a value');
87-
if (input) promptResultElement.current!.innerHTML = input;
88-
else promptResultElement.current!.innerHTML = 'prompt_not_filled';
87+
if (input) promptResultElement.current.innerHTML = input;
88+
else promptResultElement.current.innerHTML = 'prompt_not_filled';
8989
}
9090

9191
export default function Site() {
@@ -117,7 +117,9 @@ export default function Site() {
117117
mouseButton.current!.innerHTML = '';
118118
const mouseButtons = ['left', 'middle', 'right'];
119119
mouseButton.current!.innerHTML = mouseButtons[e.button];
120-
console.log(`Mouse button: ${mouseButtons[e.button]}, X: ${e.pageX}, Y: ${e.pageY}, Time: ${new Date()}`);
120+
console.log(
121+
`Mouse button: ${mouseButtons[e.button]}, X: ${e.pageX}, Y: ${e.pageY}, Time: ${new Date().toISOString()}`,
122+
);
121123
altKey.current!.innerHTML = e.altKey.toString();
122124
shiftKey.current!.innerHTML = e.shiftKey.toString();
123125
ctrlKey.current!.innerHTML = e.ctrlKey.toString();
@@ -217,10 +219,10 @@ export default function Site() {
217219
<button id="pops_up" onClick={popup}>
218220
Pops up a window
219221
</button>
220-
<button id="delayed_request" onClick={delayedRequest}>
222+
<button id="delayed_request" onClick={() => void delayedRequest()}>
221223
Fires a request in 200ms
222224
</button>
223-
<button id="delayed_request_big" onClick={delayedRequestBig}>
225+
<button id="delayed_request_big" onClick={() => void delayedRequestBig()}>
224226
Fires a big request in 250ms
225227
</button>
226228
<button id="alerts" onClick={() => alert('Am an alert')}>

node/dynamic-test-app/src/server.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
import { Command } from 'commander';
12
import * as express from 'express';
23
import * as fs from 'fs';
34
import * as https from 'https';
45
import * as path from 'path';
5-
import { Command } from 'commander';
66

77
const app = express.default();
8-
// eslint-disable-next-line
8+
99
app.use(express.json());
1010

1111
const program = new Command();
@@ -173,6 +173,7 @@ if (tls || mutualTls) {
173173
};
174174

175175
https
176+
// eslint-disable-next-line @typescript-eslint/no-misused-promises
176177
.createServer(serverOptions, app)
177178
.listen(port, () => console.log(`Successfully started server on https://localhost:${port}`));
178179
} else {

0 commit comments

Comments
 (0)