next-workers-kit 0.0.0-stage → 1.0.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 (49) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +138 -2
  3. package/dist/cli.d.ts +2 -0
  4. package/dist/cli.js +23 -0
  5. package/dist/eslint.d.ts +16 -0
  6. package/dist/eslint.js +237 -0
  7. package/dist/hooks/format.d.ts +1 -0
  8. package/dist/hooks/format.js +26 -0
  9. package/dist/hooks/typecheck.d.ts +1 -0
  10. package/dist/hooks/typecheck.js +24 -0
  11. package/dist/lib/doctor.d.ts +2 -0
  12. package/dist/lib/doctor.js +271 -0
  13. package/dist/lib/files.d.ts +2 -0
  14. package/dist/lib/files.js +28 -0
  15. package/dist/lib/jsonc.d.ts +1 -0
  16. package/dist/lib/jsonc.js +31 -0
  17. package/dist/lib/sync.d.ts +6 -0
  18. package/dist/lib/sync.js +52 -0
  19. package/dist/meta.d.ts +4 -0
  20. package/dist/meta.js +9 -0
  21. package/dist/next.d.ts +4 -0
  22. package/dist/next.js +15 -0
  23. package/dist/prettier.d.ts +3 -0
  24. package/dist/prettier.js +7 -0
  25. package/dist/rules/class-rule.d.ts +2 -0
  26. package/dist/rules/class-rule.js +29 -0
  27. package/dist/rules/feature-layout.d.ts +2 -0
  28. package/dist/rules/feature-layout.js +16 -0
  29. package/dist/rules/spacing.d.ts +1 -0
  30. package/dist/rules/spacing.js +23 -0
  31. package/dist/rules/typography.d.ts +5 -0
  32. package/dist/rules/typography.js +7 -0
  33. package/package.json +81 -4
  34. package/templates/init/claude-settings.json +25 -0
  35. package/templates/init/eslint.config.mjs +4 -0
  36. package/templates/init/gitignore +30 -0
  37. package/templates/init/knip.json +7 -0
  38. package/templates/init/mcp.json +8 -0
  39. package/templates/init/prettier.config.mjs +5 -0
  40. package/templates/init/prettierignore +4 -0
  41. package/templates/init/tsconfig.json +14 -0
  42. package/templates/synced/CLAUDE.md +1 -0
  43. package/templates/synced/dependabot.yml +19 -0
  44. package/templates/synced/editorconfig +12 -0
  45. package/templates/synced/gitattributes +1 -0
  46. package/templates/synced/lefthook.yml +9 -0
  47. package/templates/synced/npmrc +1 -0
  48. package/templates/synced/nvmrc +1 -0
  49. package/tsconfig.base.json +28 -0
@@ -0,0 +1,271 @@
1
+ import { existsSync, readdirSync, readFileSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { command, configKey, packageName } from "../meta.js";
4
+ import { synced } from "./files.js";
5
+ import { parseJsonc } from "./jsonc.js";
6
+ export const scripts = {
7
+ dev: "next dev",
8
+ build: "next build",
9
+ typecheck: "next typegen && tsc --noEmit",
10
+ lint: "next typegen && eslint --max-warnings=0",
11
+ format: "prettier --write .",
12
+ fix: "eslint --fix && prettier --write .",
13
+ knip: "knip",
14
+ check: `${command} doctor && prettier --check . && npm run lint && npm run typecheck && knip`,
15
+ "cf-typegen": "wrangler types --env-interface CloudflareEnv cloudflare-env.d.ts",
16
+ preview: "opennextjs-cloudflare build && opennextjs-cloudflare preview",
17
+ deploy: "opennextjs-cloudflare build && opennextjs-cloudflare deploy",
18
+ upload: "opennextjs-cloudflare build && opennextjs-cloudflare upload",
19
+ prepare: "lefthook install",
20
+ };
21
+ const gitignore = [
22
+ "/node_modules",
23
+ "/.next/",
24
+ "/out/",
25
+ "/build",
26
+ "/coverage",
27
+ ".DS_Store",
28
+ "*.pem",
29
+ "npm-debug.log*",
30
+ ".env*",
31
+ ".dev.vars*",
32
+ "!.dev.vars.example",
33
+ "/.open-next/",
34
+ "/.wrangler/",
35
+ "next-env.d.ts",
36
+ "*.tsbuildinfo",
37
+ ".claude/settings.local.json",
38
+ "CLAUDE.local.md",
39
+ ];
40
+ const prettierignore = [
41
+ "AGENTS.md",
42
+ "src/components/ui",
43
+ "cloudflare-env.d.ts",
44
+ ];
45
+ const required = [
46
+ "AGENTS.md",
47
+ "README.md",
48
+ "cloudflare-env.d.ts",
49
+ "open-next.config.ts",
50
+ "next.config.ts",
51
+ "wrangler.jsonc",
52
+ ];
53
+ function normalize(text) {
54
+ return text.replace(/\r\n/g, "\n");
55
+ }
56
+ // Ignore-file entries, compared without leading or trailing slashes so
57
+ // "dir", "/dir" and "dir/" match.
58
+ function ignoreEntry(line) {
59
+ return line.trim().replace(/^\/|\/$/g, "");
60
+ }
61
+ function lines(text) {
62
+ return new Set(normalize(text).split("\n").map(ignoreEntry));
63
+ }
64
+ export function doctor(root) {
65
+ const problems = [];
66
+ const report = (file, message) => problems.push(`${file}: ${message}`);
67
+ const read = (file) => {
68
+ const path = join(root, file);
69
+ return existsSync(path) ? readFileSync(path, "utf8") : undefined;
70
+ };
71
+ const json = (file) => {
72
+ const text = read(file);
73
+ if (text === undefined) {
74
+ report(file, "missing");
75
+ return undefined;
76
+ }
77
+ try {
78
+ return parseJsonc(text);
79
+ }
80
+ catch {
81
+ report(file, "is not valid JSON");
82
+ return undefined;
83
+ }
84
+ };
85
+ for (const file of required) {
86
+ if (read(file) === undefined) {
87
+ report(file, "missing");
88
+ }
89
+ }
90
+ for (const [file, source] of Object.entries(synced)) {
91
+ const text = read(file);
92
+ if (text === undefined ||
93
+ normalize(text) !== normalize(readFileSync(source, "utf8"))) {
94
+ report(file, `${text === undefined ? "missing" : "differs from the baseline"}; run npx ${command} sync`);
95
+ }
96
+ }
97
+ for (const entry of readdirSync(root)) {
98
+ if (entry.startsWith(".env")) {
99
+ report(entry, "env files are not used; keep local secrets in .dev.vars");
100
+ }
101
+ }
102
+ if (existsSync(join(root, "src/middleware.ts"))) {
103
+ report("src/middleware.ts", "use src/proxy.ts instead");
104
+ }
105
+ for (const [file, entries] of [
106
+ [".gitignore", gitignore],
107
+ [".prettierignore", prettierignore],
108
+ ]) {
109
+ const text = read(file);
110
+ if (text === undefined) {
111
+ report(file, "missing");
112
+ continue;
113
+ }
114
+ const present = lines(text);
115
+ for (const entry of entries.filter((line) => !present.has(ignoreEntry(line)))) {
116
+ report(file, `add "${entry}"`);
117
+ }
118
+ }
119
+ const pkg = json("package.json");
120
+ if (pkg) {
121
+ const deps = { ...pkg.dependencies, ...pkg.devDependencies };
122
+ const exceptions = (pkg[configKey] ?? {});
123
+ const overrides = exceptions.scripts ?? {};
124
+ if ("check" in overrides) {
125
+ report("package.json", `${configKey}.scripts can't override check, which runs ${command} doctor`);
126
+ }
127
+ for (const [name, baseline] of Object.entries(scripts)) {
128
+ const expected = name === "check" ? baseline : (overrides[name] ?? baseline);
129
+ if (pkg.scripts?.[name] !== expected) {
130
+ report("package.json", `scripts.${name} must be "${expected}"`);
131
+ }
132
+ }
133
+ // A project may raise the minimum within Node 24 when a dependency needs it.
134
+ if (!/^>=24(?:\.\d+){0,2} <25$/.test(pkg.engines?.node ?? "")) {
135
+ report("package.json", 'engines.node must be ">=24 <25" (or a higher Node 24 minimum)');
136
+ }
137
+ const npm = /^npm@(\d+)\.\d+\.\d+$/.exec(pkg.packageManager ?? "");
138
+ if (!npm || Number(npm[1]) < 12) {
139
+ report("package.json", `packageManager must name an exact npm 12 or later; npx ${command} sync sets the latest`);
140
+ }
141
+ if (deps.typescript !== "6.0.3") {
142
+ report("package.json", 'typescript must be exactly "6.0.3"');
143
+ }
144
+ if (deps["eslint-config-next"] !== deps.next) {
145
+ report("package.json", "eslint-config-next must match the next version");
146
+ }
147
+ for (const name of [
148
+ packageName,
149
+ "eslint",
150
+ "prettier",
151
+ "knip",
152
+ "lefthook",
153
+ ]) {
154
+ if (!deps[name]) {
155
+ report("package.json", `add ${name} as a dependency`);
156
+ }
157
+ }
158
+ }
159
+ const knip = json("knip.json");
160
+ if (knip) {
161
+ if (!knip.entry?.includes("open-next.config.ts")) {
162
+ report("knip.json", 'entry must include "open-next.config.ts"');
163
+ }
164
+ const ui = knip.ignoreIssues?.["src/components/ui/**"] ?? [];
165
+ if (!ui.includes("exports") || !ui.includes("types")) {
166
+ report("knip.json", 'ignoreIssues["src/components/ui/**"] must include "exports" and "types"');
167
+ }
168
+ }
169
+ const mcp = read(".mcp.json");
170
+ if (mcp === undefined) {
171
+ report(".mcp.json", "missing");
172
+ }
173
+ else if (!mcp.includes("next-devtools-mcp")) {
174
+ report(".mcp.json", "add the next-devtools-mcp server");
175
+ }
176
+ const settings = json(".claude/settings.json");
177
+ if (settings) {
178
+ // Agents may do everything; the hooks only format and typecheck.
179
+ for (const rule of ["deny", "ask"]) {
180
+ if (settings.permissions?.[rule]?.length) {
181
+ report(".claude/settings.json", `remove permissions.${rule}; agents are not restricted`);
182
+ }
183
+ }
184
+ const hooks = JSON.stringify(settings.hooks ?? {});
185
+ for (const hook of ["format", "typecheck"]) {
186
+ if (!hooks.includes(`${packageName}/dist/hooks/${hook}.js`)) {
187
+ report(".claude/settings.json", `add the ${hook} hook`);
188
+ }
189
+ }
190
+ }
191
+ for (const [file, needle] of [
192
+ ["eslint.config.mjs", `${packageName}/eslint`],
193
+ ["prettier.config.mjs", `${packageName}/prettier`],
194
+ ["tsconfig.json", `${packageName}/tsconfig.json`],
195
+ ]) {
196
+ const text = read(file);
197
+ if (text === undefined) {
198
+ report(file, "missing");
199
+ }
200
+ else if (!text.includes(needle)) {
201
+ report(file, `must use ${needle}`);
202
+ }
203
+ }
204
+ const next = read("next.config.ts");
205
+ if (next !== undefined) {
206
+ for (const [pattern, message] of [
207
+ [/typedRoutes:\s*true/, "set typedRoutes: true"],
208
+ [
209
+ /cacheComponents:\s*false/,
210
+ "set cacheComponents: false (OpenNext #1464)",
211
+ ],
212
+ [
213
+ /securityHeaders/,
214
+ `send securityHeaders from ${packageName}/next in headers()`,
215
+ ],
216
+ [
217
+ /PHASE_DEVELOPMENT_SERVER/,
218
+ "call initOpenNextCloudflareForDev() only in PHASE_DEVELOPMENT_SERVER",
219
+ ],
220
+ ]) {
221
+ if (!pattern.test(next)) {
222
+ report("next.config.ts", message);
223
+ }
224
+ }
225
+ }
226
+ const wrangler = existsSync(join(root, "wrangler.jsonc"))
227
+ ? json("wrangler.jsonc")
228
+ : undefined;
229
+ if (wrangler) {
230
+ const flags = wrangler.compatibility_flags ?? [];
231
+ if (wrangler.main !== ".open-next/worker.js") {
232
+ report("wrangler.jsonc", 'main must be ".open-next/worker.js"');
233
+ }
234
+ for (const flag of ["nodejs_compat", "global_fetch_strictly_public"]) {
235
+ if (!flags.includes(flag)) {
236
+ report("wrangler.jsonc", `compatibility_flags must include "${flag}"`);
237
+ }
238
+ }
239
+ if (wrangler.assets?.directory !== ".open-next/assets" ||
240
+ wrangler.assets.binding !== "ASSETS") {
241
+ report("wrangler.jsonc", 'assets must be { "directory": ".open-next/assets", "binding": "ASSETS" }');
242
+ }
243
+ for (const key of ["workers_dev", "preview_urls"]) {
244
+ if (wrangler[key] !== true) {
245
+ report("wrangler.jsonc", `set ${key}: true (dashboard-created Workers start with it off)`);
246
+ }
247
+ }
248
+ if (wrangler.observability?.enabled !== true) {
249
+ report("wrangler.jsonc", "set observability.enabled: true");
250
+ }
251
+ if (!wrangler.routes?.length) {
252
+ report("wrangler.jsonc", "declare the site's custom domains in routes");
253
+ }
254
+ else if (wrangler.dev?.host !== "localhost") {
255
+ report("wrangler.jsonc", 'set dev.host: "localhost" so local previews do not use the first route');
256
+ }
257
+ const secrets = wrangler.secrets?.required ?? [];
258
+ if (secrets.length) {
259
+ const example = read(".dev.vars.example");
260
+ if (example === undefined) {
261
+ report(".dev.vars.example", "missing; list the names in secrets.required");
262
+ }
263
+ else {
264
+ for (const name of secrets.filter((secret) => !new RegExp(`^${secret}=`, "m").test(example))) {
265
+ report(".dev.vars.example", `add ${name}=`);
266
+ }
267
+ }
268
+ }
269
+ }
270
+ return problems;
271
+ }
@@ -0,0 +1,2 @@
1
+ export declare const synced: Record<string, string>;
2
+ export declare const starters: Record<string, string>;
@@ -0,0 +1,28 @@
1
+ import { join } from "node:path";
2
+ import { packageRoot } from "../meta.js";
3
+ const templates = join(packageRoot, "templates");
4
+ // Identical in every project and owned by this package: `sync` writes them,
5
+ // `doctor` fails when they differ. npm drops dotfiles such as .npmrc from
6
+ // packages, so the templates are stored without the leading dot.
7
+ export const synced = {
8
+ "CLAUDE.md": join(templates, "synced", "CLAUDE.md"),
9
+ ".editorconfig": join(templates, "synced", "editorconfig"),
10
+ ".gitattributes": join(templates, "synced", "gitattributes"),
11
+ ".npmrc": join(templates, "synced", "npmrc"),
12
+ ".nvmrc": join(templates, "synced", "nvmrc"),
13
+ "lefthook.yml": join(templates, "synced", "lefthook.yml"),
14
+ ".github/dependabot.yml": join(templates, "synced", "dependabot.yml"),
15
+ };
16
+ // Owned by the project, which may add to them. `init` writes them once;
17
+ // `doctor` checks that they still contain the baseline. "{{package}}" in a
18
+ // starter becomes this package's name.
19
+ export const starters = {
20
+ ".gitignore": join(templates, "init", "gitignore"),
21
+ ".prettierignore": join(templates, "init", "prettierignore"),
22
+ "knip.json": join(templates, "init", "knip.json"),
23
+ ".mcp.json": join(templates, "init", "mcp.json"),
24
+ ".claude/settings.json": join(templates, "init", "claude-settings.json"),
25
+ "eslint.config.mjs": join(templates, "init", "eslint.config.mjs"),
26
+ "prettier.config.mjs": join(templates, "init", "prettier.config.mjs"),
27
+ "tsconfig.json": join(templates, "init", "tsconfig.json"),
28
+ };
@@ -0,0 +1 @@
1
+ export declare function parseJsonc(text: string): unknown;
@@ -0,0 +1,31 @@
1
+ // Parses JSON with comments and trailing commas, as in wrangler.jsonc.
2
+ export function parseJsonc(text) {
3
+ let out = "";
4
+ let i = 0;
5
+ while (i < text.length) {
6
+ const char = text[i];
7
+ if (char === '"') {
8
+ const start = i;
9
+ i += 1;
10
+ while (i < text.length && text[i] !== '"') {
11
+ i += text[i] === "\\" ? 2 : 1;
12
+ }
13
+ i += 1;
14
+ out += text.slice(start, i);
15
+ }
16
+ else if (char === "/" && text[i + 1] === "/") {
17
+ while (i < text.length && text[i] !== "\n") {
18
+ i += 1;
19
+ }
20
+ }
21
+ else if (char === "/" && text[i + 1] === "*") {
22
+ const end = text.indexOf("*/", i + 2);
23
+ i = end === -1 ? text.length : end + 2;
24
+ }
25
+ else {
26
+ out += char;
27
+ i += 1;
28
+ }
29
+ }
30
+ return JSON.parse(out.replace(/,(\s*[}\]])/g, "$1"));
31
+ }
@@ -0,0 +1,6 @@
1
+ interface Options {
2
+ packageManager?: boolean;
3
+ }
4
+ export declare function sync(root: string, { packageManager }?: Options): Promise<string[]>;
5
+ export declare function init(root: string, options?: Options): Promise<string[]>;
6
+ export {};
@@ -0,0 +1,52 @@
1
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
2
+ import { dirname, join } from "node:path";
3
+ import { packageName } from "../meta.js";
4
+ import { starters, synced } from "./files.js";
5
+ function write(root, files, overwrite) {
6
+ const written = [];
7
+ for (const [target, source] of Object.entries(files)) {
8
+ const path = join(root, target);
9
+ const content = readFileSync(source, "utf8").replaceAll("{{package}}", packageName);
10
+ if (existsSync(path) &&
11
+ (!overwrite || readFileSync(path, "utf8") === content)) {
12
+ continue;
13
+ }
14
+ mkdirSync(dirname(path), { recursive: true });
15
+ writeFileSync(path, content);
16
+ written.push(target);
17
+ }
18
+ return written;
19
+ }
20
+ // Workers Builds installs the npm that packageManager names, and Dependabot
21
+ // doesn't update that field, so sync moves it to the latest npm.
22
+ async function latestNpm(root) {
23
+ const path = join(root, "package.json");
24
+ if (!existsSync(path)) {
25
+ return [];
26
+ }
27
+ try {
28
+ const response = await fetch("https://registry.npmjs.org/npm/latest");
29
+ const { version } = (await response.json());
30
+ const text = readFileSync(path, "utf8");
31
+ const pkg = JSON.parse(text);
32
+ const packageManager = `npm@${version}`;
33
+ if (pkg.packageManager === packageManager) {
34
+ return [];
35
+ }
36
+ pkg.packageManager = packageManager;
37
+ writeFileSync(path, `${JSON.stringify(pkg, null, 2)}\n`);
38
+ return [`package.json (packageManager ${packageManager})`];
39
+ }
40
+ catch {
41
+ return [];
42
+ }
43
+ }
44
+ export async function sync(root, { packageManager = true } = {}) {
45
+ return [
46
+ ...write(root, synced, true),
47
+ ...(packageManager ? await latestNpm(root) : []),
48
+ ];
49
+ }
50
+ export async function init(root, options = {}) {
51
+ return [...(await sync(root, options)), ...write(root, starters, false)];
52
+ }
package/dist/meta.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ export declare const packageRoot: string;
2
+ export declare const packageName: string;
3
+ export declare const command: string;
4
+ export declare const configKey: string;
package/dist/meta.js ADDED
@@ -0,0 +1,9 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ // The package's own name and command, so files and messages follow a rename.
4
+ export const packageRoot = join(import.meta.dirname, "..");
5
+ const manifest = JSON.parse(readFileSync(join(packageRoot, "package.json"), "utf8"));
6
+ export const packageName = manifest.name;
7
+ export const command = Object.keys(manifest.bin)[0] ?? packageName;
8
+ // The package.json field where a project declares its exceptions.
9
+ export const configKey = command.replace(/-(\w)/g, (_, letter) => letter.toUpperCase());
package/dist/next.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ export declare const securityHeaders: {
2
+ key: string;
3
+ value: string;
4
+ }[];
package/dist/next.js ADDED
@@ -0,0 +1,15 @@
1
+ // Security headers for every route. Add a Content-Security-Policy per project:
2
+ // headers: () => [{ source: "/:path*", headers: [...securityHeaders, csp] }]
3
+ export const securityHeaders = [
4
+ {
5
+ key: "Strict-Transport-Security",
6
+ value: "max-age=63072000; includeSubDomains",
7
+ },
8
+ { key: "X-Frame-Options", value: "DENY" },
9
+ { key: "X-Content-Type-Options", value: "nosniff" },
10
+ { key: "Referrer-Policy", value: "strict-origin-when-cross-origin" },
11
+ {
12
+ key: "Permissions-Policy",
13
+ value: "accelerometer=(), camera=(), display-capture=(), geolocation=(), gyroscope=(), magnetometer=(), microphone=(), midi=(), payment=(), usb=()",
14
+ },
15
+ ];
@@ -0,0 +1,3 @@
1
+ import type { Config } from "prettier";
2
+ declare const config: Config;
3
+ export default config;
@@ -0,0 +1,7 @@
1
+ import * as tailwind from "prettier-plugin-tailwindcss";
2
+ const config = {
3
+ // The plugin's own types are looser than Prettier's Plugin type.
4
+ plugins: [tailwind],
5
+ tailwindFunctions: ["cn", "cva", "clsx"],
6
+ };
7
+ export default config;
@@ -0,0 +1,2 @@
1
+ import type { Rule } from "eslint";
2
+ export declare function classRule(message: string, breaks: (token: string) => boolean): Rule.RuleModule;
@@ -0,0 +1,29 @@
1
+ export function classRule(message, breaks) {
2
+ return {
3
+ meta: { type: "suggestion", schema: [], messages: { token: message } },
4
+ create(context) {
5
+ function check(node, text) {
6
+ if (typeof text !== "string") {
7
+ return;
8
+ }
9
+ for (const token of text.split(/\s+/)) {
10
+ if (breaks(token)) {
11
+ context.report({
12
+ node,
13
+ messageId: "token",
14
+ data: { utility: token },
15
+ });
16
+ }
17
+ }
18
+ }
19
+ return {
20
+ Literal: (node) => {
21
+ check(node, node.value);
22
+ },
23
+ TemplateElement: (node) => {
24
+ check(node, node.value.cooked);
25
+ },
26
+ };
27
+ },
28
+ };
29
+ }
@@ -0,0 +1,2 @@
1
+ import type { Rule } from "eslint";
2
+ export declare const featureLayout: Rule.RuleModule;
@@ -0,0 +1,16 @@
1
+ export const featureLayout = {
2
+ meta: {
3
+ type: "suggestion",
4
+ schema: [],
5
+ messages: {
6
+ folder: "Feature code lives in components/, hooks/ or lib/ inside src/features/<feature>/.",
7
+ },
8
+ },
9
+ create(context) {
10
+ return {
11
+ Program: (node) => {
12
+ context.report({ node, messageId: "folder" });
13
+ },
14
+ };
15
+ },
16
+ };
@@ -0,0 +1 @@
1
+ export declare const spacing: import("eslint").Rule.RuleModule;
@@ -0,0 +1,23 @@
1
+ import { classRule } from "./class-rule.js";
2
+ const pattern = /(?:^|:)!?-?((?:[mp](?:[trblxyse]|[bi][se]?)?|space-[xy]|gap(?:-[xy])?))-(.+?)(?:!)?$/;
3
+ export const spacing = classRule('Use a Tailwind spacing number divisible by four, or 2, instead of "{{utility}}".', (token) => {
4
+ const match = pattern.exec(token);
5
+ if (!match) {
6
+ return false;
7
+ }
8
+ const [, property = "", value = ""] = match;
9
+ if (property.startsWith("m") && value === "auto") {
10
+ return false;
11
+ }
12
+ if (property.startsWith("space-") && value === "reverse") {
13
+ return false;
14
+ }
15
+ if (/^[[(].*--/.test(value)) {
16
+ return false;
17
+ }
18
+ // Other strings, such as storage keys, can look like a spacing utility.
19
+ if (!/^(?:[\d.]+|px|\[.*\]|\(.*\))$/.test(value)) {
20
+ return false;
21
+ }
22
+ return !(value === "2" || (/^\d+$/.test(value) && Number(value) % 4 === 0));
23
+ });
@@ -0,0 +1,5 @@
1
+ export declare const typography: import("eslint").Rule.RuleModule;
2
+ export declare const typographyStyle: {
3
+ selector: string;
4
+ message: string;
5
+ };
@@ -0,0 +1,7 @@
1
+ import { classRule } from "./class-rule.js";
2
+ const pattern = /(?:^|:)!?-?(?:text-(?:xs|sm|base|lg|[2-9]?xl)(?:\/\S+)?|text-[[(]\S+|font-\S+|leading-\S+|tracking-\S+|italic|not-italic|uppercase|lowercase|capitalize|normal-case)!?$/;
3
+ export const typography = classRule('Use a role from components/typography.tsx instead of "{{utility}}".', (token) => pattern.test(token));
4
+ export const typographyStyle = {
5
+ selector: 'JSXAttribute[name.name="style"] Property[key.name=/^(font|fontFamily|fontSize|fontStyle|fontWeight|letterSpacing|lineHeight|textTransform)$/]',
6
+ message: "Use a role from components/typography.tsx.",
7
+ };
package/package.json CHANGED
@@ -1,6 +1,83 @@
1
1
  {
2
2
  "name": "next-workers-kit",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.0",
4
+ "description": "Config, structure rules and drift checks for Next.js on Cloudflare Workers (OpenNext): ESLint, TypeScript, Prettier, a project doctor and Claude Code hooks",
5
+ "license": "MIT",
6
+ "author": "pnilssson",
7
+ "type": "module",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/pnilssson/next-workers-kit.git"
11
+ },
12
+ "exports": {
13
+ "./eslint": {
14
+ "types": "./dist/eslint.d.ts",
15
+ "default": "./dist/eslint.js"
16
+ },
17
+ "./next": {
18
+ "types": "./dist/next.d.ts",
19
+ "default": "./dist/next.js"
20
+ },
21
+ "./prettier": {
22
+ "types": "./dist/prettier.d.ts",
23
+ "default": "./dist/prettier.js"
24
+ },
25
+ "./tsconfig.json": "./tsconfig.base.json"
26
+ },
27
+ "files": [
28
+ "dist",
29
+ "templates",
30
+ "tsconfig.base.json"
31
+ ],
32
+ "packageManager": "npm@12.2.1",
33
+ "engines": {
34
+ "node": ">=24 <25"
35
+ },
36
+ "scripts": {
37
+ "build": "tsc",
38
+ "prepack": "npm run build",
39
+ "test": "npm run build && node --test test/*.test.js",
40
+ "format": "prettier --write .",
41
+ "format:check": "prettier --check ."
42
+ },
43
+ "dependencies": {
44
+ "eslint-config-prettier": "^10.1.8",
45
+ "eslint-import-resolver-typescript": "^4.4.5",
46
+ "eslint-plugin-boundaries": "^7.4.0",
47
+ "prettier-plugin-tailwindcss": "^0.8.1",
48
+ "typescript-eslint": "^8.72.1"
49
+ },
50
+ "peerDependencies": {
51
+ "eslint": "^10.13.0",
52
+ "eslint-config-next": ">=16.4.0",
53
+ "prettier": "^3.9.0",
54
+ "typescript": ">=6.0.3 <6.1.0"
55
+ },
56
+ "devDependencies": {
57
+ "@types/node": "^24.19.2",
58
+ "@types/react": "^19.3.0",
59
+ "eslint": "10.13.0",
60
+ "eslint-config-next": "16.4.3",
61
+ "next": "16.4.3",
62
+ "prettier": "3.9.10",
63
+ "react": "19.3.1",
64
+ "typescript": "6.0.3"
65
+ },
66
+ "bin": {
67
+ "next-workers-kit": "./dist/cli.js"
68
+ },
69
+ "keywords": [
70
+ "nextjs",
71
+ "cloudflare",
72
+ "cloudflare-workers",
73
+ "opennext",
74
+ "eslint-config",
75
+ "prettier-config",
76
+ "tsconfig",
77
+ "claude-code"
78
+ ],
79
+ "homepage": "https://github.com/pnilssson/next-workers-kit#readme",
80
+ "bugs": {
81
+ "url": "https://github.com/pnilssson/next-workers-kit/issues"
82
+ }
83
+ }
@@ -0,0 +1,25 @@
1
+ {
2
+ "hooks": {
3
+ "PostToolUse": [
4
+ {
5
+ "matcher": "Edit|Write",
6
+ "hooks": [
7
+ {
8
+ "type": "command",
9
+ "command": "node \"$CLAUDE_PROJECT_DIR/node_modules/{{package}}/dist/hooks/format.js\""
10
+ }
11
+ ]
12
+ }
13
+ ],
14
+ "Stop": [
15
+ {
16
+ "hooks": [
17
+ {
18
+ "type": "command",
19
+ "command": "node \"$CLAUDE_PROJECT_DIR/node_modules/{{package}}/dist/hooks/typecheck.js\""
20
+ }
21
+ ]
22
+ }
23
+ ]
24
+ }
25
+ }