Files
formipay/node_modules/stylelint/lib/utils/checkAgainstRule.js
dwindown e8fbfb14c1 fix: prevent asset conflicts between React and Grid.js versions
Add coexistence checks to all enqueue methods to prevent loading
both React and Grid.js assets simultaneously.

Changes:
- ReactAdmin.php: Only enqueue React assets when ?react=1
- Init.php: Skip Grid.js when React active on admin pages
- Form.php, Coupon.php, Access.php: Restore classic assets when ?react=0
- Customer.php, Product.php, License.php: Add coexistence checks

Now the toggle between Classic and React versions works correctly.

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-18 17:02:14 +07:00

46 lines
1.4 KiB
JavaScript

'use strict';
const normalizeRuleSettings = require('../normalizeRuleSettings');
const Result = require('postcss/lib/result');
const { isPlainObject } = require('./validateTypes');
const getStylelintRule = require('./getStylelintRule');
/**
* Useful for third-party code (e.g. plugins) to run a PostCSS Root
* against a specific rule and do something with the warnings
*
* @type {typeof import('stylelint').utils.checkAgainstRule}
*/
function checkAgainstRule(options, callback) {
if (!isPlainObject(options)) throw new Error('Expected an options object');
if (!callback) throw new Error('Expected a callback function');
const { ruleName, ruleSettings, root, result, context = {} } = options;
if (!ruleName) throw new Error('Expected a "ruleName" option');
const rule = getStylelintRule(ruleName, result && result.stylelint.config);
if (!rule) throw new Error(`Rule "${ruleName}" does not exist`);
if (!ruleSettings) throw new Error('Expected a "ruleSettings" option');
if (!root) throw new Error('Expected a "root" option');
const settings = normalizeRuleSettings(ruleSettings, rule);
if (!settings) {
return;
}
// @ts-expect-error - this error should not occur with PostCSS 8
const tmpPostcssResult = new Result();
rule(settings[0], /** @type {Object} */ (settings[1]), context)(root, tmpPostcssResult);
for (const warning of tmpPostcssResult.warnings()) callback(warning);
}
module.exports = checkAgainstRule;