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>
60 lines
2.4 KiB
JavaScript
60 lines
2.4 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
const ast_1 = require("../utils/ast");
|
|
const fixer_1 = require("../utils/fixer");
|
|
const parseExpectCall_1 = require("../utils/parseExpectCall");
|
|
const matcherMap = {
|
|
toBeDisabled: 'toBeEnabled',
|
|
toBeEnabled: 'toBeDisabled',
|
|
toBeHidden: 'toBeVisible',
|
|
toBeVisible: 'toBeHidden',
|
|
};
|
|
exports.default = {
|
|
create(context) {
|
|
return {
|
|
CallExpression(node) {
|
|
const expectCall = (0, parseExpectCall_1.parseExpectCall)(node);
|
|
if (!expectCall)
|
|
return;
|
|
// As the name implies, this rule only implies if the not modifier is
|
|
// part of the matcher chain
|
|
const notModifier = expectCall.modifiers.find((mod) => (0, ast_1.getStringValue)(mod) === 'not');
|
|
if (!notModifier)
|
|
return;
|
|
// This rule only applies to specific matchers that have opposites
|
|
if (expectCall.matcherName in matcherMap) {
|
|
const newMatcher = matcherMap[expectCall.matcherName];
|
|
context.report({
|
|
data: { new: newMatcher, old: expectCall.matcherName },
|
|
fix: (fixer) => [
|
|
fixer.removeRange([
|
|
notModifier.range[0] - (0, fixer_1.getRangeOffset)(notModifier),
|
|
notModifier.range[1] + 1,
|
|
]),
|
|
(0, fixer_1.replaceAccessorFixer)(fixer, expectCall.matcher, newMatcher),
|
|
],
|
|
loc: {
|
|
end: expectCall.matcher.loc.end,
|
|
start: notModifier.loc.start,
|
|
},
|
|
messageId: 'noUselessNot',
|
|
});
|
|
}
|
|
},
|
|
};
|
|
},
|
|
meta: {
|
|
docs: {
|
|
category: 'Best Practices',
|
|
description: `Disallow usage of 'not' matchers when a more specific matcher exists`,
|
|
recommended: true,
|
|
url: 'https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/no-useless-not.md',
|
|
},
|
|
fixable: 'code',
|
|
messages: {
|
|
noUselessNot: 'Unexpected usage of not.{{old}}(). Use {{new}}() instead.',
|
|
},
|
|
type: 'problem',
|
|
},
|
|
};
|