Skip to content

Commit 0f9542c

Browse files
committed
chore(core): pass linting (a lot looser than other since core is supposed to be a bit flexible)
1 parent fe96a8c commit 0f9542c

File tree

7 files changed

+67
-36
lines changed

7 files changed

+67
-36
lines changed

libs/core/.eslintrc.json

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,32 @@
66
"files": ["*.ts"],
77
"extends": ["plugin:@nx/angular", "plugin:@angular-eslint/template/process-inline-templates"],
88
"rules": {
9-
"@angular-eslint/directive-selector": 0,
10-
"@angular-eslint/component-selector": 0,
11-
"@angular-eslint/component-class-suffix": 0,
12-
"@angular-eslint/directive-class-suffix": 0,
13-
"@angular-eslint/no-host-metadata-property": 0,
14-
"@angular-eslint/no-input-rename": 0,
15-
"@typescript-eslint/no-explicit-any": 0,
16-
"@typescript-eslint/no-empty-function": 0
9+
"@angular-eslint/directive-selector": "off",
10+
"@angular-eslint/component-selector": "off",
11+
"@angular-eslint/component-class-suffix": "off",
12+
"@angular-eslint/directive-class-suffix": "off",
13+
"@angular-eslint/no-host-metadata-property": "off",
14+
"@angular-eslint/no-input-rename": "off",
15+
"@typescript-eslint/no-explicit-any": "off",
16+
"@typescript-eslint/no-empty-function": "off",
17+
"@typescript-eslint/no-non-null-assertion": "off",
18+
"@typescript-eslint/ban-types": "off",
19+
"@typescript-eslint/no-empty-interface": "off",
20+
"@typescript-eslint/no-unused-vars": ["warn", { "argsIgnorePattern": "^_", "varsIgnorePattern": "^_" }]
1721
}
1822
},
23+
{
24+
"files": ["*.spec.ts"],
25+
"rules": {
26+
"@nx/enforce-module-boundaries": "off"
27+
}
28+
},
29+
{
30+
"files": ["web-gl-rendering-context.ts"],
31+
"rules": {
32+
"@typescript-eslint/ban-ts-comment": "off"
33+
}
34+
},
1935
{
2036
"files": ["*.html"],
2137
"extends": ["plugin:@nx/angular-template"],
@@ -25,7 +41,22 @@
2541
"files": ["*.json"],
2642
"parser": "jsonc-eslint-parser",
2743
"rules": {
28-
"@nx/dependency-checks": "error"
44+
"@nx/dependency-checks": [
45+
"error",
46+
{
47+
"ignoredDependencies": [
48+
"@analogjs/vite-plugin-angular",
49+
"@angular/router",
50+
"@nx/devkit",
51+
"@nx/vite",
52+
"@phenomnomnominal/tsquery",
53+
"nx",
54+
"rxjs",
55+
"tslib",
56+
"vite"
57+
]
58+
}
59+
]
2960
}
3061
}
3162
]

libs/core/src/lib/loop.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ function createLoop<TCanvas>(roots: Map<TCanvas, NgtSignalStore<NgtState>>) {
147147

148148
function advance(
149149
timestamp: number,
150-
runGlobalEffects: boolean = true,
150+
runGlobalEffects = true,
151151
store?: NgtSignalStore<NgtState>,
152152
frame?: XRFrame,
153153
): void {

libs/core/src/lib/renderer/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export class NgtRenderer implements Renderer2 {
128128
if (name === SPECIAL_DOM_TAG.NGT_PRIMITIVE) {
129129
if (!injectedArgs[0]) throw new Error(`[NGT] ngt-primitive without args is invalid`);
130130
const object = injectedArgs[0];
131-
let localState = getLocalState(object);
131+
const localState = getLocalState(object);
132132
if (!localState) {
133133
// NOTE: if an object isn't already "prepared", we prepare it
134134
prepare(object, { store: this.rootStore, primitive: true });
@@ -328,7 +328,7 @@ export class NgtRenderer implements Renderer2 {
328328
el: NgtRendererNode,
329329
name: string,
330330
value: string,
331-
namespace?: string | null | undefined,
331+
_namespace?: string | null | undefined,
332332
): boolean {
333333
const rS = el.__ngt_renderer__;
334334
if (rS[NgtRendererClassId.destroyed]) return false;

libs/core/src/lib/renderer/utils.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ export function attachThreeChild(parent: NgtInstanceNode, child: NgtInstanceNode
4747

4848
// whether the child is added to the parent with parent.add()
4949
let added = false;
50-
let attached = false;
5150

5251
// assign store on child if not already exist
5352
// or child store is not the same as parent store

libs/core/src/lib/roots.ts

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,19 @@ export function injectCanvasRootInitializer(injector?: Injector) {
5656
const root = roots.get(canvas);
5757
if (root) {
5858
root.update((state) => ({ internal: { ...state.internal, active: false } }));
59-
try {
60-
const state = root.get();
61-
state.events.disconnect?.();
62-
state.gl?.renderLists?.dispose?.();
63-
state.gl?.forceContextLoss?.();
64-
if (state.gl?.xr) state.xr.disconnect();
65-
dispose(state);
66-
roots.delete(canvas);
67-
} catch (e) {
68-
console.error('[NGT] Unexpected error while destroying Canvas Root', e);
69-
}
59+
setTimeout(() => {
60+
try {
61+
const state = root.get();
62+
state.events.disconnect?.();
63+
state.gl?.renderLists?.dispose?.();
64+
state.gl?.forceContextLoss?.();
65+
if (state.gl?.xr) state.xr.disconnect();
66+
dispose(state);
67+
roots.delete(canvas);
68+
} catch (e) {
69+
console.error('[NGT] Unexpected error while destroying Canvas Root', e);
70+
}
71+
}, timeout);
7072
}
7173
},
7274
configure: (inputs: NgtCanvasOptions) => {
@@ -235,8 +237,8 @@ export function injectCanvasRootInitializer(injector?: Injector) {
235237
// Avoid accessing ColorManagement to play nice with older versions
236238
if (ColorManagement) {
237239
const colorManagement = ColorManagement as NgtAnyRecord;
238-
if ('enabled' in colorManagement) colorManagement['enabled'] = !legacy ?? false;
239-
else if ('legacyMode' in colorManagement) colorManagement['legacyMode'] = legacy ?? true;
240+
if ('enabled' in colorManagement) colorManagement['enabled'] = !legacy;
241+
else if ('legacyMode' in colorManagement) colorManagement['legacyMode'] = legacy;
240242
}
241243

242244
if (!isConfigured) {

libs/core/src/lib/utils/attach.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,7 @@ export function attach(object: NgtAnyRecord, value: unknown, paths: string[] = [
1616
}
1717
}
1818

19-
export function detach(
20-
parent: NgtAnyRecord,
21-
child: NgtAnyRecord,
22-
attachProp: string[] | NgtAttachFunction,
23-
useApplyProps = false,
24-
) {
19+
export function detach(parent: NgtAnyRecord, child: NgtAnyRecord, attachProp: string[] | NgtAttachFunction) {
2520
const childLocalState = getLocalState(child);
2621
if (childLocalState) {
2722
if (Array.isArray(attachProp)) attach(parent, childLocalState.previousAttach, attachProp, childLocalState.isRaw);

libs/core/testing/src/lib/utils/mock-canvas.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,22 @@ export function createMockCanvas({
2828

2929
if (globalThis.HTMLCanvasElement) {
3030
const getContext = HTMLCanvasElement.prototype.getContext;
31-
HTMLCanvasElement.prototype.getContext = function (this: HTMLCanvasElement, id: string) {
31+
HTMLCanvasElement.prototype.getContext = function (
32+
this: HTMLCanvasElement,
33+
...args: Parameters<typeof getContext>
34+
) {
35+
const id = args[0];
3236
if (id.startsWith('webgl')) return new WebGL2RenderingContext(this);
33-
return getContext.apply(this, arguments as any);
37+
return getContext.apply(this, args);
3438
} as any;
3539
}
3640

3741
beforeReturn?.(canvas);
3842

3943
class WebGLRenderingContext extends WebGL2RenderingContext {}
40-
// @ts-expect-error
44+
// @ts-expect-error - WebGLRenderingContext is not defined in the global scope for non-browser
4145
globalThis.WebGLRenderingContext ??= WebGLRenderingContext;
42-
// @ts-expect-error
46+
// @ts-expect-error - WebGL2RenderingContext is not defined in the global scope for non-browser
4347
globalThis.WebGL2RenderingContext ??= WebGL2RenderingContext;
4448

4549
return canvas;

0 commit comments

Comments
 (0)