-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix(utils): add missing fields to flat config types #7933
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
Conversation
Thanks for the PR, @bradzacher! 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. |
✅ Deploy Preview for typescript-eslint ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIL "stringly"
Nice, thanks! I'll check this out when this lands in |
For visibility, we publish canary builds on every commit to (not saying you need to try them - just that if anybody urgently wants this ASAP, the canaries are an option 😄) |
Ok thanks, I decided to try out the canary / alpha releases and upgraded to Notes: The reason I'm still casting like this is that I want a runtime error if // eslint-disable-next-line rest-spread-spacing -- Allow JSDoc casting
.../** @type {Exclude<Exclude<import('@typescript-eslint/utils/ts-eslint').FlatConfig.Plugin['configs'], undefined>[string], undefined>} */ (
/** @type {Exclude<import('@typescript-eslint/utils/ts-eslint').FlatConfig.Plugin['configs'], undefined>} */ (
jsxA11y.configs
).recommended
).rules, An alternative that I used lower down (to throw a more helpful error) is to first assign the potentially- const firstConfig = config[0];
if (!firstConfig || !firstConfig.plugins || !firstConfig.rules) {
throw new Error(
`SafeQL configuration failed
The UpLeveled ESLint config object does not contain all of the properties: .plugins, .rules`,
);
}
firstConfig.plugins['@ts-safeql'] = await import('@ts-safeql/eslint-plugin');
firstConfig.rules['@ts-safeql/check-sql'] = [
// ... |
@karlhorky FYI you're doing things a little incorrectly here! If you have a look at #7935 you can see how I typed things. We can probably expose better types here though to make this easier. I.e. We should probably expose a type like You also should be using the compat tooling instead of deeply pulling apart the config. I still don't know the "best" way to do this style of "extend multiple configs for a given set of files. I asked on E ESLint discord (https://discord.com/channels/688543509199716507/1174310123791990866) but I got ignored... Might need try pinging again. |
Yeah, I'm aware I'm faking the types a bit in some places (this is to avoid having to know / keep updated on which plugins expose which type of config). Maybe I should open PRs to add types to each of the plugins I use... 🤔 so that I don't need to maintain them in my project - and then all consumers will have types. This ESLint config is pretty runtime-tested as is (in many student projects), so it's mostly just making the type system happy and reducing the faking to the least amount possible. But I will for sure watch all new things including #7935 and use anything to make it simpler! |
Overview
This adds the missing fields from #7273
cc @karlhorky