@@ -80,11 +80,10 @@ const defaultOptions: Options = {
80
80
81
81
// The possible error messages.
82
82
const errorMessages = {
83
- array : "Only readonly arrays allowed." ,
84
- implicit : "Implicitly a mutable array. Only readonly arrays allowed." ,
85
- property : "A readonly modifier is required." ,
86
- tuple : "Only readonly tuples allowed." ,
87
- type : "Only readonly types allowed." ,
83
+ arrayShouldBeReadonly : "Array should be readonly." ,
84
+ propertyShouldBeReadonly : "This property should be readonly." ,
85
+ tupleShouldBeReadonly : "Tuple should be readonly." ,
86
+ typeShouldBeReadonly : "Type should be readonly." ,
88
87
} as const ;
89
88
90
89
// The meta data for this rule.
@@ -137,7 +136,9 @@ function checkArrayOrTupleType(
137
136
? [
138
137
{
139
138
node,
140
- messageId : isTSTupleType ( node ) ? "tuple" : "array" ,
139
+ messageId : isTSTupleType ( node )
140
+ ? "tupleShouldBeReadonly"
141
+ : "arrayShouldBeReadonly" ,
141
142
fix :
142
143
node . parent !== undefined && isTSArrayType ( node . parent )
143
144
? ( fixer ) => [
@@ -166,7 +167,7 @@ function checkMappedType(
166
167
: [
167
168
{
168
169
node,
169
- messageId : "property " ,
170
+ messageId : "propertyShouldBeReadonly " ,
170
171
fix : ( fixer ) =>
171
172
fixer . insertTextBeforeRange (
172
173
[ node . range [ 0 ] + 1 , node . range [ 1 ] ] ,
@@ -205,7 +206,7 @@ function checkTypeReference(
205
206
? [
206
207
{
207
208
node,
208
- messageId : "type " ,
209
+ messageId : "typeShouldBeReadonly " ,
209
210
fix : ( fixer ) => fixer . replaceText ( node . typeName , immutableType ) ,
210
211
} ,
211
212
]
@@ -238,7 +239,7 @@ function checkProperty(
238
239
? [
239
240
{
240
241
node,
241
- messageId : "property " ,
242
+ messageId : "propertyShouldBeReadonly " ,
242
243
fix :
243
244
isTSIndexSignature ( node ) || isTSPropertySignature ( node )
244
245
? ( fixer ) => fixer . insertTextBefore ( node , "readonly " )
@@ -303,7 +304,7 @@ function checkForImplicitMutableArray(
303
304
? [
304
305
{
305
306
node : declarator . node ,
306
- messageId : "implicit " ,
307
+ messageId : "arrayShouldBeReadonly " ,
307
308
fix : ( fixer ) =>
308
309
fixer . insertTextAfter ( declarator . id , ": readonly unknown[]" ) ,
309
310
} ,
0 commit comments