2026-11-02 07:51 UTC
Replies (6)
-
@dan@upvote.au 2026-11-02 09:05
The recommended ESLint rules catch most of the bad stuff, and these days this is all you need in your ESLint config to enable them: import {defineConfig} from 'eslint/config'; import js from '@eslint/js' export default defineConfig([ js.configs.recommended, ]; There’s one use case where == is still commonly used: == null matches both null and undefined. Lint rules that block == usually allows the null case as an exception.
-
@9point6@lemmy.world 2026-11-02 09:08
IIRC modern linter rulesets generally just outright error if you do anything remotely like this.
-
@GeirGrusom@lemmy.world 2026-11-02 09:40
Where’s the >== operator? Because they also have the exact same problem.
-
@ParlimentOfDoom@piefed.zip 2026-11-02 14:42
As someone trying to learn Javascript, it just makes me mad that at this garbage heap of a language is so widely used.
-
@diaphragmwp@discuss.tchncs.de 2026-11-02 16:04
When I had to use JS I wrote JS 1.2 because why not. Fun how I had strings of numbers instead of actual numbers in some for loops, yet it all sort of functioned until something didn’t. I then decided to add Number() to random values just in case.
-
@nykula@piefed.social 2026-11-02 21:37
== has never, ever caused me a single issue. Parsing all server input with type-safe schemas makes sure that where I expect a string, I get a string; where I expect a number, I get a number. Bad data must result in an error before it reaches logic.