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

@@ -481,8 +481,8 @@ export class DateTime implements INodeType {
const dataPropertyName = this.getNodeParameter('dataPropertyName', i) as string;
const newDate = fromFormat
? parseDateByFormat(dateValue, fromFormat)
: parseDateByDefault(dateValue);
? parseDateByFormat.call(this, dateValue, fromFormat)
: parseDateByDefault.call(this, dateValue);
operation === 'add'
? newDate.add(duration, timeUnit).utc().format()
@@ -536,24 +536,24 @@ export class DateTime implements INodeType {
}
}
function parseDateByFormat(value: string, fromFormat: string) {
function parseDateByFormat(this: IExecuteFunctions, value: string, fromFormat: string) {
const date = moment(value, fromFormat, true);
if (moment(date).isValid()) return date;
throw new Error('Date input cannot be parsed. Please recheck the value and the "From Format" field.');
throw new NodeOperationError(this.getNode(), 'Date input cannot be parsed. Please recheck the value and the "From Format" field.');
}
function parseDateByDefault(value: string) {
const isoValue = getIsoValue(value);
function parseDateByDefault(this: IExecuteFunctions, value: string) {
const isoValue = getIsoValue.call(this, value);
if (moment(isoValue).isValid()) return moment(isoValue);
throw new Error('Unrecognized date input. Please specify a format in the "From Format" field.');
throw new NodeOperationError(this.getNode(), 'Unrecognized date input. Please specify a format in the "From Format" field.');
}
function getIsoValue(value: string) {
function getIsoValue(this: IExecuteFunctions, value: string) {
try {
return new Date(value).toISOString(); // may throw due to unpredictable input
} catch (error) {
throw new Error('Unrecognized date input. Please specify a format in the "From Format" field.');
throw new NodeOperationError(this.getNode(), 'Unrecognized date input. Please specify a format in the "From Format" field.');
}
}