@dloizides/frontend-devtools 2.4.0 → 2.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.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,13 @@ 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.5.0] - 2026-11-16
9
+
10
+ MODC-1 "Module C unified console", D-MC-46 "AC-MC-14: the lint rule flags our backend hosts".
11
+
12
+ ### Added
13
+ - `no-raw-backend-fetch` option `backendHosts` (exact hostnames or `*.suffix`): an absolute literal URL to one of our backend hosts is reported instead of being treated as third-party. Default `[]` keeps 2.4.0 behaviour.
14
+
8
15
  ## [2.4.0] - 2026-11-03
9
16
 
10
17
  UI-COMPOSE-1 "Extract shared UI from the start; compose small single-purpose parts", D-COMPOSE-2 "Single responsibility, few props, compose with slots".
package/README.md CHANGED
@@ -132,6 +132,21 @@ a prop passed in. Fix: build row actions once per entity with `defineRowActions`
132
132
  `*RowActions` module; a table may only omit an action with a reason. Enabled at `error`
133
133
  by `recommendedConfig` and `rowActionsConfig`.
134
134
 
135
+ #### `no-raw-backend-fetch`
136
+
137
+ PAT-API-1: app code calls the backend through the shared client or generated hooks, never
138
+ raw `fetch()` or `axios`. An absolute literal URL (`https://host/...`) is treated as a
139
+ third-party call and allowed. Options:
140
+
141
+ - `allow` (string[]): extra path fragments where raw fetch is allowed.
142
+ - `backendHosts` (string[], default `[]`): hostnames of our own backends. A literal URL whose
143
+ host matches is reported even though it is absolute. Entries are exact (`aml.example.com`)
144
+ or `*.suffix` (`*.dloizides.com` matches any subdomain, not the bare domain). Case-insensitive.
145
+
146
+ ```js
147
+ '@dloizides/no-raw-backend-fetch': ['error', { backendHosts: ['aml.dloizides.com', '*.proovid.com'] }],
148
+ ```
149
+
135
150
  `ruleNames` exports the sorted list for migration assertions (prove no rule was
136
151
  dropped).
137
152
 
@@ -2192,6 +2192,8 @@ var TEST_FILE = /(?:\.(?:test|spec)\.[cm]?[jt]sx?$)|(?:\/__tests__\/)/;
2192
2192
  var EXEMPT_URL_SCHEME = /^\s*(?:data|blob):/i;
2193
2193
  var ABSOLUTE_HTTP_URL = /^https?:\/\/[^/\s]+\//i;
2194
2194
  var ABSOLUTE_HTTP_LITERAL = /^https?:\/\/[^/\s]+(?:[/?#]|$)/i;
2195
+ var URL_HOST = /^https?:\/\/([^/\s?#:@]+)/i;
2196
+ var WILDCARD_PREFIX = "*.";
2195
2197
  var URL_OBJECTS = /* @__PURE__ */ new Set(["URL", "webkitURL"]);
2196
2198
  var GLOBAL_OBJECTS = /* @__PURE__ */ new Set(["window", "globalThis", "self"]);
2197
2199
  var AXIOS_MODULE = "axios";
@@ -2228,6 +2230,19 @@ function isThirdPartyLiteralUrl(node) {
2228
2230
  const head = node.quasis[0].value.cooked ?? "";
2229
2231
  return node.expressions.length === 0 ? ABSOLUTE_HTTP_LITERAL.test(head) : ABSOLUTE_HTTP_URL.test(head);
2230
2232
  }
2233
+ function literalUrlHost(node) {
2234
+ const match = URL_HOST.exec(leadingText(node));
2235
+ return match === null ? "" : match[1].toLowerCase();
2236
+ }
2237
+ function hostMatches(host, pattern) {
2238
+ const wanted = pattern.toLowerCase();
2239
+ if (!wanted.startsWith(WILDCARD_PREFIX)) return host === wanted;
2240
+ return host.endsWith(wanted.slice(1));
2241
+ }
2242
+ function isBackendHostUrl(node, backendHosts) {
2243
+ const host = literalUrlHost(node);
2244
+ return host !== "" && backendHosts.some((pattern) => hostMatches(host, pattern));
2245
+ }
2231
2246
  function unwrapExpression(node) {
2232
2247
  let current = node;
2233
2248
  while (current !== void 0 && current !== null && ["TSAsExpression", "TSNonNullExpression", "TSTypeAssertion", "TSSatisfiesExpression"].includes(current.type))
@@ -2279,9 +2294,10 @@ function scopeOf(context, node) {
2279
2294
  const sourceCode = context.sourceCode ?? context.getSourceCode();
2280
2295
  return typeof sourceCode.getScope === "function" ? sourceCode.getScope(node) : context.getScope();
2281
2296
  }
2282
- function isExemptFetchTarget(context, node) {
2297
+ function isExemptFetchTarget(context, node, backendHosts) {
2283
2298
  const target = node.arguments[0];
2284
- if (isDataOrBlobUrl(target) || isThirdPartyLiteralUrl(target)) return true;
2299
+ if (isDataOrBlobUrl(target)) return true;
2300
+ if (isThirdPartyLiteralUrl(target)) return !isBackendHostUrl(target, backendHosts);
2285
2301
  return isLocalObjectUrl(target, scopeOf(context, node));
2286
2302
  }
2287
2303
  function isAxiosSource(node) {
@@ -2304,7 +2320,8 @@ var noRawBackendFetchRule = {
2304
2320
  {
2305
2321
  type: "object",
2306
2322
  properties: {
2307
- allow: { type: "array", items: { type: "string" } }
2323
+ allow: { type: "array", items: { type: "string" } },
2324
+ backendHosts: { type: "array", items: { type: "string" } }
2308
2325
  },
2309
2326
  additionalProperties: false
2310
2327
  }
@@ -2317,6 +2334,7 @@ var noRawBackendFetchRule = {
2317
2334
  create(context) {
2318
2335
  const options = context.options[0] ?? {};
2319
2336
  const allow = Array.isArray(options.allow) ? options.allow : [];
2337
+ const backendHosts = Array.isArray(options.backendHosts) ? options.backendHosts : [];
2320
2338
  const filename = context.filename ?? context.getFilename();
2321
2339
  if (isExemptFile(filename, allow)) return {};
2322
2340
  const sourceCode = context.sourceCode ?? context.getSourceCode();
@@ -2324,7 +2342,7 @@ var noRawBackendFetchRule = {
2324
2342
  return {
2325
2343
  CallExpression(node) {
2326
2344
  if (isFetchCallee(node.callee)) {
2327
- if (!isExemptFetchTarget(context, node)) context.report({ node, messageId: "rawFetch" });
2345
+ if (!isExemptFetchTarget(context, node, backendHosts)) context.report({ node, messageId: "rawFetch" });
2328
2346
  return;
2329
2347
  }
2330
2348
  const isRequire = node.callee.type === "Identifier" && node.callee.name === "require";