@@ -83,7 +83,8 @@ type MessageIds =
83
83
| 'errorStringArraySimple'
84
84
| 'errorStringGeneric'
85
85
| 'errorStringGenericSimple'
86
- | 'errorStringArrayReadonly' ;
86
+ | 'errorStringArrayReadonly'
87
+ | 'errorStringArraySimpleReadonly' ;
87
88
88
89
export default createRule < Options , MessageIds > ( {
89
90
name : 'array-type' ,
@@ -106,6 +107,8 @@ export default createRule<Options, MessageIds>({
106
107
"Array type using '{{className}}<{{type}}>' is forbidden for simple types. Use '{{readonlyPrefix}}{{type}}[]' instead." ,
107
108
errorStringGenericSimple :
108
109
"Array type using '{{readonlyPrefix}}{{type}}[]' is forbidden for non-simple types. Use '{{className}}<{{type}}>' instead." ,
110
+ errorStringArraySimpleReadonly :
111
+ "Array type using '{{className}}<{{type}}>' is forbidden for simple types. Use '{{readonlyPrefix}}{{type}}' instead." ,
109
112
} ,
110
113
schema : [
111
114
{
@@ -233,7 +236,9 @@ export default createRule<Options, MessageIds>({
233
236
? isReadonlyWithGenericArrayType
234
237
? 'errorStringArrayReadonly'
235
238
: 'errorStringArray'
236
- : 'errorStringArraySimple' ;
239
+ : isReadonlyArrayType && node . typeName . name !== 'ReadonlyArray'
240
+ ? 'errorStringArraySimpleReadonly'
241
+ : 'errorStringArraySimple' ;
237
242
238
243
if ( ! typeParams || typeParams . length === 0 ) {
239
244
// Create an 'any' array
@@ -271,7 +276,6 @@ export default createRule<Options, MessageIds>({
271
276
typeParens ? '(' : ''
272
277
} `;
273
278
const end = `${ typeParens ? ')' : '' } ${ isReadonlyWithGenericArrayType ? '' : `[]` } ${ parentParens ? ')' : '' } ` ;
274
-
275
279
context . report ( {
276
280
node,
277
281
messageId,
0 commit comments