How to use the @hint/utils.ResourceType.parser function in @hint/utils

To help you get started, we’ve selected a few @hint/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 webhintio / hint / packages / hint / src / lib / utils / resource-loader.ts View on Github external
// TODO: validate connector version is OK once all are extracted
    let connector: IConnectorConstructor | null = null;
    const connectorName = config.connector && config.connector.name || '';

    try {
        connector = loadResource(connectorName, ResourceType.connector, config.extends, true);
    } catch (e) {
        debug(e);

        if (e.status === ResourceErrorStatus.DependencyError) {
            throw e;
        }
    }

    const { incompatible: incompatibleHints, resources: hints, missing: missingHints } = loadListOfResources(config.hints, ResourceType.hint, config.extends);
    const { incompatible: incompatibleParsers, resources: parsers, missing: missingParsers } = loadListOfResources(config.parsers, ResourceType.parser, config.extends);
    const { incompatible: incompatibleFormatters, resources: formatters, missing: missingFormatters } = loadListOfResources(config.formatters, ResourceType.formatter, config.extends);
    const missing = ([] as string[]).concat(missingHints, missingParsers, missingFormatters);
    const incompatible = ([] as string[]).concat(incompatibleFormatters, incompatibleParsers, incompatibleHints);

    if (!connector) {
        missing.push(`${ResourceType.connector}-${connectorName || config.connector}`);
    }

    return {
        connector,
        formatters,
        hints,
        incompatible,
        missing,
        parsers
    };
github webhintio / hint / packages / create-hintrc / src / create-hintrc.ts View on Github external
const customConfig = async (): Promise => {
    const connectorKeys: inquirer.ChoiceType[] = getInstalledResources(ResourceType.connector).concat(getCoreResources(ResourceType.connector));
    const formattersKeys: inquirer.ChoiceType[] = getInstalledResources(ResourceType.formatter).concat(getCoreResources(ResourceType.formatter));
    const parsersKeys: inquirer.ChoiceType[] = getInstalledResources(ResourceType.parser).concat(getCoreResources(ResourceType.parser));
    const hintsKeys: inquirer.ChoiceType[] = getInstalledResources(ResourceType.hint).concat(getCoreResources(ResourceType.hint));

    if (!anyResources(connectorKeys, ResourceType.connector) ||
        !anyResources(formattersKeys, ResourceType.formatter) ||
        !anyResources(hintsKeys, ResourceType.hint)) {

        return null;
    }

    const customQuestions: inquirer.Question[] = [
        {
            choices: connectorKeys,
            message: 'What connector do you want to use?',
            name: 'connector',
            type: 'list'
        },