ref(eslint): directly extend from tseslint preset configs#113189
ref(eslint): directly extend from tseslint preset configs#113189JoshuaKGoldberg merged 9 commits intomasterfrom
Conversation
| // Customization | ||
| 'prefer-spread': 'off', | ||
| '@typescript-eslint/prefer-enum-initializers': 'error', | ||
| 'no-unused-expressions': 'off', // Disabled in favor of @typescript-eslint/no-unused-expressions |
There was a problem hiding this comment.
[Explanation] The no-unused-expressions -> @typescript-eslint/no-unused-expressions situation is because the latter is an "extension rule". That's a typescript-eslint rule that replaces a core ESLint one and handles TypeScript-y things better. Presets such as typescript.configs.strict handle disabling core ESLint rules for you.
| }, | ||
| }, | ||
| { | ||
| extends: enableTypeAwareLinting ? [typescript.configs.strictTypeChecked] : [], |
There was a problem hiding this comment.
damn, good pattern. if we converted a few months later we'd be on this for sure already. ![]()
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit ae9e9a0. Configure here.
| .fn() | ||
| .mockImplementation((cb: FrameRequestCallback) => { | ||
| return setTimeout(cb, 0); | ||
| }); |
There was a problem hiding this comment.
[Explanation] We'd previously only enabled the core no-implied-eval, not the extension rule @typescript-eslint/no-implied-eval. That's a bug - the extension rule has better (more aggressive) reporting for things typed any, which cb is.
I noticed this while poking around for #113189. eslint-plugin-unicorn now has an `unopinionated` preset we could extend from.

Currently, the ESLint config objects generally manually configure rules from preset configs. This gives 100% control but is quite verbose and, in some cases, doesn't actually use the prebuilt lists of recommended rules.
This PR switches the typescript-eslint objects to use the new
extendsoption. This means we start off with the preset rules recommended by the plugins, then still can customize/remove rules as we see fit.This is something we recommend in typescript-eslint (and I think other plugins tend to as well), and also something @TkDodo and I were chatting about. IMO the benefits are:
If we like this, I can send PRs for ESLint core, unicorn, etc. too.
Fixes ENG-7368