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>
58 lines
2.5 KiB
JavaScript
58 lines
2.5 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
const ast_1 = require("../utils/ast");
|
|
function getPropertyRange(node) {
|
|
return node.type === 'Identifier'
|
|
? node.range
|
|
: [node.range[0] + 1, node.range[1] - 1];
|
|
}
|
|
exports.default = {
|
|
create(context) {
|
|
return {
|
|
CallExpression(node) {
|
|
if ((0, ast_1.isPageMethod)(node, '$') || (0, ast_1.isPageMethod)(node, '$$')) {
|
|
context.report({
|
|
messageId: 'noElementHandle',
|
|
node: node.callee,
|
|
suggest: [
|
|
{
|
|
fix: (fixer) => {
|
|
const { property } = node.callee;
|
|
// Replace $/$$ with locator
|
|
const fixes = [
|
|
fixer.replaceTextRange(getPropertyRange(property), 'locator'),
|
|
];
|
|
// Remove the await expression if it exists as locators do
|
|
// not need to be awaited.
|
|
if (node.parent.type === 'AwaitExpression') {
|
|
fixes.push(fixer.removeRange([node.parent.range[0], node.range[0]]));
|
|
}
|
|
return fixes;
|
|
},
|
|
messageId: (0, ast_1.isPageMethod)(node, '$')
|
|
? 'replaceElementHandleWithLocator'
|
|
: 'replaceElementHandlesWithLocator',
|
|
},
|
|
],
|
|
});
|
|
}
|
|
},
|
|
};
|
|
},
|
|
meta: {
|
|
docs: {
|
|
category: 'Possible Errors',
|
|
description: 'The use of ElementHandle is discouraged, use Locator instead',
|
|
recommended: true,
|
|
url: 'https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/no-element-handle.md',
|
|
},
|
|
hasSuggestions: true,
|
|
messages: {
|
|
noElementHandle: 'Unexpected use of element handles.',
|
|
replaceElementHandlesWithLocator: 'Replace `page.$$` with `page.locator`',
|
|
replaceElementHandleWithLocator: 'Replace `page.$` with `page.locator`',
|
|
},
|
|
type: 'suggestion',
|
|
},
|
|
};
|