How to use the @hint/utils-css.getCSSCodeSnippet function in @hint/utils-css

To help you get started, we’ve selected a few @hint/utils-css 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-scoped-svg-styles / src / hint.ts View on Github external
ast.walkRules((rule) => {
                const selectors = rule.selectors;

                for (const selector of selectors) {
                    const matchingElements = element.ownerDocument.querySelectorAll(selector);
                    const matchingElementsOutsideParentSVG = matchingElements.filter(isOutsideParentSVG(parentSVG));

                    if (matchingElementsOutsideParentSVG.length) {
                        const message = formatRuleMessage(matchingElementsOutsideParentSVG.length);
                        const location = getCSSLocationFromNode(rule);
                        const codeSnippet = getCSSCodeSnippet(rule);

                        context.report(resource, message, {
                            codeLanguage: 'css',
                            codeSnippet,
                            element,
                            location,
                            severity: Severity.error
                        });

                        let maxReportsPerCSSRule = Infinity;

                        if (context.hintOptions && context.hintOptions.maxReportsPerCSSRule !== undefined) {
                            maxReportsPerCSSRule = context.hintOptions.maxReportsPerCSSRule;
                        }

                        for (let i = 0; (i < matchingElementsOutsideParentSVG.length && i < maxReportsPerCSSRule); i++) {
github webhintio / hint / packages / hint-compat-api / src / css.ts View on Github external
const report = ({ feature, formatFeature, isValue, node, unsupported }: ReportData) => {
                const alternatives = formatAlternatives(context.language, unsupported, formatFeature);
                const message = [
                    getMessage('featureNotSupported', context.language, [feature, joinBrowsers(unsupported)]),
                    ...alternatives
                ].join(' ');
                const codeSnippet = getCSSCodeSnippet(node);
                const location = getCSSLocationFromNode(node, { isValue });
                const severity = alternatives.length ? Severity.error : Severity.warning;

                context.report(
                    resource,
                    message,
                    {
                        codeLanguage: 'css',
                        codeSnippet,
                        element,
                        location,
                        severity
                    });
            };

@hint/utils-css

utils for CSS

Apache-2.0
Latest version published 1 year ago

Package Health Score

76 / 100
Full package analysis