iamturns / eslint-config-airbnb-typescript

Airbnb's ESLint config with TypeScript support
MIT License
1.05k stars 98 forks source link

eslint `valid-typeof` disabled by `airbnb-typescript` & `airbnb-typescript/base` when not explicitly added #327

Open kpvhn opened 1 year ago

kpvhn commented 1 year ago

When extending from eslint:recommended, eslint's built-in valid-typeof is enabled.

However, when further extending from airbnb-typescript[/base], valid-typeof is not enforced any more for TypeScript files but is still working for JavaScript files.

It also works when I explicitly specify the valid-typeof rule myself in .eslintrc.cjs, line 15.

In the attached example, run npm run lint to lint j.js and t.ts.

As you can see, the error in j.js will always show whereas the same error in t.ts does not appear if I extend from airbnb-typescript[/base] and do not explicitly specify valid-typeof myself.

However, as you can see with npm run rules, eslint lists the valid-typeof rule in all cases, so it is supposed to be working, as is also indicated by the error in j.js.

It looks like the rule check is somehow skipped for TypeScript.

valid-typeof.tgz

Kenneth-Sills commented 3 months ago

This is working as intended. valid-typeof is in a list of rules we intentionally disable only for .ts(x) files because Typescript naturally covers the use-case. Keeping these rules on would slow down linting for no benefit.