Files
formipay/node_modules/stylelint/lib/normalizeRuleSettings.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

59 lines
1.7 KiB
JavaScript

'use strict';
const { isPlainObject } = require('./utils/validateTypes');
// Rule settings can take a number of forms, e.g.
// a. "rule-name": null
// b. "rule-name": [null, ...]
// c. "rule-name": primaryOption
// d. "rule-name": [primaryOption]
// e. "rule-name": [primaryOption, secondaryOption]
// Where primaryOption can be anything: primitive, Object, or Array.
/**
* This function normalizes all the possibilities into the
* standard form: [primaryOption, secondaryOption]
* Except in the cases with null, a & b, in which case
* null is returned
* @template T
* @template {Object} O
* @param {import('stylelint').ConfigRuleSettings<T, O>} rawSettings
* @param {import('stylelint').Rule<T, O>} [rule]
* @return {[T] | [T, O] | null}
*/
module.exports = function normalizeRuleSettings(rawSettings, rule) {
if (rawSettings === null || rawSettings === undefined) {
return null;
}
if (!Array.isArray(rawSettings)) {
return [rawSettings];
}
// Everything below is an array ...
const [primary, secondary] = rawSettings;
if (rawSettings.length > 0 && (primary === null || primary === undefined)) {
return null;
}
if (rule && !rule.primaryOptionArray) {
return rawSettings;
}
// Everything below is a rule that CAN have an array for a primary option ...
// (they might also have something else, e.g. rule-properties-order can
// have the string "alphabetical")
if (rawSettings.length === 1 && Array.isArray(primary)) {
return rawSettings;
}
if (rawSettings.length === 2 && !isPlainObject(primary) && isPlainObject(secondary)) {
return rawSettings;
}
// `T` must be an array type, but TSC thinks it's probably invalid to
// cast `[T]` to `T` so we cast through `any` first.
return [/** @type {T} */ (/** @type {any} */ (rawSettings))];
};