@rexezuge/tooling 1.4.0 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/eslint.d.ts.map +1 -1
- package/dist/eslint.js +1 -1
- package/dist/eslint.js.map +2 -2
- package/package.json +2 -2
- package/src/eslint.test.ts +20 -0
- package/src/eslint.ts +13 -3
package/dist/eslint.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eslint.d.ts","sourceRoot":"","sources":["../src/eslint.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AASH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAGvD;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACzC;;OAEG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1C;;;OAGG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC;;;;;;;;OAQG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,SAAS,QAAQ,EAAE,CAAC;CAC5C;AAsCD;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,qBAAqB,GAAG,UAAU,CAAC,WAAW,
|
|
1
|
+
{"version":3,"file":"eslint.d.ts","sourceRoot":"","sources":["../src/eslint.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AASH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAGvD;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACzC;;OAEG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1C;;;OAGG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC;;;;;;;;OAQG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,SAAS,QAAQ,EAAE,CAAC;CAC5C;AAsCD;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,qBAAqB,GAAG,UAAU,CAAC,WAAW,CA4H3F"}
|
package/dist/eslint.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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},
|
|
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"],f.recommended,{rules:E},{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};
|
package/dist/eslint.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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,MAAa,UACpB,OAAOC,MAAc,oBACrB,OAAOC,MAAa,wBACpB,OAAS,WAAWC,MAAsB,wBAC1C,OAAOC,MAAkB,uBACzB,OAAOC,MAA0B,yBACjC,OAAOC,MAAc,yBAErB,OAAS,wBAAAC,EAAsB,aAAAC,EAAW,4BAAAC,EAA0B,qBAAAC,MAAyB,yBAE7F,OAAS,iBAAAC,EAAe,cAAAC,EAAY,oBAAAC,EAAkB,iBAAAC,MAAqB,oBAwD3E,SAASC,EAASC,EAAmB,CACnC,OAAOA,CACT,CAYA,SAASC,EAAQC,EAAwC,CACvD,OAAOA,CACT,CAaM,SAAUC,EAAqBC,EAA8B,CACjE,KAAM,CAAE,MAAAC,CAAK,EAAKD,EACZE,EAAcF,EAAQ,aAAeb,EACrCgB,EAAYf,EAAUa,CAAK,EAAE,OAAQG,GAAUF,EAAY,KAAMG,GAAQD,EAAM,IAAI,WAAWC,CAAG,CAAC,CAAC,EACnGC,EAAQN,EAAQ,aAAe,CAAA,EAC/BO,EAAO,CAAC,GAAGJ,EAAW,GAAGG,CAAK,EAEpC,OAAOzB,EAAS,OACd,CACE,QAAS,CACP,oBACA,mBACA,aACA,4BACA,WACA,cACA,mBACA,iBACA,mBACA,4BACA,cACA,0BACA,kBACA,kBACA,GAAImB,EAAQ,cAAgB,CAAA,IAQhC,CACE,MAAO,CAAC,sCAAsC,EAC9C,gBAAiB,CACf,QAASpB,EAAQ,OAKrB,CACE,MAAO,CAAC,uBAAuB,EAC/B,QAASC,EAAS,QAAQ,uBAC1B,gBAAiB,CACf,cAAe,CACb,eAAgB,GAChB,gBAAiBmB,EAAQ,iBAAmB,QAAQ,IAAG,KAM7D,CACE,MAAO,CAAC,uBAAuB,EAC/B,MAAeP,
|
|
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 + SonarJS presets, then the family's off-block ---\n //\n // Both presets come first on purpose: UNICORN_RULES carries `sonarjs/*`\n // offs as well as `unicorn/*` ones (it is the family's single\n // \"deliberately does not follow\" block), and a preset applied after it\n // would re-enable them. That is exactly what shipped — the sonarjs preset\n // sat between the block and the rules it relaxed, so `void-use`,\n // `different-types-comparison`, `use-type-alias`, `redundant-type-aliases`,\n // `no-nested-assignment` and `no-all-duplicated-branches` linted as errors\n // in every consumer. The two presets do not share rule names, so their\n // relative order decides nothing.\n asConfig(unicorn.configs['flat/recommended']),\n asConfig(sonarjsConfigs.recommended),\n {\n rules: asRules(UNICORN_RULES),\n },\n\n // --- SonarJS advisories ---\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,MAAa,UACpB,OAAOC,MAAc,oBACrB,OAAOC,MAAa,wBACpB,OAAS,WAAWC,MAAsB,wBAC1C,OAAOC,MAAkB,uBACzB,OAAOC,MAA0B,yBACjC,OAAOC,MAAc,yBAErB,OAAS,wBAAAC,EAAsB,aAAAC,EAAW,4BAAAC,EAA0B,qBAAAC,MAAyB,yBAE7F,OAAS,iBAAAC,EAAe,cAAAC,EAAY,oBAAAC,EAAkB,iBAAAC,MAAqB,oBAwD3E,SAASC,EAASC,EAAmB,CACnC,OAAOA,CACT,CAYA,SAASC,EAAQC,EAAwC,CACvD,OAAOA,CACT,CAaM,SAAUC,EAAqBC,EAA8B,CACjE,KAAM,CAAE,MAAAC,CAAK,EAAKD,EACZE,EAAcF,EAAQ,aAAeb,EACrCgB,EAAYf,EAAUa,CAAK,EAAE,OAAQG,GAAUF,EAAY,KAAMG,GAAQD,EAAM,IAAI,WAAWC,CAAG,CAAC,CAAC,EACnGC,EAAQN,EAAQ,aAAe,CAAA,EAC/BO,EAAO,CAAC,GAAGJ,EAAW,GAAGG,CAAK,EAEpC,OAAOzB,EAAS,OACd,CACE,QAAS,CACP,oBACA,mBACA,aACA,4BACA,WACA,cACA,mBACA,iBACA,mBACA,4BACA,cACA,0BACA,kBACA,kBACA,GAAImB,EAAQ,cAAgB,CAAA,IAQhC,CACE,MAAO,CAAC,sCAAsC,EAC9C,gBAAiB,CACf,QAASpB,EAAQ,OAKrB,CACE,MAAO,CAAC,uBAAuB,EAC/B,QAASC,EAAS,QAAQ,uBAC1B,gBAAiB,CACf,cAAe,CACb,eAAgB,GAChB,gBAAiBmB,EAAQ,iBAAmB,QAAQ,IAAG,KAM7D,CACE,MAAO,CAAC,uBAAuB,EAC/B,MAAeP,GAcRX,EAAQ,QAAQ,kBAAkB,EAClCC,EAAe,YACxB,CACE,MAAeW,GAIjB,CACE,MAAeH,GAIRP,EAAa,QAAQ,kBAAkB,EASvCC,EACT,CACE,QAAS,CAAE,SAAAC,CAAQ,EACnB,MAAO,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
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
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rexezuge/tooling",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"src"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@rexezuge/d1": "1.
|
|
29
|
+
"@rexezuge/d1": "1.5.1"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"eslint": "^10.0.0",
|
package/src/eslint.test.ts
CHANGED
|
@@ -165,6 +165,26 @@ describe('defineRepoLintConfig', () => {
|
|
|
165
165
|
);
|
|
166
166
|
});
|
|
167
167
|
|
|
168
|
+
it('keeps the family offs off after the presets assemble', () => {
|
|
169
|
+
// UNICORN_RULES carries `sonarjs/*` offs as well as `unicorn/*` ones, and
|
|
170
|
+
// flat-config later entries win: a preset assembled after the block
|
|
171
|
+
// re-enables whatever the block relaxed. That shipped — the sonarjs preset
|
|
172
|
+
// sat between the block and its own rules, so six deliberate offs linted
|
|
173
|
+
// as errors in every consumer. Asserted on the merged result, because the
|
|
174
|
+
// block alone always said the right thing; only the assembly was wrong.
|
|
175
|
+
const rules = rulesOf(config, 'packages/backend-data/src/dao/x.ts');
|
|
176
|
+
for (const rule of [
|
|
177
|
+
'sonarjs/void-use',
|
|
178
|
+
'sonarjs/different-types-comparison',
|
|
179
|
+
'sonarjs/use-type-alias',
|
|
180
|
+
'sonarjs/redundant-type-aliases',
|
|
181
|
+
'sonarjs/no-nested-assignment',
|
|
182
|
+
'sonarjs/no-all-duplicated-branches',
|
|
183
|
+
]) {
|
|
184
|
+
expect(rules[rule]).toBe('off');
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
|
|
168
188
|
it('covers the family superset of domain layers', () => {
|
|
169
189
|
// provider-clients (AWS/CalDAV/Meow/Otter), webdav/dav-store (DAV/Router/Sonic),
|
|
170
190
|
// git-protocol/git-service (Git): a repo without the package never imports it,
|
package/src/eslint.ts
CHANGED
|
@@ -202,14 +202,24 @@ export function defineRepoLintConfig(options: RepoLintConfigOptions): FlatConfig
|
|
|
202
202
|
rules: asRules(TYPESCRIPT_RULES),
|
|
203
203
|
},
|
|
204
204
|
|
|
205
|
-
// --- Unicorn
|
|
205
|
+
// --- Unicorn + SonarJS presets, then the family's off-block ---
|
|
206
|
+
//
|
|
207
|
+
// Both presets come first on purpose: UNICORN_RULES carries `sonarjs/*`
|
|
208
|
+
// offs as well as `unicorn/*` ones (it is the family's single
|
|
209
|
+
// "deliberately does not follow" block), and a preset applied after it
|
|
210
|
+
// would re-enable them. That is exactly what shipped — the sonarjs preset
|
|
211
|
+
// sat between the block and the rules it relaxed, so `void-use`,
|
|
212
|
+
// `different-types-comparison`, `use-type-alias`, `redundant-type-aliases`,
|
|
213
|
+
// `no-nested-assignment` and `no-all-duplicated-branches` linted as errors
|
|
214
|
+
// in every consumer. The two presets do not share rule names, so their
|
|
215
|
+
// relative order decides nothing.
|
|
206
216
|
asConfig(unicorn.configs['flat/recommended']),
|
|
217
|
+
asConfig(sonarjsConfigs.recommended),
|
|
207
218
|
{
|
|
208
219
|
rules: asRules(UNICORN_RULES),
|
|
209
220
|
},
|
|
210
221
|
|
|
211
|
-
// --- SonarJS
|
|
212
|
-
asConfig(sonarjsConfigs.recommended),
|
|
222
|
+
// --- SonarJS advisories ---
|
|
213
223
|
{
|
|
214
224
|
rules: asRules(SONARJS_RULES),
|
|
215
225
|
},
|