How to use the @hint/utils.ResourceType.connector 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
export const loadResources = (config: Configuration): HintResources => {
    // 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}`);
github webhintio / hint / packages / hint / src / lib / config.ts View on Github external
public static validateConnectorConfig(config: Configuration) {
        const connectorId = config.connector!.name;

        debug(`Validating ${connectorId} connector`);

        const Connector = loadResource(connectorId, ResourceType.connector) as IConnectorConstructor;

        debug(`Connector schema:`);
        debug(Connector.schema);
        debug(`User configuration:`);
        debug(config.connector!.options!);

        return schemaValidator(Connector.schema, config.connector!.options!).valid;
    }
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'
        },
        {
            choices: formattersKeys,
            default: defaultFormatter,
github webhintio / hint / packages / hint / src / lib / utils / resource-loader.ts View on Github external
} 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',