Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix operators eslint issues #4388

Merged
merged 6 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/packages/operators/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"rules": {
"react-hooks/rules-of-hooks": "off"
}
}
1 change: 1 addition & 0 deletions app/packages/operators/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* global module */
module.exports = {
presets: [
["@babel/preset-env", { targets: { node: "current" } }],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ function RequestExecutor({ queueItem, onSuccess, onError }) {
callback: queueItem.callback,
...(queueItem?.request?.options || {}),
});
}, []);
}, [
executor,
ritch marked this conversation as resolved.
Show resolved Hide resolved
queueItem.callback,
queueItem.request?.options,
queueItem.request.params,
]);

return null;
}
27 changes: 14 additions & 13 deletions app/packages/operators/src/built-in-operators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class ReloadDataset extends Operator {
label: "Reload the dataset",
});
}
async execute({ state }: ExecutionContext) {
async execute() {
// TODO - improve this... this is a temp. workaround for the fact that
// there is no way to force reload just the dataset
window.location.reload();
Expand Down Expand Up @@ -109,7 +109,7 @@ class OpenPanel extends Operator {
unlisted: true,
});
}
async resolveInput(ctx: ExecutionContext): Promise<types.Property> {
async resolveInput(): Promise<types.Property> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactor to simplify the resolveInput method in OpenPanel.

The method resolveInput could be refactored for better readability and maintainability. Consider extracting parts of the code into smaller, more focused functions or using a builder pattern for creating inputs.

const inputs = new types.Object();
inputs.str("name", {
view: new types.AutocompleteView({
Expand Down Expand Up @@ -146,6 +146,8 @@ class OpenPanel extends Operator {
if (node.hasChildren()) {
return this.findFirstPanelContainer(node.firstChild());
}

return null;
ritch marked this conversation as resolved.
Show resolved Hide resolved
}
async execute({ hooks, params }: ExecutionContext) {
const { spaces, openedPanels, availablePanels } = hooks;
Expand Down Expand Up @@ -207,7 +209,7 @@ class ClosePanel extends Operator {
unlisted: true,
});
}
async resolveInput(ctx: ExecutionContext): Promise<types.Property> {
async resolveInput(): Promise<types.Property> {
const inputs = new types.Object();
inputs.str("name", {
view: new types.AutocompleteView({
Expand Down Expand Up @@ -310,7 +312,7 @@ class OpenDataset extends Operator {
unlisted: true,
});
}
async resolveInput(ctx: ExecutionContext): Promise<types.Property> {
async resolveInput(): Promise<types.Property> {
const inputs = new types.Object();
inputs.str("dataset", { label: "Dataset name", required: true });
return new types.Property(inputs);
Expand Down Expand Up @@ -358,7 +360,7 @@ class ClearAllStages extends Operator {
label: "Clear all selections, filters, and view",
});
}
useHooks(): {} {
useHooks(): object {
return {
resetExtended: fos.useResetExtendedSelection(),
};
Expand Down Expand Up @@ -412,7 +414,7 @@ class ConvertExtendedSelectionToSelectedSamples extends Operator {
label: "Convert extended selection to selected samples",
});
}
useHooks(): {} {
useHooks(): object {
return {
resetExtended: fos.useResetExtendedSelection(),
};
Expand All @@ -437,7 +439,7 @@ class SetSelectedSamples extends Operator {
unlisted: true,
});
}
useHooks(): {} {
useHooks(): object {
return {
setSelected: fos.useSetSelected(),
};
Expand All @@ -459,7 +461,7 @@ class SetView extends Operator {
unlisted: true,
});
}
useHooks(ctx: ExecutionContext): {} {
useHooks(): {} {
const refetchableSavedViews = useRefetchableSavedViews();

return {
Expand All @@ -468,7 +470,7 @@ class SetView extends Operator {
setViewName: useSetRecoilState(fos.viewName),
};
}
async resolveInput(ctx: ExecutionContext): Promise<types.Property> {
async resolveInput(): Promise<types.Property> {
const inputs = new types.Object();
inputs.list("view", new types.Object(), { view: new types.HiddenView({}) });
inputs.str("name", { label: "Name or slug of a saved view" });
Expand Down Expand Up @@ -507,7 +509,7 @@ class ShowSamples extends Operator {
unlisted: true,
});
}
async resolveInput(ctx: ExecutionContext): Promise<types.Property> {
async resolveInput(): Promise<types.Property> {
const inputs = new types.Object();
inputs.list("samples", new types.String(), {
label: "Samples",
Expand All @@ -519,7 +521,7 @@ class ShowSamples extends Operator {
});
return new types.Property(inputs);
}
useHooks(ctx: ExecutionContext): {} {
useHooks(): {} {
return {
setView: fos.useSetView(),
};
Expand Down Expand Up @@ -573,11 +575,10 @@ class ConsoleLog extends Operator {
unlisted: true,
});
}
async resolveInput(ctx: ExecutionContext): Promise<types.Property> {
async resolveInput(): Promise<types.Property> {
const inputs = new types.Object();
inputs.defineProperty("message", new types.String(), {
label: "Message",
required: true,
});
return new types.Property(inputs);
}
Expand Down
7 changes: 6 additions & 1 deletion app/packages/operators/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ export class Property {
* set to `true`.
* view: view options for the property. Refer to {@link View}
*/
constructor(type: ANY_TYPE, options?) {
constructor(type: ANY_TYPE, options?: PropertyOptions) {
this.type = type;
this.defaultValue = options?.defaultValue || options?.default;
this.required = options?.required;
Expand Down Expand Up @@ -1246,6 +1246,11 @@ type PropertyOptions = {
label?: string;
description?: string;
view?: View;
required?: boolean;
defaultValue?: any;
default?: any;
invalid?: boolean;
errorMessage?: string;
};
type ObjectProperties = Map<string, Property>;

Expand Down