From c842ffa0d7ae1b9997dce50e9fad98a9af8ddbd1 Mon Sep 17 00:00:00 2001 From: "weiran.zsd" Date: Sat, 10 Nov 2018 22:42:14 +0800 Subject: [PATCH] Chore: refactor linter#parseBooleanConfig to improve readability --- lib/linter.js | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/lib/linter.js b/lib/linter.js index b47e6eb1fcf..4426b7f67c6 100644 --- a/lib/linter.js +++ b/lib/linter.js @@ -76,19 +76,13 @@ 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 - }; - } + const [key, value] = name.split(":"); + + items[key] = { + value: value === "true", + comment + }; }); return items; }