Skip to content

Commit 41eb2ce

Browse files
committed
fix: some fixes
1 parent c317c35 commit 41eb2ce

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

src/linter/rules/__tests__/invalid-change-version.test.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ changes:
7676
level: 'error',
7777
message: 'Missing version field in the API doc entry',
7878
position: {
79-
start: { line: 4 },
80-
end: { line: 4 },
79+
start: { line: 3 },
80+
end: { line: 3 },
8181
},
8282
},
8383
]);
@@ -89,8 +89,8 @@ changes:
8989
level: 'error',
9090
message: 'Missing version field in the API doc entry',
9191
position: {
92-
start: { line: 3 },
93-
end: { line: 3 },
92+
start: { line: 4 },
93+
end: { line: 4 },
9494
},
9595
},
9696
]);

src/linter/rules/invalid-change-version.mjs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,20 +72,20 @@ export const extractVersions = ({ context, node, report }) => {
7272
if (!isMap(node)) {
7373
context.report(
7474
report(
75-
LINT_MESSAGES.invalidChangeProperty.replace('{{type}}', node.NODE_TYPE),
75+
LINT_MESSAGES.invalidChangeProperty.replace('{{type}}', node.type),
7676
node
7777
)
7878
);
7979

80-
return null;
80+
return;
8181
}
8282

8383
const versionNode = findPropertyByName(node, 'version');
8484

8585
if (!versionNode) {
8686
context.report(report(LINT_MESSAGES.missingChangeVersion, node));
8787

88-
return null;
88+
return;
8989
}
9090

9191
return normalizeNode(versionNode.value);
@@ -126,16 +126,22 @@ export const invalidChangeVersion = context => {
126126
report(
127127
LINT_MESSAGES.invalidChangeProperty.replace(
128128
'{{type}}',
129-
changesNode.value.NODE_TYPE
129+
changesNode.value.type
130130
),
131131
changesNode.key
132132
)
133133
);
134134
}
135135

136-
changesNode.value.items.forEach(node =>
137-
extractVersions({ context, node, report })
138-
.filter(Boolean) // Filter already reported empt items
136+
changesNode.value.items.forEach(node => {
137+
const versions = extractVersions({ context, node, report });
138+
139+
if (!versions) {
140+
return;
141+
}
142+
143+
versions
144+
.filter(Boolean) // Filter already reported empt items,
139145
.filter(isInvalid)
140146
.forEach(version =>
141147
context.report(
@@ -149,7 +155,7 @@ export const invalidChangeVersion = context => {
149155
version
150156
)
151157
)
152-
)
153-
);
158+
);
159+
});
154160
});
155161
};

0 commit comments

Comments
 (0)