@lvce-editor/eslint-plugin-virtual-dom 18.7.0 → 18.8.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.
Files changed (2) hide show
  1. package/dist/index.js +102 -55
  2. 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$t = {
96
+ const meta$u = {
97
97
  docs: {
98
98
  description: 'Require a statically determinable accessible name for virtual-dom controls'
99
99
  },
@@ -102,7 +102,7 @@ const meta$t = {
102
102
  },
103
103
  type: 'problem'
104
104
  };
105
- const create$t = context => {
105
+ const create$u = context => {
106
106
  return {
107
107
  ObjectExpression(node) {
108
108
  if (!isVirtualDomNode(node) || hasDirectName(node)) {
@@ -144,11 +144,11 @@ const create$t = context => {
144
144
 
145
145
  const accessibleControlName = {
146
146
  __proto__: null,
147
- create: create$t,
148
- meta: meta$t
147
+ create: create$u,
148
+ meta: meta$u
149
149
  };
150
150
 
151
- const meta$s = {
151
+ const meta$t = {
152
152
  docs: {
153
153
  description: 'Require an explicit role on clickable virtual-dom div nodes'
154
154
  },
@@ -157,7 +157,7 @@ const meta$s = {
157
157
  },
158
158
  type: 'problem'
159
159
  };
160
- const create$s = context => {
160
+ const create$t = context => {
161
161
  return {
162
162
  ObjectExpression(node) {
163
163
  if (!isVirtualDomNode(node)) {
@@ -179,11 +179,11 @@ const create$s = context => {
179
179
 
180
180
  const clickableDivNeedsRole = {
181
181
  __proto__: null,
182
- create: create$s,
183
- meta: meta$s
182
+ create: create$t,
183
+ meta: meta$t
184
184
  };
185
185
 
186
- const meta$r = {
186
+ const meta$s = {
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$r = context => {
321
+ const create$s = context => {
322
322
  return {
323
323
  ObjectExpression(node) {
324
324
  if (!isVirtualDomElement(node)) {
@@ -343,11 +343,11 @@ const create$r = context => {
343
343
 
344
344
  const hoistStaticNodes = {
345
345
  __proto__: null,
346
- create: create$r,
347
- meta: meta$r
346
+ create: create$s,
347
+ meta: meta$s
348
348
  };
349
349
 
350
- const meta$q = {
350
+ const meta$r = {
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$q = context => {
368
+ const create$r = context => {
369
369
  return {
370
370
  ArrayExpression(node) {
371
371
  const conditionalSpreads = node.elements.filter(isConditionalSpread);
@@ -384,11 +384,11 @@ const create$q = context => {
384
384
 
385
385
  const noConditionalSpread = {
386
386
  __proto__: null,
387
- create: create$q,
388
- meta: meta$q
387
+ create: create$r,
388
+ meta: meta$r
389
389
  };
390
390
 
391
- const meta$p = {
391
+ const meta$q = {
392
392
  docs: {
393
393
  description: 'Disallow element helpers for creating virtual DOM nodes'
394
394
  },
@@ -397,7 +397,7 @@ const meta$p = {
397
397
  },
398
398
  type: 'problem'
399
399
  };
400
- const create$p = context => {
400
+ const create$q = context => {
401
401
  return {
402
402
  CallExpression(node) {
403
403
  if (!isIdentifierNode(node.callee) || node.callee.name !== 'element' || !getVirtualDomElementName(node.arguments[0])) {
@@ -413,11 +413,11 @@ const create$p = context => {
413
413
 
414
414
  const noElementHelper = {
415
415
  __proto__: null,
416
- create: create$p,
417
- meta: meta$p
416
+ create: create$q,
417
+ meta: meta$q
418
418
  };
419
419
 
420
- const meta$o = {
420
+ const meta$p = {
421
421
  docs: {
422
422
  description: 'Disallow empty ARIA values in virtual-dom nodes'
423
423
  },
@@ -429,7 +429,7 @@ const meta$o = {
429
429
  const isAriaProperty = name => {
430
430
  return /^aria[A-Z]/.test(name);
431
431
  };
432
- const create$o = context => {
432
+ const create$p = context => {
433
433
  return {
434
434
  ObjectExpression(node) {
435
435
  if (!isVirtualDomNode(node)) {
@@ -454,11 +454,11 @@ const create$o = context => {
454
454
 
455
455
  const noEmptyAria = {
456
456
  __proto__: null,
457
- create: create$o,
458
- meta: meta$o
457
+ create: create$p,
458
+ meta: meta$p
459
459
  };
460
460
 
461
- const meta$n = {
461
+ const meta$o = {
462
462
  docs: {
463
463
  description: 'Disallow empty className values in virtual-dom nodes'
464
464
  },
@@ -467,7 +467,7 @@ const meta$n = {
467
467
  },
468
468
  type: 'problem'
469
469
  };
470
- const create$n = context => {
470
+ const create$o = context => {
471
471
  return {
472
472
  ObjectExpression(node) {
473
473
  if (!isVirtualDomNode(node)) {
@@ -487,11 +487,11 @@ const create$n = context => {
487
487
 
488
488
  const noEmptyClassName = {
489
489
  __proto__: null,
490
- create: create$n,
491
- meta: meta$n
490
+ create: create$o,
491
+ meta: meta$o
492
492
  };
493
493
 
494
- const meta$m = {
494
+ const meta$n = {
495
495
  docs: {
496
496
  description: 'Disallow inline event handlers in virtual-dom nodes'
497
497
  },
@@ -506,7 +506,7 @@ const isEventPropertyName = name => {
506
506
  const isInlineEventHandler = node => {
507
507
  return isStringLiteral(node) || isTemplateLiteralNode(node) || isArrowFunctionExpressionNode(node) || isFunctionExpressionNode(node);
508
508
  };
509
- const create$m = context => {
509
+ const create$n = context => {
510
510
  return {
511
511
  ObjectExpression(node) {
512
512
  if (!isVirtualDomNode(node)) {
@@ -531,11 +531,11 @@ const create$m = context => {
531
531
 
532
532
  const noInlineEventHandlers = {
533
533
  __proto__: null,
534
- create: create$m,
535
- meta: meta$m
534
+ create: create$n,
535
+ meta: meta$n
536
536
  };
537
537
 
538
- const meta$l = {
538
+ const meta$m = {
539
539
  docs: {
540
540
  description: 'Disallow inline style attributes in virtual-dom nodes'
541
541
  },
@@ -544,7 +544,7 @@ const meta$l = {
544
544
  },
545
545
  type: 'problem'
546
546
  };
547
- const create$l = context => {
547
+ const create$m = context => {
548
548
  return {
549
549
  ObjectExpression(node) {
550
550
  if (!isVirtualDomNode(node)) {
@@ -564,8 +564,8 @@ const create$l = context => {
564
564
 
565
565
  const noInlineStyle = {
566
566
  __proto__: null,
567
- create: create$l,
568
- meta: meta$l
567
+ create: create$m,
568
+ meta: meta$m
569
569
  };
570
570
 
571
571
  const ignoredProperties$1 = new Set(['childCount', 'type']);
@@ -575,7 +575,7 @@ const isOptionalExpression = node => {
575
575
  const isNullish = node => {
576
576
  return isLiteralNode(node) && node.value === null || isIdentifierNode(node) && node.name === 'undefined' || isOptionalExpression(node);
577
577
  };
578
- const meta$k = {
578
+ const meta$l = {
579
579
  docs: {
580
580
  description: 'Disallow nullish virtual-dom attribute values'
581
581
  },
@@ -584,7 +584,7 @@ const meta$k = {
584
584
  },
585
585
  type: 'problem'
586
586
  };
587
- const create$k = context => {
587
+ const create$l = context => {
588
588
  return {
589
589
  ObjectExpression(node) {
590
590
  if (!isVirtualDomNode(node)) {
@@ -612,11 +612,11 @@ const create$k = context => {
612
612
 
613
613
  const noNullishAttributeValues = {
614
614
  __proto__: null,
615
- create: create$k,
616
- meta: meta$k
615
+ create: create$l,
616
+ meta: meta$l
617
617
  };
618
618
 
619
- const meta$j = {
619
+ const meta$k = {
620
620
  docs: {
621
621
  description: 'Disallow object-like attribute values in virtual-dom nodes'
622
622
  },
@@ -629,7 +629,7 @@ const ignoredProperties = new Set(['childCount', 'type']);
629
629
  const isObjectLikeAttributeValue = node => {
630
630
  return isObjectExpressionNode(node) || isArrayExpressionNode(node) || isArrowFunctionExpressionNode(node) || isFunctionExpressionNode(node);
631
631
  };
632
- const create$j = context => {
632
+ const create$k = context => {
633
633
  return {
634
634
  ObjectExpression(node) {
635
635
  if (!isVirtualDomNode(node)) {
@@ -654,11 +654,11 @@ const create$j = context => {
654
654
 
655
655
  const noObjectAttributeValues = {
656
656
  __proto__: null,
657
- create: create$j,
658
- meta: meta$j
657
+ create: create$k,
658
+ meta: meta$k
659
659
  };
660
660
 
661
- const meta$i = {
661
+ const meta$j = {
662
662
  docs: {
663
663
  description: 'Disallow positive virtual-dom tabIndex values'
664
664
  },
@@ -667,7 +667,7 @@ const meta$i = {
667
667
  },
668
668
  type: 'problem'
669
669
  };
670
- const create$i = context => {
670
+ const create$j = context => {
671
671
  return {
672
672
  ObjectExpression(node) {
673
673
  if (!isVirtualDomNode(node)) {
@@ -688,11 +688,11 @@ const create$i = context => {
688
688
 
689
689
  const noPositiveTabIndex = {
690
690
  __proto__: null,
691
- create: create$i,
692
- meta: meta$i
691
+ create: create$j,
692
+ meta: meta$j
693
693
  };
694
694
 
695
- const meta$h = {
695
+ const meta$i = {
696
696
  docs: {
697
697
  description: 'Disallow raw string children in virtual-dom arrays'
698
698
  },
@@ -704,7 +704,7 @@ const meta$h = {
704
704
  const isVirtualDomArray = node => {
705
705
  return isArrayExpressionNode(node) && node.elements.some(element => isVirtualDomNode(element) || isTextCall(element));
706
706
  };
707
- const create$h = context => {
707
+ const create$i = context => {
708
708
  return {
709
709
  ArrayExpression(node) {
710
710
  if (!isVirtualDomArray(node)) {
@@ -725,11 +725,11 @@ const create$h = context => {
725
725
 
726
726
  const noRawTextChildren = {
727
727
  __proto__: null,
728
- create: create$h,
729
- meta: meta$h
728
+ create: create$i,
729
+ meta: meta$i
730
730
  };
731
731
 
732
- const meta$g = {
732
+ const meta$h = {
733
733
  docs: {
734
734
  description: 'Require each virtual-dom event listener to call its dedicated handler'
735
735
  },
@@ -738,7 +738,7 @@ const meta$g = {
738
738
  },
739
739
  type: 'problem'
740
740
  };
741
- const create$g = context => {
741
+ const create$h = context => {
742
742
  return {
743
743
  ObjectExpression(node) {
744
744
  if (!isObjectExpressionNode(node)) {
@@ -767,6 +767,50 @@ const create$g = context => {
767
767
  };
768
768
 
769
769
  const noSharedEventListenerHandlers = {
770
+ __proto__: null,
771
+ create: create$h,
772
+ meta: meta$h
773
+ };
774
+
775
+ const meta$g = {
776
+ docs: {
777
+ description: 'Disallow local text helper functions for creating virtual DOM text nodes'
778
+ },
779
+ messages: {
780
+ noTextHelper: 'Import `text` from `@lvce-editor/virtual-dom` instead of declaring a local helper.'
781
+ },
782
+ type: 'problem'
783
+ };
784
+ const isTextIdentifier = node => {
785
+ return node?.type === 'Identifier' && node.name === 'text';
786
+ };
787
+ const isFunctionExpression = node => {
788
+ return node?.type === 'ArrowFunctionExpression' || node?.type === 'FunctionExpression';
789
+ };
790
+ const create$g = context => {
791
+ return {
792
+ FunctionDeclaration(node) {
793
+ if (!isTextIdentifier(node.id)) {
794
+ return;
795
+ }
796
+ context.report({
797
+ messageId: 'noTextHelper',
798
+ node: node.id
799
+ });
800
+ },
801
+ VariableDeclarator(node) {
802
+ if (!isTextIdentifier(node.id) || !isFunctionExpression(node.init)) {
803
+ return;
804
+ }
805
+ context.report({
806
+ messageId: 'noTextHelper',
807
+ node: node.id
808
+ });
809
+ }
810
+ };
811
+ };
812
+
813
+ const noTextHelper = {
770
814
  __proto__: null,
771
815
  create: create$g,
772
816
  meta: meta$g
@@ -1632,6 +1676,7 @@ const plugin = {
1632
1676
  'no-positive-tab-index': noPositiveTabIndex,
1633
1677
  'no-raw-text-children': noRawTextChildren,
1634
1678
  'no-shared-event-listener-handlers': noSharedEventListenerHandlers,
1679
+ 'no-text-helper': noTextHelper,
1635
1680
  'no-tree-helper': noTreeHelper,
1636
1681
  'prefer-class-name-constants': preferClassNameConstants,
1637
1682
  'prefer-constants': preferConstants,
@@ -1667,6 +1712,7 @@ const recommended = [{
1667
1712
  'virtual-dom/no-object-attribute-values': 'error',
1668
1713
  'virtual-dom/no-raw-text-children': 'error',
1669
1714
  'virtual-dom/no-shared-event-listener-handlers': 'error',
1715
+ 'virtual-dom/no-text-helper': 'error',
1670
1716
  'virtual-dom/no-tree-helper': 'error',
1671
1717
  'virtual-dom/prefer-constants': 'error',
1672
1718
  'virtual-dom/prefer-layout-destructuring': 'error',
@@ -1681,7 +1727,8 @@ const recommended = [{
1681
1727
  }, {
1682
1728
  files: ['**/test/**/*.{js,mjs,cjs,ts,mts,cts}', '**/tests/**/*.{js,mjs,cjs,ts,mts,cts}', '**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts}'],
1683
1729
  rules: {
1684
- 'virtual-dom/hoist-static-nodes': 'off'
1730
+ 'virtual-dom/hoist-static-nodes': 'off',
1731
+ 'virtual-dom/prefer-merge-class-names': 'off'
1685
1732
  }
1686
1733
  }];
1687
1734
  const strict = [...recommended, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/eslint-plugin-virtual-dom",
3
- "version": "18.7.0",
3
+ "version": "18.8.0",
4
4
  "main": "dist/index.js",
5
5
  "repository": {
6
6
  "type": "git",