Skip to content
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

Eslint: Avoid relying on unsafe == and != js behavior #30078

Merged
merged 1 commit into from
Dec 9, 2024

Conversation

s-rigaud
Copy link
Contributor

@s-rigaud s-rigaud commented Dec 9, 2024

Description

Add eslint rule to avoid relying on == or != that can lead to unexpected behavior. Most of the code is already using triple === or !==.

If this PR get approved I will create another one for == usage in addons and examples.

@s-rigaud s-rigaud force-pushed the avoid-double-equal-usage branch from 8239157 to ae91751 Compare December 9, 2024 19:00
Copy link

github-actions bot commented Dec 9, 2024

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 339.2
79.01
339.21
79.01
+2 B
+1 B
WebGPU 485.98
134.92
485.98
134.91
+4 B
-3 B
WebGPU Nodes 485.44
134.82
485.45
134.82
+4 B
-2 B

🌳 Bundle size after tree-shaking

Minimal build including a renderer, camera, empty scene, and dependencies.

Before After Diff
WebGL 465.1
112.06
465.1
112.06
+2 B
+0 B
WebGPU 555.38
150.4
555.38
150.4
+4 B
-4 B
WebGPU Nodes 511.23
140.1
511.23
140.09
+3 B
-2 B

@sunag sunag added this to the r172 milestone Dec 9, 2024
@sunag sunag merged commit 047f7d7 into mrdoob:dev Dec 9, 2024
12 checks passed
@Mugen87
Copy link
Collaborator

Mugen87 commented Dec 10, 2024

I've reverted the rule via de85929 since it is too strict for the addons folder, see discussion in #30089.

@s-rigaud
Copy link
Contributor Author

What do you think about keeping the rule but not applying it in addons for now ? This way the core source code can stay a bit safer and eslint does not complain for addons. The following eslint config does the trick:

  "overrides": [
      {
          "files": ["examples/jsm/**/*.js"],
          "rules": {
              "eqeqeq": "off"
          }
      }
  ]

@s-rigaud s-rigaud deleted the avoid-double-equal-usage branch December 11, 2024 14:24
@Mugen87
Copy link
Collaborator

Mugen87 commented Dec 11, 2024

IMO, we should not start to distinct rules per directories that makes everything unnecessarily complicated. Let's not over-engineer the ESLint usage and keeps things simple.

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.

3 participants