@dloizides/frontend-devtools 1.10.0 → 2.1.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
@@ -5,6 +5,23 @@ All notable changes to `@dloizides/frontend-devtools` are documented here.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [2.1.0] - 2026-10-20
9
+
10
+ QUAL-ADOPT-1 "Fail lint/arch tests when an app re-implements an existing package" (TS half).
11
+
12
+ ### Added
13
+ - `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.
14
+ - `reuseConfig` + `REUSE_RULE_NAMES` (opt-in, not part of `recommendedConfig`).
15
+
16
+ ## [2.0.0] - 2026-10-20
17
+
18
+ D-PAT-15 "Move initI18n out of frontend-devtools so it is dev-only".
19
+
20
+ ### Removed (BREAKING)
21
+ - `initI18n` and `InitI18nOptions`: import them from `@dloizides/i18n` (>= 1.1.0), same signature: `import { initI18n } from '@dloizides/i18n';`.
22
+ - The root entry (`@dloizides/frontend-devtools`): it exported only `initI18n`. Use the `/eslint` and `/test-results` subpaths.
23
+ - The `i18next` and `react-i18next` optional peer dependencies.
24
+
8
25
  ## [1.10.0] - 2026-10-19
9
26
 
10
27
  PATTERN-1.12 "TS rule packs + house rules in frontend-devtools" (D-PAT-12 "Whole rule packs as warnings, one shared approach").
package/README.md CHANGED
@@ -6,11 +6,10 @@ product-agnostic concerns that were duplicated byte-for-byte across
6
6
 
7
7
  1. The **custom ESLint rule pack** (17 rules) — previously 17 identical
8
8
  `eslint-plugins/*.mjs` files in each app.
9
- 2. **`initI18n()`** — the parameterized i18next + react-i18next init factory —
10
- previously an identical `src/localization/i18n.ts` in each app.
9
+ 2. **`initI18n()` moved to `@dloizides/i18n` in 2.0.0** — this package is dev-only:
10
+ `import { initI18n } from '@dloizides/i18n';` (same signature).
11
11
 
12
- > **Decoupling:** the package owns the *logic* (rule implementations + the
13
- > i18next `.use().init()` chain). Each app owns its *config* — which rules it
12
+ > **Decoupling:** the package owns the *logic* (rule implementations). Each app owns its *config* — which rules it
14
13
  > enables and with what options, plus its own `locales/*.json` strings.
15
14
  > This package **never imports a product**.
16
15
 
@@ -20,12 +19,12 @@ product-agnostic concerns that were duplicated byte-for-byte across
20
19
  npm install -D @dloizides/frontend-devtools
21
20
  ```
22
21
 
23
- `eslint`, `i18next`, and `react-i18next` are optional peer dependencies — apps
24
- that only use one half don't need the other's peers.
22
+ `eslint` is an optional peer dependency. There is no root entry since 2.0.0: import from
23
+ `@dloizides/frontend-devtools/eslint` or `@dloizides/frontend-devtools/test-results`.
25
24
 
26
25
  ## ESLint rule pack
27
26
 
28
- Import from the root or the `/eslint` subpath. Three shapes are exported:
27
+ Import from the `/eslint` subpath. Three shapes are exported:
29
28
 
30
29
  | Export | Use when |
31
30
  | --- | --- |
@@ -136,38 +135,14 @@ by `recommendedConfig` and `rowActionsConfig`.
136
135
  `ruleNames` exports the sorted list for migration assertions (prove no rule was
137
136
  dropped).
138
137
 
139
- ## i18n init factory
138
+ ## i18n init factory — moved
140
139
 
141
- ```ts
142
- // src/localization/i18n.ts
143
- import { initI18n } from '@dloizides/frontend-devtools';
144
- import * as Localization from 'expo-localization';
145
- import en from './locales/en.json';
146
-
147
- const i18n = initI18n({
148
- resources: { en: { translation: en } },
149
- lng: Localization.getLocales()[0]?.languageCode, // optional; defaults to fallback
150
- });
140
+ `initI18n` and `InitI18nOptions` live in `@dloizides/i18n` (>= 1.1.0) since 2.0.0:
151
141
 
152
- export default i18n;
142
+ ```ts
143
+ import { initI18n } from '@dloizides/i18n';
153
144
  ```
154
145
 
155
- ### `InitI18nOptions`
156
-
157
- | Field | Type | Default | Notes |
158
- | --- | --- | --- | --- |
159
- | `resources` | `Resource` | — (required) | App-owned strings bundle. |
160
- | `lng` | `string` | `fallbackLng` | Active language. |
161
- | `fallbackLng` | `string` | `'en'` | Fallback for missing keys. |
162
- | `escapeValue` | `boolean` | `false` | React already escapes output. |
163
- | `defaultNS` | `string \| string[]` | i18next default | Optional. |
164
- | `ns` | `string \| string[]` | — | Optional; for multi-namespace apps. |
165
-
166
- The factory wires `react-i18next` into the i18next singleton, runs `.init()`,
167
- swallows the (synchronous-for-in-memory) init rejection, and returns the
168
- singleton. The `FM()` / `FD()` helpers + `locales/*.json` stay **app-owned**
169
- (per the SaaS code standards).
170
-
171
146
  ## Scripts
172
147
 
173
148
  | Script | What |
@@ -90,7 +90,10 @@ declare const gameConfig: FlatConfig;
90
90
  declare const API_RULE_NAMES: readonly string[];
91
91
  /** PAT-API-1: the backend is called through the shared client or generated hooks, never raw fetch/axios. */
92
92
  declare const apiConfig: FlatConfig;
93
+ declare const REUSE_RULE_NAMES: readonly string[];
94
+ /** QUAL-ADOPT-1: app code may not re-implement a capability a shared @dloizides package provides. Opt-in. */
95
+ declare const reuseConfig: FlatConfig;
93
96
  /** The recommended flat-config block: every rule the pack enables by default, at error. */
94
97
  declare const recommendedConfig: FlatConfig;
95
98
 
96
- export { API_RULE_NAMES, COMMENT_RULE_NAMES, type CustomRule, type FlatConfig, type FlatConfigPlugin, GAME_RULE_NAMES, HOUSE_PATTERN_RULE_NAMES, ROW_ACTION_RULE_NAMES, type SingleRulePlugin, apiConfig, commentsConfig, gameConfig, legacyPlugins, patternPacksConfig, plugin, recommendedConfig, rowActionsConfig, ruleNames, rules };
99
+ export { API_RULE_NAMES, COMMENT_RULE_NAMES, type CustomRule, type FlatConfig, type FlatConfigPlugin, GAME_RULE_NAMES, HOUSE_PATTERN_RULE_NAMES, REUSE_RULE_NAMES, ROW_ACTION_RULE_NAMES, type SingleRulePlugin, apiConfig, commentsConfig, gameConfig, legacyPlugins, patternPacksConfig, plugin, recommendedConfig, reuseConfig, rowActionsConfig, ruleNames, rules };
@@ -90,7 +90,10 @@ declare const gameConfig: FlatConfig;
90
90
  declare const API_RULE_NAMES: readonly string[];
91
91
  /** PAT-API-1: the backend is called through the shared client or generated hooks, never raw fetch/axios. */
92
92
  declare const apiConfig: FlatConfig;
93
+ declare const REUSE_RULE_NAMES: readonly string[];
94
+ /** QUAL-ADOPT-1: app code may not re-implement a capability a shared @dloizides package provides. Opt-in. */
95
+ declare const reuseConfig: FlatConfig;
93
96
  /** The recommended flat-config block: every rule the pack enables by default, at error. */
94
97
  declare const recommendedConfig: FlatConfig;
95
98
 
96
- export { API_RULE_NAMES, COMMENT_RULE_NAMES, type CustomRule, type FlatConfig, type FlatConfigPlugin, GAME_RULE_NAMES, HOUSE_PATTERN_RULE_NAMES, ROW_ACTION_RULE_NAMES, type SingleRulePlugin, apiConfig, commentsConfig, gameConfig, legacyPlugins, patternPacksConfig, plugin, recommendedConfig, rowActionsConfig, ruleNames, rules };
99
+ export { API_RULE_NAMES, COMMENT_RULE_NAMES, type CustomRule, type FlatConfig, type FlatConfigPlugin, GAME_RULE_NAMES, HOUSE_PATTERN_RULE_NAMES, REUSE_RULE_NAMES, ROW_ACTION_RULE_NAMES, type SingleRulePlugin, apiConfig, commentsConfig, gameConfig, legacyPlugins, patternPacksConfig, plugin, recommendedConfig, reuseConfig, rowActionsConfig, ruleNames, rules };
@@ -2143,6 +2143,103 @@ var no_raw_color_literal_default = {
2143
2143
  }
2144
2144
  };
2145
2145
 
2146
+ // src/rules/reimplemented-packages-registry.js
2147
+ var REIMPLEMENTED_PACKAGE_REGISTRY = [
2148
+ {
2149
+ id: "analytics",
2150
+ package: "@dloizides/analytics-web",
2151
+ use: "createAnalytics, track, createWebVitals",
2152
+ paths: [/\/src\/lib\/analytics\//, /\/UmamiClient\.[cm]?[jt]sx?$/, /\/MultiProviderClient\.[cm]?[jt]sx?$/, /\/useWebVitalsTracking\.[cm]?[jt]sx?$/],
2153
+ literals: []
2154
+ },
2155
+ {
2156
+ id: "bff-csrf",
2157
+ package: "@dloizides/bff-web-client",
2158
+ use: "createBffAxiosClient (default CSRF interceptor)",
2159
+ paths: [/\/bffCsrf\.[cm]?[jt]sx?$/],
2160
+ literals: [/^X-BFF-Csrf$/i]
2161
+ },
2162
+ {
2163
+ id: "forgot-password",
2164
+ package: "@dloizides/auth-web",
2165
+ use: "useBffForgotPassword, ForgotPasswordForm",
2166
+ paths: [/\/forgotPasswordRequest\.[cm]?[jt]sx?$/],
2167
+ literals: []
2168
+ },
2169
+ {
2170
+ id: "logger",
2171
+ package: "@dloizides/logging-web",
2172
+ use: "logger, LoggingService",
2173
+ paths: [/\/src\/(?:lib\/)?utils\/logger\.[cm]?[jt]sx?$/],
2174
+ literals: []
2175
+ }
2176
+ ];
2177
+
2178
+ // src/rules/no-reimplemented-package.js
2179
+ var TEST_FILE2 = /(?:\.(?:test|spec)\.[cm]?[jt]sx?$)|(?:\/__tests__\/)|(?:\/e2e\/)/;
2180
+ var SHARED_SOURCE = /\/(?:NpmPackages\/packages|node_modules)\//;
2181
+ function normalisePath2(filename) {
2182
+ return typeof filename === "string" ? filename.split("\\").join("/") : "";
2183
+ }
2184
+ function isExemptFile2(path2, allow) {
2185
+ if (!path2.includes("/src/")) return true;
2186
+ if (TEST_FILE2.test(path2) || SHARED_SOURCE.test(path2)) return true;
2187
+ return allow.some((fragment) => path2.includes(fragment));
2188
+ }
2189
+ function literalText(node) {
2190
+ if (node.type === "Literal") return typeof node.value === "string" ? node.value : "";
2191
+ return node.quasis.length === 1 ? node.quasis[0].value.cooked ?? "" : "";
2192
+ }
2193
+ var noReimplementedPackageRule = {
2194
+ meta: {
2195
+ type: "problem",
2196
+ docs: {
2197
+ description: "Flag app code that re-implements a capability a shared @dloizides package already provides.",
2198
+ recommended: false
2199
+ },
2200
+ schema: [
2201
+ {
2202
+ type: "object",
2203
+ properties: { allow: { type: "array", items: { type: "string" } } },
2204
+ additionalProperties: false
2205
+ }
2206
+ ],
2207
+ messages: {
2208
+ reimplemented: "This re-implements {{package}} ({{id}}). Use {{use}} from {{package}} instead (QUAL-ADOPT-1)."
2209
+ }
2210
+ },
2211
+ create(context) {
2212
+ const options = context.options[0] ?? {};
2213
+ const path2 = normalisePath2(context.filename ?? context.getFilename());
2214
+ if (isExemptFile2(path2, options.allow ?? [])) return {};
2215
+ const reported = /* @__PURE__ */ new Set();
2216
+ const report = (node, entry) => {
2217
+ if (reported.has(entry.id)) return;
2218
+ reported.add(entry.id);
2219
+ context.report({ node, messageId: "reimplemented", data: { id: entry.id, package: entry.package, use: entry.use } });
2220
+ };
2221
+ const checkLiteral = (node) => {
2222
+ const text = literalText(node);
2223
+ if (text === "") return;
2224
+ for (const entry of REIMPLEMENTED_PACKAGE_REGISTRY)
2225
+ if (entry.literals.some((pattern) => pattern.test(text))) report(node, entry);
2226
+ };
2227
+ return {
2228
+ Program(node) {
2229
+ for (const entry of REIMPLEMENTED_PACKAGE_REGISTRY)
2230
+ if (entry.paths.some((pattern) => pattern.test(path2))) report(node, entry);
2231
+ },
2232
+ Literal: checkLiteral,
2233
+ TemplateLiteral: checkLiteral
2234
+ };
2235
+ }
2236
+ };
2237
+ var no_reimplemented_package_default = {
2238
+ rules: {
2239
+ "no-reimplemented-package": noReimplementedPackageRule
2240
+ }
2241
+ };
2242
+
2146
2243
  // src/rules/prefer-const-enum.js
2147
2244
  function toPascalCase(value) {
2148
2245
  const words = value.replace(/([a-z])([A-Z])/g, "$1 $2").split(/[-_\s]+/).filter((w) => w.length > 0);
@@ -2214,17 +2311,17 @@ var prefer_const_enum_default = {
2214
2311
 
2215
2312
  // src/rules/query-key-factory.js
2216
2313
  var QUERY_KEY = "queryKey";
2217
- var TEST_FILE2 = /(?:\.(?:test|spec)\.[cm]?[jt]sx?$)|(?:\/__tests__\/)/;
2314
+ var TEST_FILE3 = /(?:\.(?:test|spec)\.[cm]?[jt]sx?$)|(?:\/__tests__\/)/;
2218
2315
  var FACTORY_FILE = /[kK]eys?(?:Factory)?\.[cm]?[jt]sx?$/;
2219
2316
  var DEFAULT_ALLOWED_PATH_FRAGMENTS2 = ["/generated/", "/autoGeneratedHooks/"];
2220
2317
  var INLINE_KEY_TYPES = /* @__PURE__ */ new Set(["ArrayExpression", "Literal", "TemplateLiteral"]);
2221
2318
  var TYPE_WRAPPERS = /* @__PURE__ */ new Set(["TSAsExpression", "TSSatisfiesExpression", "TSNonNullExpression"]);
2222
- function normalisePath2(filename) {
2319
+ function normalisePath3(filename) {
2223
2320
  return typeof filename === "string" ? filename.split("\\").join("/") : "";
2224
2321
  }
2225
- function isExemptFile2(filename, allow) {
2226
- const path2 = normalisePath2(filename);
2227
- if (TEST_FILE2.test(path2)) return true;
2322
+ function isExemptFile3(filename, allow) {
2323
+ const path2 = normalisePath3(filename);
2324
+ if (TEST_FILE3.test(path2)) return true;
2228
2325
  if (FACTORY_FILE.test(path2)) return true;
2229
2326
  return [...DEFAULT_ALLOWED_PATH_FRAGMENTS2, ...allow].some((fragment) => path2.includes(fragment));
2230
2327
  }
@@ -2259,7 +2356,7 @@ var rule4 = {
2259
2356
  const options = context.options[0] ?? {};
2260
2357
  const allow = Array.isArray(options.allow) ? options.allow : [];
2261
2358
  const filename = context.filename ?? context.getFilename();
2262
- if (isExemptFile2(filename, allow)) return {};
2359
+ if (isExemptFile3(filename, allow)) return {};
2263
2360
  return {
2264
2361
  Property(node) {
2265
2362
  if (!isQueryKeyProperty(node)) return;
@@ -2953,6 +3050,7 @@ var ruleModules = [
2953
3050
  no_product_imports_in_shared_default,
2954
3051
  no_raw_backend_fetch_default,
2955
3052
  no_raw_color_literal_default,
3053
+ no_reimplemented_package_default,
2956
3054
  prefer_const_enum_default,
2957
3055
  query_key_factory_default,
2958
3056
  require_stable_hook_args_default,
@@ -3071,6 +3169,13 @@ var apiConfig = {
3071
3169
  "@dloizides/no-raw-backend-fetch": "error"
3072
3170
  }
3073
3171
  };
3172
+ var REUSE_RULE_NAMES = ["no-reimplemented-package"];
3173
+ var reuseConfig = {
3174
+ plugins: commentsConfig.plugins,
3175
+ rules: {
3176
+ "@dloizides/no-reimplemented-package": "error"
3177
+ }
3178
+ };
3074
3179
  var recommendedConfig = {
3075
3180
  plugins: commentsConfig.plugins,
3076
3181
  rules: { ...commentsConfig.rules, ...rowActionsConfig.rules, ...apiConfig.rules }
@@ -3080,6 +3185,7 @@ exports.API_RULE_NAMES = API_RULE_NAMES;
3080
3185
  exports.COMMENT_RULE_NAMES = COMMENT_RULE_NAMES;
3081
3186
  exports.GAME_RULE_NAMES = GAME_RULE_NAMES;
3082
3187
  exports.HOUSE_PATTERN_RULE_NAMES = HOUSE_PATTERN_RULE_NAMES;
3188
+ exports.REUSE_RULE_NAMES = REUSE_RULE_NAMES;
3083
3189
  exports.ROW_ACTION_RULE_NAMES = ROW_ACTION_RULE_NAMES;
3084
3190
  exports.apiConfig = apiConfig;
3085
3191
  exports.commentsConfig = commentsConfig;
@@ -3088,6 +3194,7 @@ exports.legacyPlugins = legacyPlugins;
3088
3194
  exports.patternPacksConfig = patternPacksConfig;
3089
3195
  exports.plugin = plugin;
3090
3196
  exports.recommendedConfig = recommendedConfig;
3197
+ exports.reuseConfig = reuseConfig;
3091
3198
  exports.rowActionsConfig = rowActionsConfig;
3092
3199
  exports.ruleNames = ruleNames;
3093
3200
  exports.rules = rules;