Is there any sort of ESLint rule which I could use which says something like:
If you have a function with more than one argument, enforce using a
props
object (can be destructured). If it’s just one argument, can be any type like string/number/custom-type/etc..
That way if you try and do this:
type User = {
name: string
email: string
}
function funcWith2Args(id: String, updates?: Partial<User>) {
}
It would say something like, do this:
function funcWith2Args({ id, updates }: { id: String, updates?: Partial<User> }) {
}
If no rule exists, can you show how to create the rule, I would be new to writing my own ESLint config.
This was somewhat related, but not quite what I’m asking:
Is there a way to enforce with ESLint that destructured objects are typed inline instead of with a separate type definition?
Searching typescript ESLint rules I didn’t find anything talking about “props” or “arguments”.