@lvce-editor/eslint-plugin-virtual-dom 18.5.0 → 18.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +180 -74
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -93,7 +93,7 @@ const controlsAllowingChildren = new Set(['A', 'Button']);
|
|
|
93
93
|
const hasDirectName = node => {
|
|
94
94
|
return Boolean(getProperty(node, 'ariaLabel') || getProperty(node, 'ariaLabelledBy') || getProperty(node, 'title'));
|
|
95
95
|
};
|
|
96
|
-
const meta$
|
|
96
|
+
const meta$t = {
|
|
97
97
|
docs: {
|
|
98
98
|
description: 'Require a statically determinable accessible name for virtual-dom controls'
|
|
99
99
|
},
|
|
@@ -102,7 +102,7 @@ const meta$q = {
|
|
|
102
102
|
},
|
|
103
103
|
type: 'problem'
|
|
104
104
|
};
|
|
105
|
-
const create$
|
|
105
|
+
const create$t = context => {
|
|
106
106
|
return {
|
|
107
107
|
ObjectExpression(node) {
|
|
108
108
|
if (!isVirtualDomNode(node) || hasDirectName(node)) {
|
|
@@ -144,11 +144,11 @@ const create$q = context => {
|
|
|
144
144
|
|
|
145
145
|
const accessibleControlName = {
|
|
146
146
|
__proto__: null,
|
|
147
|
-
create: create$
|
|
148
|
-
meta: meta$
|
|
147
|
+
create: create$t,
|
|
148
|
+
meta: meta$t
|
|
149
149
|
};
|
|
150
150
|
|
|
151
|
-
const meta$
|
|
151
|
+
const meta$s = {
|
|
152
152
|
docs: {
|
|
153
153
|
description: 'Require an explicit role on clickable virtual-dom div nodes'
|
|
154
154
|
},
|
|
@@ -157,7 +157,7 @@ const meta$p = {
|
|
|
157
157
|
},
|
|
158
158
|
type: 'problem'
|
|
159
159
|
};
|
|
160
|
-
const create$
|
|
160
|
+
const create$s = context => {
|
|
161
161
|
return {
|
|
162
162
|
ObjectExpression(node) {
|
|
163
163
|
if (!isVirtualDomNode(node)) {
|
|
@@ -179,11 +179,11 @@ const create$p = context => {
|
|
|
179
179
|
|
|
180
180
|
const clickableDivNeedsRole = {
|
|
181
181
|
__proto__: null,
|
|
182
|
-
create: create$
|
|
183
|
-
meta: meta$
|
|
182
|
+
create: create$s,
|
|
183
|
+
meta: meta$s
|
|
184
184
|
};
|
|
185
185
|
|
|
186
|
-
const meta$
|
|
186
|
+
const meta$r = {
|
|
187
187
|
docs: {
|
|
188
188
|
description: 'Require static virtual-dom nodes created inside functions to be hoisted to module scope'
|
|
189
189
|
},
|
|
@@ -318,7 +318,7 @@ const isStaticExpression = (sourceCode, node) => {
|
|
|
318
318
|
return false;
|
|
319
319
|
}
|
|
320
320
|
};
|
|
321
|
-
const create$
|
|
321
|
+
const create$r = context => {
|
|
322
322
|
return {
|
|
323
323
|
ObjectExpression(node) {
|
|
324
324
|
if (!isVirtualDomElement(node)) {
|
|
@@ -343,11 +343,11 @@ const create$o = context => {
|
|
|
343
343
|
|
|
344
344
|
const hoistStaticNodes = {
|
|
345
345
|
__proto__: null,
|
|
346
|
-
create: create$
|
|
347
|
-
meta: meta$
|
|
346
|
+
create: create$r,
|
|
347
|
+
meta: meta$r
|
|
348
348
|
};
|
|
349
349
|
|
|
350
|
-
const meta$
|
|
350
|
+
const meta$q = {
|
|
351
351
|
docs: {
|
|
352
352
|
description: 'Disallow conditional spreads in virtual-dom arrays'
|
|
353
353
|
},
|
|
@@ -365,7 +365,7 @@ const isVirtualDomArray$1 = node => {
|
|
|
365
365
|
const addsVirtualDomChildren = spread => {
|
|
366
366
|
return isVirtualDomArray$1(spread.argument.consequent) || isVirtualDomArray$1(spread.argument.alternate);
|
|
367
367
|
};
|
|
368
|
-
const create$
|
|
368
|
+
const create$q = context => {
|
|
369
369
|
return {
|
|
370
370
|
ArrayExpression(node) {
|
|
371
371
|
const conditionalSpreads = node.elements.filter(isConditionalSpread);
|
|
@@ -384,11 +384,40 @@ const create$n = context => {
|
|
|
384
384
|
|
|
385
385
|
const noConditionalSpread = {
|
|
386
386
|
__proto__: null,
|
|
387
|
-
create: create$
|
|
388
|
-
meta: meta$
|
|
387
|
+
create: create$q,
|
|
388
|
+
meta: meta$q
|
|
389
389
|
};
|
|
390
390
|
|
|
391
|
-
const meta$
|
|
391
|
+
const meta$p = {
|
|
392
|
+
docs: {
|
|
393
|
+
description: 'Disallow element helpers for creating virtual DOM nodes'
|
|
394
|
+
},
|
|
395
|
+
messages: {
|
|
396
|
+
noElementHelper: 'Create virtual DOM nodes directly as plain objects and arrays instead of using `element(...)` and flattening a nested tree.'
|
|
397
|
+
},
|
|
398
|
+
type: 'problem'
|
|
399
|
+
};
|
|
400
|
+
const create$p = context => {
|
|
401
|
+
return {
|
|
402
|
+
CallExpression(node) {
|
|
403
|
+
if (!isIdentifierNode(node.callee) || node.callee.name !== 'element' || !getVirtualDomElementName(node.arguments[0])) {
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
context.report({
|
|
407
|
+
messageId: 'noElementHelper',
|
|
408
|
+
node
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
};
|
|
412
|
+
};
|
|
413
|
+
|
|
414
|
+
const noElementHelper = {
|
|
415
|
+
__proto__: null,
|
|
416
|
+
create: create$p,
|
|
417
|
+
meta: meta$p
|
|
418
|
+
};
|
|
419
|
+
|
|
420
|
+
const meta$o = {
|
|
392
421
|
docs: {
|
|
393
422
|
description: 'Disallow empty ARIA values in virtual-dom nodes'
|
|
394
423
|
},
|
|
@@ -400,7 +429,7 @@ const meta$m = {
|
|
|
400
429
|
const isAriaProperty = name => {
|
|
401
430
|
return /^aria[A-Z]/.test(name);
|
|
402
431
|
};
|
|
403
|
-
const create$
|
|
432
|
+
const create$o = context => {
|
|
404
433
|
return {
|
|
405
434
|
ObjectExpression(node) {
|
|
406
435
|
if (!isVirtualDomNode(node)) {
|
|
@@ -425,11 +454,11 @@ const create$m = context => {
|
|
|
425
454
|
|
|
426
455
|
const noEmptyAria = {
|
|
427
456
|
__proto__: null,
|
|
428
|
-
create: create$
|
|
429
|
-
meta: meta$
|
|
457
|
+
create: create$o,
|
|
458
|
+
meta: meta$o
|
|
430
459
|
};
|
|
431
460
|
|
|
432
|
-
const meta$
|
|
461
|
+
const meta$n = {
|
|
433
462
|
docs: {
|
|
434
463
|
description: 'Disallow empty className values in virtual-dom nodes'
|
|
435
464
|
},
|
|
@@ -438,7 +467,7 @@ const meta$l = {
|
|
|
438
467
|
},
|
|
439
468
|
type: 'problem'
|
|
440
469
|
};
|
|
441
|
-
const create$
|
|
470
|
+
const create$n = context => {
|
|
442
471
|
return {
|
|
443
472
|
ObjectExpression(node) {
|
|
444
473
|
if (!isVirtualDomNode(node)) {
|
|
@@ -458,11 +487,11 @@ const create$l = context => {
|
|
|
458
487
|
|
|
459
488
|
const noEmptyClassName = {
|
|
460
489
|
__proto__: null,
|
|
461
|
-
create: create$
|
|
462
|
-
meta: meta$
|
|
490
|
+
create: create$n,
|
|
491
|
+
meta: meta$n
|
|
463
492
|
};
|
|
464
493
|
|
|
465
|
-
const meta$
|
|
494
|
+
const meta$m = {
|
|
466
495
|
docs: {
|
|
467
496
|
description: 'Disallow inline event handlers in virtual-dom nodes'
|
|
468
497
|
},
|
|
@@ -477,7 +506,7 @@ const isEventPropertyName = name => {
|
|
|
477
506
|
const isInlineEventHandler = node => {
|
|
478
507
|
return isStringLiteral(node) || isTemplateLiteralNode(node) || isArrowFunctionExpressionNode(node) || isFunctionExpressionNode(node);
|
|
479
508
|
};
|
|
480
|
-
const create$
|
|
509
|
+
const create$m = context => {
|
|
481
510
|
return {
|
|
482
511
|
ObjectExpression(node) {
|
|
483
512
|
if (!isVirtualDomNode(node)) {
|
|
@@ -502,11 +531,11 @@ const create$k = context => {
|
|
|
502
531
|
|
|
503
532
|
const noInlineEventHandlers = {
|
|
504
533
|
__proto__: null,
|
|
505
|
-
create: create$
|
|
506
|
-
meta: meta$
|
|
534
|
+
create: create$m,
|
|
535
|
+
meta: meta$m
|
|
507
536
|
};
|
|
508
537
|
|
|
509
|
-
const meta$
|
|
538
|
+
const meta$l = {
|
|
510
539
|
docs: {
|
|
511
540
|
description: 'Disallow inline style attributes in virtual-dom nodes'
|
|
512
541
|
},
|
|
@@ -515,7 +544,7 @@ const meta$j = {
|
|
|
515
544
|
},
|
|
516
545
|
type: 'problem'
|
|
517
546
|
};
|
|
518
|
-
const create$
|
|
547
|
+
const create$l = context => {
|
|
519
548
|
return {
|
|
520
549
|
ObjectExpression(node) {
|
|
521
550
|
if (!isVirtualDomNode(node)) {
|
|
@@ -535,8 +564,8 @@ const create$j = context => {
|
|
|
535
564
|
|
|
536
565
|
const noInlineStyle = {
|
|
537
566
|
__proto__: null,
|
|
538
|
-
create: create$
|
|
539
|
-
meta: meta$
|
|
567
|
+
create: create$l,
|
|
568
|
+
meta: meta$l
|
|
540
569
|
};
|
|
541
570
|
|
|
542
571
|
const ignoredProperties$1 = new Set(['childCount', 'type']);
|
|
@@ -546,7 +575,7 @@ const isOptionalExpression = node => {
|
|
|
546
575
|
const isNullish = node => {
|
|
547
576
|
return isLiteralNode(node) && node.value === null || isIdentifierNode(node) && node.name === 'undefined' || isOptionalExpression(node);
|
|
548
577
|
};
|
|
549
|
-
const meta$
|
|
578
|
+
const meta$k = {
|
|
550
579
|
docs: {
|
|
551
580
|
description: 'Disallow nullish virtual-dom attribute values'
|
|
552
581
|
},
|
|
@@ -555,7 +584,7 @@ const meta$i = {
|
|
|
555
584
|
},
|
|
556
585
|
type: 'problem'
|
|
557
586
|
};
|
|
558
|
-
const create$
|
|
587
|
+
const create$k = context => {
|
|
559
588
|
return {
|
|
560
589
|
ObjectExpression(node) {
|
|
561
590
|
if (!isVirtualDomNode(node)) {
|
|
@@ -583,11 +612,11 @@ const create$i = context => {
|
|
|
583
612
|
|
|
584
613
|
const noNullishAttributeValues = {
|
|
585
614
|
__proto__: null,
|
|
586
|
-
create: create$
|
|
587
|
-
meta: meta$
|
|
615
|
+
create: create$k,
|
|
616
|
+
meta: meta$k
|
|
588
617
|
};
|
|
589
618
|
|
|
590
|
-
const meta$
|
|
619
|
+
const meta$j = {
|
|
591
620
|
docs: {
|
|
592
621
|
description: 'Disallow object-like attribute values in virtual-dom nodes'
|
|
593
622
|
},
|
|
@@ -600,7 +629,7 @@ const ignoredProperties = new Set(['childCount', 'type']);
|
|
|
600
629
|
const isObjectLikeAttributeValue = node => {
|
|
601
630
|
return isObjectExpressionNode(node) || isArrayExpressionNode(node) || isArrowFunctionExpressionNode(node) || isFunctionExpressionNode(node);
|
|
602
631
|
};
|
|
603
|
-
const create$
|
|
632
|
+
const create$j = context => {
|
|
604
633
|
return {
|
|
605
634
|
ObjectExpression(node) {
|
|
606
635
|
if (!isVirtualDomNode(node)) {
|
|
@@ -625,11 +654,11 @@ const create$h = context => {
|
|
|
625
654
|
|
|
626
655
|
const noObjectAttributeValues = {
|
|
627
656
|
__proto__: null,
|
|
628
|
-
create: create$
|
|
629
|
-
meta: meta$
|
|
657
|
+
create: create$j,
|
|
658
|
+
meta: meta$j
|
|
630
659
|
};
|
|
631
660
|
|
|
632
|
-
const meta$
|
|
661
|
+
const meta$i = {
|
|
633
662
|
docs: {
|
|
634
663
|
description: 'Disallow positive virtual-dom tabIndex values'
|
|
635
664
|
},
|
|
@@ -638,7 +667,7 @@ const meta$g = {
|
|
|
638
667
|
},
|
|
639
668
|
type: 'problem'
|
|
640
669
|
};
|
|
641
|
-
const create$
|
|
670
|
+
const create$i = context => {
|
|
642
671
|
return {
|
|
643
672
|
ObjectExpression(node) {
|
|
644
673
|
if (!isVirtualDomNode(node)) {
|
|
@@ -659,11 +688,11 @@ const create$g = context => {
|
|
|
659
688
|
|
|
660
689
|
const noPositiveTabIndex = {
|
|
661
690
|
__proto__: null,
|
|
662
|
-
create: create$
|
|
663
|
-
meta: meta$
|
|
691
|
+
create: create$i,
|
|
692
|
+
meta: meta$i
|
|
664
693
|
};
|
|
665
694
|
|
|
666
|
-
const meta$
|
|
695
|
+
const meta$h = {
|
|
667
696
|
docs: {
|
|
668
697
|
description: 'Disallow raw string children in virtual-dom arrays'
|
|
669
698
|
},
|
|
@@ -675,7 +704,7 @@ const meta$f = {
|
|
|
675
704
|
const isVirtualDomArray = node => {
|
|
676
705
|
return isArrayExpressionNode(node) && node.elements.some(element => isVirtualDomNode(element) || isTextCall(element));
|
|
677
706
|
};
|
|
678
|
-
const create$
|
|
707
|
+
const create$h = context => {
|
|
679
708
|
return {
|
|
680
709
|
ArrayExpression(node) {
|
|
681
710
|
if (!isVirtualDomArray(node)) {
|
|
@@ -696,11 +725,11 @@ const create$f = context => {
|
|
|
696
725
|
|
|
697
726
|
const noRawTextChildren = {
|
|
698
727
|
__proto__: null,
|
|
699
|
-
create: create$
|
|
700
|
-
meta: meta$
|
|
728
|
+
create: create$h,
|
|
729
|
+
meta: meta$h
|
|
701
730
|
};
|
|
702
731
|
|
|
703
|
-
const meta$
|
|
732
|
+
const meta$g = {
|
|
704
733
|
docs: {
|
|
705
734
|
description: 'Require each virtual-dom event listener to call its dedicated handler'
|
|
706
735
|
},
|
|
@@ -709,7 +738,7 @@ const meta$e = {
|
|
|
709
738
|
},
|
|
710
739
|
type: 'problem'
|
|
711
740
|
};
|
|
712
|
-
const create$
|
|
741
|
+
const create$g = context => {
|
|
713
742
|
return {
|
|
714
743
|
ObjectExpression(node) {
|
|
715
744
|
if (!isObjectExpressionNode(node)) {
|
|
@@ -739,11 +768,44 @@ const create$e = context => {
|
|
|
739
768
|
|
|
740
769
|
const noSharedEventListenerHandlers = {
|
|
741
770
|
__proto__: null,
|
|
742
|
-
create: create$
|
|
743
|
-
meta: meta$
|
|
771
|
+
create: create$g,
|
|
772
|
+
meta: meta$g
|
|
744
773
|
};
|
|
745
774
|
|
|
746
|
-
const meta$
|
|
775
|
+
const meta$f = {
|
|
776
|
+
docs: {
|
|
777
|
+
description: 'Disallow tree helpers for creating virtual DOM nodes'
|
|
778
|
+
},
|
|
779
|
+
messages: {
|
|
780
|
+
noTreeHelper: 'Create virtual DOM nodes as plain objects and arrays instead of using `tree(...)`.'
|
|
781
|
+
},
|
|
782
|
+
type: 'problem'
|
|
783
|
+
};
|
|
784
|
+
const create$f = context => {
|
|
785
|
+
return {
|
|
786
|
+
CallExpression(node) {
|
|
787
|
+
if (!isIdentifierNode(node.callee) || node.callee.name !== 'tree') {
|
|
788
|
+
return;
|
|
789
|
+
}
|
|
790
|
+
const attributes = node.arguments[1];
|
|
791
|
+
if (!isObjectExpressionNode(attributes) || !hasProperty(attributes, 'className')) {
|
|
792
|
+
return;
|
|
793
|
+
}
|
|
794
|
+
context.report({
|
|
795
|
+
messageId: 'noTreeHelper',
|
|
796
|
+
node
|
|
797
|
+
});
|
|
798
|
+
}
|
|
799
|
+
};
|
|
800
|
+
};
|
|
801
|
+
|
|
802
|
+
const noTreeHelper = {
|
|
803
|
+
__proto__: null,
|
|
804
|
+
create: create$f,
|
|
805
|
+
meta: meta$f
|
|
806
|
+
};
|
|
807
|
+
|
|
808
|
+
const meta$e = {
|
|
747
809
|
docs: {
|
|
748
810
|
description: 'Prefer constants for single literal virtual-dom class names'
|
|
749
811
|
},
|
|
@@ -752,7 +814,7 @@ const meta$d = {
|
|
|
752
814
|
},
|
|
753
815
|
type: 'suggestion'
|
|
754
816
|
};
|
|
755
|
-
const create$
|
|
817
|
+
const create$e = context => {
|
|
756
818
|
return {
|
|
757
819
|
ObjectExpression(node) {
|
|
758
820
|
if (!isVirtualDomNode(node)) {
|
|
@@ -772,11 +834,11 @@ const create$d = context => {
|
|
|
772
834
|
|
|
773
835
|
const preferClassNameConstants = {
|
|
774
836
|
__proto__: null,
|
|
775
|
-
create: create$
|
|
776
|
-
meta: meta$
|
|
837
|
+
create: create$e,
|
|
838
|
+
meta: meta$e
|
|
777
839
|
};
|
|
778
840
|
|
|
779
|
-
const meta$
|
|
841
|
+
const meta$d = {
|
|
780
842
|
docs: {
|
|
781
843
|
description: 'Prefer virtual-dom constants over raw type, role, aria boolean, and tabIndex values'
|
|
782
844
|
},
|
|
@@ -792,7 +854,7 @@ const meta$c = {
|
|
|
792
854
|
const isAriaBooleanProperty = name => {
|
|
793
855
|
return /^aria[A-Z]/.test(name);
|
|
794
856
|
};
|
|
795
|
-
const create$
|
|
857
|
+
const create$d = context => {
|
|
796
858
|
return {
|
|
797
859
|
ObjectExpression(node) {
|
|
798
860
|
if (!isVirtualDomNode(node)) {
|
|
@@ -847,11 +909,11 @@ const create$c = context => {
|
|
|
847
909
|
|
|
848
910
|
const preferConstants = {
|
|
849
911
|
__proto__: null,
|
|
850
|
-
create: create$
|
|
851
|
-
meta: meta$
|
|
912
|
+
create: create$d,
|
|
913
|
+
meta: meta$d
|
|
852
914
|
};
|
|
853
915
|
|
|
854
|
-
const meta$
|
|
916
|
+
const meta$c = {
|
|
855
917
|
docs: {
|
|
856
918
|
description: 'Prefer destructuring layout properties before use'
|
|
857
919
|
},
|
|
@@ -878,7 +940,7 @@ const isWriteExpression$1 = node => {
|
|
|
878
940
|
}
|
|
879
941
|
return parent.type === 'UnaryExpression' && parent.operator === 'delete' && parent.argument === node;
|
|
880
942
|
};
|
|
881
|
-
const create$
|
|
943
|
+
const create$c = context => {
|
|
882
944
|
return {
|
|
883
945
|
MemberExpression(node) {
|
|
884
946
|
if (node.computed) {
|
|
@@ -906,11 +968,11 @@ const create$b = context => {
|
|
|
906
968
|
|
|
907
969
|
const preferLayoutDestructuring = {
|
|
908
970
|
__proto__: null,
|
|
909
|
-
create: create$
|
|
910
|
-
meta: meta$
|
|
971
|
+
create: create$c,
|
|
972
|
+
meta: meta$c
|
|
911
973
|
};
|
|
912
974
|
|
|
913
|
-
const meta$
|
|
975
|
+
const meta$b = {
|
|
914
976
|
docs: {
|
|
915
977
|
description: 'Require Intl.DateTimeFormat instances to be created lazily'
|
|
916
978
|
},
|
|
@@ -925,7 +987,7 @@ const isFunctionNode = node => {
|
|
|
925
987
|
const isDateTimeFormat = node => {
|
|
926
988
|
return node.type === 'MemberExpression' && !node.computed && node.object.type === 'Identifier' && node.object.name === 'Intl' && node.property.type === 'Identifier' && node.property.name === 'DateTimeFormat';
|
|
927
989
|
};
|
|
928
|
-
const create$
|
|
990
|
+
const create$b = context => {
|
|
929
991
|
const isCreatedLazily = node => {
|
|
930
992
|
return context.sourceCode.getAncestors(node).some(isFunctionNode);
|
|
931
993
|
};
|
|
@@ -946,8 +1008,8 @@ const create$a = context => {
|
|
|
946
1008
|
|
|
947
1009
|
const preferLazyDateTimeFormat = {
|
|
948
1010
|
__proto__: null,
|
|
949
|
-
create: create$
|
|
950
|
-
meta: meta$
|
|
1011
|
+
create: create$b,
|
|
1012
|
+
meta: meta$b
|
|
951
1013
|
};
|
|
952
1014
|
|
|
953
1015
|
const isClassNameKey = node => {
|
|
@@ -995,7 +1057,7 @@ const getParent = node => {
|
|
|
995
1057
|
}
|
|
996
1058
|
return undefined;
|
|
997
1059
|
};
|
|
998
|
-
const meta$
|
|
1060
|
+
const meta$a = {
|
|
999
1061
|
docs: {
|
|
1000
1062
|
description: 'Prefer mergeClassNames for composing virtual-dom className values'
|
|
1001
1063
|
},
|
|
@@ -1004,7 +1066,7 @@ const meta$9 = {
|
|
|
1004
1066
|
},
|
|
1005
1067
|
type: 'suggestion'
|
|
1006
1068
|
};
|
|
1007
|
-
const create$
|
|
1069
|
+
const create$a = context => {
|
|
1008
1070
|
const reportNamespacedClassNameComposition = node => {
|
|
1009
1071
|
if (!isManualClassNameConcatenation(node) || !hasClassNamesReference(node)) {
|
|
1010
1072
|
return;
|
|
@@ -1035,11 +1097,11 @@ const create$9 = context => {
|
|
|
1035
1097
|
|
|
1036
1098
|
const preferMergeClassNames = {
|
|
1037
1099
|
__proto__: null,
|
|
1038
|
-
create: create$
|
|
1039
|
-
meta: meta$
|
|
1100
|
+
create: create$a,
|
|
1101
|
+
meta: meta$a
|
|
1040
1102
|
};
|
|
1041
1103
|
|
|
1042
|
-
const meta$
|
|
1104
|
+
const meta$9 = {
|
|
1043
1105
|
docs: {
|
|
1044
1106
|
description: 'Prefer destructuring state properties before use'
|
|
1045
1107
|
},
|
|
@@ -1066,7 +1128,7 @@ const isWriteExpression = node => {
|
|
|
1066
1128
|
}
|
|
1067
1129
|
return parent.type === 'UnaryExpression' && parent.operator === 'delete' && parent.argument === node;
|
|
1068
1130
|
};
|
|
1069
|
-
const create$
|
|
1131
|
+
const create$9 = context => {
|
|
1070
1132
|
return {
|
|
1071
1133
|
MemberExpression(node) {
|
|
1072
1134
|
if (node.computed) {
|
|
@@ -1093,6 +1155,44 @@ const create$8 = context => {
|
|
|
1093
1155
|
};
|
|
1094
1156
|
|
|
1095
1157
|
const preferStateDestructuring = {
|
|
1158
|
+
__proto__: null,
|
|
1159
|
+
create: create$9,
|
|
1160
|
+
meta: meta$9
|
|
1161
|
+
};
|
|
1162
|
+
|
|
1163
|
+
const meta$8 = {
|
|
1164
|
+
docs: {
|
|
1165
|
+
description: 'Prefer URL.canParse over catching errors from the URL constructor'
|
|
1166
|
+
},
|
|
1167
|
+
messages: {
|
|
1168
|
+
preferUrlCanParse: 'Use URL.canParse() to validate the URL before calling new URL().'
|
|
1169
|
+
},
|
|
1170
|
+
type: 'suggestion'
|
|
1171
|
+
};
|
|
1172
|
+
const isUrlConstructor = node => {
|
|
1173
|
+
return node.callee.type === 'Identifier' && node.callee.name === 'URL';
|
|
1174
|
+
};
|
|
1175
|
+
const isInCaughtTryBlock = (context, node) => {
|
|
1176
|
+
const ancestors = context.sourceCode.getAncestors(node);
|
|
1177
|
+
return ancestors.some(ancestor => {
|
|
1178
|
+
return ancestor.type === 'TryStatement' && ancestor.handler !== null && ancestors.includes(ancestor.block);
|
|
1179
|
+
});
|
|
1180
|
+
};
|
|
1181
|
+
const create$8 = context => {
|
|
1182
|
+
return {
|
|
1183
|
+
NewExpression(node) {
|
|
1184
|
+
if (!isUrlConstructor(node) || !isInCaughtTryBlock(context, node)) {
|
|
1185
|
+
return;
|
|
1186
|
+
}
|
|
1187
|
+
context.report({
|
|
1188
|
+
messageId: 'preferUrlCanParse',
|
|
1189
|
+
node
|
|
1190
|
+
});
|
|
1191
|
+
}
|
|
1192
|
+
};
|
|
1193
|
+
};
|
|
1194
|
+
|
|
1195
|
+
const preferUrlCanParse = {
|
|
1096
1196
|
__proto__: null,
|
|
1097
1197
|
create: create$8,
|
|
1098
1198
|
meta: meta$8
|
|
@@ -1522,6 +1622,7 @@ const plugin = {
|
|
|
1522
1622
|
'clickable-div-needs-role': clickableDivNeedsRole,
|
|
1523
1623
|
'hoist-static-nodes': hoistStaticNodes,
|
|
1524
1624
|
'no-conditional-spread': noConditionalSpread,
|
|
1625
|
+
'no-element-helper': noElementHelper,
|
|
1525
1626
|
'no-empty-aria': noEmptyAria,
|
|
1526
1627
|
'no-empty-class-name': noEmptyClassName,
|
|
1527
1628
|
'no-inline-event-handlers': noInlineEventHandlers,
|
|
@@ -1531,12 +1632,14 @@ const plugin = {
|
|
|
1531
1632
|
'no-positive-tab-index': noPositiveTabIndex,
|
|
1532
1633
|
'no-raw-text-children': noRawTextChildren,
|
|
1533
1634
|
'no-shared-event-listener-handlers': noSharedEventListenerHandlers,
|
|
1635
|
+
'no-tree-helper': noTreeHelper,
|
|
1534
1636
|
'prefer-class-name-constants': preferClassNameConstants,
|
|
1535
1637
|
'prefer-constants': preferConstants,
|
|
1536
1638
|
'prefer-layout-destructuring': preferLayoutDestructuring,
|
|
1537
1639
|
'prefer-lazy-date-time-format': preferLazyDateTimeFormat,
|
|
1538
1640
|
'prefer-merge-class-names': preferMergeClassNames,
|
|
1539
1641
|
'prefer-state-destructuring': preferStateDestructuring,
|
|
1642
|
+
'prefer-url-can-parse': preferUrlCanParse,
|
|
1540
1643
|
'require-event-listener-options': requireEventListenerOptions,
|
|
1541
1644
|
'require-image-alt': requireImageAlt,
|
|
1542
1645
|
'secure-links': secureLinks,
|
|
@@ -1556,6 +1659,7 @@ const recommended = [{
|
|
|
1556
1659
|
'virtual-dom/clickable-div-needs-role': 'error',
|
|
1557
1660
|
'virtual-dom/hoist-static-nodes': 'error',
|
|
1558
1661
|
'virtual-dom/no-conditional-spread': 'error',
|
|
1662
|
+
'virtual-dom/no-element-helper': 'error',
|
|
1559
1663
|
'virtual-dom/no-empty-aria': 'error',
|
|
1560
1664
|
'virtual-dom/no-empty-class-name': 'error',
|
|
1561
1665
|
'virtual-dom/no-inline-event-handlers': 'error',
|
|
@@ -1563,11 +1667,13 @@ const recommended = [{
|
|
|
1563
1667
|
'virtual-dom/no-object-attribute-values': 'error',
|
|
1564
1668
|
'virtual-dom/no-raw-text-children': 'error',
|
|
1565
1669
|
'virtual-dom/no-shared-event-listener-handlers': 'error',
|
|
1670
|
+
'virtual-dom/no-tree-helper': 'error',
|
|
1566
1671
|
'virtual-dom/prefer-constants': 'error',
|
|
1567
1672
|
'virtual-dom/prefer-layout-destructuring': 'error',
|
|
1568
1673
|
'virtual-dom/prefer-lazy-date-time-format': 'error',
|
|
1569
1674
|
'virtual-dom/prefer-merge-class-names': 'error',
|
|
1570
1675
|
'virtual-dom/prefer-state-destructuring': 'error',
|
|
1676
|
+
'virtual-dom/prefer-url-can-parse': 'error',
|
|
1571
1677
|
'virtual-dom/require-event-listener-options': 'error',
|
|
1572
1678
|
'virtual-dom/secure-links': 'error',
|
|
1573
1679
|
'virtual-dom/valid-child-count': 'error'
|