@@ -80,9 +80,9 @@ type Options = [
80
80
] ;
81
81
type MessageIds =
82
82
| 'errorStringGeneric'
83
- | 'errorStringGenericSimple'
84
83
| 'errorStringArray'
85
- | 'errorStringArraySimple' ;
84
+ | 'errorStringArraySimple'
85
+ | 'errorStringGenericSimple' ;
86
86
87
87
const arrayOption = { enum : [ 'array' , 'generic' , 'array-simple' ] } ;
88
88
@@ -98,13 +98,13 @@ export default util.createRule<Options, MessageIds>({
98
98
fixable : 'code' ,
99
99
messages : {
100
100
errorStringGeneric :
101
- "Array type using '{{type}}[]' is forbidden. Use 'Array<{{type}}>' instead." ,
102
- errorStringGenericSimple :
103
- "Array type using '{{type}}[]' is forbidden for non-simple types. Use 'Array<{{type}}>' instead." ,
101
+ "Array type using '{{readonlyPrefix}}{{type}}[]' is forbidden. Use '{{className}}<{{type}}>' instead." ,
104
102
errorStringArray :
105
- "Array type using 'Array <{{type}}>' is forbidden. Use '{{type}}[]' instead." ,
103
+ "Array type using '{{className}} <{{type}}>' is forbidden. Use '{{readonlyPrefix}} {{type}}[]' instead." ,
106
104
errorStringArraySimple :
107
- "Array type using 'Array<{{type}}>' is forbidden for simple types. Use '{{type}}[]' instead." ,
105
+ "Array type using '{{className}}<{{type}}>' is forbidden for simple types. Use '{{readonlyPrefix}}{{type}}[]' instead." ,
106
+ errorStringGenericSimple :
107
+ "Array type using '{{readonlyPrefix}}{{type}}[]' is forbidden for non-simple types. Use '{{className}}<{{type}}>' instead." ,
108
108
} ,
109
109
schema : [
110
110
{
@@ -163,6 +163,8 @@ export default util.createRule<Options, MessageIds>({
163
163
node : errorNode ,
164
164
messageId,
165
165
data : {
166
+ className : isReadonly ? 'ReadonlyArray' : 'Array' ,
167
+ readonlyPrefix : isReadonly ? 'readonly ' : '' ,
166
168
type : getMessageType ( node . elementType ) ,
167
169
} ,
168
170
fix ( fixer ) {
@@ -216,6 +218,8 @@ export default util.createRule<Options, MessageIds>({
216
218
node,
217
219
messageId,
218
220
data : {
221
+ className : isReadonlyArrayType ? 'ReadonlyArray' : 'Array' ,
222
+ readonlyPrefix,
219
223
type : 'any' ,
220
224
} ,
221
225
fix ( fixer ) {
@@ -250,6 +254,8 @@ export default util.createRule<Options, MessageIds>({
250
254
node,
251
255
messageId,
252
256
data : {
257
+ className : isReadonlyArrayType ? 'ReadonlyArray' : 'Array' ,
258
+ readonlyPrefix,
253
259
type : getMessageType ( type ) ,
254
260
} ,
255
261
fix ( fixer ) {
0 commit comments