Skip to content

Commit

Permalink
Chore: refactor linter#parseBooleanConfig to improve readability (#11074
Browse files Browse the repository at this point in the history
)
  • Loading branch information
aladdin-add committed Nov 11, 2018
1 parent 5da378a commit e18c827
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions lib/linter.js
Expand Up @@ -76,19 +76,14 @@ function parseBooleanConfig(string, comment) {
if (!name) {
return;
}
const pos = name.indexOf(":");

if (pos === -1) {
items[name] = {
value: false,
comment
};
} else {
items[name.slice(0, pos)] = {
value: name.slice(pos + 1) === "true",
comment
};
}
// value defaults to "false" (if not provided), e.g: "foo" => ["foo", "false"]
const [key, value = "false"] = name.split(":");

items[key] = {
value: value === "true",
comment
};
});
return items;
}
Expand Down

0 comments on commit e18c827

Please sign in to comment.