@blumintinc/eslint-plugin-blumint 1.20.159 → 1.20.160

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
@@ -223,7 +223,7 @@ function noFrontendImportsFromFunctionsPatterns(pattern) {
223
223
  module.exports = {
224
224
  meta: {
225
225
  name: '@blumintinc/eslint-plugin-blumint',
226
- version: '1.20.159',
226
+ version: '1.20.160',
227
227
  },
228
228
  parseOptions: {
229
229
  ecmaVersion: 2020,
@@ -323,6 +323,44 @@ function buildImportExtensionFix(fixer, program) {
323
323
  * that never renders. The report stands, the edit is withheld.
324
324
  */
325
325
  const isRewritableFunction = (node) => !node.async && !node.generator;
326
+ /**
327
+ * Whether the call registers the one module factory jest hoists.
328
+ *
329
+ * `jest.mock` alone: `babel-plugin-jest-hoist` carries no case for `doMock` or
330
+ * `setMock`, which exist precisely to run in place, so a factory passed to
331
+ * either keeps its access to the module's bindings and needs no carve-out.
332
+ */
333
+ function isHoistedMockCall(node) {
334
+ const { callee } = node;
335
+ if (callee.type !== utils_1.AST_NODE_TYPES.MemberExpression || callee.computed) {
336
+ return false;
337
+ }
338
+ const { object, property } = callee;
339
+ return (object.type === utils_1.AST_NODE_TYPES.Identifier &&
340
+ object.name === 'jest' &&
341
+ property.type === utils_1.AST_NODE_TYPES.Identifier &&
342
+ property.name === 'mock');
343
+ }
344
+ /**
345
+ * Whether the node sits inside the factory jest hoists — the second argument of
346
+ * the call. The module specifier that precedes it is evaluated in place and
347
+ * keeps its access to the file's imports, so only the factory subtree is out of
348
+ * reach.
349
+ */
350
+ function isInsideMockFactory(node) {
351
+ let child = node;
352
+ let parent = node.parent;
353
+ while (parent) {
354
+ if (parent.type === utils_1.AST_NODE_TYPES.CallExpression &&
355
+ parent.arguments[1] === child &&
356
+ isHoistedMockCall(parent)) {
357
+ return true;
358
+ }
359
+ child = parent;
360
+ parent = parent.parent;
361
+ }
362
+ return false;
363
+ }
326
364
  /**
327
365
  * Whether the emitted `memo(...)` call can reach the helper, and the import edit
328
366
  * that makes it so (null when the helper is already imported).
@@ -337,6 +375,15 @@ const isRewritableFunction = (node) => !node.async && !node.generator;
337
375
  * default import rather than a `memo` binding, so it never reaches this path.
338
376
  */
339
377
  function planMemoBinding(context, fixer, node) {
378
+ // Jest hoists a `jest.mock()` factory above the module's imports, so the
379
+ // helper is unbound when the factory runs and jest rejects the reference
380
+ // outright ("Invalid variable access: memo"). This holds whether the import
381
+ // is injected here or already present, so it is decided before the
382
+ // already-imported shortcut below. The report stands because legal spellings
383
+ // exist: `import { memo as mockMemo }`, or `jest.requireActual` in-factory.
384
+ if (isInsideMockFactory(node)) {
385
+ return { available: false, importFix: null };
386
+ }
340
387
  const existingMemo = ASTHelpers_1.ASTHelpers.findVariableInScope(ASTHelpers_1.ASTHelpers.getScope(context, node), MEMO_NAME);
341
388
  if (existingMemo && !bindsMemoHelper(existingMemo)) {
342
389
  return { available: false, importFix: null };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blumintinc/eslint-plugin-blumint",
3
- "version": "1.20.159",
3
+ "version": "1.20.160",
4
4
  "description": "Custom eslint rules for use within BluMint",
5
5
  "author": {
6
6
  "name": "Brodie McGuire",
@@ -1,4 +1,18 @@
1
1
  [
2
+ {
3
+ "version": "1.20.160",
4
+ "date": "2026-08-17T02:55:06.538Z",
5
+ "rules": [
6
+ {
7
+ "name": "require-memo",
8
+ "changeType": "fix",
9
+ "issues": [
10
+ 2028
11
+ ],
12
+ "summary": "decline the memo rewrite inside a jest.mock factory (closes #2028)"
13
+ }
14
+ ]
15
+ },
2
16
  {
3
17
  "version": "1.20.159",
4
18
  "date": "2026-08-17T02:05:07.694Z",