@usequeek/theme-check 0.2.0 → 0.3.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.
- package/dist/rules/static.d.ts +6 -0
- package/dist/rules/static.js +19 -1
- 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
|
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,
|