How to use the @hint/utils-compat-data.getSupported function in @hint/utils-compat-data

To help you get started, we’ve selected a few @hint/utils-compat-data 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-compat-api / src / utils / filter-supports.ts View on Github external
const filterItem = (item: Declaration | DeclarationGroup, browsers: string[]): string[] => {
    if ('prop' in item) {
        const supportsProperty = getSupported({ property: item.prop }, browsers);
        const supportsValue = supportsProperty && getSupported({ property: item.prop, value: item.value }, supportsProperty);

        return supportsValue || [];
    }

    switch (item.type) {
        case 'and':
            return intersection(...item.nodes.map((child) => {
                return filterItem(child, browsers);
            }));
        case 'or':
            return union(...item.nodes.map((child) => {
                return filterItem(child, browsers);
            }));
        case 'not':
            return difference(browsers, filterItem(item.nodes[0], browsers));
github webhintio / hint / packages / hint-compat-api / src / utils / filter-supports.ts View on Github external
const filterItem = (item: Declaration | DeclarationGroup, browsers: string[]): string[] => {
    if ('prop' in item) {
        const supportsProperty = getSupported({ property: item.prop }, browsers);
        const supportsValue = supportsProperty && getSupported({ property: item.prop, value: item.value }, supportsProperty);

        return supportsValue || [];
    }

    switch (item.type) {
        case 'and':
            return intersection(...item.nodes.map((child) => {
                return filterItem(child, browsers);
            }));
        case 'or':
            return union(...item.nodes.map((child) => {
                return filterItem(child, browsers);
            }));
        case 'not':
            return difference(browsers, filterItem(item.nodes[0], browsers));
        default:
github webhintio / hint / packages / hint-compat-api / src / utils / filter-supports.ts View on Github external
export const filterSupports = (params: string, browsers: string[]): string[] | null => {
    const hasAtSupports = getSupported({ rule: 'supports'}, browsers);

    if (!hasAtSupports) {
        return null;
    }

    const root = parseSupports(params);

    if (!root) {
        return null;
    }

    try {
        const supported = filterItem(root, hasAtSupports);

        return supported.length ? supported : null;
    } catch (e) {