@shopify/shop-minis-react 0.3.1 → 0.3.2
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/shop-minis-react/node_modules/.pnpm/simple-swizzle@0.2.2/node_modules/simple-swizzle/index.js +1 -1
- package/dist/shop-minis-react/node_modules/.pnpm/use-sync-external-store@1.5.0_react@19.1.0/node_modules/use-sync-external-store/shim/index.js +1 -1
- package/eslint/rules/prefer-sdk-hooks.cjs +9 -11
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __module as r } from "../../../../../../../_virtual/
|
|
1
|
+
import { __module as r } from "../../../../../../../_virtual/index10.js";
|
|
2
2
|
import { __require as o } from "../cjs/use-sync-external-store-shim.production.js";
|
|
3
3
|
import { __require as i } from "../cjs/use-sync-external-store-shim.development.js";
|
|
4
4
|
var e;
|
|
@@ -14,9 +14,7 @@ module.exports = {
|
|
|
14
14
|
},
|
|
15
15
|
messages: {
|
|
16
16
|
preferAsyncStorage:
|
|
17
|
-
'Use useAsyncStorage from @shopify/shop-minis-react instead of localStorage. The SDK hook provides async storage that works reliably in the Shop mini-app environment.',
|
|
18
|
-
preferSecureStorage:
|
|
19
|
-
'Use useSecureStorage from @shopify/shop-minis-react instead of localStorage for sensitive data. The SDK hook provides encrypted storage.',
|
|
17
|
+
'Use useAsyncStorage (or useSecureStorage for sensitive data) from @shopify/shop-minis-react instead of localStorage. The SDK hook provides async storage that works reliably in the Shop mini-app environment.',
|
|
20
18
|
},
|
|
21
19
|
schema: [
|
|
22
20
|
{
|
|
@@ -40,9 +38,6 @@ module.exports = {
|
|
|
40
38
|
const defaultApis = {
|
|
41
39
|
localStorage: 'useAsyncStorage',
|
|
42
40
|
sessionStorage: 'useAsyncStorage',
|
|
43
|
-
// Future additions will go here:
|
|
44
|
-
// navigator.geolocation: 'useGeolocation',
|
|
45
|
-
// window.history: 'useNavigation',
|
|
46
41
|
}
|
|
47
42
|
|
|
48
43
|
// Get user configuration or use defaults
|
|
@@ -55,7 +50,10 @@ module.exports = {
|
|
|
55
50
|
return {
|
|
56
51
|
MemberExpression(node) {
|
|
57
52
|
// Check for direct access: localStorage.getItem()
|
|
58
|
-
if (
|
|
53
|
+
if (
|
|
54
|
+
node.object.type === 'Identifier' &&
|
|
55
|
+
Object.hasOwn(apiMap, node.object.name)
|
|
56
|
+
) {
|
|
59
57
|
const apiName = node.object.name
|
|
60
58
|
const sdkHook = apiMap[apiName]
|
|
61
59
|
|
|
@@ -77,7 +75,7 @@ module.exports = {
|
|
|
77
75
|
(node.object.object.name === 'window' ||
|
|
78
76
|
node.object.object.name === 'globalThis') &&
|
|
79
77
|
node.object.property.type === 'Identifier' &&
|
|
80
|
-
apiMap
|
|
78
|
+
Object.hasOwn(apiMap, node.object.property.name)
|
|
81
79
|
) {
|
|
82
80
|
const apiName = node.object.property.name
|
|
83
81
|
const sdkHook = apiMap[apiName]
|
|
@@ -112,12 +110,12 @@ module.exports = {
|
|
|
112
110
|
}
|
|
113
111
|
|
|
114
112
|
// Check if this is a direct reference to localStorage/sessionStorage
|
|
115
|
-
if (!apiMap
|
|
113
|
+
if (!Object.hasOwn(apiMap, node.name)) {
|
|
116
114
|
return
|
|
117
115
|
}
|
|
118
116
|
|
|
119
|
-
// Skip if it's being declared
|
|
120
|
-
if (parent.type === 'VariableDeclarator' && parent.
|
|
117
|
+
// Skip if it's the variable name being declared (e.g., const localStorage = ...)
|
|
118
|
+
if (parent.type === 'VariableDeclarator' && parent.id === node) {
|
|
121
119
|
return
|
|
122
120
|
}
|
|
123
121
|
|