refactor(core): Remove linting exceptions in nodes-base (#4794)

*  enabled array-type

*  await-thenable on

*  ban-types on

*  default-param-last on

*  dot-notation on

*  member-delimiter-style on

*  no-duplicate-imports on

*  no-empty-interface on

*  no-floating-promises on

*  no-for-in-array on

*  no-invalid-void-type on

*  no-loop-func on

*  no-shadow on

*  ban-ts-comment re enabled

*  @typescript-eslint/lines-between-class-members on

* address my own comment

* @typescript-eslint/return-await on

* @typescript-eslint/promise-function-async on

* @typescript-eslint/no-unnecessary-boolean-literal-compare on

* @typescript-eslint/no-unnecessary-type-assertion on

* prefer-const on

* @typescript-eslint/prefer-optional-chain on

Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
This commit is contained in:
Michael Kret
2022-12-02 22:54:28 +02:00
committed by GitHub
parent 8101c05d6f
commit 61e26804ba
796 changed files with 3735 additions and 2847 deletions

View File

@@ -80,6 +80,7 @@ export function generateReturning(pgp: pgPromise.IMain<{}, pg.IClient>, returnin
* @param {input[]} input The Node's input data
*/
export async function pgQuery(
// eslint-disable-next-line @typescript-eslint/ban-types
getNodeParam: Function,
pgp: pgPromise.IMain<{}, pg.IClient>,
db: pgPromise.IDatabase<{}, pg.IClient>,
@@ -118,7 +119,7 @@ export async function pgQuery(
await t.any(allQueries[i].query, allQueries[i].values),
);
} catch (err) {
if (continueOnFail === false) throw err;
if (!continueOnFail) throw err;
result.push({
...items[i].json,
code: (err as JsonObject).code,
@@ -139,7 +140,7 @@ export async function pgQuery(
await t.any(allQueries[i].query, allQueries[i].values),
);
} catch (err) {
if (continueOnFail === false) throw err;
if (!continueOnFail) throw err;
result.push({
...items[i].json,
code: (err as JsonObject).code,
@@ -201,7 +202,7 @@ export async function pgQueryV2(
);
result.push(...executionData);
} catch (err) {
if (continueOnFail === false) throw err;
if (!continueOnFail) throw err;
result.push({
json: { ...items[i].json },
code: (err as JsonObject).code,
@@ -225,7 +226,7 @@ export async function pgQueryV2(
);
result.push(...executionData);
} catch (err) {
if (continueOnFail === false) throw err;
if (!continueOnFail) throw err;
result.push({
json: { ...items[i].json },
code: (err as JsonObject).code,
@@ -249,6 +250,7 @@ export async function pgQueryV2(
* @param {INodeExecutionData[]} items The items to be inserted
*/
export async function pgInsert(
// eslint-disable-next-line @typescript-eslint/ban-types
getNodeParam: Function,
pgp: pgPromise.IMain<{}, pg.IClient>,
db: pgPromise.IDatabase<{}, pg.IClient>,
@@ -289,7 +291,7 @@ export async function pgInsert(
try {
result.push(await t.one(pgp.helpers.insert(itemCopy, cs) + returning));
} catch (err) {
if (continueOnFail === false) throw err;
if (!continueOnFail) throw err;
result.push({
...itemCopy,
code: (err as JsonObject).code,
@@ -311,7 +313,7 @@ export async function pgInsert(
result.push(insertResult);
}
} catch (err) {
if (continueOnFail === false) {
if (!continueOnFail) {
throw err;
}
result.push({
@@ -389,7 +391,7 @@ export async function pgInsertV2(
}),
);
} catch (err) {
if (continueOnFail === false) throw err;
if (!continueOnFail) throw err;
result.push({
json: { ...itemCopy },
code: (err as JsonObject).code,
@@ -416,7 +418,7 @@ export async function pgInsertV2(
result.push(...executionData);
}
} catch (err) {
if (continueOnFail === false) {
if (!continueOnFail) {
throw err;
}
result.push({
@@ -443,6 +445,7 @@ export async function pgInsertV2(
* @param {INodeExecutionData[]} items The items to be updated
*/
export async function pgUpdate(
// eslint-disable-next-line @typescript-eslint/ban-types
getNodeParam: Function,
pgp: pgPromise.IMain<{}, pg.IClient>,
db: pgPromise.IDatabase<{}, pg.IClient>,
@@ -491,19 +494,17 @@ export async function pgUpdate(
pgp.helpers.update(updateItems, cs) +
' WHERE ' +
updateKeys
.map((updateKey) => {
const key = pgp.as.name(updateKey.name);
.map((entry) => {
const key = pgp.as.name(entry.name);
return 'v.' + key + ' = t.' + key;
})
.join(' AND ') +
returning;
return await db.any(query);
return db.any(query);
} else {
const where =
' WHERE ' +
updateKeys
.map((updateKey) => pgp.as.name(updateKey.name) + ' = ${' + updateKey.prop + '}')
.join(' AND ');
updateKeys.map((entry) => pgp.as.name(entry.name) + ' = ${' + entry.prop + '}').join(' AND ');
if (mode === 'transaction') {
return db.tx(async (t) => {
const result: IDataObject[] = [];
@@ -517,7 +518,7 @@ export async function pgUpdate(
),
);
} catch (err) {
if (continueOnFail === false) throw err;
if (!continueOnFail) throw err;
result.push({
...itemCopy,
code: (err as JsonObject).code,
@@ -541,7 +542,7 @@ export async function pgUpdate(
),
);
} catch (err) {
if (continueOnFail === false) throw err;
if (!continueOnFail) throw err;
result.push({
...itemCopy,
code: (err as JsonObject).code,
@@ -613,8 +614,8 @@ export async function pgUpdateV2(
pgp.helpers.update(updateItems, cs) +
' WHERE ' +
updateKeys
.map((updateKey) => {
const key = pgp.as.name(updateKey.name);
.map((entry) => {
const key = pgp.as.name(entry.name);
return 'v.' + key + ' = t.' + key;
})
.join(' AND ') +
@@ -624,9 +625,7 @@ export async function pgUpdateV2(
} else {
const where =
' WHERE ' +
updateKeys
.map((updateKey) => pgp.as.name(updateKey.name) + ' = ${' + updateKey.prop + '}')
.join(' AND ');
updateKeys.map((entry) => pgp.as.name(entry.name) + ' = ${' + entry.prop + '}').join(' AND ');
if (mode === 'transaction') {
return db.tx(async (t) => {
const result: IDataObject[] = [];
@@ -642,7 +641,7 @@ export async function pgUpdateV2(
);
result.push(...executionData);
} catch (err) {
if (continueOnFail === false) throw err;
if (!continueOnFail) throw err;
result.push({
...itemCopy,
code: (err as JsonObject).code,
@@ -668,7 +667,7 @@ export async function pgUpdateV2(
);
result.push(...executionData);
} catch (err) {
if (continueOnFail === false) throw err;
if (!continueOnFail) throw err;
result.push({
json: { ...items[i].json },
code: (err as JsonObject).code,

View File

@@ -277,6 +277,7 @@ export class Postgres implements INodeType {
},
],
};
methods = {
credentialTest: {
async postgresConnectionTest(
@@ -305,7 +306,7 @@ export class Postgres implements INodeType {
const db = pgp(config);
await db.connect();
await pgp.end();
pgp.end();
} catch (error) {
return {
status: 'Error',
@@ -394,7 +395,7 @@ export class Postgres implements INodeType {
returnItems = this.helpers.returnJsonArray(updateItems);
} else {
await pgp.end();
pgp.end();
throw new NodeOperationError(
this.getNode(),
`The operation "${operation}" is not supported!`,
@@ -402,7 +403,7 @@ export class Postgres implements INodeType {
}
// Close the connection
await pgp.end();
pgp.end();
return this.prepareOutputData(returnItems);
}