mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
refactor: Validate formatting in nodes-base
(no-changelog) (#4685)
* 🔥 Remove Prettier exceptions * 👕 Start linting on formatting * ⚡ Update `format` command * 🎨 Apply formatting
This commit is contained in:
parent
4f64e26a83
commit
60d66426ff
|
@ -1,9 +1,3 @@
|
||||||
dist
|
dist
|
||||||
packages/editor-ui
|
packages/editor-ui
|
||||||
package.json
|
package.json
|
||||||
|
|
||||||
!packages/nodes-base/src
|
|
||||||
!packages/nodes-base/test
|
|
||||||
!packages/nodes-base/nodes
|
|
||||||
|
|
||||||
packages/nodes-base/nodes/UProc/Json/Tools.ts
|
|
||||||
|
|
|
@ -2,9 +2,10 @@
|
||||||
* @type {import('@types/eslint').ESLint.ConfigData}
|
* @type {import('@types/eslint').ESLint.ConfigData}
|
||||||
*/
|
*/
|
||||||
module.exports = {
|
module.exports = {
|
||||||
extends: ['@n8n_io/eslint-config/base'],
|
extends: ['@n8n_io/eslint-config/node'],
|
||||||
parserOptions: {
|
parserOptions: {
|
||||||
project: ['./tsconfig.json'],
|
project: ['./tsconfig.json'],
|
||||||
|
tsconfigRootDir: __dirname,
|
||||||
},
|
},
|
||||||
|
|
||||||
rules: {
|
rules: {
|
||||||
|
@ -15,7 +16,6 @@ module.exports = {
|
||||||
'import/order': 'off',
|
'import/order': 'off',
|
||||||
'prefer-const': 'off',
|
'prefer-const': 'off',
|
||||||
'prefer-spread': 'off',
|
'prefer-spread': 'off',
|
||||||
'prettier/prettier': 'off',
|
|
||||||
'import/no-extraneous-dependencies': 'off',
|
'import/no-extraneous-dependencies': 'off',
|
||||||
|
|
||||||
'@typescript-eslint/array-type': 'off',
|
'@typescript-eslint/array-type': 'off',
|
||||||
|
|
|
@ -8,7 +8,6 @@ The nodes which are included by default in n8n
|
||||||
npm install n8n-nodes-base -g
|
npm install n8n-nodes-base -g
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## License
|
## 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).
|
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).
|
||||||
|
|
|
@ -22,7 +22,7 @@ export class CloudflareApi implements ICredentialType {
|
||||||
type: 'generic',
|
type: 'generic',
|
||||||
properties: {
|
properties: {
|
||||||
headers: {
|
headers: {
|
||||||
'Authorization': '=Bearer {{$credentials.apiToken}}',
|
Authorization: '=Bearer {{$credentials.apiToken}}',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
import { IAuthenticateGeneric, ICredentialTestRequest, ICredentialType, INodeProperties } from 'n8n-workflow';
|
import {
|
||||||
|
IAuthenticateGeneric,
|
||||||
|
ICredentialTestRequest,
|
||||||
|
ICredentialType,
|
||||||
|
INodeProperties,
|
||||||
|
} from 'n8n-workflow';
|
||||||
|
|
||||||
export class HubspotAppToken implements ICredentialType {
|
export class HubspotAppToken implements ICredentialType {
|
||||||
name = 'hubspotAppToken';
|
name = 'hubspotAppToken';
|
||||||
|
|
|
@ -91,7 +91,8 @@ export class MicrosoftSql implements ICredentialType {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
default: '7_4',
|
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.",
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ export class RundeckApi implements ICredentialType {
|
||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
authenticate: IAuthenticateGeneric = {
|
authenticate: IAuthenticateGeneric = {
|
||||||
type: 'generic',
|
type: 'generic',
|
||||||
properties: {
|
properties: {
|
||||||
|
@ -41,5 +41,5 @@ export class RundeckApi implements ICredentialType {
|
||||||
url: '/api/14/system/info',
|
url: '/api/14/system/info',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 };
|
return { token: access_token };
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
const { existsSync, promises: { writeFile } } = require('fs');
|
const {
|
||||||
|
existsSync,
|
||||||
|
promises: { writeFile },
|
||||||
|
} = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const { task, src, dest } = require('gulp');
|
const { task, src, dest } = require('gulp');
|
||||||
|
|
||||||
|
@ -8,7 +11,7 @@ const PURPLE_ANSI_COLOR_CODE = 35;
|
||||||
task('build:icons', copyIcons);
|
task('build:icons', copyIcons);
|
||||||
|
|
||||||
function 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'));
|
return src('credentials/**/*.{png,svg}').pipe(dest('dist/credentials'));
|
||||||
}
|
}
|
||||||
|
@ -55,7 +58,7 @@ function getNodeTranslationPaths() {
|
||||||
|
|
||||||
if (existsSync(nodeTranslationPath)) {
|
if (existsSync(nodeTranslationPath)) {
|
||||||
acc.push(nodeTranslationPath);
|
acc.push(nodeTranslationPath);
|
||||||
};
|
}
|
||||||
|
|
||||||
return acc;
|
return acc;
|
||||||
}, []);
|
}, []);
|
||||||
|
@ -74,7 +77,6 @@ function getHeaders(nodeTranslationPaths) {
|
||||||
}, {});
|
}, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
// helpers
|
// helpers
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
|
@ -89,24 +91,18 @@ function isValidHeader(header, allowedHeaderKeys) {
|
||||||
|
|
||||||
const headerKeys = Object.keys(header);
|
const headerKeys = Object.keys(header);
|
||||||
|
|
||||||
return headerKeys.length > 0 &&
|
return headerKeys.length > 0 && headerKeys.every((key) => allowedHeaderKeys.includes(key));
|
||||||
headerKeys.every(key => allowedHeaderKeys.includes(key));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function writeDistFile(data, distPath) {
|
function writeDistFile(data, distPath) {
|
||||||
writeFile(
|
writeFile(distPath, `module.exports = ${JSON.stringify(data, null, 2)}`);
|
||||||
distPath,
|
|
||||||
`module.exports = ${JSON.stringify(data, null, 2)}`,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const log = (string, { bulletpoint } = { bulletpoint: false }) => {
|
const log = (string, { bulletpoint } = { bulletpoint: false }) => {
|
||||||
if (bulletpoint) {
|
if (bulletpoint) {
|
||||||
process.stdout.write(
|
process.stdout.write(colorize(PURPLE_ANSI_COLOR_CODE, `- ${string}\n`));
|
||||||
colorize(PURPLE_ANSI_COLOR_CODE, `- ${string}\n`),
|
|
||||||
);
|
|
||||||
return;
|
return;
|
||||||
};
|
}
|
||||||
|
|
||||||
process.stdout.write(`${string}\n`);
|
process.stdout.write(`${string}\n`);
|
||||||
};
|
};
|
||||||
|
|
|
@ -23,9 +23,6 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"subcategories": {
|
"subcategories": {
|
||||||
"Core Nodes": [
|
"Core Nodes": ["Helpers", "Other Trigger Nodes"]
|
||||||
"Helpers",
|
|
||||||
"Other Trigger Nodes"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,9 +19,6 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"subcategories": {
|
"subcategories": {
|
||||||
"Core Nodes": [
|
"Core Nodes": ["Helpers", "Other Trigger Nodes"]
|
||||||
"Helpers",
|
|
||||||
"Other Trigger Nodes"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,9 +2,7 @@
|
||||||
"node": "n8n-nodes-base.executeWorkflowTrigger",
|
"node": "n8n-nodes-base.executeWorkflowTrigger",
|
||||||
"nodeVersion": "1.0",
|
"nodeVersion": "1.0",
|
||||||
"codexVersion": "1.0",
|
"codexVersion": "1.0",
|
||||||
"categories": [
|
"categories": ["Core Nodes"],
|
||||||
"Core Nodes"
|
|
||||||
],
|
|
||||||
"resources": {
|
"resources": {
|
||||||
"primaryDocumentation": [
|
"primaryDocumentation": [
|
||||||
{
|
{
|
||||||
|
@ -14,8 +12,6 @@
|
||||||
"generic": []
|
"generic": []
|
||||||
},
|
},
|
||||||
"subcategories": {
|
"subcategories": {
|
||||||
"Core Nodes": [
|
"Core Nodes": ["Helpers"]
|
||||||
"Helpers"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,9 +24,6 @@
|
||||||
},
|
},
|
||||||
"alias": ["Time", "Scheduler", "Polling"],
|
"alias": ["Time", "Scheduler", "Polling"],
|
||||||
"subcategories": {
|
"subcategories": {
|
||||||
"Core Nodes": [
|
"Core Nodes": ["Flow", "Other Trigger Nodes"]
|
||||||
"Flow",
|
|
||||||
"Other Trigger Nodes"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,9 +12,6 @@
|
||||||
},
|
},
|
||||||
"alias": ["Watch", "Monitor"],
|
"alias": ["Watch", "Monitor"],
|
||||||
"subcategories": {
|
"subcategories": {
|
||||||
"Core Nodes":[
|
"Core Nodes": ["Files", "Other Trigger Nodes"]
|
||||||
"Files",
|
|
||||||
"Other Trigger Nodes"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,9 +2,7 @@
|
||||||
"node": "n8n-nodes-base.manualTrigger",
|
"node": "n8n-nodes-base.manualTrigger",
|
||||||
"nodeVersion": "1.0",
|
"nodeVersion": "1.0",
|
||||||
"codexVersion": "1.0",
|
"codexVersion": "1.0",
|
||||||
"categories": [
|
"categories": ["Core Nodes"],
|
||||||
"Core Nodes"
|
|
||||||
],
|
|
||||||
"resources": {
|
"resources": {
|
||||||
"primaryDocumentation": [
|
"primaryDocumentation": [
|
||||||
{
|
{
|
||||||
|
|
|
@ -11,9 +11,6 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"subcategories": {
|
"subcategories": {
|
||||||
"Core Nodes": [
|
"Core Nodes": ["Flow", "Other Trigger Nodes"]
|
||||||
"Flow",
|
|
||||||
"Other Trigger Nodes"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,9 +18,6 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"subcategories": {
|
"subcategories": {
|
||||||
"Core Nodes": [
|
"Core Nodes": ["Flow", "Other Trigger Nodes"]
|
||||||
"Flow",
|
|
||||||
"Other Trigger Nodes"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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:
|
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
|
1. manually add the id #event-types to `<ul>` that contains all event types
|
||||||
2. copy-paste the function in the JS console
|
2. copy-paste the function in the JS console
|
||||||
3. the result is copied into in the clipboard
|
3. the result is copied into in the clipboard
|
||||||
4. paste the prepared array in StripeTrigger.node.ts
|
4. paste the prepared array in StripeTrigger.node.ts
|
||||||
|
|
||||||
```js
|
```js
|
||||||
types = []
|
types = [];
|
||||||
$$('ul#event-types li').forEach(el => {
|
$$('ul#event-types li').forEach((el) => {
|
||||||
const value = el.querySelector('.method-list-item-label-name').innerText
|
const value = el.querySelector('.method-list-item-label-name').innerText;
|
||||||
|
|
||||||
types.push({
|
types.push({
|
||||||
name: value
|
name: value
|
||||||
|
@ -20,8 +20,8 @@ $$('ul#event-types li').forEach(el => {
|
||||||
.map((s) => s.charAt(0).toUpperCase() + s.substring(1))
|
.map((s) => s.charAt(0).toUpperCase() + s.substring(1))
|
||||||
.join(' '),
|
.join(' '),
|
||||||
value,
|
value,
|
||||||
description: el.querySelector('.method-list-item-description').innerText
|
description: el.querySelector('.method-list-item-description').innerText,
|
||||||
})
|
});
|
||||||
})
|
});
|
||||||
copy(types)
|
copy(types);
|
||||||
```
|
```
|
||||||
|
|
|
@ -11,9 +11,6 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"subcategories": {
|
"subcategories": {
|
||||||
"Core Nodes": [
|
"Core Nodes": ["Flow", "Other Trigger Nodes"]
|
||||||
"Flow",
|
|
||||||
"Other Trigger Nodes"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
"dev": "pnpm watch",
|
"dev": "pnpm watch",
|
||||||
"build": "tsc && gulp build:icons && gulp build:translations",
|
"build": "tsc && gulp build:icons && gulp build:translations",
|
||||||
"build:translations": "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",
|
"lint": "tslint -p tsconfig.json -c tslint.json && eslint nodes credentials",
|
||||||
"lintfix": "tslint --fix -p tsconfig.json -c tslint.json && eslint nodes credentials --fix",
|
"lintfix": "tslint --fix -p tsconfig.json -c tslint.json && eslint nodes credentials --fix",
|
||||||
"watch": "tsc --watch",
|
"watch": "tsc --watch",
|
||||||
|
|
|
@ -1,16 +1,11 @@
|
||||||
{
|
{
|
||||||
"linterOptions": {
|
"linterOptions": {
|
||||||
"exclude": [
|
"exclude": ["node_modules/**/*"]
|
||||||
"node_modules/**/*"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"defaultSeverity": "error",
|
"defaultSeverity": "error",
|
||||||
"jsRules": {},
|
"jsRules": {},
|
||||||
"rules": {
|
"rules": {
|
||||||
"array-type": [
|
"array-type": [true, "array-simple"],
|
||||||
true,
|
|
||||||
"array-simple"
|
|
||||||
],
|
|
||||||
"arrow-return-shorthand": true,
|
"arrow-return-shorthand": true,
|
||||||
"ban": [
|
"ban": [
|
||||||
true,
|
true,
|
||||||
|
@ -21,40 +16,18 @@
|
||||||
],
|
],
|
||||||
"ban-types": [
|
"ban-types": [
|
||||||
true,
|
true,
|
||||||
[
|
["Object", "Use {} instead."],
|
||||||
"Object",
|
["String", "Use 'string' instead."],
|
||||||
"Use {} instead."
|
["Number", "Use 'number' instead."],
|
||||||
],
|
["Boolean", "Use 'boolean' instead."]
|
||||||
[
|
|
||||||
"String",
|
|
||||||
"Use 'string' instead."
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"Number",
|
|
||||||
"Use 'number' instead."
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"Boolean",
|
|
||||||
"Use 'boolean' instead."
|
|
||||||
]
|
|
||||||
],
|
],
|
||||||
"class-name": true,
|
"class-name": true,
|
||||||
"curly": [
|
"curly": [true, "ignore-same-line"],
|
||||||
true,
|
|
||||||
"ignore-same-line"
|
|
||||||
],
|
|
||||||
"forin": true,
|
"forin": true,
|
||||||
"jsdoc-format": true,
|
"jsdoc-format": true,
|
||||||
"label-position": true,
|
"label-position": true,
|
||||||
"indent": [
|
"indent": [true, "tabs", 2],
|
||||||
true,
|
"member-access": [true, "no-public"],
|
||||||
"tabs",
|
|
||||||
2
|
|
||||||
],
|
|
||||||
"member-access": [
|
|
||||||
true,
|
|
||||||
"no-public"
|
|
||||||
],
|
|
||||||
"new-parens": true,
|
"new-parens": true,
|
||||||
"no-angle-bracket-type-assertion": true,
|
"no-angle-bracket-type-assertion": true,
|
||||||
"no-any": true,
|
"no-any": true,
|
||||||
|
@ -72,27 +45,16 @@
|
||||||
"named-imports-order": "case-insensitive"
|
"named-imports-order": "case-insensitive"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"no-namespace": [
|
"no-namespace": [false, "allow-declarations"],
|
||||||
false,
|
|
||||||
"allow-declarations"
|
|
||||||
],
|
|
||||||
"no-reference": true,
|
"no-reference": true,
|
||||||
"no-string-throw": true,
|
"no-string-throw": true,
|
||||||
"no-unused-expression": true,
|
"no-unused-expression": true,
|
||||||
"no-var-keyword": true,
|
"no-var-keyword": true,
|
||||||
"object-literal-shorthand": true,
|
"object-literal-shorthand": true,
|
||||||
"only-arrow-functions": [
|
"only-arrow-functions": [true, "allow-declarations", "allow-named-functions"],
|
||||||
true,
|
|
||||||
"allow-declarations",
|
|
||||||
"allow-named-functions"
|
|
||||||
],
|
|
||||||
"prefer-const": true,
|
"prefer-const": true,
|
||||||
"radix": true,
|
"radix": true,
|
||||||
"semicolon": [
|
"semicolon": [true, "always", "ignore-bound-class-methods"],
|
||||||
true,
|
|
||||||
"always",
|
|
||||||
"ignore-bound-class-methods"
|
|
||||||
],
|
|
||||||
"switch-default": true,
|
"switch-default": true,
|
||||||
"trailing-comma": [
|
"trailing-comma": [
|
||||||
true,
|
true,
|
||||||
|
@ -106,15 +68,9 @@
|
||||||
"esSpecCompliant": true
|
"esSpecCompliant": true
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"triple-equals": [
|
"triple-equals": [true, "allow-null-check"],
|
||||||
true,
|
|
||||||
"allow-null-check"
|
|
||||||
],
|
|
||||||
"use-isnan": true,
|
"use-isnan": true,
|
||||||
"quotes": [
|
"quotes": ["error", "single"],
|
||||||
"error",
|
|
||||||
"single"
|
|
||||||
],
|
|
||||||
"variable-name": [
|
"variable-name": [
|
||||||
true,
|
true,
|
||||||
"check-format",
|
"check-format",
|
||||||
|
|
Loading…
Reference in a new issue