@blumintinc/eslint-plugin-blumint 1.20.28 → 1.20.29
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 +1 -1
- package/lib/rules/global-const-style.js +28 -2
- package/package.json +1 -1
- package/release-manifest.json +14 -0
package/lib/index.js
CHANGED
|
@@ -83,6 +83,11 @@ const renameWouldCollide = (variable, newName) => {
|
|
|
83
83
|
}
|
|
84
84
|
return false;
|
|
85
85
|
};
|
|
86
|
+
// `undefined`, `NaN` and `Infinity` parse as identifiers but denote primitive
|
|
87
|
+
// values rather than a binding being aliased, so they stay subject to the
|
|
88
|
+
// naming check exactly like the literals they stand in for. Every other bare
|
|
89
|
+
// identifier initializer is an alias (see `isBindingAlias`).
|
|
90
|
+
const PRIMITIVE_VALUE_GLOBALS = new Set(['undefined', 'NaN', 'Infinity']);
|
|
86
91
|
// Next.js recognizes these export names by their literal identifier, so
|
|
87
92
|
// renaming them to UPPER_SNAKE_CASE silently breaks the framework contract
|
|
88
93
|
// (e.g. `export const config` controls the API-route body parser / runtime).
|
|
@@ -139,6 +144,26 @@ exports.default = (0, createRule_1.createRule)({
|
|
|
139
144
|
}
|
|
140
145
|
return false;
|
|
141
146
|
};
|
|
147
|
+
/**
|
|
148
|
+
* A bare identifier initializer (`export const toUsernameSlugStamp =
|
|
149
|
+
* toKvStamp;`) aliases an existing binding instead of declaring a
|
|
150
|
+
* configuration value, so the rule's premise does not hold: the alias
|
|
151
|
+
* inherits whatever convention its target follows, and a callable — the
|
|
152
|
+
* dominant case, since aliasing a re-exported function is the idiom — is
|
|
153
|
+
* always camelCase. Renaming one is also destructive, because the point of
|
|
154
|
+
* such a re-export is preserving a name importers depend on and a
|
|
155
|
+
* single-file fixer cannot rewrite them (Issue #1418).
|
|
156
|
+
*
|
|
157
|
+
* The check unwraps assertions so a type-pinned alias (`x as Foo`,
|
|
158
|
+
* `x as const`) is treated the same as the bare form. A `MemberExpression`
|
|
159
|
+
* (`Foo.bar`) is deliberately not covered — it keeps whatever behavior
|
|
160
|
+
* `isDynamicValue` already gives it.
|
|
161
|
+
*/
|
|
162
|
+
const isBindingAlias = (node) => {
|
|
163
|
+
const target = unwrapAssertions(node);
|
|
164
|
+
return (target.type === utils_1.AST_NODE_TYPES.Identifier &&
|
|
165
|
+
!PRIMITIVE_VALUE_GLOBALS.has(target.name));
|
|
166
|
+
};
|
|
142
167
|
const describeValueKind = (node) => {
|
|
143
168
|
const target = unwrapAssertions(node);
|
|
144
169
|
if (target.type === utils_1.AST_NODE_TYPES.ArrayExpression) {
|
|
@@ -209,8 +234,9 @@ exports.default = (0, createRule_1.createRule)({
|
|
|
209
234
|
}
|
|
210
235
|
const { name } = declaration.id;
|
|
211
236
|
const init = declaration.init;
|
|
212
|
-
// Skip if no initializer
|
|
213
|
-
if
|
|
237
|
+
// Skip if no initializer, if it's a dynamic value or class instance,
|
|
238
|
+
// or if it merely aliases another binding
|
|
239
|
+
if (!init || isDynamicValue(init) || isBindingAlias(init)) {
|
|
214
240
|
return;
|
|
215
241
|
}
|
|
216
242
|
const sourceCode = context.sourceCode;
|
package/package.json
CHANGED
package/release-manifest.json
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"version": "1.20.29",
|
|
4
|
+
"date": "2026-07-30T08:31:47.570Z",
|
|
5
|
+
"rules": [
|
|
6
|
+
{
|
|
7
|
+
"name": "global-const-style",
|
|
8
|
+
"changeType": "fix",
|
|
9
|
+
"issues": [
|
|
10
|
+
1418
|
|
11
|
+
],
|
|
12
|
+
"summary": "exempt bare-identifier binding aliases (closes #1418)"
|
|
13
|
+
}
|
|
14
|
+
]
|
|
15
|
+
},
|
|
2
16
|
{
|
|
3
17
|
"version": "1.20.28",
|
|
4
18
|
"date": "2026-07-30T07:59:36.776Z",
|