<commit_before>// LICENSE : MIT
"use strict";
const objectAssign = require("object-assign");
const concat = require("unique-concat");
import loadConfig from "./config-loader";
import {isPluginRuleKey, isPresetRuleKey} from "../util/config-util";
import {mapRulesConfig} from "./preset-loader";
import loadRulesConfigFromPlugins from "./plugin-loader";
import loadRulesConfigFromPresets from "./preset-loader";
import TextLintModuleResolver from "../engine/textlint-module-resolver";
/**
 * Get rule keys from `.textlintrc` config object.
 * @param rulesConfig
 * @returns {{available: string[], disable: string[]}}
 */
function separateAvailableOrDisable(rulesConfig) {
    const ruleOf = {
        presets: [],
        available: [],
        disable: []
    };
    if (!rulesConfig) {
        return ruleOf;
    }
    Object.keys(rulesConfig).forEach(key => {
        // `textlint-rule-preset-XXX`
        if (isPresetRuleKey(key)) {
            if (typeof rulesConfig[key] === "object" || rulesConfig[key] === true) {
                ruleOf.presets.push(key);
            }
            return;
        }
        // `<plugin>/<rule-key>` should ignored
        if (isPluginRuleKey(key)) {
            return;
        }
        // ignore `false` value
        if (typeof rulesConfig[key] === "object" || rulesConfig[key] === true) {
            ruleOf.available.push(key);
        } else {
            ruleOf.disable.push(key);
        }
    });
    return ruleOf;
}
/**
 * Convert config of preset to rulesConfig flat path format.
 *
 * e.g.)
 * {
 *  "preset-a" : { "key": "value"}
 * }
 * => {"preset-a/key": "value"}
 *
 * @param rulesConfig
 * @returns {{string: string}}
 */
function convertRulesConfigToFlatPath(rulesConfig) {
    if (!rulesConfig) {
        return {};
    }
    const filteredConfig = {};
    Object.keys(rulesConfig).forEach(key => {
        if (isPresetRuleKey(key)) {
            // <preset>/<rule>
            objectAssign(filteredConfig, mapRulesConfig(rulesConfig[key], key));
            return;
        }
        filteredConfig[key] = rulesConfig[key];
    });
    return filteredConfig;
}
/**
 * @type {TextLintConfig}
 */
const defaultOptions = Object.freeze({
    // rule package names
    rules: [],
    // disabled rule package names
    // always should start with empty
    disabledRules: [],
    // preset package names
    // e.g.) ["preset-foo"]
    presets: [],
    // plugin package names
    plugins: [],
    // rules base directory that is related `rules`.
    rulesBaseDirectory: undefined,
    // ".textlint" file path
    configFile: undefined,
    // rules config object
    rulesConfig: {},
    // rule directories
    rulePaths: [],
    // available extensions
    // if set the option, should filter by extension.
    extensions: [],
    // formatter-file-name
    // e.g.) stylish.js => set "stylish"
    formatterName: undefined,
    // --no-color
    color: true
});

// Priority: CLI > Code options > config file
class Config {
    /**
     * @return {string} rc config filename
     * it's name use as `.<name>rc`
     */
    static get CONFIG_FILE_NAME() {
        return "textlint";
    }

    /**
     * @return {string} config package prefix
     */
    static get CONFIG_PACKAGE_PREFIX() {
        return "textlint-config-";
    }

    /**
     * @return {string} rule package's name prefix<commit_msg>docs(config): Where is default formamter? See engines<commit_after>// LICENSE : MIT
"use strict";
const objectAssign = require("object-assign");
const concat = require("unique-concat");
import loadConfig from "./config-loader";
import {isPluginRuleKey, isPresetRuleKey} from "../util/config-util";
import {mapRulesConfig} from "./preset-loader";
import loadRulesConfigFromPlugins from "./plugin-loader";
import loadRulesConfigFromPresets from "./preset-loader";
import TextLintModuleResolver from "../engine/textlint-module-resolver";
/**
 * Get rule keys from `.textlintrc` config object.
 * @param rulesConfig
 * @returns {{available: string[], disable: string[]}}
 */
function separateAvailableOrDisable(rulesConfig) {
    const ruleOf = {
        presets: [],
        available: [],
        disable: []
    };
    if (!rulesConfig) {
        return ruleOf;
    }
    Object.keys(rulesConfig).forEach(key => {
        // `textlint-rule-preset-XXX`
        if (isPresetRuleKey(key)) {
            if (typeof rulesConfig[key] === "object" || rulesConfig[key] === true) {
                ruleOf.presets.push(key);
            }
            return;
        }
        // `<plugin>/<rule-key>` should ignored
        if (isPluginRuleKey(key)) {
            return;
        }
        // ignore `false` value
        if (typeof rulesConfig[key] === "object" || rulesConfig[key] === true) {
            ruleOf.available.push(key);
        } else {
            ruleOf.disable.push(key);
        }
    });
    return ruleOf;
}
/**
 * Convert config of preset to rulesConfig flat path format.
 *
 * e.g.)
 * {
 *  "preset-a" : { "key": "value"}
 * }
 * => {"preset-a/key": "value"}
 *
 * @param rulesConfig
 * @returns {{string: string}}
 */
function convertRulesConfigToFlatPath(rulesConfig) {
    if (!rulesConfig) {
        return {};
    }
    const filteredConfig = {};
    Object.keys(rulesConfig).forEach(key => {
        if (isPresetRuleKey(key)) {
            // <preset>/<rule>
            objectAssign(filteredConfig, mapRulesConfig(rulesConfig[key], key));
            return;
        }
        filteredConfig[key] = rulesConfig[key];
    });
    return filteredConfig;
}
/**
 * @type {TextLintConfig}
 */
const defaultOptions = Object.freeze({
    // rule package names
    rules: [],
    // disabled rule package names
    // always should start with empty
    disabledRules: [],
    // preset package names
    // e.g.) ["preset-foo"]
    presets: [],
    // plugin package names
    plugins: [],
    // rules base directory that is related `rules`.
    rulesBaseDirectory: undefined,
    // ".textlint" file path
    configFile: undefined,
    // rules config object
    rulesConfig: {},
    // rule directories
    rulePaths: [],
    // available extensions
    // if set the option, should filter by extension.
    extensions: [],
    // formatter file name
    // e.g.) stylish.js => set "stylish"
    // NOTE: default formatter is defined in Engine,
    // because There is difference between TextLintEngine and TextFixEngine.
    formatterName: undefined,
    // --no-color
    color: true
});

// Priority: CLI > Code options > config file
class Config {
    /**
     * @return {string} rc config filename
     * it's name use as `.<name>rc`
     */
    static get CONFIG_FILE_NAME() {
        return "textlint";
    }

    /**
     * @return {string} config package prefix
     */
    static get CONFIG_PACKAGE_PREFIX() {
        return "textlint-config-";
    }

    /**
     * @return {string} rule package's name prefix
{'fraction_non_alphanumeric': 0.1435815705592582, 'fraction_numerical': 0.0, 'mean_word_length': 2.402168555938886, 'pattern_counts': {'":': 4, '<': 13, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4513222', 'n_tokens_mistral': 2007, 'n_tokens_neox': 1982, 'n_words': 506}