Skip to content

Commit 3514982

Browse files
authored
Merge pull request microsoft#1818 from microsoft/octogonz/clarify-ban-types-message
[eslint-config] Improve error message for "ban-types" rule
2 parents b21ddc7 + e5b6d54 commit 3514982

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@rushstack/eslint-config",
5+
"comment": "Improve the error message text for the \"ban-types\" rule",
6+
"type": "patch"
7+
}
8+
],
9+
"packageName": "@rushstack/eslint-config",
10+
"email": "4673363+octogonz@users.noreply.github.com"
11+
}

stack/eslint-config/index.js

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,32 @@ module.exports = {
5656
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
5757
//
5858
// CONFIGURATION: By default, these are banned: String, Boolean, Number, Object, Symbol
59-
"@typescript-eslint/ban-types": "error",
59+
"@typescript-eslint/ban-types": [
60+
"error",
61+
{
62+
types: {
63+
String: {
64+
message: "Use 'string' instead",
65+
fixWith: "string"
66+
},
67+
Boolean: {
68+
message: "Use 'boolean' instead",
69+
fixWith: "boolean"
70+
},
71+
Number: {
72+
message: "Use 'number' instead",
73+
fixWith: "number"
74+
},
75+
Object: {
76+
message: "Use 'object' instead, or else define a proper TypeScript type:"
77+
},
78+
Symbol: {
79+
message: "Use 'symbol' instead",
80+
fixWith: "symbol"
81+
}
82+
}
83+
}
84+
],
6085

6186
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
6287
"@typescript-eslint/camelcase": [

0 commit comments

Comments
 (0)