refactor: Apply more eslint-plugin-n8n-nodes-base rules (#3624)

* ⬆️ Upgrade `eslint-plugin-n8n-nodes-base`

* 📦 Update `package-lock.json`

* 🔧 Adjust renamed filesystem rules

* ✏️ Alphabetize ruleset

*  Categorize overrides

*  Set renamings in lint exceptions

*  Run baseline `lintfix`

*  Update linting scripts

* 👕 Apply `node-param-description-missing-from-dynamic-multi-options`

* 👕 Apply `cred-class-field-name-missing-oauth2` (#3627)

* Rule working as intended

* Removed comments

* Move cred rule to different rule set

* 👕 Apply `node-param-array-type-assertion`

* 👕 Apply `node-dirname-against-convention`

* Apply `cred-class-field-display-name-oauth2` (#3628)

* Apply `node-execute-block-wrong-error-thrown`

* Apply `node-class-description-display-name-unsuffixed-trigger-node`

* Apply `node-class-description-name-unsuffixed-trigger-node`

* Apply `cred-class-name-missing-oauth2-suffix` (#3636)

* Rule working as intended, add exception to existing nodes

* 👕 Apply `cred-class-field-name-uppercase-first-char` (#3638)

* ⬆️ Upgrade to plugin version 1.2.28

* 📦 Update `package-lock.json`

* 👕 Update lintings with 1.2.8 change

* 👕 Apply `cred-class-field-name-unsuffixed`

* 👕 Apply `cred-class-name-unsuffixed`

* 👕 Apply `node-class-description-credentials-name-unsuffixed`

* ✏️ Alphabetize rules

*  Remove `nodelinter` package

* 📦 Update `package-lock.json`

*  Consolidate `lint` and `lintfix` scripts

Co-authored-by: agobrech <45268029+agobrech@users.noreply.github.com>
Co-authored-by: agobrech <ael.gobrecht@gmail.com>
This commit is contained in:
Iván Ovejero
2022-07-04 11:12:08 +02:00
committed by GitHub
parent 6b9289349f
commit 59f2e8e7d5
74 changed files with 7530 additions and 24481 deletions

View File

@@ -4,6 +4,8 @@ import {
INodeExecutionData,
INodeType,
INodeTypeDescription,
NodeApiError,
NodeOperationError,
} from 'n8n-workflow';
@@ -122,7 +124,7 @@ export class Discord implements INodeType {
const webhookUri = this.getNodeParameter('webhookUri', 0, '') as string;
if (!webhookUri) throw Error('Webhook uri is required.');
if (!webhookUri) throw new NodeOperationError(this.getNode(), 'Webhook uri is required.');
const items = this.getInputData();
const length = items.length as number;
@@ -134,17 +136,17 @@ export class Discord implements INodeType {
const options = this.getNodeParameter('options', i) as IDataObject;
if (!body.content && !options.embeds) {
throw new Error('Either content or embeds must be set.');
throw new NodeOperationError(this.getNode(), 'Either content or embeds must be set.');
}
if (options.embeds) {
try {
//@ts-expect-error
body.embeds = JSON.parse(options.embeds);
if (!Array.isArray(body.embeds)) {
throw new Error('Embeds must be an array of embeds.');
throw new NodeOperationError(this.getNode(), 'Embeds must be an array of embeds.');
}
} catch (e) {
throw new Error('Embeds must be valid JSON.');
throw new NodeOperationError(this.getNode(), 'Embeds must be valid JSON.');
}
}
if (options.username) {
@@ -156,7 +158,7 @@ export class Discord implements INodeType {
//@ts-expect-error
body.components = JSON.parse(options.components);
} catch (e) {
throw new Error('Components must be valid JSON.');
throw new NodeOperationError(this.getNode(), 'Components must be valid JSON.');
}
}
@@ -259,8 +261,9 @@ export class Discord implements INodeType {
} while (--maxTries);
if (maxTries <= 0) {
throw new Error(
'Could not send Webhook message. Max amount of rate-limit retries reached.',
throw new NodeApiError(
this.getNode(),
{ error: 'Could not send Webhook message. Max amount of rate-limit retries reached.' },
);
}