textlint
Version:
The pluggable linting tool for text and markdown.
40 lines • 1.21 kB
JavaScript
// LICENSE : MIT
;
import { isPluginRuleKey, isPresetRuleKey } from "./config-util";
/**
* Get rule keys from `.textlintrc` config object.
* @param {Object} [rulesConfig]
* @returns {{available: string[], disabledRuleNames: string[]}}
*/
export function separateEnabledOrDisabled(rulesConfig) {
const ruleOf = {
presetNames: [],
enabledRuleNames: [],
disabledRuleNames: []
};
if (!rulesConfig) {
return ruleOf;
}
Object.keys(rulesConfig).forEach((key) => {
// `<plugin>/<rule-key>` should ignored
if (isPluginRuleKey(key)) {
return;
}
// `textlint-rule-preset-XXX`
if (isPresetRuleKey(key)) {
if (typeof rulesConfig[key] === "object" || rulesConfig[key] === true) {
ruleOf.presetNames.push(key);
}
return;
}
// ignore `false` value
if (typeof rulesConfig[key] === "object" || rulesConfig[key] === true) {
ruleOf.enabledRuleNames.push(key);
}
else {
ruleOf.disabledRuleNames.push(key);
}
});
return ruleOf;
}
//# sourceMappingURL=separate-by-config-option.js.map