Skip to content

Naming conventions - linting #16455

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 64 commits into
base: master
Choose a base branch
from
Draft

Conversation

RaananW
Copy link
Member

@RaananW RaananW commented Apr 7, 2025

If you have any questions, contact me!

Draft to give everyone time to review and present me with questions.

NOTE - lint currently fails due to javascript out of heap memory. The last few commits are just attempts to get the CI to play nicely. Once I have the solution I will clean the config file and the command running eslint

@bjsplat
Copy link
Collaborator

bjsplat commented Apr 9, 2025

@bjsplat
Copy link
Collaborator

bjsplat commented Apr 9, 2025

Reviewer - this PR has made changes to one or more package.json files.

@bjsplat
Copy link
Collaborator

bjsplat commented Apr 9, 2025

@bjsplat
Copy link
Collaborator

bjsplat commented Apr 9, 2025

You have changed file(s) that made possible changes to the sandbox.
You can test the sandbox snapshot here:

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/SANDBOX/refs/pull/16455/merge/

@bjsplat
Copy link
Collaborator

bjsplat commented Apr 9, 2025

You have made possible changes to the playground.
You can test the snapshot here:

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/PLAYGROUND/refs/pull/16455/merge/

The snapshot playground with the CDN snapshot (only when available):

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/PLAYGROUND/refs/pull/16455/merge/?snapshot=refs/pull/16455/merge

Note that neither Babylon scenes nor textures are uploaded to the snapshot directory, so some playgrounds won't work correctly.

@bjsplat
Copy link
Collaborator

bjsplat commented Apr 9, 2025

@bjsplat
Copy link
Collaborator

bjsplat commented Apr 9, 2025

Copy link
Contributor

@docEdub docEdub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked over the audio engine changes and they all look good to me. Thanks!

Copy link
Contributor

@bghgary bghgary left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed some files (up to camera inputs, skipping the audio files). There are many similar issues, so I'm going to stop until we decide what to do with them.

@@ -10,8 +10,8 @@ import type { Observer } from "core/Misc/observable";
import { Logger } from "core/Misc/logger";
import type { AbstractEngine } from "core/Engines";

const _positionUpdateFailMessage = "Failed to update html mesh renderer position due to failure to get canvas rect. HtmlMesh instances may not render correctly";
const babylonUnitsToPixels = 100;
const _PositionUpdateFailMessage = "Failed to update html mesh renderer position due to failure to get canvas rect. HtmlMesh instances may not render correctly";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need an underscore?

Copy link
Member Author

@RaananW RaananW Apr 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this was an old rule that was changed and will be reverted tomorrow. Same with all of those that I didn't revert
Sorry - no, we don't need the underscore, but those had underscore already. No underscore was added, it is just the unchanged defined naming convention. I will remove all underscores from non-exported global members to stay consistent and will remove the underscore from the rule

@@ -297,7 +297,7 @@ export class HtmlMeshRenderer {
}

// prettier-ignore
protected _getCameraCSSMatrix(matrix: Matrix): string {
protected _getCameraCssMatrix(matrix: Matrix): string {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our coding standards doc (not public) says to use all caps for initialisms. Can linting even tell the difference between initialisms and abbreviations? Maybe we need to modify the doc.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Abbreviations are an interesting topic that I will be happy to discuss. We do support abbreviations, but they need to be manually added to the lint file. Let's talk about it tomorrow.

Copy link
Member Author

@RaananW RaananW Apr 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our coding standards doc (not public) says to use all caps for initialisms.

Not the new docs, which states:

Abbreviations
[Strict] case (e.g. getMeshById, not getMeshByID)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know what new docs you mean, but abbreviations are not the same as initialisms.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, but that was what it meant. we can discuss this. Anyhow, abbreviations are supported (and configured). You can see it in the linting file (the first line).
StringPascalCase for example, does not support abbreviations. so It should be HtmlCssSupportId. However, with known and supported abbreviations (or initialisms :-) ) we fallback to CamelCase

@bjsplat
Copy link
Collaborator

bjsplat commented Apr 10, 2025

Reviewer - this PR has made changes to one or more package.json files.

@bjsplat
Copy link
Collaborator

bjsplat commented Apr 10, 2025

Graph tools CI has failed you can find the test results at:

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/TOOLS/refs/pull/16455/merge/testResults/

@bjsplat
Copy link
Collaborator

bjsplat commented Apr 10, 2025

You have made possible changes to the playground.
You can test the snapshot here:

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/PLAYGROUND/refs/pull/16455/merge/

The snapshot playground with the CDN snapshot (only when available):

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/PLAYGROUND/refs/pull/16455/merge/?snapshot=refs/pull/16455/merge

Note that neither Babylon scenes nor textures are uploaded to the snapshot directory, so some playgrounds won't work correctly.

@bjsplat
Copy link
Collaborator

bjsplat commented Apr 10, 2025

@bjsplat
Copy link
Collaborator

bjsplat commented Apr 10, 2025

You have changed file(s) that made possible changes to the sandbox.
You can test the sandbox snapshot here:

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/SANDBOX/refs/pull/16455/merge/

@bjsplat
Copy link
Collaborator

bjsplat commented Apr 10, 2025

@bjsplat
Copy link
Collaborator

bjsplat commented Apr 10, 2025

@bjsplat
Copy link
Collaborator

bjsplat commented Apr 10, 2025

Reviewer - this PR has made changes to one or more package.json files.

@bjsplat
Copy link
Collaborator

bjsplat commented Apr 10, 2025

@bjsplat
Copy link
Collaborator

bjsplat commented Apr 10, 2025

You have made possible changes to the playground.
You can test the snapshot here:

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/PLAYGROUND/refs/pull/16455/merge/

The snapshot playground with the CDN snapshot (only when available):

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/PLAYGROUND/refs/pull/16455/merge/?snapshot=refs/pull/16455/merge

Note that neither Babylon scenes nor textures are uploaded to the snapshot directory, so some playgrounds won't work correctly.

@bjsplat
Copy link
Collaborator

bjsplat commented Apr 10, 2025

You have changed file(s) that made possible changes to the sandbox.
You can test the sandbox snapshot here:

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/SANDBOX/refs/pull/16455/merge/

@bjsplat
Copy link
Collaborator

bjsplat commented Apr 10, 2025

@bjsplat
Copy link
Collaborator

bjsplat commented Apr 10, 2025

@@ -1,3 +1,110 @@
// want to add a new allowed abbreviation? Feer not! Just add it to the regex below.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// want to add a new allowed abbreviation? Feer not! Just add it to the regex below.
// want to add a new allowed abbreviation? Fear not! Just add it to the regex below.

@@ -20,7 +20,7 @@ const FitStrategyContain: FitStrategyType = {
sizingElement.style.width = `${width}px`;
sizingElement.style.height = `${height}px`;

const [childWidth, childHeight] = [scalingElement!.offsetWidth, scalingElement!.offsetHeight];
const [childWidth, childHeight] = [scalingElement.offsetWidth, scalingElement.offsetHeight];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are unnecessary non-null assertions now flagged?

@@ -49,11 +49,13 @@ export class PointerDragBehavior implements Behavior<AbstractMesh> {
* Get or set the currentDraggingPointerId
* @deprecated Please use currentDraggingPointerId instead
*/
// eslint-disable-next-line @typescript-eslint/naming-convention
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do this for existing public APIs that don't follow the naming conventions, but for new stuff it should be enforced, is that right?

@@ -861,7 +862,7 @@ export class Viewer implements IDisposable {
},
suspendRendering: () => this._suspendRendering(),
markSceneMutated: () => this._markSceneMutated(),
pick: (screenX: number, screenY: number) => this._pick(screenX, screenY),
pick: async (screenX: number, screenY: number) => this._pick(screenX, screenY),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is async needed here?

@@ -6,7 +6,7 @@ import { Logger } from "core/Misc/logger";
import { ConfigureCustomViewerElement } from "viewer/viewerElement";
import "viewer";

interface HTML3DElementAttributes extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> {
interface IHTML3DElementAttributes extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, this gets weird where we have to decide whether it makes more sense to align with Babylon naming conventions or React naming conventions.

@@ -10,6 +10,7 @@ import { useEffect, useState } from "react";
* @param eventNames The names of the events to listen for.
* @returns The current value of the accessor.
*/
// eslint-disable-next-line @typescript-eslint/naming-convention
export function useEventfulState<T>(accessor: () => T, element: HTMLElement | null | undefined, ...eventNames: string[]): T {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These functions are really only intended for internal use within the Configurator, so I would think it would be fine to update the casing.

document.removeEventListener("pointermove", onPointerMove);
document.removeEventListener("touchstart", onPointerMove);
_scene = null;
const SoStopCaptureOnEnter = () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be Do… :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants