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

67 lines
2.1 KiB
JavaScript

'use strict';
/** @typedef {import('stylelint').RangeType} RangeType */
/** @typedef {import('stylelint').DisableReportRange} DisabledRange */
/** @typedef {import('stylelint').LintResult} StylelintResult */
/** @typedef {import('stylelint').ConfigRuleSettings<any, Object>} StylelintConfigRuleSettings */
/**
* Returns a report describing which `results` (if any) contain disabled ranges
* for rules that disallow disables via `reportDisables: true`.
*
* @param {StylelintResult[]} results
*/
module.exports = function reportDisables(results) {
for (const result of results) {
// File with `CssSyntaxError` don't have `_postcssResult`s.
if (!result._postcssResult) {
continue;
}
/** @type {{[ruleName: string]: Array<RangeType>}} */
const rangeData = result._postcssResult.stylelint.disabledRanges;
if (!rangeData) continue;
const config = result._postcssResult.stylelint.config;
if (!config || !config.rules) continue;
// If no rules actually disallow disables, don't bother looking for ranges
// that correspond to disabled rules.
if (!Object.values(config.rules).some((rule) => reportDisablesForRule(rule))) {
continue;
}
for (const [rule, ranges] of Object.entries(rangeData)) {
for (const range of ranges) {
if (!reportDisablesForRule(config.rules[rule] || [])) continue;
// If the comment doesn't have a location, we can't report a useful error.
// In practice we expect all comments to have locations, though.
if (!range.comment.source || !range.comment.source.start) continue;
result.warnings.push({
text: `Rule "${rule}" may not be disabled`,
rule: 'reportDisables',
line: range.comment.source.start.line,
column: range.comment.source.start.column,
endLine: range.comment.source.end && range.comment.source.end.line,
endColumn: range.comment.source.end && range.comment.source.end.column,
severity: 'error',
});
}
}
}
};
/**
* @param {StylelintConfigRuleSettings} options
* @return {boolean}
*/
function reportDisablesForRule(options) {
if (!options || !options[1]) return false;
return Boolean(options[1].reportDisables);
}