diff --git a/package.json b/package.json index 0c7d8dac15..30fcfb7959 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "start:default": "cd packages/cli/bin && ./n8n", "start:windows": "cd packages/cli/bin && n8n", "test": "lerna run test", + "tslint": "lerna exec npm run tslint", "watch": "lerna run --parallel watch" }, "devDependencies": { diff --git a/packages/cli/src/Server.ts b/packages/cli/src/Server.ts index e4093e5a15..ee248e4d14 100644 --- a/packages/cli/src/Server.ts +++ b/packages/cli/src/Server.ts @@ -18,7 +18,7 @@ import * as clientOAuth2 from 'client-oauth2'; import * as clientOAuth1 from 'oauth-1.0a'; import { RequestOptions } from 'oauth-1.0a'; import * as csrf from 'csrf'; -import * as requestPromise from 'request-promise-native'; +import * as requestPromise from 'request-promise-native'; import { createHmac } from 'crypto'; import { @@ -120,7 +120,7 @@ class App { restEndpoint: string; protocol: string; - sslKey: string; + sslKey: string; sslCert: string; presetCredentialsLoaded: boolean; @@ -143,7 +143,7 @@ class App { this.activeExecutionsInstance = ActiveExecutions.getInstance(); this.protocol = config.get('protocol'); - this.sslKey = config.get('ssl_key'); + this.sslKey = config.get('ssl_key'); this.sslCert = config.get('ssl_cert'); this.externalHooks = ExternalHooks(); @@ -204,7 +204,7 @@ class App { } // Check for and validate JWT if configured - const jwtAuthActive = config.get('security.jwtAuth.active') as boolean; + const jwtAuthActive = config.get('security.jwtAuth.active') as boolean; if (jwtAuthActive === true) { const jwtAuthHeader = await GenericHelpers.getConfigValue('security.jwtAuth.jwtHeader') as string; if (jwtAuthHeader === '') { @@ -282,7 +282,7 @@ class App { normalize: true, // Trim whitespace inside text nodes normalizeTags: true, // Transform tags to lowercase explicitArray: false, // Only put properties in array if length > 1 - } })); + } })); this.app.use(bodyParser.text({ limit: '16mb', verify: (req, res, buf) => { @@ -981,7 +981,7 @@ class App { const callback = `${WebhookHelpers.getWebhookBaseUrl()}${this.restEndpoint}/oauth1-credential/callback?cid=${req.query.id}`; - const options: RequestOptions = { + const options: RequestOptions = { method: 'POST', url: (_.get(oauthCredentials, 'requestTokenUrl') as string), data: { @@ -1049,7 +1049,7 @@ class App { const decryptedDataOriginal = credentialsHelper.getDecrypted(result.name, result.type, true); const oauthCredentials = credentialsHelper.applyDefaultsAndOverwrites(decryptedDataOriginal, result.type); - const options: OptionsWithUrl = { + const options: OptionsWithUrl = { method: 'POST', url: _.get(oauthCredentials, 'accessTokenUrl') as string, qs: { diff --git a/packages/nodes-base/nodes/Google/Task/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Task/GenericFunctions.ts index c3a5031511..55a690ad73 100644 --- a/packages/nodes-base/nodes/Google/Task/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Task/GenericFunctions.ts @@ -16,11 +16,11 @@ export async function googleApiRequest( this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, - body: any = {}, + body: IDataObject = {}, qs: IDataObject = {}, uri?: string, headers: IDataObject = {} -): Promise { +): Promise { // tslint:disable-line:no-any const options: OptionsWithUri = { headers: { 'Content-Type': 'application/json' @@ -65,9 +65,9 @@ export async function googleApiRequestAllItems( propertyName: string, method: string, endpoint: string, - body: any = {}, + body: IDataObject = {}, query: IDataObject = {} -): Promise { +): Promise { // tslint:disable-line:no-any const returnData: IDataObject[] = []; let responseData; diff --git a/packages/nodes-base/nodes/Microsoft/Sql/GenericFunctions.ts b/packages/nodes-base/nodes/Microsoft/Sql/GenericFunctions.ts index 8309b35db0..601d3b5393 100644 --- a/packages/nodes-base/nodes/Microsoft/Sql/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Microsoft/Sql/GenericFunctions.ts @@ -14,7 +14,7 @@ export function copyInputItem( properties: string[], ): IDataObject { // Prepare the data to insert and copy it to be returned - let newItem: IDataObject = {}; + const newItem: IDataObject = {}; for (const property of properties) { if (item.json[property] === undefined) { newItem[property] = null; @@ -70,14 +70,14 @@ export function createTableStruct( export function executeQueryQueue( tables: ITables, buildQueryQueue: Function, -): Promise { +): Promise { // tslint:disable-line:no-any return Promise.all( Object.keys(tables).map(table => { const columnsResults = Object.keys(tables[table]).map(columnString => { return Promise.all( buildQueryQueue({ - table: table, - columnString: columnString, + table, + columnString, items: tables[table][columnString], }), ); @@ -94,7 +94,7 @@ export function executeQueryQueue( * @returns {string} (Val1, Val2, ...) */ export function extractValues(item: IDataObject): string { - return `(${Object.values(item as any) + return `(${Object.values(item as any) // tslint:disable-line:no-any .map(val => (typeof val === 'string' ? `'${val}'` : val)) // maybe other types such as dates have to be handled as well .join(',')})`; } diff --git a/packages/nodes-base/nodes/Microsoft/Sql/TableInterface.ts b/packages/nodes-base/nodes/Microsoft/Sql/TableInterface.ts index a0343e6e0b..c260c36ab3 100644 --- a/packages/nodes-base/nodes/Microsoft/Sql/TableInterface.ts +++ b/packages/nodes-base/nodes/Microsoft/Sql/TableInterface.ts @@ -2,6 +2,6 @@ import { IDataObject } from 'n8n-workflow'; export interface ITables { [key: string]: { - [key: string]: Array; + [key: string]: IDataObject[]; }; } diff --git a/packages/nodes-base/nodes/Postgres/Postgres.node.functions.ts b/packages/nodes-base/nodes/Postgres/Postgres.node.functions.ts index fb4c50051c..4dae3a64c1 100644 --- a/packages/nodes-base/nodes/Postgres/Postgres.node.functions.ts +++ b/packages/nodes-base/nodes/Postgres/Postgres.node.functions.ts @@ -40,7 +40,7 @@ export function pgQuery( pgp: pgPromise.IMain<{}, pg.IClient>, db: pgPromise.IDatabase<{}, pg.IClient>, input: INodeExecutionData[], -): Promise> { +): Promise { const queries: string[] = []; for (let i = 0; i < input.length; i++) { queries.push(getNodeParam('query', i) as string); @@ -63,7 +63,7 @@ export async function pgInsert( pgp: pgPromise.IMain<{}, pg.IClient>, db: pgPromise.IDatabase<{}, pg.IClient>, items: INodeExecutionData[], -): Promise> { +): Promise { const table = getNodeParam('table', 0) as string; const schema = getNodeParam('schema', 0) as string; let returnFields = (getNodeParam('returnFields', 0) as string).split(',') as string[]; @@ -103,7 +103,7 @@ export async function pgUpdate( pgp: pgPromise.IMain<{}, pg.IClient>, db: pgPromise.IDatabase<{}, pg.IClient>, items: INodeExecutionData[], -): Promise> { +): Promise { const table = getNodeParam('table', 0) as string; const updateKey = getNodeParam('updateKey', 0) as string; const columnString = getNodeParam('columns', 0) as string; diff --git a/packages/nodes-base/nodes/Zoom/GenericFunctions.ts b/packages/nodes-base/nodes/Zoom/GenericFunctions.ts index 95e07f09b9..3d036f5f39 100644 --- a/packages/nodes-base/nodes/Zoom/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Zoom/GenericFunctions.ts @@ -70,10 +70,9 @@ export async function zoomApiRequestAllItems( propertyName: string, method: string, endpoint: string, - body: any = {}, + body: IDataObject = {}, query: IDataObject = {} -): Promise { - // tslint:disable-line:no-any +): Promise { // tslint:disable-line:no-any const returnData: IDataObject[] = []; let responseData; query.page_number = 0; diff --git a/packages/nodes-base/nodes/utils/utilities.ts b/packages/nodes-base/nodes/utils/utilities.ts index 73105a901c..0ba469dd10 100644 --- a/packages/nodes-base/nodes/utils/utilities.ts +++ b/packages/nodes-base/nodes/utils/utilities.ts @@ -14,7 +14,7 @@ * chunk(['a', 'b', 'c', 'd'], 3) * // => [['a', 'b', 'c'], ['d']] */ -export function chunk(array: any[], size: number = 1) { +export function chunk(array: any[], size = 1) { // tslint:disable-line:no-any const length = array == null ? 0 : array.length; if (!length || size < 1) { return []; @@ -40,11 +40,11 @@ export function chunk(array: any[], size: number = 1) { * // => ['a', 'b', 'c', 'd'] * */ -export function flatten(nestedArray: any[][]) { +export function flatten(nestedArray: any[][]) { // tslint:disable-line:no-any const result = []; - (function loop(array: any[]) { - for (var i = 0; i < array.length; i++) { + (function loop(array: any[]) { // tslint:disable-line:no-any + for (let i = 0; i < array.length; i++) { if (Array.isArray(array[i])) { loop(array[i]); } else {