@blumintinc/eslint-plugin-blumint 1.20.59 → 1.20.60

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.59',
226
+ version: '1.20.60',
227
227
  },
228
228
  parseOptions: {
229
229
  ecmaVersion: 2020,
@@ -41,19 +41,36 @@ const NON_PLURALIZABLE_SUFFIXES = [
41
41
  * the reference itself as a container.
42
42
  */
43
43
  const ARRAY_GENERIC_NAMES = new Set(['Array', 'ReadonlyArray']);
44
+ /**
45
+ * Union members that only express absence. Stripping them keeps a nullable
46
+ * container recognisable as a container: `T[]` and `T[] | null` describe the
47
+ * same collection, so they must not disagree about whether a plural name fits.
48
+ */
49
+ const NULLISH_TYPE_NODES = new Set([
50
+ utils_1.AST_NODE_TYPES.TSNullKeyword,
51
+ utils_1.AST_NODE_TYPES.TSUndefinedKeyword,
52
+ ]);
53
+ /**
54
+ * Shared budget for wrapper peeling and union recursion. Wrapper nesting is
55
+ * finite in real code; the cap only guards against a pathological cycle. Every
56
+ * peel and every descent into a union member spends one unit, so the recursion
57
+ * a union introduces stays bounded by the same constant.
58
+ */
59
+ const MAX_TYPE_DEPTH = 10;
44
60
  /**
45
61
  * Returns true when the type alias RHS resolves to a container shape — a
46
62
  * `TSArrayType` (`Foo[]`) or `TSTupleType` (`[A, B]`) — for which a plural name
47
63
  * is the correct, self-documenting choice. Sees through identity-ish wrappers
48
64
  * over the same shape: the `readonly` type operator, parenthesized types, and
49
65
  * the `Readonly<T>` utility type; `Array<T>`/`ReadonlyArray<T>` are containers
50
- * outright.
66
+ * outright. A union whose non-nullish members are all containers counts too.
67
+ *
68
+ * @param depth Budget already spent by an enclosing wrapper or union member.
51
69
  */
52
- function resolvesToContainerType(node) {
70
+ function resolvesToContainerType(node, depth = 0) {
53
71
  let current = node;
54
72
  // Fixpoint loop: peel identity wrappers until a concrete shape is reached.
55
- // Wrappers are finite; the cap only guards against a pathological cycle.
56
- for (let i = 0; i < 10; i++) {
73
+ for (let i = depth; i < MAX_TYPE_DEPTH; i++) {
57
74
  switch (current.type) {
58
75
  case utils_1.AST_NODE_TYPES.TSArrayType:
59
76
  case utils_1.AST_NODE_TYPES.TSTupleType:
@@ -66,6 +83,18 @@ function resolvesToContainerType(node) {
66
83
  current = operator.typeAnnotation;
67
84
  continue;
68
85
  }
86
+ case utils_1.AST_NODE_TYPES.TSUnionType: {
87
+ const union = current;
88
+ const substantive = union.types.filter((member) => !NULLISH_TYPE_NODES.has(member.type));
89
+ // `null | undefined` holds no collection at all.
90
+ if (substantive.length === 0)
91
+ return false;
92
+ // Requiring EVERY remaining member to be a container keeps the
93
+ // exemption conservative: a mixed union such as `Edge[] | Edge` can hold
94
+ // a single value, so a plural name there still misleads. Members recurse
95
+ // with the spent budget so nesting cannot escape the cap.
96
+ return substantive.every((member) => resolvesToContainerType(member, i + 1));
97
+ }
69
98
  case utils_1.AST_NODE_TYPES.TSTypeReference: {
70
99
  const ref = current;
71
100
  if (ref.typeName.type !== utils_1.AST_NODE_TYPES.Identifier)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blumintinc/eslint-plugin-blumint",
3
- "version": "1.20.59",
3
+ "version": "1.20.60",
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.60",
4
+ "date": "2026-08-01T05:06:58.616Z",
5
+ "rules": [
6
+ {
7
+ "name": "enforce-singular-type-names",
8
+ "changeType": "fix",
9
+ "issues": [
10
+ 1550
11
+ ],
12
+ "summary": "keep the container exemption when nullable (closes #1550)"
13
+ }
14
+ ]
15
+ },
2
16
  {
3
17
  "version": "1.20.59",
4
18
  "date": "2026-08-01T04:43:54.837Z",