Revamping the ban-types rule
ban-types rule · 6 min read
For many years, @typescript-eslint/ban-types was one of the more prominent rules in typescript-eslint.
It served three purposes:
- It banned usage of the unsafe "empty object"
{}type - It banned uses of dangerous or misleading built-in types:
Function,Number, and so on - It also allowed users to provide additional types to ban
Those are all great areas for linting!
However, @typescript-eslint/ban-types suffered from several key design issues:
- By targeting all three areas of banning, it was hard to configure to only what a project needs
- It was overly strict on banning
{}, to the point of confusing and inconveniencing users - It was limited in what auto-fixes and edge cases it could handle for its default banned types
This post will explain how @typescript-eslint/ban-types came to be, its benefits and drawbacks, and the new rules that better handle its targeted functionality.
