How to use query-ast - 1 common examples

To help you get started, we’ve selected a few query-ast 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 jgranstrom / sass-extract / src / parse.js View on Github external
export function parseDeclarations(data) {
  const ast = parse(data);
  const $ast = createQueryWrapper(ast);

  const implicitGlobalDeclarations = $ast('declaration').hasParent('stylesheet');
  const explicitGlobalDeclarations = $ast('declaration').hasParent('block')
  .filter(node => isExplicitGlobalDeclaration($ast, node));

  let implicitGlobals = implicitGlobalDeclarations.map(declaration => parseDeclaration($ast, declaration, SCOPE_IMPICIT));
  let explicitGlobals = explicitGlobalDeclarations.map(declaration => parseDeclaration($ast, declaration, SCOPE_EXPLICIT));  

  return { explicitGlobals, implicitGlobals };
}

query-ast

A library to traverse/modify an AST

BSD-3-Clause
Latest version published 2 years ago

Package Health Score

58 / 100
Full package analysis

Popular query-ast functions

Similar packages