@blumintinc/eslint-plugin-blumint 1.18.6 → 1.18.7
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
|
@@ -5,7 +5,10 @@ const createRule_1 = require("../utils/createRule");
|
|
|
5
5
|
const ClassGraphBuilder_1 = require("../utils/graph/ClassGraphBuilder");
|
|
6
6
|
function getMemberName(member) {
|
|
7
7
|
if (member.type === 'MethodDefinition' ||
|
|
8
|
-
member.type === 'PropertyDefinition'
|
|
8
|
+
member.type === 'PropertyDefinition' ||
|
|
9
|
+
member.type === 'TSAbstractMethodDefinition' ||
|
|
10
|
+
member.type === 'TSAbstractPropertyDefinition' ||
|
|
11
|
+
member.type === 'TSAbstractAccessorProperty') {
|
|
9
12
|
return member.key.type === 'Identifier' ? member.key.name : null;
|
|
10
13
|
}
|
|
11
14
|
return null;
|
|
@@ -43,10 +46,7 @@ exports.classMethodsReadTopToBottom = (0, createRule_1.createRule)({
|
|
|
43
46
|
const graphBuilder = new ClassGraphBuilder_1.ClassGraphBuilder(className, node);
|
|
44
47
|
const sortedOrder = graphBuilder.memberNamesSorted;
|
|
45
48
|
const actualOrder = node.body
|
|
46
|
-
.map((member) => member
|
|
47
|
-
member.type === 'PropertyDefinition'
|
|
48
|
-
? member.key.name
|
|
49
|
-
: null)
|
|
49
|
+
.map((member) => getMemberName(member))
|
|
50
50
|
.filter(Boolean);
|
|
51
51
|
// Check if we have the same number of methods in both arrays
|
|
52
52
|
// This prevents issues with similar method names being treated as duplicates
|
|
@@ -58,6 +58,19 @@ exports.classMethodsReadTopToBottom = (0, createRule_1.createRule)({
|
|
|
58
58
|
if (uniqueMethodNames.size !== actualOrder.length) {
|
|
59
59
|
return; // Skip if there are actual duplicates
|
|
60
60
|
}
|
|
61
|
+
// Defense-in-depth: the fixer overwrites the ENTIRE class body from the
|
|
62
|
+
// tracked members. If any member is not tracked (unknown node type,
|
|
63
|
+
// non-Identifier/computed key, static block, index signature, etc.), it
|
|
64
|
+
// would be silently dropped by the rewrite. Bail rather than emit a body
|
|
65
|
+
// that deletes source the rule does not track.
|
|
66
|
+
const trackedNames = new Set(sortedOrder);
|
|
67
|
+
const allMembersRepresented = node.body.every((member) => {
|
|
68
|
+
const name = getMemberName(member);
|
|
69
|
+
return name !== null && trackedNames.has(name);
|
|
70
|
+
});
|
|
71
|
+
if (!allMembersRepresented) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
61
74
|
for (let i = 0; i < actualOrder.length; i++) {
|
|
62
75
|
const actualMember = actualOrder[i];
|
|
63
76
|
const expectedMember = sortedOrder[i];
|
|
@@ -36,7 +36,11 @@ class ClassGraphBuilder {
|
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
38
|
static isClassMember(node) {
|
|
39
|
-
return (node.type === 'MethodDefinition' ||
|
|
39
|
+
return (node.type === 'MethodDefinition' ||
|
|
40
|
+
node.type === 'PropertyDefinition' ||
|
|
41
|
+
node.type === 'TSAbstractMethodDefinition' ||
|
|
42
|
+
node.type === 'TSAbstractPropertyDefinition' ||
|
|
43
|
+
node.type === 'TSAbstractAccessorProperty');
|
|
40
44
|
}
|
|
41
45
|
addMemberToGraph(member) {
|
|
42
46
|
const name = member.key.name;
|
|
@@ -48,6 +52,10 @@ class ClassGraphBuilder {
|
|
|
48
52
|
if (member.type === 'MethodDefinition') {
|
|
49
53
|
return member.kind === 'constructor' ? 'constructor' : 'method';
|
|
50
54
|
}
|
|
55
|
+
// Abstract methods can never be constructors, so they are always methods.
|
|
56
|
+
if (member.type === 'TSAbstractMethodDefinition') {
|
|
57
|
+
return 'method';
|
|
58
|
+
}
|
|
51
59
|
return 'property';
|
|
52
60
|
}
|
|
53
61
|
static createGraphNode(name, type, accessibility, isStatic = false) {
|
package/package.json
CHANGED
package/release-manifest.json
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"version": "1.18.7",
|
|
4
|
+
"date": "2026-07-10T02:31:44.580Z",
|
|
5
|
+
"rules": [
|
|
6
|
+
{
|
|
7
|
+
"name": "class-methods-read-top-to-bottom",
|
|
8
|
+
"changeType": "fix",
|
|
9
|
+
"issues": [
|
|
10
|
+
1279
|
|
11
|
+
],
|
|
12
|
+
"summary": "preserve abstract members during autofix (closes #1279)"
|
|
13
|
+
}
|
|
14
|
+
]
|
|
15
|
+
},
|
|
2
16
|
{
|
|
3
17
|
"version": "1.18.6",
|
|
4
18
|
"date": "2026-07-09T08:45:37.007Z",
|