Files
formipay/node_modules/stylelint/lib/rules/function-name-case/index.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

115 lines
2.9 KiB
JavaScript

'use strict';
const declarationValueIndex = require('../../utils/declarationValueIndex');
const getDeclarationValue = require('../../utils/getDeclarationValue');
const isStandardSyntaxFunction = require('../../utils/isStandardSyntaxFunction');
const { camelCaseFunctions } = require('../../reference/functions');
const optionsMatches = require('../../utils/optionsMatches');
const report = require('../../utils/report');
const ruleMessages = require('../../utils/ruleMessages');
const setDeclarationValue = require('../../utils/setDeclarationValue');
const validateOptions = require('../../utils/validateOptions');
const valueParser = require('postcss-value-parser');
const { isRegExp, isString } = require('../../utils/validateTypes');
const ruleName = 'function-name-case';
const messages = ruleMessages(ruleName, {
expected: (actual, expected) => `Expected "${actual}" to be "${expected}"`,
});
const meta = {
url: 'https://stylelint.io/user-guide/rules/function-name-case',
fixable: true,
};
const mapLowercaseFunctionNamesToCamelCase = new Map();
for (const func of camelCaseFunctions) {
mapLowercaseFunctionNamesToCamelCase.set(func.toLowerCase(), func);
}
/** @type {import('stylelint').Rule} */
const rule = (primary, secondaryOptions, context) => {
return (root, result) => {
const validOptions = validateOptions(
result,
ruleName,
{
actual: primary,
possible: ['lower', 'upper'],
},
{
actual: secondaryOptions,
possible: {
ignoreFunctions: [isString, isRegExp],
},
optional: true,
},
);
if (!validOptions) {
return;
}
root.walkDecls((decl) => {
let needFix = false;
const parsed = valueParser(getDeclarationValue(decl));
parsed.walk((node) => {
if (node.type !== 'function' || !isStandardSyntaxFunction(node)) {
return;
}
const functionName = node.value;
const functionNameLowerCase = functionName.toLowerCase();
if (optionsMatches(secondaryOptions, 'ignoreFunctions', functionName)) {
return;
}
let expectedFunctionName = null;
if (
primary === 'lower' &&
mapLowercaseFunctionNamesToCamelCase.has(functionNameLowerCase)
) {
expectedFunctionName = mapLowercaseFunctionNamesToCamelCase.get(functionNameLowerCase);
} else if (primary === 'lower') {
expectedFunctionName = functionNameLowerCase;
} else {
expectedFunctionName = functionName.toUpperCase();
}
if (functionName === expectedFunctionName) {
return;
}
if (context.fix) {
needFix = true;
node.value = expectedFunctionName;
return;
}
report({
message: messages.expected(functionName, expectedFunctionName),
node: decl,
index: declarationValueIndex(decl) + node.sourceIndex,
result,
ruleName,
});
});
if (context.fix && needFix) {
setDeclarationValue(decl, parsed.toString());
}
});
};
};
rule.ruleName = ruleName;
rule.messages = messages;
rule.meta = meta;
module.exports = rule;