@freeappstore/compliance 0.1.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.
Files changed (46) hide show
  1. package/LICENSE +21 -0
  2. package/dist/checks/no-brand-overrides.d.ts +24 -0
  3. package/dist/checks/no-brand-overrides.d.ts.map +1 -0
  4. package/dist/checks/no-brand-overrides.js +164 -0
  5. package/dist/checks/no-brand-overrides.js.map +1 -0
  6. package/dist/checks/no-brand-overrides.test.d.ts +2 -0
  7. package/dist/checks/no-brand-overrides.test.d.ts.map +1 -0
  8. package/dist/checks/no-brand-overrides.test.js +102 -0
  9. package/dist/checks/no-brand-overrides.test.js.map +1 -0
  10. package/dist/checks/no-scroll.d.ts +24 -0
  11. package/dist/checks/no-scroll.d.ts.map +1 -0
  12. package/dist/checks/no-scroll.js +143 -0
  13. package/dist/checks/no-scroll.js.map +1 -0
  14. package/dist/checks/no-scroll.test.d.ts +2 -0
  15. package/dist/checks/no-scroll.test.d.ts.map +1 -0
  16. package/dist/checks/no-scroll.test.js +105 -0
  17. package/dist/checks/no-scroll.test.js.map +1 -0
  18. package/dist/checks/unsafe-vh.d.ts +24 -0
  19. package/dist/checks/unsafe-vh.d.ts.map +1 -0
  20. package/dist/checks/unsafe-vh.js +110 -0
  21. package/dist/checks/unsafe-vh.js.map +1 -0
  22. package/dist/checks/unsafe-vh.test.d.ts +2 -0
  23. package/dist/checks/unsafe-vh.test.d.ts.map +1 -0
  24. package/dist/checks/unsafe-vh.test.js +115 -0
  25. package/dist/checks/unsafe-vh.test.js.map +1 -0
  26. package/dist/checks/viewport-support.d.ts +23 -0
  27. package/dist/checks/viewport-support.d.ts.map +1 -0
  28. package/dist/checks/viewport-support.js +87 -0
  29. package/dist/checks/viewport-support.js.map +1 -0
  30. package/dist/checks/viewport-support.test.d.ts +2 -0
  31. package/dist/checks/viewport-support.test.d.ts.map +1 -0
  32. package/dist/checks/viewport-support.test.js +63 -0
  33. package/dist/checks/viewport-support.test.js.map +1 -0
  34. package/dist/index.d.ts +7 -1
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +13 -1
  37. package/dist/index.js.map +1 -1
  38. package/dist/live/index.d.ts +50 -0
  39. package/dist/live/index.d.ts.map +1 -0
  40. package/dist/live/index.js +311 -0
  41. package/dist/live/index.js.map +1 -0
  42. package/dist/live/index.test.d.ts +2 -0
  43. package/dist/live/index.test.d.ts.map +1 -0
  44. package/dist/live/index.test.js +259 -0
  45. package/dist/live/index.test.js.map +1 -0
  46. package/package.json +7 -7
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 FreeAppStore
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,24 @@
1
+ import type { CheckResult } from '../types.js';
2
+ /**
3
+ * Apps and games on the platform must look consistent with the storefront
4
+ * and with each other — brand colors, fonts, and layout rhythm come from
5
+ * the template, not the app. This check fails on the most common forms of
6
+ * brand-override drift:
7
+ *
8
+ * 1. Custom CSS variable overrides for the platform-defined tokens
9
+ * (--paper, --ink, --accent, --line, --panel, --muted). These are
10
+ * defined by the template; an app redefining them changes the brand.
11
+ * 2. Custom font-family declarations beyond the brand stack
12
+ * (Manrope, Fraunces) and the system / monospace fallbacks.
13
+ *
14
+ * What's allowed:
15
+ * - Using the variables (color: var(--accent)) — that's the whole point.
16
+ * - Hardcoded colors for non-brand purposes (highlight states, error
17
+ * red, etc.). We don't try to gate every hex literal — too noisy and
18
+ * too many false positives.
19
+ */
20
+ export declare function checkNoBrandOverrides(repoDir: string): Promise<CheckResult>;
21
+ export declare function scanContent(filename: string, content: string, opts?: {
22
+ skipVarRedefs?: boolean;
23
+ }): string[];
24
+ //# sourceMappingURL=no-brand-overrides.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-brand-overrides.d.ts","sourceRoot":"","sources":["../../src/checks/no-brand-overrides.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAwCjF;AA2DD,wBAAgB,WAAW,CACzB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,IAAI,GAAE;IAAE,aAAa,CAAC,EAAE,OAAO,CAAA;CAAO,GACrC,MAAM,EAAE,CAyCV"}
@@ -0,0 +1,164 @@
1
+ import { readFile } from 'node:fs/promises';
2
+ import { extname, relative } from 'node:path';
3
+ import { walk } from '../lib/walk.js';
4
+ /**
5
+ * Apps and games on the platform must look consistent with the storefront
6
+ * and with each other — brand colors, fonts, and layout rhythm come from
7
+ * the template, not the app. This check fails on the most common forms of
8
+ * brand-override drift:
9
+ *
10
+ * 1. Custom CSS variable overrides for the platform-defined tokens
11
+ * (--paper, --ink, --accent, --line, --panel, --muted). These are
12
+ * defined by the template; an app redefining them changes the brand.
13
+ * 2. Custom font-family declarations beyond the brand stack
14
+ * (Manrope, Fraunces) and the system / monospace fallbacks.
15
+ *
16
+ * What's allowed:
17
+ * - Using the variables (color: var(--accent)) — that's the whole point.
18
+ * - Hardcoded colors for non-brand purposes (highlight states, error
19
+ * red, etc.). We don't try to gate every hex literal — too noisy and
20
+ * too many false positives.
21
+ */
22
+ export async function checkNoBrandOverrides(repoDir) {
23
+ const issues = [];
24
+ for await (const file of walk(repoDir)) {
25
+ const ext = extname(file).toLowerCase();
26
+ if (!SCANNED_EXTS.has(ext))
27
+ continue;
28
+ const content = await readFile(file, 'utf8').catch(() => '');
29
+ if (!content)
30
+ continue;
31
+ const rel = relative(repoDir, file);
32
+ // Canonical theme file: the platform's CSS variables ARE defined here.
33
+ // Apps own this file post-scaffold (they can technically modify token
34
+ // values, and we accept the imperfection — the loud places where a
35
+ // brand override actually causes inconsistency are inline styles +
36
+ // per-component CSS, which this check still covers).
37
+ const isThemeFile = rel === 'web/src/index.css' || rel === 'web/src/main.css';
38
+ const fileIssues = scanContent(rel, content, { skipVarRedefs: isThemeFile });
39
+ issues.push(...fileIssues);
40
+ // Cap at 10 — beyond that the user has bigger problems and we don't
41
+ // want a 200-line failure report.
42
+ if (issues.length >= 10)
43
+ break;
44
+ }
45
+ if (issues.length === 0) {
46
+ return {
47
+ name: 'No brand overrides',
48
+ status: 'pass',
49
+ detail: 'apps inherit colors + fonts from the template',
50
+ };
51
+ }
52
+ return {
53
+ name: 'No brand overrides',
54
+ status: 'fail',
55
+ detail: `${issues.length} apparent override${issues.length === 1 ? '' : 's'}`,
56
+ suggestions: [
57
+ ...issues.slice(0, 5),
58
+ ...(issues.length > 5 ? [`...and ${issues.length - 5} more`] : []),
59
+ 'Use the template tokens (var(--accent), var(--ink), etc.) instead of redefining them.',
60
+ 'Brand fonts are Manrope (body) + Fraunces (display). Stick to those + system / monospace.',
61
+ ],
62
+ };
63
+ }
64
+ const SCANNED_EXTS = new Set(['.css', '.scss', '.tsx', '.ts', '.jsx', '.js', '.html']);
65
+ const PROTECTED_VARS = new Set([
66
+ '--paper',
67
+ '--ink',
68
+ '--muted',
69
+ '--accent',
70
+ '--line',
71
+ '--line-strong',
72
+ '--panel',
73
+ ]);
74
+ /**
75
+ * Whitelist of font-family declarations we accept. Anything outside this
76
+ * set — for ANY font name not in the brand stack and not a generic /
77
+ * system fallback — flags. The check is case-insensitive.
78
+ */
79
+ const ALLOWED_FONT_TOKENS = new Set([
80
+ // Brand stack
81
+ 'manrope',
82
+ 'fraunces',
83
+ // Generic/system fallbacks (CSS keywords)
84
+ 'serif',
85
+ 'sans-serif',
86
+ 'monospace',
87
+ 'system-ui',
88
+ 'ui-monospace',
89
+ 'ui-serif',
90
+ 'ui-sans-serif',
91
+ 'inherit',
92
+ 'initial',
93
+ 'unset',
94
+ 'revert',
95
+ // Common system stack names — these are aliases, not custom fonts.
96
+ '-apple-system',
97
+ 'blinkmacsystemfont',
98
+ 'segoe ui',
99
+ 'roboto',
100
+ 'helvetica',
101
+ 'helvetica neue',
102
+ 'arial',
103
+ 'sf mono',
104
+ 'sf pro',
105
+ 'menlo',
106
+ 'monaco',
107
+ 'consolas',
108
+ 'liberation mono',
109
+ 'courier',
110
+ 'courier new',
111
+ 'georgia',
112
+ 'noto sans',
113
+ 'noto color emoji',
114
+ 'apple color emoji',
115
+ 'segoe ui emoji',
116
+ 'segoe ui symbol',
117
+ ]);
118
+ export function scanContent(filename, content, opts = {}) {
119
+ const out = [];
120
+ // 1. CSS variable overrides for protected tokens.
121
+ // Match `--accent: <something>;` outside of var() invocations.
122
+ // The regex looks for "<two dashes><name>:" near the start of a line,
123
+ // which is how CSS declarations look. var(--accent) won't match because
124
+ // there's a `(` not a `:`.
125
+ if (!opts.skipVarRedefs) {
126
+ const varDeclRe = /(?:^|[\s;{,])(--[a-z-]+)\s*:/gim;
127
+ let m;
128
+ while ((m = varDeclRe.exec(content)) !== null) {
129
+ const name = m[1];
130
+ if (PROTECTED_VARS.has(name)) {
131
+ const line = lineNumberAt(content, m.index);
132
+ out.push(`${filename}:${line} redefines ${name} (template owns this token)`);
133
+ }
134
+ }
135
+ }
136
+ // 2. font-family overrides. Pull every string after `font-family:` (in
137
+ // CSS) or `fontFamily:` (in JSX/TS), parse the comma-separated list,
138
+ // and flag any quoted token not in ALLOWED_FONT_TOKENS.
139
+ const fontRe = /(?:font-family|fontFamily)\s*[:=]\s*["'`]?([^;"'`}\n]+)["'`]?/g;
140
+ let m;
141
+ while ((m = fontRe.exec(content)) !== null) {
142
+ const list = m[1];
143
+ const tokens = list
144
+ .split(',')
145
+ .map((t) => t.trim().replace(/^["']|["']$/g, '').toLowerCase())
146
+ .filter(Boolean);
147
+ for (const t of tokens) {
148
+ if (!ALLOWED_FONT_TOKENS.has(t)) {
149
+ const line = lineNumberAt(content, m.index);
150
+ out.push(`${filename}:${line} non-brand font "${t}"`);
151
+ break; // one warning per declaration is plenty
152
+ }
153
+ }
154
+ }
155
+ return out;
156
+ }
157
+ function lineNumberAt(content, index) {
158
+ let n = 1;
159
+ for (let i = 0; i < index; i++)
160
+ if (content.charCodeAt(i) === 10)
161
+ n++;
162
+ return n;
163
+ }
164
+ //# sourceMappingURL=no-brand-overrides.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-brand-overrides.js","sourceRoot":"","sources":["../../src/checks/no-brand-overrides.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE9C,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAEtC;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,OAAe;IACzD,MAAM,MAAM,GAAa,EAAE,CAAC;IAE5B,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,IAAI,CAAC,OAAO,CAAC,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AAC,GAAG,CAAC,CAAC;gBACtD,MAAM,CAAC,wCAAwC;YACjD,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,YAAY,CAAC,OAAe,EAAE,KAAa;IAClD,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE;QAAE,IAAI,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,EAAE;YAAE,CAAC,EAAE,CAAC;IACtE,OAAO,CAAC,CAAC;AACX,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=no-brand-overrides.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-brand-overrides.test.d.ts","sourceRoot":"","sources":["../../src/checks/no-brand-overrides.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,102 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { mkdtemp, mkdir, writeFile } from 'node:fs/promises';
3
+ import { tmpdir } from 'node:os';
4
+ import { join } from 'node:path';
5
+ import { checkNoBrandOverrides, scanContent } from './no-brand-overrides.js';
6
+ async function fixture(files) {
7
+ const dir = await mkdtemp(join(tmpdir(), 'fas-brand-'));
8
+ for (const [path, content] of Object.entries(files)) {
9
+ const full = join(dir, path);
10
+ await mkdir(join(full, '..'), { recursive: true });
11
+ await writeFile(full, content);
12
+ }
13
+ return dir;
14
+ }
15
+ describe('scanContent (unit)', () => {
16
+ it('flags an override of a protected CSS variable', () => {
17
+ const issues = scanContent('web/src/index.css', `
18
+ :root { --accent: hotpink; }
19
+ `);
20
+ expect(issues).toHaveLength(1);
21
+ expect(issues[0]).toMatch(/--accent/);
22
+ });
23
+ it('does NOT flag using the variable via var()', () => {
24
+ const issues = scanContent('web/src/App.tsx', `
25
+ <div style={{ color: 'var(--accent)' }} />
26
+ `);
27
+ expect(issues).toEqual([]);
28
+ });
29
+ it('does not flag a non-protected custom variable (apps can have their own)', () => {
30
+ const issues = scanContent('web/src/index.css', `
31
+ :root { --my-shadow: 0 0 4px black; }
32
+ `);
33
+ expect(issues).toEqual([]);
34
+ });
35
+ it('flags a non-brand font-family in CSS', () => {
36
+ const issues = scanContent('web/src/index.css', `
37
+ h1 { font-family: "Cormorant Garamond", serif; }
38
+ `);
39
+ expect(issues).toHaveLength(1);
40
+ expect(issues[0]).toMatch(/cormorant garamond/);
41
+ });
42
+ it('flags a non-brand font in inline JSX styles', () => {
43
+ const issues = scanContent('web/src/App.tsx', `
44
+ <h1 style={{ fontFamily: "Sora, sans-serif" }} />
45
+ `);
46
+ expect(issues).toHaveLength(1);
47
+ expect(issues[0]).toMatch(/sora/);
48
+ });
49
+ it('accepts brand fonts and system fallbacks', () => {
50
+ const issues = scanContent('web/src/index.css', `
51
+ body { font-family: "Manrope", system-ui, sans-serif; }
52
+ h1 { font-family: Fraunces, Georgia, serif; }
53
+ code { font-family: "SF Mono", Menlo, monospace; }
54
+ `);
55
+ expect(issues).toEqual([]);
56
+ });
57
+ it('reports line numbers', () => {
58
+ const issues = scanContent('web/src/index.css', `\n\n:root { --paper: red; }\n`);
59
+ expect(issues[0]).toMatch(/:3 /);
60
+ });
61
+ });
62
+ describe('checkNoBrandOverrides (integration)', () => {
63
+ it('passes when all CSS uses brand tokens', async () => {
64
+ const dir = await fixture({
65
+ 'web/src/index.css': `
66
+ :root { --my-extra: 4px; }
67
+ body { font-family: Manrope, system-ui, sans-serif; }
68
+ h1 { font-family: Fraunces, serif; color: var(--accent); }
69
+ `,
70
+ });
71
+ const r = await checkNoBrandOverrides(dir);
72
+ expect(r.status).toBe('pass');
73
+ });
74
+ it('fails when an app overrides a protected variable in a non-theme CSS file', async () => {
75
+ // web/src/index.css is the canonical theme file (exempt). Per-component
76
+ // CSS like this isn't.
77
+ const dir = await fixture({
78
+ 'web/src/components/Branding.css': `:root { --accent: deeppink; }`,
79
+ });
80
+ const r = await checkNoBrandOverrides(dir);
81
+ expect(r.status).toBe('fail');
82
+ expect(r.detail).toMatch(/override/);
83
+ expect(r.suggestions?.join(' ')).toMatch(/var\(--accent\)/);
84
+ });
85
+ it('does NOT fail when web/src/index.css legitimately defines tokens (template-owned)', async () => {
86
+ const dir = await fixture({
87
+ 'web/src/index.css': `:root { --paper: #ffffff; --ink: #1a1a1a; --accent: #2563eb; }`,
88
+ });
89
+ const r = await checkNoBrandOverrides(dir);
90
+ expect(r.status).toBe('pass');
91
+ });
92
+ it('fails when an app uses non-brand fonts', async () => {
93
+ const dir = await fixture({
94
+ 'web/src/App.tsx': `
95
+ const h1 = <h1 style={{ fontFamily: "Cormorant Garamond, serif" }} />;
96
+ `,
97
+ });
98
+ const r = await checkNoBrandOverrides(dir);
99
+ expect(r.status).toBe('fail');
100
+ });
101
+ });
102
+ //# sourceMappingURL=no-brand-overrides.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-brand-overrides.test.js","sourceRoot":"","sources":["../../src/checks/no-brand-overrides.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE7E,KAAK,UAAU,OAAO,CAAC,KAA6B;IAClD,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,YAAY,CAAC,CAAC,CAAC;IACxD,KAAK,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACpD,MAAM,IAAI,GAAG,IAAI,CA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,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC;YACxB,iCAAiC,EAAE,+BAA+B;SACnE,CAAC,CAAC;QACH,MAAM,CAAC,GAAG,MAAM,qBAAqB,CAAC,GAAG,CAAC,CAAC;QAC3C,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC9B,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QACrC,MAAM,CAAC,CAAC,CAAC,WAAW,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAC9D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mFAAmF,EAAE,KAAK,IAAI,EAAE;QACjG,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC;YACxB,mBAAmB,EAAE,gEAAgE;SACtF,CAAC,CAAC;QACH,MAAM,CAAC,GAAG,MAAM,qBAAqB,CAAC,GAAG,CAAC,CAAC;QAC3C,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAChC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,wCAAwC,EAAE,KAAK,IAAI,EAAE;QACtD,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC;YACxB,iBAAiB,EAAE;;OAElB;SACF,CAAC,CAAC;QACH,MAAM,CAAC,GAAG,MAAM,qBAAqB,CAAC,GAAG,CAAC,CAAC;QAC3C,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAChC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,24 @@
1
+ import type { CheckResult } from '../types.js';
2
+ /**
3
+ * Games on FreeGameStore must fit the viewport — no horizontal or
4
+ * vertical scroll at the document level. Static analysis catches the
5
+ * common CSS / inline-style anti-patterns:
6
+ *
7
+ * - `overflow: scroll` or `overflow: auto` on `html` or `body`.
8
+ * - `min-height: 100vh` on `html` / `body` (creates page that's at
9
+ * least viewport-tall, but content + topbar = > 100vh = scroll).
10
+ * - Missing the `100svh` / `100vh` height constraint on the layout
11
+ * wrapper (loose check — "at least one root element should hard-cap
12
+ * to viewport height").
13
+ *
14
+ * Runtime guarantees (real DOM measurement) live in the e2e Playwright
15
+ * suite; this check exists as a fast pre-publish gate so creators
16
+ * don't ship trivially-scrolling games.
17
+ *
18
+ * Apps (FreeAppStore) are not subject to this check — the apps Shell
19
+ * wraps them in a sidebar+main layout that legitimately scrolls. We
20
+ * detect "is this a game project" by looking for the @freeappstore/games
21
+ * dep, the canonical signal that the app uses GameShell.
22
+ */
23
+ export declare function checkNoScroll(repoDir: string): Promise<CheckResult>;
24
+ //# sourceMappingURL=no-scroll.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-scroll.d.ts","sourceRoot":"","sources":["../../src/checks/no-scroll.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CA6EzE"}
@@ -0,0 +1,143 @@
1
+ import { readFile } from 'node:fs/promises';
2
+ import { extname, relative } from 'node:path';
3
+ import { walk } from '../lib/walk.js';
4
+ /**
5
+ * Games on FreeGameStore must fit the viewport — no horizontal or
6
+ * vertical scroll at the document level. Static analysis catches the
7
+ * common CSS / inline-style anti-patterns:
8
+ *
9
+ * - `overflow: scroll` or `overflow: auto` on `html` or `body`.
10
+ * - `min-height: 100vh` on `html` / `body` (creates page that's at
11
+ * least viewport-tall, but content + topbar = > 100vh = scroll).
12
+ * - Missing the `100svh` / `100vh` height constraint on the layout
13
+ * wrapper (loose check — "at least one root element should hard-cap
14
+ * to viewport height").
15
+ *
16
+ * Runtime guarantees (real DOM measurement) live in the e2e Playwright
17
+ * suite; this check exists as a fast pre-publish gate so creators
18
+ * don't ship trivially-scrolling games.
19
+ *
20
+ * Apps (FreeAppStore) are not subject to this check — the apps Shell
21
+ * wraps them in a sidebar+main layout that legitimately scrolls. We
22
+ * detect "is this a game project" by looking for the @freeappstore/games
23
+ * dep, the canonical signal that the app uses GameShell.
24
+ */
25
+ export async function checkNoScroll(repoDir) {
26
+ // Skip apps — only games are subject to no-scroll.
27
+ if (!(await isGame(repoDir))) {
28
+ return {
29
+ name: 'No scroll (games only)',
30
+ status: 'pass',
31
+ detail: 'not a game project — check skipped',
32
+ };
33
+ }
34
+ const issues = [];
35
+ let sawViewportLock = false;
36
+ for await (const file of walk(repoDir)) {
37
+ const ext = extname(file).toLowerCase();
38
+ if (!SCAN_EXTS.has(ext))
39
+ continue;
40
+ const content = await readFile(file, 'utf8').catch(() => '');
41
+ if (!content)
42
+ continue;
43
+ const rel = relative(repoDir, file);
44
+ // 1. Forbidden overflow declarations on root elements.
45
+ for (const re of FORBIDDEN_OVERFLOW) {
46
+ const m = re.exec(content);
47
+ if (m) {
48
+ const line = lineNumberAt(content, m.index);
49
+ issues.push(`${rel}:${line} ${m[0]} — root scrolling not allowed in games`);
50
+ }
51
+ }
52
+ // 2. min-height on root elements (creates pages taller than viewport).
53
+ for (const re of FORBIDDEN_MIN_HEIGHT) {
54
+ const m = re.exec(content);
55
+ if (m) {
56
+ const line = lineNumberAt(content, m.index);
57
+ issues.push(`${rel}:${line} ${m[0]} — use exact viewport height (100svh) instead`);
58
+ }
59
+ }
60
+ // 3. Look for at least one viewport-lock pattern. GameShell sets
61
+ // `height: 100svh` on a fixed wrapper; we accept any 100svh / 100vh
62
+ // declaration as evidence the game considered viewport sizing.
63
+ if (VIEWPORT_LOCK.test(content))
64
+ sawViewportLock = true;
65
+ if (issues.length >= 8)
66
+ break;
67
+ }
68
+ if (issues.length > 0) {
69
+ return {
70
+ name: 'No scroll (games only)',
71
+ status: 'fail',
72
+ detail: `${issues.length} scroll-enabling pattern${issues.length === 1 ? '' : 's'}`,
73
+ suggestions: [
74
+ ...issues.slice(0, 5),
75
+ ...(issues.length > 5 ? [`...and ${issues.length - 5} more`] : []),
76
+ 'Use <GameShell> from @freeappstore/games — it locks layout to 100svh.',
77
+ 'Inside the play area, use overflow: hidden instead of overflow: auto.',
78
+ ],
79
+ };
80
+ }
81
+ if (!sawViewportLock) {
82
+ return {
83
+ name: 'No scroll (games only)',
84
+ status: 'warn',
85
+ detail: 'no 100svh/100vh viewport lock detected — game may scroll on small viewports',
86
+ suggestions: [
87
+ 'Wrap your game in <GameShell> from @freeappstore/games, or',
88
+ 'Add `height: 100svh` to your root container.',
89
+ ],
90
+ };
91
+ }
92
+ return {
93
+ name: 'No scroll (games only)',
94
+ status: 'pass',
95
+ detail: 'viewport-locked layout detected',
96
+ };
97
+ }
98
+ const SCAN_EXTS = new Set(['.css', '.scss', '.tsx', '.ts', '.jsx', '.js', '.html']);
99
+ // Match `overflow: scroll` and `overflow: auto` on html/body selectors,
100
+ // or as bare global rules in CSS. Conservative: only flags when paired
101
+ // with html/body — avoids false positives for component-scoped overflow.
102
+ //
103
+ // IMPORTANT: no `g` flag. Module-scoped regexes with `g` share lastIndex
104
+ // across parallel test runs and produce flaky matches; we only need
105
+ // first-match-per-file anyway.
106
+ const FORBIDDEN_OVERFLOW = [
107
+ /(?:^|[\s,{])(?:html|body)\s*\{[^}]*overflow\s*:\s*(?:scroll|auto)/im,
108
+ /(?:^|[\s,{])(?:html|body)\s*\{[^}]*overflow-(?:x|y)\s*:\s*(?:scroll|auto)/im,
109
+ ];
110
+ const FORBIDDEN_MIN_HEIGHT = [
111
+ /(?:^|[\s,{])(?:html|body)\s*\{[^}]*min-height\s*:\s*100vh/im,
112
+ ];
113
+ const VIEWPORT_LOCK = /(?:height|max-height)\s*:\s*100(?:s?vh)|GameShell|@freeappstore\/games/i;
114
+ async function isGame(repoDir) {
115
+ // Fast path: look for the explicit games-sdk dep in any package.json.
116
+ // Falls back to scanning JSX for GameShell import — catches cases
117
+ // where the dep is hoisted to a workspace root.
118
+ for await (const file of walk(repoDir)) {
119
+ const base = file.split('/').pop() ?? '';
120
+ if (base !== 'package.json')
121
+ continue;
122
+ const content = await readFile(file, 'utf8').catch(() => '');
123
+ if (/@freeappstore\/games/.test(content))
124
+ return true;
125
+ }
126
+ for await (const file of walk(repoDir)) {
127
+ const ext = extname(file).toLowerCase();
128
+ if (ext !== '.tsx' && ext !== '.ts')
129
+ continue;
130
+ const content = await readFile(file, 'utf8').catch(() => '');
131
+ if (/from\s+['"]@freeappstore\/games['"]/.test(content))
132
+ return true;
133
+ }
134
+ return false;
135
+ }
136
+ function lineNumberAt(content, index) {
137
+ let n = 1;
138
+ for (let i = 0; i < index; i++)
139
+ if (content.charCodeAt(i) === 10)
140
+ n++;
141
+ return n;
142
+ }
143
+ //# sourceMappingURL=no-scroll.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-scroll.js","sourceRoot":"","sources":["../../src/checks/no-scroll.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE9C,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAEtC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,OAAe;IACjD,mDAAmD;IACnD,IAAI,CAAC,CAAC,MAAM,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC;QAC7B,OAAO;YACL,IAAI,EAAE,wBAAwB;YAC9B,MAAM,EAAE,MAAM;YACd,MAAM,EAAE,oCAAoC;SAC7C,CAAC;IACJ,CAAC;IAED,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,IAAI,eAAe,GAAG,KAAK,CAAC;IAE5B,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,IAAI,CAAC,OAAO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E,IAAI,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,EAAE;YAAE,CAAC,EAAE,CAAC;IACtE,OAAO,CAAC,CAAC;AACX,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=no-scroll.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-scroll.test.d.ts","sourceRoot":"","sources":["../../src/checks/no-scroll.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,105 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { mkdtemp, mkdir, writeFile } from 'node:fs/promises';
3
+ import { tmpdir } from 'node:os';
4
+ import { join } from 'node:path';
5
+ import { checkNoScroll } from './no-scroll.js';
6
+ async function fixture(files) {
7
+ const dir = await mkdtemp(join(tmpdir(), 'fas-noscroll-'));
8
+ for (const [path, content] of Object.entries(files)) {
9
+ const full = join(dir, path);
10
+ await mkdir(join(full, '..'), { recursive: true });
11
+ await writeFile(full, content);
12
+ }
13
+ return dir;
14
+ }
15
+ const GAME_DEPS = JSON.stringify({
16
+ name: 'my-game',
17
+ dependencies: { '@freeappstore/games': '^0.1.0' },
18
+ });
19
+ describe('checkNoScroll', () => {
20
+ it('passes (skipped) when the project is not a game', async () => {
21
+ const dir = await fixture({
22
+ 'package.json': JSON.stringify({ name: 'my-app' }),
23
+ 'web/src/index.css': 'body { overflow: scroll; }',
24
+ });
25
+ const r = await checkNoScroll(dir);
26
+ expect(r.status).toBe('pass');
27
+ expect(r.detail).toMatch(/not a game/);
28
+ });
29
+ it('detects @freeappstore/games dep as the game signal', async () => {
30
+ const dir = await fixture({
31
+ 'package.json': GAME_DEPS,
32
+ 'web/src/index.css': 'body { height: 100svh; }',
33
+ 'web/src/App.tsx': 'import { GameShell } from "@freeappstore/games";',
34
+ });
35
+ const r = await checkNoScroll(dir);
36
+ // Should at least run the check, not skip.
37
+ expect(r.detail).not.toMatch(/not a game/);
38
+ });
39
+ it('fails when html/body declares overflow: scroll', async () => {
40
+ const dir = await fixture({
41
+ 'package.json': GAME_DEPS,
42
+ 'web/src/index.css': 'html { overflow: scroll; }',
43
+ });
44
+ const r = await checkNoScroll(dir);
45
+ expect(r.status).toBe('fail');
46
+ expect(r.suggestions?.join(' ')).toMatch(/GameShell/);
47
+ });
48
+ it('fails when html/body declares overflow: auto', async () => {
49
+ const dir = await fixture({
50
+ 'package.json': GAME_DEPS,
51
+ 'web/src/index.css': 'body { overflow: auto; }',
52
+ });
53
+ const r = await checkNoScroll(dir);
54
+ expect(r.status).toBe('fail');
55
+ });
56
+ it('fails on overflow-y: scroll on body', async () => {
57
+ const dir = await fixture({
58
+ 'package.json': GAME_DEPS,
59
+ 'web/src/index.css': 'body { overflow-y: scroll; padding: 0; }',
60
+ });
61
+ const r = await checkNoScroll(dir);
62
+ expect(r.status).toBe('fail');
63
+ });
64
+ it('fails on min-height: 100vh on body (creates page taller than viewport)', async () => {
65
+ const dir = await fixture({
66
+ 'package.json': GAME_DEPS,
67
+ 'web/src/index.css': 'body { min-height: 100vh; }',
68
+ });
69
+ const r = await checkNoScroll(dir);
70
+ expect(r.status).toBe('fail');
71
+ expect(r.suggestions?.join(' ')).toMatch(/100svh/);
72
+ });
73
+ it('warns when there is no viewport-lock evidence', async () => {
74
+ const dir = await fixture({
75
+ 'package.json': GAME_DEPS,
76
+ 'web/src/index.css': 'body { padding: 0; }',
77
+ 'web/src/App.tsx': 'export default function App() { return <div>game</div>; }',
78
+ });
79
+ const r = await checkNoScroll(dir);
80
+ expect(r.status).toBe('warn');
81
+ expect(r.detail).toMatch(/viewport lock/);
82
+ });
83
+ it('passes when GameShell is imported (the canonical viewport lock)', async () => {
84
+ const dir = await fixture({
85
+ 'package.json': GAME_DEPS,
86
+ 'web/src/App.tsx': `
87
+ import { GameShell, GameTopbar } from "@freeappstore/games";
88
+ export default function App() {
89
+ return <GameShell topbar={<GameTopbar score={0} />}>game</GameShell>;
90
+ }
91
+ `,
92
+ });
93
+ const r = await checkNoScroll(dir);
94
+ expect(r.status).toBe('pass');
95
+ });
96
+ it('passes when CSS has explicit 100svh height lock', async () => {
97
+ const dir = await fixture({
98
+ 'package.json': GAME_DEPS,
99
+ 'web/src/index.css': '.game-root { height: 100svh; overflow: hidden; }',
100
+ });
101
+ const r = await checkNoScroll(dir);
102
+ expect(r.status).toBe('pass');
103
+ });
104
+ });
105
+ //# sourceMappingURL=no-scroll.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-scroll.test.js","sourceRoot":"","sources":["../../src/checks/no-scroll.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,KAAK,UAAU,OAAO,CAAC,KAA6B;IAClD,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,eAAe,CAAC,CAAC,CAAC;IAC3D,KAAK,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACpD,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAC7B,MAAM,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACnD,MAAM,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACjC,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;IAC/B,IAAI,EAAE,SAAS;IAC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