Files
formipay/node_modules/eslint-plugin-playwright/lib/rules/prefer-lowercase-title.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

107 lines
3.8 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const ast_1 = require("../utils/ast");
function isString(node) {
return node && ((0, ast_1.isStringLiteral)(node) || node.type === 'TemplateLiteral');
}
exports.default = {
create(context) {
const { allowedPrefixes, ignore, ignoreTopLevelDescribe } = {
allowedPrefixes: [],
ignore: [],
ignoreTopLevelDescribe: false,
...(context.options?.[0] ?? {}),
};
let describeCount = 0;
return {
CallExpression(node) {
const method = (0, ast_1.isDescribeCall)(node)
? 'test.describe'
: (0, ast_1.isTest)(node)
? 'test'
: null;
if (method === 'test.describe') {
describeCount++;
if (ignoreTopLevelDescribe && describeCount === 1) {
return;
}
}
else if (!method) {
return;
}
const [title] = node.arguments;
if (!isString(title)) {
return;
}
const description = (0, ast_1.getStringValue)(title);
if (!description ||
allowedPrefixes.some((name) => description.startsWith(name))) {
return;
}
const firstCharacter = description.charAt(0);
if (!firstCharacter ||
firstCharacter === firstCharacter.toLowerCase() ||
ignore.includes(method)) {
return;
}
context.report({
data: { method },
fix(fixer) {
const rangeIgnoringQuotes = [
title.range[0] + 1,
title.range[1] - 1,
];
const newDescription = description.substring(0, 1).toLowerCase() +
description.substring(1);
return fixer.replaceTextRange(rangeIgnoringQuotes, newDescription);
},
messageId: 'unexpectedLowercase',
node: node.arguments[0],
});
},
'CallExpression:exit'(node) {
if ((0, ast_1.isDescribeCall)(node)) {
describeCount--;
}
},
};
},
meta: {
docs: {
category: 'Best Practices',
description: 'Enforce lowercase test names',
recommended: false,
url: 'https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/prefer-lowercase-title.md',
},
fixable: 'code',
messages: {
unexpectedLowercase: '`{{method}}`s should begin with lowercase',
},
schema: [
{
additionalProperties: false,
properties: {
allowedPrefixes: {
additionalItems: false,
items: { type: 'string' },
type: 'array',
},
ignore: {
additionalItems: false,
items: {
enum: ['test.describe', 'test'],
},
type: 'array',
},
ignoreTopLevelDescribe: {
default: false,
type: 'boolean',
},
},
type: 'object',
},
],
type: 'suggestion',
},
};