How to use the @hint/utils.logger.error 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-image-optimization-cloudinary / src / hint.ts View on Github external
const isConfigured = (hintOptions: any) => {
            const cloudinaryUrl = process.env.CLOUDINARY_URL; // eslint-disable-line no-process-env
            const { apiKey, apiSecret, cloudName, threshold } = hintOptions;

            if (threshold) {
                sizeThreshold = threshold;
            }

            if (cloudinaryUrl) {
                return true;
            }

            if (!apiKey || !apiSecret || !cloudName) {
                logger.error(getMessage('noConfigFound', context.language));

                return false;
            }

            cloudinary.v2.config({
                api_key: apiKey,
                api_secret: apiSecret,
                cloud_name: cloudName
            });

            return true;
        };
        /* eslint-enable camelcase */
github webhintio / hint / packages / create-hint / src / create-hint.ts View on Github external
logger.log(`1. Run 'yarn' to install the dependencies.
2. Go to the folder 'packages/hint-${hintPackage.normalizedName}'.
3. Run 'yarn build' to build the project.
4. Go to the folder 'packages/hint'.
5. Add your hint to '.hintrc'.
6. Run 'yarn hint https://YourUrl' to analyze your site.`);
        } else {
            logger.log(`1. Go to the folder 'hint-${hintPackage.normalizedName}'.
2. Run 'npm run init' to install all the dependencies and build the project.
3. Run 'npm run hint -- https://YourUrl' to analyze you site.`);
        }

        return true;
    } catch (e) {
        /* istanbul ignore next */{ // eslint-disable-line no-lone-blocks
            logger.error('Error trying to create new hint');
            logger.error(e);

            return false;
        }
    }
};
github webhintio / hint / packages / connector-local / src / connector.ts View on Github external
return total;
                }

                /* istanbul ignore if */
                if (value[0] === '/') {
                    total.push(value.substr(1));
                } else {
                    total.push(value);
                }

                return total;
            }, []);

            return result;
        } catch (err) {
            logger.error(getMessage('errorReading', this.engine.language));

            return [];
        }
    }
github webhintio / hint / packages / formatter-excel / src / formatter.ts View on Github external
try {
            // We save the file with the friendly target name
            const name = target.replace(/:\/\//g, '-')
                .replace(/:/g, '-')
                .replace(/\./g, '-')
                .replace(/\//g, '-')
                .replace(/-$/, '');

            const fileName = options.output || path.resolve(cwd(), `${name}.xlsx`);

            await workbook.xlsx.writeFile(fileName);
        } catch (e) {
            /* istanbul ignore next */
            { // eslint-disable-line
                logger.error(getMessage('errorSaving', language));

                if (e.message.includes('EBUSY')) {
                    logger.error(getMessage('maybeIsOpened', language));
                }
            }
        }
    }
}
github webhintio / hint / packages / hint / src / lib / cli.ts View on Github external
return 1;
    }

    let handled = false;

    notifyIfNeeded();

    while (cliActions.length > 0 && !handled) {
        const action = cliActions.shift()!; // Can assume not-undefined as previous line already checks the length.

        /* istanbul ignore next */
        try {
            handled = await action(currentOptions);
        } catch (e) {
            logger.error(e);

            return 1;
        }
    }

    return handled ? 0 : 1;
};
github webhintio / hint / packages / hint / src / lib / cli.ts View on Github external
export const execute = async (args: string | string[] | Object): Promise => {
    let currentOptions: CLIOptions;

    try {
        currentOptions = options.parse(args);
    } catch (e) {
        logger.error(e.message);

        return 1;
    }

    let handled = false;

    notifyIfNeeded();

    while (cliActions.length > 0 && !handled) {
        const action = cliActions.shift()!; // Can assume not-undefined as previous line already checks the length.

        /* istanbul ignore next */
        try {
            handled = await action(currentOptions);
        } catch (e) {
            logger.error(e);
github webhintio / hint / packages / hint / src / lib / cli / analyze.ts View on Github external
return getAnalyzer(config, options, targets);
        }

        if (error.status === AnalyzerErrorStatus.ResourceError) {
            const installed = await askToInstallPackages(error.resources!);

            if (!installed) {
                throw e;
            }

            return getAnalyzer(userConfig, options, targets);
        }

        if (error.status === AnalyzerErrorStatus.HintError) {
            logger.error(`Invalid hint configuration in .hintrc: ${error.invalidHints!.join(', ')}.`);

            throw e;
        }

        if (error.status === AnalyzerErrorStatus.ConnectorError) {
            logger.error(`Invalid connector configuration in .hintrc`);

            throw e;
        }

        /*
         * If the error is not an AnalyzerErrorStatus
         * bubble up the exception.
         */
        logger.error(e.message, e);
github webhintio / hint / packages / hint / src / lib / config / config-validator.ts View on Github external
export const validateConfig = (config: UserConfig): boolean => {
    debug('Validating configuration');

    const validateInfo: SchemaValidationResult = validate(schema, config);

    if (!validateInfo.valid) {
        logger.error('Configuration schema is not valid:');

        validateInfo.groupedErrors.forEach((error: GroupedError) => {
            logger.error(` - ${error.message}`);
        });

        return false;
    }

    return true;
};
github webhintio / hint / packages / formatter-html / src / formatter.ts View on Github external
.replace(/\./g, '-')
                    .replace(/\//g, '-')
                    .replace(/[?=]/g, '-query-')
                    .replace(/-$/, '');
                const destDir = options.output || path.join(cwd(), 'hint-report');

                const destination = path.join(destDir, `${name}.html`);

                await fs.outputFile(destination, html);

                logger.log(getMessageFormatter('youCanView', language, destination));
            }

            return result;
        } catch (err) {
            logger.error(err);

            throw err;
        }
    }
}
github webhintio / hint / packages / hint / src / lib / config / config-validator.ts View on Github external
validateInfo.groupedErrors.forEach((error: GroupedError) => {
            logger.error(` - ${error.message}`);
        });