chore: lint

This commit is contained in:
amhsirak
2024-12-11 02:02:09 +05:30
parent 81bbba473f
commit a34e865773

View File

@@ -82,8 +82,8 @@ export const getElementInformation = async (
const originalEl = document.elementFromPoint(x, y) as HTMLElement; const originalEl = document.elementFromPoint(x, y) as HTMLElement;
if (originalEl) { if (originalEl) {
let element = originalEl; let element = originalEl;
const containerTags = ['DIV', 'SECTION', 'ARTICLE', 'MAIN', 'HEADER', 'FOOTER', 'NAV', 'ASIDE', const containerTags = ['DIV', 'SECTION', 'ARTICLE', 'MAIN', 'HEADER', 'FOOTER', 'NAV', 'ASIDE',
'ADDRESS', 'BLOCKQUOTE', 'DETAILS', 'DIALOG', 'FIGURE', 'FIGCAPTION', 'MAIN', 'MARK', 'SUMMARY', 'TIME', 'ADDRESS', 'BLOCKQUOTE', 'DETAILS', 'DIALOG', 'FIGURE', 'FIGCAPTION', 'MAIN', 'MARK', 'SUMMARY', 'TIME',
'TABLE', 'THEAD', 'TBODY', 'TFOOT', 'TR', 'TH', 'TD', 'CAPTION', 'COLGROUP', 'COL', 'FORM', 'FIELDSET', 'TABLE', 'THEAD', 'TBODY', 'TFOOT', 'TR', 'TH', 'TD', 'CAPTION', 'COLGROUP', 'COL', 'FORM', 'FIELDSET',
'LEGEND', 'LABEL', 'INPUT', 'BUTTON', 'SELECT', 'DATALIST', 'OPTGROUP', 'OPTION', 'TEXTAREA', 'OUTPUT', 'LEGEND', 'LABEL', 'INPUT', 'BUTTON', 'SELECT', 'DATALIST', 'OPTGROUP', 'OPTION', 'TEXTAREA', 'OUTPUT',
@@ -99,14 +99,14 @@ export const getElementInformation = async (
break; break;
} }
const fullyContained = const fullyContained =
parentRect.left <= childRect.left && parentRect.left <= childRect.left &&
parentRect.right >= childRect.right && parentRect.right >= childRect.right &&
parentRect.top <= childRect.top && parentRect.top <= childRect.top &&
parentRect.bottom >= childRect.bottom; parentRect.bottom >= childRect.bottom;
const significantOverlap = const significantOverlap =
(childRect.width * childRect.height) / (childRect.width * childRect.height) /
(parentRect.width * parentRect.height) > 0.5; (parentRect.width * parentRect.height) > 0.5;
if (fullyContained && significantOverlap) { if (fullyContained && significantOverlap) {
@@ -203,8 +203,8 @@ export const getRect = async (page: Page, coordinates: Coordinates, listSelector
const originalEl = document.elementFromPoint(x, y) as HTMLElement; const originalEl = document.elementFromPoint(x, y) as HTMLElement;
if (originalEl) { if (originalEl) {
let element = originalEl; let element = originalEl;
const containerTags = ['DIV', 'SECTION', 'ARTICLE', 'MAIN', 'HEADER', 'FOOTER', 'NAV', 'ASIDE', const containerTags = ['DIV', 'SECTION', 'ARTICLE', 'MAIN', 'HEADER', 'FOOTER', 'NAV', 'ASIDE',
'ADDRESS', 'BLOCKQUOTE', 'DETAILS', 'DIALOG', 'FIGURE', 'FIGCAPTION', 'MAIN', 'MARK', 'SUMMARY', 'TIME', 'ADDRESS', 'BLOCKQUOTE', 'DETAILS', 'DIALOG', 'FIGURE', 'FIGCAPTION', 'MAIN', 'MARK', 'SUMMARY', 'TIME',
'TABLE', 'THEAD', 'TBODY', 'TFOOT', 'TR', 'TH', 'TD', 'CAPTION', 'COLGROUP', 'COL', 'FORM', 'FIELDSET', 'TABLE', 'THEAD', 'TBODY', 'TFOOT', 'TR', 'TH', 'TD', 'CAPTION', 'COLGROUP', 'COL', 'FORM', 'FIELDSET',
'LEGEND', 'LABEL', 'INPUT', 'BUTTON', 'SELECT', 'DATALIST', 'OPTGROUP', 'OPTION', 'TEXTAREA', 'OUTPUT', 'LEGEND', 'LABEL', 'INPUT', 'BUTTON', 'SELECT', 'DATALIST', 'OPTGROUP', 'OPTION', 'TEXTAREA', 'OUTPUT',
@@ -220,14 +220,14 @@ export const getRect = async (page: Page, coordinates: Coordinates, listSelector
break; break;
} }
const fullyContained = const fullyContained =
parentRect.left <= childRect.left && parentRect.left <= childRect.left &&
parentRect.right >= childRect.right && parentRect.right >= childRect.right &&
parentRect.top <= childRect.top && parentRect.top <= childRect.top &&
parentRect.bottom >= childRect.bottom; parentRect.bottom >= childRect.bottom;
const significantOverlap = const significantOverlap =
(childRect.width * childRect.height) / (childRect.width * childRect.height) /
(parentRect.width * parentRect.height) > 0.5; (parentRect.width * parentRect.height) > 0.5;
if (fullyContained && significantOverlap) { if (fullyContained && significantOverlap) {
@@ -238,7 +238,7 @@ export const getRect = async (page: Page, coordinates: Coordinates, listSelector
} }
const rectangle = element?.getBoundingClientRect(); const rectangle = element?.getBoundingClientRect();
if (rectangle) { if (rectangle) {
return { return {
x: rectangle.x, x: rectangle.x,
@@ -916,7 +916,7 @@ export const getNonUniqueSelectors = async (page: Page, coordinates: Coordinates
let element = originalEl; let element = originalEl;
const containerTags = ['DIV', 'SECTION', 'ARTICLE', 'MAIN', 'HEADER', 'FOOTER', 'NAV', 'ASIDE', const containerTags = ['DIV', 'SECTION', 'ARTICLE', 'MAIN', 'HEADER', 'FOOTER', 'NAV', 'ASIDE',
'ADDRESS', 'BLOCKQUOTE', 'DETAILS', 'DIALOG', 'FIGURE', 'FIGCAPTION', 'MAIN', 'MARK', 'SUMMARY', 'TIME', 'ADDRESS', 'BLOCKQUOTE', 'DETAILS', 'DIALOG', 'FIGURE', 'FIGCAPTION', 'MAIN', 'MARK', 'SUMMARY', 'TIME',
'TABLE', 'THEAD', 'TBODY', 'TFOOT', 'TR', 'TH', 'TD', 'CAPTION', 'COLGROUP', 'COL', 'FORM', 'FIELDSET', 'TABLE', 'THEAD', 'TBODY', 'TFOOT', 'TR', 'TH', 'TD', 'CAPTION', 'COLGROUP', 'COL', 'FORM', 'FIELDSET',
'LEGEND', 'LABEL', 'INPUT', 'BUTTON', 'SELECT', 'DATALIST', 'OPTGROUP', 'OPTION', 'TEXTAREA', 'OUTPUT', 'LEGEND', 'LABEL', 'INPUT', 'BUTTON', 'SELECT', 'DATALIST', 'OPTGROUP', 'OPTION', 'TEXTAREA', 'OUTPUT',
@@ -924,7 +924,7 @@ export const getNonUniqueSelectors = async (page: Page, coordinates: Coordinates
'PARAM', 'VIDEO', 'AUDIO', 'SOURCE', 'TRACK', 'CANVAS', 'MAP', 'AREA', 'SVG', 'IFRAME', 'FRAME', 'FRAMESET', 'PARAM', 'VIDEO', 'AUDIO', 'SOURCE', 'TRACK', 'CANVAS', 'MAP', 'AREA', 'SVG', 'IFRAME', 'FRAME', 'FRAMESET',
'LI', 'UL', 'OL', 'DL', 'DT', 'DD', 'HR', 'P', 'PRE', 'LISTING', 'PLAINTEXT', 'A' 'LI', 'UL', 'OL', 'DL', 'DT', 'DD', 'HR', 'P', 'PRE', 'LISTING', 'PLAINTEXT', 'A'
]; ];
while (element.parentElement) { while (element.parentElement) {
const parentRect = element.parentElement.getBoundingClientRect(); const parentRect = element.parentElement.getBoundingClientRect();
const childRect = element.getBoundingClientRect(); const childRect = element.getBoundingClientRect();
@@ -933,22 +933,22 @@ export const getNonUniqueSelectors = async (page: Page, coordinates: Coordinates
break; break;
} }
const fullyContained = const fullyContained =
parentRect.left <= childRect.left && parentRect.left <= childRect.left &&
parentRect.right >= childRect.right && parentRect.right >= childRect.right &&
parentRect.top <= childRect.top && parentRect.top <= childRect.top &&
parentRect.bottom >= childRect.bottom; parentRect.bottom >= childRect.bottom;
const significantOverlap = const significantOverlap =
(childRect.width * childRect.height) / (childRect.width * childRect.height) /
(parentRect.width * parentRect.height) > 0.5; (parentRect.width * parentRect.height) > 0.5;
if (fullyContained && significantOverlap) { if (fullyContained && significantOverlap) {
element = element.parentElement; element = element.parentElement;
} else { } else {
break; break;
}
} }
}
const generalSelector = getSelectorPath(element); const generalSelector = getSelectorPath(element);
return { return {