How to use the postcss-values-parser.parse function in postcss-values-parser

To help you get started, we’ve selected a few postcss-values-parser 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 signal-noise / stylelint-scales / lib / rules / word-spacing / index.js View on Github external
function check(decl, size) {
      // Parse the size and walk through Numerics
      parse(size, {
        ignoreUnknownWords: true
      }).walkNumerics(({ value, unit: valueUnit }) => {
        // Return early if not a checked unit
        if (!lengthUnits.includes(valueUnit)) return;

        // Validate scale and units
        const validUnit = unit ? valueUnit === unit : true;
        const validScale = scale.includes(Math.abs(Number(value)));

        // Get message of the violation
        let message;
        if (!validScale) {
          message = messages.expected(`${value}`, scale.join(", "));
        } else if (!validUnit) {
          message = messages.expected(`${valueUnit}`, `${unit}`);
        } else {
github signal-noise / stylelint-scales / lib / rules / font-size / index.js View on Github external
function check(decl, size) {
      // Parse the size and walk through Numerics
      parse(size, {
        ignoreUnknownWords: true
      }).walkNumerics(({ value, unit: valueUnit }) => {
        // Return early if not a checked unit
        if (!lengthUnits.includes(valueUnit)) return;

        // Validate scale and units
        const validUnit = unit ? valueUnit === unit : true;
        const validScale = scale.includes(Number(value));

        // Get message of the violation
        let message;
        if (!validScale) {
          message = messages.expected(`${value}`, scale.join(", "));
        } else if (!validUnit) {
          message = messages.expected(`${valueUnit}`, `${unit}`);
        } else {
github signal-noise / stylelint-scales / lib / rules / sizes / index.js View on Github external
function check(decl, size) {
      // Parse the size and walk through Numerics
      parse(size, {
        ignoreUnknownWords: true
      }).walkNumerics(({ value, unit: valueUnit }) => {
        // Return early if not a checked unit
        if (!lengthUnits.includes(valueUnit)) return;

        // Validate scale and units
        const validUnit = unit ? valueUnit === unit : true;
        const validScale = scale.includes(Number(value));

        // Get message of the violation
        let message;
        if (!validScale) {
          message = messages.expected(`${value}`, scale.join(", "));
        } else if (!validUnit) {
          message = messages.expected(`${valueUnit}`, `${unit}`);
        } else {
github signal-noise / stylelint-scales / lib / rules / letter-spacing / index.js View on Github external
function check(decl, size) {
      // Parse the size and walk through Numerics
      parse(size, {
        ignoreUnknownWords: true
      }).walkNumerics(({ value, unit: valueUnit }) => {
        // Return early if not a checked unit
        if (!lengthUnits.includes(valueUnit)) return;

        // Validate scale and units
        const validUnit = unit ? valueUnit === unit : true;
        const validScale = scale.includes(Math.abs(Number(value)));

        // Get message of the violation
        let message;
        if (!validScale) {
          message = messages.expected(`${value}`, scale.join(", "));
        } else if (!validUnit) {
          message = messages.expected(`${valueUnit}`, `${unit}`);
        } else {
github postcss / postcss-custom-properties / src / lib / get-custom-properties-from-root.js View on Github external
rule.nodes.slice().forEach(decl => {
				if (isCustomDecl(decl) && !isBlockIgnored(decl)) {
					const { prop } = decl;

					// write the parsed value to the custom property
					customPropertiesObject[prop] = parse(decl.value).nodes;

					// conditionally remove the custom property declaration
					if (!opts.preserve) {
						decl.remove();
					}
				}
			});
github csstools / postcss-env-function / src / lib / get-replaced-value.js View on Github external
export default (originalValue, variables) => {
	// get the ast of the original value
	const ast = parse(originalValue);

	// walk all of the css env() functions
	walkEnvFuncs(ast, node => {
		// update the environment value for the css env() function
		updateEnvValue(node, variables);
	});

	// return the stringified ast
	return String(ast);
};
github projectwallace / css-analyzer / src / analyzer / values / animations.js View on Github external
function getSingleTimingFunction(animation) {
  let timingFunction

  parse(animation).walk(node => {
    // There should only be one timing function per shorthand
    if (timingFunction) {
      return
    }

    // Look for timing keywords
    if (
      node.type === 'word' &&
      [
        'ease',
        'ease-in',
        'ease-in-out',
        'ease-out',
        'linear',
        'step-start',
        'step-end'
github signal-noise / stylelint-scales / lib / rules / border-width / index.js View on Github external
function check(decl, size) {
      // Parse the size and walk through Numerics
      parse(size, {
        ignoreUnknownWords: true
      }).walkNumerics(({ value, unit: valueUnit }) => {
        // Return early if not a checked unit
        if (!lengthUnits.includes(valueUnit)) return;

        // Validate scale and units
        const validUnit = unit ? valueUnit === unit : true;
        const validScale = scale.includes(Math.abs(Number(value)));

        // Get message of the violation
        let message;
        if (!validScale) {
          message = messages.expected(`${value}`, scale.join(", "));
        } else if (!validUnit) {
          message = messages.expected(`${valueUnit}`, `${unit}`);
        } else {