@usequeek/theme-check 0.2.0 → 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/rules/static.d.ts +7 -1
- package/dist/rules/static.js +30 -8
- package/package.json +1 -1
package/dist/rules/static.d.ts
CHANGED
|
@@ -10,6 +10,12 @@ export declare const demoStoreRule: Rule;
|
|
|
10
10
|
export declare const demoStoresRule: Rule;
|
|
11
11
|
export declare const demoArtRule: Rule;
|
|
12
12
|
export declare const codeQualityRule: Rule;
|
|
13
|
+
/**
|
|
14
|
+
* The first module a theme imports from Next.js (`next`, `next/link`, …), or null.
|
|
15
|
+
* Static, side-effect and dynamic imports and `require` all count; the kit may
|
|
16
|
+
* import Next, a theme may not.
|
|
17
|
+
*/
|
|
18
|
+
export declare function frameworkImport(source: string): string | null;
|
|
13
19
|
export declare const sdkBoundaryRule: Rule;
|
|
14
20
|
/**
|
|
15
21
|
* The ThemeModule shape (Layout, Header, Footer, blocks, getBlock, pages…) is
|
|
@@ -51,7 +57,7 @@ export declare function vendorFactFallbacks(source: string): Array<{
|
|
|
51
57
|
}>;
|
|
52
58
|
export declare const vendorFactsRule: Rule;
|
|
53
59
|
export declare const fontsSelfHostedRule: Rule;
|
|
54
|
-
/** The starter's
|
|
60
|
+
/** The starter's labelled placeholder images ("Your banner photo", "Category photo", "Product photo") under theme-assets/_bare. */
|
|
55
61
|
export declare const STARTER_PLACEHOLDER_IMAGES: readonly string[];
|
|
56
62
|
export declare const placeholderContentRule: Rule;
|
|
57
63
|
export declare const STATIC_RULES: Rule[];
|
package/dist/rules/static.js
CHANGED
|
@@ -269,9 +269,18 @@ export const codeQualityRule = {
|
|
|
269
269
|
return findings;
|
|
270
270
|
},
|
|
271
271
|
};
|
|
272
|
+
/**
|
|
273
|
+
* The first module a theme imports from Next.js (`next`, `next/link`, …), or null.
|
|
274
|
+
* Static, side-effect and dynamic imports and `require` all count; the kit may
|
|
275
|
+
* import Next, a theme may not.
|
|
276
|
+
*/
|
|
277
|
+
export function frameworkImport(source) {
|
|
278
|
+
const match = source.match(/(?:\bfrom\s*|\bimport\s*\(?\s*|\brequire\s*\(\s*)['"](next(?:\/[\w./-]+)?)['"]/);
|
|
279
|
+
return match ? match[1] : null;
|
|
280
|
+
}
|
|
272
281
|
export const sdkBoundaryRule = {
|
|
273
282
|
id: 'theme/core-boundary',
|
|
274
|
-
summary: 'No SDK imports, no direct API calls, no store mutations',
|
|
283
|
+
summary: 'No SDK or framework imports, no direct API calls, no store mutations',
|
|
275
284
|
kind: 'static',
|
|
276
285
|
run(context) {
|
|
277
286
|
const findings = [];
|
|
@@ -286,6 +295,15 @@ export const sdkBoundaryRule = {
|
|
|
286
295
|
docs: `${context.env.docs}#what-themes-must-not-do`,
|
|
287
296
|
}));
|
|
288
297
|
}
|
|
298
|
+
const framework = frameworkImport(source);
|
|
299
|
+
if (framework) {
|
|
300
|
+
findings.push(finding(context, 'theme/core-boundary', 'reject', {
|
|
301
|
+
where,
|
|
302
|
+
found: `imports the storefront's framework directly ('${framework}')`,
|
|
303
|
+
fix: "Import Link, useRouter and usePathname from '@usequeek/theme-kit/navigation'. Which framework runs the storefront is Queek's to change; a theme that imports it would break when it does.",
|
|
304
|
+
docs: `${context.env.docs}#what-themes-must-not-do`,
|
|
305
|
+
}));
|
|
306
|
+
}
|
|
289
307
|
if (/\b(?:fetch|axios)\s*\(\s*['"`]https?:/.test(source)) {
|
|
290
308
|
findings.push(finding(context, 'theme/core-boundary', 'reject', {
|
|
291
309
|
where,
|
|
@@ -1171,14 +1189,18 @@ export const fontsSelfHostedRule = {
|
|
|
1171
1189
|
return findings;
|
|
1172
1190
|
},
|
|
1173
1191
|
};
|
|
1174
|
-
/** The starter's
|
|
1192
|
+
/** The starter's labelled placeholder images ("Your banner photo", "Category photo", "Product photo") under theme-assets/_bare. */
|
|
1175
1193
|
export const STARTER_PLACEHOLDER_IMAGES = [
|
|
1176
|
-
'https://media.usequeek.com/theme-assets/_bare/
|
|
1177
|
-
'https://media.usequeek.com/theme-assets/_bare/
|
|
1178
|
-
'https://media.usequeek.com/theme-assets/_bare/
|
|
1179
|
-
'https://media.usequeek.com/theme-assets/_bare/
|
|
1180
|
-
'https://media.usequeek.com/theme-assets/_bare/
|
|
1181
|
-
'https://media.usequeek.com/theme-assets/_bare/
|
|
1194
|
+
'https://media.usequeek.com/theme-assets/_bare/0c8749c67b449815.jpg',
|
|
1195
|
+
'https://media.usequeek.com/theme-assets/_bare/23d5f6928502dcca.jpg',
|
|
1196
|
+
'https://media.usequeek.com/theme-assets/_bare/430bb331b314f613.jpg',
|
|
1197
|
+
'https://media.usequeek.com/theme-assets/_bare/43b1e392b8039306.jpg',
|
|
1198
|
+
'https://media.usequeek.com/theme-assets/_bare/5a75479e668914bb.jpg',
|
|
1199
|
+
'https://media.usequeek.com/theme-assets/_bare/8847c6c8472cc629.jpg',
|
|
1200
|
+
'https://media.usequeek.com/theme-assets/_bare/ce7b1219776e7a98.jpg',
|
|
1201
|
+
'https://media.usequeek.com/theme-assets/_bare/dcdae58f874939a9.jpg',
|
|
1202
|
+
'https://media.usequeek.com/theme-assets/_bare/e37b930c35976c89.jpg',
|
|
1203
|
+
'https://media.usequeek.com/theme-assets/_bare/e8543451de24e310.jpg',
|
|
1182
1204
|
];
|
|
1183
1205
|
export const placeholderContentRule = {
|
|
1184
1206
|
id: 'theme/placeholder-content',
|