linter-bundle
Version:
Ready-to use bundle of linting tools, containing configurations for ESLint, stylelint and markdownlint.
31 lines (22 loc) • 787 B
JavaScript
// @ts-nocheck
import styleSearch from '../style-search/index.mjs';
const rangeOperators = ['>=', '<=', '>', '<', '='];
/** @typedef {import('style-search').StyleSearchMatch} StyleSearchMatch */
/**
* @template {import('postcss').AtRule} T
* @param {T} atRule
* @param {(match: StyleSearchMatch, params: string, atRule: T) => void} callback
*/
export default function findMediaOperator (atRule, callback) {
if (atRule.name.toLowerCase() !== 'media') {
return;
}
const parameters = atRule.raws.params ? atRule.raws.params.raw : atRule.params;
styleSearch({ source: parameters, target: rangeOperators }, (match) => {
const before = parameters[match.startIndex - 1];
if (before === '>' || before === '<') {
return;
}
callback(match, parameters, atRule);
});
}