Avoiding general Function type in react + typescript

Viewed 4037

I am looking for a rule that prevents usage of "Function" as a type

myMethod: Function;

I didn't find anything so I am open to suggestions :)

2 Answers

You can use the @typescript-eslint/ban-types rule Rule Link. But this will also ban the other default types too like String, Boolean, etc. Link of other default banned types

If you wish to only ban Function and disable the other bans then add this to your .eslintrc file.

"@typescript-eslint/ban-types": ["error",
    {
        "types": {
            "String": false,
            "Boolean": false,
            "Number": false,
            "Symbol": false,
            "{}": false,
            "Object": false,
            "object": false,
            "Function": true,
        },
        "extendDefaults": true
    }
]
Related