@rexezuge/tooling 1.3.0 → 1.5.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 (128) hide show
  1. package/dist/eslint-boundaries.d.ts +12 -4
  2. package/dist/eslint-boundaries.d.ts.map +1 -1
  3. package/dist/eslint-boundaries.js +1 -224
  4. package/dist/eslint-boundaries.js.map +7 -1
  5. package/dist/eslint-rules.js +1 -273
  6. package/dist/eslint-rules.js.map +7 -1
  7. package/dist/eslint.js +1 -194
  8. package/dist/eslint.js.map +7 -1
  9. package/dist/functions/pages-proxy.d.ts.map +1 -1
  10. package/dist/functions/pages-proxy.js +1 -131
  11. package/dist/functions/pages-proxy.js.map +7 -1
  12. package/dist/index.js +1 -31
  13. package/dist/index.js.map +7 -1
  14. package/dist/scripts/backup/d1-target.d.ts +15 -5
  15. package/dist/scripts/backup/d1-target.d.ts.map +1 -1
  16. package/dist/scripts/backup/d1-target.js +1 -31
  17. package/dist/scripts/backup/d1-target.js.map +7 -1
  18. package/dist/scripts/backup/destination-config.d.ts +24 -8
  19. package/dist/scripts/backup/destination-config.d.ts.map +1 -1
  20. package/dist/scripts/backup/destination-config.js +1 -57
  21. package/dist/scripts/backup/destination-config.js.map +7 -1
  22. package/dist/scripts/backup/encrypt-backup.js +2 -97
  23. package/dist/scripts/backup/encrypt-backup.js.map +7 -1
  24. package/dist/scripts/backup/naming.d.ts +3 -1
  25. package/dist/scripts/backup/naming.d.ts.map +1 -1
  26. package/dist/scripts/backup/naming.js +1 -58
  27. package/dist/scripts/backup/naming.js.map +7 -1
  28. package/dist/scripts/check-god-files.d.ts +40 -14
  29. package/dist/scripts/check-god-files.d.ts.map +1 -1
  30. package/dist/scripts/check-god-files.js +2 -271
  31. package/dist/scripts/check-god-files.js.map +7 -1
  32. package/dist/scripts/ensure-spa-shell-stub.js +1 -29
  33. package/dist/scripts/ensure-spa-shell-stub.js.map +7 -1
  34. package/dist/scripts/init-secrets.d.ts +0 -16
  35. package/dist/scripts/init-secrets.d.ts.map +1 -1
  36. package/dist/scripts/init-secrets.js +2 -239
  37. package/dist/scripts/init-secrets.js.map +7 -1
  38. package/dist/scripts/lib/cli-args.d.ts.map +1 -1
  39. package/dist/scripts/lib/cli-args.js +1 -116
  40. package/dist/scripts/lib/cli-args.js.map +7 -1
  41. package/dist/scripts/lib/github-actions.js +3 -38
  42. package/dist/scripts/lib/github-actions.js.map +7 -1
  43. package/dist/scripts/lib/wrangler-table.d.ts.map +1 -1
  44. package/dist/scripts/lib/wrangler-table.js +2 -99
  45. package/dist/scripts/lib/wrangler-table.js.map +7 -1
  46. package/dist/scripts/migrations-lock.js +1 -44
  47. package/dist/scripts/migrations-lock.js.map +7 -1
  48. package/dist/scripts/prepare-wrangler-config.js +1 -49
  49. package/dist/scripts/prepare-wrangler-config.js.map +7 -1
  50. package/dist/scripts/spa-shell.d.ts +12 -4
  51. package/dist/scripts/spa-shell.d.ts.map +1 -1
  52. package/dist/scripts/spa-shell.js +3 -160
  53. package/dist/scripts/spa-shell.js.map +7 -1
  54. package/dist/scripts/validate-locales.d.ts +13 -5
  55. package/dist/scripts/validate-locales.d.ts.map +1 -1
  56. package/dist/scripts/validate-locales.js +4 -350
  57. package/dist/scripts/validate-locales.js.map +7 -1
  58. package/dist/scripts/verify-migrations.d.ts +27 -9
  59. package/dist/scripts/verify-migrations.d.ts.map +1 -1
  60. package/dist/scripts/verify-migrations.js +2 -312
  61. package/dist/scripts/verify-migrations.js.map +7 -1
  62. package/dist/scripts/verify-spa-shell.js +1 -52
  63. package/dist/scripts/verify-spa-shell.js.map +7 -1
  64. package/dist/scripts/wrangler-config/cli.js +3 -51
  65. package/dist/scripts/wrangler-config/cli.js.map +7 -1
  66. package/dist/scripts/wrangler-config/patches.d.ts +9 -3
  67. package/dist/scripts/wrangler-config/patches.d.ts.map +1 -1
  68. package/dist/scripts/wrangler-config/patches.js +4 -141
  69. package/dist/scripts/wrangler-config/patches.js.map +7 -1
  70. package/dist/scripts/wrangler-config/resources.d.ts +18 -6
  71. package/dist/scripts/wrangler-config/resources.d.ts.map +1 -1
  72. package/dist/scripts/wrangler-config/resources.js +1 -290
  73. package/dist/scripts/wrangler-config/resources.js.map +7 -1
  74. package/dist/scripts/wrangler-config/types.d.ts +24 -8
  75. package/dist/scripts/wrangler-config/types.d.ts.map +1 -1
  76. package/dist/scripts/wrangler-config/types.js +1 -49
  77. package/dist/scripts/wrangler-config/types.js.map +7 -1
  78. package/dist/test/integration-migrations.d.ts +29 -12
  79. package/dist/test/integration-migrations.d.ts.map +1 -1
  80. package/dist/test/integration-migrations.js +2 -171
  81. package/dist/test/integration-migrations.js.map +7 -1
  82. package/dist/test/mocks/cloudflare-workers.js +1 -90
  83. package/dist/test/mocks/cloudflare-workers.js.map +7 -1
  84. package/dist/vite.d.ts +5 -3
  85. package/dist/vite.d.ts.map +1 -1
  86. package/dist/vite.js +3 -125
  87. package/dist/vite.js.map +7 -1
  88. package/dist/vitest-aliases.d.ts.map +1 -1
  89. package/dist/vitest-aliases.js +1 -81
  90. package/dist/vitest-aliases.js.map +7 -1
  91. package/dist/vitest-integration.js +1 -64
  92. package/dist/vitest-integration.js.map +7 -1
  93. package/dist/vitest-repo.js +1 -146
  94. package/dist/vitest-repo.js.map +7 -1
  95. package/dist/vitest-web.js +1 -109
  96. package/dist/vitest-web.js.map +7 -1
  97. package/dist/vitest.js +1 -133
  98. package/dist/vitest.js.map +7 -1
  99. package/package.json +3 -3
  100. package/src/eslint-boundaries.ts +13 -5
  101. package/src/eslint.test.ts +18 -8
  102. package/src/functions/pages-proxy.test.ts +1 -1
  103. package/src/functions/pages-proxy.ts +4 -2
  104. package/src/scripts/backup/backup-rules.test.ts +1 -1
  105. package/src/scripts/backup/d1-target.ts +15 -5
  106. package/src/scripts/backup/destination-config.ts +27 -9
  107. package/src/scripts/backup/encrypt-backup.ts +10 -8
  108. package/src/scripts/backup/naming.ts +3 -1
  109. package/src/scripts/check-god-files.test.ts +18 -18
  110. package/src/scripts/check-god-files.ts +60 -31
  111. package/src/scripts/init-secrets.ts +17 -7
  112. package/src/scripts/lib/cli-args.ts +6 -3
  113. package/src/scripts/lib/wrangler-table.ts +5 -3
  114. package/src/scripts/migrations-lock.ts +1 -1
  115. package/src/scripts/spa-shell.test.ts +17 -17
  116. package/src/scripts/spa-shell.ts +26 -14
  117. package/src/scripts/validate-locales.test.ts +17 -17
  118. package/src/scripts/validate-locales.ts +43 -25
  119. package/src/scripts/verify-migrations.test.ts +7 -7
  120. package/src/scripts/verify-migrations.ts +47 -24
  121. package/src/scripts/wrangler-config/patches.ts +12 -4
  122. package/src/scripts/wrangler-config/resources.ts +30 -14
  123. package/src/scripts/wrangler-config/types.ts +24 -8
  124. package/src/test/integration-migrations.test.ts +6 -6
  125. package/src/test/integration-migrations.ts +33 -14
  126. package/src/vite.test.ts +24 -13
  127. package/src/vite.ts +5 -5
  128. package/src/vitest-aliases.ts +1 -3
@@ -1 +1,7 @@
1
- {"version":3,"file":"eslint-rules.js","sourceRoot":"","sources":["../src/eslint-rules.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAsC;IACjE,mCAAmC,EAAE,CAAC,OAAO,EAAE,EAAE,iBAAiB,EAAE,IAAI,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC;IACpG,gEAAgE;IAChE,yCAAyC,EAAE,CAAC,OAAO,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;IAC1E,8EAA8E;IAC9E,8EAA8E;IAC9E,iCAAiC;IACjC,oCAAoC,EAAE,MAAM;IAC5C,yCAAyC,EAAE,MAAM;IACjD,4CAA4C,EAAE,MAAM;IACpD,mCAAmC,EAAE,MAAM;IAC3C,qCAAqC,EAAE,MAAM;IAC7C,uCAAuC,EAAE,MAAM;IAC/C,4EAA4E;IAC5E,0BAA0B;IAC1B,wCAAwC,EAAE,CAAC,OAAO,EAAE,EAAE,gBAAgB,EA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AAE,KAAK;IAC1C,sEAAsE;IACtE,kCAAkC,EAAE,KAAK;IACzC,0DAA0D;IAC1D,mDAAmD,EAAE,KAAK;IAC1D,qEAAqE;IACrE,kDAAkD,EAAE,KAAK;IACzD,uEAAuE;IACvE,uCAAuC,EAAE,KAAK;IAC9C,qCAAqC,EAAE,KAAK;IAC5C,kEAAkE;IAClE,8BAA8B,EAAE,KAAK;IACrC,oCAAoC,EAAE,KAAK;IAC3C,qEAAqE;IACrE,iCAAiC,EAAE,KAAK;IACxC,kCAAkC,EAAE,KAAK;IACzC,2EAA2E;IAC3E,sCAAsC,EAAE,KAAK;IAC7C,uEAAuE;IACvE,oCAAoC,EAAE,KAAK;IAC3C,mEAAmE;IACnE,kBAAkB,EAAE,KAAK;IACzB,4EAA4E;IAC5E,yEAAyE;IACzE,2EAA2E;IAC3E,yEAAyE;IACzE,qDAAqD;IACrD,iCAAiC,EAAE,KAAK;IACxC,yBAAyB,EAAE,KAAK;IAChC,sBAAsB,EAAE,KAAK;IAC7B,6EAA6E;IAC7E,yBAAyB;IACzB,6BAA6B,EAAE,KAAK;IACpC,yEAAyE;IACzE,4BAA4B,EAAE,KAAK;IACnC,mEAAmE;IACnE,wBAAwB,EAAE,KAAK;IAC/B,gEAAgE;IAChE,8BAA8B,EAAE,KAAK;IACrC,sEAAsE;IACtE,6BAA6B,EAAE,KAAK;IACpC,wEAAwE;IACxE,iCAAiC,EAAE,KAAK;IACxC,6EAA6E;IAC7E,uBAAuB,EAAE,KAAK;IAC9B,yCAAyC,EAAE,KAAK;IAChD,sCAAsC,EAAE,KAAK;IAC7C,2CAA2C,EAAE,KAAK;IAClD,mDAAmD,EAAE,KAAK;IAC1D,oCAAoC,EAAE,KAAK;IAC3C,mCAAmC,EAAE,KAAK;CAC3C,CAAC","sourcesContent":["/**\n * The rule-override blocks of the repo lint config.\n *\n * Extracted from `eslint.ts` with the boundary rules: each block is a plain\n * rules object with the provenance comment that says *why* it is set to this\n * value, because a per-rule decision with no reason attached is a decision the\n * next reader re-litigates. `eslint.ts` composes these; this file is where a\n * rule's story lives.\n */\n\n/**\n * TypeScript rules, identical in all four source stacks.\n */\nexport const TYPESCRIPT_RULES: Readonly<Record<string, unknown>> = {\n '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }],\n // Allow `void expr` for intentional fire-and-forget in Workers.\n '@typescript-eslint/no-floating-promises': ['error', { ignoreVoid: true }],\n // Relax the unsafe-any rules to warn: the external API boundaries (Cloudflare\n // bindings, provider SDKs) are typed `any` upstream, and the alternative is a\n // config that cannot be adopted.\n '@typescript-eslint/no-explicit-any': 'warn',\n '@typescript-eslint/no-unsafe-assignment': 'warn',\n '@typescript-eslint/no-unsafe-member-access': 'warn',\n '@typescript-eslint/no-unsafe-call': 'warn',\n '@typescript-eslint/no-unsafe-return': 'warn',\n '@typescript-eslint/no-unsafe-argument': 'warn',\n // JSX event handlers and hook callback objects commonly use async functions\n // where void is expected.\n '@typescript-eslint/no-misused-promises': ['error', { checksVoidReturn: { attributes: false, properties: false } }],\n // An `async` function with no `await`: every handler and DAO method is\n // `async` by shape so a future `await` does not change its signature.\n '@typescript-eslint/require-await': 'off',\n // `await` on a value the types say is not thenable, where the value is a\n // `PromiseLike` from an interface declared that way.\n '@typescript-eslint/await-thenable': 'off',\n};\n\n/**\n * Unicorn and SonarJS rules carried from the source repos, each off for a\n * stated reason.\n *\n * This is the family's \"deliberately does not follow\" block: every entry is\n * off because complying would make the code worse for what the project is,\n * and each is listed rather than dropped so the decision stays reviewable.\n */\nexport const UNICORN_RULES: Readonly<Record<string, unknown>> = {\n // Codebase uses ctx, req, res, env, err, util, db, dao, etc. — too invasive\n // to rename.\n 'unicorn/prevent-abbreviations': 'off',\n // D1/DAO layer returns null; disabling this avoids mass rewrites.\n 'unicorn/no-null': 'off',\n // Monorepo uses CommonJS-compatible module style in some configs.\n 'unicorn/prefer-module': 'off',\n // Top-level await not available in all Workers entry points.\n 'unicorn/prefer-top-level-await': 'off',\n // Error subclassing via `new MyError()` is intentional in backend-errors.\n 'unicorn/custom-error-definition': 'off',\n // Allow process.exit in build/script files.\n 'unicorn/no-process-exit': 'off',\n // Array reduce is used intentionally in analytics/data transformation.\n 'unicorn/no-array-reduce': 'off',\n // Allow Number() — parseInt/parseFloat are used in some cases intentionally.\n 'unicorn/prefer-number-properties': ['error', { checkInfinity: false }],\n // Allow nested ternaries in JSX (React render patterns).\n 'unicorn/no-nested-ternary': 'off',\n // Allow Array.from — codebase uses it for iterables.\n 'unicorn/prefer-spread': 'off',\n // Entire codebase uses PascalCase for TS files; kebab-case would require\n // mass renames.\n 'unicorn/filename-case': 'off',\n // Established names should not be force-renamed.\n 'unicorn/name-replacements': 'off',\n // Zod schema builder chains and other deep method chains are intentional.\n 'unicorn/max-nested-calls': 'off',\n // import.meta.dirname is not available in all test environments.\n 'unicorn/prefer-import-meta-properties': 'off',\n // Codebase uses `err` as catch parameter name throughout.\n 'unicorn/catch-error-name': 'off',\n // Established boolean param names (retryable, enabled, etc.).\n 'unicorn/consistent-boolean-name': 'off',\n // Uint8Array#toBase64 / fromBase64 are not in all Workers runtime versions.\n 'unicorn/prefer-uint8array-base64': 'off',\n // Class member ordering would require extensive restructuring.\n 'unicorn/consistent-class-member-order': 'off',\n // API response fields use verb prefixes by convention.\n 'unicorn/no-non-function-verb-prefix': 'off',\n // forEach is used intentionally throughout the provider and utility layers.\n 'unicorn/no-for-each': 'off',\n // .then() chains in DAO and provider layers are often intentional.\n 'unicorn/prefer-await': 'warn',\n // Callback references (e.g. .map(Number)) are sometimes intentional.\n 'unicorn/no-array-callback-reference': 'warn',\n // toSorted() is ES2023 and may not be in all tsconfig lib targets.\n 'unicorn/no-array-sort': 'warn',\n // Early-return guard clauses are the established style; the rule only\n // rewrites the final guard of a ladder, which yields asymmetric mixed style\n // and long inline ternaries. Off in Mail-Meow and Edge-Sonic; canonical here\n // because it is the family's established style.\n 'unicorn/prefer-ternary': 'off',\n // `(await x).y` -> a named intermediate. Fires constantly in the tests,\n // where destructuring beside the assertion it serves is clearer.\n 'unicorn/no-await-expression-member': 'off',\n // `Number(x)` over `+x`: the `+` form is used where an explicit typeof check\n // has already narrowed the operand.\n 'unicorn/prefer-number-coercion': 'off',\n // Code-point iteration: the byte-level readers index deliberately, because\n // the offset *is* what they are reading.\n 'unicorn/prefer-code-point': 'off',\n // `if (!x) return;` over a compound condition: one guard per line, each with\n // its own comment, is what keeps endpoint guards readable.\n 'unicorn/prefer-simple-condition-first': 'off',\n // Module-scope `let` assigned from `beforeEach` in the test harnesses.\n 'unicorn/no-top-level-assignment-in-function': 'off',\n // Sequential `for...of` with `await` in the DAOs — D1's subrequest budget is\n // the scarce resource.\n 'unicorn/no-unreadable-for-of-expression': 'off',\n // `Object.hasOwn` over `in`: used where a prototype-chain hit is harmless.\n 'unicorn/no-computed-property-existence-check': 'off',\n // A labeled `break` out of two loops.\n 'unicorn/no-break-in-nested-loop': 'off',\n // `this` outside a class body: the module-level cache singletons document\n // their `this` contract in prose.\n 'unicorn/no-this-outside-of-class': 'off',\n // A class named inside its own static method.\n 'unicorn/class-reference-in-static-methods': 'off',\n // Assigning `globalThis.fetch` in a test — the only way to intercept the\n // ambient fetch in Node without a module mock.\n 'unicorn/no-global-object-property-assignment': 'off',\n // `(a ? b : c) && d`: written longhand so each precedence decision is\n // visible.\n 'unicorn/prefer-logical-operator-over-ternary': 'off',\n // `children[0]` in the XML helpers, which index a child list positionally.\n 'unicorn/better-dom-traversing': 'off',\n // `entries()` -> `keys()`/`values()`: the full entry is destructured.\n 'unicorn/prefer-iterator-to-array': 'off',\n // `.map(fn, thisArg)`: rejected on purpose.\n 'unicorn/no-array-method-this-argument': 'off',\n // A module-scope function that closes over nothing.\n 'unicorn/consistent-function-scoping': 'off',\n // `foo[0] === 'a' || foo[0] === 'b'` written longhand where the\n // alternatives are not adjacent.\n 'unicorn/prefer-includes-over-repeated-comparisons': 'off',\n // A `type` alias over an inline union, where the name is what makes the\n // signature and its doc comment readable.\n 'sonarjs/use-type-alias': 'off',\n // A short local alias for a type imported from a protocol package.\n 'sonarjs/redundant-type-aliases': 'off',\n // `type: value` narrowing the other way, where both spellings appear in the\n // same schema and the code follows whichever the spec uses there.\n 'sonarjs/no-nested-assignment': 'off',\n // `Number.isInteger` plus a separate range check, where the bounds come from\n // the caller's own options in one place.\n 'unicorn/prefer-number-is-safe-integer': 'off',\n // `\\u{...}` over a `\\xNN` escape: the table is written in the byte form the\n // spec prints.\n 'unicorn/prefer-unicode-code-point-escapes': 'off',\n // `self.x = this.x` in an entry model: the alias makes the verbatim\n // round-trip explicit.\n 'unicorn/no-this-assignment': 'off',\n // Building a `Set` at module scope from a constant list, for O(1) membership\n // on a path that runs per parameter.\n 'unicorn/no-top-level-side-effects': 'off',\n // A conditional whose branches are identical, kept where the two branches\n // are named separately to document that they are meant to diverge.\n 'sonarjs/no-all-duplicated-branches': 'off',\n // An `else` after a `return`: the flat form keeps the remaining cases at one\n // indent level in the dispatch tables.\n 'unicorn/prefer-else-if': 'off',\n // A nested ternary in a sort comparator, where the three-way order is the\n // point.\n 'unicorn/prefer-minimal-ternary': 'off',\n // `void promise` where initiating the call is the point and the rejection is\n // handled at a named site elsewhere.\n 'sonarjs/void-use': 'off',\n // `x === undefined` reported as always-true/false. With\n // `noUncheckedIndexedAccess` on, the guard is exactly right.\n 'sonarjs/different-types-comparison': 'off',\n // An accumulating loop with a sequential `await` in it, over D1 writes.\n 'unicorn/prefer-array-from-async': 'off',\n};\n\n/**\n * SonarJS rules the sources turned from errors into advisories, with the\n * threshold raised to a value that has actually held.\n */\nexport const SONARJS_RULES: Readonly<Record<string, unknown>> = {\n // Raise duplicate-string threshold to avoid flagging intentional repeated\n // literals like provider IDs.\n 'sonarjs/no-duplicate-string': ['warn', { threshold: 5 }],\n // Cognitive complexity — warn rather than error, so the ratchet can move\n // without a red build. Raise the number only as files are decomposed.\n 'sonarjs/cognitive-complexity': ['warn', 20],\n // False positives: connection method names like 'imap-password' and field\n // names like 'password_hash'.\n 'sonarjs/no-hardcoded-passwords': 'off',\n // Third-party deprecations are warnings, not errors.\n 'sonarjs/deprecation': 'warn',\n // Nested ternaries in complex data-mapping code.\n 'sonarjs/no-nested-conditional': 'warn',\n // React component props are commonly not marked Readonly<>.\n 'sonarjs/prefer-read-only-props': 'warn',\n // Static readonly properties require invasive refactoring.\n 'sonarjs/public-static-readonly': 'warn',\n // Nested template literals in SQL queries and prompt construction.\n 'sonarjs/no-nested-template-literals': 'warn',\n};\n\n/**\n * Test-suite overrides.\n *\n * `test/**` is deliberately *not* in the config's ignores list. Durable-DAV,\n * AWS and Mail-Meow all ignored it, and ~200 KB of test code had accumulated\n * violations that nothing reported. This block puts the suite back under the\n * same rules as the rest of the workspace and switches off only the handful\n * whose findings are structural artefacts of test code rather than defects.\n * It does not disable correctness rules: the unused-variable, dead-store,\n * regex and sorting findings in the suite are real and are fixed, not\n * suppressed.\n */\nexport const TEST_RULES: Readonly<Record<string, unknown>> = {\n // `it('…', async () => …)` is the Vitest idiom.\n '@typescript-eslint/no-misused-promises': ['error', { checksVoidReturn: { arguments: false, attributes: false } }],\n // Unbound method is a common false positive in mock assertions like\n // expect(fn).toHaveBeenCalledWith(...).\n '@typescript-eslint/unbound-method': 'off',\n // Test helpers and stubs routinely use async functions without await.\n '@typescript-eslint/require-await': 'off',\n // Redundant type constituents appear in typed mock stubs.\n '@typescript-eslint/no-redundant-type-constituents': 'off',\n // `as never` casts are the standard fake-DB double pattern in tests.\n '@typescript-eslint/no-unnecessary-type-assertion': 'off',\n // Promise.withResolvers() and function-scoping refactors are cosmetic.\n 'unicorn/prefer-promise-with-resolvers': 'off',\n 'unicorn/consistent-function-scoping': 'off',\n // Fake-DB builders push-then-return and sort without comparators.\n 'unicorn/no-return-array-push': 'off',\n 'unicorn/require-array-sort-compare': 'off',\n // Iterator-helper rewrites churn test fakes with no runtime benefit.\n 'unicorn/prefer-iterator-helpers': 'off',\n 'unicorn/prefer-iterator-to-array': 'off',\n // String replacement with test-driven values is intentional in assertions.\n 'unicorn/no-unsafe-string-replacement': 'off',\n // Fake-D1 doubles await a DAO thunk and call straight onto the result.\n 'unicorn/no-await-expression-member': 'off',\n // `void promise` marks a deliberately unawaited promise in a test.\n 'sonarjs/void-use': 'off',\n // A test asserting request routing has to name `http://` hosts, and a proxy\n // test has to name a loopback upstream. Both are the subject matter, not\n // leaked configuration. `unicorn/prefer-https` must stay off here and this\n // is not a style preference: it rewrites `http://` to `https://` *inside\n // string literals*, and `--fix` applies it silently.\n 'sonarjs/no-clear-text-protocols': 'off',\n 'sonarjs/no-hardcoded-ip': 'off',\n 'unicorn/prefer-https': 'off',\n // sonarjs/assertions-in-tests fires false positives when test helpers handle\n // assertions indirectly.\n 'sonarjs/assertions-in-tests': 'off',\n // sonarjs/no-extra-arguments fires incorrectly on Vitest mock overloads.\n 'sonarjs/no-extra-arguments': 'off',\n // Union/inline types in test fakes are more readable than aliases.\n 'sonarjs/use-type-alias': 'off',\n // Alphabetical-sort rule fights deterministic fixture ordering.\n 'sonarjs/no-alphabetical-sort': 'off',\n // Repeated string literals in fixtures/assertions are clearer inline.\n 'sonarjs/no-duplicate-string': 'off',\n // Fake-D1 doubles break out of a nested loop to model a statement miss.\n 'unicorn/no-break-in-nested-loop': 'off',\n // Fixtures are naturally built with sort()/for…of over composed expressions.\n 'unicorn/no-array-sort': 'off',\n 'unicorn/no-unreadable-for-of-expression': 'off',\n 'unicorn/no-useless-template-literals': 'off',\n 'unicorn/no-declarations-before-early-exit': 'off',\n 'unicorn/prefer-includes-over-repeated-comparisons': 'off',\n 'sonarjs/prefer-specific-assertions': 'off',\n 'sonarjs/no-inverted-boolean-check': 'off',\n};\n"]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/eslint-rules.ts"],
4
+ "sourcesContent": ["/**\n * The rule-override blocks of the repo lint config.\n *\n * Extracted from `eslint.ts` with the boundary rules: each block is a plain\n * rules object with the provenance comment that says *why* it is set to this\n * value, because a per-rule decision with no reason attached is a decision the\n * next reader re-litigates. `eslint.ts` composes these; this file is where a\n * rule's story lives.\n */\n\n/**\n * TypeScript rules, identical in all four source stacks.\n */\nexport const TYPESCRIPT_RULES: Readonly<Record<string, unknown>> = {\n '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }],\n // Allow `void expr` for intentional fire-and-forget in Workers.\n '@typescript-eslint/no-floating-promises': ['error', { ignoreVoid: true }],\n // Relax the unsafe-any rules to warn: the external API boundaries (Cloudflare\n // bindings, provider SDKs) are typed `any` upstream, and the alternative is a\n // config that cannot be adopted.\n '@typescript-eslint/no-explicit-any': 'warn',\n '@typescript-eslint/no-unsafe-assignment': 'warn',\n '@typescript-eslint/no-unsafe-member-access': 'warn',\n '@typescript-eslint/no-unsafe-call': 'warn',\n '@typescript-eslint/no-unsafe-return': 'warn',\n '@typescript-eslint/no-unsafe-argument': 'warn',\n // JSX event handlers and hook callback objects commonly use async functions\n // where void is expected.\n '@typescript-eslint/no-misused-promises': ['error', { checksVoidReturn: { attributes: false, properties: false } }],\n // An `async` function with no `await`: every handler and DAO method is\n // `async` by shape so a future `await` does not change its signature.\n '@typescript-eslint/require-await': 'off',\n // `await` on a value the types say is not thenable, where the value is a\n // `PromiseLike` from an interface declared that way.\n '@typescript-eslint/await-thenable': 'off',\n};\n\n/**\n * Unicorn and SonarJS rules carried from the source repos, each off for a\n * stated reason.\n *\n * This is the family's \"deliberately does not follow\" block: every entry is\n * off because complying would make the code worse for what the project is,\n * and each is listed rather than dropped so the decision stays reviewable.\n */\nexport const UNICORN_RULES: Readonly<Record<string, unknown>> = {\n // Codebase uses ctx, req, res, env, err, util, db, dao, etc. — too invasive\n // to rename.\n 'unicorn/prevent-abbreviations': 'off',\n // D1/DAO layer returns null; disabling this avoids mass rewrites.\n 'unicorn/no-null': 'off',\n // Monorepo uses CommonJS-compatible module style in some configs.\n 'unicorn/prefer-module': 'off',\n // Top-level await not available in all Workers entry points.\n 'unicorn/prefer-top-level-await': 'off',\n // Error subclassing via `new MyError()` is intentional in backend-errors.\n 'unicorn/custom-error-definition': 'off',\n // Allow process.exit in build/script files.\n 'unicorn/no-process-exit': 'off',\n // Array reduce is used intentionally in analytics/data transformation.\n 'unicorn/no-array-reduce': 'off',\n // Allow Number() — parseInt/parseFloat are used in some cases intentionally.\n 'unicorn/prefer-number-properties': ['error', { checkInfinity: false }],\n // Allow nested ternaries in JSX (React render patterns).\n 'unicorn/no-nested-ternary': 'off',\n // Allow Array.from — codebase uses it for iterables.\n 'unicorn/prefer-spread': 'off',\n // Entire codebase uses PascalCase for TS files; kebab-case would require\n // mass renames.\n 'unicorn/filename-case': 'off',\n // Established names should not be force-renamed.\n 'unicorn/name-replacements': 'off',\n // Zod schema builder chains and other deep method chains are intentional.\n 'unicorn/max-nested-calls': 'off',\n // import.meta.dirname is not available in all test environments.\n 'unicorn/prefer-import-meta-properties': 'off',\n // Codebase uses `err` as catch parameter name throughout.\n 'unicorn/catch-error-name': 'off',\n // Established boolean param names (retryable, enabled, etc.).\n 'unicorn/consistent-boolean-name': 'off',\n // Uint8Array#toBase64 / fromBase64 are not in all Workers runtime versions.\n 'unicorn/prefer-uint8array-base64': 'off',\n // Class member ordering would require extensive restructuring.\n 'unicorn/consistent-class-member-order': 'off',\n // API response fields use verb prefixes by convention.\n 'unicorn/no-non-function-verb-prefix': 'off',\n // forEach is used intentionally throughout the provider and utility layers.\n 'unicorn/no-for-each': 'off',\n // .then() chains in DAO and provider layers are often intentional.\n 'unicorn/prefer-await': 'warn',\n // Callback references (e.g. .map(Number)) are sometimes intentional.\n 'unicorn/no-array-callback-reference': 'warn',\n // toSorted() is ES2023 and may not be in all tsconfig lib targets.\n 'unicorn/no-array-sort': 'warn',\n // Early-return guard clauses are the established style; the rule only\n // rewrites the final guard of a ladder, which yields asymmetric mixed style\n // and long inline ternaries. Off in Mail-Meow and Edge-Sonic; canonical here\n // because it is the family's established style.\n 'unicorn/prefer-ternary': 'off',\n // `(await x).y` -> a named intermediate. Fires constantly in the tests,\n // where destructuring beside the assertion it serves is clearer.\n 'unicorn/no-await-expression-member': 'off',\n // `Number(x)` over `+x`: the `+` form is used where an explicit typeof check\n // has already narrowed the operand.\n 'unicorn/prefer-number-coercion': 'off',\n // Code-point iteration: the byte-level readers index deliberately, because\n // the offset *is* what they are reading.\n 'unicorn/prefer-code-point': 'off',\n // `if (!x) return;` over a compound condition: one guard per line, each with\n // its own comment, is what keeps endpoint guards readable.\n 'unicorn/prefer-simple-condition-first': 'off',\n // Module-scope `let` assigned from `beforeEach` in the test harnesses.\n 'unicorn/no-top-level-assignment-in-function': 'off',\n // Sequential `for...of` with `await` in the DAOs — D1's subrequest budget is\n // the scarce resource.\n 'unicorn/no-unreadable-for-of-expression': 'off',\n // `Object.hasOwn` over `in`: used where a prototype-chain hit is harmless.\n 'unicorn/no-computed-property-existence-check': 'off',\n // A labeled `break` out of two loops.\n 'unicorn/no-break-in-nested-loop': 'off',\n // `this` outside a class body: the module-level cache singletons document\n // their `this` contract in prose.\n 'unicorn/no-this-outside-of-class': 'off',\n // A class named inside its own static method.\n 'unicorn/class-reference-in-static-methods': 'off',\n // Assigning `globalThis.fetch` in a test — the only way to intercept the\n // ambient fetch in Node without a module mock.\n 'unicorn/no-global-object-property-assignment': 'off',\n // `(a ? b : c) && d`: written longhand so each precedence decision is\n // visible.\n 'unicorn/prefer-logical-operator-over-ternary': 'off',\n // `children[0]` in the XML helpers, which index a child list positionally.\n 'unicorn/better-dom-traversing': 'off',\n // `entries()` -> `keys()`/`values()`: the full entry is destructured.\n 'unicorn/prefer-iterator-to-array': 'off',\n // `.map(fn, thisArg)`: rejected on purpose.\n 'unicorn/no-array-method-this-argument': 'off',\n // A module-scope function that closes over nothing.\n 'unicorn/consistent-function-scoping': 'off',\n // `foo[0] === 'a' || foo[0] === 'b'` written longhand where the\n // alternatives are not adjacent.\n 'unicorn/prefer-includes-over-repeated-comparisons': 'off',\n // A `type` alias over an inline union, where the name is what makes the\n // signature and its doc comment readable.\n 'sonarjs/use-type-alias': 'off',\n // A short local alias for a type imported from a protocol package.\n 'sonarjs/redundant-type-aliases': 'off',\n // `type: value` narrowing the other way, where both spellings appear in the\n // same schema and the code follows whichever the spec uses there.\n 'sonarjs/no-nested-assignment': 'off',\n // `Number.isInteger` plus a separate range check, where the bounds come from\n // the caller's own options in one place.\n 'unicorn/prefer-number-is-safe-integer': 'off',\n // `\\u{...}` over a `\\xNN` escape: the table is written in the byte form the\n // spec prints.\n 'unicorn/prefer-unicode-code-point-escapes': 'off',\n // `self.x = this.x` in an entry model: the alias makes the verbatim\n // round-trip explicit.\n 'unicorn/no-this-assignment': 'off',\n // Building a `Set` at module scope from a constant list, for O(1) membership\n // on a path that runs per parameter.\n 'unicorn/no-top-level-side-effects': 'off',\n // A conditional whose branches are identical, kept where the two branches\n // are named separately to document that they are meant to diverge.\n 'sonarjs/no-all-duplicated-branches': 'off',\n // An `else` after a `return`: the flat form keeps the remaining cases at one\n // indent level in the dispatch tables.\n 'unicorn/prefer-else-if': 'off',\n // A nested ternary in a sort comparator, where the three-way order is the\n // point.\n 'unicorn/prefer-minimal-ternary': 'off',\n // `void promise` where initiating the call is the point and the rejection is\n // handled at a named site elsewhere.\n 'sonarjs/void-use': 'off',\n // `x === undefined` reported as always-true/false. With\n // `noUncheckedIndexedAccess` on, the guard is exactly right.\n 'sonarjs/different-types-comparison': 'off',\n // An accumulating loop with a sequential `await` in it, over D1 writes.\n 'unicorn/prefer-array-from-async': 'off',\n};\n\n/**\n * SonarJS rules the sources turned from errors into advisories, with the\n * threshold raised to a value that has actually held.\n */\nexport const SONARJS_RULES: Readonly<Record<string, unknown>> = {\n // Raise duplicate-string threshold to avoid flagging intentional repeated\n // literals like provider IDs.\n 'sonarjs/no-duplicate-string': ['warn', { threshold: 5 }],\n // Cognitive complexity — warn rather than error, so the ratchet can move\n // without a red build. Raise the number only as files are decomposed.\n 'sonarjs/cognitive-complexity': ['warn', 20],\n // False positives: connection method names like 'imap-password' and field\n // names like 'password_hash'.\n 'sonarjs/no-hardcoded-passwords': 'off',\n // Third-party deprecations are warnings, not errors.\n 'sonarjs/deprecation': 'warn',\n // Nested ternaries in complex data-mapping code.\n 'sonarjs/no-nested-conditional': 'warn',\n // React component props are commonly not marked Readonly<>.\n 'sonarjs/prefer-read-only-props': 'warn',\n // Static readonly properties require invasive refactoring.\n 'sonarjs/public-static-readonly': 'warn',\n // Nested template literals in SQL queries and prompt construction.\n 'sonarjs/no-nested-template-literals': 'warn',\n};\n\n/**\n * Test-suite overrides.\n *\n * `test/**` is deliberately *not* in the config's ignores list. Durable-DAV,\n * AWS and Mail-Meow all ignored it, and ~200 KB of test code had accumulated\n * violations that nothing reported. This block puts the suite back under the\n * same rules as the rest of the workspace and switches off only the handful\n * whose findings are structural artefacts of test code rather than defects.\n * It does not disable correctness rules: the unused-variable, dead-store,\n * regex and sorting findings in the suite are real and are fixed, not\n * suppressed.\n */\nexport const TEST_RULES: Readonly<Record<string, unknown>> = {\n // `it('…', async () => …)` is the Vitest idiom.\n '@typescript-eslint/no-misused-promises': ['error', { checksVoidReturn: { arguments: false, attributes: false } }],\n // Unbound method is a common false positive in mock assertions like\n // expect(fn).toHaveBeenCalledWith(...).\n '@typescript-eslint/unbound-method': 'off',\n // Test helpers and stubs routinely use async functions without await.\n '@typescript-eslint/require-await': 'off',\n // Redundant type constituents appear in typed mock stubs.\n '@typescript-eslint/no-redundant-type-constituents': 'off',\n // `as never` casts are the standard fake-DB double pattern in tests.\n '@typescript-eslint/no-unnecessary-type-assertion': 'off',\n // Promise.withResolvers() and function-scoping refactors are cosmetic.\n 'unicorn/prefer-promise-with-resolvers': 'off',\n 'unicorn/consistent-function-scoping': 'off',\n // Fake-DB builders push-then-return and sort without comparators.\n 'unicorn/no-return-array-push': 'off',\n 'unicorn/require-array-sort-compare': 'off',\n // Iterator-helper rewrites churn test fakes with no runtime benefit.\n 'unicorn/prefer-iterator-helpers': 'off',\n 'unicorn/prefer-iterator-to-array': 'off',\n // String replacement with test-driven values is intentional in assertions.\n 'unicorn/no-unsafe-string-replacement': 'off',\n // Fake-D1 doubles await a DAO thunk and call straight onto the result.\n 'unicorn/no-await-expression-member': 'off',\n // `void promise` marks a deliberately unawaited promise in a test.\n 'sonarjs/void-use': 'off',\n // A test asserting request routing has to name `http://` hosts, and a proxy\n // test has to name a loopback upstream. Both are the subject matter, not\n // leaked configuration. `unicorn/prefer-https` must stay off here and this\n // is not a style preference: it rewrites `http://` to `https://` *inside\n // string literals*, and `--fix` applies it silently.\n 'sonarjs/no-clear-text-protocols': 'off',\n 'sonarjs/no-hardcoded-ip': 'off',\n 'unicorn/prefer-https': 'off',\n // sonarjs/assertions-in-tests fires false positives when test helpers handle\n // assertions indirectly.\n 'sonarjs/assertions-in-tests': 'off',\n // sonarjs/no-extra-arguments fires incorrectly on Vitest mock overloads.\n 'sonarjs/no-extra-arguments': 'off',\n // Union/inline types in test fakes are more readable than aliases.\n 'sonarjs/use-type-alias': 'off',\n // Alphabetical-sort rule fights deterministic fixture ordering.\n 'sonarjs/no-alphabetical-sort': 'off',\n // Repeated string literals in fixtures/assertions are clearer inline.\n 'sonarjs/no-duplicate-string': 'off',\n // Fake-D1 doubles break out of a nested loop to model a statement miss.\n 'unicorn/no-break-in-nested-loop': 'off',\n // Fixtures are naturally built with sort()/for…of over composed expressions.\n 'unicorn/no-array-sort': 'off',\n 'unicorn/no-unreadable-for-of-expression': 'off',\n 'unicorn/no-useless-template-literals': 'off',\n 'unicorn/no-declarations-before-early-exit': 'off',\n 'unicorn/prefer-includes-over-repeated-comparisons': 'off',\n 'sonarjs/prefer-specific-assertions': 'off',\n 'sonarjs/no-inverted-boolean-check': 'off',\n};\n"],
5
+ "mappings": "AAaO,MAAMA,EAAsD,CACjE,oCAAqC,CAAC,QAAS,CAAE,kBAAmB,KAAM,kBAAmB,IAAI,CAAE,EAEnG,0CAA2C,CAAC,QAAS,CAAE,WAAY,EAAI,CAAE,EAIzE,qCAAsC,OACtC,0CAA2C,OAC3C,6CA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AAkC,OAElC,sCAAuC,QAe5BC,EAAgD,CAE3D,yCAA0C,CAAC,QAAS,CAAE,iBAAkB,CAAE,UAAW,GAAO,WAAY,EAAK,CAAE,CAAE,EAGjH,oCAAqC,MAErC,mCAAoC,MAEpC,oDAAqD,MAErD,mDAAoD,MAEpD,wCAAyC,MACzC,sCAAuC,MAEvC,+BAAgC,MAChC,qCAAsC,MAEtC,kCAAmC,MACnC,mCAAoC,MAEpC,uCAAwC,MAExC,qCAAsC,MAEtC,mBAAoB,MAMpB,kCAAmC,MACnC,0BAA2B,MAC3B,uBAAwB,MAGxB,8BAA+B,MAE/B,6BAA8B,MAE9B,yBAA0B,MAE1B,+BAAgC,MAEhC,8BAA+B,MAE/B,kCAAmC,MAEnC,wBAAyB,MACzB,0CAA2C,MAC3C,uCAAwC,MACxC,4CAA6C,MAC7C,oDAAqD,MACrD,qCAAsC,MACtC,oCAAqC",
6
+ "names": ["TYPESCRIPT_RULES", "UNICORN_RULES", "SONARJS_RULES", "TEST_RULES"]
7
+ }
package/dist/eslint.js CHANGED
@@ -1,194 +1 @@
1
- /**
2
- * The converged ESLint flat config for a monorepo in the Rexezuge family.
3
- *
4
- * Provenance: the base is Durable-DAV's `eslint.config.mjs` (the most
5
- * elaborate of the nine repos, with the layered `no-restricted-imports` boundary
6
- * rules). Merged in from the stacks that share the same plugin set:
7
- *
8
- * - **Edge-Sonic** — `test/**` is *not* ignored (it is linted like everything else,
9
- * with a narrow override block for Vitest idioms), and `unicorn/prefer-ternary`
10
- * is off. Edge-Sonic is also the source for the dynamic-`import()` boundary
11
- * guard and its `apps/web` layer block.
12
- * - **Mail-Meow** — `prettier/prettier` is an **error**, not a warning.
13
- * - **AWS-AccessBridge** — the `apps/api` DAO/service boundary uses
14
- * `allowTypeImports` where the source repos do not. It is also the source for
15
- * the anchored skip patterns and the symlink-safe walk that came out of its own
16
- * backlog.
17
- * - **CalDAV-Bridge, Mail-Otter, Durable-DAV-Router, Edge-Git, Agent-Router** —
18
- * the `provider-clients` / `webdav`+`dav-store` / `git-protocol`+`git-service`
19
- * layers and the per-client `apps/api` alternatives in the boundary table.
20
- *
21
- * Canonical decisions, and why each one:
22
- *
23
- * 1. **`prettier/prettier: 'error'`.** Three of the four source repos had it at
24
- * `warn`, which under `eslint --quiet` is unenforceable — a gate nobody can see
25
- * is a gate that has never run. Formatting drift is therefore a hard failure.
26
- * 2. **The layered boundary rules are parameterized by `scope`.** Every source
27
- * repo wrote the same blocks with a different npm scope hardcoded; the
28
- * factory takes `scope` (`'@myapp'`) and generates the `@myapp/*` patterns.
29
- * The table itself lives in {@link ./eslint-boundaries.ts} and covers the
30
- * family superset — a repo without a domain package never triggers its ban,
31
- * so no repo needs `extraLayers` for a known package.
32
- * 3. **`test/**` is linted, not ignored.** Durable-DAV/AWS/Mail-Meow ignored it;
33
- * Edge-Sonic does not, and records why: ~200 KB of test code had accumulated
34
- * violations that nothing reported.
35
- * 4. **`apps/web` is a layer in its own right**, banned from every `@scope/*`
36
- * package. Edge-Sonic is the only source with that block; the others had none,
37
- * which is how their layer table's "may import: the browser" was a convention
38
- * rather than a gate. A backend package imported by the SPA compiles and then
39
- * fails at bundle time, with the error pointing at the bundler.
40
- * 5. **jsdom + node globals for web files.** The sources ran `globals.node` only;
41
- * `apps/web` needs browser globals as well, and the vitest config for the SPA
42
- * runs under jsdom, so the lint environment matches the test environment.
43
- * 6. **`eslint-plugin-react-hooks` is NOT imported here.** The kit stays
44
- * zero-dependency, and the plugin belongs to the app that has JSX. A consumer
45
- * appends it — the README shows the four lines.
46
- *
47
- * The rule bodies live in {@link ./eslint-rules.ts} and the boundary table in
48
- * {@link ./eslint-boundaries.ts}; this file is the assembly. A repo that needs a
49
- * boundary the canonical table does not name passes `extraLayers` — see
50
- * {@link RepoLintConfigOptions}.
51
- */
52
- import globals from 'globals';
53
- import tseslint from 'typescript-eslint';
54
- import unicorn from 'eslint-plugin-unicorn';
55
- import { configs as sonarjsConfigs } from 'eslint-plugin-sonarjs';
56
- import pluginRegexp from 'eslint-plugin-regexp';
57
- import eslintConfigPrettier from 'eslint-config-prettier';
58
- import prettier from 'eslint-plugin-prettier';
59
- import { DEFAULT_PROJECT_DIRS, layerBans, restrictedDynamicImports, restrictedImports } from "./eslint-boundaries.js";
60
- import { SONARJS_RULES, TEST_RULES, TYPESCRIPT_RULES, UNICORN_RULES } from "./eslint-rules.js";
61
- /**
62
- * Bridge a third-party preset into `tseslint.config()`.
63
- *
64
- * `sonarjs`' `recommended` preset is typed as a union that includes the legacy
65
- * config shape, which `tseslint.config()` does not accept — but ESLint accepts it
66
- * at runtime, which is the only thing that matters here. One checked assertion,
67
- * rather than forking the plugin's own types.
68
- */
69
- function asConfig(config) {
70
- return config;
71
- }
72
- /**
73
- * Bridge a rule block onto `tseslint.config()`'s `rules` field.
74
- *
75
- * The blocks in `eslint-rules.ts` are written as ESLint expects them —
76
- * `'off' | 'warn' | 'error' | [level, ...options]` — but spelled as data so a
77
- * rule's reason comment sits beside the rule itself. ESLint's own `RuleEntry`
78
- * union is narrower than the data shape, and widening every entry to that union
79
- * would buy nothing; one assertion here, with the reason, is the cheaper and
80
- * more honest of the two.
81
- */
82
- function asRules(block) {
83
- return block;
84
- }
85
- /**
86
- * Build the repo's flat config.
87
- *
88
- * Consumed from the repo root as three lines:
89
- *
90
- * ```js
91
- * // eslint.config.mjs
92
- * import { defineRepoLintConfig } from '@rexezuge/tooling/eslint';
93
- * export default defineRepoLintConfig({ scope: '@myapp' });
94
- * ```
95
- */
96
- export function defineRepoLintConfig(options) {
97
- const { scope } = options;
98
- const projectDirs = options.projectDirs ?? DEFAULT_PROJECT_DIRS;
99
- const canonical = layerBans(scope).filter((layer) => projectDirs.some((dir) => layer.dir.startsWith(dir)));
100
- const extra = options.extraLayers ?? [];
101
- const bans = [...canonical, ...extra];
102
- return tseslint.config({
103
- ignores: [
104
- 'eslint.config.mjs',
105
- 'eslint.config.js',
106
- 'scripts/**',
107
- 'worker-configuration.d.ts',
108
- 'local/**',
109
- 'app/dist/**',
110
- 'apps/web/dist/**',
111
- 'apps/*/dist/**',
112
- 'src/generated/**',
113
- 'apps/api/src/generated/**',
114
- 'coverage/**',
115
- 'coverage-integration/**',
116
- 'coverage-web/**',
117
- 'node_modules/**',
118
- ...(options.extraIgnores ?? []),
119
- ],
120
- },
121
- // Base: globals for all JS/TS source files. Node is the floor because the
122
- // scripts and the workers both run on it; the web block below adds browser
123
- // globals rather than replacing them, so a shared file that touches both
124
- // (there are several in `shared/`) still lints.
125
- {
126
- files: ['**/*.{js,mjs,cjs,ts,mts,cts,tsx,jsx}'],
127
- languageOptions: {
128
- globals: globals.node,
129
- },
130
- },
131
- // Type-aware TS rules, scoped to TS files only.
132
- {
133
- files: ['**/*.{ts,mts,cts,tsx}'],
134
- extends: tseslint.configs.recommendedTypeChecked,
135
- languageOptions: {
136
- parserOptions: {
137
- projectService: true,
138
- tsconfigRootDir: options.tsconfigRootDir ?? process.cwd(),
139
- },
140
- },
141
- },
142
- // --- typescript-eslint overrides (identical in all four source stacks) ---
143
- {
144
- files: ['**/*.{ts,mts,cts,tsx}'],
145
- rules: asRules(TYPESCRIPT_RULES),
146
- },
147
- // --- Unicorn: modern JS/TS quality rules ---
148
- asConfig(unicorn.configs['flat/recommended']), {
149
- rules: asRules(UNICORN_RULES),
150
- },
151
- // --- SonarJS: code smell and bug detection ---
152
- asConfig(sonarjsConfigs.recommended), {
153
- rules: asRules(SONARJS_RULES),
154
- },
155
- // --- Regexp: static analysis for regular expressions ---
156
- asConfig(pluginRegexp.configs['flat/recommended']),
157
- // --- Prettier: formatting drift is a hard error ---
158
- //
159
- // Mail-Meow's decision, adopted repo-wide because the alternative is
160
- // unenforceable: `pnpm run lint` is `eslint --fix --quiet` in three of the
161
- // four source repos, and `--quiet` discards every warning, so a
162
- // `prettier/prettier` *warning* is a silent no-op. 242 files were in that
163
- // state in Edge-Sonic: the gate had never run.
164
- asConfig(eslintConfigPrettier), {
165
- plugins: { prettier },
166
- rules: {
167
- 'prettier/prettier': 'error',
168
- },
169
- },
170
- // --- Import direction guardrails (parameterized by scope) ---
171
- ...restrictedImports(bans), ...restrictedDynamicImports(bans),
172
- // --- Web: browser globals, matching the jsdom test environment ---
173
- //
174
- // The sources linted `apps/web` under `globals.node` only, so `window`,
175
- // `document` and `localStorage` read as undefined globals. The vitest web
176
- // config runs those suites under jsdom; the lint environment should agree
177
- // with the environment the code is executed in, or the rule is reporting
178
- // something untrue about how the file behaves.
179
- {
180
- files: ['apps/web/**/*.{ts,tsx,js,jsx,mts,cts,mjs,cjs}'],
181
- languageOptions: {
182
- globals: { ...globals.node, ...globals.browser },
183
- },
184
- },
185
- // --- Test suite ---
186
- //
187
- // `test/**` is deliberately NOT in the ignores list above. See TEST_RULES
188
- // for the override block and the reasoning behind it.
189
- {
190
- files: ['test/**/*.{ts,tsx,mts,cts}', '**/*.test.{ts,tsx,mts,cts}', '**/*.spec.{ts,tsx,mts,cts}'],
191
- rules: asRules(TEST_RULES),
192
- });
193
- }
194
- //# sourceMappingURL=eslint.js.map
1
+ import t from"globals";import r from"typescript-eslint";import p from"eslint-plugin-unicorn";import{configs as f}from"eslint-plugin-sonarjs";import g from"eslint-plugin-regexp";import l from"eslint-config-prettier";import d from"eslint-plugin-prettier";import{DEFAULT_PROJECT_DIRS as u,layerBans as x,restrictedDynamicImports as j,restrictedImports as R}from"./eslint-boundaries.js";import{SONARJS_RULES as S,TEST_RULES as b,TYPESCRIPT_RULES as C,UNICORN_RULES as E}from"./eslint-rules.js";function y(s){return s}function P(s){return s}function N(s){const{scope:o}=s,i=s.projectDirs??u,n=x(o).filter(a=>i.some(m=>a.dir.startsWith(m))),c=s.extraLayers??[],e=[...n,...c];return r.config({ignores:["eslint.config.mjs","eslint.config.js","scripts/**","worker-configuration.d.ts","local/**","app/dist/**","apps/web/dist/**","apps/*/dist/**","src/generated/**","apps/api/src/generated/**","coverage/**","coverage-integration/**","coverage-web/**","node_modules/**",...s.extraIgnores??[]]},{files:["**/*.{js,mjs,cjs,ts,mts,cts,tsx,jsx}"],languageOptions:{globals:t.node}},{files:["**/*.{ts,mts,cts,tsx}"],extends:r.configs.recommendedTypeChecked,languageOptions:{parserOptions:{projectService:!0,tsconfigRootDir:s.tsconfigRootDir??process.cwd()}}},{files:["**/*.{ts,mts,cts,tsx}"],rules:C},p.configs["flat/recommended"],{rules:E},f.recommended,{rules:S},g.configs["flat/recommended"],l,{plugins:{prettier:d},rules:{"prettier/prettier":"error"}},...R(e),...j(e),{files:["apps/web/**/*.{ts,tsx,js,jsx,mts,cts,mjs,cjs}"],languageOptions:{globals:{...t.node,...t.browser}}},{files:["test/**/*.{ts,tsx,mts,cts}","**/*.test.{ts,tsx,mts,cts}","**/*.spec.{ts,tsx,mts,cts}"],rules:b})}export{N as defineRepoLintConfig};
@@ -1 +1,7 @@
1
- {"version":3,"file":"eslint.js","sourceRoot":"","sources":["../src/eslint.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AAEH,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,QAAQ,MAAM,mBAAmB,CAAC;AACzC,OAAO,OAAO,MAAM,uBAAuB,CAAC;AAC5C,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,YAAY,MAAM,sBAAsB,CAAC;AAChD,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAC1D,OAAO,QAAQ,MAAM,wBAAwB,CAAC;AAE9C,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEtH,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAgD/F;;;;;;;GAOG;AACH,SAAS,QAAQ,CAAC,MAAmB;IACnC,OAAO,MAAqB,CAAC;AAC/B,CAAC;AAED;;;;;;;;;GASG;A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,KAAK,EAAE,OAAO,CAAC,UAAU,CAAC;KAC3B,CACF,CAAC;AACJ,CAAC","sourcesContent":["/**\n * The converged ESLint flat config for a monorepo in the Rexezuge family.\n *\n * Provenance: the base is Durable-DAV's `eslint.config.mjs` (the most\n * elaborate of the nine repos, with the layered `no-restricted-imports` boundary\n * rules). Merged in from the stacks that share the same plugin set:\n *\n * - **Edge-Sonic** — `test/**` is *not* ignored (it is linted like everything else,\n * with a narrow override block for Vitest idioms), and `unicorn/prefer-ternary`\n * is off. Edge-Sonic is also the source for the dynamic-`import()` boundary\n * guard and its `apps/web` layer block.\n * - **Mail-Meow** — `prettier/prettier` is an **error**, not a warning.\n * - **AWS-AccessBridge** — the `apps/api` DAO/service boundary uses\n * `allowTypeImports` where the source repos do not. It is also the source for\n * the anchored skip patterns and the symlink-safe walk that came out of its own\n * backlog.\n * - **CalDAV-Bridge, Mail-Otter, Durable-DAV-Router, Edge-Git, Agent-Router** —\n * the `provider-clients` / `webdav`+`dav-store` / `git-protocol`+`git-service`\n * layers and the per-client `apps/api` alternatives in the boundary table.\n *\n * Canonical decisions, and why each one:\n *\n * 1. **`prettier/prettier: 'error'`.** Three of the four source repos had it at\n * `warn`, which under `eslint --quiet` is unenforceable — a gate nobody can see\n * is a gate that has never run. Formatting drift is therefore a hard failure.\n * 2. **The layered boundary rules are parameterized by `scope`.** Every source\n * repo wrote the same blocks with a different npm scope hardcoded; the\n * factory takes `scope` (`'@myapp'`) and generates the `@myapp/*` patterns.\n * The table itself lives in {@link ./eslint-boundaries.ts} and covers the\n * family superset — a repo without a domain package never triggers its ban,\n * so no repo needs `extraLayers` for a known package.\n * 3. **`test/**` is linted, not ignored.** Durable-DAV/AWS/Mail-Meow ignored it;\n * Edge-Sonic does not, and records why: ~200 KB of test code had accumulated\n * violations that nothing reported.\n * 4. **`apps/web` is a layer in its own right**, banned from every `@scope/*`\n * package. Edge-Sonic is the only source with that block; the others had none,\n * which is how their layer table's \"may import: the browser\" was a convention\n * rather than a gate. A backend package imported by the SPA compiles and then\n * fails at bundle time, with the error pointing at the bundler.\n * 5. **jsdom + node globals for web files.** The sources ran `globals.node` only;\n * `apps/web` needs browser globals as well, and the vitest config for the SPA\n * runs under jsdom, so the lint environment matches the test environment.\n * 6. **`eslint-plugin-react-hooks` is NOT imported here.** The kit stays\n * zero-dependency, and the plugin belongs to the app that has JSX. A consumer\n * appends it — the README shows the four lines.\n *\n * The rule bodies live in {@link ./eslint-rules.ts} and the boundary table in\n * {@link ./eslint-boundaries.ts}; this file is the assembly. A repo that needs a\n * boundary the canonical table does not name passes `extraLayers` — see\n * {@link RepoLintConfigOptions}.\n */\n\nimport globals from 'globals';\nimport tseslint from 'typescript-eslint';\nimport unicorn from 'eslint-plugin-unicorn';\nimport { configs as sonarjsConfigs } from 'eslint-plugin-sonarjs';\nimport pluginRegexp from 'eslint-plugin-regexp';\nimport eslintConfigPrettier from 'eslint-config-prettier';\nimport prettier from 'eslint-plugin-prettier';\nimport type { FlatConfig } from 'typescript-eslint';\nimport { DEFAULT_PROJECT_DIRS, layerBans, restrictedDynamicImports, restrictedImports } from './eslint-boundaries.ts';\nimport type { LayerBan } from './eslint-boundaries.ts';\nimport { SONARJS_RULES, TEST_RULES, TYPESCRIPT_RULES, UNICORN_RULES } from './eslint-rules.ts';\n\n/**\n * What `defineRepoLintConfig` accepts.\n */\nexport interface RepoLintConfigOptions {\n /**\n * The consuming repo's npm scope, e.g. `'@myapp'`. Every `no-restricted-imports`\n * pattern in the boundary rules is derived from it, so the same factory serves\n * all nine repos.\n */\n readonly scope: string;\n /**\n * The workspace directories the layered boundary rules are scoped to, as repo-\n * relative globs. Defaults to the canonical layout the nine repos share.\n */\n readonly projectDirs?: readonly string[];\n /**\n * Extra ignore globs, merged with the canonical set.\n */\n readonly extraIgnores?: readonly string[];\n /**\n * Where `projectService` resolves the tsconfig from. Defaults to the directory\n * ESLint is invoked in, which is the repo root in every CI job.\n */\n readonly tsconfigRootDir?: string;\n /**\n * Extra boundary layers, appended to the canonical table.\n *\n * The escape valve for a repo whose layout has a boundary the canonical table\n * does not name — AWS-AccessBridge's `apps/api/src/endpoints/**` rule (\"route\n * classes must not import DAOs directly\") and its `aws4fetch` ban are the shape.\n * Same {@link LayerBan} form, so `extraLayers` flows through the\n * `no-restricted-imports` and the `no-restricted-syntax` guard alike.\n */\n readonly extraLayers?: readonly LayerBan[];\n}\n\n/**\n * One argument to `tseslint.config()`.\n */\ntype ConfigInput = Parameters<typeof tseslint.config>[number];\n\n/**\n * A plugin preset or config object as the source repos pass it.\n */\ntype MaybeConfig = FlatConfig.Config | readonly FlatConfig.Config[];\n\n/**\n * Bridge a third-party preset into `tseslint.config()`.\n *\n * `sonarjs`' `recommended` preset is typed as a union that includes the legacy\n * config shape, which `tseslint.config()` does not accept — but ESLint accepts it\n * at runtime, which is the only thing that matters here. One checked assertion,\n * rather than forking the plugin's own types.\n */\nfunction asConfig(config: MaybeConfig): ConfigInput {\n return config as ConfigInput;\n}\n\n/**\n * Bridge a rule block onto `tseslint.config()`'s `rules` field.\n *\n * The blocks in `eslint-rules.ts` are written as ESLint expects them —\n * `'off' | 'warn' | 'error' | [level, ...options]` — but spelled as data so a\n * rule's reason comment sits beside the rule itself. ESLint's own `RuleEntry`\n * union is narrower than the data shape, and widening every entry to that union\n * would buy nothing; one assertion here, with the reason, is the cheaper and\n * more honest of the two.\n */\nfunction asRules(block: Readonly<Record<string, unknown>>): FlatConfig.Config['rules'] {\n return block as FlatConfig.Config['rules'];\n}\n\n/**\n * Build the repo's flat config.\n *\n * Consumed from the repo root as three lines:\n *\n * ```js\n * // eslint.config.mjs\n * import { defineRepoLintConfig } from '@rexezuge/tooling/eslint';\n * export default defineRepoLintConfig({ scope: '@myapp' });\n * ```\n */\nexport function defineRepoLintConfig(options: RepoLintConfigOptions): FlatConfig.ConfigArray {\n const { scope } = options;\n const projectDirs = options.projectDirs ?? DEFAULT_PROJECT_DIRS;\n const canonical = layerBans(scope).filter((layer) => projectDirs.some((dir) => layer.dir.startsWith(dir)));\n const extra = options.extraLayers ?? [];\n const bans = [...canonical, ...extra];\n\n return tseslint.config(\n {\n ignores: [\n 'eslint.config.mjs',\n 'eslint.config.js',\n 'scripts/**',\n 'worker-configuration.d.ts',\n 'local/**',\n 'app/dist/**',\n 'apps/web/dist/**',\n 'apps/*/dist/**',\n 'src/generated/**',\n 'apps/api/src/generated/**',\n 'coverage/**',\n 'coverage-integration/**',\n 'coverage-web/**',\n 'node_modules/**',\n ...(options.extraIgnores ?? []),\n ],\n },\n\n // Base: globals for all JS/TS source files. Node is the floor because the\n // scripts and the workers both run on it; the web block below adds browser\n // globals rather than replacing them, so a shared file that touches both\n // (there are several in `shared/`) still lints.\n {\n files: ['**/*.{js,mjs,cjs,ts,mts,cts,tsx,jsx}'],\n languageOptions: {\n globals: globals.node,\n },\n },\n\n // Type-aware TS rules, scoped to TS files only.\n {\n files: ['**/*.{ts,mts,cts,tsx}'],\n extends: tseslint.configs.recommendedTypeChecked,\n languageOptions: {\n parserOptions: {\n projectService: true,\n tsconfigRootDir: options.tsconfigRootDir ?? process.cwd(),\n },\n },\n },\n\n // --- typescript-eslint overrides (identical in all four source stacks) ---\n {\n files: ['**/*.{ts,mts,cts,tsx}'],\n rules: asRules(TYPESCRIPT_RULES),\n },\n\n // --- Unicorn: modern JS/TS quality rules ---\n asConfig(unicorn.configs['flat/recommended']),\n {\n rules: asRules(UNICORN_RULES),\n },\n\n // --- SonarJS: code smell and bug detection ---\n asConfig(sonarjsConfigs.recommended),\n {\n rules: asRules(SONARJS_RULES),\n },\n\n // --- Regexp: static analysis for regular expressions ---\n asConfig(pluginRegexp.configs['flat/recommended']),\n\n // --- Prettier: formatting drift is a hard error ---\n //\n // Mail-Meow's decision, adopted repo-wide because the alternative is\n // unenforceable: `pnpm run lint` is `eslint --fix --quiet` in three of the\n // four source repos, and `--quiet` discards every warning, so a\n // `prettier/prettier` *warning* is a silent no-op. 242 files were in that\n // state in Edge-Sonic: the gate had never run.\n asConfig(eslintConfigPrettier),\n {\n plugins: { prettier },\n rules: {\n 'prettier/prettier': 'error',\n },\n },\n\n // --- Import direction guardrails (parameterized by scope) ---\n ...restrictedImports(bans),\n ...restrictedDynamicImports(bans),\n\n // --- Web: browser globals, matching the jsdom test environment ---\n //\n // The sources linted `apps/web` under `globals.node` only, so `window`,\n // `document` and `localStorage` read as undefined globals. The vitest web\n // config runs those suites under jsdom; the lint environment should agree\n // with the environment the code is executed in, or the rule is reporting\n // something untrue about how the file behaves.\n {\n files: ['apps/web/**/*.{ts,tsx,js,jsx,mts,cts,mjs,cjs}'],\n languageOptions: {\n globals: { ...globals.node, ...globals.browser },\n },\n },\n\n // --- Test suite ---\n //\n // `test/**` is deliberately NOT in the ignores list above. See TEST_RULES\n // for the override block and the reasoning behind it.\n {\n files: ['test/**/*.{ts,tsx,mts,cts}', '**/*.test.{ts,tsx,mts,cts}', '**/*.spec.{ts,tsx,mts,cts}'],\n rules: asRules(TEST_RULES),\n },\n );\n}\n"]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/eslint.ts"],
4
+ "sourcesContent": ["/**\n * The converged ESLint flat config for a monorepo in the Rexezuge family.\n *\n * Provenance: the base is Durable-DAV's `eslint.config.mjs` (the most\n * elaborate of the nine repos, with the layered `no-restricted-imports` boundary\n * rules). Merged in from the stacks that share the same plugin set:\n *\n * - **Edge-Sonic** — `test/**` is *not* ignored (it is linted like everything else,\n * with a narrow override block for Vitest idioms), and `unicorn/prefer-ternary`\n * is off. Edge-Sonic is also the source for the dynamic-`import()` boundary\n * guard and its `apps/web` layer block.\n * - **Mail-Meow** — `prettier/prettier` is an **error**, not a warning.\n * - **AWS-AccessBridge** — the `apps/api` DAO/service boundary uses\n * `allowTypeImports` where the source repos do not. It is also the source for\n * the anchored skip patterns and the symlink-safe walk that came out of its own\n * backlog.\n * - **CalDAV-Bridge, Mail-Otter, Durable-DAV-Router, Edge-Git, Agent-Router** —\n * the `provider-clients` / `webdav`+`dav-store` / `git-protocol`+`git-service`\n * layers and the per-client `apps/api` alternatives in the boundary table.\n *\n * Canonical decisions, and why each one:\n *\n * 1. **`prettier/prettier: 'error'`.** Three of the four source repos had it at\n * `warn`, which under `eslint --quiet` is unenforceable — a gate nobody can see\n * is a gate that has never run. Formatting drift is therefore a hard failure.\n * 2. **The layered boundary rules are parameterized by `scope`.** Every source\n * repo wrote the same blocks with a different npm scope hardcoded; the\n * factory takes `scope` (`'@myapp'`) and generates the `@myapp/*` patterns.\n * The table itself lives in {@link ./eslint-boundaries.ts} and covers the\n * family superset — a repo without a domain package never triggers its ban,\n * so no repo needs `extraLayers` for a known package.\n * 3. **`test/**` is linted, not ignored.** Durable-DAV/AWS/Mail-Meow ignored it;\n * Edge-Sonic does not, and records why: ~200 KB of test code had accumulated\n * violations that nothing reported.\n * 4. **`apps/web` is a layer in its own right**, banned from every `@scope/*`\n * package. Edge-Sonic is the only source with that block; the others had none,\n * which is how their layer table's \"may import: the browser\" was a convention\n * rather than a gate. A backend package imported by the SPA compiles and then\n * fails at bundle time, with the error pointing at the bundler.\n * 5. **jsdom + node globals for web files.** The sources ran `globals.node` only;\n * `apps/web` needs browser globals as well, and the vitest config for the SPA\n * runs under jsdom, so the lint environment matches the test environment.\n * 6. **`eslint-plugin-react-hooks` is NOT imported here.** The kit stays\n * zero-dependency, and the plugin belongs to the app that has JSX. A consumer\n * appends it — the README shows the four lines.\n *\n * The rule bodies live in {@link ./eslint-rules.ts} and the boundary table in\n * {@link ./eslint-boundaries.ts}; this file is the assembly. A repo that needs a\n * boundary the canonical table does not name passes `extraLayers` — see\n * {@link RepoLintConfigOptions}.\n */\n\nimport globals from 'globals';\nimport tseslint from 'typescript-eslint';\nimport unicorn from 'eslint-plugin-unicorn';\nimport { configs as sonarjsConfigs } from 'eslint-plugin-sonarjs';\nimport pluginRegexp from 'eslint-plugin-regexp';\nimport eslintConfigPrettier from 'eslint-config-prettier';\nimport prettier from 'eslint-plugin-prettier';\nimport type { FlatConfig } from 'typescript-eslint';\nimport { DEFAULT_PROJECT_DIRS, layerBans, restrictedDynamicImports, restrictedImports } from './eslint-boundaries.ts';\nimport type { LayerBan } from './eslint-boundaries.ts';\nimport { SONARJS_RULES, TEST_RULES, TYPESCRIPT_RULES, UNICORN_RULES } from './eslint-rules.ts';\n\n/**\n * What `defineRepoLintConfig` accepts.\n */\nexport interface RepoLintConfigOptions {\n /**\n * The consuming repo's npm scope, e.g. `'@myapp'`. Every `no-restricted-imports`\n * pattern in the boundary rules is derived from it, so the same factory serves\n * all nine repos.\n */\n readonly scope: string;\n /**\n * The workspace directories the layered boundary rules are scoped to, as repo-\n * relative globs. Defaults to the canonical layout the nine repos share.\n */\n readonly projectDirs?: readonly string[];\n /**\n * Extra ignore globs, merged with the canonical set.\n */\n readonly extraIgnores?: readonly string[];\n /**\n * Where `projectService` resolves the tsconfig from. Defaults to the directory\n * ESLint is invoked in, which is the repo root in every CI job.\n */\n readonly tsconfigRootDir?: string;\n /**\n * Extra boundary layers, appended to the canonical table.\n *\n * The escape valve for a repo whose layout has a boundary the canonical table\n * does not name — AWS-AccessBridge's `apps/api/src/endpoints/**` rule (\"route\n * classes must not import DAOs directly\") and its `aws4fetch` ban are the shape.\n * Same {@link LayerBan} form, so `extraLayers` flows through the\n * `no-restricted-imports` and the `no-restricted-syntax` guard alike.\n */\n readonly extraLayers?: readonly LayerBan[];\n}\n\n/**\n * One argument to `tseslint.config()`.\n */\ntype ConfigInput = Parameters<typeof tseslint.config>[number];\n\n/**\n * A plugin preset or config object as the source repos pass it.\n */\ntype MaybeConfig = FlatConfig.Config | readonly FlatConfig.Config[];\n\n/**\n * Bridge a third-party preset into `tseslint.config()`.\n *\n * `sonarjs`' `recommended` preset is typed as a union that includes the legacy\n * config shape, which `tseslint.config()` does not accept — but ESLint accepts it\n * at runtime, which is the only thing that matters here. One checked assertion,\n * rather than forking the plugin's own types.\n */\nfunction asConfig(config: MaybeConfig): ConfigInput {\n return config as ConfigInput;\n}\n\n/**\n * Bridge a rule block onto `tseslint.config()`'s `rules` field.\n *\n * The blocks in `eslint-rules.ts` are written as ESLint expects them —\n * `'off' | 'warn' | 'error' | [level, ...options]` — but spelled as data so a\n * rule's reason comment sits beside the rule itself. ESLint's own `RuleEntry`\n * union is narrower than the data shape, and widening every entry to that union\n * would buy nothing; one assertion here, with the reason, is the cheaper and\n * more honest of the two.\n */\nfunction asRules(block: Readonly<Record<string, unknown>>): FlatConfig.Config['rules'] {\n return block as FlatConfig.Config['rules'];\n}\n\n/**\n * Build the repo's flat config.\n *\n * Consumed from the repo root as three lines:\n *\n * ```js\n * // eslint.config.mjs\n * import { defineRepoLintConfig } from '@rexezuge/tooling/eslint';\n * export default defineRepoLintConfig({ scope: '@myapp' });\n * ```\n */\nexport function defineRepoLintConfig(options: RepoLintConfigOptions): FlatConfig.ConfigArray {\n const { scope } = options;\n const projectDirs = options.projectDirs ?? DEFAULT_PROJECT_DIRS;\n const canonical = layerBans(scope).filter((layer) => projectDirs.some((dir) => layer.dir.startsWith(dir)));\n const extra = options.extraLayers ?? [];\n const bans = [...canonical, ...extra];\n\n return tseslint.config(\n {\n ignores: [\n 'eslint.config.mjs',\n 'eslint.config.js',\n 'scripts/**',\n 'worker-configuration.d.ts',\n 'local/**',\n 'app/dist/**',\n 'apps/web/dist/**',\n 'apps/*/dist/**',\n 'src/generated/**',\n 'apps/api/src/generated/**',\n 'coverage/**',\n 'coverage-integration/**',\n 'coverage-web/**',\n 'node_modules/**',\n ...(options.extraIgnores ?? []),\n ],\n },\n\n // Base: globals for all JS/TS source files. Node is the floor because the\n // scripts and the workers both run on it; the web block below adds browser\n // globals rather than replacing them, so a shared file that touches both\n // (there are several in `shared/`) still lints.\n {\n files: ['**/*.{js,mjs,cjs,ts,mts,cts,tsx,jsx}'],\n languageOptions: {\n globals: globals.node,\n },\n },\n\n // Type-aware TS rules, scoped to TS files only.\n {\n files: ['**/*.{ts,mts,cts,tsx}'],\n extends: tseslint.configs.recommendedTypeChecked,\n languageOptions: {\n parserOptions: {\n projectService: true,\n tsconfigRootDir: options.tsconfigRootDir ?? process.cwd(),\n },\n },\n },\n\n // --- typescript-eslint overrides (identical in all four source stacks) ---\n {\n files: ['**/*.{ts,mts,cts,tsx}'],\n rules: asRules(TYPESCRIPT_RULES),\n },\n\n // --- Unicorn: modern JS/TS quality rules ---\n asConfig(unicorn.configs['flat/recommended']),\n {\n rules: asRules(UNICORN_RULES),\n },\n\n // --- SonarJS: code smell and bug detection ---\n asConfig(sonarjsConfigs.recommended),\n {\n rules: asRules(SONARJS_RULES),\n },\n\n // --- Regexp: static analysis for regular expressions ---\n asConfig(pluginRegexp.configs['flat/recommended']),\n\n // --- Prettier: formatting drift is a hard error ---\n //\n // Mail-Meow's decision, adopted repo-wide because the alternative is\n // unenforceable: `pnpm run lint` is `eslint --fix --quiet` in three of the\n // four source repos, and `--quiet` discards every warning, so a\n // `prettier/prettier` *warning* is a silent no-op. 242 files were in that\n // state in Edge-Sonic: the gate had never run.\n asConfig(eslintConfigPrettier),\n {\n plugins: { prettier },\n rules: {\n 'prettier/prettier': 'error',\n },\n },\n\n // --- Import direction guardrails (parameterized by scope) ---\n ...restrictedImports(bans),\n ...restrictedDynamicImports(bans),\n\n // --- Web: browser globals, matching the jsdom test environment ---\n //\n // The sources linted `apps/web` under `globals.node` only, so `window`,\n // `document` and `localStorage` read as undefined globals. The vitest web\n // config runs those suites under jsdom; the lint environment should agree\n // with the environment the code is executed in, or the rule is reporting\n // something untrue about how the file behaves.\n {\n files: ['apps/web/**/*.{ts,tsx,js,jsx,mts,cts,mjs,cjs}'],\n languageOptions: {\n globals: { ...globals.node, ...globals.browser },\n },\n },\n\n // --- Test suite ---\n //\n // `test/**` is deliberately NOT in the ignores list above. See TEST_RULES\n // for the override block and the reasoning behind it.\n {\n files: ['test/**/*.{ts,tsx,mts,cts}', '**/*.test.{ts,tsx,mts,cts}', '**/*.spec.{ts,tsx,mts,cts}'],\n rules: asRules(TEST_RULES),\n },\n );\n}\n"],
5
+ "mappings": "AAoDA,OAAOA,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O,CACL,oBAAqB,UAKzB,GAAGI,EAAkBiB,CAAI,EACzB,GAAGlB,EAAyBkB,CAAI,EAShC,CACE,MAAO,CAAC,+CAA+C,EACvD,gBAAiB,CACf,QAAS,CAAE,GAAG3B,EAAQ,KAAM,GAAGA,EAAQ,OAAO,IAQlD,CACE,MAAO,CAAC,6BAA8B,6BAA8B,4BAA4B,EAChG,MAAeY,EAChB,CAEL",
6
+ "names": ["globals", "tseslint", "unicorn", "sonarjsConfigs", "pluginRegexp", "eslintConfigPrettier", "prettier", "DEFAULT_PROJECT_DIRS", "layerBans", "restrictedDynamicImports", "restrictedImports", "SONARJS_RULES", "TEST_RULES", "TYPESCRIPT_RULES", "UNICORN_RULES", "asConfig", "config", "asRules", "block", "defineRepoLintConfig", "options", "scope", "projectDirs", "canonical", "layer", "dir", "extra", "bans"]
7
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"pages-proxy.d.ts","sourceRoot":"","sources":["../../src/functions/pages-proxy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AAEH;;;;;;GAMG;AACH,MAAM,WAAW,OAAO;IACtB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,GAAG,OAAO,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;CAC7E;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;CAC9B;AAED;;;;;;GAMG;AACH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,GAAG,EAAE,aAAa,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,EAAE,oBAAoB,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AAgCjF;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;;;OAMG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,OAAO,CAAC;CACpC;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,iBAAsB,GAAG,aAAa,CAuC/E"}
1
+ {"version":3,"file":"pages-proxy.d.ts","sourceRoot":"","sources":["../../src/functions/pages-proxy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AAEH;;;;;;GAMG;AACH,MAAM,WAAW,OAAO;IACtB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,GAAG,OAAO,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;CAC7E;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;CAC9B;AAED;;;;;;GAMG;AACH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,GAAG,EAAE,aAAa,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,EAAE,oBAAoB,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AAkCjF;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;;;OAMG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,OAAO,CAAC;CACpC;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,iBAAsB,GAAG,aAAa,CAuC/E"}
@@ -1,131 +1 @@
1
- /**
2
- * The Cloudflare Pages catch-all proxy.
3
- *
4
- * Provenance: the `functions/[[path]].ts` shim duplicated in Durable-DAV,
5
- * Mail-Meow and Edge-Git (and present in nine repos in total). Each copy is an
6
- * `onRequest` handler that forwards the request to the API worker through a
7
- * service binding, rewriting the three headers the worker routes on.
8
- *
9
- * What each source contributes:
10
- *
11
- * - **Durable-DAV / Edge-Git** — the core shape: set `X-Forwarded-Host`,
12
- * `X-Forwarded-Proto` and `X-Forwarded-Uri` from the original URL, forward the
13
- * body for non-GET/HEAD methods, and hand the request to `env.API_WORKER`.
14
- * - **Mail-Meow** — the hop-by-hop header strip, and the decision to *always*
15
- * delete `X-Forwarded-For` before conditionally setting it from
16
- * `CF-Connecting-IP`. Setting it only when the header was present left a
17
- * caller-supplied value intact on any request that reached Pages without
18
- * `CF-Connecting-IP`, so the origin would trust an attacker-chosen client IP.
19
- * - **Durable-DAV-Router** — `duplex: 'half'`, required whenever the forwarded
20
- * body is a stream. Without it this threw a `TypeError` on every non-GET
21
- * request rather than proxying it.
22
- * - **Edge-Sonic** — the client-forwarding-header strip list, which additionally
23
- * removes `Forwarded`, `True-Client-IP` and `X-Real-Ip`. Edge-Sonic goes
24
- * further and *never* sets `X-Forwarded-For` at all, because its worker keys
25
- * the rate limiter on `CF-Connecting-IP` and refuses `X-Forwarded-For` on
26
- * purpose.
27
- *
28
- * ### The convergence decision on `X-Forwarded-For`
29
- *
30
- * The two families disagree, and the disagreement is about which worker is
31
- * behind the binding. Mail-Meow's behaviour is kept as the default because it is
32
- * the only one that preserves the client IP for the audit trail, which five repos
33
- * read. A repo whose worker refuses the header — Edge-Sonic's — passes
34
- * `forwardClientIp: false`, which deletes it and sets nothing. What is *not*
35
- * available is the source repos' conditional `if (clientIp) set(...)`: that is
36
- * the defect Mail-Meow recorded fixing, and a factory that could reintroduce it
37
- * would be a factory that carries the bug forward.
38
- *
39
- * ### `duplex: 'half'` rides with the body
40
- *
41
- * Required by the Fetch spec whenever a `Request` is constructed with a **stream**
42
- * body. workerd does not throw without it, which is why the line was absent from
43
- * every Pages copy — and Node does, which is why `test/pages-proxy.test.ts` in
44
- * Edge-Sonic could not drive the handler at all. It is spread only where a body
45
- * is forwarded, because a `RequestInit` carrying `duplex` and no body is a shape
46
- * no runtime documents; the cast is `as RequestInit` either way, since `duplex`
47
- * is not in the DOM lib's type.
48
- *
49
- * The result is a handler factory, so a consumer's `functions/[[path]].ts` is a
50
- * one-line re-export. Structural `Fetcher` and `PagesFunction` types are declared
51
- * here rather than imported from `@cloudflare/workers-types`, so the kit stays
52
- * zero-dependency and this module typechecks without the generated
53
- * `worker-configuration.d.ts`.
54
- */
55
- /**
56
- * Headers a *client* may have set, stripped before the request crosses the
57
- * binding.
58
- *
59
- * These describe the connection between the client and the proxy. Forwarding
60
- * them would let the origin believe the proxy's view of the client is the
61
- * client's own claim about itself. The three the proxy sets itself are set from
62
- * values it reads off the request, not from the client's headers.
63
- */
64
- const CLIENT_FORWARDING_HEADERS = [
65
- 'connection',
66
- 'keep-alive',
67
- 'proxy-authenticate',
68
- 'proxy-authorization',
69
- 'te',
70
- 'trailer',
71
- 'transfer-encoding',
72
- 'upgrade',
73
- 'X-Forwarded-For',
74
- 'X-Forwarded-Host',
75
- 'X-Forwarded-Proto',
76
- 'X-Forwarded-Uri',
77
- 'Forwarded',
78
- 'True-Client-IP',
79
- 'X-Real-Ip',
80
- ];
81
- /** The header Cloudflare sets with the socket's peer address. */
82
- const CF_CONNECTING_IP_HEADER = 'CF-Connecting-IP';
83
- /**
84
- * The `onRequest` handler for `functions/[[path]].ts`.
85
- *
86
- * Usage — the consumer's `functions/[[path]].ts` becomes two lines:
87
- *
88
- * ```ts
89
- * import { createPagesProxy } from '@rexezuge/tooling/functions/pages-proxy';
90
- * export const onRequest = createPagesProxy();
91
- * ```
92
- *
93
- * @param options see {@link PagesProxyOptions}. Omitted gives the family's
94
- * majority behaviour.
95
- */
96
- export function createPagesProxy(options = {}) {
97
- const forwardClientIp = options.forwardClientIp ?? true;
98
- return async ({ request, env }) => {
99
- const originalUrl = new URL(request.url);
100
- const headers = new Headers(request.headers);
101
- for (const header of CLIENT_FORWARDING_HEADERS)
102
- headers.delete(header);
103
- // Set from values read off the request rather than from the client: only the
104
- // proxy knows which host it served, and a service binding hands over a
105
- // rewritten URL, so the original path is what has to be carried across.
106
- headers.set('X-Forwarded-Host', originalUrl.host);
107
- headers.set('X-Forwarded-Proto', originalUrl.protocol.replace(':', ''));
108
- headers.set('X-Forwarded-Uri', `${originalUrl.pathname}${originalUrl.search}`);
109
- if (forwardClientIp) {
110
- const clientIp = request.headers.get(CF_CONNECTING_IP_HEADER);
111
- if (clientIp)
112
- headers.set('X-Forwarded-For', clientIp);
113
- }
114
- // `GET`/`HEAD` carry no body, and a `Request` with one is rejected outright
115
- // for those methods. The body is forwarded as a *stream*, so a large upload
116
- // does not have to fit in memory on the Pages side.
117
- const hasBody = request.method !== 'GET' && request.method !== 'HEAD';
118
- const proxyRequest = new Request(originalUrl.href, {
119
- method: request.method,
120
- headers,
121
- body: hasBody ? request.body : undefined,
122
- // See the header: `duplex` is not in the DOM lib's `RequestInit` type, and
123
- // removing the cast would mean not forwarding bodies at all, which is a
124
- // worse answer than one assertion.
125
- ...(hasBody && { duplex: 'half' }),
126
- redirect: request.redirect,
127
- });
128
- return env.API_WORKER.fetch(proxyRequest);
129
- };
130
- }
131
- //# sourceMappingURL=pages-proxy.js.map
1
+ const s=["connection","keep-alive","proxy-authenticate","proxy-authorization","te","trailer","transfer-encoding","upgrade","X-Forwarded-For","X-Forwarded-Host","X-Forwarded-Proto","X-Forwarded-Uri","Forwarded","True-Client-IP","X-Real-Ip"],h="CF-Connecting-IP";function l(n={}){const a=n.forwardClientIp??!0;return async({request:e,env:c})=>{const o=new URL(e.url),r=new Headers(e.headers);for(const t of s)r.delete(t);if(r.set("X-Forwarded-Host",o.host),r.set("X-Forwarded-Proto",o.protocol.replace(":","")),r.set("X-Forwarded-Uri",`${o.pathname}${o.search}`),a){const t=e.headers.get(h);t&&r.set("X-Forwarded-For",t)}const d=e.method!=="GET"&&e.method!=="HEAD",i=new Request(o.href,{method:e.method,headers:r,body:d?e.body:void 0,...d&&{duplex:"half"},redirect:e.redirect});return c.API_WORKER.fetch(i)}}export{l as createPagesProx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G,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC;QAE/E,IAAI,eAAe,EAAE,CAAC;YACpB,MAAM,QAAQ,GAAkB,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;YAC7E,IAAI,QAAQ;gBAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE,QAAQ,CAAC,CAAC;QACzD,CAAC;QAED,4EAA4E;QAC5E,4EAA4E;QAC5E,oDAAoD;QACpD,MAAM,OAAO,GAAY,OAAO,CAAC,MAAM,KAAK,KAAK,IAAI,OAAO,CAAC,MAAM,KAAK,MAAM,CAAC;QAE/E,MAAM,YAAY,GAAY,IAAI,OAAO,CAAC,WAAW,CAAC,IAAI,EAAE;YAC1D,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,OAAO;YACP,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;YACxC,2EAA2E;YAC3E,wEAAwE;YACxE,mCAAmC;YACnC,GAAG,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;YAClC,QAAQ,EAAE,OAAO,CAAC,QAAQ;SACZ,CAAC,CAAC;QAElB,OAAO,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IAC5C,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/**\n * The Cloudflare Pages catch-all proxy.\n *\n * Provenance: the `functions/[[path]].ts` shim duplicated in Durable-DAV,\n * Mail-Meow and Edge-Git (and present in nine repos in total). Each copy is an\n * `onRequest` handler that forwards the request to the API worker through a\n * service binding, rewriting the three headers the worker routes on.\n *\n * What each source contributes:\n *\n * - **Durable-DAV / Edge-Git** — the core shape: set `X-Forwarded-Host`,\n * `X-Forwarded-Proto` and `X-Forwarded-Uri` from the original URL, forward the\n * body for non-GET/HEAD methods, and hand the request to `env.API_WORKER`.\n * - **Mail-Meow** — the hop-by-hop header strip, and the decision to *always*\n * delete `X-Forwarded-For` before conditionally setting it from\n * `CF-Connecting-IP`. Setting it only when the header was present left a\n * caller-supplied value intact on any request that reached Pages without\n * `CF-Connecting-IP`, so the origin would trust an attacker-chosen client IP.\n * - **Durable-DAV-Router** — `duplex: 'half'`, required whenever the forwarded\n * body is a stream. Without it this threw a `TypeError` on every non-GET\n * request rather than proxying it.\n * - **Edge-Sonic** — the client-forwarding-header strip list, which additionally\n * removes `Forwarded`, `True-Client-IP` and `X-Real-Ip`. Edge-Sonic goes\n * further and *never* sets `X-Forwarded-For` at all, because its worker keys\n * the rate limiter on `CF-Connecting-IP` and refuses `X-Forwarded-For` on\n * purpose.\n *\n * ### The convergence decision on `X-Forwarded-For`\n *\n * The two families disagree, and the disagreement is about which worker is\n * behind the binding. Mail-Meow's behaviour is kept as the default because it is\n * the only one that preserves the client IP for the audit trail, which five repos\n * read. A repo whose worker refuses the header — Edge-Sonic's — passes\n * `forwardClientIp: false`, which deletes it and sets nothing. What is *not*\n * available is the source repos' conditional `if (clientIp) set(...)`: that is\n * the defect Mail-Meow recorded fixing, and a factory that could reintroduce it\n * would be a factory that carries the bug forward.\n *\n * ### `duplex: 'half'` rides with the body\n *\n * Required by the Fetch spec whenever a `Request` is constructed with a **stream**\n * body. workerd does not throw without it, which is why the line was absent from\n * every Pages copy — and Node does, which is why `test/pages-proxy.test.ts` in\n * Edge-Sonic could not drive the handler at all. It is spread only where a body\n * is forwarded, because a `RequestInit` carrying `duplex` and no body is a shape\n * no runtime documents; the cast is `as RequestInit` either way, since `duplex`\n * is not in the DOM lib's type.\n *\n * The result is a handler factory, so a consumer's `functions/[[path]].ts` is a\n * one-line re-export. Structural `Fetcher` and `PagesFunction` types are declared\n * here rather than imported from `@cloudflare/workers-types`, so the kit stays\n * zero-dependency and this module typechecks without the generated\n * `worker-configuration.d.ts`.\n */\n\n/**\n * The subset of Cloudflare's `Fetcher` this proxy uses.\n *\n * Structural, not imported: the shim only ever calls `fetch`, and requiring\n * `@cloudflare/workers-types` for one method would couple the kit to a generated\n * types file that only exists inside a Wrangler project.\n */\nexport interface Fetcher {\n fetch(input: string | URL | Request, init?: RequestInit): Promise<Response>;\n}\n\n/**\n * The environment a Pages Function is invoked with.\n */\nexport interface PagesProxyEnv {\n readonly API_WORKER: Fetcher;\n}\n\n/**\n * The context Cloudflare passes to `onRequest`.\n *\n * Only the fields this proxy reads are declared. `params` and `waitUntil` are\n * omitted because the catch-all does not use them — a shim that named them would\n * be claiming a contract it does not exercise.\n */\nexport interface PagesFunctionContext {\n readonly request: Request;\n readonly env: PagesProxyEnv;\n}\n\n/**\n * A Pages Function handler.\n */\nexport type PagesFunction = (context: PagesFunctionContext) => Promise<Response>;\n\n/**\n * Headers a *client* may have set, stripped before the request crosses the\n * binding.\n *\n * These describe the connection between the client and the proxy. Forwarding\n * them would let the origin believe the proxy's view of the client is the\n * client's own claim about itself. The three the proxy sets itself are set from\n * values it reads off the request, not from the client's headers.\n */\nconst CLIENT_FORWARDING_HEADERS: readonly string[] = [\n 'connection',\n 'keep-alive',\n 'proxy-authenticate',\n 'proxy-authorization',\n 'te',\n 'trailer',\n 'transfer-encoding',\n 'upgrade',\n 'X-Forwarded-For',\n 'X-Forwarded-Host',\n 'X-Forwarded-Proto',\n 'X-Forwarded-Uri',\n 'Forwarded',\n 'True-Client-IP',\n 'X-Real-Ip',\n];\n\n/** The header Cloudflare sets with the socket's peer address. */\nconst CF_CONNECTING_IP_HEADER = 'CF-Connecting-IP';\n\n/**\n * What `createPagesProxy` accepts.\n */\nexport interface PagesProxyOptions {\n /**\n * Set `X-Forwarded-For` from `CF-Connecting-IP`.\n *\n * Default `true` — Mail-Meow's behaviour, which five repos rely on for their\n * audit trail. Pass `false` for a worker that refuses the header outright\n * (Edge-Sonic's does), and the header is deleted and nothing set.\n */\n readonly forwardClientIp?: boolean;\n}\n\n/**\n * The `onRequest` handler for `functions/[[path]].ts`.\n *\n * Usage — the consumer's `functions/[[path]].ts` becomes two lines:\n *\n * ```ts\n * import { createPagesProxy } from '@rexezuge/tooling/functions/pages-proxy';\n * export const onRequest = createPagesProxy();\n * ```\n *\n * @param options see {@link PagesProxyOptions}. Omitted gives the family's\n * majority behaviour.\n */\nexport function createPagesProxy(options: PagesProxyOptions = {}): PagesFunction {\n const forwardClientIp = options.forwardClientIp ?? true;\n\n return async ({ request, env }: PagesFunctionContext): Promise<Response> => {\n const originalUrl: URL = new URL(request.url);\n\n const headers: Headers = new Headers(request.headers);\n for (const header of CLIENT_FORWARDING_HEADERS) headers.delete(header);\n\n // Set from values read off the request rather than from the client: only the\n // proxy knows which host it served, and a service binding hands over a\n // rewritten URL, so the original path is what has to be carried across.\n headers.set('X-Forwarded-Host', originalUrl.host);\n headers.set('X-Forwarded-Proto', originalUrl.protocol.replace(':', ''));\n headers.set('X-Forwarded-Uri', `${originalUrl.pathname}${originalUrl.search}`);\n\n if (forwardClientIp) {\n const clientIp: string | null = request.headers.get(CF_CONNECTING_IP_HEADER);\n if (clientIp) headers.set('X-Forwarded-For', clientIp);\n }\n\n // `GET`/`HEAD` carry no body, and a `Request` with one is rejected outright\n // for those methods. The body is forwarded as a *stream*, so a large upload\n // does not have to fit in memory on the Pages side.\n const hasBody: boolean = request.method !== 'GET' && request.method !== 'HEAD';\n\n const proxyRequest: Request = new Request(originalUrl.href, {\n method: request.method,\n headers,\n body: hasBody ? request.body : undefined,\n // See the header: `duplex` is not in the DOM lib's `RequestInit` type, and\n // removing the cast would mean not forwarding bodies at all, which is a\n // worse answer than one assertion.\n ...(hasBody && { duplex: 'half' }),\n redirect: request.redirect,\n } as RequestInit);\n\n return env.API_WORKER.fetch(proxyRequest);\n };\n}\n"]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/functions/pages-proxy.ts"],
4
+ "sourcesContent": ["/**\n * The Cloudflare Pages catch-all proxy.\n *\n * Provenance: the `functions/[[path]].ts` shim duplicated in Durable-DAV,\n * Mail-Meow and Edge-Git (and present in nine repos in total). Each copy is an\n * `onRequest` handler that forwards the request to the API worker through a\n * service binding, rewriting the three headers the worker routes on.\n *\n * What each source contributes:\n *\n * - **Durable-DAV / Edge-Git** — the core shape: set `X-Forwarded-Host`,\n * `X-Forwarded-Proto` and `X-Forwarded-Uri` from the original URL, forward the\n * body for non-GET/HEAD methods, and hand the request to `env.API_WORKER`.\n * - **Mail-Meow** — the hop-by-hop header strip, and the decision to *always*\n * delete `X-Forwarded-For` before conditionally setting it from\n * `CF-Connecting-IP`. Setting it only when the header was present left a\n * caller-supplied value intact on any request that reached Pages without\n * `CF-Connecting-IP`, so the origin would trust an attacker-chosen client IP.\n * - **Durable-DAV-Router** — `duplex: 'half'`, required whenever the forwarded\n * body is a stream. Without it this threw a `TypeError` on every non-GET\n * request rather than proxying it.\n * - **Edge-Sonic** — the client-forwarding-header strip list, which additionally\n * removes `Forwarded`, `True-Client-IP` and `X-Real-Ip`. Edge-Sonic goes\n * further and *never* sets `X-Forwarded-For` at all, because its worker keys\n * the rate limiter on `CF-Connecting-IP` and refuses `X-Forwarded-For` on\n * purpose.\n *\n * ### The convergence decision on `X-Forwarded-For`\n *\n * The two families disagree, and the disagreement is about which worker is\n * behind the binding. Mail-Meow's behaviour is kept as the default because it is\n * the only one that preserves the client IP for the audit trail, which five repos\n * read. A repo whose worker refuses the header — Edge-Sonic's — passes\n * `forwardClientIp: false`, which deletes it and sets nothing. What is *not*\n * available is the source repos' conditional `if (clientIp) set(...)`: that is\n * the defect Mail-Meow recorded fixing, and a factory that could reintroduce it\n * would be a factory that carries the bug forward.\n *\n * ### `duplex: 'half'` rides with the body\n *\n * Required by the Fetch spec whenever a `Request` is constructed with a **stream**\n * body. workerd does not throw without it, which is why the line was absent from\n * every Pages copy — and Node does, which is why `test/pages-proxy.test.ts` in\n * Edge-Sonic could not drive the handler at all. It is spread only where a body\n * is forwarded, because a `RequestInit` carrying `duplex` and no body is a shape\n * no runtime documents; the cast is `as RequestInit` either way, since `duplex`\n * is not in the DOM lib's type.\n *\n * The result is a handler factory, so a consumer's `functions/[[path]].ts` is a\n * one-line re-export. Structural `Fetcher` and `PagesFunction` types are declared\n * here rather than imported from `@cloudflare/workers-types`, so the kit stays\n * zero-dependency and this module typechecks without the generated\n * `worker-configuration.d.ts`.\n */\n\n/**\n * The subset of Cloudflare's `Fetcher` this proxy uses.\n *\n * Structural, not imported: the shim only ever calls `fetch`, and requiring\n * `@cloudflare/workers-types` for one method would couple the kit to a generated\n * types file that only exists inside a Wrangler project.\n */\nexport interface Fetcher {\n fetch(input: string | URL | Request, init?: RequestInit): Promise<Response>;\n}\n\n/**\n * The environment a Pages Function is invoked with.\n */\nexport interface PagesProxyEnv {\n readonly API_WORKER: Fetcher;\n}\n\n/**\n * The context Cloudflare passes to `onRequest`.\n *\n * Only the fields this proxy reads are declared. `params` and `waitUntil` are\n * omitted because the catch-all does not use them — a shim that named them would\n * be claiming a contract it does not exercise.\n */\nexport interface PagesFunctionContext {\n readonly request: Request;\n readonly env: PagesProxyEnv;\n}\n\n/**\n * A Pages Function handler.\n */\nexport type PagesFunction = (context: PagesFunctionContext) => Promise<Response>;\n\n/**\n * Headers a *client* may have set, stripped before the request crosses the\n * binding.\n *\n * These describe the connection between the client and the proxy. Forwarding\n * them would let the origin believe the proxy's view of the client is the\n * client's own claim about itself. The three the proxy sets itself are set from\n * values it reads off the request, not from the client's headers.\n */\nconst CLIENT_FORWARDING_HEADERS: readonly string[] = [\n 'connection',\n 'keep-alive',\n 'proxy-authenticate',\n 'proxy-authorization',\n 'te',\n 'trailer',\n 'transfer-encoding',\n 'upgrade',\n 'X-Forwarded-For',\n 'X-Forwarded-Host',\n 'X-Forwarded-Proto',\n 'X-Forwarded-Uri',\n 'Forwarded',\n 'True-Client-IP',\n 'X-Real-Ip',\n];\n\n/**\nThe header Cloudflare sets with the socket's peer address.\n*/\nconst CF_CONNECTING_IP_HEADER = 'CF-Connecting-IP';\n\n/**\n * What `createPagesProxy` accepts.\n */\nexport interface PagesProxyOptions {\n /**\n * Set `X-Forwarded-For` from `CF-Connecting-IP`.\n *\n * Default `true` — Mail-Meow's behaviour, which five repos rely on for their\n * audit trail. Pass `false` for a worker that refuses the header outright\n * (Edge-Sonic's does), and the header is deleted and nothing set.\n */\n readonly forwardClientIp?: boolean;\n}\n\n/**\n * The `onRequest` handler for `functions/[[path]].ts`.\n *\n * Usage — the consumer's `functions/[[path]].ts` becomes two lines:\n *\n * ```ts\n * import { createPagesProxy } from '@rexezuge/tooling/functions/pages-proxy';\n * export const onRequest = createPagesProxy();\n * ```\n *\n * @param options see {@link PagesProxyOptions}. Omitted gives the family's\n * majority behaviour.\n */\nexport function createPagesProxy(options: PagesProxyOptions = {}): PagesFunction {\n const forwardClientIp = options.forwardClientIp ?? true;\n\n return async ({ request, env }: PagesFunctionContext): Promise<Response> => {\n const originalUrl: URL = new URL(request.url);\n\n const headers: Headers = new Headers(request.headers);\n for (const header of CLIENT_FORWARDING_HEADERS) headers.delete(header);\n\n // Set from values read off the request rather than from the client: only the\n // proxy knows which host it served, and a service binding hands over a\n // rewritten URL, so the original path is what has to be carried across.\n headers.set('X-Forwarded-Host', originalUrl.host);\n headers.set('X-Forwarded-Proto', originalUrl.protocol.replace(':', ''));\n headers.set('X-Forwarded-Uri', `${originalUrl.pathname}${originalUrl.search}`);\n\n if (forwardClientIp) {\n const clientIp: string | null = request.headers.get(CF_CONNECTING_IP_HEADER);\n if (clientIp) headers.set('X-Forwarded-For', clientIp);\n }\n\n // `GET`/`HEAD` carry no body, and a `Request` with one is rejected outright\n // for those methods. The body is forwarded as a *stream*, so a large upload\n // does not have to fit in memory on the Pages side.\n const hasBody: boolean = request.method !== 'GET' && request.method !== 'HEAD';\n\n const proxyRequest: Request = new Request(originalUrl.href, {\n method: request.method,\n headers,\n body: hasBody ? request.body : undefined,\n // See the header: `duplex` is not in the DOM lib's `RequestInit` type, and\n // removing the cast would mean not forwarding bodies at all, which is a\n // worse answer than one assertion.\n ...(hasBody && { duplex: 'half' }),\n redirect: request.redirect,\n });\n\n return env.API_WORKER.fetch(proxyRequest);\n };\n}\n"],
5
+ "mappings": "AAmGA,MAAMA,EAA+C,CACnD,aACA,aACA,qBACA,sBACA,KACA,UACA,oBACA,UACA,kBACA,mBACA,oBACA,kBACA,YACA,iBACA,aAMIC,EAA0B,mBA6B1B,SAAUC,EAAiBC,EAA6B,CAAA,EAAE,CAC9D,MAAMC,EAAkBD,EAAQ,iBAAmB,GAEnD,MAAO,OAAO,CAAE,QAAAE,EAAS,IAAAC,CAAG,IAA+C,CACzE,MAAMC,EAAmB,IAAI,IAAIF,EAAQ,GAAG,EAEtCG,EAAmB,IAAI,QAAQH,EAAQ,OAAO,EACpD,UAAWI,KAAUT,EAA2BQ,EAAQ,OAAOC,CAAM,EASrE,GAJAD,EAAQ,IAAI,mBAAoBD,EAAY,IAAI,EAChDC,EAAQ,IAAI,oBAAqBD,EAAY,SAAS,QAAQ,IAAK,EAAE,CAAC,EACtEC,EAAQ,IAAI,kBAAmB,GAAGD,EAAY,QAAQ,GAAGA,EAAY,MAAM,EAAE,EAEzEH,EAAiB,CACnB,MAAMM,EAA0BL,EAAQ,QAAQ,IAAIJ,CAAuB,EACvES,GAAUF,EAAQ,IAAI,kBAAmBE,CAAQ,CACvD,CAKA,MAAMC,EAAmBN,EAAQ,SAAW,OAASA,EAAQ,SAAW,OAElEO,EAAwB,IAAI,QAAQL,EAAY,KAAM,CAC1D,OAAQF,EAAQ,OAChB,QAAAG,EACA,KAAMG,EAAUN,EAAQ,KAAO,OAI/B,GAAIM,GAAW,CAAE,OAAQ,MAAM,EAC/B,SAAUN,EAAQ,SACnB,EAED,OAAOC,EAAI,WAAW,MAAMM,CAAY,CAC1C,CACF",
6
+ "names": ["CLIENT_FORWARDING_HEADERS", "CF_CONNECTING_IP_HEADER", "createPagesProxy", "options", "forwardClientIp", "request", "env", "originalUrl", "headers", "header", "clientIp", "hasBody", "proxyRequest"]
7
+ }
package/dist/index.js CHANGED
@@ -1,31 +1 @@
1
- /**
2
- * `@rexezuge/tooling` — the tooling layer of the kit.
3
- *
4
- * The config factories and the test helpers are re-exported here, so a consumer has
5
- * one import for everything its `*.config.mts` files and its mocks need. The
6
- * scripts under `scripts/` are **not** re-exported: they resolve paths relative to
7
- * the repository they run in, so they are run from disk with `tsx`, not imported.
8
- * See `README.md` for the copy-in recipe and the per-script usage.
9
- *
10
- * The zero-dependency rule: nothing here imports another `@rexezuge/*` package. The
11
- * one exception in the tree is `scripts/backup/encrypt-backup.ts`, which uses
12
- * `@rexezuge/d1`'s AES-GCM so the backup and the workers share one definition of
13
- * "what an encryption key looks like"; that dependency is declared on the package
14
- * and is only ever resolved in the consumer's repo, where the kit is installed
15
- * alongside `@rexezuge/d1`.
16
- */
17
- export { defineRepoLintConfig } from "./eslint.js";
18
- export { defineUnitVitestConfig } from "./vitest.js";
19
- export { defineWebVitestConfig } from "./vitest-web.js";
20
- export { defineRepoVitestConfig } from "./vitest-repo.js";
21
- export { defineIntegrationVitestConfig } from "./vitest-integration.js";
22
- export { DEFAULT_CLOUDFLARE_MOCKS, DEFAULT_WORKSPACE_PACKAGES, KIT_NO_EXTERNAL, workspaceAliases } from "./vitest-aliases.js";
23
- export { defineWebViteConfig, spaShellEmbedPlugin } from "./vite.js";
24
- export { createPagesProxy } from "./functions/pages-proxy.js";
25
- // --- Test helpers ---------------------------------------------------------
26
- //
27
- // Aliased in a Vitest config, not imported by application code, so the mocks stay
28
- // where the suites can reach them.
29
- export { DurableObject, RpcTarget, WorkflowEntrypoint } from "./test/mocks/cloudflare-workers.js";
30
- export { createMigrationHelper, readMigrationFiles, splitSql } from "./test/integration-migrations.js";
31
- //# sourceMappingURL=index.js.map
1
+ import{defineRepoLintConfig as r}from"./eslint.js";import{defineUnitVitestConfig as i}from"./vitest.js";import{defineWebVitestConfig as n}from"./vitest-web.js";import{defineRepoVitestConfig as a}from"./vitest-repo.js";import{defineIntegrationVitestConfig as m}from"./vitest-integration.js";import{DEFAULT_CLOUDFLARE_MOCKS as x,DEFAULT_WORKSPACE_PACKAGES as l,KIT_NO_EXTERNAL as C,workspaceAliases as E}from"./vitest-aliases.js";import{defineWebViteConfig as A,spaShellEmbedPlugin as L}from"./vite.js";import{createPagesProxy as _}from"./functions/pages-proxy.js";import{DurableObject as c,RpcTarget as O,WorkflowEntrypoint as P}from"./test/mocks/cloudflare-workers.js";import{createMigrationHelper as T,readMigrationFiles as V,splitSql as D}from"./test/integration-migrations.js";export{x as DEFAULT_CLOUDFLARE_MOCKS,l as DEFAULT_WORKSPACE_PACKAGES,c as DurableObject,C as KIT_NO_EXTERNAL,O as RpcTarget,P as WorkflowEntrypoint,T as createMigrationHelper,_ as createPagesProxy,m as defineIntegrationVitestConfig,r as defineRepoLintConfig,a as defineRepoVitestConfig,i as defineUnitVitestConfig,A as defineWebViteConfig,n as defineWebVitestConfig,V as readMigrationFiles,L as spaShellEmbedPlugin,D as splitSql,E as workspaceAliases};