@dloizides/frontend-devtools 2.0.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.
@@ -2132,6 +2132,103 @@ var no_raw_color_literal_default = {
2132
2132
  }
2133
2133
  };
2134
2134
 
2135
+ // src/rules/reimplemented-packages-registry.js
2136
+ var REIMPLEMENTED_PACKAGE_REGISTRY = [
2137
+ {
2138
+ id: "analytics",
2139
+ package: "@dloizides/analytics-web",
2140
+ use: "createAnalytics, track, createWebVitals",
2141
+ paths: [/\/src\/lib\/analytics\//, /\/UmamiClient\.[cm]?[jt]sx?$/, /\/MultiProviderClient\.[cm]?[jt]sx?$/, /\/useWebVitalsTracking\.[cm]?[jt]sx?$/],
2142
+ literals: []
2143
+ },
2144
+ {
2145
+ id: "bff-csrf",
2146
+ package: "@dloizides/bff-web-client",
2147
+ use: "createBffAxiosClient (default CSRF interceptor)",
2148
+ paths: [/\/bffCsrf\.[cm]?[jt]sx?$/],
2149
+ literals: [/^X-BFF-Csrf$/i]
2150
+ },
2151
+ {
2152
+ id: "forgot-password",
2153
+ package: "@dloizides/auth-web",
2154
+ use: "useBffForgotPassword, ForgotPasswordForm",
2155
+ paths: [/\/forgotPasswordRequest\.[cm]?[jt]sx?$/],
2156
+ literals: []
2157
+ },
2158
+ {
2159
+ id: "logger",
2160
+ package: "@dloizides/logging-web",
2161
+ use: "logger, LoggingService",
2162
+ paths: [/\/src\/(?:lib\/)?utils\/logger\.[cm]?[jt]sx?$/],
2163
+ literals: []
2164
+ }
2165
+ ];
2166
+
2167
+ // src/rules/no-reimplemented-package.js
2168
+ var TEST_FILE2 = /(?:\.(?:test|spec)\.[cm]?[jt]sx?$)|(?:\/__tests__\/)|(?:\/e2e\/)/;
2169
+ var SHARED_SOURCE = /\/(?:NpmPackages\/packages|node_modules)\//;
2170
+ function normalisePath2(filename) {
2171
+ return typeof filename === "string" ? filename.split("\\").join("/") : "";
2172
+ }
2173
+ function isExemptFile2(path2, allow) {
2174
+ if (!path2.includes("/src/")) return true;
2175
+ if (TEST_FILE2.test(path2) || SHARED_SOURCE.test(path2)) return true;
2176
+ return allow.some((fragment) => path2.includes(fragment));
2177
+ }
2178
+ function literalText(node) {
2179
+ if (node.type === "Literal") return typeof node.value === "string" ? node.value : "";
2180
+ return node.quasis.length === 1 ? node.quasis[0].value.cooked ?? "" : "";
2181
+ }
2182
+ var noReimplementedPackageRule = {
2183
+ meta: {
2184
+ type: "problem",
2185
+ docs: {
2186
+ description: "Flag app code that re-implements a capability a shared @dloizides package already provides.",
2187
+ recommended: false
2188
+ },
2189
+ schema: [
2190
+ {
2191
+ type: "object",
2192
+ properties: { allow: { type: "array", items: { type: "string" } } },
2193
+ additionalProperties: false
2194
+ }
2195
+ ],
2196
+ messages: {
2197
+ reimplemented: "This re-implements {{package}} ({{id}}). Use {{use}} from {{package}} instead (QUAL-ADOPT-1)."
2198
+ }
2199
+ },
2200
+ create(context) {
2201
+ const options = context.options[0] ?? {};
2202
+ const path2 = normalisePath2(context.filename ?? context.getFilename());
2203
+ if (isExemptFile2(path2, options.allow ?? [])) return {};
2204
+ const reported = /* @__PURE__ */ new Set();
2205
+ const report = (node, entry) => {
2206
+ if (reported.has(entry.id)) return;
2207
+ reported.add(entry.id);
2208
+ context.report({ node, messageId: "reimplemented", data: { id: entry.id, package: entry.package, use: entry.use } });
2209
+ };
2210
+ const checkLiteral = (node) => {
2211
+ const text = literalText(node);
2212
+ if (text === "") return;
2213
+ for (const entry of REIMPLEMENTED_PACKAGE_REGISTRY)
2214
+ if (entry.literals.some((pattern) => pattern.test(text))) report(node, entry);
2215
+ };
2216
+ return {
2217
+ Program(node) {
2218
+ for (const entry of REIMPLEMENTED_PACKAGE_REGISTRY)
2219
+ if (entry.paths.some((pattern) => pattern.test(path2))) report(node, entry);
2220
+ },
2221
+ Literal: checkLiteral,
2222
+ TemplateLiteral: checkLiteral
2223
+ };
2224
+ }
2225
+ };
2226
+ var no_reimplemented_package_default = {
2227
+ rules: {
2228
+ "no-reimplemented-package": noReimplementedPackageRule
2229
+ }
2230
+ };
2231
+
2135
2232
  // src/rules/prefer-const-enum.js
2136
2233
  function toPascalCase(value) {
2137
2234
  const words = value.replace(/([a-z])([A-Z])/g, "$1 $2").split(/[-_\s]+/).filter((w) => w.length > 0);
@@ -2203,17 +2300,17 @@ var prefer_const_enum_default = {
2203
2300
 
2204
2301
  // src/rules/query-key-factory.js
2205
2302
  var QUERY_KEY = "queryKey";
2206
- var TEST_FILE2 = /(?:\.(?:test|spec)\.[cm]?[jt]sx?$)|(?:\/__tests__\/)/;
2303
+ var TEST_FILE3 = /(?:\.(?:test|spec)\.[cm]?[jt]sx?$)|(?:\/__tests__\/)/;
2207
2304
  var FACTORY_FILE = /[kK]eys?(?:Factory)?\.[cm]?[jt]sx?$/;
2208
2305
  var DEFAULT_ALLOWED_PATH_FRAGMENTS2 = ["/generated/", "/autoGeneratedHooks/"];
2209
2306
  var INLINE_KEY_TYPES = /* @__PURE__ */ new Set(["ArrayExpression", "Literal", "TemplateLiteral"]);
2210
2307
  var TYPE_WRAPPERS = /* @__PURE__ */ new Set(["TSAsExpression", "TSSatisfiesExpression", "TSNonNullExpression"]);
2211
- function normalisePath2(filename) {
2308
+ function normalisePath3(filename) {
2212
2309
  return typeof filename === "string" ? filename.split("\\").join("/") : "";
2213
2310
  }
2214
- function isExemptFile2(filename, allow) {
2215
- const path2 = normalisePath2(filename);
2216
- if (TEST_FILE2.test(path2)) return true;
2311
+ function isExemptFile3(filename, allow) {
2312
+ const path2 = normalisePath3(filename);
2313
+ if (TEST_FILE3.test(path2)) return true;
2217
2314
  if (FACTORY_FILE.test(path2)) return true;
2218
2315
  return [...DEFAULT_ALLOWED_PATH_FRAGMENTS2, ...allow].some((fragment) => path2.includes(fragment));
2219
2316
  }
@@ -2248,7 +2345,7 @@ var rule4 = {
2248
2345
  const options = context.options[0] ?? {};
2249
2346
  const allow = Array.isArray(options.allow) ? options.allow : [];
2250
2347
  const filename = context.filename ?? context.getFilename();
2251
- if (isExemptFile2(filename, allow)) return {};
2348
+ if (isExemptFile3(filename, allow)) return {};
2252
2349
  return {
2253
2350
  Property(node) {
2254
2351
  if (!isQueryKeyProperty(node)) return;
@@ -2942,6 +3039,7 @@ var ruleModules = [
2942
3039
  no_product_imports_in_shared_default,
2943
3040
  no_raw_backend_fetch_default,
2944
3041
  no_raw_color_literal_default,
3042
+ no_reimplemented_package_default,
2945
3043
  prefer_const_enum_default,
2946
3044
  query_key_factory_default,
2947
3045
  require_stable_hook_args_default,
@@ -3060,11 +3158,18 @@ var apiConfig = {
3060
3158
  "@dloizides/no-raw-backend-fetch": "error"
3061
3159
  }
3062
3160
  };
3161
+ var REUSE_RULE_NAMES = ["no-reimplemented-package"];
3162
+ var reuseConfig = {
3163
+ plugins: commentsConfig.plugins,
3164
+ rules: {
3165
+ "@dloizides/no-reimplemented-package": "error"
3166
+ }
3167
+ };
3063
3168
  var recommendedConfig = {
3064
3169
  plugins: commentsConfig.plugins,
3065
3170
  rules: { ...commentsConfig.rules, ...rowActionsConfig.rules, ...apiConfig.rules }
3066
3171
  };
3067
3172
 
3068
- export { API_RULE_NAMES, COMMENT_RULE_NAMES, GAME_RULE_NAMES, HOUSE_PATTERN_RULE_NAMES, ROW_ACTION_RULE_NAMES, apiConfig, commentsConfig, gameConfig, legacyPlugins, patternPacksConfig, plugin, recommendedConfig, rowActionsConfig, ruleNames, rules };
3173
+ export { API_RULE_NAMES, COMMENT_RULE_NAMES, GAME_RULE_NAMES, HOUSE_PATTERN_RULE_NAMES, REUSE_RULE_NAMES, ROW_ACTION_RULE_NAMES, apiConfig, commentsConfig, gameConfig, legacyPlugins, patternPacksConfig, plugin, recommendedConfig, reuseConfig, rowActionsConfig, ruleNames, rules };
3069
3174
  //# sourceMappingURL=index.mjs.map
3070
3175
  //# sourceMappingURL=index.mjs.map