mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-09 22:24:05 -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
|
||||
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
|
||||
|
|
|
@ -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: {
|
||||
|
@ -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',
|
||||
|
|
|
@ -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).
|
||||
|
|
|
@ -22,7 +22,7 @@ export class CloudflareApi implements ICredentialType {
|
|||
type: 'generic',
|
||||
properties: {
|
||||
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 {
|
||||
name = 'hubspotAppToken';
|
||||
|
|
|
@ -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.",
|
||||
},
|
||||
];
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ export class RundeckApi implements ICredentialType {
|
|||
default: '',
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
authenticate: IAuthenticateGeneric = {
|
||||
type: 'generic',
|
||||
properties: {
|
||||
|
@ -41,5 +41,5 @@ export class RundeckApi implements ICredentialType {
|
|||
url: '/api/14/system/info',
|
||||
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 };
|
||||
}
|
||||
|
|
|
@ -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');
|
||||
|
||||
|
@ -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'));
|
||||
}
|
||||
|
@ -55,7 +58,7 @@ function getNodeTranslationPaths() {
|
|||
|
||||
if (existsSync(nodeTranslationPath)) {
|
||||
acc.push(nodeTranslationPath);
|
||||
};
|
||||
}
|
||||
|
||||
return acc;
|
||||
}, []);
|
||||
|
@ -74,7 +77,6 @@ function getHeaders(nodeTranslationPaths) {
|
|||
}, {});
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------
|
||||
// helpers
|
||||
// ----------------------------------
|
||||
|
@ -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`);
|
||||
};
|
||||
|
|
|
@ -23,9 +23,6 @@
|
|||
]
|
||||
},
|
||||
"subcategories": {
|
||||
"Core Nodes": [
|
||||
"Helpers",
|
||||
"Other Trigger Nodes"
|
||||
]
|
||||
"Core Nodes": ["Helpers", "Other Trigger Nodes"]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,9 +19,6 @@
|
|||
]
|
||||
},
|
||||
"subcategories": {
|
||||
"Core Nodes": [
|
||||
"Helpers",
|
||||
"Other Trigger Nodes"
|
||||
]
|
||||
"Core Nodes": ["Helpers", "Other Trigger Nodes"]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,9 +2,7 @@
|
|||
"node": "n8n-nodes-base.executeWorkflowTrigger",
|
||||
"nodeVersion": "1.0",
|
||||
"codexVersion": "1.0",
|
||||
"categories": [
|
||||
"Core Nodes"
|
||||
],
|
||||
"categories": ["Core Nodes"],
|
||||
"resources": {
|
||||
"primaryDocumentation": [
|
||||
{
|
||||
|
@ -14,8 +12,6 @@
|
|||
"generic": []
|
||||
},
|
||||
"subcategories": {
|
||||
"Core Nodes": [
|
||||
"Helpers"
|
||||
]
|
||||
"Core Nodes": ["Helpers"]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,9 +24,6 @@
|
|||
},
|
||||
"alias": ["Time", "Scheduler", "Polling"],
|
||||
"subcategories": {
|
||||
"Core Nodes": [
|
||||
"Flow",
|
||||
"Other Trigger Nodes"
|
||||
]
|
||||
"Core Nodes": ["Flow", "Other Trigger Nodes"]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,9 +12,6 @@
|
|||
},
|
||||
"alias": ["Watch", "Monitor"],
|
||||
"subcategories": {
|
||||
"Core Nodes":[
|
||||
"Files",
|
||||
"Other Trigger Nodes"
|
||||
]
|
||||
"Core Nodes": ["Files", "Other Trigger Nodes"]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,9 +2,7 @@
|
|||
"node": "n8n-nodes-base.manualTrigger",
|
||||
"nodeVersion": "1.0",
|
||||
"codexVersion": "1.0",
|
||||
"categories": [
|
||||
"Core Nodes"
|
||||
],
|
||||
"categories": ["Core Nodes"],
|
||||
"resources": {
|
||||
"primaryDocumentation": [
|
||||
{
|
||||
|
|
|
@ -11,9 +11,6 @@
|
|||
]
|
||||
},
|
||||
"subcategories": {
|
||||
"Core Nodes": [
|
||||
"Flow",
|
||||
"Other Trigger Nodes"
|
||||
]
|
||||
"Core Nodes": ["Flow", "Other Trigger Nodes"]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,9 +18,6 @@
|
|||
]
|
||||
},
|
||||
"subcategories": {
|
||||
"Core Nodes": [
|
||||
"Flow",
|
||||
"Other Trigger Nodes"
|
||||
]
|
||||
"Core 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:
|
||||
|
||||
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
|
||||
|
@ -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);
|
||||
```
|
||||
|
|
|
@ -11,9 +11,6 @@
|
|||
]
|
||||
},
|
||||
"subcategories": {
|
||||
"Core Nodes": [
|
||||
"Flow",
|
||||
"Other Trigger Nodes"
|
||||
]
|
||||
"Core Nodes": ["Flow", "Other Trigger Nodes"]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -1,16 +1,11 @@
|
|||
{
|
||||
"linterOptions": {
|
||||
"exclude": [
|
||||
"node_modules/**/*"
|
||||
]
|
||||
"exclude": ["node_modules/**/*"]
|
||||
},
|
||||
"defaultSeverity": "error",
|
||||
"jsRules": {},
|
||||
"rules": {
|
||||
"array-type": [
|
||||
true,
|
||||
"array-simple"
|
||||
],
|
||||
"array-type": [true, "array-simple"],
|
||||
"arrow-return-shorthand": true,
|
||||
"ban": [
|
||||
true,
|
||||
|
@ -21,40 +16,18 @@
|
|||
],
|
||||
"ban-types": [
|
||||
true,
|
||||
[
|
||||
"Object",
|
||||
"Use {} instead."
|
||||
],
|
||||
[
|
||||
"String",
|
||||
"Use 'string' instead."
|
||||
],
|
||||
[
|
||||
"Number",
|
||||
"Use 'number' instead."
|
||||
],
|
||||
[
|
||||
"Boolean",
|
||||
"Use 'boolean' instead."
|
||||
]
|
||||
["Object", "Use {} instead."],
|
||||
["String", "Use 'string' instead."],
|
||||
["Number", "Use 'number' instead."],
|
||||
["Boolean", "Use 'boolean' instead."]
|
||||
],
|
||||
"class-name": true,
|
||||
"curly": [
|
||||
true,
|
||||
"ignore-same-line"
|
||||
],
|
||||
"curly": [true, "ignore-same-line"],
|
||||
"forin": true,
|
||||
"jsdoc-format": true,
|
||||
"label-position": true,
|
||||
"indent": [
|
||||
true,
|
||||
"tabs",
|
||||
2
|
||||
],
|
||||
"member-access": [
|
||||
true,
|
||||
"no-public"
|
||||
],
|
||||
"indent": [true, "tabs", 2],
|
||||
"member-access": [true, "no-public"],
|
||||
"new-parens": true,
|
||||
"no-angle-bracket-type-assertion": true,
|
||||
"no-any": true,
|
||||
|
@ -72,27 +45,16 @@
|
|||
"named-imports-order": "case-insensitive"
|
||||
}
|
||||
],
|
||||
"no-namespace": [
|
||||
false,
|
||||
"allow-declarations"
|
||||
],
|
||||
"no-namespace": [false, "allow-declarations"],
|
||||
"no-reference": true,
|
||||
"no-string-throw": true,
|
||||
"no-unused-expression": true,
|
||||
"no-var-keyword": true,
|
||||
"object-literal-shorthand": true,
|
||||
"only-arrow-functions": [
|
||||
true,
|
||||
"allow-declarations",
|
||||
"allow-named-functions"
|
||||
],
|
||||
"only-arrow-functions": [true, "allow-declarations", "allow-named-functions"],
|
||||
"prefer-const": true,
|
||||
"radix": true,
|
||||
"semicolon": [
|
||||
true,
|
||||
"always",
|
||||
"ignore-bound-class-methods"
|
||||
],
|
||||
"semicolon": [true, "always", "ignore-bound-class-methods"],
|
||||
"switch-default": true,
|
||||
"trailing-comma": [
|
||||
true,
|
||||
|
@ -106,15 +68,9 @@
|
|||
"esSpecCompliant": true
|
||||
}
|
||||
],
|
||||
"triple-equals": [
|
||||
true,
|
||||
"allow-null-check"
|
||||
],
|
||||
"triple-equals": [true, "allow-null-check"],
|
||||
"use-isnan": true,
|
||||
"quotes": [
|
||||
"error",
|
||||
"single"
|
||||
],
|
||||
"quotes": ["error", "single"],
|
||||
"variable-name": [
|
||||
true,
|
||||
"check-format",
|
||||
|
|
Loading…
Reference in a new issue