How to use the @hint/utils.ResourceType.configuration 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 loadConfiguration = (configurationId: string, configurations?: string[]) => {
    return loadResource(configurationId, ResourceType.configuration, configurations);
};
github webhintio / hint / packages / create-hintrc / src / create-hintrc.ts View on Github external
const extendConfig = async (): Promise => {
    const configPackages: NpmPackage[] = await getOfficialPackages(ResourceType.configuration);

    if (!anyResources(configPackages, ResourceType.configuration)) {
        return null;
    }

    const configNames = configPackages.map((pkg) => {
        return {
            name: getConfigurationName(pkg.name),
            value: pkg.name
        };
    });

    const choices = configNames.filter((config) => {
        return config.name !== 'all';
    });
github webhintio / hint / packages / create-hintrc / src / create-hintrc.ts View on Github external
const extendConfig = async (): Promise => {
    const configPackages: NpmPackage[] = await getOfficialPackages(ResourceType.configuration);

    if (!anyResources(configPackages, ResourceType.configuration)) {
        return null;
    }

    const configNames = configPackages.map((pkg) => {
        return {
            name: getConfigurationName(pkg.name),
            value: pkg.name
        };
    });

    const choices = configNames.filter((config) => {
        return config.name !== 'all';
    });

    const questions: inquirer.Questions = [{
        choices,
github webhintio / hint / packages / create-hintrc / src / create-hintrc.ts View on Github external
const initialAnswer: inquirer.Answers = await inquirer.prompt(initialQuestion);

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

    if (!result) {
        return false;
    }

    const filePath: string = path.join(cwd(), '.hintrc');

    await promisify(fs.writeFile)(filePath, JSON.stringify(result.config, null, 4), 'utf8');

    if (Array.isArray(result.packages) && result.packages.length > 0) {
        const isInstalled = getInstalledResources(ResourceType.configuration).includes(getConfigurationName(result.packages[0]));

        if (isInstalled) {
            return true;
        }

        await installPackages(result.packages);
    }

    trackEvent('new-hintrc', result.config);
    await sendPendingData();

    return true;
};