UNPKG

textlint

Version:

The pluggable linting tool for text and markdown.

43 lines 1.4 kB
// LICENSE : MIT "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.separateEnabledOrDisabled = void 0; const config_util_1 = require("./config-util"); /** * Get rule keys from `.textlintrc` config object. * @param {Object} [rulesConfig] * @returns {{available: string[], disabledRuleNames: string[]}} */ function separateEnabledOrDisabled(rulesConfig) { const ruleOf = { presetNames: [], enabledRuleNames: [], disabledRuleNames: [] }; if (!rulesConfig) { return ruleOf; } Object.keys(rulesConfig).forEach((key) => { // `<plugin>/<rule-key>` should ignored if ((0, config_util_1.isPluginRuleKey)(key)) { return; } // `textlint-rule-preset-XXX` if ((0, config_util_1.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; } exports.separateEnabledOrDisabled = separateEnabledOrDisabled; //# sourceMappingURL=separate-by-config-option.js.map