@shopify/shop-minis-react 0.4.12 → 0.4.13
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/_virtual/index4.js +2 -2
- package/dist/_virtual/index5.js +3 -2
- package/dist/_virtual/index5.js.map +1 -1
- package/dist/_virtual/index6.js +2 -3
- package/dist/_virtual/index6.js.map +1 -1
- package/dist/shop-minis-react/node_modules/.pnpm/@videojs_xhr@2.7.0/node_modules/@videojs/xhr/lib/index.js +1 -1
- package/dist/shop-minis-react/node_modules/.pnpm/mpd-parser@1.3.1/node_modules/mpd-parser/dist/mpd-parser.es.js +1 -1
- package/dist/shop-minis-react/node_modules/.pnpm/querystringify@2.2.0/node_modules/querystringify/index.js +1 -1
- package/eslint/config.cjs +2 -0
- package/eslint/index.cjs +4 -0
- package/eslint/rules/asset-path-patterns.cjs +30 -0
- package/eslint/rules/no-dynamic-asset-paths.cjs +78 -0
- package/eslint/rules/no-hardcoded-asset-paths.cjs +124 -0
- package/package.json +1 -1
package/dist/_virtual/index4.js
CHANGED
package/dist/_virtual/index5.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index5.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index5.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|
package/dist/_virtual/index6.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index6.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index6.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __module as q } from "../../../../../../../../_virtual/
|
|
1
|
+
import { __module as q } from "../../../../../../../../_virtual/index4.js";
|
|
2
2
|
import { __require as F } from "../../../../../global@4.4.0/node_modules/global/window.js";
|
|
3
3
|
import { __require as N } from "../../../../../@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/extends.js";
|
|
4
4
|
import { __require as J } from "../../../../../is-function@1.0.2/node_modules/is-function/index.js";
|
|
@@ -2,7 +2,7 @@ import L from "../../../../@videojs_vhs-utils@4.1.1/node_modules/@videojs/vhs-ut
|
|
|
2
2
|
import T from "../../../../../../../_virtual/window.js";
|
|
3
3
|
import { forEachMediaGroup as Z } from "../../../../@videojs_vhs-utils@4.1.1/node_modules/@videojs/vhs-utils/es/media-groups.js";
|
|
4
4
|
import J from "../../../../@videojs_vhs-utils@4.1.1/node_modules/@videojs/vhs-utils/es/decode-b64-to-uint8-array.js";
|
|
5
|
-
import { l as Q } from "../../../../../../../_virtual/
|
|
5
|
+
import { l as Q } from "../../../../../../../_virtual/index5.js";
|
|
6
6
|
/*! @name mpd-parser @version 1.3.1 @license Apache-2.0 */
|
|
7
7
|
const w = (e) => !!e && typeof e == "object", E = (...e) => e.reduce((n, t) => (typeof t != "object" || Object.keys(t).forEach((r) => {
|
|
8
8
|
Array.isArray(n[r]) && Array.isArray(t[r]) ? n[r] = n[r].concat(t[r]) : w(n[r]) && w(t[r]) ? n[r] = E(n[r], t[r]) : n[r] = t[r];
|
package/eslint/config.cjs
CHANGED
|
@@ -38,7 +38,9 @@ module.exports = {
|
|
|
38
38
|
'react/no-danger': 'error',
|
|
39
39
|
|
|
40
40
|
// Shop Minis custom rules
|
|
41
|
+
'shop-minis/no-dynamic-asset-paths': 'warn',
|
|
41
42
|
'shop-minis/no-env-without-fallback': 'error',
|
|
43
|
+
'shop-minis/no-hardcoded-asset-paths': 'error',
|
|
42
44
|
'shop-minis/no-internal-imports': 'error',
|
|
43
45
|
'shop-minis/no-secrets': ['error'],
|
|
44
46
|
'shop-minis/prefer-sdk-components': 'warn',
|
package/eslint/index.cjs
CHANGED
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
* @fileoverview Custom ESLint rules for Shop Minis React SDK
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
const noDynamicAssetPaths = require('./rules/no-dynamic-asset-paths.cjs')
|
|
7
8
|
const noEnvWithoutFallback = require('./rules/no-env-without-fallback.cjs')
|
|
9
|
+
const noHardcodedAssetPaths = require('./rules/no-hardcoded-asset-paths.cjs')
|
|
8
10
|
const noInternalImports = require('./rules/no-internal-imports.cjs')
|
|
9
11
|
const noSecrets = require('./rules/no-secrets.cjs')
|
|
10
12
|
const preferSdkComponents = require('./rules/prefer-sdk-components.cjs')
|
|
@@ -13,7 +15,9 @@ const validateManifest = require('./rules/validate-manifest.cjs')
|
|
|
13
15
|
|
|
14
16
|
module.exports = {
|
|
15
17
|
rules: {
|
|
18
|
+
'no-dynamic-asset-paths': noDynamicAssetPaths,
|
|
16
19
|
'no-env-without-fallback': noEnvWithoutFallback,
|
|
20
|
+
'no-hardcoded-asset-paths': noHardcodedAssetPaths,
|
|
17
21
|
'no-internal-imports': noInternalImports,
|
|
18
22
|
'no-secrets': noSecrets,
|
|
19
23
|
'prefer-sdk-components': preferSdkComponents,
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared patterns for asset path detection rules
|
|
3
|
+
* @fileoverview Regex patterns for detecting asset file extensions and path types
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// Asset file extensions to detect
|
|
7
|
+
const ASSET_EXTENSIONS = /\.(png|jpe?g|gif|svg|webp|ico|bmp|avif)$/i
|
|
8
|
+
|
|
9
|
+
// Patterns that indicate a local path (not a remote URL)
|
|
10
|
+
const LOCAL_PATH_PATTERNS = [
|
|
11
|
+
/^\.?\//, // Starts with / or ./
|
|
12
|
+
/^\.\.\//, // Starts with ../
|
|
13
|
+
/\/src\//i, // Contains /src/
|
|
14
|
+
/\/assets\//i, // Contains /assets/
|
|
15
|
+
/\/images?\//i, // Contains /image/ or /images/
|
|
16
|
+
/\/public\//i, // Contains /public/
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
// Patterns that indicate a remote URL or data URL (should be allowed)
|
|
20
|
+
const REMOTE_PATTERNS = [
|
|
21
|
+
/^https?:\/\//i, // http:// or https://
|
|
22
|
+
/^data:/i, // data: URLs
|
|
23
|
+
/^blob:/i, // blob: URLs
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
module.exports = {
|
|
27
|
+
ASSET_EXTENSIONS,
|
|
28
|
+
LOCAL_PATH_PATTERNS,
|
|
29
|
+
REMOTE_PATTERNS,
|
|
30
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ESLint rule to warn about dynamic asset paths in template literals
|
|
3
|
+
* @fileoverview Warns about template literals that may construct asset paths dynamically
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const {
|
|
7
|
+
ASSET_EXTENSIONS,
|
|
8
|
+
LOCAL_PATH_PATTERNS,
|
|
9
|
+
REMOTE_PATTERNS,
|
|
10
|
+
// eslint-disable-next-line import/extensions
|
|
11
|
+
} = require('./asset-path-patterns.cjs')
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Check if a template literal might contain an asset path but we can't be certain
|
|
15
|
+
* Returns true only for UNCERTAIN cases (ends with asset extension but doesn't
|
|
16
|
+
* start with a known local path pattern). Definite cases are handled by
|
|
17
|
+
* no-hardcoded-asset-paths rule.
|
|
18
|
+
* @param {object} node - The TemplateLiteral AST node
|
|
19
|
+
* @returns {boolean}
|
|
20
|
+
*/
|
|
21
|
+
function isUncertainAssetTemplateLiteral(node) {
|
|
22
|
+
const quasis = node.quasis
|
|
23
|
+
if (quasis.length === 0) return false
|
|
24
|
+
|
|
25
|
+
// Get the first static part to check if it starts with a local path
|
|
26
|
+
const firstPart = quasis[0].value.raw || quasis[0].value.cooked || ''
|
|
27
|
+
|
|
28
|
+
// Get the last static part to check if it ends with an asset extension
|
|
29
|
+
const lastPart =
|
|
30
|
+
quasis[quasis.length - 1].value.raw ||
|
|
31
|
+
quasis[quasis.length - 1].value.cooked ||
|
|
32
|
+
''
|
|
33
|
+
|
|
34
|
+
// Must end with an asset extension
|
|
35
|
+
if (!ASSET_EXTENSIONS.test(lastPart)) return false
|
|
36
|
+
|
|
37
|
+
// Check if it starts with a remote URL (only need to check first static part)
|
|
38
|
+
if (REMOTE_PATTERNS.some(pattern => pattern.test(firstPart))) return false
|
|
39
|
+
|
|
40
|
+
// If it starts with a local path pattern, it's a DEFINITE error (handled by other rule)
|
|
41
|
+
// We only want to flag UNCERTAIN cases here
|
|
42
|
+
if (LOCAL_PATH_PATTERNS.some(pattern => pattern.test(firstPart))) return false
|
|
43
|
+
|
|
44
|
+
// Ends with asset extension but doesn't start with known local path = uncertain
|
|
45
|
+
return true
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
module.exports = {
|
|
49
|
+
meta: {
|
|
50
|
+
type: 'suggestion',
|
|
51
|
+
docs: {
|
|
52
|
+
description:
|
|
53
|
+
'Warn about template literals that may construct asset paths dynamically',
|
|
54
|
+
category: 'Best Practices',
|
|
55
|
+
recommended: true,
|
|
56
|
+
url: 'https://vite.dev/guide/assets',
|
|
57
|
+
},
|
|
58
|
+
messages: {
|
|
59
|
+
noDynamicAssetPath:
|
|
60
|
+
'Template literal may contain a hardcoded asset path that will not work in production. Import assets instead of constructing paths dynamically. See: https://vite.dev/guide/assets',
|
|
61
|
+
},
|
|
62
|
+
schema: [],
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
create(context) {
|
|
66
|
+
return {
|
|
67
|
+
TemplateLiteral(node) {
|
|
68
|
+
// Only flag uncertain cases (definite cases handled by no-hardcoded-asset-paths)
|
|
69
|
+
if (isUncertainAssetTemplateLiteral(node)) {
|
|
70
|
+
context.report({
|
|
71
|
+
node,
|
|
72
|
+
messageId: 'noDynamicAssetPath',
|
|
73
|
+
})
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ESLint rule to detect hardcoded local asset paths that won't work in production
|
|
3
|
+
* @fileoverview Prevents using un-imported hardcoded asset paths that work in Vite dev but fail in production
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const {
|
|
7
|
+
ASSET_EXTENSIONS,
|
|
8
|
+
LOCAL_PATH_PATTERNS,
|
|
9
|
+
REMOTE_PATTERNS,
|
|
10
|
+
// eslint-disable-next-line import/extensions
|
|
11
|
+
} = require('./asset-path-patterns.cjs')
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Check if a string looks like a local asset path
|
|
15
|
+
* @param {string} value - The string to check
|
|
16
|
+
* @returns {boolean}
|
|
17
|
+
*/
|
|
18
|
+
function isLocalAssetPath(value) {
|
|
19
|
+
if (typeof value !== 'string') return false
|
|
20
|
+
|
|
21
|
+
// Must have an asset extension
|
|
22
|
+
if (!ASSET_EXTENSIONS.test(value)) return false
|
|
23
|
+
|
|
24
|
+
// Skip remote URLs and data URLs
|
|
25
|
+
if (REMOTE_PATTERNS.some(pattern => pattern.test(value))) return false
|
|
26
|
+
|
|
27
|
+
// Check if it looks like a local path
|
|
28
|
+
return LOCAL_PATH_PATTERNS.some(pattern => pattern.test(value))
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Check if a template literal is definitely a local asset path
|
|
33
|
+
* Returns true only if we can determine with certainty it's a local path
|
|
34
|
+
* (starts with a local path pattern AND ends with an asset extension)
|
|
35
|
+
* @param {object} node - The TemplateLiteral AST node
|
|
36
|
+
* @returns {boolean}
|
|
37
|
+
*/
|
|
38
|
+
function isLocalAssetTemplateLiteral(node) {
|
|
39
|
+
const quasis = node.quasis
|
|
40
|
+
if (quasis.length === 0) return false
|
|
41
|
+
|
|
42
|
+
// Get the first static part to check if it starts with a local path
|
|
43
|
+
const firstPart = quasis[0].value.raw || quasis[0].value.cooked || ''
|
|
44
|
+
|
|
45
|
+
// Get the last static part to check if it ends with an asset extension
|
|
46
|
+
const lastPart =
|
|
47
|
+
quasis[quasis.length - 1].value.raw ||
|
|
48
|
+
quasis[quasis.length - 1].value.cooked ||
|
|
49
|
+
''
|
|
50
|
+
|
|
51
|
+
// Must end with an asset extension
|
|
52
|
+
if (!ASSET_EXTENSIONS.test(lastPart)) return false
|
|
53
|
+
|
|
54
|
+
// Check if it starts with a remote URL (only need to check first static part)
|
|
55
|
+
if (REMOTE_PATTERNS.some(pattern => pattern.test(firstPart))) return false
|
|
56
|
+
|
|
57
|
+
// Must start with a local path pattern (this makes it a definite error)
|
|
58
|
+
return LOCAL_PATH_PATTERNS.some(pattern => pattern.test(firstPart))
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
module.exports = {
|
|
62
|
+
meta: {
|
|
63
|
+
type: 'problem',
|
|
64
|
+
docs: {
|
|
65
|
+
description:
|
|
66
|
+
'Disallow hardcoded local asset paths that work in dev but fail in production',
|
|
67
|
+
category: 'Possible Errors',
|
|
68
|
+
recommended: true,
|
|
69
|
+
url: 'https://vite.dev/guide/assets',
|
|
70
|
+
},
|
|
71
|
+
messages: {
|
|
72
|
+
noHardcodedAssetPath:
|
|
73
|
+
'Hardcoded asset path "{{path}}" will not work in production. Import the asset instead: `import asset from "{{path}}"` then use the imported variable. See: https://vite.dev/guide/assets',
|
|
74
|
+
noHardcodedAssetPathTemplate:
|
|
75
|
+
'Template literal contains a hardcoded local asset path that will not work in production. Import assets instead of constructing paths. See: https://vite.dev/guide/assets',
|
|
76
|
+
},
|
|
77
|
+
schema: [],
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
create(context) {
|
|
81
|
+
return {
|
|
82
|
+
Literal(node) {
|
|
83
|
+
// Only check string literals
|
|
84
|
+
if (typeof node.value !== 'string') return
|
|
85
|
+
|
|
86
|
+
// Skip import/export declarations - those are the CORRECT way to use assets
|
|
87
|
+
const parent = node.parent
|
|
88
|
+
if (
|
|
89
|
+
parent &&
|
|
90
|
+
(parent.type === 'ImportDeclaration' ||
|
|
91
|
+
parent.type === 'ExportNamedDeclaration' ||
|
|
92
|
+
parent.type === 'ExportAllDeclaration' ||
|
|
93
|
+
(parent.type === 'CallExpression' &&
|
|
94
|
+
parent.callee &&
|
|
95
|
+
(parent.callee.name === 'require' ||
|
|
96
|
+
parent.callee.type === 'Import')))
|
|
97
|
+
) {
|
|
98
|
+
return
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (isLocalAssetPath(node.value)) {
|
|
102
|
+
context.report({
|
|
103
|
+
node,
|
|
104
|
+
messageId: 'noHardcodedAssetPath',
|
|
105
|
+
data: {
|
|
106
|
+
path: node.value,
|
|
107
|
+
},
|
|
108
|
+
})
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
|
|
112
|
+
TemplateLiteral(node) {
|
|
113
|
+
// Only flag template literals that are DEFINITELY local asset paths
|
|
114
|
+
// (start with local path pattern AND end with asset extension)
|
|
115
|
+
if (isLocalAssetTemplateLiteral(node)) {
|
|
116
|
+
context.report({
|
|
117
|
+
node,
|
|
118
|
+
messageId: 'noHardcodedAssetPathTemplate',
|
|
119
|
+
})
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
}
|