UNPKG

@adguard/aglint

Version:

Universal adblock filter list linter.

72 lines (71 loc) 2.54 kB
/** * Migrated from https://github.com/AdguardTeam/tsurlfilter/blob/2144959e92f94e4738274ce577c2fe26e3a0c08b/packages/agtree/src/utils/csstree.ts. * * We implement our custom generate logic for some CSS nodes because CSSTree's default * generator does not add spaces, just in some edge cases, but we want to show some formatted code. */ import { type DeclarationList, type FunctionNode, type MediaQuery, type MediaQueryList, type PseudoClassSelector, type Selector, type SelectorList } from '@adguard/ecss-tree'; /** * Generates string representation of the media query. * * @param mediaQueryNode Media query AST. * * @returns String representation of the media query. */ export declare const generateMediaQuery: (mediaQueryNode: MediaQuery) => string; /** * Generates string representation of the media query list. * * @param mediaQueryListNode Media query list AST. * * @returns String representation of the media query list. */ export declare const generateMediaQueryList: (mediaQueryListNode: MediaQueryList) => string; /** * Selector generation based on CSSTree's AST. This is necessary because CSSTree * only adds spaces in some edge cases. * * @param selectorNode CSS Tree AST. * * @returns CSS selector as string. */ export declare const generateSelector: (selectorNode: Selector) => string; /** * Generates string representation of the selector list. * * @param selectorListNode SelectorList AST. * * @returns String representation of the selector list. */ export declare const generateSelectorList: (selectorListNode: SelectorList) => string; /** * Block generation based on CSSTree's AST. This is necessary because CSSTree only adds spaces in some edge cases. * * @param declarationListNode CSS Tree AST. * * @returns CSS selector as string. */ export declare const generateDeclarationList: (declarationListNode: DeclarationList) => string; /** * Helper function to generate a raw string from a pseudo-class * selector's children. * * @param node Pseudo-class selector node. * * @returns Generated pseudo-class value. * * @example * - `:nth-child(2n+1)` -> `2n+1` * - `:matches-path(/foo/bar)` -> `/foo/bar` */ export declare const generatePseudoClassValue: (node: PseudoClassSelector) => string; /** * Helper function to generate a raw string from a function selector's children. * * @param node Function node. * * @returns Generated function value. * * @example `responseheader(name)` -> `name` */ export declare const generateFunctionValue: (node: FunctionNode) => string;