epiphany/node_modules/stylelint/lib/utils/transformSelector.js
2023-12-09 22:48:07 -08:00

19 lines
558 B
JavaScript

'use strict';
const selectorParser = require('postcss-selector-parser');
/**
* @param {import('stylelint').PostcssResult} result
* @param {import('postcss').Rule} node
* @param {(root: import('postcss-selector-parser').Root) => void} callback
* @returns {string | undefined}
*/
module.exports = function transformSelector(result, node, callback) {
try {
return selectorParser(callback).processSync(node, { updateSelector: true });
} catch {
result.warn('Cannot parse selector', { node, stylelintType: 'parseError' });
return undefined;
}
};