chore(core): lint

This commit is contained in:
karishmas6
2024-07-31 05:37:57 +05:30
parent 67c4bbaf3e
commit 014f6e6bec

View File

@@ -8,7 +8,7 @@ import { operators } from './types/logic';
* Class for static processing the workflow files/objects. * Class for static processing the workflow files/objects.
*/ */
export default class Preprocessor { export default class Preprocessor {
static validateWorkflow(workflow: WorkflowFile) : any { static validateWorkflow(workflow: WorkflowFile): any {
const regex = Joi.object({ const regex = Joi.object({
$regex: Joi.string().required(), $regex: Joi.string().required(),
}); });
@@ -51,8 +51,8 @@ export default class Preprocessor {
* @param {WorkflowFile} workflow The given workflow * @param {WorkflowFile} workflow The given workflow
* @returns {String[]} List of parameters' names. * @returns {String[]} List of parameters' names.
*/ */
static getParams(workflow: WorkflowFile) : string[] { static getParams(workflow: WorkflowFile): string[] {
const getParamsRecurse = (object : any) : string[] => { const getParamsRecurse = (object: any): string[] => {
if (typeof object === 'object') { if (typeof object === 'object') {
// Recursion base case // Recursion base case
if (object.$param) { if (object.$param) {
@@ -61,7 +61,7 @@ export default class Preprocessor {
// Recursion general case // Recursion general case
return Object.values(object) return Object.values(object)
.reduce((p: string[], v : any) : string[] => [...p, ...getParamsRecurse(v)], []); .reduce((p: string[], v: any): string[] => [...p, ...getParamsRecurse(v)], []);
} }
return []; return [];
}; };
@@ -74,12 +74,12 @@ export default class Preprocessor {
* field in WHERE clauses so far) * field in WHERE clauses so far)
*/ */
// TODO : add recursive selector search (also in click/fill etc. events?) // TODO : add recursive selector search (also in click/fill etc. events?)
static extractSelectors(workflow: Workflow) : SelectorArray { static extractSelectors(workflow: Workflow): SelectorArray {
/** /**
* Given a Where condition, this function extracts * Given a Where condition, this function extracts
* all the existing selectors from it (recursively). * all the existing selectors from it (recursively).
*/ */
const selectorsFromCondition = (where: Where) : SelectorArray => { const selectorsFromCondition = (where: Where): SelectorArray => {
// the `selectors` field is either on the top level // the `selectors` field is either on the top level
let out = where.selectors ?? []; let out = where.selectors ?? [];
if (!Array.isArray(out)) { if (!Array.isArray(out)) {
@@ -112,7 +112,7 @@ export default class Preprocessor {
* with the defined value. * with the defined value.
* @returns {Workflow} Copy of the given workflow, modified (the initial workflow is left untouched). * @returns {Workflow} Copy of the given workflow, modified (the initial workflow is left untouched).
*/ */
static initWorkflow(workflow: Workflow, params?: ParamType) : Workflow { static initWorkflow(workflow: Workflow, params?: ParamType): Workflow {
const paramNames = this.getParams({ workflow }); const paramNames = this.getParams({ workflow });
if (Object.keys(params ?? {}).sort().join(',') !== paramNames.sort().join(',')) { if (Object.keys(params ?? {}).sort().join(',') !== paramNames.sort().join(',')) {
@@ -133,7 +133,7 @@ export default class Preprocessor {
object: unknown, object: unknown,
k: string, k: string,
f: (value: string) => unknown, f: (value: string) => unknown,
) : unknown => { ): unknown => {
if (!object || typeof object !== 'object') { if (!object || typeof object !== 'object') {
return object; return object;
} }
@@ -174,6 +174,6 @@ export default class Preprocessor {
(regex) => new RegExp(regex), (regex) => new RegExp(regex),
); );
return <Workflow> workflowCopy; return <Workflow>workflowCopy;
} }
} }