@blumintinc/eslint-plugin-blumint 1.19.18 → 1.19.20

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/lib/index.js CHANGED
@@ -222,7 +222,7 @@ function noFrontendImportsFromFunctionsPatterns(pattern) {
222
222
  module.exports = {
223
223
  meta: {
224
224
  name: '@blumintinc/eslint-plugin-blumint',
225
- version: '1.19.18',
225
+ version: '1.19.20',
226
226
  },
227
227
  parseOptions: {
228
228
  ecmaVersion: 2020,
@@ -1,6 +1,10 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.enforceAssertSafeObjectKey = void 0;
7
+ const path_1 = __importDefault(require("path"));
4
8
  const utils_1 = require("@typescript-eslint/utils");
5
9
  const createRule_1 = require("../utils/createRule");
6
10
  const ASTHelpers_1 = require("../utils/ASTHelpers");
@@ -31,13 +35,47 @@ exports.enforceAssertSafeObjectKey = (0, createRule_1.createRule)({
31
35
  create(context, [options]) {
32
36
  const importPath = options?.assertSafeImportPath || DEFAULT_IMPORT_PATH;
33
37
  let hasAssertSafeImport = false;
38
+ /**
39
+ * Computes the module specifier for the injected assertSafe import.
40
+ *
41
+ * `importPath` is anchored at the repo root (relative to process.cwd(),
42
+ * which is the repo root in real eslint runs), matching how
43
+ * avoid-utils-directory and test-file-location-enforcement treat paths.
44
+ * A bare repo-root specifier such as 'functions/src/util/assertSafe' is
45
+ * unresolvable inside the functions/ TS project, whose baseUrl is
46
+ * functions/: it would resolve to functions/functions/src/util/assertSafe,
47
+ * which does not exist. The specifier is therefore derived relative to the
48
+ * file being fixed so the emitted import resolves from that file's location.
49
+ */
50
+ const computeImportSpecifier = () => {
51
+ const rawFilename = context.getFilename().replace(/\\/g, '/');
52
+ // Virtual/stdin files (RuleTester default 'file.ts', '<input>', '<text>')
53
+ // are not absolute; we cannot anchor a relative path, so emit the
54
+ // configured path verbatim (preserves the option's literal value for
55
+ // non-file lints).
56
+ if (!path_1.default.isAbsolute(rawFilename)) {
57
+ return importPath;
58
+ }
59
+ const target = importPath
60
+ .replace(/\\/g, '/')
61
+ .replace(/\.(tsx?|jsx?|mts|cts)$/i, '');
62
+ const fileRelToCwd = path_1.default
63
+ .relative(process.cwd(), rawFilename)
64
+ .replace(/\\/g, '/');
65
+ const fileDir = path_1.default.posix.dirname(fileRelToCwd);
66
+ let specifier = path_1.default.posix.relative(fileDir, target);
67
+ if (!specifier.startsWith('.')) {
68
+ specifier = `./${specifier}`;
69
+ }
70
+ return specifier;
71
+ };
34
72
  /**
35
73
  * Helper function to add assertSafe import if needed
36
74
  */
37
75
  const addAssertSafeImport = (fixer) => {
38
76
  const program = context.sourceCode.ast;
39
77
  const firstImport = program.body.find((node) => node.type === utils_1.AST_NODE_TYPES.ImportDeclaration);
40
- const importStatement = `import { assertSafe } from '${importPath}';\n`;
78
+ const importStatement = `import { assertSafe } from '${computeImportSpecifier()}';\n`;
41
79
  if (firstImport) {
42
80
  return fixer.insertTextBefore(firstImport, importStatement);
43
81
  }
@@ -177,7 +177,11 @@ exports.preferMapOverConditionalDispatch = (0, createRule_1.createRule)({
177
177
  }
178
178
  let text;
179
179
  try {
180
- text = checker.typeToString(widened);
180
+ // Pass the expression's TS node as the enclosing declaration so the
181
+ // printer qualifies namespaced symbols to their scoped name (e.g.
182
+ // `JSX.Element`, not the DOM global `Element`) at the fix site.
183
+ const enclosing = esTreeNodeToTSNodeMap.get(expr);
184
+ text = checker.typeToString(widened, enclosing);
181
185
  }
182
186
  catch {
183
187
  return null;
@@ -192,9 +196,13 @@ exports.preferMapOverConditionalDispatch = (0, createRule_1.createRule)({
192
196
  }
193
197
  return parts.length > 0 ? parts.join(' | ') : null;
194
198
  }
195
- function discriminantTypeText(type) {
199
+ function discriminantTypeText(type, discriminant) {
196
200
  try {
197
- const text = checker.typeToString(type);
201
+ // Pass the discriminant's TS node as the enclosing declaration so the
202
+ // printer qualifies namespaced symbols to their scoped name at the fix
203
+ // site rather than printing an ambiguous short name.
204
+ const enclosing = esTreeNodeToTSNodeMap.get(discriminant);
205
+ const text = checker.typeToString(type, enclosing);
198
206
  return text && text !== 'error' ? text : null;
199
207
  }
200
208
  catch {
@@ -542,7 +550,7 @@ exports.preferMapOverConditionalDispatch = (0, createRule_1.createRule)({
542
550
  if (literalKeys.length === 0 || hasOther) {
543
551
  return null;
544
552
  }
545
- const dText = discriminantTypeText(type);
553
+ const dText = discriminantTypeText(type, discriminant);
546
554
  if (!dText) {
547
555
  return null;
548
556
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blumintinc/eslint-plugin-blumint",
3
- "version": "1.19.18",
3
+ "version": "1.19.20",
4
4
  "description": "Custom eslint rules for use within BluMint",
5
5
  "author": {
6
6
  "name": "Brodie McGuire",
@@ -1,4 +1,32 @@
1
1
  [
2
+ {
3
+ "version": "1.19.20",
4
+ "date": "2026-07-18T20:26:20.204Z",
5
+ "rules": [
6
+ {
7
+ "name": "prefer-map-over-conditional-dispatch",
8
+ "changeType": "fix",
9
+ "issues": [
10
+ 1322
11
+ ],
12
+ "summary": "qualify JSX value/discriminant type via enclosingDeclaration (closes #1322)"
13
+ }
14
+ ]
15
+ },
16
+ {
17
+ "version": "1.19.19",
18
+ "date": "2026-07-18T17:27:38.611Z",
19
+ "rules": [
20
+ {
21
+ "name": "enforce-assert-safe-object-key",
22
+ "changeType": "fix",
23
+ "issues": [
24
+ 1321
25
+ ],
26
+ "summary": "compute assertSafe import specifier relative to the fixed file (closes #1321)"
27
+ }
28
+ ]
29
+ },
2
30
  {
3
31
  "version": "1.19.18",
4
32
  "date": "2026-07-18T13:43:27.635Z",