@shopify/shop-minis-react 0.9.0 → 0.10.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.
@@ -122,10 +122,6 @@ module.exports = {
122
122
  messages: {
123
123
  missingScope:
124
124
  '{{source}} requires scope "{{scope}}" in src/manifest.json. Add "{{scope}}" to the "scopes" array.',
125
- missingScopeProductCard:
126
- 'Component "ProductCard" requires scope "{{scope}}" in src/manifest.json. Add "{{scope}}" to the "scopes" array or set favoriteButtonDisabled to true on all ProductCard instances.',
127
- missingScopeProductLink:
128
- 'Component "ProductLink" requires scope "{{scope}}" in src/manifest.json. Add "{{scope}}" to the "scopes" array or set hideFavoriteAction to true (or provide a customAction) on all ProductLink instances.',
129
125
  missingPermission:
130
126
  '{{reason}} requires permission "{{permission}}" in src/manifest.json. Add "{{permission}}" to the "permissions" array.',
131
127
  missingTrustedDomain:
@@ -149,9 +145,6 @@ module.exports = {
149
145
  const requiredPermissions = new Set()
150
146
  const requiredDomains = new Set()
151
147
  const fixedIssues = new Set()
152
- // Track how components are actually used (e.g., with specific props)
153
- const componentUsagePatterns = new Map()
154
-
155
148
  // Check module-level cache first to avoid repeated file I/O
156
149
  if (manifestPathCache && fs.existsSync(manifestPathCache)) {
157
150
  // Check if manifest.json has been modified (for IDE integration)
@@ -465,78 +458,6 @@ module.exports = {
465
458
  }
466
459
  },
467
460
 
468
- // Track ProductCard and ProductLink usage with disabled favorite functionality
469
- JSXElement(node) {
470
- const elementName = node.openingElement.name.name
471
-
472
- // Handle ProductCard with favoriteButtonDisabled prop
473
- if (elementName === 'ProductCard') {
474
- // Check if favoriteButtonDisabled prop is present and true
475
- const favoriteDisabledProp = node.openingElement.attributes.find(
476
- attr =>
477
- attr.type === 'JSXAttribute' &&
478
- attr.name?.name === 'favoriteButtonDisabled'
479
- )
480
-
481
- const isDisabled =
482
- favoriteDisabledProp &&
483
- // Shorthand syntax: <ProductCard favoriteButtonDisabled />
484
- (favoriteDisabledProp.value === null ||
485
- // Explicit true: <ProductCard favoriteButtonDisabled={true} />
486
- (favoriteDisabledProp.value?.type === 'JSXExpressionContainer' &&
487
- favoriteDisabledProp.value?.expression?.type === 'Literal' &&
488
- favoriteDisabledProp.value?.expression?.value === true))
489
-
490
- // Track usage pattern
491
- const componentPath = 'commerce/product-card'
492
- if (!componentUsagePatterns.has(componentPath)) {
493
- componentUsagePatterns.set(componentPath, {
494
- allDisabled: true,
495
- hasUsage: true,
496
- })
497
- }
498
- const pattern = componentUsagePatterns.get(componentPath)
499
- pattern.allDisabled = pattern.allDisabled && isDisabled
500
- }
501
-
502
- // Handle ProductLink with hideFavoriteAction or customAction props
503
- if (elementName === 'ProductLink') {
504
- // Check if hideFavoriteAction prop is present and true
505
- const hideFavoriteProp = node.openingElement.attributes.find(
506
- attr =>
507
- attr.type === 'JSXAttribute' &&
508
- attr.name?.name === 'hideFavoriteAction'
509
- )
510
-
511
- // Check if customAction prop is present (replaces favorite action)
512
- const customActionProp = node.openingElement.attributes.find(
513
- attr =>
514
- attr.type === 'JSXAttribute' && attr.name?.name === 'customAction'
515
- )
516
-
517
- const isFavoriteDisabled =
518
- // hideFavoriteAction={true} or shorthand
519
- (hideFavoriteProp &&
520
- (hideFavoriteProp.value === null || // shorthand
521
- (hideFavoriteProp.value?.type === 'JSXExpressionContainer' &&
522
- hideFavoriteProp.value?.expression?.type === 'Literal' &&
523
- hideFavoriteProp.value?.expression?.value === true))) ||
524
- // customAction is provided (any truthy value replaces favorites)
525
- customActionProp !== undefined
526
-
527
- // Track usage pattern
528
- const componentPath = 'commerce/product-link'
529
- if (!componentUsagePatterns.has(componentPath)) {
530
- componentUsagePatterns.set(componentPath, {
531
- allDisabled: true,
532
- hasUsage: true,
533
- })
534
- }
535
- const pattern = componentUsagePatterns.get(componentPath)
536
- pattern.allDisabled = pattern.allDisabled && isFavoriteDisabled
537
- }
538
- },
539
-
540
461
  // Check JSX attributes for external URLs
541
462
  JSXAttribute(node) {
542
463
  if (!node.value || node.value.type !== 'Literal') {
@@ -669,18 +590,6 @@ module.exports = {
669
590
  // Check scopes for components
670
591
  usedComponents.forEach(
671
592
  ({path: componentPath, name: componentName, node}) => {
672
- // Special handling for components with conditional favorite functionality
673
- if (
674
- componentPath === 'commerce/product-card' ||
675
- componentPath === 'commerce/product-link'
676
- ) {
677
- const usagePattern = componentUsagePatterns.get(componentPath)
678
- // Skip scope requirement if all usages have favorites disabled
679
- if (usagePattern?.hasUsage && usagePattern?.allDisabled) {
680
- return // No scope required when favorite functionality is disabled
681
- }
682
- }
683
-
684
593
  const componentData = componentScopesMap[componentPath]
685
594
  if (
686
595
  !componentData ||
@@ -789,13 +698,7 @@ module.exports = {
789
698
  const sourceName = issue.hookName || issue.componentName
790
699
  const sourceType = issue.hookName ? 'Hook' : 'Component'
791
700
 
792
- // Use custom message for ProductCard and ProductLink
793
- let messageId = 'missingScope'
794
- if (issue.componentName === 'ProductCard') {
795
- messageId = 'missingScopeProductCard'
796
- } else if (issue.componentName === 'ProductLink') {
797
- messageId = 'missingScopeProductLink'
798
- }
701
+ const messageId = 'missingScope'
799
702
 
800
703
  context.report({
801
704
  loc: {line: 1, column: 0},
@@ -1,18 +1 @@
1
- {
2
- "commerce/product-card": {
3
- "scopes": [
4
- "product_list:write"
5
- ],
6
- "hooks": [
7
- "useSavedProductsActions"
8
- ]
9
- },
10
- "commerce/product-link": {
11
- "scopes": [
12
- "product_list:write"
13
- ],
14
- "hooks": [
15
- "useSavedProductsActions"
16
- ]
17
- }
18
- }
1
+ {}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@shopify/shop-minis-react",
3
3
  "license": "SEE LICENSE IN LICENSE.txt",
4
- "version": "0.9.0",
4
+ "version": "0.10.0",
5
5
  "sideEffects": false,
6
6
  "type": "module",
7
7
  "engines": {