How to use the @textlint/utils.normalizeTextlintRulePresetKey function in @textlint/utils

To help you get started, we’ve selected a few @textlint/utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github textlint / textlint / packages / textlint / src / engine / textlint-module-loader.ts View on Github external
loadPreset(presetName: string) {
        /*
         Caution: Rules of preset are defined as following.
             {
                "rules": {
                    "preset-gizmo": {
                        "ruleA": false

                }
            }

        It mean that "ruleA" is defined as "preset-gizmo/ruleA"

         */
        const presetRuleNameWithoutPrefix = normalizeTextlintRulePresetKey(presetName);
        // ignore plugin's rule
        if (isPluginRuleKey(presetRuleNameWithoutPrefix)) {
            Logger.warn(`${presetRuleNameWithoutPrefix} is Plugin's rule. This is unknown case, please report issue.`);
            return;
        }

        const pkgPath = this.moduleResolver.resolvePresetPackageName(presetName);
        debug("Loading rules from preset: %s", pkgPath);
        const preset = moduleInterop(require(pkgPath));
        const entities = TextLintModuleMapper.createEntities(preset.rules, presetRuleNameWithoutPrefix);
        entities.forEach(entry => {
            this.emit(TextLintModuleLoader.Event.rule, entry);
        });
    }