Skip to content

Commit 56c4c69

Browse files
ivovBHesseldieck
andauthored
🎨 Set up linting and formatting (n8n-io#2120)
* ⬆️ Upgrade TS to 4.3.5 * 👕 Add ESLint configs * 🎨 Add Prettier config * 📦 Add deps and commands * ⚡ Adjust global .editorconfig to new ruleset * 🔥 Remove unneeded local .editorconfig * 📦 Update deps in editor-ui * 🔨 Limit Prettier to only TS files * ⚡ Add recommended VSCode extensions * 👕 Fix build * 🔥 Remove Vue setting from global config * ⚡ Disable prefer-default-export per feedback * ✏️ Add forgotten divider * 👕 Disable no-plusplus * 👕 Disable class-methods-use-this * ✏️ Alphabetize overrides * 👕 Add one-var consecutive override * ⏪ Revert one-var consecutive override This reverts commit b9252cf. * 🎨 👕 Lint and format workflow package (n8n-io#2121) * 🎨 Format /workflow package * 👕 Lint /workflow package * 🎨 Re-format /workflow package * 👕 Re-lint /workflow package * ✏️ Fix typo * ⚡ Consolidate if-checks * 🔥 Remove prefer-default-export exceptions * 🔥 Remove no-plusplus exceptions * 🔥 Remove class-methods-use-this exceptions * 🎨 👕 Lint and format node-dev package (n8n-io#2122) * 🎨 Format /node-dev package * ⚡ Exclude templates from ESLint config This keeps the templates consistent with the codebase while preventing lint exceptions from being made part of the templates. * 👕 Lint /node-dev package * 🔥 Remove prefer-default-export exceptions * 🔥 Remove no-plusplus exceptions * 🎨 👕 Lint and format core package (n8n-io#2123) * 🎨 Format /core package * 👕 Lint /core package * 🎨 Re-format /core package * 👕 Re-lint /core package * 🔥 Remove prefer-default-export exceptions * 🔥 Remove no-plusplus exceptions * 🔥 Remove class-methods-use-this exceptions * 🎨 👕 Lint and format cli package (n8n-io#2124) * 🎨 Format /cli package * 👕 Exclude migrations from linting * 👕 Lint /cli package * 🎨 Re-format /cli package * 👕 Re-lint /cli package * 👕 Fix build * 🔥 Remove prefer-default-export exceptions * ⚡ Update exceptions in ActiveExecutions * 🔥 Remove no-plusplus exceptions * 🔥 Remove class-methods-use-this exceptions * 👕 fix lint issues * 🔧 use package specific linter, remove tslint command * 🔨 resolve build issue, sync dependencies * 🔧 change lint command Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com>
1 parent 223cd75 commit 56c4c69

File tree

108 files changed

+11695
-8279
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+11695
-8279
lines changed

.editorconfig

-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ trim_trailing_whitespace = true
1212
indent_style = space
1313
indent_size = 2
1414

15-
[*.ts]
16-
quote_type = single
17-
1815
[*.yml]
1916
indent_style = space
2017
indent_size = 2

.eslintrc.js

+354
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,354 @@
1+
module.exports = {
2+
env: {
3+
browser: true,
4+
es6: true,
5+
node: true,
6+
},
7+
8+
parser: '@typescript-eslint/parser',
9+
parserOptions: {
10+
project: ['./packages/*/tsconfig.json'],
11+
sourceType: 'module',
12+
},
13+
ignorePatterns: [
14+
'.eslintrc.js',
15+
'**/*.js',
16+
'**/node_modules/**',
17+
'**/dist/**',
18+
'**/test/**',
19+
'**/templates/**',
20+
'**/ormconfig.ts',
21+
'**/migrations/**',
22+
],
23+
24+
extends: [
25+
/**
26+
* Config for typescript-eslint recommended ruleset (without type checking)
27+
*
28+
* https://github.com/typescript-eslint/typescript-eslint/blob/1c1b572c3000d72cfe665b7afbada0ec415e7855/packages/eslint-plugin/src/configs/recommended.ts
29+
*/
30+
'plugin:@typescript-eslint/recommended',
31+
32+
/**
33+
* Config for typescript-eslint recommended ruleset (with type checking)
34+
*
35+
* https://github.com/typescript-eslint/typescript-eslint/blob/1c1b572c3000d72cfe665b7afbada0ec415e7855/packages/eslint-plugin/src/configs/recommended-requiring-type-checking.ts
36+
*/
37+
'plugin:@typescript-eslint/recommended-requiring-type-checking',
38+
39+
/**
40+
* Config for Airbnb style guide for TS, /base to remove React rules
41+
*
42+
* https://github.com/iamturns/eslint-config-airbnb-typescript
43+
* https://github.com/airbnb/javascript/tree/master/packages/eslint-config-airbnb-base/rules
44+
*/
45+
'eslint-config-airbnb-typescript/base',
46+
47+
/**
48+
* Config to disable ESLint rules covered by Prettier
49+
*
50+
* https://github.com/prettier/eslint-config-prettier
51+
*/
52+
'eslint-config-prettier',
53+
],
54+
55+
plugins: [
56+
/**
57+
* Plugin with lint rules for import/export syntax
58+
* https://github.com/import-js/eslint-plugin-import
59+
*/
60+
'eslint-plugin-import',
61+
62+
/**
63+
* @typescript-eslint/eslint-plugin is required by eslint-config-airbnb-typescript
64+
* See step 2: https://github.com/iamturns/eslint-config-airbnb-typescript#2-install-eslint-plugins
65+
*/
66+
'@typescript-eslint',
67+
68+
/**
69+
* Plugin to report formatting violations as lint violations
70+
* https://github.com/prettier/eslint-plugin-prettier
71+
*/
72+
'eslint-plugin-prettier',
73+
],
74+
75+
rules: {
76+
// ******************************************************************
77+
// required by prettier plugin
78+
// ******************************************************************
79+
80+
// The following rule enables eslint-plugin-prettier
81+
// See: https://github.com/prettier/eslint-plugin-prettier#recommended-configuration
82+
83+
'prettier/prettier': 'error',
84+
85+
// The following two rules must be disabled when using eslint-plugin-prettier:
86+
// See: https://github.com/prettier/eslint-plugin-prettier#arrow-body-style-and-prefer-arrow-callback-issue
87+
88+
/**
89+
* https://eslint.org/docs/rules/arrow-body-style
90+
*/
91+
'arrow-body-style': 'off',
92+
93+
/**
94+
* https://eslint.org/docs/rules/prefer-arrow-callback
95+
*/
96+
'prefer-arrow-callback': 'off',
97+
98+
// ******************************************************************
99+
// additions to base ruleset
100+
// ******************************************************************
101+
102+
// ----------------------------------
103+
// ESLint
104+
// ----------------------------------
105+
106+
/**
107+
* https://eslint.org/docs/rules/id-denylist
108+
*/
109+
'id-denylist': [
110+
'error',
111+
'err',
112+
'cb',
113+
'callback',
114+
'any',
115+
'Number',
116+
'number',
117+
'String',
118+
'string',
119+
'Boolean',
120+
'boolean',
121+
'Undefined',
122+
'undefined',
123+
],
124+
125+
// ----------------------------------
126+
// @typescript-eslint
127+
// ----------------------------------
128+
129+
/**
130+
* https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/array-type.md
131+
*/
132+
'@typescript-eslint/array-type': ['error', { default: 'array-simple' }],
133+
134+
/**
135+
* https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/ban-ts-comment.md
136+
*/
137+
'@typescript-eslint/ban-ts-comment': 'off',
138+
139+
/**
140+
* https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/ban-types.md
141+
*/
142+
'@typescript-eslint/ban-types': [
143+
'error',
144+
{
145+
types: {
146+
Object: {
147+
message: 'Use object instead',
148+
fixWith: 'object',
149+
},
150+
String: {
151+
message: 'Use string instead',
152+
fixWith: 'string',
153+
},
154+
Boolean: {
155+
message: 'Use boolean instead',
156+
fixWith: 'boolean',
157+
},
158+
Number: {
159+
message: 'Use number instead',
160+
fixWith: 'number',
161+
},
162+
Symbol: {
163+
message: 'Use symbol instead',
164+
fixWith: 'symbol',
165+
},
166+
Function: {
167+
message: [
168+
'The `Function` type accepts any function-like value.',
169+
'It provides no type safety when calling the function, which can be a common source of bugs.',
170+
'It also accepts things like class declarations, which will throw at runtime as they will not be called with `new`.',
171+
'If you are expecting the function to accept certain arguments, you should explicitly define the function shape.',
172+
].join('\n'),
173+
},
174+
},
175+
extendDefaults: false,
176+
},
177+
],
178+
179+
/**
180+
* https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/consistent-type-assertions.md
181+
*/
182+
'@typescript-eslint/consistent-type-assertions': 'error',
183+
184+
/**
185+
* https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/explicit-member-accessibility.md
186+
*/
187+
'@typescript-eslint/explicit-member-accessibility': ['error', { accessibility: 'no-public' }],
188+
189+
/**
190+
* https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/member-delimiter-style.md
191+
*/
192+
'@typescript-eslint/member-delimiter-style': [
193+
'error',
194+
{
195+
multiline: {
196+
delimiter: 'semi',
197+
requireLast: true,
198+
},
199+
singleline: {
200+
delimiter: 'semi',
201+
requireLast: false,
202+
},
203+
},
204+
],
205+
206+
/**
207+
* https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/naming-convention.md
208+
*/
209+
'@typescript-eslint/naming-convention': [
210+
'error',
211+
{
212+
selector: 'default',
213+
format: ['camelCase'],
214+
},
215+
{
216+
selector: 'variable',
217+
format: ['camelCase', 'snake_case', 'UPPER_CASE'],
218+
leadingUnderscore: 'allowSingleOrDouble',
219+
trailingUnderscore: 'allowSingleOrDouble',
220+
},
221+
{
222+
selector: 'property',
223+
format: ['camelCase', 'snake_case'],
224+
leadingUnderscore: 'allowSingleOrDouble',
225+
trailingUnderscore: 'allowSingleOrDouble',
226+
},
227+
{
228+
selector: 'typeLike',
229+
format: ['PascalCase'],
230+
},
231+
{
232+
selector: ['method', 'function'],
233+
format: ['camelCase'],
234+
leadingUnderscore: 'allowSingleOrDouble',
235+
},
236+
],
237+
238+
/**
239+
* https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-duplicate-imports.md
240+
*/
241+
'@typescript-eslint/no-duplicate-imports': 'error',
242+
243+
/**
244+
* https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-invalid-void-type.md
245+
*/
246+
'@typescript-eslint/no-invalid-void-type': 'error',
247+
248+
/**
249+
* https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-misused-promises.md
250+
*/
251+
'@typescript-eslint/no-misused-promises': ['error', { checksVoidReturn: false }],
252+
253+
/**
254+
* https://eslint.org/docs/1.0.0/rules/no-throw-literal
255+
*/
256+
'@typescript-eslint/no-throw-literal': 'error',
257+
258+
/**
259+
* https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unnecessary-boolean-literal-compare.md
260+
*/
261+
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error',
262+
263+
/**
264+
* https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unnecessary-qualifier.md
265+
*/
266+
'@typescript-eslint/no-unnecessary-qualifier': 'error',
267+
268+
/**
269+
* https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unused-expressions.md
270+
*/
271+
'@typescript-eslint/no-unused-expressions': 'error',
272+
273+
/**
274+
* https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unused-vars.md
275+
*/
276+
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '_' }],
277+
278+
/**
279+
* https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/prefer-nullish-coalescing.md
280+
*/
281+
'@typescript-eslint/prefer-nullish-coalescing': 'error',
282+
283+
/**
284+
* https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/prefer-optional-chain.md
285+
*/
286+
'@typescript-eslint/prefer-optional-chain': 'error',
287+
288+
/**
289+
* https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/promise-function-async.md
290+
*/
291+
'@typescript-eslint/promise-function-async': 'error',
292+
293+
// ----------------------------------
294+
// eslint-plugin-import
295+
// ----------------------------------
296+
297+
/**
298+
* https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-default-export.md
299+
*/
300+
'import/no-default-export': 'error',
301+
302+
/**
303+
* https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/order.md
304+
*/
305+
'import/order': 'error',
306+
307+
// ******************************************************************
308+
// overrides to base ruleset
309+
// ******************************************************************
310+
311+
// ----------------------------------
312+
// ESLint
313+
// ----------------------------------
314+
315+
/**
316+
* https://eslint.org/docs/rules/class-methods-use-this
317+
*/
318+
'class-methods-use-this': 'off',
319+
320+
/**
321+
* https://eslint.org/docs/rules/eqeqeq
322+
*/
323+
eqeqeq: 'error',
324+
325+
/**
326+
* https://eslint.org/docs/rules/no-plusplus
327+
*/
328+
'no-plusplus': 'off',
329+
330+
/**
331+
* https://eslint.org/docs/rules/object-shorthand
332+
*/
333+
'object-shorthand': 'error',
334+
335+
/**
336+
* https://eslint.org/docs/rules/prefer-const
337+
*/
338+
'prefer-const': 'error',
339+
340+
/**
341+
* https://eslint.org/docs/rules/prefer-spread
342+
*/
343+
'prefer-spread': 'error',
344+
345+
// ----------------------------------
346+
// import
347+
// ----------------------------------
348+
349+
/**
350+
* https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/prefer-default-export.md
351+
*/
352+
'import/prefer-default-export': 'off',
353+
},
354+
};

.github/workflows/tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ jobs:
2323
npm run bootstrap
2424
npm run build --if-present
2525
npm test
26-
npm run tslint
26+
npm run lint
2727
env:
2828
CI: true

.gitignore

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ yarn.lock
1010
google-generated-credentials.json
1111
_START_PACKAGE
1212
.env
13-
.vscode
13+
.vscode/*
14+
!.vscode/extensions.json
1415
.idea
15-
.prettierrc.js
1616
vetur.config.js
1717
nodelinter.config.json

0 commit comments

Comments
 (0)