Skip to content

Commit 7ce79ef

Browse files
committed
refactor: some improvements
1 parent 41eb2ce commit 7ce79ef

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

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

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ const isInvalid = NODE_RELEASED_VERSIONS
6262
!(isValidReplaceMe(version.value, length) || valid(version.value));
6363

6464
/**
65+
* Validates and extracts versions of a change node
6566
*
6667
* @param {object} root0
6768
* @param {import('../types.d.ts').LintContext} root0.context
@@ -77,15 +78,15 @@ export const extractVersions = ({ context, node, report }) => {
7778
)
7879
);
7980

80-
return;
81+
return [];
8182
}
8283

8384
const versionNode = findPropertyByName(node, 'version');
8485

8586
if (!versionNode) {
8687
context.report(report(LINT_MESSAGES.missingChangeVersion, node));
8788

88-
return;
89+
return [];
8990
}
9091

9192
return normalizeNode(versionNode.value);
@@ -134,13 +135,7 @@ export const invalidChangeVersion = context => {
134135
}
135136

136137
changesNode.value.items.forEach(node => {
137-
const versions = extractVersions({ context, node, report });
138-
139-
if (!versions) {
140-
return;
141-
}
142-
143-
versions
138+
extractVersions({ context, node, report })
144139
.filter(Boolean) // Filter already reported empt items,
145140
.filter(isInvalid)
146141
.forEach(version =>

src/linter/utils/yaml.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const findPropertyByName = (node, propertyName) => {
1717
return;
1818
}
1919

20-
return pair.key.value == propertyName;
20+
return pair.key.value === propertyName;
2121
});
2222
};
2323

0 commit comments

Comments
 (0)