chore:: lint

This commit is contained in:
karishmas6
2024-06-06 05:14:18 +05:30
parent cded3fead6
commit bdc37a188f

View File

@@ -38,7 +38,8 @@ export const getRect = async (page: Page, coordinates: Coordinates) => {
left: rectangle.left, left: rectangle.left,
}; };
} }
}}, }
},
{ x: coordinates.x, y: coordinates.y }, { x: coordinates.x, y: coordinates.y },
); );
return rect; return rect;
@@ -65,7 +66,7 @@ export const getElementInformation = async (
const elementInfo = await page.evaluate( const elementInfo = await page.evaluate(
async ({ x, y }) => { async ({ x, y }) => {
const el = document.elementFromPoint(x, y) as HTMLElement; const el = document.elementFromPoint(x, y) as HTMLElement;
if ( el ) { if (el) {
const { parentElement } = el; const { parentElement } = el;
// Match the logic in recorder.ts for link clicks // Match the logic in recorder.ts for link clicks
const element = parentElement?.tagName === 'A' ? parentElement : el; const element = parentElement?.tagName === 'A' ? parentElement : el;
@@ -100,7 +101,7 @@ export const getElementInformation = async (
*/ */
export const getSelectors = async (page: Page, coordinates: Coordinates) => { export const getSelectors = async (page: Page, coordinates: Coordinates) => {
try { try {
const selectors : any = await page.evaluate(async ({ x, y }) => { const selectors: any = await page.evaluate(async ({ x, y }) => {
// version @medv/finder // version @medv/finder
// https://github.com/antonmedv/finder/blob/master/finder.ts // https://github.com/antonmedv/finder/blob/master/finder.ts
@@ -558,7 +559,7 @@ export const getSelectors = async (page: Page, coordinates: Coordinates) => {
const genSelectors = (element: HTMLElement | null) =>{ const genSelectors = (element: HTMLElement | null) => {
if (element == null) { if (element == null) {
return null; return null;
} }
@@ -639,7 +640,7 @@ export const getSelectors = async (page: Page, coordinates: Coordinates) => {
return genAttributeSet(element, attributes).size > 0; return genAttributeSet(element, attributes).size > 0;
} }
// Gets all attributes that aren't null and empty // Gets all attributes that aren't null and empty
function genValidAttributeFilter(element: HTMLElement, attributes: string[]) { function genValidAttributeFilter(element: HTMLElement, attributes: string[]) {
const attrSet = genAttributeSet(element, attributes); const attrSet = genAttributeSet(element, attributes);
@@ -655,12 +656,12 @@ export const getSelectors = async (page: Page, coordinates: Coordinates) => {
attr: genValidAttributeFilter(element, attributes), attr: genValidAttributeFilter(element, attributes),
}) })
: null; : null;
} catch (e) {} } catch (e) { }
return selector; return selector;
} }
// isCharacterNumber // isCharacterNumber
function isCharacterNumber(char: string) { function isCharacterNumber(char: string) {
return char.length === 1 && char.match(/[0-9]/); return char.length === 1 && char.match(/[0-9]/);
} }
@@ -711,11 +712,11 @@ export const selectorAlreadyInWorkflow = (selector: string, workflow: Workflow)
* @param page The page to use for the validation. * @param page The page to use for the validation.
* @category WorkflowManagement * @category WorkflowManagement
*/ */
export const isRuleOvershadowing = async(selectors: string[], page:Page): Promise<boolean> => { export const isRuleOvershadowing = async (selectors: string[], page: Page): Promise<boolean> => {
for (const selector of selectors){ for (const selector of selectors) {
const areElsVisible = await page.$$eval(selector, const areElsVisible = await page.$$eval(selector,
(elems) => { (elems) => {
const isVisible = ( elem: HTMLElement | SVGElement ) => { const isVisible = (elem: HTMLElement | SVGElement) => {
if (elem instanceof HTMLElement) { if (elem instanceof HTMLElement) {
return !!(elem.offsetWidth return !!(elem.offsetWidth
|| elem.offsetHeight || elem.offsetHeight
@@ -735,7 +736,7 @@ export const isRuleOvershadowing = async(selectors: string[], page:Page): Promis
return false return false
} }
if (areElsVisible.includes(false)){ if (areElsVisible.includes(false)) {
return false; return false;
} }
} }