@blumintinc/eslint-plugin-blumint 1.20.57 → 1.20.59

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.57',
226
+ version: '1.20.59',
227
227
  },
228
228
  parseOptions: {
229
229
  ecmaVersion: 2020,
@@ -42,6 +42,39 @@ function bindsMemoize(variable) {
42
42
  ALLOWED_MEMOIZE_MODULES.has(String(declaration.source.value)));
43
43
  }));
44
44
  }
45
+ /**
46
+ * Whether a declared return type annotation promises no value: `void` or
47
+ * `Promise<void>`.
48
+ *
49
+ * Memoizing such a method caches nothing — there is no result to hand back —
50
+ * while changing runtime behaviour: the side effects run once per instance and
51
+ * every later call silently no-ops. Because the decision comes from the
52
+ * annotation node, spacing and line breaks inside the type are irrelevant.
53
+ *
54
+ * The check stays keyed to a plain `void`: a union (`Promise<void | undefined>`)
55
+ * or a type parameter (`Promise<T>`) can resolve to a value, so those still
56
+ * warrant caching. Absent annotations are likewise not exempt — this rule is
57
+ * syntactic (no `parserOptions.project`), so an unannotated body carries no
58
+ * declaration of intent to honour, and exempting inferred void would silently
59
+ * drop methods the author never marked value-less.
60
+ */
61
+ function declaresVoidResult(returnType) {
62
+ const annotation = returnType?.typeAnnotation;
63
+ if (!annotation) {
64
+ return false;
65
+ }
66
+ if (annotation.type === utils_1.AST_NODE_TYPES.TSVoidKeyword) {
67
+ return true;
68
+ }
69
+ if (annotation.type !== utils_1.AST_NODE_TYPES.TSTypeReference ||
70
+ annotation.typeName.type !== utils_1.AST_NODE_TYPES.Identifier ||
71
+ annotation.typeName.name !== 'Promise') {
72
+ return false;
73
+ }
74
+ const typeArguments = annotation.typeParameters?.params;
75
+ return (typeArguments?.length === 1 &&
76
+ typeArguments[0].type === utils_1.AST_NODE_TYPES.TSVoidKeyword);
77
+ }
45
78
  /**
46
79
  * Matches a memoize decorator in supported syntaxes:
47
80
  * - @Alias()
@@ -148,6 +181,13 @@ exports.enforceMemoizeAsync = (0, createRule_1.createRule)({
148
181
  if (node.value.params.length > 1) {
149
182
  return;
150
183
  }
184
+ // A method declared to produce no value has no result to cache, so the
185
+ // decorator's benefit is unobtainable while its cost is real: the
186
+ // fixer would convert a repeatable side effect into a
187
+ // once-per-instance one, unattended, under `--fix`.
188
+ if (declaresVoidResult(node.value.returnType)) {
189
+ return;
190
+ }
151
191
  const { aliases: memoizeAliases, namespaces: memoizeNamespaces } = memoizeImports();
152
192
  const hasMemoizeImport = memoizeAliases.size > 0 || memoizeNamespaces.size > 0;
153
193
  // Check if method already has @Memoize or @Memoize() decorator
@@ -2,6 +2,51 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.preferTypeOverInterface = void 0;
4
4
  const createRule_1 = require("../utils/createRule");
5
+ const utils_1 = require("@typescript-eslint/utils");
6
+ /**
7
+ * A module augmentation targets either an external module
8
+ * (`declare module 'pkg'`, whose id is a string literal) or the global scope
9
+ * (`declare global`). Declaration merging is the whole point of such a block
10
+ * and only `interface` can merge, so the `type` rewrite does not merely change
11
+ * style: it drops the augmentation and collides with the original declaration
12
+ * (TS2300 "Duplicate identifier").
13
+ *
14
+ * A plain `namespace X` — including the ambient `declare namespace X`, whose
15
+ * id is an identifier — augments nothing, so interfaces inside it stay
16
+ * reportable and a type alias works there.
17
+ */
18
+ function isModuleAugmentation(node) {
19
+ if (node.id.type === utils_1.AST_NODE_TYPES.Literal &&
20
+ typeof node.id.value === 'string') {
21
+ return true;
22
+ }
23
+ // `declare global` carries a dedicated flag, which also covers the bare
24
+ // `global { ... }` form nested inside an ambient module (that form has no
25
+ // `declare` of its own).
26
+ if (node.global === true) {
27
+ return true;
28
+ }
29
+ // Parser versions that predate the `global` flag spell the same block as an
30
+ // ambient module whose id is the `global` keyword. Requiring `declare` keeps
31
+ // an ordinary `namespace global { ... }` reportable.
32
+ return (node.declare === true &&
33
+ node.id.type === utils_1.AST_NODE_TYPES.Identifier &&
34
+ node.id.name === 'global');
35
+ }
36
+ /**
37
+ * The interface need not be a direct child of the augmentation block; it can
38
+ * sit inside a nested namespace or any other container within it, so the whole
39
+ * ancestor chain is inspected.
40
+ */
41
+ function isInsideModuleAugmentation(node) {
42
+ for (let ancestor = node.parent; ancestor; ancestor = ancestor.parent) {
43
+ if (ancestor.type === utils_1.AST_NODE_TYPES.TSModuleDeclaration &&
44
+ isModuleAugmentation(ancestor)) {
45
+ return true;
46
+ }
47
+ }
48
+ return false;
49
+ }
5
50
  exports.preferTypeOverInterface = (0, createRule_1.createRule)({
6
51
  name: 'prefer-type-over-interface',
7
52
  meta: {
@@ -22,6 +67,9 @@ exports.preferTypeOverInterface = (0, createRule_1.createRule)({
22
67
  create(context) {
23
68
  return {
24
69
  TSInterfaceDeclaration(node) {
70
+ if (isInsideModuleAugmentation(node)) {
71
+ return;
72
+ }
25
73
  context.report({
26
74
  node,
27
75
  messageId: 'preferType',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blumintinc/eslint-plugin-blumint",
3
- "version": "1.20.57",
3
+ "version": "1.20.59",
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.20.59",
4
+ "date": "2026-08-01T04:43:54.837Z",
5
+ "rules": [
6
+ {
7
+ "name": "prefer-type-over-interface",
8
+ "changeType": "fix",
9
+ "issues": [
10
+ 1549
11
+ ],
12
+ "summary": "exempt module augmentations (closes #1549)"
13
+ }
14
+ ]
15
+ },
16
+ {
17
+ "version": "1.20.58",
18
+ "date": "2026-08-01T04:26:49.434Z",
19
+ "rules": [
20
+ {
21
+ "name": "enforce-memoize-async",
22
+ "changeType": "fix",
23
+ "issues": [
24
+ 1548
25
+ ],
26
+ "summary": "skip methods declared Promise<void> (closes #1548)"
27
+ }
28
+ ]
29
+ },
2
30
  {
3
31
  "version": "1.20.57",
4
32
  "date": "2026-08-01T03:42:42.343Z",