@dloizides/frontend-devtools 2.2.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,178 +1,185 @@
1
- # Changelog
2
-
3
- All notable changes to `@dloizides/frontend-devtools` are documented here.
4
-
5
- The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
- and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
-
8
- ## [2.2.0] - 2026-10-23
9
-
10
- FOCUS-1 "Every screen names its initial focus", D-FOCUS-2 "Lint rule and ledger".
11
-
12
- ### Added
13
- - `explicit-initial-focus`: flags a file that builds a menu of 2+ buttons (HTML strings or `createElement('button')`) with no `MENU_DEFAULT_ATTR` / `data-menu-default` / `dataset.menuDefault` / `initialFocus`, and a JSX `*Dialog` / `*Modal` / `role="dialog"` in a file with no `autoFocus`, `initialFocus(Ref)` or `.focus()` call. Options: `minControls`, `dialogPattern`, `selfFocusing`.
14
- - `focusConfig` + `FOCUS_RULE_NAMES` (opt-in, not part of `recommendedConfig` or `gameConfig`).
15
-
16
- ## [2.1.0] - 2026-10-20
17
-
18
- QUAL-ADOPT-1 "Fail lint/arch tests when an app re-implements an existing package" (TS half).
19
-
20
- ### Added
21
- - `no-reimplemented-package`: flags app code that re-implements a shared package (hand-rolled analytics/Umami -> `@dloizides/analytics-web`, `X-BFF-Csrf` header or `bffCsrf` -> `@dloizides/bff-web-client`, `forgotPasswordRequest` -> `@dloizides/auth-web`, `utils/logger` -> `@dloizides/logging-web`). Pairs live in one registry, `src/rules/reimplemented-packages-registry.js`. Tests, e2e and package sources are exempt; `allow` adds path fragments.
22
- - `reuseConfig` + `REUSE_RULE_NAMES` (opt-in, not part of `recommendedConfig`).
23
-
24
- ## [2.0.0] - 2026-10-20
25
-
26
- D-PAT-15 "Move initI18n out of frontend-devtools so it is dev-only".
27
-
28
- ### Removed (BREAKING)
29
- - `initI18n` and `InitI18nOptions`: import them from `@dloizides/i18n` (>= 1.1.0), same signature: `import { initI18n } from '@dloizides/i18n';`.
30
- - The root entry (`@dloizides/frontend-devtools`): it exported only `initI18n`. Use the `/eslint` and `/test-results` subpaths.
31
- - The `i18next` and `react-i18next` optional peer dependencies.
32
-
33
- ## [1.10.0] - 2026-10-19
34
-
35
- PATTERN-1.12 "TS rule packs + house rules in frontend-devtools" (D-PAT-12 "Whole rule packs as warnings, one shared approach").
36
-
37
- ### Added
38
- - `patternPacksConfig`: the recommended rules of `@tanstack/eslint-plugin-query`, `eslint-plugin-react-you-might-not-need-an-effect`, `eslint-plugin-boundaries` and `eslint-plugin-sonarjs`, every rule at `warn`, plus the house rules.
39
- - `query-key-factory` (PAT-QUERY-KEY-1 "queryKey only from a key factory"): flags an inline array/string/template `queryKey`; key-factory files (`*Keys.ts`), tests and generated code are exempt; `allow` adds path fragments.
40
- - `HOUSE_PATTERN_RULE_NAMES`.
41
-
42
- ## [1.9.0] - 2026-10-19
43
-
44
- PATTERN-1.4 "TypeScript pattern rules as ESLint rules", `no-raw-backend-fetch` (PAT-API-1 "web apps call the backend through the shared client") hardening.
45
-
46
- ### Changed
47
- - `no-raw-backend-fetch` no longer reports `fetch` of a literal absolute `http(s)://host/...` URL (third-party), or of a value produced by `URL.createObjectURL(...)` / `new FileReader().result` (direct, or via a single `const`).
48
- - `no-raw-backend-fetch` registers no visitors when the parsed AST is not an ESTree `Program` (non-JS languages under an unscoped `apiConfig`).
49
-
50
- ### Tests
51
- - `apiConfigUnscoped.test.ts`: `apiConfig` without `files` lints `.js`/`.mjs`/`.cjs`, build output and a 2000-deep nested file without throwing, and still reports under `src/`.
52
-
53
- ## [1.8.0] - 2026-10-19
54
-
55
- PATTERN-1.4 "TypeScript pattern rules as ESLint rules", row PAT-API-1 "web apps call the backend through the shared client".
56
-
57
- ### Added
58
-
59
- - `no-raw-backend-fetch`: reports `fetch(` / `window.fetch(` / `globalThis.fetch(` / `self.fetch(` and value imports of `axios`
60
- (`import`, `require`, `import()`) in `src/**`. Exempt: `src/server/`, `src/http/`, `src/lib/http/`, `packages/*-client/`,
61
- `/generated/`, service worker files, `app/+html.*`, tests, `data:`/`blob:` URLs, `import type` from axios. Option `{ allow: string[] }`.
62
- - `apiConfig` flat-config preset (`API_RULE_NAMES`) at `error`; included in `recommendedConfig`.
63
-
64
- ## [1.7.0] - 2026-10-19
65
-
66
- NAV-1 "Every game menu works with arrow keys and controller", phase 3.
67
-
68
- ### Added
69
-
70
- - `game-menu-focusable`: reports a `click` / `pointerdown` / `pointerup` listener or `onclick =` on an element created as
71
- `div` / `span` / `li` / `img` whose variable never gets `tabIndex` / `role` (property or `setAttribute`), and every
72
- `stopPropagation()` inside a `keydown` / `onkeydown` handler (inline, named function or const). No options, no autofix.
73
- - `gameConfig` flat-config preset (`GAME_RULE_NAMES`): enables `game-menu-focusable` at `error`. Not part of
74
- `recommendedConfig`; game repos opt in.
75
-
76
- ### Changed
77
-
78
- - `testdoc-results.v1.schema.json` copy synced to Dloizides.Testing 7fbf809 (adds the optional `features` array).
79
-
80
- ## [1.5.0] - 2026-10-07
81
-
82
- KEFI-ACT-1 "Same attendee actions everywhere" (generalized: one row-action source per entity, every portal).
83
-
84
- ### Added
85
-
86
- - `single-row-action-source`: reports `<RowActionGroup actions>` from `@dloizides/ui-buttons` built in the same file
87
- (inline array, array-bound identifier, `useMemo` returning an array, local builder function, `RowActionSpec[]`
88
- annotated local). Imported builders/sets and props pass. No options, no autofix.
89
- - `rowActionsConfig` and `recommendedConfig` flat-config blocks (`recommendedConfig` = comments + row actions, all `error`).
90
-
91
- ## [1.4.0] - 2026-10-07
92
-
93
- COMMENTS-1 "No code comments; only short doc comments on public members", decision D-CMT-4 "One-line summary, no call chains".
94
-
95
- ### Changed
96
-
97
- - `doc-comment-max-lines`: the description (lines other than `@param` / `@returns`) is capped at ONE line
98
- (`summaryMaxLines`, default 1), every doc line at 120 chars (`lineMaxChars`), and a line containing an arrow
99
- (U+2192 or `->`) or starting `Flow:` is reported (`callChain`). Matches `.claude/hooks/review-violations.js` docBlock().
100
- The 3-line total cap is unchanged. One report per block; banned tags take precedence.
101
-
102
- ## [1.3.0] - 2026-10-06
103
-
104
- COMMENTS-1 "No code comments; only short doc comments on public members" (decisions D-CMT-1, D-CMT-3).
105
-
106
- ### Added
107
-
108
- - `no-comments`: reports every comment that is not a `/**` doc block and not a tool directive
109
- (`eslint-*`, `@ts-*`, `prettier-ignore`, `istanbul`/`c8`, `/// <reference>`, `#__PURE__`,
110
- `webpackChunkName`, shebang). `allow: string[]` adds directive regexes. Suggestion only, no autofix.
111
- - `doc-comment-public-only`: a doc block must sit on an exported declaration (incl. `export { x }`,
112
- `export default x`, `module.exports`, ambient `declare module`) or a public member of one;
113
- `private` / `protected` / `#` members and local declarations are reported.
114
- - `doc-comment-max-lines`: doc body capped at `max` (default 3) content lines; block tags other than
115
- `allowedTags` (default `@param`, `@returns`) are reported. JSDoc type-annotation blocks
116
- (`@type`, `@typedef`, ...) are exempt from both doc rules.
117
- - `commentsConfig` flat-config block (the three rules at `error`) and `COMMENT_RULE_NAMES`, exported
118
- from `/eslint`. Not adopted by any app yet: each repo opts in as step 1 of its COMMENTS-CLEAN sweep.
119
-
120
- ## [1.1.0] - 2026-07-13
121
-
122
- Both changes come out of the ES-04 (agora-web) build, which surfaced two ways the
123
- rule pack misbehaved against a freshly scaffolded app.
124
-
125
- ### Fixed
126
-
127
- - **`no-null-check`: the autofixer no longer corrupts files.** It rewrote
128
- `x === undefined` → `!isValueDefined(x)` *without importing `isValueDefined`*,
129
- so `eslint --fix` emitted source referencing an undeclared global. Running
130
- `lint:fix` on agora-web rewrote ~20 files and produced 67 `no-unsafe-call` /
131
- `strict-boolean-expressions` errors. A fixer that produces broken code is worse
132
- than no fixer — `lint:fix` is the first thing anyone runs.
133
-
134
- The fixer now inserts `import { isValueDefined } from '@dloizides/utils';` (the
135
- path is configurable via the pre-existing but previously **unused**
136
- `utilImportPath` option) when the file has no binding for the guard, and skips
137
- the autofix entirely in the module that defines or re-exports it. Proven with
138
- `Linter.verifyAndFix` multipass tests — the actual `--fix` code path.
139
-
140
- ⚠️ The package's own test suite had *codified* the bug: it asserted the
141
- import-less output was correct. Those expectations were wrong and are updated.
142
-
143
- ### Changed
144
-
145
- - **`smart-max-lines`: `functionWarn` is now opt-in (default: off).** ESLint has
146
- no per-report severity, so a `functionWarn` report is emitted at the severity
147
- the *rule* is configured with. Every app configured the rule as `'error'` and
148
- passed `functionWarn: 30` — which made the real, enforced limit **30 lines**
149
- while the docs promised **50**. The rule lied about its own threshold.
150
-
151
- Out of the box the only enforced thresholds are now `componentMax` (200) and
152
- `functionMax` (50) — exactly what the documentation has always promised.
153
- `functionWarn` remains available as an explicit *stricter second threshold*,
154
- and its schema/message now say plainly that it reports at the rule's severity
155
- rather than as a warning.
156
-
157
- Migration: drop `functionWarn: 30` from your ESLint config. This only relaxes
158
- linting (30 → 50), so it cannot introduce new failures.
159
-
160
- ## [1.0.0] - 2026-06-14
161
-
162
- ### Added
163
-
164
- - Initial extraction of the shared RN-web dev tooling duplicated across
165
- erevna-web, katalogos-web, and kefi-web.
166
- - **ESLint custom rule pack** (17 rules) exported as `plugin` / `rules` /
167
- `legacyPlugins`, also available under the `@dloizides/frontend-devtools/eslint`
168
- subpath. Rule names preserved byte-for-byte so existing config keys and
169
- `eslint-disable-next-line <rule>` comments keep working:
170
- `enforce-function-style`, `enforce-module-structure`, `enforce-route-preload`,
171
- `enforce-test-colocation`, `enum-file-isolation`, `i18n-interpolation`,
172
- `i18n-param-names`, `no-barrel-companion-file`, `no-duplicate-nav-prefix`,
173
- `no-duplicate-shared-patterns`, `no-generated-models-barrel-value-import`,
174
- `no-null-check`, `no-optional-undefined`, `no-product-imports-in-shared`,
175
- `prefer-const-enum`, `require-stable-hook-args`, `smart-max-lines`.
176
- - **`initI18n(options)`** — parameterized i18next + react-i18next init factory.
177
- Carries the `import/no-named-as-default-member` disable so apps stop repeating
178
- it. The app owns its `locales/*.json` strings and the active language.
1
+ # Changelog
2
+
3
+ All notable changes to `@dloizides/frontend-devtools` are documented here.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [2.3.0] - 2026-10-28
9
+
10
+ OBS-1 "Every app ships metrics, production-grade logs and alerts with working links", D-OBS-15 "Front-end budgets, warn only".
11
+
12
+ ### Added
13
+ - `./lighthouse` subpath: `budgetAssertions` (LCP < 2500 ms, TBT < 200 ms, CLS < 0.1, script transfer < 300 KB, all `warn`), `mobileSettings` (Lighthouse's mid-range phone profile) and `withBudgets(config)`, which merges both into an app's `lighthouserc.js`; keys the app sets win.
14
+
15
+ ## [2.2.0] - 2026-10-23
16
+
17
+ FOCUS-1 "Every screen names its initial focus", D-FOCUS-2 "Lint rule and ledger".
18
+
19
+ ### Added
20
+ - `explicit-initial-focus`: flags a file that builds a menu of 2+ buttons (HTML strings or `createElement('button')`) with no `MENU_DEFAULT_ATTR` / `data-menu-default` / `dataset.menuDefault` / `initialFocus`, and a JSX `*Dialog` / `*Modal` / `role="dialog"` in a file with no `autoFocus`, `initialFocus(Ref)` or `.focus()` call. Options: `minControls`, `dialogPattern`, `selfFocusing`.
21
+ - `focusConfig` + `FOCUS_RULE_NAMES` (opt-in, not part of `recommendedConfig` or `gameConfig`).
22
+
23
+ ## [2.1.0] - 2026-10-20
24
+
25
+ QUAL-ADOPT-1 "Fail lint/arch tests when an app re-implements an existing package" (TS half).
26
+
27
+ ### Added
28
+ - `no-reimplemented-package`: flags app code that re-implements a shared package (hand-rolled analytics/Umami -> `@dloizides/analytics-web`, `X-BFF-Csrf` header or `bffCsrf` -> `@dloizides/bff-web-client`, `forgotPasswordRequest` -> `@dloizides/auth-web`, `utils/logger` -> `@dloizides/logging-web`). Pairs live in one registry, `src/rules/reimplemented-packages-registry.js`. Tests, e2e and package sources are exempt; `allow` adds path fragments.
29
+ - `reuseConfig` + `REUSE_RULE_NAMES` (opt-in, not part of `recommendedConfig`).
30
+
31
+ ## [2.0.0] - 2026-10-20
32
+
33
+ D-PAT-15 "Move initI18n out of frontend-devtools so it is dev-only".
34
+
35
+ ### Removed (BREAKING)
36
+ - `initI18n` and `InitI18nOptions`: import them from `@dloizides/i18n` (>= 1.1.0), same signature: `import { initI18n } from '@dloizides/i18n';`.
37
+ - The root entry (`@dloizides/frontend-devtools`): it exported only `initI18n`. Use the `/eslint` and `/test-results` subpaths.
38
+ - The `i18next` and `react-i18next` optional peer dependencies.
39
+
40
+ ## [1.10.0] - 2026-10-19
41
+
42
+ PATTERN-1.12 "TS rule packs + house rules in frontend-devtools" (D-PAT-12 "Whole rule packs as warnings, one shared approach").
43
+
44
+ ### Added
45
+ - `patternPacksConfig`: the recommended rules of `@tanstack/eslint-plugin-query`, `eslint-plugin-react-you-might-not-need-an-effect`, `eslint-plugin-boundaries` and `eslint-plugin-sonarjs`, every rule at `warn`, plus the house rules.
46
+ - `query-key-factory` (PAT-QUERY-KEY-1 "queryKey only from a key factory"): flags an inline array/string/template `queryKey`; key-factory files (`*Keys.ts`), tests and generated code are exempt; `allow` adds path fragments.
47
+ - `HOUSE_PATTERN_RULE_NAMES`.
48
+
49
+ ## [1.9.0] - 2026-10-19
50
+
51
+ PATTERN-1.4 "TypeScript pattern rules as ESLint rules", `no-raw-backend-fetch` (PAT-API-1 "web apps call the backend through the shared client") hardening.
52
+
53
+ ### Changed
54
+ - `no-raw-backend-fetch` no longer reports `fetch` of a literal absolute `http(s)://host/...` URL (third-party), or of a value produced by `URL.createObjectURL(...)` / `new FileReader().result` (direct, or via a single `const`).
55
+ - `no-raw-backend-fetch` registers no visitors when the parsed AST is not an ESTree `Program` (non-JS languages under an unscoped `apiConfig`).
56
+
57
+ ### Tests
58
+ - `apiConfigUnscoped.test.ts`: `apiConfig` without `files` lints `.js`/`.mjs`/`.cjs`, build output and a 2000-deep nested file without throwing, and still reports under `src/`.
59
+
60
+ ## [1.8.0] - 2026-10-19
61
+
62
+ PATTERN-1.4 "TypeScript pattern rules as ESLint rules", row PAT-API-1 "web apps call the backend through the shared client".
63
+
64
+ ### Added
65
+
66
+ - `no-raw-backend-fetch`: reports `fetch(` / `window.fetch(` / `globalThis.fetch(` / `self.fetch(` and value imports of `axios`
67
+ (`import`, `require`, `import()`) in `src/**`. Exempt: `src/server/`, `src/http/`, `src/lib/http/`, `packages/*-client/`,
68
+ `/generated/`, service worker files, `app/+html.*`, tests, `data:`/`blob:` URLs, `import type` from axios. Option `{ allow: string[] }`.
69
+ - `apiConfig` flat-config preset (`API_RULE_NAMES`) at `error`; included in `recommendedConfig`.
70
+
71
+ ## [1.7.0] - 2026-10-19
72
+
73
+ NAV-1 "Every game menu works with arrow keys and controller", phase 3.
74
+
75
+ ### Added
76
+
77
+ - `game-menu-focusable`: reports a `click` / `pointerdown` / `pointerup` listener or `onclick =` on an element created as
78
+ `div` / `span` / `li` / `img` whose variable never gets `tabIndex` / `role` (property or `setAttribute`), and every
79
+ `stopPropagation()` inside a `keydown` / `onkeydown` handler (inline, named function or const). No options, no autofix.
80
+ - `gameConfig` flat-config preset (`GAME_RULE_NAMES`): enables `game-menu-focusable` at `error`. Not part of
81
+ `recommendedConfig`; game repos opt in.
82
+
83
+ ### Changed
84
+
85
+ - `testdoc-results.v1.schema.json` copy synced to Dloizides.Testing 7fbf809 (adds the optional `features` array).
86
+
87
+ ## [1.5.0] - 2026-10-07
88
+
89
+ KEFI-ACT-1 "Same attendee actions everywhere" (generalized: one row-action source per entity, every portal).
90
+
91
+ ### Added
92
+
93
+ - `single-row-action-source`: reports `<RowActionGroup actions>` from `@dloizides/ui-buttons` built in the same file
94
+ (inline array, array-bound identifier, `useMemo` returning an array, local builder function, `RowActionSpec[]`
95
+ annotated local). Imported builders/sets and props pass. No options, no autofix.
96
+ - `rowActionsConfig` and `recommendedConfig` flat-config blocks (`recommendedConfig` = comments + row actions, all `error`).
97
+
98
+ ## [1.4.0] - 2026-10-07
99
+
100
+ COMMENTS-1 "No code comments; only short doc comments on public members", decision D-CMT-4 "One-line summary, no call chains".
101
+
102
+ ### Changed
103
+
104
+ - `doc-comment-max-lines`: the description (lines other than `@param` / `@returns`) is capped at ONE line
105
+ (`summaryMaxLines`, default 1), every doc line at 120 chars (`lineMaxChars`), and a line containing an arrow
106
+ (U+2192 or `->`) or starting `Flow:` is reported (`callChain`). Matches `.claude/hooks/review-violations.js` docBlock().
107
+ The 3-line total cap is unchanged. One report per block; banned tags take precedence.
108
+
109
+ ## [1.3.0] - 2026-10-06
110
+
111
+ COMMENTS-1 "No code comments; only short doc comments on public members" (decisions D-CMT-1, D-CMT-3).
112
+
113
+ ### Added
114
+
115
+ - `no-comments`: reports every comment that is not a `/**` doc block and not a tool directive
116
+ (`eslint-*`, `@ts-*`, `prettier-ignore`, `istanbul`/`c8`, `/// <reference>`, `#__PURE__`,
117
+ `webpackChunkName`, shebang). `allow: string[]` adds directive regexes. Suggestion only, no autofix.
118
+ - `doc-comment-public-only`: a doc block must sit on an exported declaration (incl. `export { x }`,
119
+ `export default x`, `module.exports`, ambient `declare module`) or a public member of one;
120
+ `private` / `protected` / `#` members and local declarations are reported.
121
+ - `doc-comment-max-lines`: doc body capped at `max` (default 3) content lines; block tags other than
122
+ `allowedTags` (default `@param`, `@returns`) are reported. JSDoc type-annotation blocks
123
+ (`@type`, `@typedef`, ...) are exempt from both doc rules.
124
+ - `commentsConfig` flat-config block (the three rules at `error`) and `COMMENT_RULE_NAMES`, exported
125
+ from `/eslint`. Not adopted by any app yet: each repo opts in as step 1 of its COMMENTS-CLEAN sweep.
126
+
127
+ ## [1.1.0] - 2026-07-13
128
+
129
+ Both changes come out of the ES-04 (agora-web) build, which surfaced two ways the
130
+ rule pack misbehaved against a freshly scaffolded app.
131
+
132
+ ### Fixed
133
+
134
+ - **`no-null-check`: the autofixer no longer corrupts files.** It rewrote
135
+ `x === undefined` → `!isValueDefined(x)` *without importing `isValueDefined`*,
136
+ so `eslint --fix` emitted source referencing an undeclared global. Running
137
+ `lint:fix` on agora-web rewrote ~20 files and produced 67 `no-unsafe-call` /
138
+ `strict-boolean-expressions` errors. A fixer that produces broken code is worse
139
+ than no fixer — `lint:fix` is the first thing anyone runs.
140
+
141
+ The fixer now inserts `import { isValueDefined } from '@dloizides/utils';` (the
142
+ path is configurable via the pre-existing but previously **unused**
143
+ `utilImportPath` option) when the file has no binding for the guard, and skips
144
+ the autofix entirely in the module that defines or re-exports it. Proven with
145
+ `Linter.verifyAndFix` multipass tests — the actual `--fix` code path.
146
+
147
+ ⚠️ The package's own test suite had *codified* the bug: it asserted the
148
+ import-less output was correct. Those expectations were wrong and are updated.
149
+
150
+ ### Changed
151
+
152
+ - **`smart-max-lines`: `functionWarn` is now opt-in (default: off).** ESLint has
153
+ no per-report severity, so a `functionWarn` report is emitted at the severity
154
+ the *rule* is configured with. Every app configured the rule as `'error'` and
155
+ passed `functionWarn: 30` — which made the real, enforced limit **30 lines**
156
+ while the docs promised **50**. The rule lied about its own threshold.
157
+
158
+ Out of the box the only enforced thresholds are now `componentMax` (200) and
159
+ `functionMax` (50) — exactly what the documentation has always promised.
160
+ `functionWarn` remains available as an explicit *stricter second threshold*,
161
+ and its schema/message now say plainly that it reports at the rule's severity
162
+ rather than as a warning.
163
+
164
+ Migration: drop `functionWarn: 30` from your ESLint config. This only relaxes
165
+ linting (30 → 50), so it cannot introduce new failures.
166
+
167
+ ## [1.0.0] - 2026-06-14
168
+
169
+ ### Added
170
+
171
+ - Initial extraction of the shared RN-web dev tooling duplicated across
172
+ erevna-web, katalogos-web, and kefi-web.
173
+ - **ESLint custom rule pack** (17 rules) exported as `plugin` / `rules` /
174
+ `legacyPlugins`, also available under the `@dloizides/frontend-devtools/eslint`
175
+ subpath. Rule names preserved byte-for-byte so existing config keys and
176
+ `eslint-disable-next-line <rule>` comments keep working:
177
+ `enforce-function-style`, `enforce-module-structure`, `enforce-route-preload`,
178
+ `enforce-test-colocation`, `enum-file-isolation`, `i18n-interpolation`,
179
+ `i18n-param-names`, `no-barrel-companion-file`, `no-duplicate-nav-prefix`,
180
+ `no-duplicate-shared-patterns`, `no-generated-models-barrel-value-import`,
181
+ `no-null-check`, `no-optional-undefined`, `no-product-imports-in-shared`,
182
+ `prefer-const-enum`, `require-stable-hook-args`, `smart-max-lines`.
183
+ - **`initI18n(options)`** — parameterized i18next + react-i18next init factory.
184
+ Carries the `import/no-named-as-default-member` disable so apps stop repeating
185
+ it. The app owns its `locales/*.json` strings and the active language.
package/README.md CHANGED
@@ -155,3 +155,12 @@ import { initI18n } from '@dloizides/i18n';
155
155
  ## License
156
156
 
157
157
  MIT © dloizides
158
+
159
+ ## Lighthouse budgets (`/lighthouse`)
160
+
161
+ D-OBS-15 front-end budgets, warn only, on a mid-range phone. In an app's `lighthouserc.js`:
162
+
163
+ ```js
164
+ const { withBudgets } = require('@dloizides/frontend-devtools/lighthouse');
165
+ module.exports = withBudgets({ ci: { collect: { url: ['http://localhost:8099/'] }, assert: { assertions: {} } } });
166
+ ```
@@ -0,0 +1,41 @@
1
+ /** D-OBS-15 front-end budgets (OBS-1): Core Web Vitals on a mid-range phone, warn only. */
2
+ declare const LIGHTHOUSE_BUDGETS: {
3
+ readonly lcpMs: 2500;
4
+ readonly tbtMs: 200;
5
+ readonly cls: 0.1;
6
+ readonly scriptBytes: number;
7
+ };
8
+ type Assertion = ['warn' | 'error', Record<string, number>];
9
+ /** Lighthouse CI assertions for the D-OBS-15 budgets; every entry is `warn`, never `error`. */
10
+ declare const budgetAssertions: Record<string, Assertion>;
11
+ /** Lighthouse's own mid-range phone profile (Moto G Power, simulated slow 4G, 4x CPU slowdown). */
12
+ declare const mobileSettings: {
13
+ readonly formFactor: "mobile";
14
+ readonly screenEmulation: {
15
+ readonly mobile: true;
16
+ readonly width: 412;
17
+ readonly height: 823;
18
+ readonly deviceScaleFactor: 1.75;
19
+ readonly disabled: false;
20
+ };
21
+ readonly throttlingMethod: "simulate";
22
+ readonly throttling: {
23
+ readonly rttMs: 150;
24
+ readonly throughputKbps: 1638.4;
25
+ readonly cpuSlowdownMultiplier: 4;
26
+ };
27
+ };
28
+ interface LhciConfig {
29
+ ci: {
30
+ collect?: {
31
+ settings?: Record<string, unknown>;
32
+ } & Record<string, unknown>;
33
+ assert?: {
34
+ assertions?: Record<string, unknown>;
35
+ } & Record<string, unknown>;
36
+ } & Record<string, unknown>;
37
+ }
38
+ /** Adds the mobile settings and budget assertions to an app's lighthouserc; app-set keys win. */
39
+ declare function withBudgets<T extends LhciConfig>(config: T): T;
40
+
41
+ export { LIGHTHOUSE_BUDGETS, budgetAssertions, mobileSettings, withBudgets };
@@ -0,0 +1,41 @@
1
+ /** D-OBS-15 front-end budgets (OBS-1): Core Web Vitals on a mid-range phone, warn only. */
2
+ declare const LIGHTHOUSE_BUDGETS: {
3
+ readonly lcpMs: 2500;
4
+ readonly tbtMs: 200;
5
+ readonly cls: 0.1;
6
+ readonly scriptBytes: number;
7
+ };
8
+ type Assertion = ['warn' | 'error', Record<string, number>];
9
+ /** Lighthouse CI assertions for the D-OBS-15 budgets; every entry is `warn`, never `error`. */
10
+ declare const budgetAssertions: Record<string, Assertion>;
11
+ /** Lighthouse's own mid-range phone profile (Moto G Power, simulated slow 4G, 4x CPU slowdown). */
12
+ declare const mobileSettings: {
13
+ readonly formFactor: "mobile";
14
+ readonly screenEmulation: {
15
+ readonly mobile: true;
16
+ readonly width: 412;
17
+ readonly height: 823;
18
+ readonly deviceScaleFactor: 1.75;
19
+ readonly disabled: false;
20
+ };
21
+ readonly throttlingMethod: "simulate";
22
+ readonly throttling: {
23
+ readonly rttMs: 150;
24
+ readonly throughputKbps: 1638.4;
25
+ readonly cpuSlowdownMultiplier: 4;
26
+ };
27
+ };
28
+ interface LhciConfig {
29
+ ci: {
30
+ collect?: {
31
+ settings?: Record<string, unknown>;
32
+ } & Record<string, unknown>;
33
+ assert?: {
34
+ assertions?: Record<string, unknown>;
35
+ } & Record<string, unknown>;
36
+ } & Record<string, unknown>;
37
+ }
38
+ /** Adds the mobile settings and budget assertions to an app's lighthouserc; app-set keys win. */
39
+ declare function withBudgets<T extends LhciConfig>(config: T): T;
40
+
41
+ export { LIGHTHOUSE_BUDGETS, budgetAssertions, mobileSettings, withBudgets };
@@ -0,0 +1,39 @@
1
+ 'use strict';
2
+
3
+ // src/lighthouse/index.ts
4
+ var LIGHTHOUSE_BUDGETS = {
5
+ lcpMs: 2500,
6
+ tbtMs: 200,
7
+ cls: 0.1,
8
+ scriptBytes: 300 * 1024
9
+ };
10
+ var budgetAssertions = {
11
+ "largest-contentful-paint": ["warn", { maxNumericValue: LIGHTHOUSE_BUDGETS.lcpMs }],
12
+ "total-blocking-time": ["warn", { maxNumericValue: LIGHTHOUSE_BUDGETS.tbtMs }],
13
+ "cumulative-layout-shift": ["warn", { maxNumericValue: LIGHTHOUSE_BUDGETS.cls }],
14
+ "resource-summary:script:size": ["warn", { maxNumericValue: LIGHTHOUSE_BUDGETS.scriptBytes }]
15
+ };
16
+ var mobileSettings = {
17
+ formFactor: "mobile",
18
+ screenEmulation: { mobile: true, width: 412, height: 823, deviceScaleFactor: 1.75, disabled: false },
19
+ throttlingMethod: "simulate",
20
+ throttling: { rttMs: 150, throughputKbps: 1638.4, cpuSlowdownMultiplier: 4 }
21
+ };
22
+ function withBudgets(config) {
23
+ const { collect = {}, assert = {} } = config.ci;
24
+ return {
25
+ ...config,
26
+ ci: {
27
+ ...config.ci,
28
+ collect: { ...collect, settings: { ...mobileSettings, ...collect.settings } },
29
+ assert: { ...assert, assertions: { ...budgetAssertions, ...assert.assertions } }
30
+ }
31
+ };
32
+ }
33
+
34
+ exports.LIGHTHOUSE_BUDGETS = LIGHTHOUSE_BUDGETS;
35
+ exports.budgetAssertions = budgetAssertions;
36
+ exports.mobileSettings = mobileSettings;
37
+ exports.withBudgets = withBudgets;
38
+ //# sourceMappingURL=index.js.map
39
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/lighthouse/index.ts"],"names":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GAAG,MAAA,EAAQ,UAAA,EAAY,EAAE,GAAG,gBAAA,EAAkB,GAAG,MAAA,CAAO,UAAA,EAAW;AAAE;AACjF,GACF;AACF","file":"index.js","sourcesContent":["/** D-OBS-15 front-end budgets (OBS-1): Core Web Vitals on a mid-range phone, warn only. */\nexport const LIGHTHOUSE_BUDGETS = {\n lcpMs: 2500,\n tbtMs: 200,\n cls: 0.1,\n scriptBytes: 300 * 1024,\n} as const;\n\ntype Assertion = ['warn' | 'error', Record<string, number>];\n\n/** Lighthouse CI assertions for the D-OBS-15 budgets; every entry is `warn`, never `error`. */\nexport const budgetAssertions: Record<string, Assertion> = {\n 'largest-contentful-paint': ['warn', { maxNumericValue: LIGHTHOUSE_BUDGETS.lcpMs }],\n 'total-blocking-time': ['warn', { maxNumericValue: LIGHTHOUSE_BUDGETS.tbtMs }],\n 'cumulative-layout-shift': ['warn', { maxNumericValue: LIGHTHOUSE_BUDGETS.cls }],\n 'resource-summary:script:size': ['warn', { maxNumericValue: LIGHTHOUSE_BUDGETS.scriptBytes }],\n};\n\n/** Lighthouse's own mid-range phone profile (Moto G Power, simulated slow 4G, 4x CPU slowdown). */\nexport const mobileSettings = {\n formFactor: 'mobile',\n screenEmulation: { mobile: true, width: 412, height: 823, deviceScaleFactor: 1.75, disabled: false },\n throttlingMethod: 'simulate',\n throttling: { rttMs: 150, throughputKbps: 1638.4, cpuSlowdownMultiplier: 4 },\n} as const;\n\ninterface LhciConfig {\n ci: {\n collect?: { settings?: Record<string, unknown> } & Record<string, unknown>;\n assert?: { assertions?: Record<string, unknown> } & Record<string, unknown>;\n } & Record<string, unknown>;\n}\n\n/** Adds the mobile settings and budget assertions to an app's lighthouserc; app-set keys win. */\nexport function withBudgets<T extends LhciConfig>(config: T): T {\n const { collect = {}, assert = {} } = config.ci;\n return {\n ...config,\n ci: {\n ...config.ci,\n collect: { ...collect, settings: { ...mobileSettings, ...collect.settings } },\n assert: { ...assert, assertions: { ...budgetAssertions, ...assert.assertions } },\n },\n };\n}\n"]}
@@ -0,0 +1,34 @@
1
+ // src/lighthouse/index.ts
2
+ var LIGHTHOUSE_BUDGETS = {
3
+ lcpMs: 2500,
4
+ tbtMs: 200,
5
+ cls: 0.1,
6
+ scriptBytes: 300 * 1024
7
+ };
8
+ var budgetAssertions = {
9
+ "largest-contentful-paint": ["warn", { maxNumericValue: LIGHTHOUSE_BUDGETS.lcpMs }],
10
+ "total-blocking-time": ["warn", { maxNumericValue: LIGHTHOUSE_BUDGETS.tbtMs }],
11
+ "cumulative-layout-shift": ["warn", { maxNumericValue: LIGHTHOUSE_BUDGETS.cls }],
12
+ "resource-summary:script:size": ["warn", { maxNumericValue: LIGHTHOUSE_BUDGETS.scriptBytes }]
13
+ };
14
+ var mobileSettings = {
15
+ formFactor: "mobile",
16
+ screenEmulation: { mobile: true, width: 412, height: 823, deviceScaleFactor: 1.75, disabled: false },
17
+ throttlingMethod: "simulate",
18
+ throttling: { rttMs: 150, throughputKbps: 1638.4, cpuSlowdownMultiplier: 4 }
19
+ };
20
+ function withBudgets(config) {
21
+ const { collect = {}, assert = {} } = config.ci;
22
+ return {
23
+ ...config,
24
+ ci: {
25
+ ...config.ci,
26
+ collect: { ...collect, settings: { ...mobileSettings, ...collect.settings } },
27
+ assert: { ...assert, assertions: { ...budgetAssertions, ...assert.assertions } }
28
+ }
29
+ };
30
+ }
31
+
32
+ export { LIGHTHOUSE_BUDGETS, budgetAssertions, mobileSettings, withBudgets };
33
+ //# sourceMappingURL=index.mjs.map
34
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/lighthouse/index.ts"],"names":[],"mappings":";AACO,IAAM,kBAAA,GAAqB;AAAA,EAChC,KAAA,EAAO,IAAA;AAAA,EACP,KAAA,EAAO,GAAA;AAAA,EACP,GAAA,EAAK,GAAA;AAAA,EACL,aAAa,GAAA,GAAM;AACrB;AAKO,IAAM,gBAAA,GAA8C;AAAA,EACzD,4BAA4B,CAAC,MAAA,EA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: 2500,\n tbtMs: 200,\n cls: 0.1,\n scriptBytes: 300 * 1024,\n} as const;\n\ntype Assertion = ['warn' | 'error', Record<string, number>];\n\n/** Lighthouse CI assertions for the D-OBS-15 budgets; every entry is `warn`, never `error`. */\nexport const budgetAssertions: Record<string, Assertion> = {\n 'largest-contentful-paint': ['warn', { maxNumericValue: LIGHTHOUSE_BUDGETS.lcpMs }],\n 'total-blocking-time': ['warn', { maxNumericValue: LIGHTHOUSE_BUDGETS.tbtMs }],\n 'cumulative-layout-shift': ['warn', { maxNumericValue: LIGHTHOUSE_BUDGETS.cls }],\n 'resource-summary:script:size': ['warn', { maxNumericValue: LIGHTHOUSE_BUDGETS.scriptBytes }],\n};\n\n/** Lighthouse's own mid-range phone profile (Moto G Power, simulated slow 4G, 4x CPU slowdown). */\nexport const mobileSettings = {\n formFactor: 'mobile',\n screenEmulation: { mobile: true, width: 412, height: 823, deviceScaleFactor: 1.75, disabled: false },\n throttlingMethod: 'simulate',\n throttling: { rttMs: 150, throughputKbps: 1638.4, cpuSlowdownMultiplier: 4 },\n} as const;\n\ninterface LhciConfig {\n ci: {\n collect?: { settings?: Record<string, unknown> } & Record<string, unknown>;\n assert?: { assertions?: Record<string, unknown> } & Record<string, unknown>;\n } & Record<string, unknown>;\n}\n\n/** Adds the mobile settings and budget assertions to an app's lighthouserc; app-set keys win. */\nexport function withBudgets<T extends LhciConfig>(config: T): T {\n const { collect = {}, assert = {} } = config.ci;\n return {\n ...config,\n ci: {\n ...config.ci,\n collect: { ...collect, settings: { ...mobileSettings, ...collect.settings } },\n assert: { ...assert, assertions: { ...budgetAssertions, ...assert.assertions } },\n },\n };\n}\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dloizides/frontend-devtools",
3
- "version": "2.2.0",
4
- "description": "Shared RN-web dev tooling (dev-only) for the dloizides.com SaaS frontends: the custom ESLint plugin pack and rule packs (/eslint) and the test-results reporters (/test-results). initI18n moved to @dloizides/i18n in 2.0.0. Never imports a product.",
3
+ "version": "2.3.0",
4
+ "description": "Shared RN-web dev tooling (dev-only) for the dloizides.com SaaS frontends: the custom ESLint plugin pack and rule packs (/eslint) the test-results reporters (/test-results) and the Lighthouse CI budget preset (/lighthouse). initI18n moved to @dloizides/i18n in 2.0.0. Never imports a product.",
5
5
  "keywords": [
6
6
  "eslint",
7
7
  "eslint-plugin",
@@ -35,6 +35,16 @@
35
35
  "default": "./dist/eslint/index.mjs"
36
36
  }
37
37
  },
38
+ "./lighthouse": {
39
+ "require": {
40
+ "types": "./dist/lighthouse/index.d.ts",
41
+ "default": "./dist/lighthouse/index.js"
42
+ },
43
+ "import": {
44
+ "types": "./dist/lighthouse/index.d.mts",
45
+ "default": "./dist/lighthouse/index.mjs"
46
+ }
47
+ },
38
48
  "./test-results": {
39
49
  "require": {
40
50
  "types": "./dist/test-results/index.d.ts",