Skip to content

Commit 3679627

Browse files
committed
Better punctuation and formatting
1 parent 3d46a1e commit 3679627

File tree

2 files changed

+136
-112
lines changed

2 files changed

+136
-112
lines changed

packages/eslint-plugin-react-hooks/__tests__/ESLintRuleReactiveDeps-test.js

Lines changed: 81 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -428,8 +428,8 @@ const tests = {
428428
}
429429
`,
430430
errors: [
431-
'React Hook useEffect has missing [local] dependencies. ' +
432-
'Either fix or remove the dependency array.',
431+
"React Hook useEffect has a missing 'local' dependency. " +
432+
'Either include it or remove the dependency array.',
433433
],
434434
},
435435
{
@@ -456,8 +456,8 @@ const tests = {
456456
}
457457
`,
458458
errors: [
459-
'React Hook useEffect has missing [local] dependencies. ' +
460-
'Either fix or remove the dependency array.',
459+
"React Hook useEffect has a missing 'local' dependency. " +
460+
'Either include it or remove the dependency array.',
461461
],
462462
},
463463
{
@@ -484,8 +484,8 @@ const tests = {
484484
}
485485
`,
486486
errors: [
487-
'React Hook useEffect has missing [local] dependencies. ' +
488-
'Either fix or remove the dependency array.',
487+
"React Hook useEffect has a missing 'local' dependency. " +
488+
'Either include it or remove the dependency array.',
489489
],
490490
},
491491
{
@@ -514,8 +514,8 @@ const tests = {
514514
}
515515
`,
516516
errors: [
517-
'React Hook useEffect has missing [local] dependencies. ' +
518-
'Either fix or remove the dependency array.',
517+
"React Hook useEffect has a missing 'local' dependency. " +
518+
'Either include it or remove the dependency array.',
519519
],
520520
},
521521
{
@@ -544,8 +544,8 @@ const tests = {
544544
}
545545
`,
546546
errors: [
547-
'React Hook useEffect has missing [local1, local2] dependencies. ' +
548-
'Either fix or remove the dependency array.',
547+
"React Hook useEffect has missing 'local1' and 'local2' dependencies. " +
548+
'Either include them or remove the dependency array.',
549549
],
550550
},
551551
{
@@ -570,8 +570,8 @@ const tests = {
570570
}
571571
`,
572572
errors: [
573-
'React Hook useEffect has missing [local2] dependencies. ' +
574-
'Either fix or remove the dependency array.',
573+
"React Hook useEffect has a missing 'local2' dependency. " +
574+
'Either include it or remove the dependency array.',
575575
],
576576
},
577577
{
@@ -594,8 +594,8 @@ const tests = {
594594
}
595595
`,
596596
errors: [
597-
'React Hook useEffect has unnecessary [local2] dependencies. ' +
598-
'Either fix or remove the dependency array.',
597+
"React Hook useEffect has an unnecessary 'local2' dependency. " +
598+
'Either exclude it or remove the dependency array.',
599599
],
600600
},
601601
{
@@ -626,8 +626,9 @@ const tests = {
626626
}
627627
`,
628628
errors: [
629-
'React Hook useEffect has missing [local2], unnecessary [local1] dependencies. ' +
630-
'Either fix or remove the dependency array.',
629+
// Focus on the more important part first (missing dep)
630+
"React Hook useEffect has a missing 'local2' dependency. " +
631+
'Either include it or remove the dependency array.',
631632
],
632633
},
633634
{
@@ -650,8 +651,8 @@ const tests = {
650651
}
651652
`,
652653
errors: [
653-
'React Hook useEffect has missing [local] dependencies. ' +
654-
'Either fix or remove the dependency array.',
654+
"React Hook useEffect has a missing 'local' dependency. " +
655+
'Either include it or remove the dependency array.',
655656
],
656657
},
657658
{
@@ -674,8 +675,8 @@ const tests = {
674675
}
675676
`,
676677
errors: [
677-
'React Hook useEffect has duplicate [local] dependencies. ' +
678-
'Either fix or remove the dependency array.',
678+
"React Hook useEffect has a duplicate 'local' dependency. " +
679+
'Either omit it or remove the dependency array.',
679680
],
680681
},
681682
{
@@ -690,8 +691,8 @@ const tests = {
690691
}
691692
`,
692693
errors: [
693-
'React Hook useEffect has unnecessary [local] dependencies. ' +
694-
'Either fix or remove the dependency array.',
694+
"React Hook useEffect has an unnecessary 'local' dependency. " +
695+
'Either exclude it or remove the dependency array.',
695696
],
696697
},
697698
{
@@ -710,8 +711,8 @@ const tests = {
710711
}
711712
`,
712713
errors: [
713-
'React Hook useEffect has missing [history] dependencies. ' +
714-
'Either fix or remove the dependency array.',
714+
"React Hook useEffect has a missing 'history' dependency. " +
715+
'Either include it or remove the dependency array.',
715716
],
716717
},
717718
{
@@ -736,8 +737,8 @@ const tests = {
736737
}
737738
`,
738739
errors: [
739-
'React Hook useEffect has missing [history.foo] dependencies. ' +
740-
'Either fix or remove the dependency array.',
740+
"React Hook useEffect has a missing 'history.foo' dependency. " +
741+
'Either include it or remove the dependency array.',
741742
],
742743
},
743744
{
@@ -783,8 +784,8 @@ const tests = {
783784
'React Hook useEffect has a second argument which is not an array ' +
784785
"literal. This means we can't statically verify whether you've " +
785786
'passed the correct dependencies.',
786-
'React Hook useEffect has missing [local] dependencies. ' +
787-
'Either fix or remove the dependency array.',
787+
"React Hook useEffect has a missing 'local' dependency. " +
788+
'Either include it or remove the dependency array.',
788789
],
789790
},
790791
{
@@ -808,8 +809,8 @@ const tests = {
808809
}
809810
`,
810811
errors: [
811-
'React Hook useEffect has missing [local] dependencies. ' +
812-
'Either fix or remove the dependency array.',
812+
"React Hook useEffect has a missing 'local' dependency. " +
813+
'Either include it or remove the dependency array.',
813814
'React Hook useEffect has a spread element in its dependency list. ' +
814815
"This means we can't statically verify whether you've passed the " +
815816
'correct dependencies.',
@@ -858,8 +859,8 @@ const tests = {
858859
}
859860
`,
860861
errors: [
861-
'React Hook useEffect has missing [local] dependencies. ' +
862-
'Either fix or remove the dependency array.',
862+
"React Hook useEffect has a missing 'local' dependency. " +
863+
'Either include it or remove the dependency array.',
863864
"Unsupported expression in React Hook useEffect's dependency list. " +
864865
'Currently only simple variables are supported.',
865866
],
@@ -884,8 +885,8 @@ const tests = {
884885
}
885886
`,
886887
errors: [
887-
'React Hook useEffect has missing [local], unnecessary [local.id] dependencies. ' +
888-
'Either fix or remove the dependency array.',
888+
"React Hook useEffect has a missing 'local' dependency. " +
889+
'Either include it or remove the dependency array.',
889890
],
890891
},
891892
{
@@ -906,8 +907,8 @@ const tests = {
906907
}
907908
`,
908909
errors: [
909-
'React Hook useEffect has duplicate [local] dependencies. ' +
910-
'Either fix or remove the dependency array.',
910+
"React Hook useEffect has a duplicate 'local' dependency. " +
911+
'Either omit it or remove the dependency array.',
911912
],
912913
},
913914
{
@@ -930,8 +931,8 @@ const tests = {
930931
}
931932
`,
932933
errors: [
933-
'React Hook useEffect has unnecessary [local1] dependencies. ' +
934-
'Either fix or remove the dependency array.',
934+
"React Hook useEffect has an unnecessary 'local1' dependency. " +
935+
'Either exclude it or remove the dependency array.',
935936
],
936937
},
937938
{
@@ -948,8 +949,8 @@ const tests = {
948949
}
949950
`,
950951
errors: [
951-
'React Hook useEffect has unnecessary [local1] dependencies. ' +
952-
'Either fix or remove the dependency array.',
952+
"React Hook useEffect has an unnecessary 'local1' dependency. " +
953+
'Either exclude it or remove the dependency array.',
953954
],
954955
},
955956
{
@@ -970,8 +971,8 @@ const tests = {
970971
}
971972
`,
972973
errors: [
973-
'React Hook useEffect has missing [props.foo] dependencies. ' +
974-
'Either fix or remove the dependency array.',
974+
"React Hook useEffect has a missing 'props.foo' dependency. " +
975+
'Either include it or remove the dependency array.',
975976
],
976977
},
977978
{
@@ -994,8 +995,8 @@ const tests = {
994995
}
995996
`,
996997
errors: [
997-
'React Hook useEffect has missing [props.foo, props.bar] dependencies. ' +
998-
'Either fix or remove the dependency array.',
998+
"React Hook useEffect has missing 'props.foo' and 'props.bar' dependencies. " +
999+
'Either include them or remove the dependency array.',
9991000
],
10001001
},
10011002
{
@@ -1022,8 +1023,8 @@ const tests = {
10221023
}
10231024
`,
10241025
errors: [
1025-
'React Hook useEffect has missing [props.foo, props.bar, local] dependencies. ' +
1026-
'Either fix or remove the dependency array.',
1026+
"React Hook useEffect has missing 'props.foo', 'props.bar', and 'local' dependencies. " +
1027+
'Either include them or remove the dependency array.',
10271028
],
10281029
},
10291030
{
@@ -1048,8 +1049,8 @@ const tests = {
10481049
}
10491050
`,
10501051
errors: [
1051-
'React Hook useEffect has missing [local] dependencies. ' +
1052-
'Either fix or remove the dependency array.',
1052+
"React Hook useEffect has a missing 'local' dependency. " +
1053+
'Either include it or remove the dependency array.',
10531054
],
10541055
},
10551056
{
@@ -1104,18 +1105,18 @@ const tests = {
11041105
}
11051106
`,
11061107
errors: [
1107-
'React Hook useEffect has missing [props.foo] dependencies. ' +
1108-
'Either fix or remove the dependency array.',
1109-
'React Hook useCallback has missing [props.foo] dependencies. ' +
1110-
'Either fix or remove the dependency array.',
1111-
'React Hook useMemo has missing [props.foo] dependencies. ' +
1112-
'Either fix or remove the dependency array.',
1113-
'React Hook React.useEffect has missing [props.foo] dependencies. ' +
1114-
'Either fix or remove the dependency array.',
1115-
'React Hook React.useCallback has missing [props.foo] dependencies. ' +
1116-
'Either fix or remove the dependency array.',
1117-
'React Hook React.useMemo has missing [props.foo] dependencies. ' +
1118-
'Either fix or remove the dependency array.',
1108+
"React Hook useEffect has a missing 'props.foo' dependency. " +
1109+
'Either include it or remove the dependency array.',
1110+
"React Hook useCallback has a missing 'props.foo' dependency. " +
1111+
'Either include it or remove the dependency array.',
1112+
"React Hook useMemo has a missing 'props.foo' dependency. " +
1113+
'Either include it or remove the dependency array.',
1114+
"React Hook React.useEffect has a missing 'props.foo' dependency. " +
1115+
'Either include it or remove the dependency array.',
1116+
"React Hook React.useCallback has a missing 'props.foo' dependency. " +
1117+
'Either include it or remove the dependency array.',
1118+
"React Hook React.useMemo has a missing 'props.foo' dependency. " +
1119+
'Either include it or remove the dependency array.',
11191120
],
11201121
},
11211122
{
@@ -1153,12 +1154,12 @@ const tests = {
11531154
`,
11541155
options: [{additionalHooks: 'useCustomEffect'}],
11551156
errors: [
1156-
'React Hook useCustomEffect has missing [props.foo] dependencies. ' +
1157-
'Either fix or remove the dependency array.',
1158-
'React Hook useEffect has missing [props.foo] dependencies. ' +
1159-
'Either fix or remove the dependency array.',
1160-
'React Hook React.useEffect has missing [props.foo] dependencies. ' +
1161-
'Either fix or remove the dependency array.',
1157+
"React Hook useCustomEffect has a missing 'props.foo' dependency. " +
1158+
'Either include it or remove the dependency array.',
1159+
"React Hook useEffect has a missing 'props.foo' dependency. " +
1160+
'Either include it or remove the dependency array.',
1161+
"React Hook React.useEffect has a missing 'props.foo' dependency. " +
1162+
'Either include it or remove the dependency array.',
11621163
],
11631164
},
11641165
{
@@ -1180,8 +1181,8 @@ const tests = {
11801181
}
11811182
`,
11821183
errors: [
1183-
'React Hook useEffect has missing [local] dependencies. ' +
1184-
'Either fix or remove the dependency array.',
1184+
"React Hook useEffect has a missing 'local' dependency. " +
1185+
'Either include it or remove the dependency array.',
11851186
"Unsupported expression in React Hook useEffect's dependency list. " +
11861187
'Currently only simple variables are supported.',
11871188
],
@@ -1205,8 +1206,8 @@ const tests = {
12051206
}
12061207
`,
12071208
errors: [
1208-
'React Hook useEffect has missing [local] dependencies. ' +
1209-
'Either fix or remove the dependency array.',
1209+
"React Hook useEffect has a missing 'local' dependency. " +
1210+
'Either include it or remove the dependency array.',
12101211
"Unsupported expression in React Hook useEffect's dependency list. " +
12111212
'Currently only simple variables are supported.',
12121213
],
@@ -1233,8 +1234,8 @@ const tests = {
12331234
}
12341235
`,
12351236
errors: [
1236-
'React Hook useEffect has missing [state] dependencies. ' +
1237-
'Either fix or remove the dependency array.',
1237+
"React Hook useEffect has a missing 'state' dependency. " +
1238+
'Either include it or remove the dependency array.',
12381239
],
12391240
},
12401241
{
@@ -1262,10 +1263,10 @@ const tests = {
12621263
}, [ref1, ref2, props.someOtherRefs, props.color]);
12631264
}
12641265
`,
1265-
// TODO: better message for the ref case.
1266+
// TODO: special message for the ref case.
12661267
errors: [
1267-
'React Hook useEffect has missing [props.someOtherRefs, props.color] dependencies. ' +
1268-
'Either fix or remove the dependency array.',
1268+
"React Hook useEffect has missing 'props.someOtherRefs' and 'props.color' dependencies. " +
1269+
'Either include them or remove the dependency array.',
12691270
],
12701271
},
12711272
{
@@ -1285,10 +1286,10 @@ const tests = {
12851286
}, [ref]);
12861287
}
12871288
`,
1288-
// TODO: better message for the ref case.
1289+
// TODO: special message for the ref case.
12891290
errors: [
1290-
'React Hook useEffect has unnecessary [ref.current] dependencies. ' +
1291-
'Either fix or remove the dependency array.',
1291+
"React Hook useEffect has an unnecessary 'ref.current' dependency. " +
1292+
'Either exclude it or remove the dependency array.',
12921293
],
12931294
},
12941295
{
@@ -1311,8 +1312,8 @@ const tests = {
13111312
});
13121313
`,
13131314
errors: [
1314-
'React Hook useImperativeHandle has missing [props.hello] dependencies. ' +
1315-
'Either fix or remove the dependency array.',
1315+
"React Hook useImperativeHandle has a missing 'props.hello' dependency. " +
1316+
'Either include it or remove the dependency array.',
13161317
],
13171318
},
13181319
],

0 commit comments

Comments
 (0)