@adguard/aglint
Version:
Universal adblock filter list linter.
31 lines (28 loc) • 846 B
JavaScript
/*
* AGLint v3.0.0 (build date: Wed, 21 May 2025 13:24:14 GMT)
* (c) 2025 AdGuard Software Ltd.
* Released under the MIT license
* https://github.com/AdguardTeam/AGLint#readme
*/
import { parse } from '@adguard/ecss-tree';
/**
* Helper function to parse CSS string into CSSTree node by using proper settings for the linter.
*
* @param rawCss Raw CSS string to parse.
* @param context Parsing context. See {@link CssTreeParsingContext}.
*
* @returns The parsed CSS node.
*
* @throws SyntaxParseError if the CSS parsing fails.
*/
const parseCss = (rawCss, context) => {
// https://github.com/csstree/csstree/blob/master/docs/parsing.md#parsesource-options
return parse(rawCss, {
context,
positions: true,
onParseError: (error) => {
throw error;
},
});
};
export { parseCss };