Skip to content

Commit

Permalink
Autofix lint issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
travist committed Nov 27, 2024
1 parent a581a3e commit f945a77
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ describe('validateAvailableItems', function () {
baz: true,
biz: false,
new: true,
test: false
test: false,
},
};
const context = generateProcessorContext(component, data);
Expand All @@ -631,16 +631,15 @@ describe('validateAvailableItems', function () {
component: {
one: true,
two: false,
three: true
three: true,
},
};
const context = generateProcessorContext(component, data);

context.fetch = () => {
return Promise.resolve({
ok: true,
json: () =>
Promise.resolve(['one', 'two', 'three']),
json: () => Promise.resolve(['one', 'two', 'three']),
});
};
const result = await validateAvailableItems(context);
Expand All @@ -663,16 +662,15 @@ describe('validateAvailableItems', function () {
two: false,
three: true,
four: true,
five: false
five: false,
},
};
const context = generateProcessorContext(component, data);

context.fetch = () => {
return Promise.resolve({
ok: true,
json: () =>
Promise.resolve(['one', 'two', 'three']),
json: () => Promise.resolve(['one', 'two', 'three']),
});
};
const result = await validateAvailableItems(context);
Expand Down
18 changes: 5 additions & 13 deletions src/process/validation/rules/validateAvailableItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@ function isValidateableSelectComponent(component: any): component is SelectCompo
}

function isValidateableSelectBoxesComponent(component: any): component is SelectBoxesComponent {
return (
component &&
!!component.validate?.onlyAvailableItems &&
component.type === 'selectboxes'
);
return component && !!component.validate?.onlyAvailableItems && component.type === 'selectboxes';
}

function mapDynamicValues<T extends Record<string, any>>(component: SelectComponent, values: T[]) {
Expand Down Expand Up @@ -279,11 +275,9 @@ export const validateAvailableItems: RuleFn = async (context: ValidationContext)
const values =
component.dataSrc === 'url'
? await getAvailableDynamicValues(component, context)
: component.values.map(val => val.value);
: component.values.map((val) => val.value);
if (values) {
return difference(Object.keys(value), values).length
? error
: null;
return difference(Object.keys(value), values).length ? error : null;
}
}
} catch (err: any) {
Expand Down Expand Up @@ -340,11 +334,9 @@ export const validateAvailableItemsSync: RuleFnSync = (context: ValidationContex
return null;
}

const values = component.values.map(val => val.value);
const values = component.values.map((val) => val.value);
if (values) {
return difference(Object.keys(value), values).length
? error
: null;
return difference(Object.keys(value), values).length ? error : null;
}
}
} catch (err: any) {
Expand Down

0 comments on commit f945a77

Please sign in to comment.