8000 fix(typescript-eslint): make exported configs/plugin compatible with `defineConfig()` by kirkwaiblinger · Pull Request #11190 · typescript-eslint/typescript-eslint · GitHub
[go: up one dir, main page]

Skip to content

fix(typescript-eslint): make exported configs/plugin compatible with defineConfig() #11190

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8000
Draft
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

kirkwaiblinger
Copy link
Member
@kirkwaiblinger kirkwaiblinger commented May 8, 2025

Warning

I'll be travelling until May 27th, and don't expect to be able to spend time on this until then. If someone else is able to resolve the remaining failing integration tests in my absence and get this over the finish line, please feel free to do so!

PR Checklist

Overview

This switches our exports to use defineConfig()-compatible types, rather than making our type declarations compatible with eslint core's. The type declarations that we have for things like FlatConfig.Config and such are deliberately wide/loose, since they're meant to be used as a highly permissive parameter type for tseslint.config(). So we don't want to be exporting our configs as those types anymore.

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @kirkwaiblinger!

typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community.

The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately.

Thanks again!


🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint.

Copy link
netlify bot commented May 8, 2025

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit 6730308
🔍 Latest deploy log https://app.netlify.com/projects/typescript-eslint/deploys/68277c2ec2e51100095c60ec
😎 Deploy Preview https://deploy-preview-11190--typescript-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 62 (🔴 down 37 from production)
Accessibility: 100 (no change from production)
Best Practices: 100 (no change from production)
SEO: 98 (no change from production)
PWA: 80 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
nx-cloud bot commented May 8, 2025

View your CI Pipeline Execution ↗ for commit 6730308.

Command Status Duration Result
nx typecheck ast-spec ✅ Succeeded 2s View ↗
nx run-many --target=build --exclude website --... ✅ Succeeded 2s View ↗
nx run-many --target=clean ✅ Succeeded 10s View ↗

☁️ Nx Cloud last updated this comment at 2025-05-16 18:20:58 UTC

@kirkwaiblinger kirkwaiblinger changed the title fix(typescript-eslint): make exported types compatible with defineConfig() fix(typescript-eslint): make exported configs/plugin compatible with defineConfig() May 8, 2025
bradzacher
bradzacher previously approved these changes May 8, 2025
Copy link
Member
@bradzacher bradzacher left a comment

Choose a reason for hiding this comment

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

looks like this change is a net-positive and removes a bunch of errors from the integration tests -- so don't forget to regen the snapshots.


/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion -- These "unnecessary" assertions work around "requires explicit type annotation" errors. */
Copy link
Member

Choose a reason for hiding this comment

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

could this be done as const configs = { ... } satisfies Record<string, eslintConfigHelpers.Config | eslintConfigHelpers.Config[]>?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, well, now I can no longer repro the "requires a type assertion" error at all, maybe because I ended up adding the eslint/config-helpers package in the package.json.

So looks like the satisfies option is available to us (as well as just const configs = { ... }). I'll switch it to satisfies.

};
/* eslint-enable @typescript-eslint/no-unnecessary-type-assertion */

export type Config = TSESLint.FlatConfig.ConfigFile;
Copy link
Member

Choose a reason for hiding this comment

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

I can't remember -- is this the loose type or the strict type?
Perhaps we should deprecate this to rename it? Or change the type to the ESLint types?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is a loose one; it's just a T | Promise<T> version of the type of the parameter type of tseslint.config(...configs).

I think deprecating makes sense 👍

@@ -51,6 +51,7 @@
"check-types": "npx nx typecheck"
},
"dependencies": {
"@eslint/config-helpers": "^0.2",
Copy link
Member

Choose a reason for hiding this comment

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

ugh an 0.x version sucks cos it means that every minor release we'll be forced to update our version or else users will be blocked.

ESLint itself depends on this package so in some future when we drop v8 and older v9 versions -- we would be able to make this a peer dependency and just rely on the version installed that way.

@kirkwaiblinger kirkwaiblinger marked this pull request as ready for review May 16, 2025 16:54
@kirkwaiblinger kirkwaiblinger requested review from bradzacher, aryaemami59 and a team and removed request for aryaemami59 May 16, 2025 16:56
Copy link
codecov bot commented May 16, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.92%. Comparing base (05014ff) to head (6730308).

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #11190   +/-   ##
=======================================
  Coverage   90.92%   90.92%           
=======================================
  Files         499      499           
  Lines       50845    50845           
  Branches     8384     8384           
=======================================
  Hits        46231    46231           
  Misses       4599     4599           
  Partials       15       15           
Flag Coverage Δ
unittest 90.92% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor
@aryaemami59 aryaemami59 left a comment

Choose a reason for hiding this comment

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

Looks great! 👍

@kirkwaiblinger
Copy link
Member Author

ah, wait, redrafting since I forgot about the integration test failures

@kirkwaiblinger kirkwaiblinger marked this pull request as draft May 16, 2025 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: typescript-eslint config types are incompatible with defineConfig() types
3 participants
0