How to use the @hint/utils.logger.log 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 / cli / help.ts View on Github external
return false;
        }

        // This is for the `_` property. If there are sites, we don't show help neither
        if (Array.isArray(value) && value.length > 0) {
            return false;
        }

        return result && true;
    }, true);

    if (!showHelp) {
        return Promise.resolve(false);
    }

    logger.log(options.generateHelp());

    return Promise.resolve(true);
};
github webhintio / hint / packages / formatter-html / src / formatter.ts View on Github external
await removeLanguageFile();
                // We save the result with the friendly target name
                const name = target.replace(/:\/\//g, '-')
                    .replace(/:/g, '-')
                    .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 / create-hintrc / src / create-hintrc.ts View on Github external
export default async (): Promise => {

    debug('Starting --init');

    logger.log('Welcome to hint configuration generator');

    const initialQuestion: inquirer.Questions = [{
        choices: ['predefined', 'custom'],
        default: 'predefined',
        message: 'Do you want to use a predefined configuration or create your own based on your installed packages?',
        name: 'configType',
        type: 'list'
    }];

    const initialAnswer: inquirer.Answers = await inquirer.prompt(initialQuestion);

    const result = initialAnswer.configType === 'predefined' ?
        await extendConfig() :
        await customConfig();

    if (!result) {
github webhintio / hint / packages / hint / src / lib / cli / analyze.ts View on Github external
const showDefaultMessage = () => {
    const defaultMessage = `Using the built-in configuration.
Visit https://webhint.io/docs/user-guide/ to learn how to create your own configuration.`;

    logger.log(defaultMessage);
};
github webhintio / hint / packages / hint / src / lib / cli / version.ts View on Github external
export default (): Promise => {

    const pkg = loadHintPackage();

    logger.log(`v${pkg.version}`);

    return Promise.resolve(true);
};
github webhintio / hint / packages / create-hint / src / create-hint.ts View on Github external
const copyFiles = async (origin: string, destination: string) => {

    logger.log(`Creating new hint in ${destination}`);
    await copy(origin, destination);
    logger.log('External files copied');
};
github webhintio / hint / packages / formatter-json / src / formatter.ts View on Github external
return;
        }

        const language = options.language!;
        const resources: _.Dictionary = _.groupBy(messages, 'resource');

        const result = _.reduce(resources, (total: string, msgs: Problem[], resource: string) => {
            const sortedMessages: Problem[] = _.sortBy(msgs, ['location.line', 'location.column']);
            const result = `${total ? '\n\n' : ''}${resource}: ${getMessage('issues', language, msgs.length.toString())}
${JSON.stringify(sortedMessages, null, 2)}`;

            return total + result;
        }, '');

        if (!options.output) {
            logger.log(result);

            return;
        }

        await writeFileAsync(options.output, result);
    }
}
github webhintio / hint / packages / create-parser / src / new-parser.ts View on Github external
const copyFiles = async (data: NewParser) => {
    const files = path.join(__dirname, 'files');
    const noOfficialFiles = path.join(__dirname, 'no-official-files');

    logger.log(`Creating new hint in ${data.destination}`);
    if (!data.official) {
        await fs.copy(noOfficialFiles, data.destination);
    }
    await fs.copy(files, data.destination);
    logger.log('Files copied');
};
github webhintio / hint / packages / hint / src / lib / cli / analyze.ts View on Github external
const showMissingAndIncompatiblePackages = (resources: HintResources) => {
    if (resources.missing.length > 0) {
        logger.log(`The following ${resources.missing.length === 1 ? 'package is' : 'packages are'} missing:
    ${resources.missing.join(', ')}`);
    }

    if (resources.incompatible.length > 0) {
        logger.log(`The following ${resources.incompatible.length === 1 ? 'package is' : 'packages are'} incompatible:
    ${resources.incompatible.join(', ')}`);
    }
};
github webhintio / hint / packages / formatter-stylish / src / formatter.ts View on Github external
const color = occurencesToColor(totals);
        const foundTotalMessage = getMessage('totalFound', language, [
            totals[Severity.error].toString(),
            totals[Severity.error] === 1 ? getMessage('error', language) : getMessage('errors', language),
            totals[Severity.warning].toString(),
            totals[Severity.warning] === 1 ? getMessage('warning', language) : getMessage('warnings', language),
            totals[Severity.hint].toString(),
            totals[Severity.hint] === 1 ? getMessage('hint', language) : getMessage('hints', language),
            totals[Severity.information].toString(),
            totals[Severity.information] === 1 ? getMessage('information', language) : getMessage('informations', language)
        ]);

        result += color.bold(`${logSymbols.error} ${foundTotalMessage}`);

        if (!options.output) {
            logger.log(result);

            return;
        }

        await writeFileAsync(options.output, stripAnsi(result));
    }
}