eslint-types / eslint-define-config

Provide a defineConfig function for .eslintrc.js files
MIT License
361 stars 26 forks source link

feat: expose `RuleConfig` etc. #235

Closed antfu closed 1 year ago

antfu commented 1 year ago

Would be easier to add custom types

Shinigami92 commented 1 year ago

TBH I'm not a fan of this 🤔 eslint-define-config is not meant to be a dependency to define custom rules, and originally there are even typescript types in @types/eslint itself we just nearly copied these over so we do not have direct dependencies in the src code

Please have a look at https://github.com/DefinitelyTyped/DefinitelyTyped/blob/d6df71f271f38735049115008ff6b5de169c9450/types/eslint/index.d.ts#L893

These should be changed/used originally, but eslint-define-config cant do that, because then it would require a peer dev dependency or fallback to any

antfu commented 1 year ago

Well, it's just a re-export of a few simple types. I see no harm in having them, but I am not blocked by it either. Totally up to you to decide then.

Shinigami92 commented 1 year ago

Well, it's just a re-export of a few simple types. I see no harm in having them, but I am not blocked by it either. Totally up to you to decide then.

It's definitely not that I don't want to export them just to make others life harder It's more the: that seems to be the wrong way

Either eslint or @types/eslint should export these, so even I could reuse them in this repo

But I'm even the not sure if I e.g. need to put @types/eslint from devDeps to direct deps 🤔 I just don't know what that would do to the project relying on eslint-define-config

Sidenote: I spend today in train, because I drive home I don't promise to work much this weekend, because I want to relax from the week and spend time for gaming as well as friends

Shinigami92 commented 1 year ago

I could answer yet in #233 yet because I need to write a bit more and prepared for that, but tldr I would love to get rid at all of eslint-define-config But I think this can be targeted for eslint v9 FlatConfig-only or even eslint v10

A bit like the move from cjs to esm

Shinigami92 commented 1 year ago

@antfu is there any reason now to have exported this? Or did the augmented global properties support solved it?

antfu commented 1 year ago

I found that ESLint exposes that as well. I'm more curious about why you don't use the one from ESLint directly tho. But indeed this is not necessary.

Shinigami92 commented 1 year ago

I found that ESLint exposes that as well. I'm more curious about why you don't use the one from ESLint directly tho. But indeed this is not necessary.

I think there types were not so precise, but also I didn't wanted to rely on their types, because then I would need to rely on @types/eslint. Otherwise the types would be broken / fallback to any, if @types/eslint is not installed on the dev's side. However, @sxzz did use types from eslint here: https://github.com/eslint-types/eslint-define-config/blob/7567bd63ab809180faa6535d75171ff1fbd8d54c/src/flat-config/index.d.ts#L1 But I never used FlatConfig yet :shrug:, so I don't have knowledge about that if it even works.