@blumintinc/eslint-plugin-blumint 1.20.73 → 1.20.74
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 +21 -4
- package/package.json +1 -1
- package/release-manifest.json +14 -0
package/lib/index.js
CHANGED
|
@@ -3,6 +3,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const utils_1 = require("@typescript-eslint/utils");
|
|
4
4
|
const createRule_1 = require("../utils/createRule");
|
|
5
5
|
const isUpperSnakeCase = (str) => /^[A-Z][A-Z0-9_]*$/.test(str);
|
|
6
|
+
/**
|
|
7
|
+
* Converts an identifier to UPPER_SNAKE_CASE by splitting on case *boundaries*.
|
|
8
|
+
*
|
|
9
|
+
* Idempotence is a correctness requirement, not a nicety: `--fix` re-lints its
|
|
10
|
+
* own output up to ten times per file, and a sibling rule can rewrite the same
|
|
11
|
+
* identifier in between (`enforce-react-type-naming` lowercases it), so a
|
|
12
|
+
* converter that re-separates what it already separated compounds every pass
|
|
13
|
+
* and writes an ever-growing, corrupted identifier into source (Issue #1605).
|
|
14
|
+
* Splitting on boundaries also keeps acronym runs intact, so `HTTPServer` reads
|
|
15
|
+
* as `HTTP_SERVER` rather than `H_T_T_P_SERVER`.
|
|
16
|
+
*
|
|
17
|
+
* The leading underscore is dropped because `_PRIVATE_THING` fails
|
|
18
|
+
* `isUpperSnakeCase`, which would leave the rule demanding a rename it can
|
|
19
|
+
* never satisfy.
|
|
20
|
+
*/
|
|
21
|
+
const toUpperSnakeCase = (name) => name
|
|
22
|
+
.replace(/([a-z0-9])([A-Z])/g, '$1_$2')
|
|
23
|
+
.replace(/([A-Z]+)([A-Z][a-z])/g, '$1_$2')
|
|
24
|
+
.toUpperCase()
|
|
25
|
+
.replace(/^_/, '');
|
|
6
26
|
// Jest mock handles produced by an `as` cast to a `jest.Mock*` type are
|
|
7
27
|
// stateful test doubles that are reassigned/mutated through
|
|
8
28
|
// `.mockImplementation()`, `.mockReturnValue()`, etc. They are not immutable
|
|
@@ -328,10 +348,7 @@ exports.default = (0, createRule_1.createRule)({
|
|
|
328
348
|
// the `mockedX` idiom is intentional. The exemption gates only this
|
|
329
349
|
// rename check — the `as const` logic above is untouched.
|
|
330
350
|
if (!isUpperSnakeCase(name) && !isJestMockCast(init)) {
|
|
331
|
-
const newName = name
|
|
332
|
-
.replace(/([A-Z])/g, '_$1')
|
|
333
|
-
.toUpperCase()
|
|
334
|
-
.replace(/^_/, '');
|
|
351
|
+
const newName = toUpperSnakeCase(name);
|
|
335
352
|
const idNode = declaration.id;
|
|
336
353
|
context.report({
|
|
337
354
|
node: declaration,
|
package/package.json
CHANGED
package/release-manifest.json
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"version": "1.20.74",
|
|
4
|
+
"date": "2026-08-02T06:07:00.009Z",
|
|
5
|
+
"rules": [
|
|
6
|
+
{
|
|
7
|
+
"name": "global-const-style",
|
|
8
|
+
"changeType": "fix",
|
|
9
|
+
"issues": [
|
|
10
|
+
1605
|
|
11
|
+
],
|
|
12
|
+
"summary": "split the rename on case boundaries so it is idempotent (closes #1605)"
|
|
13
|
+
}
|
|
14
|
+
]
|
|
15
|
+
},
|
|
2
16
|
{
|
|
3
17
|
"version": "1.20.73",
|
|
4
18
|
"date": "2026-08-02T05:14:39.301Z",
|