File tree Expand file tree Collapse file tree 3 files changed +14
-6
lines changed Expand file tree Collapse file tree 3 files changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ import {
23
23
isTSArrayType ,
24
24
isTSIndexSignature ,
25
25
isTSParameterProperty ,
26
+ isTSTupleType ,
26
27
isTSTypeOperator
27
28
} from "../util/typeguard" ;
28
29
@@ -70,6 +71,7 @@ const defaultOptions: Options = {
70
71
// The possible error messages.
71
72
const errorMessages = {
72
73
array : "Only readonly arrays allowed." ,
74
+ tuple : "Only readonly tuples allowed." ,
73
75
implicit : "Implicitly a mutable array. Only readonly arrays allowed." ,
74
76
property : "A readonly modifier is required."
75
77
} as const ;
@@ -105,7 +107,7 @@ function checkArrayOrTupleType(
105
107
? [
106
108
{
107
109
node,
108
- messageId : "array" ,
110
+ messageId : isTSTupleType ( node ) ? "tuple" : "array" ,
109
111
fix :
110
112
node . parent && isTSArrayType ( node . parent )
111
113
? fixer => [
Original file line number Diff line number Diff line change @@ -166,6 +166,12 @@ export function isTSPropertySignature(
166
166
return node . type === AST_NODE_TYPES . TSPropertySignature ;
167
167
}
168
168
169
+ export function isTSTupleType (
170
+ node : TSESTree . Node
171
+ ) : node is TSESTree . TSTupleType {
172
+ return node . type === AST_NODE_TYPES . TSTupleType ;
173
+ }
174
+
169
175
export function isTSTypeAliasDeclaration (
170
176
node : TSESTree . Node
171
177
) : node is TSESTree . TSTypeAliasDeclaration {
Original file line number Diff line number Diff line change @@ -517,7 +517,7 @@ const invalid: ReadonlyArray<InvalidTestCase> = [
517
517
}` ,
518
518
errors : [
519
519
{
520
- messageId : "array " ,
520
+ messageId : "tuple " ,
521
521
type : "TSTupleType" ,
522
522
line : 1 ,
523
523
column : 21
@@ -534,13 +534,13 @@ const invalid: ReadonlyArray<InvalidTestCase> = [
534
534
}` ,
535
535
errors : [
536
536
{
537
- messageId : "array " ,
537
+ messageId : "tuple " ,
538
538
type : "TSTupleType" ,
539
539
line : 1 ,
540
540
column : 21
541
541
} ,
542
542
{
543
- messageId : "array " ,
543
+ messageId : "tuple " ,
544
544
type : "TSTupleType" ,
545
545
line : 1 ,
546
546
column : 38
@@ -557,7 +557,7 @@ const invalid: ReadonlyArray<InvalidTestCase> = [
557
557
}` ,
558
558
errors : [
559
559
{
560
- messageId : "array " ,
560
+ messageId : "tuple " ,
561
561
type : "TSTupleType" ,
562
562
line : 1 ,
563
563
column : 47
@@ -574,7 +574,7 @@ const invalid: ReadonlyArray<InvalidTestCase> = [
574
574
}` ,
575
575
errors : [
576
576
{
577
- messageId : "array " ,
577
+ messageId : "tuple " ,
578
578
type : "TSTupleType" ,
579
579
line : 1 ,
580
580
column : 21
You can’t perform that action at this time.
0 commit comments