transformSelector.js 504 B

12345678910111213141516
  1. 'use strict';
  2. const selectorParser = require('postcss-selector-parser');
  3. /**
  4. * @param {import('stylelint').PostcssResult} result
  5. * @param {import('postcss').Rule} node
  6. * @param {(root: import('postcss-selector-parser').Root) => void} callback
  7. */
  8. module.exports = function transformSelector(result, node, callback) {
  9. try {
  10. return selectorParser(callback).processSync(node, { updateSelector: true });
  11. } catch {
  12. result.warn('Cannot parse selector', { node, stylelintType: 'parseError' });
  13. }
  14. };