@blumintinc/eslint-plugin-blumint 1.19.15 → 1.19.17

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.15',
225
+ version: '1.19.17',
226
226
  },
227
227
  parseOptions: {
228
228
  ecmaVersion: 2020,
@@ -661,6 +661,15 @@ exports.preferGetterOverParameterlessMethod = (0, createRule_1.createRule)({
661
661
  ? (suggestedNameCounts.get(classBody)?.get(scopeKey) ?? 0) > 1
662
662
  : false;
663
663
  const isAsync = node.value.async;
664
+ // Only `private` methods are safe to autofix. A public / protected /
665
+ // unspecified-accessibility method is API surface whose call sites of
666
+ // the form `instance.method()` may live in other files this
667
+ // single-file rule never sees. Converting such a method to a getter
668
+ // silently breaks every external caller (the call would invoke the
669
+ // getter's return value), so the fix must be withheld for anything
670
+ // not demonstrably private. The report (nudge) is still emitted.
671
+ const isPrivate = node.accessibility === 'private' ||
672
+ node.key.type === utils_1.AST_NODE_TYPES.PrivateIdentifier;
664
673
  context.report({
665
674
  node: node.key,
666
675
  messageId: sideEffectReason
@@ -671,7 +680,8 @@ exports.preferGetterOverParameterlessMethod = (0, createRule_1.createRule)({
671
680
  suggestedName,
672
681
  reason: sideEffectReason ?? 'it returns a value',
673
682
  },
674
- fix: sideEffectReason ||
683
+ fix: !isPrivate ||
684
+ sideEffectReason ||
675
685
  isAsync ||
676
686
  !leftParen ||
677
687
  !rightParen ||
@@ -138,6 +138,37 @@ function isIterationMethodCallback(node) {
138
138
  callee.property.type === utils_1.AST_NODE_TYPES.Identifier &&
139
139
  ITERATION_METHODS.has(callee.property.name));
140
140
  }
141
+ /**
142
+ * True when the NEAREST enclosing function of `node` is itself an Array
143
+ * iteration-method callback (`arr.map((x) => ({ … }))`, `.filter`, `.reduce`,
144
+ * `.forEach`, `.sort`, ...). This extends the `isIterationMethodCallback`
145
+ * exemption (issue #1290) from the callback function itself down to the
146
+ * object/array literals created directly inside its body (issue #1319): such a
147
+ * literal is a per-iteration value discarded along with the mapped result, so
148
+ * its identity is never observed. The rule's own remediation is unfollowable at
149
+ * the literal — `useMemo` cannot run per-iteration inside a `.map` loop, and a
150
+ * literal closing over the callback parameter cannot be hoisted to module
151
+ * scope. The memoizable unit is the whole `.map()` call:
152
+ * `const tabs = useMemo(() => arr.map((x) => ({ … })), [arr])`.
153
+ *
154
+ * The walk starts at `node` and stops at the FIRST function encountered
155
+ * (including `node` itself when `node` is a function). Keying on the nearest
156
+ * function — not any ancestor — is what preserves the #1290 scope guard: a
157
+ * nested, non-iteration callback inside the map body (e.g. an `onClick` handler
158
+ * that persists as a JSX prop) is the nearest function for any literal in its
159
+ * body, so those literals stay flagged, and the handler itself (its own nearest
160
+ * function is itself) stays flagged too.
161
+ */
162
+ function isInsideIterationMethodCallback(node) {
163
+ let current = node;
164
+ while (current) {
165
+ if (isFunctionNode(current)) {
166
+ return isIterationMethodCallback(current);
167
+ }
168
+ current = current.parent;
169
+ }
170
+ return false;
171
+ }
141
172
  /**
142
173
  * Type guard for parenthesized expressions to unwrap safely.
143
174
  * @param node Node to evaluate.
@@ -838,7 +869,15 @@ exports.reactMemoizeLiterals = (0, createRule_1.createRule)({
838
869
  // to module level, and useCallback can't run inside a .map loop. Inline
839
870
  // functions passed as JSX-attribute props *inside* the callback body are
840
871
  // separate nodes and remain flagged.
841
- if (isIterationMethodCallback(node)) {
872
+ //
873
+ // The same rationale exempts object/array literals created directly
874
+ // inside such a callback (issue #1319): they are per-iteration values
875
+ // discarded with the mapped result, `useMemo` cannot run inside the loop,
876
+ // and the memoizable unit is the enclosing `.map()` call. The guard keys
877
+ // on the NEAREST enclosing function, so a literal inside a nested,
878
+ // non-iteration callback (e.g. an `onClick` handler) is NOT exempted.
879
+ if (isIterationMethodCallback(node) ||
880
+ isInsideIterationMethodCallback(node)) {
842
881
  return;
843
882
  }
844
883
  // Inline literals that resolve to a style JSX attribute (sx, style),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blumintinc/eslint-plugin-blumint",
3
- "version": "1.19.15",
3
+ "version": "1.19.17",
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.17",
4
+ "date": "2026-07-18T07:27:36.853Z",
5
+ "rules": [
6
+ {
7
+ "name": "react-memoize-literals",
8
+ "changeType": "fix",
9
+ "issues": [
10
+ 1319
11
+ ],
12
+ "summary": "exempt literals inside iteration-method callbacks (closes #1319)"
13
+ }
14
+ ]
15
+ },
16
+ {
17
+ "version": "1.19.16",
18
+ "date": "2026-07-18T06:29:03.568Z",
19
+ "rules": [
20
+ {
21
+ "name": "prefer-getter-over-parameterless-method",
22
+ "changeType": "fix",
23
+ "issues": [
24
+ 1318
25
+ ],
26
+ "summary": "withhold autofix for non-private methods (closes #1318)"
27
+ }
28
+ ]
29
+ },
2
30
  {
3
31
  "version": "1.19.15",
4
32
  "date": "2026-07-17T23:29:51.136Z",