style: Add new ESLint rule no-lonely-if and unicorn/no-lonely-if (#10176)

Co-authored-by: fisker Cheung <lionkay@gmail.com>
This commit is contained in:
Lipisandfisker Cheung authored and GitHub committed 2022-09-29 10:25:54 +08:00
1 parent f32daf742f
commit 4ed2d3c4bc
8 files changed
+49 -53

No files matched your search

+7 -7
View File
@@ -160,13 +160,13 @@ function addTypePrefix(node, prefix, skipPrefix) {
delete node.parent;
for (const key in node) {
addTypePrefix(node[key], prefix, skipPrefix);
if (key === "type" && typeof node[key] === "string") {
if (
!node[key].startsWith(prefix) &&
(!skipPrefix || !skipPrefix.test(node[key]))
) {
node[key] = prefix + node[key];
}
if (
key === "type" &&
typeof node[key] === "string" &&
!node[key].startsWith(prefix) &&
(!skipPrefix || !skipPrefix.test(node[key]))
) {
node[key] = prefix + node[key];
}
}
}