@lvce-editor/eslint-plugin-virtual-dom 17.6.0 → 17.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 +119 -58
- 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$q = {
|
|
97
97
|
docs: {
|
|
98
98
|
description: 'Require a statically determinable accessible name for virtual-dom controls'
|
|
99
99
|
},
|
|
@@ -102,7 +102,7 @@ const meta$p = {
|
|
|
102
102
|
},
|
|
103
103
|
type: 'problem'
|
|
104
104
|
};
|
|
105
|
-
const create$
|
|
105
|
+
const create$q = context => {
|
|
106
106
|
return {
|
|
107
107
|
ObjectExpression(node) {
|
|
108
108
|
if (!isVirtualDomNode(node) || hasDirectName(node)) {
|
|
@@ -144,11 +144,11 @@ const create$p = context => {
|
|
|
144
144
|
|
|
145
145
|
const accessibleControlName = {
|
|
146
146
|
__proto__: null,
|
|
147
|
-
create: create$
|
|
148
|
-
meta: meta$
|
|
147
|
+
create: create$q,
|
|
148
|
+
meta: meta$q
|
|
149
149
|
};
|
|
150
150
|
|
|
151
|
-
const meta$
|
|
151
|
+
const meta$p = {
|
|
152
152
|
docs: {
|
|
153
153
|
description: 'Require an explicit role on clickable virtual-dom div nodes'
|
|
154
154
|
},
|
|
@@ -157,7 +157,7 @@ const meta$o = {
|
|
|
157
157
|
},
|
|
158
158
|
type: 'problem'
|
|
159
159
|
};
|
|
160
|
-
const create$
|
|
160
|
+
const create$p = context => {
|
|
161
161
|
return {
|
|
162
162
|
ObjectExpression(node) {
|
|
163
163
|
if (!isVirtualDomNode(node)) {
|
|
@@ -179,11 +179,11 @@ const create$o = context => {
|
|
|
179
179
|
|
|
180
180
|
const clickableDivNeedsRole = {
|
|
181
181
|
__proto__: null,
|
|
182
|
-
create: create$
|
|
183
|
-
meta: meta$
|
|
182
|
+
create: create$p,
|
|
183
|
+
meta: meta$p
|
|
184
184
|
};
|
|
185
185
|
|
|
186
|
-
const meta$
|
|
186
|
+
const meta$o = {
|
|
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$o = context => {
|
|
322
322
|
return {
|
|
323
323
|
ObjectExpression(node) {
|
|
324
324
|
if (!isVirtualDomElement(node)) {
|
|
@@ -343,11 +343,11 @@ const create$n = context => {
|
|
|
343
343
|
|
|
344
344
|
const hoistStaticNodes = {
|
|
345
345
|
__proto__: null,
|
|
346
|
-
create: create$
|
|
347
|
-
meta: meta$
|
|
346
|
+
create: create$o,
|
|
347
|
+
meta: meta$o
|
|
348
348
|
};
|
|
349
349
|
|
|
350
|
-
const meta$
|
|
350
|
+
const meta$n = {
|
|
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$n = context => {
|
|
369
369
|
return {
|
|
370
370
|
ArrayExpression(node) {
|
|
371
371
|
const conditionalSpreads = node.elements.filter(isConditionalSpread);
|
|
@@ -384,11 +384,11 @@ const create$m = context => {
|
|
|
384
384
|
|
|
385
385
|
const noConditionalSpread = {
|
|
386
386
|
__proto__: null,
|
|
387
|
-
create: create$
|
|
388
|
-
meta: meta$
|
|
387
|
+
create: create$n,
|
|
388
|
+
meta: meta$n
|
|
389
389
|
};
|
|
390
390
|
|
|
391
|
-
const meta$
|
|
391
|
+
const meta$m = {
|
|
392
392
|
docs: {
|
|
393
393
|
description: 'Disallow empty ARIA values in virtual-dom nodes'
|
|
394
394
|
},
|
|
@@ -400,7 +400,7 @@ const meta$l = {
|
|
|
400
400
|
const isAriaProperty = name => {
|
|
401
401
|
return /^aria[A-Z]/.test(name);
|
|
402
402
|
};
|
|
403
|
-
const create$
|
|
403
|
+
const create$m = context => {
|
|
404
404
|
return {
|
|
405
405
|
ObjectExpression(node) {
|
|
406
406
|
if (!isVirtualDomNode(node)) {
|
|
@@ -425,11 +425,11 @@ const create$l = context => {
|
|
|
425
425
|
|
|
426
426
|
const noEmptyAria = {
|
|
427
427
|
__proto__: null,
|
|
428
|
-
create: create$
|
|
429
|
-
meta: meta$
|
|
428
|
+
create: create$m,
|
|
429
|
+
meta: meta$m
|
|
430
430
|
};
|
|
431
431
|
|
|
432
|
-
const meta$
|
|
432
|
+
const meta$l = {
|
|
433
433
|
docs: {
|
|
434
434
|
description: 'Disallow empty className values in virtual-dom nodes'
|
|
435
435
|
},
|
|
@@ -438,7 +438,7 @@ const meta$k = {
|
|
|
438
438
|
},
|
|
439
439
|
type: 'problem'
|
|
440
440
|
};
|
|
441
|
-
const create$
|
|
441
|
+
const create$l = context => {
|
|
442
442
|
return {
|
|
443
443
|
ObjectExpression(node) {
|
|
444
444
|
if (!isVirtualDomNode(node)) {
|
|
@@ -458,11 +458,11 @@ const create$k = context => {
|
|
|
458
458
|
|
|
459
459
|
const noEmptyClassName = {
|
|
460
460
|
__proto__: null,
|
|
461
|
-
create: create$
|
|
462
|
-
meta: meta$
|
|
461
|
+
create: create$l,
|
|
462
|
+
meta: meta$l
|
|
463
463
|
};
|
|
464
464
|
|
|
465
|
-
const meta$
|
|
465
|
+
const meta$k = {
|
|
466
466
|
docs: {
|
|
467
467
|
description: 'Disallow inline event handlers in virtual-dom nodes'
|
|
468
468
|
},
|
|
@@ -477,7 +477,7 @@ const isEventPropertyName = name => {
|
|
|
477
477
|
const isInlineEventHandler = node => {
|
|
478
478
|
return isStringLiteral(node) || isTemplateLiteralNode(node) || isArrowFunctionExpressionNode(node) || isFunctionExpressionNode(node);
|
|
479
479
|
};
|
|
480
|
-
const create$
|
|
480
|
+
const create$k = context => {
|
|
481
481
|
return {
|
|
482
482
|
ObjectExpression(node) {
|
|
483
483
|
if (!isVirtualDomNode(node)) {
|
|
@@ -502,11 +502,11 @@ const create$j = context => {
|
|
|
502
502
|
|
|
503
503
|
const noInlineEventHandlers = {
|
|
504
504
|
__proto__: null,
|
|
505
|
-
create: create$
|
|
506
|
-
meta: meta$
|
|
505
|
+
create: create$k,
|
|
506
|
+
meta: meta$k
|
|
507
507
|
};
|
|
508
508
|
|
|
509
|
-
const meta$
|
|
509
|
+
const meta$j = {
|
|
510
510
|
docs: {
|
|
511
511
|
description: 'Disallow inline style attributes in virtual-dom nodes'
|
|
512
512
|
},
|
|
@@ -515,7 +515,7 @@ const meta$i = {
|
|
|
515
515
|
},
|
|
516
516
|
type: 'problem'
|
|
517
517
|
};
|
|
518
|
-
const create$
|
|
518
|
+
const create$j = context => {
|
|
519
519
|
return {
|
|
520
520
|
ObjectExpression(node) {
|
|
521
521
|
if (!isVirtualDomNode(node)) {
|
|
@@ -535,8 +535,8 @@ const create$i = context => {
|
|
|
535
535
|
|
|
536
536
|
const noInlineStyle = {
|
|
537
537
|
__proto__: null,
|
|
538
|
-
create: create$
|
|
539
|
-
meta: meta$
|
|
538
|
+
create: create$j,
|
|
539
|
+
meta: meta$j
|
|
540
540
|
};
|
|
541
541
|
|
|
542
542
|
const ignoredProperties$1 = new Set(['childCount', 'type']);
|
|
@@ -546,7 +546,7 @@ const isOptionalExpression = node => {
|
|
|
546
546
|
const isNullish = node => {
|
|
547
547
|
return isLiteralNode(node) && node.value === null || isIdentifierNode(node) && node.name === 'undefined' || isOptionalExpression(node);
|
|
548
548
|
};
|
|
549
|
-
const meta$
|
|
549
|
+
const meta$i = {
|
|
550
550
|
docs: {
|
|
551
551
|
description: 'Disallow nullish virtual-dom attribute values'
|
|
552
552
|
},
|
|
@@ -555,7 +555,7 @@ const meta$h = {
|
|
|
555
555
|
},
|
|
556
556
|
type: 'problem'
|
|
557
557
|
};
|
|
558
|
-
const create$
|
|
558
|
+
const create$i = context => {
|
|
559
559
|
return {
|
|
560
560
|
ObjectExpression(node) {
|
|
561
561
|
if (!isVirtualDomNode(node)) {
|
|
@@ -583,11 +583,11 @@ const create$h = context => {
|
|
|
583
583
|
|
|
584
584
|
const noNullishAttributeValues = {
|
|
585
585
|
__proto__: null,
|
|
586
|
-
create: create$
|
|
587
|
-
meta: meta$
|
|
586
|
+
create: create$i,
|
|
587
|
+
meta: meta$i
|
|
588
588
|
};
|
|
589
589
|
|
|
590
|
-
const meta$
|
|
590
|
+
const meta$h = {
|
|
591
591
|
docs: {
|
|
592
592
|
description: 'Disallow object-like attribute values in virtual-dom nodes'
|
|
593
593
|
},
|
|
@@ -600,7 +600,7 @@ const ignoredProperties = new Set(['childCount', 'type']);
|
|
|
600
600
|
const isObjectLikeAttributeValue = node => {
|
|
601
601
|
return isObjectExpressionNode(node) || isArrayExpressionNode(node) || isArrowFunctionExpressionNode(node) || isFunctionExpressionNode(node);
|
|
602
602
|
};
|
|
603
|
-
const create$
|
|
603
|
+
const create$h = context => {
|
|
604
604
|
return {
|
|
605
605
|
ObjectExpression(node) {
|
|
606
606
|
if (!isVirtualDomNode(node)) {
|
|
@@ -625,11 +625,11 @@ const create$g = context => {
|
|
|
625
625
|
|
|
626
626
|
const noObjectAttributeValues = {
|
|
627
627
|
__proto__: null,
|
|
628
|
-
create: create$
|
|
629
|
-
meta: meta$
|
|
628
|
+
create: create$h,
|
|
629
|
+
meta: meta$h
|
|
630
630
|
};
|
|
631
631
|
|
|
632
|
-
const meta$
|
|
632
|
+
const meta$g = {
|
|
633
633
|
docs: {
|
|
634
634
|
description: 'Disallow positive virtual-dom tabIndex values'
|
|
635
635
|
},
|
|
@@ -638,7 +638,7 @@ const meta$f = {
|
|
|
638
638
|
},
|
|
639
639
|
type: 'problem'
|
|
640
640
|
};
|
|
641
|
-
const create$
|
|
641
|
+
const create$g = context => {
|
|
642
642
|
return {
|
|
643
643
|
ObjectExpression(node) {
|
|
644
644
|
if (!isVirtualDomNode(node)) {
|
|
@@ -659,11 +659,11 @@ const create$f = context => {
|
|
|
659
659
|
|
|
660
660
|
const noPositiveTabIndex = {
|
|
661
661
|
__proto__: null,
|
|
662
|
-
create: create$
|
|
663
|
-
meta: meta$
|
|
662
|
+
create: create$g,
|
|
663
|
+
meta: meta$g
|
|
664
664
|
};
|
|
665
665
|
|
|
666
|
-
const meta$
|
|
666
|
+
const meta$f = {
|
|
667
667
|
docs: {
|
|
668
668
|
description: 'Disallow raw string children in virtual-dom arrays'
|
|
669
669
|
},
|
|
@@ -675,7 +675,7 @@ const meta$e = {
|
|
|
675
675
|
const isVirtualDomArray = node => {
|
|
676
676
|
return isArrayExpressionNode(node) && node.elements.some(element => isVirtualDomNode(element) || isTextCall(element));
|
|
677
677
|
};
|
|
678
|
-
const create$
|
|
678
|
+
const create$f = context => {
|
|
679
679
|
return {
|
|
680
680
|
ArrayExpression(node) {
|
|
681
681
|
if (!isVirtualDomArray(node)) {
|
|
@@ -696,11 +696,11 @@ const create$e = context => {
|
|
|
696
696
|
|
|
697
697
|
const noRawTextChildren = {
|
|
698
698
|
__proto__: null,
|
|
699
|
-
create: create$
|
|
700
|
-
meta: meta$
|
|
699
|
+
create: create$f,
|
|
700
|
+
meta: meta$f
|
|
701
701
|
};
|
|
702
702
|
|
|
703
|
-
const meta$
|
|
703
|
+
const meta$e = {
|
|
704
704
|
docs: {
|
|
705
705
|
description: 'Require each virtual-dom event listener to call its dedicated handler'
|
|
706
706
|
},
|
|
@@ -709,7 +709,7 @@ const meta$d = {
|
|
|
709
709
|
},
|
|
710
710
|
type: 'problem'
|
|
711
711
|
};
|
|
712
|
-
const create$
|
|
712
|
+
const create$e = context => {
|
|
713
713
|
return {
|
|
714
714
|
ObjectExpression(node) {
|
|
715
715
|
if (!isObjectExpressionNode(node)) {
|
|
@@ -739,11 +739,11 @@ const create$d = context => {
|
|
|
739
739
|
|
|
740
740
|
const noSharedEventListenerHandlers = {
|
|
741
741
|
__proto__: null,
|
|
742
|
-
create: create$
|
|
743
|
-
meta: meta$
|
|
742
|
+
create: create$e,
|
|
743
|
+
meta: meta$e
|
|
744
744
|
};
|
|
745
745
|
|
|
746
|
-
const meta$
|
|
746
|
+
const meta$d = {
|
|
747
747
|
docs: {
|
|
748
748
|
description: 'Prefer constants for single literal virtual-dom class names'
|
|
749
749
|
},
|
|
@@ -752,7 +752,7 @@ const meta$c = {
|
|
|
752
752
|
},
|
|
753
753
|
type: 'suggestion'
|
|
754
754
|
};
|
|
755
|
-
const create$
|
|
755
|
+
const create$d = context => {
|
|
756
756
|
return {
|
|
757
757
|
ObjectExpression(node) {
|
|
758
758
|
if (!isVirtualDomNode(node)) {
|
|
@@ -772,11 +772,11 @@ const create$c = context => {
|
|
|
772
772
|
|
|
773
773
|
const preferClassNameConstants = {
|
|
774
774
|
__proto__: null,
|
|
775
|
-
create: create$
|
|
776
|
-
meta: meta$
|
|
775
|
+
create: create$d,
|
|
776
|
+
meta: meta$d
|
|
777
777
|
};
|
|
778
778
|
|
|
779
|
-
const meta$
|
|
779
|
+
const meta$c = {
|
|
780
780
|
docs: {
|
|
781
781
|
description: 'Prefer virtual-dom constants over raw type, role, aria boolean, and tabIndex values'
|
|
782
782
|
},
|
|
@@ -792,7 +792,7 @@ const meta$b = {
|
|
|
792
792
|
const isAriaBooleanProperty = name => {
|
|
793
793
|
return /^aria[A-Z]/.test(name);
|
|
794
794
|
};
|
|
795
|
-
const create$
|
|
795
|
+
const create$c = context => {
|
|
796
796
|
return {
|
|
797
797
|
ObjectExpression(node) {
|
|
798
798
|
if (!isVirtualDomNode(node)) {
|
|
@@ -846,6 +846,65 @@ const create$b = context => {
|
|
|
846
846
|
};
|
|
847
847
|
|
|
848
848
|
const preferConstants = {
|
|
849
|
+
__proto__: null,
|
|
850
|
+
create: create$c,
|
|
851
|
+
meta: meta$c
|
|
852
|
+
};
|
|
853
|
+
|
|
854
|
+
const meta$b = {
|
|
855
|
+
docs: {
|
|
856
|
+
description: 'Prefer destructuring layout properties before use'
|
|
857
|
+
},
|
|
858
|
+
messages: {
|
|
859
|
+
preferLayoutDestructuring: 'Prefer destructuring from layout instead of using layout.{{property}}.'
|
|
860
|
+
},
|
|
861
|
+
type: 'suggestion'
|
|
862
|
+
};
|
|
863
|
+
const isIdentifier$1 = node => {
|
|
864
|
+
return node?.type === 'Identifier';
|
|
865
|
+
};
|
|
866
|
+
const isWriteExpression$1 = node => {
|
|
867
|
+
const {
|
|
868
|
+
parent
|
|
869
|
+
} = node;
|
|
870
|
+
if (!parent) {
|
|
871
|
+
return false;
|
|
872
|
+
}
|
|
873
|
+
if (parent.type === 'AssignmentExpression' && parent.left === node) {
|
|
874
|
+
return true;
|
|
875
|
+
}
|
|
876
|
+
if (parent.type === 'UpdateExpression' && parent.argument === node) {
|
|
877
|
+
return true;
|
|
878
|
+
}
|
|
879
|
+
return parent.type === 'UnaryExpression' && parent.operator === 'delete' && parent.argument === node;
|
|
880
|
+
};
|
|
881
|
+
const create$b = context => {
|
|
882
|
+
return {
|
|
883
|
+
MemberExpression(node) {
|
|
884
|
+
if (node.computed) {
|
|
885
|
+
return;
|
|
886
|
+
}
|
|
887
|
+
if (!isIdentifier$1(node.object) || node.object.name !== 'layout') {
|
|
888
|
+
return;
|
|
889
|
+
}
|
|
890
|
+
if (!isIdentifier$1(node.property)) {
|
|
891
|
+
return;
|
|
892
|
+
}
|
|
893
|
+
if (isWriteExpression$1(node)) {
|
|
894
|
+
return;
|
|
895
|
+
}
|
|
896
|
+
context.report({
|
|
897
|
+
data: {
|
|
898
|
+
property: node.property.name
|
|
899
|
+
},
|
|
900
|
+
messageId: 'preferLayoutDestructuring',
|
|
901
|
+
node
|
|
902
|
+
});
|
|
903
|
+
}
|
|
904
|
+
};
|
|
905
|
+
};
|
|
906
|
+
|
|
907
|
+
const preferLayoutDestructuring = {
|
|
849
908
|
__proto__: null,
|
|
850
909
|
create: create$b,
|
|
851
910
|
meta: meta$b
|
|
@@ -1474,6 +1533,7 @@ const plugin = {
|
|
|
1474
1533
|
'no-shared-event-listener-handlers': noSharedEventListenerHandlers,
|
|
1475
1534
|
'prefer-class-name-constants': preferClassNameConstants,
|
|
1476
1535
|
'prefer-constants': preferConstants,
|
|
1536
|
+
'prefer-layout-destructuring': preferLayoutDestructuring,
|
|
1477
1537
|
'prefer-lazy-date-time-format': preferLazyDateTimeFormat,
|
|
1478
1538
|
'prefer-merge-class-names': preferMergeClassNames,
|
|
1479
1539
|
'prefer-state-destructuring': preferStateDestructuring,
|
|
@@ -1504,6 +1564,7 @@ const recommended = [{
|
|
|
1504
1564
|
'virtual-dom/no-raw-text-children': 'error',
|
|
1505
1565
|
'virtual-dom/no-shared-event-listener-handlers': 'error',
|
|
1506
1566
|
'virtual-dom/prefer-constants': 'error',
|
|
1567
|
+
'virtual-dom/prefer-layout-destructuring': 'error',
|
|
1507
1568
|
'virtual-dom/prefer-lazy-date-time-format': 'error',
|
|
1508
1569
|
'virtual-dom/prefer-merge-class-names': 'error',
|
|
1509
1570
|
'virtual-dom/prefer-state-destructuring': 'error',
|