noBannedTypes (since v10.0.0)
Disallow certain types.
Some built-in types have aliases, while some types are considered dangerous or harmful. It’s often a good idea to ban certain types to help with consistency and safety.
This rule bans specific types and can suggest alternatives. Note that it doesn’t ban the corresponding runtime objects from being used.
Source: https://typescript-eslint.io/rules/ban-types
Examples
Invalid
let foo: String = "bar";
nursery/noBannedTypes.js:1:10 lint/nursery/noBannedTypes FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Don't use 'String' as a type.
> 1 │ let foo: String = "bar";
│ ^^^^^^
2 │
ℹ Use lowercase primitives for consistency.
ℹ Safe fix: Use 'string' instead
1 │ - let·foo:·String·=·"bar";
1 │ + let·foo:·string·=·"bar";
2 2 │
let bool = true as Boolean;
nursery/noBannedTypes.js:1:20 lint/nursery/noBannedTypes FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Don't use 'Boolean' as a type.
> 1 │ let bool = true as Boolean;
│ ^^^^^^^
2 │
ℹ Use lowercase primitives for consistency.
ℹ Safe fix: Use 'boolean' instead
1 │ - let·bool·=·true·as·Boolean;
1 │ + let·bool·=·true·as·boolean;
2 2 │
let invalidTuple: [string, Boolean] = ["foo", false];
nursery/noBannedTypes.js:1:28 lint/nursery/noBannedTypes FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Don't use 'Boolean' as a type.
> 1 │ let invalidTuple: [string, Boolean] = ["foo", false];
│ ^^^^^^^
2 │
ℹ Use lowercase primitives for consistency.
ℹ Safe fix: Use 'boolean' instead
1 │ - let·invalidTuple:·[string,·Boolean]·=·["foo",·false];
1 │ + let·invalidTuple:·[string,·boolean]·=·["foo",·false];
2 2 │
Valid
let foo: string = "bar";
let tuple: [boolean, string] = [false, "foo"];