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

refactor(editor): Enable @typescript-eslint/no-base-to-string lint rule, fix errors (no-changelog) #9783

Merged
merged 3 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/editor-ui/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ module.exports = {
'@typescript-eslint/restrict-plus-operands': 'warn',
'@typescript-eslint/ban-ts-comment': ['warn', { 'ts-ignore': true }],
'@typescript-eslint/no-redundant-type-constituents': 'warn',
'@typescript-eslint/no-base-to-string': 'warn',
'@typescript-eslint/no-unsafe-enum-comparison': 'warn',
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -887,8 +887,9 @@ export default defineComponent({
this.testedSuccessfully = false;
}

const usesExternalSecrets = Object.entries(credentialDetails.data || {}).some(([, value]) =>
/=.*\{\{[^}]*\$secrets\.[^}]+}}.*/.test(`${value}`),
const usesExternalSecrets = Object.entries(credentialDetails.data || {}).some(
([, value]) =>
typeof value !== 'object' && /=.*\{\{[^}]*\$secrets\.[^}]+}}.*/.test(`${value}`),
);

const trackProperties: ITelemetryTrackProperties = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,11 @@ const outputTypeParsers: {
} else if (content.id.includes('SystemMessage')) {
message = `**System Message:** ${message}`;
}
if (execData.action && execData.action !== 'getMessages') {
if (
Copy link
Member

Choose a reason for hiding this comment

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

this is good enough as a short-term solution, but in the long-term we really need to use a lot less of IDataObject. If execData was to use proper typing, we wouldn't need hacky checks like these.

execData.action &&
typeof execData.action !== 'object' &&
execData.action !== 'getMessages'
) {
message = `## Action: ${execData.action}\n\n${message}`;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ export default defineComponent({
onModalClose() {
if (!this.hasOnceBeenSaved) {
this.workflowsStore.removeNode(this.node);
if (this.nodeParameters.id) {
if (this.nodeParameters.id && typeof this.nodeParameters.id !== 'object') {
this.logStreamingStore.removeDestination(this.nodeParameters.id.toString());
}
}
Expand All @@ -480,7 +480,9 @@ export default defineComponent({
this.uiStore.stateIsDirty = false;

const destinationType = (
this.nodeParameters.__type ? `${this.nodeParameters.__type}` : 'unknown'
this.nodeParameters.__type && typeof this.nodeParameters.__type !== 'object'
? `${this.nodeParameters.__type}`
: 'unknown'
)
.replace('$$MessageEventBusDestination', '')
.toLowerCase();
Expand Down
3 changes: 2 additions & 1 deletion packages/editor-ui/src/composables/useRunWorkflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,8 @@ export function useRunWorkflow(useRunWorkflowOpts: { router: ReturnType<typeof u
if (!showForm) continue;

const { webhookSuffix } = (node.parameters.options ?? {}) as IDataObject;
const suffix = webhookSuffix ? `/${webhookSuffix}` : '';
const suffix =
webhookSuffix && typeof webhookSuffix !== 'object' ? `/${webhookSuffix}` : '';
testUrl = `${rootStore.getFormWaitingUrl}/${runWorkflowApiResponse.executionId}${suffix}`;
}

Expand Down
4 changes: 3 additions & 1 deletion packages/editor-ui/src/utils/mappingUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ export function getMappedResult(
} else if (typeof prevValue === 'string' && isExpression(prevValue) && prevValue.length > 1) {
return `${prevValue} ${newParamValue}`;
} else if (prevValue && ['string', 'json'].includes(parameter.type)) {
return prevValue === '=' ? `=${newParamValue}` : `=${prevValue} ${newParamValue}`;
return prevValue === '=' || typeof prevValue === 'object'
? `=${newParamValue}`
: `=${prevValue} ${newParamValue}`;
}

return `=${newParamValue}`;
Expand Down
Loading