Skip to content

Commit ead0f0c

Browse files
committed
refactor: optimizations
1 parent a4b2023 commit ead0f0c

File tree

4 files changed

+20
-7
lines changed

4 files changed

+20
-7
lines changed

helpers/test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable-next-line unicorn/prefer-module, unicorn/no-anonymous-default-export */
12
module.exports = function (Handlebars) {
23
Handlebars.registerHelper('test', function () {
34
return 'This is a test helper';

scripts/check-commit-mail.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ import * as dotenv from 'dotenv';
66
dotenv.config();
77

88
const checkCommitMail = () => {
9+
// eslint-disable-next-line no-console
910
console.log(`Check COMMIT_MAIL`);
1011
if (!process.env.COMMIT_MAIL) {
12+
// eslint-disable-next-line no-console
1113
console.error(
1214
`No COMMIT_MAIL set in .env, please look at the file '.env.template'`
1315
);
@@ -20,9 +22,11 @@ const checkCommitMail = () => {
2022
.toLowerCase();
2123
const commitMail = process.env.COMMIT_MAIL.trim().toLowerCase();
2224
if (currentMail !== commitMail) {
25+
// eslint-disable-next-line no-console
2326
console.error(
2427
`currentMail: ${currentMail} !== initialMail: ${commitMail}`
2528
);
29+
// eslint-disable-next-line no-console
2630
console.error(
2731
`Please set your commit user mail for this project like: 'git config user.email "${commitMail}"'`
2832
);
Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1+
// eslint-disable-next-line unicorn/prefer-module, unicorn/no-anonymous-default-export
12
module.exports = async (page, scenario) => {
23
const hoverSelector = scenario.hoverSelectors || scenario.hoverSelector;
34
const clickSelector = scenario.clickSelectors || scenario.clickSelector;
45
const keyPressSelector =
56
scenario.keyPressSelectors || scenario.keyPressSelector;
6-
const scrollToSelector = scenario.scrollToSelector;
7-
const postInteractionWait = scenario.postInteractionWait; // selector [str] | ms [int]
7+
const {scrollToSelector} = scenario;
8+
const {postInteractionWait} = scenario; // Selector [str] | ms [int]
89

910
if (keyPressSelector) {
10-
for (const keyPressSelectorItem of [].concat(keyPressSelector)) {
11+
for (const keyPressSelectorItem of [keyPressSelector].flat()) {
12+
// eslint-disable-next-line no-await-in-loop
1113
await page.waitForSelector(keyPressSelectorItem.selector);
14+
// eslint-disable-next-line no-await-in-loop
1215
await page.type(
1316
keyPressSelectorItem.selector,
1417
keyPressSelectorItem.keyPress
@@ -17,15 +20,19 @@ module.exports = async (page, scenario) => {
1720
}
1821

1922
if (hoverSelector) {
20-
for (const hoverSelectorIndex of [].concat(hoverSelector)) {
23+
for (const hoverSelectorIndex of [hoverSelector].flat()) {
24+
// eslint-disable-next-line no-await-in-loop
2125
await page.waitForSelector(hoverSelectorIndex);
26+
// eslint-disable-next-line no-await-in-loop
2227
await page.hover(hoverSelectorIndex);
2328
}
2429
}
2530

2631
if (clickSelector) {
27-
for (const clickSelectorIndex of [].concat(clickSelector)) {
32+
for (const clickSelectorIndex of [clickSelector].flat()) {
33+
// eslint-disable-next-line no-await-in-loop
2834
await page.waitForSelector(clickSelectorIndex);
35+
// eslint-disable-next-line no-await-in-loop
2936
await page.click(clickSelectorIndex);
3037
}
3138
}
@@ -37,7 +44,7 @@ module.exports = async (page, scenario) => {
3744
if (scrollToSelector) {
3845
await page.waitForSelector(scrollToSelector);
3946
await page.evaluate((scrollToSelector) => {
40-
document.querySelector(scrollToSelector).scrollIntoView();
47+
globalThis.querySelector(scrollToSelector).scrollIntoView();
4148
}, scrollToSelector);
4249
}
4350
};

xo.config.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ const xoConfig = [
88
'tests/backstop_data/engine_scripts/',
99
'out/**/*',
1010
'dist/**/*',
11-
'**/*.min.js'
11+
'**/*.min.js',
12+
'source/_patterns/02-components/dialog/focus-restore.dialog.plugin.js'
1213
],
1314
prettier: true,
1415
rules: {

0 commit comments

Comments
 (0)