Skip to content

Commit 459e13a

Browse files
committed
build: add lint workflow
1 parent 2edf633 commit 459e13a

File tree

15 files changed

+1313
-76
lines changed

15 files changed

+1313
-76
lines changed

.github/workflows/.gitkeep

Whitespace-only changes.

.github/workflows/lint.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
lint:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v4
14+
15+
- name: Set up Node.js
16+
uses: actions/setup-node@v4
17+
with:
18+
node-version: '20'
19+
20+
- name: Install dependencies
21+
run: npm install
22+
23+
- name: Run lint
24+
run: npm run lint

eslint.config.mjs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import js from '@eslint/js';
2+
import tseslint from 'typescript-eslint';
3+
4+
export default tseslint.config(
5+
js.configs.recommended,
6+
tseslint.configs.recommended,
7+
{
8+
rules: {
9+
'@typescript-eslint/no-unused-vars': [
10+
'error',
11+
{
12+
argsIgnorePattern: '^_',
13+
varsIgnorePattern: '^_',
14+
caughtErrors: 'none',
15+
}
16+
],
17+
}
18+
}
19+
);

lib/bindings/messaging.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,12 @@ export const removeEventListener = eventTarget.removeEventListener.bind(eventTar
131131
/**
132132
* Dispatch an event to the host process.
133133
*/
134+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
134135
function dispatchEventToHost(type: 'rpcRequest', detail: { method: string, args: any[] }): number;
136+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
135137
function dispatchEventToHost(type: 'rpcResponse', detail: { success: boolean, data?: any, message?: string }): number;
136138
function dispatchEventToHost(type: 'documentEvent', detail: { documentId: number, eventType: number, timestamp: number });
139+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
137140
function dispatchEventToHost(type: 'rpcRequest' | 'rpcResponse' | 'documentEvent', detail: any): number {
138141
return nativeEventTarget.dispatchEvent({
139142
type: eventNameToType(type),
@@ -181,13 +184,17 @@ export function reportDocumentEvent(
181184
* @param args the arguments to pass to the remote method.
182185
* @returns a promise that resolves with the response data.
183186
*/
187+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
184188
export const makeRpcCall = function makeRpcCallToNative(method: string, args: any[]) {
185189
const reqId = dispatchEventToHost('rpcRequest', { method, args });
186190
if (typeof reqId !== 'number') {
187191
throw new Error('Failed to make rpc call to the host process: invalid request id.');
188192
}
193+
194+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
189195
return new Promise<any>((resolve, reject) => {
190196
RpcRequestWaitlist.set(reqId, (responseText: string) => {
197+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
191198
let json: any;
192199
try {
193200
json = JSON.parse(responseText) || {};

lib/events/error-event.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export class ErrorEventImpl extends Event implements ErrorEvent {
22
colno: number;
3+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
34
error: any;
45
filename: string;
56
lineno: number;

lib/events/mouse-event.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,19 @@ export default class MouseEventImpl extends Event implements MouseEvent {
4343
this.movementY = eventInitDict.movementY;
4444
}
4545

46-
getModifierState(keyArg: string): boolean {
46+
getModifierState(_keyArg: string): boolean {
4747
throw new Error("Method not implemented.");
4848
}
49-
initMouseEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, ctrlKeyArg: boolean, altKeyArg: boolean, shiftKeyArg: boolean, metaKeyArg: boolean, buttonArg: number, relatedTargetArg: EventTarget): void {
49+
initMouseEvent(_typeArg: string,
50+
_canBubbleArg: boolean, _cancelableArg: boolean, _viewArg: Window, _detailArg: number,
51+
_screenXArg: number, _screenYArg: number, _clientXArg: number, _clientYArg: number,
52+
_ctrlKeyArg: boolean, _altKeyArg: boolean, _shiftKeyArg: boolean, _metaKeyArg: boolean,
53+
_buttonArg: number,
54+
_relatedTargetArg: EventTarget): void {
5055
throw new Error("Method not implemented.");
5156
}
52-
initUIEvent(typeArg: string, bubblesArg?: boolean, cancelableArg?: boolean, viewArg?: Window, detailArg?: number): void {
57+
initUIEvent(_typeArg: string,
58+
_bubblesArg?: boolean, _cancelableArg?: boolean, _viewArg?: Window, _detailArg?: number): void {
5359
throw new Error("Method not implemented.");
5460
}
5561
}

lib/navigator/index.ts

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,39 +11,44 @@ class NavigatorImpl implements Navigator {
1111
serviceWorker: ServiceWorkerContainer;
1212
userActivation: UserActivation;
1313
wakeLock: WakeLock;
14-
canShare(data?: ShareData): boolean {
14+
15+
canShare(_data?: ShareData): boolean {
1516
throw new Error('Method not implemented.');
1617
}
1718
getGamepads(): Gamepad[] {
1819
throw new Error('Method not implemented.');
1920
}
20-
requestMIDIAccess(options?: MIDIOptions): Promise<MIDIAccess> {
21+
requestMIDIAccess(_options?: MIDIOptions): Promise<MIDIAccess> {
2122
throw new Error('Method not implemented.');
2223
}
2324
requestMediaKeySystemAccess(keySystem: string, supportedConfigurations: MediaKeySystemConfiguration[]): Promise<MediaKeySystemAccess>;
2425
requestMediaKeySystemAccess(keySystem: string, supportedConfigurations: Iterable<MediaKeySystemConfiguration>): Promise<MediaKeySystemAccess>;
25-
requestMediaKeySystemAccess(keySystem: unknown, supportedConfigurations: unknown): Promise<MediaKeySystemAccess> {
26+
requestMediaKeySystemAccess(_keySystem: unknown, _supportedConfigurations: unknown): Promise<MediaKeySystemAccess> {
2627
throw new Error('Method not implemented.');
2728
}
28-
sendBeacon(url: string | URL, data?: BodyInit): boolean {
29+
sendBeacon(_url: string | URL, _data?: BodyInit): boolean {
2930
throw new Error('Method not implemented.');
3031
}
31-
share(data?: ShareData): Promise<void> {
32+
share(_data?: ShareData): Promise<void> {
3233
throw new Error('Method not implemented.');
3334
}
3435
vibrate(pattern: VibratePattern): boolean;
3536
vibrate(pattern: Iterable<number>): boolean;
36-
vibrate(pattern: unknown): boolean {
37+
vibrate(_pattern: unknown): boolean {
3738
throw new Error('Method not implemented.');
3839
}
40+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
3941
mozGetVRDevices: (any: any) => any;
40-
webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: any, errorCallback: any): void {
42+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
43+
webkitGetUserMedia(_constraints: MediaStreamConstraints, _successCallback: any, _errorCallback: any): void {
4144
throw new Error('Method not implemented.');
4245
}
43-
mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: any, errorCallback: any): void {
46+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
47+
mozGetUserMedia(_constraints: MediaStreamConstraints, _successCallback: any, _errorCallback: any): void {
4448
throw new Error('Method not implemented.');
4549
}
46-
msGetUserMedia(constraints: MediaStreamConstraints, successCallback: any, errorCallback: any): void {
50+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
51+
msGetUserMedia(_constraints: MediaStreamConstraints, _successCallback: any, _errorCallback: any): void {
4752
throw new Error('Method not implemented.');
4853
}
4954
webkitGetGamepads(): Gamepad[] {
@@ -82,10 +87,10 @@ class NavigatorImpl implements Navigator {
8287
clearAppBadge(): Promise<void> {
8388
throw new Error('Method not implemented.');
8489
}
85-
setAppBadge(contents?: number): Promise<void> {
90+
setAppBadge(_contents?: number): Promise<void> {
8691
throw new Error('Method not implemented.');
8792
}
88-
registerProtocolHandler(scheme: string, url: string | URL): void {
93+
registerProtocolHandler(_scheme: string, _url: string | URL): void {
8994
throw new Error('Method not implemented.');
9095
}
9196
hardwareConcurrency: number;

lib/nodejs-patches/textdecoder.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class TextDecoderForWin1252 implements TextDecoder {
4747
}
4848
}
4949

50-
globalThis.TextDecoder = function _TextDecoder(label?: string, options?: TextDecoderOptions) {
50+
function _TextDecoder(label?: string, options?: TextDecoderOptions) {
5151
if (labelsOfWin1252.includes(label)) {
5252
return new TextDecoderForWin1252(options);
5353
} else {
@@ -56,4 +56,7 @@ globalThis.TextDecoder = function _TextDecoder(label?: string, options?: TextDec
5656
fatal: false,
5757
});
5858
}
59-
} as any;
59+
}
60+
61+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
62+
globalThis.TextDecoder = _TextDecoder as any;

lib/runtime2/index.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export class TransmuteRuntime2 extends EventTarget {
7373
*/
7474
const exts = gl.getSupportedExtensions();
7575
console.info(`[WebGL] supported extensions(${exts.length}):`);
76-
for (let extName of exts) {
76+
for (const extName of exts) {
7777
console.info(` - ${extName}`);
7878
}
7979
console.info(`[JSARDOM] version=${JSARDOM.version}`);
@@ -163,8 +163,10 @@ export class TransmuteRuntime2 extends EventTarget {
163163
loadAsHTML = false;
164164
break;
165165
case '.splinecode':
166-
const sourceBlob = new Blob([createSplineDesignViewer(codeOrUrl)], { type: 'text/plain' });
167-
codeOrUrl = URL.createObjectURL(sourceBlob);
166+
{
167+
const sourceBlob = new Blob([createSplineDesignViewer(codeOrUrl)], { type: 'text/plain' });
168+
codeOrUrl = URL.createObjectURL(sourceBlob);
169+
}
168170
break;
169171
default:
170172
break;

lib/webgl/WebGL2RenderingContext.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { wrapWebGLRenderingContext } from './WebGLRenderingContext';
22

3+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
34
export function wrapWebGL2RenderingContext(impl: any): WebGL2RenderingContext {
45
return Object.assign(
56
wrapWebGLRenderingContext(impl) as WebGL2RenderingContext, // wrap for WebGL1 first

0 commit comments

Comments
 (0)