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(core): Revert rule @typescript-eslint/prefer-nullish-coalescing #5199

Merged
merged 3 commits into from Jan 19, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/nodes-base/.eslintrc.js
Expand Up @@ -29,6 +29,7 @@ module.exports = {
'@typescript-eslint/restrict-template-expressions': 'off', //1152 errors, better to fix in separate PR
'@typescript-eslint/unbound-method': 'off',
'@typescript-eslint/ban-ts-comment': ['warn', { 'ts-ignore': true }],
'@typescript-eslint/prefer-nullish-coalescing': 'off',
},

overrides: [
Expand Down
Expand Up @@ -32,7 +32,7 @@ export async function acuitySchedulingApiRequest(
method,
qs,
body,
uri: uri ?? `https://acuityscheduling.com/api/v1${resource}`,
uri: uri || `https://acuityscheduling.com/api/v1${resource}`,
json: true,
};

Expand Down
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/Affinity/GenericFunctions.ts
Expand Up @@ -27,7 +27,7 @@ export async function affinityApiRequest(
method,
body,
qs: query,
uri: uri ?? `${endpoint}${resource}`,
uri: uri || `${endpoint}${resource}`,
json: true,
};
if (!Object.keys(body).length) {
Expand Down
4 changes: 2 additions & 2 deletions packages/nodes-base/nodes/AgileCrm/GenericFunctions.ts
Expand Up @@ -33,7 +33,7 @@ export async function agileCrmApiRequest(
password: credentials.apiKey as string,
},
qs: query,
uri: uri ?? `https://${credentials.subdomain}.agilecrm.com/dev/${endpoint}`,
uri: uri || `https://${credentials.subdomain}.agilecrm.com/dev/${endpoint}`,
json: true,
};

Expand Down Expand Up @@ -113,7 +113,7 @@ export async function agileCrmApiRequestUpdate(
username: credentials.email as string,
password: credentials.apiKey as string,
},
uri: uri ?? baseUri,
uri: uri || baseUri,
json: true,
};

Expand Down
4 changes: 2 additions & 2 deletions packages/nodes-base/nodes/Airtable/GenericFunctions.ts
Expand Up @@ -34,7 +34,7 @@ export async function apiRequest(
uri?: string,
option: IDataObject = {},
): Promise<any> {
query = query ?? {};
query = query || {};

// For some reason for some endpoints the bearer auth does not work
// and it returns 404 like for the /meta request. So we always send
Expand All @@ -46,7 +46,7 @@ export async function apiRequest(
method,
body,
qs: query,
uri: uri ?? `https://api.airtable.com/v0/${endpoint}`,
uri: uri || `https://api.airtable.com/v0/${endpoint}`,
useQuerystring: false,
json: true,
};
Expand Down
4 changes: 2 additions & 2 deletions packages/nodes-base/nodes/ApiTemplateIo/ApiTemplateIo.node.ts
Expand Up @@ -441,7 +441,7 @@ export class ApiTemplateIo implements INodeType {
const fileName = responseData.download_url.split('/').pop();
const binaryData = await this.helpers.prepareBinaryData(
data,
options.fileName ?? fileName,
options.fileName || fileName,
);
responseData = {
json: responseData,
Expand Down Expand Up @@ -525,7 +525,7 @@ export class ApiTemplateIo implements INodeType {
const fileName = responseData.download_url.split('/').pop();
const binaryData = await this.helpers.prepareBinaryData(
imageData,
options.fileName ?? fileName,
options.fileName || fileName,
);
responseData = {
json: responseData,
Expand Down
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/Asana/GenericFunctions.ts
Expand Up @@ -28,7 +28,7 @@ export async function asanaApiRequest(
method,
body: { data: body },
qs: query,
url: uri ?? `https://app.asana.com/api/1.0${endpoint}`,
url: uri || `https://app.asana.com/api/1.0${endpoint}`,
json: true,
};

Expand Down
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/Autopilot/GenericFunctions.ts
Expand Up @@ -28,7 +28,7 @@ export async function autopilotApiRequest(
method,
body,
qs: query,
uri: uri ?? `${endpoint}${resource}`,
uri: uri || `${endpoint}${resource}`,
json: true,
};
if (!Object.keys(body).length) {
Expand Down
Expand Up @@ -44,7 +44,7 @@ export async function awsApiRequest(
const endpoint = new URL(getEndpointForService(service, credentials) + path);

// Sign AWS API request with the user credentials
const signOpts = { headers: headers ?? {}, host: endpoint.host, method, path, body } as Request;
const signOpts = { headers: headers || {}, host: endpoint.host, method, path, body } as Request;
const securityHeaders = {
accessKeyId: `${credentials.accessKeyId}`.trim(),
secretAccessKey: `${credentials.secretAccessKey}`.trim(),
Expand Down
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/Bannerbear/GenericFunctions.ts
Expand Up @@ -26,7 +26,7 @@ export async function bannerbearApiRequest(
method,
body,
qs: query,
uri: uri ?? `https://api.bannerbear.com/v2${resource}`,
uri: uri || `https://api.bannerbear.com/v2${resource}`,
json: true,
};
if (!Object.keys(body).length) {
Expand Down
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/Bitbucket/GenericFunctions.ts
Expand Up @@ -26,7 +26,7 @@ export async function bitbucketApiRequest(
},
qs,
body,
uri: uri ?? `https://api.bitbucket.org/2.0${resource}`,
uri: uri || `https://api.bitbucket.org/2.0${resource}`,
json: true,
};
options = Object.assign({}, options, option);
Expand Down
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/Bitly/GenericFunctions.ts
Expand Up @@ -25,7 +25,7 @@ export async function bitlyApiRequest(
method,
qs,
body,
uri: uri ?? `https://api-ssl.bitly.com/v4${resource}`,
uri: uri || `https://api-ssl.bitly.com/v4${resource}`,
json: true,
};
options = Object.assign({}, options, option);
Expand Down
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/Bitwarden/GenericFunctions.ts
Expand Up @@ -138,7 +138,7 @@ export async function loadResource(this: ILoadOptionsFunctions, resource: string

data.forEach(({ id, name, externalId }: { id: string; name: string; externalId?: string }) => {
returnData.push({
name: externalId ?? name ?? id,
name: externalId || name || id,
value: id,
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/Box/GenericFunctions.ts
Expand Up @@ -26,7 +26,7 @@ export async function boxApiRequest(
method,
body,
qs,
uri: uri ?? `https://api.box.com/2.0${resource}`,
uri: uri || `https://api.box.com/2.0${resource}`,
json: true,
};
options = Object.assign({}, options, option);
Expand Down
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/Brandfetch/GenericFunctions.ts
Expand Up @@ -28,7 +28,7 @@ export async function brandfetchApiRequest(
method,
qs,
body,
uri: uri ?? `https://api.brandfetch.io/v1${resource}`,
uri: uri || `https://api.brandfetch.io/v1${resource}`,
json: true,
};

Expand Down
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/Calendly/GenericFunctions.ts
Expand Up @@ -46,7 +46,7 @@ export async function calendlyApiRequest(
method,
body,
qs: query,
uri: uri ?? `${endpoint}${resource}`,
uri: uri || `${endpoint}${resource}`,
json: true,
};

Expand Down
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/CircleCi/GenericFunctions.ts
Expand Up @@ -28,7 +28,7 @@ export async function circleciApiRequest(
method,
qs,
body,
uri: uri ?? `https://circleci.com/api/v2${resource}`,
uri: uri || `https://circleci.com/api/v2${resource}`,
json: true,
};
options = Object.assign({}, options, option);
Expand Down
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/Cisco/Webex/GenericFunctions.ts
Expand Up @@ -28,7 +28,7 @@ export async function webexApiRequest(
method,
body,
qs,
uri: uri ?? `https://webexapis.com/v1${resource}`,
uri: uri || `https://webexapis.com/v1${resource}`,
json: true,
};
try {
Expand Down
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/Citrix/ADC/GenericFunctions.ts
Expand Up @@ -28,7 +28,7 @@ export async function citrixADCApiRequest(
method,
body,
qs,
uri: uri ?? `${url.replace(new RegExp('/$'), '')}/nitro/v1${resource}`,
uri: uri || `${url.replace(new RegExp('/$'), '')}/nitro/v1${resource}`,
json: true,
};

Expand Down
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/Clearbit/GenericFunctions.ts
Expand Up @@ -26,7 +26,7 @@ export async function clearbitApiRequest(
method,
qs,
body,
uri: uri ?? `https://${api}.clearbit.com${resource}`,
uri: uri || `https://${api}.clearbit.com${resource}`,
json: true,
};
options = Object.assign({}, options, option);
Expand Down
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/ClickUp/GenericFunctions.ts
Expand Up @@ -32,7 +32,7 @@ export async function clickupApiRequest(
method,
qs,
body,
uri: uri ?? `https://api.clickup.com/api/v2${resource}`,
uri: uri || `https://api.clickup.com/api/v2${resource}`,
json: true,
};

Expand Down
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/Cockpit/GenericFunctions.ts
Expand Up @@ -22,7 +22,7 @@ export async function cockpitApiRequest(
token: credentials.accessToken,
},
body,
uri: uri ?? `${credentials.url}/api${resource}`,
uri: uri || `${credentials.url}/api${resource}`,
json: true,
};

Expand Down
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/Coda/GenericFunctions.ts
Expand Up @@ -19,7 +19,7 @@ export async function codaApiRequest(
method,
qs,
body,
uri: uri ?? `https://coda.io/apis/v1${resource}`,
uri: uri || `https://coda.io/apis/v1${resource}`,
json: true,
};
options = Object.assign({}, options, option);
Expand Down
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/CoinGecko/GenericFunctions.ts
Expand Up @@ -22,7 +22,7 @@ export async function coinGeckoApiRequest(
method,
body,
qs,
uri: uri ?? `https://api.coingecko.com/api/v3${endpoint}`,
uri: uri || `https://api.coingecko.com/api/v3${endpoint}`,
json: true,
};

Expand Down
10 changes: 5 additions & 5 deletions packages/nodes-base/nodes/CompareDatasets/GenericFunctions.ts
Expand Up @@ -47,14 +47,14 @@ function compareItems(
differentKeys.forEach((key) => {
switch (resolve) {
case 'preferInput1':
different[key] = item1.json[key] ?? null;
different[key] = item1.json[key] || null;
break;
case 'preferInput2':
different[key] = item2.json[key] ?? null;
different[key] = item2.json[key] || null;
break;
default:
const input1 = item1.json[key] ?? null;
const input2 = item2.json[key] ?? null;
const input1 = item1.json[key] || null;
const input2 = item2.json[key] || null;
if (skipFields.includes(key)) {
skipped[key] = { input1, input2 };
} else {
Expand Down Expand Up @@ -89,7 +89,7 @@ function combineItems(
if (disableDotNotation) {
entry.json[field] = match.json[field];
} else {
const value = get(match.json, field) ?? null;
const value = get(match.json, field) || null;
set(entry, `json.${field}`, value);
}
});
Expand Down
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/Contentful/GenericFunctions.ts
Expand Up @@ -22,7 +22,7 @@ export async function contentfulApiRequest(
method,
qs,
body,
uri: uri ?? `https://${isPreview ? 'preview' : 'cdn'}.contentful.com${resource}`,
uri: uri || `https://${isPreview ? 'preview' : 'cdn'}.contentful.com${resource}`,
json: true,
};

Expand Down
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/ConvertKit/GenericFunctions.ts
Expand Up @@ -23,7 +23,7 @@ export async function convertKitApiRequest(
method,
qs,
body,
uri: uri ?? `https://api.convertkit.com/v3${endpoint}`,
uri: uri || `https://api.convertkit.com/v3${endpoint}`,
json: true,
};

Expand Down
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/Cortex/GenericFunctions.ts
Expand Up @@ -27,7 +27,7 @@ export async function cortexApiRequest(
headers: {},
method,
qs: query,
uri: uri ?? `${credentials.host}/api${resource}`,
uri: uri || `${credentials.host}/api${resource}`,
body,
json: true,
};
Expand Down
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/DateTime/DateTime.node.ts
Expand Up @@ -430,7 +430,7 @@ export class DateTime implements INodeType {
newDate = moment.unix(currentDate as unknown as number);
} else {
if (options.fromTimezone || options.toTimezone) {
const fromTimezone = options.fromTimezone ?? workflowTimezone;
const fromTimezone = options.fromTimezone || workflowTimezone;
if (options.fromFormat) {
newDate = moment.tz(
currentDate,
Expand Down
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/DeepL/GenericFunctions.ts
Expand Up @@ -25,7 +25,7 @@ export async function deepLApiRequest(
method,
form: body,
qs,
uri: uri ?? `${credentials.apiPlan === 'pro' ? proApiEndpoint : freeApiEndpoint}${resource}`,
uri: uri || `${credentials.apiPlan === 'pro' ? proApiEndpoint : freeApiEndpoint}${resource}`,
json: true,
};

Expand Down
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/Demio/GenericFunctions.ts
Expand Up @@ -29,7 +29,7 @@ export async function demioApiRequest(
method,
qs,
body,
uri: uri ?? `https://my.demio.com/api/v1${resource}`,
uri: uri || `https://my.demio.com/api/v1${resource}`,
json: true,
};

Expand Down
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/Dhl/GenericFunctions.ts
Expand Up @@ -33,7 +33,7 @@ export async function dhlApiRequest(
method,
qs,
body,
uri: uri ?? `https://api-eu.dhl.com${path}`,
uri: uri || `https://api-eu.dhl.com${path}`,
json: true,
};
options = Object.assign({}, options, option);
Expand Down
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/Drift/GenericFunctions.ts
Expand Up @@ -19,7 +19,7 @@ export async function driftApiRequest(
method,
body,
qs: query,
uri: uri ?? `https://driftapi.com${resource}`,
uri: uri || `https://driftapi.com${resource}`,
json: true,
};

Expand Down
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/ERPNext/GenericFunctions.ts
Expand Up @@ -30,7 +30,7 @@ export async function erpNextApiRequest(
method,
body,
qs: query,
uri: uri ?? `${baseUrl}${resource}`,
uri: uri || `${baseUrl}${resource}`,
json: true,
rejectUnauthorized: !credentials.allowUnauthorizedCerts,
};
Expand Down
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/EditImage/EditImage.node.ts
Expand Up @@ -1239,7 +1239,7 @@ export class EditImage implements INodeType {
// Combine the lines to a single string
const renderText = lines.join('\n');

const font = options.font ?? operationData.font;
const font = options.font || operationData.font;

if (font && font !== 'default') {
gmInstance = gmInstance!.font(font as string);
Expand Down
Expand Up @@ -447,7 +447,7 @@ export class ElasticSecurity implements INodeType {
const body = {
comment: this.getNodeParameter('comment', i),
type: 'user',
owner: additionalFields.owner ?? 'securitySolution',
owner: additionalFields.owner || 'securitySolution',
} as IDataObject;

const caseId = this.getNodeParameter('caseId', i);
Expand Down
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/EmailSend/EmailSend.node.ts
Expand Up @@ -193,7 +193,7 @@ export class EmailSend implements INodeType {
continue;
}
attachments.push({
filename: item.binary[propertyName].fileName ?? 'unknown',
filename: item.binary[propertyName].fileName || 'unknown',
content: await this.helpers.getBinaryDataBuffer(itemIndex, propertyName),
});
}
Expand Down
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/Eventbrite/GenericFunctions.ts
Expand Up @@ -30,7 +30,7 @@ export async function eventbriteApiRequest(
method,
qs,
body,
uri: uri ?? `https://www.eventbriteapi.com/v3${resource}`,
uri: uri || `https://www.eventbriteapi.com/v3${resource}`,
json: true,
};
options = Object.assign({}, options, option);
Expand Down
Expand Up @@ -38,7 +38,7 @@ async function execPromise(command: string): Promise<IExecReturnData> {

resolve(returnData);
}).on('exit', (code) => {
returnData.exitCode = code ?? 0;
returnData.exitCode = code || 0;
});
});
}
Expand Down