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

refactor: Validate formatting in nodes-base (no-changelog) #4685

Merged
merged 4 commits into from
Nov 22, 2022
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
dist
packages/editor-ui
package.json

!packages/nodes-base/src
!packages/nodes-base/test
!packages/nodes-base/nodes

packages/nodes-base/nodes/UProc/Json/Tools.ts
4 changes: 2 additions & 2 deletions packages/nodes-base/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
* @type {import('@types/eslint').ESLint.ConfigData}
*/
module.exports = {
extends: ['@n8n_io/eslint-config/base'],
extends: ['@n8n_io/eslint-config/node'],
parserOptions: {
project: ['./tsconfig.json'],
tsconfigRootDir: __dirname,
},

rules: {
Expand All @@ -15,7 +16,6 @@ module.exports = {
'import/order': 'off',
'prefer-const': 'off',
'prefer-spread': 'off',
'prettier/prettier': 'off',
'import/no-extraneous-dependencies': 'off',

'@typescript-eslint/array-type': 'off',
Expand Down
1 change: 0 additions & 1 deletion packages/nodes-base/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ The nodes which are included by default in n8n
npm install n8n-nodes-base -g
```


## License

n8n is [fair-code](http://faircode.io) distributed under the [**Sustainable Use License**](https://github.com/n8n-io/n8n/blob/master/packages/cli/LICENSE.md).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class CloudflareApi implements ICredentialType {
type: 'generic',
properties: {
headers: {
'Authorization': '=Bearer {{$credentials.apiToken}}',
Authorization: '=Bearer {{$credentials.apiToken}}',
},
},
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { IAuthenticateGeneric, ICredentialTestRequest, ICredentialType, INodeProperties } from 'n8n-workflow';
import {
netroy marked this conversation as resolved.
Show resolved Hide resolved
IAuthenticateGeneric,
ICredentialTestRequest,
ICredentialType,
INodeProperties,
} from 'n8n-workflow';

export class HubspotAppToken implements ICredentialType {
name = 'hubspotAppToken';
Expand Down
3 changes: 2 additions & 1 deletion packages/nodes-base/credentials/MicrosoftSql.credentials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ export class MicrosoftSql implements ICredentialType {
},
],
default: '7_4',
description: 'The version of TDS to use. If server doesn\'t support specified version, negotiated version is used instead.',
description:
"The version of TDS to use. If server doesn't support specified version, negotiated version is used instead.",
},
];
}
4 changes: 2 additions & 2 deletions packages/nodes-base/credentials/RundeckApi.credentials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class RundeckApi implements ICredentialType {
default: '',
},
];

authenticate: IAuthenticateGeneric = {
type: 'generic',
properties: {
Expand All @@ -41,5 +41,5 @@ export class RundeckApi implements ICredentialType {
url: '/api/14/system/info',
method: 'GET',
},
};
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ export class VenafiTlsProtectDatacenterApi implements ICredentialType {
},
};

const { access_token } = await this.helpers.httpRequest(requestOptions) as { access_token: string };
const { access_token } = (await this.helpers.httpRequest(requestOptions)) as {
access_token: string;
};

return { token: access_token };
}
Expand Down
24 changes: 10 additions & 14 deletions packages/nodes-base/gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
const { existsSync, promises: { writeFile } } = require('fs');
const {
existsSync,
promises: { writeFile },
} = require('fs');
const path = require('path');
const { task, src, dest } = require('gulp');

Expand All @@ -8,7 +11,7 @@ const PURPLE_ANSI_COLOR_CODE = 35;
task('build:icons', copyIcons);

function copyIcons() {
src('nodes/**/*.{png,svg}').pipe(dest('dist/nodes'))
src('nodes/**/*.{png,svg}').pipe(dest('dist/nodes'));

return src('credentials/**/*.{png,svg}').pipe(dest('dist/credentials'));
}
Expand Down Expand Up @@ -55,7 +58,7 @@ function getNodeTranslationPaths() {

if (existsSync(nodeTranslationPath)) {
acc.push(nodeTranslationPath);
};
}

return acc;
}, []);
Expand All @@ -74,7 +77,6 @@ function getHeaders(nodeTranslationPaths) {
}, {});
}


// ----------------------------------
// helpers
// ----------------------------------
Expand All @@ -89,24 +91,18 @@ function isValidHeader(header, allowedHeaderKeys) {

const headerKeys = Object.keys(header);

return headerKeys.length > 0 &&
headerKeys.every(key => allowedHeaderKeys.includes(key));
return headerKeys.length > 0 && headerKeys.every((key) => allowedHeaderKeys.includes(key));
}

function writeDistFile(data, distPath) {
writeFile(
distPath,
`module.exports = ${JSON.stringify(data, null, 2)}`,
);
writeFile(distPath, `module.exports = ${JSON.stringify(data, null, 2)}`);
}

const log = (string, { bulletpoint } = { bulletpoint: false }) => {
if (bulletpoint) {
process.stdout.write(
colorize(PURPLE_ANSI_COLOR_CODE, `- ${string}\n`),
);
process.stdout.write(colorize(PURPLE_ANSI_COLOR_CODE, `- ${string}\n`));
return;
};
}

process.stdout.write(`${string}\n`);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@
]
},
"subcategories": {
"Core Nodes": [
"Helpers",
"Other Trigger Nodes"
]
"Core Nodes": ["Helpers", "Other Trigger Nodes"]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
]
},
"subcategories": {
"Core Nodes": [
"Helpers",
"Other Trigger Nodes"
]
"Core Nodes": ["Helpers", "Other Trigger Nodes"]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
"node": "n8n-nodes-base.executeWorkflowTrigger",
"nodeVersion": "1.0",
"codexVersion": "1.0",
"categories": [
"Core Nodes"
],
"categories": ["Core Nodes"],
"resources": {
"primaryDocumentation": [
{
Expand All @@ -14,8 +12,6 @@
"generic": []
},
"subcategories": {
"Core Nodes": [
"Helpers"
]
"Core Nodes": ["Helpers"]
}
}
5 changes: 1 addition & 4 deletions packages/nodes-base/nodes/Interval/Interval.node.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@
},
"alias": ["Time", "Scheduler", "Polling"],
"subcategories": {
"Core Nodes": [
"Flow",
"Other Trigger Nodes"
]
"Core Nodes": ["Flow", "Other Trigger Nodes"]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
},
"alias": ["Watch", "Monitor"],
"subcategories": {
"Core Nodes":[
"Files",
"Other Trigger Nodes"
]
"Core Nodes": ["Files", "Other Trigger Nodes"]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
"node": "n8n-nodes-base.manualTrigger",
"nodeVersion": "1.0",
"codexVersion": "1.0",
"categories": [
"Core Nodes"
],
"categories": ["Core Nodes"],
"resources": {
"primaryDocumentation": [
{
Expand Down
5 changes: 1 addition & 4 deletions packages/nodes-base/nodes/N8nTrigger/N8nTrigger.node.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
]
},
"subcategories": {
"Core Nodes": [
"Flow",
"Other Trigger Nodes"
]
"Core Nodes": ["Flow", "Other Trigger Nodes"]
}
}
5 changes: 1 addition & 4 deletions packages/nodes-base/nodes/SseTrigger/SseTrigger.node.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
]
},
"subcategories": {
"Core Nodes": [
"Flow",
"Other Trigger Nodes"
]
"Core Nodes": ["Flow", "Other Trigger Nodes"]
}
}
22 changes: 11 additions & 11 deletions packages/nodes-base/nodes/Stripe/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ All Stripe webhook events are taken from docs:

To get the entire list of events as a JS array, scrape the website:

1. manually add the id #event-types to `<ul>` that contains all event types
2. copy-paste the function in the JS console
3. the result is copied into in the clipboard
4. paste the prepared array in StripeTrigger.node.ts
1. manually add the id #event-types to `<ul>` that contains all event types
2. copy-paste the function in the JS console
3. the result is copied into in the clipboard
4. paste the prepared array in StripeTrigger.node.ts

```js
types = []
$$('ul#event-types li').forEach(el => {
const value = el.querySelector('.method-list-item-label-name').innerText
types = [];
$$('ul#event-types li').forEach((el) => {
const value = el.querySelector('.method-list-item-label-name').innerText;

types.push({
name: value
Expand All @@ -20,8 +20,8 @@ $$('ul#event-types li').forEach(el => {
.map((s) => s.charAt(0).toUpperCase() + s.substring(1))
.join(' '),
value,
description: el.querySelector('.method-list-item-description').innerText
})
})
copy(types)
description: el.querySelector('.method-list-item-description').innerText,
});
});
copy(types);
```
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
]
},
"subcategories": {
"Core Nodes": [
"Flow",
"Other Trigger Nodes"
]
"Core Nodes": ["Flow", "Other Trigger Nodes"]
}
}
2 changes: 1 addition & 1 deletion packages/nodes-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"dev": "pnpm watch",
"build": "tsc && gulp build:icons && gulp build:translations",
"build:translations": "gulp build:translations",
"format": "prettier --write **/*.{ts,json}",
"format": "prettier --write **/*.{ts,js,json,md} --ignore-path ../../.prettierignore",
"lint": "tslint -p tsconfig.json -c tslint.json && eslint nodes credentials",
"lintfix": "tslint --fix -p tsconfig.json -c tslint.json && eslint nodes credentials --fix",
"watch": "tsc --watch",
Expand Down
Loading