Skip to content

ref(eslint): directly extend from tseslint preset configs#113189

Merged
JoshuaKGoldberg merged 9 commits intomasterfrom
tseslint-preset-configs
Apr 17, 2026
Merged

ref(eslint): directly extend from tseslint preset configs#113189
JoshuaKGoldberg merged 9 commits intomasterfrom
tseslint-preset-configs

Conversation

@JoshuaKGoldberg
Copy link
Copy Markdown
Member

@JoshuaKGoldberg JoshuaKGoldberg commented Apr 16, 2026

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 extends option. 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:

  • Getting new recommended rules automatically as devDependencies get bumped
  • Necessary little oddities such as extension rules are handled for us
  • Opt-out rather than opt-in: making any exemptions of rules explicit
  • Over time, as we remove opt-outs, simpler ESLint config objects

If we like this, I can send PRs for ESLint core, unicorn, etc. too.

Fixes ENG-7368

@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Apr 16, 2026
Comment thread eslint.config.ts Outdated
@linear-code
Copy link
Copy Markdown

linear-code bot commented Apr 16, 2026

Comment thread eslint.config.ts
// Customization
'prefer-spread': 'off',
'@typescript-eslint/prefer-enum-initializers': 'error',
'no-unused-expressions': 'off', // Disabled in favor of @typescript-eslint/no-unused-expressions
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

@JoshuaKGoldberg JoshuaKGoldberg marked this pull request as ready for review April 16, 2026 18:29
@JoshuaKGoldberg JoshuaKGoldberg requested a review from a team as a code owner April 16, 2026 18:29
@JoshuaKGoldberg JoshuaKGoldberg requested review from a team, TkDodo and ryan953 April 16, 2026 18:29
Comment thread eslint.config.ts
Comment thread eslint.config.ts
Comment thread eslint.config.ts Outdated
Comment thread eslint.config.ts Outdated
},
},
{
extends: enableTypeAwareLinting ? [typescript.configs.strictTypeChecked] : [],
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

damn, good pattern. if we converted a few months later we'd be on this for sure already. :shipit:

Copy link
Copy Markdown
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ 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.

Comment thread eslint.config.ts Outdated
Comment thread eslint.config.ts
Copy link
Copy Markdown
Collaborator

@TkDodo TkDodo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ship it!

.fn()
.mockImplementation((cb: FrameRequestCallback) => {
return setTimeout(cb, 0);
});
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

Comment thread eslint.config.ts Outdated
JoshuaKGoldberg added a commit that referenced this pull request Apr 17, 2026
I noticed this while poking around for #113189. eslint-plugin-unicorn
now has an `unopinionated` preset we could extend from.
@JoshuaKGoldberg JoshuaKGoldberg merged commit 123cb85 into master Apr 17, 2026
62 of 65 checks passed
@JoshuaKGoldberg JoshuaKGoldberg deleted the tseslint-preset-configs branch April 17, 2026 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants