Lint e2e tests, enforce selectors

This commit is contained in:
Yury Bondarenko
2024-03-14 14:30:25 +01:00
parent 13e9808df2
commit 9a27db3835
4 changed files with 68 additions and 1 deletions

View File

@@ -98,7 +98,20 @@ export default ESLintUtils.RuleCreator.withoutDocs({
// ignore tests and non-routing modules
if (context.getFilename()?.endsWith('.spec.ts')) {
return {
[`CallExpression[callee.object.name = "By"][callee.property.name = "css"] > Literal[value = /.*${DISALLOWED_THEME_SELECTORS}.*/]`](node: any) {
[`CallExpression[callee.object.name = "By"][callee.property.name = "css"] > Literal:first-child[value = /.*${DISALLOWED_THEME_SELECTORS}.*/]`](node: any) {
context.report({
node,
messageId: 'mustUseThemedWrapper',
fix(fixer: any){
const newSelector = fixSelectors(node.raw);
return fixer.replaceText(node, newSelector);
}
});
},
};
} else if (context.getFilename()?.endsWith('.cy.ts')) {
return {
[`CallExpression[callee.object.name = "cy"][callee.property.name = "get"] > Literal:first-child[value = /.*${DISALLOWED_THEME_SELECTORS}.*/]`](node: any) {
context.report({
node,
messageId: 'mustUseThemedWrapper',