Hacker News new | ask | show | jobs
by dtech 1891 days ago
Linting is not the same as typechecking. Take a look at the default available rules [1]. For example number == NaN is valid Javascript, but 99.9% of the time an error. Or you might want to require always using === over ==.

Generally, linting is things that are valid in the language, but still better to do otherwise.

[1] https://eslint.org/docs/rules/

1 comments

I’m aware of the difference just wondering what benefits people have found. Catching == versus === is a good one.
import order, empty function bodies, leading underscores in different scenarios (if you have such conventions), sort object keys (not just alphabetically, but by use, eg. shorthands last { name: 'Jim', surname }...)

There is some overlap and it's not as crucial to have a good linter as it used to be.

Two common rules I like to enforce are no nested ternaries and no unused variables.
tsconfig's noUnusedLocals can help you with the last one.
And it allows you to opt out when needed by starting the variable with an underscore, which is much nicer than eslint-disable-next-line...
Ah nice, I didn't know that. Thanks.