@mrpelz/boilerplate-common 6.3.3-workspaces-6fcb015a.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,15 @@
1
+ root = true
2
+
3
+ [*]
4
+ charset = utf-8
5
+ end_of_line = lf
6
+ indent_size = 2
7
+ indent_style = space
8
+ insert_final_newline = true
9
+ trim_trailing_whitespace = true
10
+
11
+ [*.sh]
12
+ indent_style = tab
13
+
14
+ [{Makefile,*.mk}]
15
+ indent_style = tab
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env sh
2
+ . "$(dirname -- "$0")/_/husky.sh"
3
+
4
+ node_modules/.bin/commitlint --verbose --edit
@@ -0,0 +1,10 @@
1
+ {
2
+ "recommendations": [
3
+ "dbaeumer.vscode-eslint",
4
+ "editorconfig.editorconfig",
5
+ "meganrogge.template-string-converter",
6
+ "ms-vscode.makefile-tools",
7
+ "nhoizey.gremlins",
8
+ "yoavbls.pretty-ts-errors"
9
+ ]
10
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "editor.codeActionsOnSave": {
3
+ "source.fixAll": true
4
+ },
5
+ "editor.formatOnSave": false,
6
+ "eslint.experimental.useFlatConfig": true,
7
+ "eslint.format.enable": true,
8
+ "files.autoSave": "onWindowChange",
9
+ "javascript.format.enable": false,
10
+ "javascript.preferences.importModuleSpecifierEnding": "js",
11
+ "js/ts.implicitProjectConfig.checkJs": true,
12
+ "prettier.enable": false,
13
+ "typescript.format.enable": false,
14
+ "typescript.preferences.importModuleSpecifierEnding": "js"
15
+ }
@@ -0,0 +1,204 @@
1
+ .SILENT:
2
+
3
+ .PHONY: \
4
+ check \
5
+ check_commit \
6
+ check_config \
7
+ check_lint \
8
+ check_package_json \
9
+ check_package_json_name \
10
+ check_package_json_repository \
11
+ check_package_json_sort \
12
+ check_package_json_version \
13
+ check_test \
14
+ check_typescript \
15
+ transform \
16
+ transform_clear \
17
+ transform_lint \
18
+ transform_package_json \
19
+ transform_package_json_name \
20
+ transform_package_json_sort \
21
+ transform_package_json_version \
22
+ transform_prod \
23
+ transform_typescript \
24
+ util_clear \
25
+ util_get_version \
26
+ util_install_git_hooks \
27
+ watch \
28
+ watch_config \
29
+ watch_dev \
30
+ watch_lint \
31
+ watch_test \
32
+ watch_typescript
33
+
34
+ SHELL := /usr/bin/env bash
35
+
36
+ ARGS := $(filter-out $(firstword $(MAKECMDGOALS)),$(MAKECMDGOALS))
37
+
38
+ export PATH := $(shell npm root)/.bin:$(PATH)
39
+
40
+ PKG_NAME := $(shell npm pkg get name 2>/dev/null | sed -nr 's/^"@(.+)"$$/\1/p' 2>/dev/null)
41
+ GIT_NAME := $(shell git remote get-url origin 2>/dev/null | sed -nr 's/^(https|git)(:\/\/|@)(.+@)?([^\/:]+)[\/:]([^\/:]+)\/(.+)\.git$$/\5\/\6/p' 2>/dev/null)
42
+
43
+ PKG_VERSION := $(shell npm pkg get version 2>/dev/null | sed -nr 's/^"(.+)"$$/\1/p' 2>/dev/null)
44
+ GIT_VERSION := $(shell git describe --tag --abbrev=0 2>/dev/null | sed -nr 's/^v(.+)$$/\1/p' 2>/dev/null)
45
+
46
+ PKG_REPO_TYPE := $(shell npm pkg get repository.type 2>/dev/null | sed -nr 's/^"(.+)"$$/\1/p' 2>/dev/null)
47
+ PKG_REPO_NAME := $(shell npm pkg get repository.url 2>/dev/null | sed -nr 's/^"(.+)"$$/\1/p' 2>/dev/null | sed -nr 's/^(https|git)(:\/\/|@)(.+@)?([^\/:]+)[\/:]([^\/:]+)\/(.+)\.git$$/\5\/\6/p' 2>/dev/null)
48
+ PKG_REPO_DIRECTORY := $(shell npm pkg get repository.directory 2>/dev/null | sed -nr 's/^"(.+)"$$/\1/p' 2>/dev/null)
49
+
50
+ ESLINT_ARGS := --ignore-pattern "dist/**/*" --ignore-pattern "node_modules/**/*" --ignore-pattern "packages/**/*"
51
+
52
+ %:
53
+ @:
54
+
55
+ check: \
56
+ check_commit \
57
+ check_package_json \
58
+ check_lint \
59
+ check_config \
60
+ check_typescript \
61
+ check_test
62
+
63
+ check_commit:
64
+ commitlint --verbose --from HEAD~1 --to HEAD
65
+
66
+ check_config:
67
+ tsc --project tsconfig.meta.json
68
+
69
+ check_lint:
70
+ eslint $(ESLINT_ARGS) .
71
+
72
+ check_package_json: \
73
+ check_package_json_sort \
74
+ check_package_json_repository \
75
+ check_package_json_name \
76
+ check_package_json_version
77
+
78
+ check_package_json_name:
79
+ if [[ -z "$(GIT_NAME)" ]]; then \
80
+ echo "cannot determine git repository name, skipping"; \
81
+ fi
82
+
83
+ if [[ -n "$(PKG_REPO_DIRECTORY)" ]]; then \
84
+ echo "is sub-package, not comparing to repository name"; \
85
+ fi
86
+
87
+ if [[ -z "$(GIT_NAME)" || -n "$(PKG_REPO_DIRECTORY)" || "$(PKG_NAME)" = "$(GIT_NAME)" ]]; then \
88
+ exit 0; \
89
+ else \
90
+ echo "name in package.json ($(PKG_NAME)) does not match git repository name ($(GIT_NAME))"; \
91
+ exit 1; \
92
+ fi
93
+
94
+ check_package_json_repository:
95
+ if [[ -z "$(GIT_NAME)" ]]; then \
96
+ echo "cannot determine git repository name, skipping"; \
97
+ fi
98
+
99
+ if [[ -z "$(GIT_NAME)" || "$(PKG_REPO_TYPE)" = "git" ]]; then \
100
+ exit 0; \
101
+ else \
102
+ echo "repository.type in package.json ($(PKG_REPO_TYPE)) does not match \"git\""; \
103
+ exit 1; \
104
+ fi
105
+
106
+ if [[ -z "$(GIT_NAME)" || "$(PKG_REPO_NAME)" = "$(GIT_NAME)" ]]; then \
107
+ exit 0; \
108
+ else \
109
+ echo "package name derived from repository.url in package.json ($(PKG_REPO_NAME)) does not match git repository name ($(GIT_NAME))"; \
110
+ exit 1; \
111
+ fi
112
+
113
+ if [[ -z "$(ARGS)" || "$(PKG_REPO_DIRECTORY)" = "$(ARGS)" ]]; then \
114
+ exit 0; \
115
+ else \
116
+ echo "sub-package directory derived from repository.directory in package.json ($(PKG_REPO_DIRECTORY)) does not match required directory ($(ARGS))"; \
117
+ exit 1; \
118
+ fi
119
+
120
+ check_package_json_sort:
121
+ sort-package-json --check
122
+
123
+ check_package_json_version:
124
+ if [[ -z "$(GIT_VERSION)" ]]; then \
125
+ echo "cannot determine git repository version, skipping"; \
126
+ fi
127
+
128
+ if [[ -z "$(GIT_VERSION)" || "$(PKG_VERSION)" = "$(GIT_VERSION)" ]]; then \
129
+ exit 0; \
130
+ else \
131
+ echo "version in package.json ($(PKG_VERSION)) does not match git repository version ($(GIT_VERSION))"; \
132
+ exit 1; \
133
+ fi
134
+
135
+ check_test:
136
+ jest .
137
+
138
+ check_typescript:
139
+ tsc
140
+
141
+ transform: \
142
+ transform_package_json \
143
+ transform_lint \
144
+ transform_typescript
145
+
146
+ transform_clear: \
147
+ util_clear \
148
+ transform
149
+
150
+ transform_lint:
151
+ eslint --fix $(ESLINT_ARGS) .
152
+
153
+ transform_package_json: \
154
+ transform_package_json_sort \
155
+ transform_package_json_name \
156
+ transform_package_json_version
157
+
158
+ transform_package_json_name:
159
+ if [[ -n "$(PKG_REPO_DIRECTORY)" ]]; then \
160
+ echo "is sub-package, not applying repository name"; \
161
+ else \
162
+ npm pkg set "name=@$(GIT_NAME)"; \
163
+ fi
164
+
165
+ transform_package_json_sort:
166
+ sort-package-json
167
+
168
+ transform_package_json_version:
169
+ npm pkg set "version=$(GIT_VERSION)"
170
+
171
+ transform_prod: \
172
+ util_clear \
173
+ transform_typescript
174
+
175
+ transform_typescript:
176
+ tsc --project tsconfig.build.json
177
+
178
+ util_clear:
179
+ rm -rf dist/{*,.*}
180
+
181
+ util_get_version:
182
+ @echo $(PKG_VERSION)
183
+
184
+ util_install_git_hooks:
185
+ husky install
186
+
187
+ watch:
188
+ scripts/watch.sh
189
+
190
+ watch_config:
191
+ tsc --project tsconfig.meta.json --watch
192
+
193
+ watch_dev:
194
+ scripts/dev.sh
195
+
196
+ watch_lint:
197
+ chokidar --initial "**/*.js" "src/**/*.{js,ts}" --ignore "dist/**/*" --ignore "node_modules/**/*" --ignore "*.d.ts" \
198
+ --command "clear; eslint --ignore-pattern \"dist/**/*\" --ignore-pattern \"node_modules/**/*\" --ignore-pattern \"packages/**/*\" .; echo \"[waiting for changes…]\""
199
+
200
+ watch_test:
201
+ jest --watch .
202
+
203
+ watch_typescript:
204
+ tsc --project tsconfig.build.json --watch
@@ -0,0 +1,4 @@
1
+ /** @type {import('@commitlint/types').UserConfig} */
2
+ export default {
3
+ extends: ['@commitlint/config-conventional'],
4
+ };
package/config/dev.sh ADDED
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env bash
2
+
3
+ tmux \
4
+ new-session "make -s watch_lint" \; \
5
+ bind-key -n C-d "set-option -w remain-on-exit off; set-option -w synchronize-panes on; send-keys C-c; kill-pane; kill-pane" \; \
6
+ bind-key -n C-Down "select-pane -D" \; \
7
+ bind-key -n C-Left "select-pane -L" \; \
8
+ bind-key -n C-Right "select-pane -R" \; \
9
+ bind-key -n C-Space "resize-pane -Z" \; \
10
+ bind-key -n C-Up "select-pane -U" \; \
11
+ set-option -w mouse on \; \
12
+ set-option -w pane-active-border-style bold,fg=black,bg=white \; \
13
+ set-option -w pane-border-status top \; \
14
+ set-option -w pane-border-style bold,fg=white \; \
15
+ set-option -w remain-on-exit on \; \
16
+ set-option -w status off \; \
17
+ set-option -p pane-border-format "eslint (eslint.config.json, includes files outside \"src\")" \; \
18
+ split-window -h -l 50% "make -s watch_test" \; \
19
+ set-option -p pane-border-format "jest (jest.config.json)" \; \
20
+ split-window -f -v -l 50% "make -s watch_typescript" \; \
21
+ set-option -p pane-border-format "tsc (tsconfig.build.json, excludes test-files)" \; \
22
+ split-window -h -l 50% "make -s watch_config" \; \
23
+ set-option -p pane-border-format "tsc (tsconfig.meta.json, checks files outside \"src\")" \; \
24
+ split-window -f -v -l 5 \; \
25
+ set-option -p pane-border-format "input" \; \
@@ -0,0 +1,524 @@
1
+ import typescriptPlugin from '@typescript-eslint/eslint-plugin';
2
+ // @ts-ignore
3
+ import typescriptParser from '@typescript-eslint/parser';
4
+ // @ts-ignore
5
+ import importPlugin from 'eslint-plugin-import';
6
+ import prettierPlugin from 'eslint-plugin-prettier';
7
+ // @ts-ignore
8
+ import simpleImportSortPlugin from 'eslint-plugin-simple-import-sort';
9
+ // @ts-ignore
10
+ import pluginUnicorn from 'eslint-plugin-unicorn';
11
+
12
+ const unicornRecommendedRules =
13
+ /** @type {import('eslint').Linter.RulesRecord} */ (
14
+ pluginUnicorn.configs.recommended.rules
15
+ ); // assert correct type, as "eslint-plugin-unicorn" has no type definitions
16
+
17
+ /** @type {import('eslint').Linter.RulesRecord} */
18
+ export const rules = {
19
+ ...unicornRecommendedRules,
20
+ '@typescript-eslint/adjacent-overload-signatures': 'error',
21
+ '@typescript-eslint/ban-ts-comment': 'error',
22
+ '@typescript-eslint/ban-types': 'error',
23
+ '@typescript-eslint/explicit-module-boundary-types': [
24
+ 'error',
25
+ {
26
+ allowArgumentsExplicitlyTypedAsAny: true,
27
+ },
28
+ ],
29
+ '@typescript-eslint/member-ordering': [
30
+ 'error',
31
+ {
32
+ default: {
33
+ memberTypes: [
34
+ 'signature',
35
+ 'private-static-field',
36
+ 'protected-static-field',
37
+ 'public-static-field',
38
+ 'static-field',
39
+ 'private-static-method',
40
+ 'protected-static-method',
41
+ 'public-static-method',
42
+ 'static-method',
43
+ 'private-decorated-field',
44
+ 'private-instance-field',
45
+ 'private-field',
46
+ 'protected-abstract-field',
47
+ 'protected-decorated-field',
48
+ 'protected-instance-field',
49
+ 'protected-field',
50
+ 'public-abstract-field',
51
+ 'public-decorated-field',
52
+ 'public-instance-field',
53
+ 'public-field',
54
+ 'abstract-field',
55
+ 'decorated-field',
56
+ 'instance-field',
57
+ 'field',
58
+ 'private-constructor',
59
+ 'protected-constructor',
60
+ 'public-constructor',
61
+ 'constructor',
62
+ 'private-decorated-method',
63
+ 'private-instance-method',
64
+ 'private-method',
65
+ 'protected-abstract-method',
66
+ 'protected-decorated-method',
67
+ 'protected-instance-method',
68
+ 'protected-method',
69
+ 'public-abstract-method',
70
+ 'public-decorated-method',
71
+ 'public-instance-method',
72
+ 'public-method',
73
+ 'abstract-method',
74
+ 'decorated-method',
75
+ 'instance-method',
76
+ 'method',
77
+ ],
78
+ order: 'alphabetically',
79
+ },
80
+ },
81
+ ],
82
+ '@typescript-eslint/naming-convention': [
83
+ 'error',
84
+ {
85
+ format: ['camelCase'],
86
+ selector: 'default',
87
+ trailingUnderscore: 'allow',
88
+ },
89
+ {
90
+ format: ['camelCase', 'PascalCase'],
91
+ selector: 'function',
92
+ trailingUnderscore: 'allow',
93
+ },
94
+ {
95
+ format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
96
+ leadingUnderscore: 'allow',
97
+ selector: 'variable',
98
+ trailingUnderscore: 'allow',
99
+ },
100
+ {
101
+ format: null,
102
+ modifiers: ['destructured'],
103
+ selector: 'variable',
104
+ trailingUnderscore: 'allow',
105
+ },
106
+ {
107
+ format: ['camelCase'],
108
+ leadingUnderscore: 'allow',
109
+ selector: 'parameter',
110
+ trailingUnderscore: 'allow',
111
+ },
112
+ {
113
+ format: ['camelCase'],
114
+ leadingUnderscore: 'allow',
115
+ selector: 'memberLike',
116
+ trailingUnderscore: 'allow',
117
+ },
118
+ {
119
+ format: ['camelCase'],
120
+ leadingUnderscore: 'require',
121
+ modifiers: ['private'],
122
+ selector: 'memberLike',
123
+ trailingUnderscore: 'allow',
124
+ },
125
+ {
126
+ format: ['UPPER_CASE'],
127
+ selector: 'enumMember',
128
+ trailingUnderscore: 'allow',
129
+ },
130
+ {
131
+ format: ['PascalCase'],
132
+ selector: 'typeLike',
133
+ trailingUnderscore: 'allow',
134
+ },
135
+ ],
136
+ '@typescript-eslint/no-array-constructor': 'error',
137
+ '@typescript-eslint/no-empty-function': 'error',
138
+ '@typescript-eslint/no-empty-interface': 'error',
139
+ '@typescript-eslint/no-explicit-any': 'warn',
140
+ '@typescript-eslint/no-extra-non-null-assertion': 'error',
141
+ '@typescript-eslint/no-extra-semi': 'error',
142
+ '@typescript-eslint/no-inferrable-types': 'error',
143
+ '@typescript-eslint/no-misused-new': 'error',
144
+ '@typescript-eslint/no-namespace': 'error',
145
+ '@typescript-eslint/no-non-null-asserted-optional-chain': 'error',
146
+ '@typescript-eslint/no-non-null-assertion': 'warn',
147
+ '@typescript-eslint/no-shadow': 'error',
148
+ '@typescript-eslint/no-this-alias': 'error',
149
+ '@typescript-eslint/no-unused-vars': [
150
+ 'warn',
151
+ {
152
+ varsIgnorePattern: '(?:^_.*|^h|^fragment$|^T)',
153
+ },
154
+ ],
155
+ '@typescript-eslint/no-use-before-define': 'error',
156
+ '@typescript-eslint/no-useless-constructor': 'warn',
157
+ '@typescript-eslint/no-var-requires': 'error',
158
+ '@typescript-eslint/parameter-properties': [
159
+ 'warn',
160
+ {
161
+ prefer: 'parameter-property',
162
+ },
163
+ ],
164
+ '@typescript-eslint/prefer-as-const': 'error',
165
+ '@typescript-eslint/prefer-for-of': 'error',
166
+ '@typescript-eslint/prefer-namespace-keyword': 'error',
167
+ '@typescript-eslint/triple-slash-reference': 'error',
168
+ 'accessor-pairs': 'error',
169
+ 'array-bracket-spacing': ['error', 'never'],
170
+ 'array-callback-return': 'error',
171
+ 'arrow-body-style': 'warn',
172
+ 'arrow-parens': ['error', 'always'],
173
+ 'arrow-spacing': [
174
+ 'error',
175
+ {
176
+ after: true,
177
+ before: true,
178
+ },
179
+ ],
180
+ 'block-scoped-var': 'error',
181
+ 'block-spacing': ['error', 'always'],
182
+ 'brace-style': [
183
+ 'error',
184
+ '1tbs',
185
+ {
186
+ allowSingleLine: true,
187
+ },
188
+ ],
189
+ 'callback-return': 'error',
190
+ 'comma-style': ['error', 'last'],
191
+ complexity: 'error',
192
+ 'computed-property-spacing': ['error', 'never'],
193
+ 'consistent-return': [
194
+ 'error',
195
+ {
196
+ treatUndefinedAsUnspecified: false,
197
+ },
198
+ ],
199
+ 'default-case': 'error',
200
+ 'dot-location': ['error', 'property'],
201
+ 'dot-notation': [
202
+ 'error',
203
+ {
204
+ allowKeywords: true,
205
+ },
206
+ ],
207
+ 'eol-last': 'error',
208
+ eqeqeq: 'error',
209
+ 'for-direction': 'error',
210
+ 'func-call-spacing': 'error',
211
+ 'func-name-matching': 'error',
212
+ 'func-names': 'error',
213
+ 'func-style': [
214
+ 'error',
215
+ 'declaration',
216
+ {
217
+ allowArrowFunctions: true,
218
+ },
219
+ ],
220
+ 'generator-star-spacing': 'error',
221
+ 'global-require': 'error',
222
+ 'guard-for-in': 'error',
223
+ 'handle-callback-err': 'error',
224
+ 'id-blacklist': 'error',
225
+ 'id-match': 'error',
226
+ 'import/extensions': [
227
+ 'error',
228
+ 'ignorePackages',
229
+ {
230
+ cjs: 'never',
231
+ js: 'always',
232
+ jsx: 'never',
233
+ mjs: 'never',
234
+ ts: 'never',
235
+ tsx: 'never',
236
+ },
237
+ ],
238
+ 'import/no-commonjs': 'error',
239
+ 'import/no-duplicates': 'error',
240
+ 'import/no-named-as-default': 'warn',
241
+ 'import/no-named-as-default-member': 'warn',
242
+ 'jsx-quotes': 'error',
243
+ 'key-spacing': 'error',
244
+ 'keyword-spacing': [
245
+ 'error',
246
+ {
247
+ after: true,
248
+ before: true,
249
+ },
250
+ ],
251
+ 'linebreak-style': ['error', 'unix'],
252
+ 'lines-around-directive': 'error',
253
+ 'lines-between-class-members': [
254
+ 'error',
255
+ 'always',
256
+ {
257
+ exceptAfterSingleLine: true,
258
+ },
259
+ ],
260
+ 'max-depth': 'error',
261
+ 'max-nested-callbacks': 'error',
262
+ 'multiline-comment-style': ['error', 'separate-lines'],
263
+ 'new-cap': 'error',
264
+ 'new-parens': 'error',
265
+ 'no-alert': 'error',
266
+ 'no-async-promise-executor': 'error',
267
+ 'no-await-in-loop': 'error',
268
+ 'no-bitwise': 'error',
269
+ 'no-buffer-constructor': 'error',
270
+ 'no-caller': 'error',
271
+ 'no-case-declarations': 'error',
272
+ 'no-catch-shadow': 'error',
273
+ 'no-class-assign': 'error',
274
+ 'no-compare-neg-zero': 'error',
275
+ 'no-cond-assign': 'error',
276
+ 'no-console': 'error',
277
+ 'no-constant-condition': 'error',
278
+ 'no-control-regex': 'error',
279
+ 'no-debugger': 'error',
280
+ 'no-delete-var': 'error',
281
+ 'no-div-regex': 'error',
282
+ 'no-duplicate-case': 'error',
283
+ 'no-duplicate-imports': 'error',
284
+ 'no-else-return': 'error',
285
+ 'no-empty': 'error',
286
+ 'no-empty-character-class': 'error',
287
+ 'no-empty-pattern': 'error',
288
+ 'no-eq-null': 'error',
289
+ 'no-eval': 'error',
290
+ 'no-ex-assign': 'error',
291
+ 'no-extend-native': 'error',
292
+ 'no-extra-bind': 'error',
293
+ 'no-extra-boolean-cast': 'error',
294
+ 'no-extra-label': 'error',
295
+ 'no-fallthrough': 'error',
296
+ 'no-floating-decimal': 'error',
297
+ 'no-global-assign': 'error',
298
+ 'no-implicit-coercion': 'error',
299
+ 'no-implicit-globals': 'error',
300
+ 'no-implied-eval': 'error',
301
+ 'no-inner-declarations': 'error',
302
+ 'no-invalid-regexp': 'error',
303
+ 'no-invalid-this': 'error',
304
+ 'no-irregular-whitespace': 'error',
305
+ 'no-iterator': 'error',
306
+ 'no-label-var': 'error',
307
+ 'no-labels': 'error',
308
+ 'no-lone-blocks': 'error',
309
+ 'no-lonely-if': 'error',
310
+ 'no-loop-func': 'error',
311
+ 'no-misleading-character-class': 'error',
312
+ 'no-mixed-requires': 'error',
313
+ 'no-mixed-spaces-and-tabs': 'error',
314
+ 'no-multi-assign': 'error',
315
+ 'no-multi-spaces': 'error',
316
+ 'no-multi-str': 'error',
317
+ 'no-multiple-empty-lines': 'error',
318
+ 'no-native-reassign': 'error',
319
+ 'no-negated-condition': 'error',
320
+ 'no-negated-in-lhs': 'error',
321
+ 'no-nested-ternary': 'error',
322
+ 'no-new': 'error',
323
+ 'no-new-func': 'error',
324
+ 'no-new-object': 'error',
325
+ 'no-new-require': 'error',
326
+ 'no-new-wrappers': 'error',
327
+ 'no-octal': 'error',
328
+ 'no-octal-escape': 'error',
329
+ 'no-param-reassign': 'error',
330
+ 'no-path-concat': 'error',
331
+ 'no-plusplus': 'error',
332
+ 'no-proto': 'error',
333
+ 'no-prototype-builtins': 'error',
334
+ 'no-regex-spaces': 'error',
335
+ 'no-restricted-globals': 'error',
336
+ 'no-restricted-imports': 'error',
337
+ 'no-restricted-modules': 'error',
338
+ 'no-restricted-properties': 'error',
339
+ 'no-restricted-syntax': 'error',
340
+ 'no-return-assign': 'error',
341
+ 'no-return-await': 'error',
342
+ 'no-script-url': 'error',
343
+ 'no-self-assign': 'error',
344
+ 'no-self-compare': 'error',
345
+ 'no-sequences': 'error',
346
+ 'no-shadow-restricted-names': 'error',
347
+ 'no-spaced-func': 'error',
348
+ 'no-sparse-arrays': 'error',
349
+ 'no-sync': 'error',
350
+ 'no-tabs': 'error',
351
+ 'no-template-curly-in-string': 'error',
352
+ 'no-throw-literal': 'error',
353
+ 'no-trailing-spaces': 'error',
354
+ 'no-undef-init': 'error',
355
+ 'no-unexpected-multiline': 'error',
356
+ 'no-unmodified-loop-condition': 'error',
357
+ 'no-unneeded-ternary': 'error',
358
+ 'no-unsafe-finally': 'error',
359
+ 'no-unused-expressions': 'error',
360
+ 'no-unused-labels': 'error',
361
+ 'no-useless-call': 'error',
362
+ 'no-useless-catch': 'error',
363
+ 'no-useless-computed-key': 'error',
364
+ 'no-useless-concat': 'error',
365
+ 'no-useless-escape': 'error',
366
+ 'no-useless-rename': 'error',
367
+ 'no-useless-return': 'error',
368
+ 'no-var': 'error',
369
+ 'no-void': 'error',
370
+ 'no-warning-comments': 'error',
371
+ 'no-whitespace-before-property': 'error',
372
+ 'no-with': 'error',
373
+ 'nonblock-statement-body-position': 'error',
374
+ 'object-curly-newline': 'error',
375
+ 'object-curly-spacing': ['error', 'always'],
376
+ 'object-shorthand': 'error',
377
+ 'one-var-declaration-per-line': 'error',
378
+ 'operator-assignment': ['error', 'always'],
379
+ 'padding-line-between-statements': 'error',
380
+ 'prefer-arrow-callback': 'error',
381
+ 'prefer-named-capture-group': 'error',
382
+ 'prefer-numeric-literals': 'error',
383
+ 'prefer-promise-reject-errors': [
384
+ 'error',
385
+ {
386
+ allowEmptyReject: true,
387
+ },
388
+ ],
389
+ 'prefer-rest-params': 'error',
390
+ 'prefer-spread': 'error',
391
+ 'prefer-template': 'error',
392
+ 'prettier/prettier': [
393
+ 'error',
394
+ {
395
+ singleQuote: true,
396
+ },
397
+ {
398
+ usePrettierrc: false,
399
+ },
400
+ ],
401
+ 'quote-props': ['error', 'as-needed'],
402
+ quotes: ['error', 'single'],
403
+ radix: ['error', 'always'],
404
+ 'require-atomic-updates': 'error',
405
+ 'require-yield': 'error',
406
+ 'rest-spread-spacing': ['error', 'never'],
407
+ semi: 'error',
408
+ 'semi-spacing': [
409
+ 'error',
410
+ {
411
+ after: true,
412
+ before: false,
413
+ },
414
+ ],
415
+ 'semi-style': ['error', 'last'],
416
+ 'simple-import-sort/imports': 'error',
417
+ 'sort-keys': 'error',
418
+ 'sort-vars': 'error',
419
+ 'space-before-blocks': 'error',
420
+ 'space-in-parens': ['error', 'never'],
421
+ 'space-infix-ops': 'error',
422
+ 'space-unary-ops': [
423
+ 'error',
424
+ {
425
+ nonwords: false,
426
+ words: true,
427
+ },
428
+ ],
429
+ 'spaced-comment': ['error', 'always'],
430
+ strict: ['error', 'never'],
431
+ 'switch-colon-spacing': 'error',
432
+ 'symbol-description': 'error',
433
+ 'template-curly-spacing': ['error', 'never'],
434
+ 'template-tag-spacing': 'error',
435
+ 'unicode-bom': ['error', 'never'],
436
+ 'unicorn/no-null': 'off',
437
+ 'unicorn/no-useless-undefined': 'off',
438
+ 'unicorn/number-literal-case': 'off',
439
+ 'unicorn/prefer-native-coercion-functions': 'off',
440
+ 'unicorn/prefer-regexp-test': 'off',
441
+ 'unicorn/prefer-set-has': 'off',
442
+ 'unicorn/prefer-spread': 'off',
443
+ 'unicorn/prefer-top-level-await': 'off',
444
+ 'unicorn/prevent-abbreviations': 'off',
445
+ 'use-isnan': 'error',
446
+ 'vars-on-top': 'error',
447
+ 'wrap-regex': 'error',
448
+ 'yield-star-spacing': 'error',
449
+ yoda: ['error', 'never'],
450
+ };
451
+
452
+ /** @type {Record<string, import('eslint').ESLint.Plugin>} */
453
+ export const plugins = {
454
+ '@typescript-eslint': typescriptPlugin,
455
+ import: importPlugin,
456
+ prettier: prettierPlugin,
457
+ // @ts-ignore
458
+ 'simple-import-sort': simpleImportSortPlugin,
459
+ unicorn: { rules: pluginUnicorn.rules },
460
+ };
461
+
462
+ /** @type {import('eslint').Linter.FlatConfig} */
463
+ export const configMeta = {
464
+ files: ['**/*.js'],
465
+ ignores: ['dist/**/*', 'node_modules/**/*', 'src/**/*'],
466
+ languageOptions: {
467
+ parser: typescriptParser,
468
+ parserOptions: {
469
+ ecmaFeatures: { modules: true },
470
+ ecmaVersion: 'latest',
471
+ project: 'tsconfig.meta.json',
472
+ },
473
+ },
474
+ plugins,
475
+ rules: {
476
+ ...rules,
477
+ '@typescript-eslint/ban-ts-comment': 'off',
478
+ '@typescript-eslint/naming-convention': 'off',
479
+ 'import/no-named-as-default': 'off',
480
+ 'import/no-named-as-default-member': 'off',
481
+ 'unicorn/prefer-export-from': 'off',
482
+ },
483
+ settings: {
484
+ 'import/resolver': {
485
+ typescript: {
486
+ enforceExtension: true,
487
+ project: 'tsconfig.meta.json',
488
+ },
489
+ },
490
+ },
491
+ };
492
+
493
+ /** @type {import('eslint').Linter.FlatConfig} */
494
+ export const config = {
495
+ files: ['src/**/*.{js,ts}'],
496
+ languageOptions: {
497
+ globals: {
498
+ Atomics: true,
499
+ SharedArrayBuffer: true,
500
+ },
501
+ parser: typescriptParser,
502
+ parserOptions: {
503
+ ecmaFeatures: { modules: true },
504
+ ecmaVersion: 'latest',
505
+ project: 'tsconfig.json',
506
+ },
507
+ },
508
+ plugins,
509
+ rules,
510
+ settings: {
511
+ 'import/resolver': {
512
+ typescript: {
513
+ enforceExtension: true,
514
+ extensionAlias: {
515
+ '.js': ['.js', '.ts'],
516
+ },
517
+ project: 'tsconfig.json',
518
+ },
519
+ },
520
+ },
521
+ };
522
+
523
+ /** @type {import('eslint').Linter.FlatConfig[]} */
524
+ export default [configMeta, config];
@@ -0,0 +1,10 @@
1
+ /** @type {import('ts-jest').JestConfigWithTsJest} */
2
+ export default {
3
+ moduleNameMapper: {
4
+ '^(\\./.+)\\.js$': '$1',
5
+ },
6
+ passWithNoTests: true,
7
+ preset: 'ts-jest/presets/js-with-ts-esm',
8
+ roots: ['src'],
9
+ testEnvironment: 'node',
10
+ };
@@ -0,0 +1,23 @@
1
+ {
2
+ "compilerOptions": {
3
+ "allowJs": true,
4
+ "alwaysStrict": true,
5
+ "checkJs": true,
6
+ "declaration": true,
7
+ "declarationMap": true,
8
+ "esModuleInterop": true,
9
+ "incremental": true,
10
+ "lib": [
11
+ "ESNext"
12
+ ],
13
+ "module": "NodeNext",
14
+ "moduleResolution": "NodeNext",
15
+ "noEmit": true,
16
+ "noImplicitAny": true,
17
+ "noImplicitReturns": true,
18
+ "sourceMap": true,
19
+ "strictNullChecks": true,
20
+ "target": "ESNext",
21
+ "useDefineForClassFields": true
22
+ },
23
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "compilerOptions": {
3
+ "incremental": false,
4
+ "moduleResolution": "Node",
5
+ "module": "None",
6
+ "skipLibCheck": true,
7
+ },
8
+ "extends": "./tsconfig.base.json",
9
+ }
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env bash
2
+
3
+ tmux \
4
+ new-session "make -s watch_lint" \; \
5
+ bind-key -n C-d "set-option -w remain-on-exit off; set-option -w synchronize-panes on; send-keys C-c; kill-pane; kill-pane" \; \
6
+ bind-key -n C-Down "select-pane -D" \; \
7
+ bind-key -n C-Left "select-pane -L" \; \
8
+ bind-key -n C-Right "select-pane -R" \; \
9
+ bind-key -n C-Space "resize-pane -Z" \; \
10
+ bind-key -n C-Up "select-pane -U" \; \
11
+ set-option -w mouse on \; \
12
+ set-option -w pane-active-border-style bold,fg=black,bg=white \; \
13
+ set-option -w pane-border-status top \; \
14
+ set-option -w pane-border-style bold,fg=white \; \
15
+ set-option -w remain-on-exit on \; \
16
+ set-option -w status off \; \
17
+ set-option -p pane-border-format "eslint (eslint.config.json, includes files outside \"src\")" \; \
18
+ split-window -h -l 50% "make -s watch_test" \; \
19
+ set-option -p pane-border-format "jest (jest.config.json)" \; \
20
+ split-window -f -v -l 50% "make -s watch_typescript" \; \
21
+ set-option -p pane-border-format "tsc (tsconfig.build.json, excludes test-files)" \; \
22
+ split-window -h -l 50% "make -s watch_config" \; \
23
+ set-option -p pane-border-format "tsc (tsconfig.meta.json, checks files outside \"src\")" \; \
24
+ select-pane -t 1 \; \
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@mrpelz/boilerplate-common",
3
+ "version": "6.3.3-workspaces-6fcb015a.0",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "https://git.i.wurstsalat.cloud/mrpelz/boilerplate.git",
7
+ "directory": "packages/boilerplate-common"
8
+ },
9
+ "license": "UNLICENSED",
10
+ "author": "Lennart Pelz <mail@mrpelz.de>",
11
+ "type": "module",
12
+ "main": "dist/main.js",
13
+ "module": "dist/main.js",
14
+ "types": "dist/main.d.ts",
15
+ "bin": {
16
+ "boilerplate-bootstrap": "scripts/bootstrap.sh"
17
+ },
18
+ "files": [
19
+ "dist/**/*.{js,map,ts}",
20
+ "config/**/{*,.*}",
21
+ "scripts/bootstrap.sh"
22
+ ],
23
+ "dependencies": {
24
+ "@commitlint/cli": "latest",
25
+ "@commitlint/config-conventional": "latest",
26
+ "@commitlint/types": "latest",
27
+ "@jest/globals": "latest",
28
+ "@types/eslint": "latest",
29
+ "@typescript-eslint/eslint-plugin": "latest",
30
+ "@typescript-eslint/parser": "latest",
31
+ "@typescript-eslint/types": "latest",
32
+ "chokidar-cli": "latest",
33
+ "eslint": "latest",
34
+ "eslint-import-resolver-typescript": "latest",
35
+ "eslint-plugin-import": "latest",
36
+ "eslint-plugin-prettier": "latest",
37
+ "eslint-plugin-simple-import-sort": "latest",
38
+ "eslint-plugin-unicorn": "latest",
39
+ "husky": "latest",
40
+ "jest": "latest",
41
+ "prettier": "latest",
42
+ "sort-package-json": "latest",
43
+ "ts-jest": "latest",
44
+ "typescript": "latest"
45
+ }
46
+ }
@@ -0,0 +1,308 @@
1
+ #!/usr/bin/env bash
2
+
3
+ ## ENVIRONMENT
4
+
5
+ OVERRIDE=$1
6
+
7
+ BOILERPLATE_MODULE_IDENTIFIER="@mrpelz/boilerplate-common"
8
+
9
+ BOILERPLATE_MODULE_NAME=$BOILERPLATE_MODULE_IDENTIFIER
10
+ BOILERPLATE_MODULE_PATH="$(realpath --relative-to=. "$(npm root)")/$BOILERPLATE_MODULE_IDENTIFIER/"
11
+
12
+ FORMAT_BOLD=$(tput bold)
13
+ FORMAT_NORMAL=$(tput sgr0)
14
+
15
+ ## UTILS
16
+
17
+ check_response() {
18
+ local CHECK_PROMPT=$1
19
+ local DEFAULT_RESPONSE=$2
20
+
21
+ echo "❓ $CHECK_PROMPT"
22
+
23
+ local CHECK_SUFFIX
24
+
25
+ case $DEFAULT_RESPONSE in
26
+ y | Y) CHECK_SUFFIX="[Y/n]" ;;
27
+ n | N) CHECK_SUFFIX="[y/N]" ;;
28
+ *) CHECK_SUFFIX="[y/n]" ;;
29
+ esac
30
+
31
+ case $OVERRIDE in
32
+ y | Y) CHOICE=y ;;
33
+ n | N) CHOICE=n ;;
34
+ d | D) CHOICE=$DEFAULT_RESPONSE ;;
35
+ *) read -r -p "❔ $CHECK_SUFFIX " CHOICE ;;
36
+ esac
37
+
38
+ if [[ -z "$CHOICE" ]]; then
39
+ CHOICE=$DEFAULT_RESPONSE
40
+ fi
41
+
42
+ echo "❗ $CHOICE"
43
+
44
+ case "$CHOICE" in
45
+ y | Y) return 0 ;;
46
+ n | N) return 1 ;;
47
+ *) return 1 ;;
48
+ esac
49
+ }
50
+
51
+ check_command() {
52
+ local COMMAND=$1
53
+
54
+ if command -v "$COMMAND" &>/dev/null; then
55
+ return 0
56
+ fi
57
+
58
+ return 1
59
+ }
60
+
61
+ check_non_existent() {
62
+ local FILE_PATH=$1
63
+ local OVERRIDE_PROMPT=$2
64
+
65
+ if [[ -e "$FILE_PATH" ]]; then
66
+ echo "💾 file already exists"
67
+
68
+ if check_response "$OVERRIDE_PROMPT" n; then
69
+ return 0
70
+ fi
71
+
72
+ return 1
73
+ fi
74
+
75
+ return 0
76
+ }
77
+
78
+ display() {
79
+ local CONTENT=$1
80
+ local SYNTAX=$2
81
+
82
+ if check_command highlight; then
83
+ echo "$CONTENT" | highlight --out-format=xterm256 --syntax="$SYNTAX"
84
+ else
85
+ echo "$CONTENT"
86
+ fi
87
+ }
88
+
89
+ make_ln() {
90
+ local TARGET_PATH=$1
91
+ local LINK_PATH=$2
92
+
93
+ local LINK_NAME
94
+ LINK_NAME=$(basename "$LINK_PATH")
95
+
96
+ local LINK_DIR
97
+ LINK_DIR=$(dirname "$LINK_PATH")
98
+
99
+ echo "[SYMBOLIC LINK] \"${FORMAT_BOLD}${LINK_NAME}${FORMAT_NORMAL}\""
100
+
101
+ if ! check_response "🔗 add symbolic link \"$LINK_PATH\" (pointing to target \"$TARGET_PATH\") to \"$LINK_DIR\" in \"$PWD\"?" y; then
102
+ return
103
+ fi
104
+
105
+ if check_non_existent "$LINK_PATH" "🪠 overwrite with link?"; then
106
+ mkdir -p "$LINK_DIR"
107
+ ln -f -r -s "$PWD/$TARGET_PATH" "$LINK_PATH"
108
+ fi
109
+ }
110
+
111
+ make_config() {
112
+ local FILE_PATH=$1
113
+ local FILE_CONTENT=$2
114
+
115
+ local FILE_NAME
116
+ FILE_NAME=$(basename "$FILE_PATH")
117
+
118
+ local FILE_DIR
119
+ FILE_DIR=$(dirname "$FILE_PATH")
120
+
121
+ echo "[CONFIG FILE] \"${FORMAT_BOLD}${FILE_NAME}${FORMAT_NORMAL}\""
122
+
123
+ echo "🆕 new file contents:"
124
+ display "$FILE_CONTENT" "${FILE_NAME##*.}"
125
+
126
+ if ! check_response "📄 add config file \"$FILE_PATH\" to \"$FILE_DIR\" in \"$PWD\"?" y; then
127
+ return
128
+ fi
129
+
130
+ if check_non_existent "$FILE_PATH" "🪠 overwrite with new contents?"; then
131
+ mkdir -p "$FILE_DIR"
132
+ echo "$FILE_CONTENT" >"$FILE_PATH"
133
+ fi
134
+ }
135
+
136
+ ## FLOW
137
+
138
+ if [[ "$(npm pkg get name | head -n 1)" == "\"$BOILERPLATE_MODULE_IDENTIFIER\"" ]]; then
139
+ echo "📍 running within \"$BOILERPLATE_MODULE_IDENTIFIER\""
140
+
141
+ BOILERPLATE_MODULE_NAME="."
142
+ BOILERPLATE_MODULE_PATH="./"
143
+ else
144
+ echo "ℹ️ running with \"$BOILERPLATE_MODULE_IDENTIFIER\" as dependency"
145
+ fi
146
+
147
+ if ! check_command make; then
148
+ echo "❌ \"make\" is not available, aborting"
149
+ exit 1
150
+ fi
151
+
152
+ if ! check_command sed; then
153
+ echo "❌ \"sed\" is not available, aborting"
154
+ exit 1
155
+ fi
156
+
157
+ if ! check_command tmux; then
158
+ echo "❌ \"tmux\" is not available, aborting"
159
+ exit 1
160
+ fi
161
+
162
+ if check_response "🖇 install symbolic links referencing files in boilerplate?" y; then
163
+ make_ln "${BOILERPLATE_MODULE_PATH}config/.editorconfig" .editorconfig
164
+
165
+ make_ln "${BOILERPLATE_MODULE_PATH}config/.vscode/extensions.json" .vscode/extensions.json
166
+ make_ln "${BOILERPLATE_MODULE_PATH}config/.vscode/settings.json" .vscode/settings.json
167
+
168
+ make_ln "${BOILERPLATE_MODULE_PATH}config/watch.sh" scripts/watch.sh
169
+ make_ln "${BOILERPLATE_MODULE_PATH}config/dev.sh" scripts/dev.sh
170
+ fi
171
+
172
+ if check_response "📃 install bare config files extending base files in boilerplate?" y; then
173
+
174
+ # no indent
175
+ make_config .gitignore "$(
176
+ cat <<EOF
177
+ .DS_Store
178
+ dist
179
+ node_modules
180
+ secrets.txt
181
+ EOF
182
+ )"
183
+
184
+ make_config Makefile "$(
185
+ cat <<EOF
186
+ include ${BOILERPLATE_MODULE_PATH}config/Makefile
187
+ EOF
188
+ )"
189
+
190
+ make_config commitlint.config.js "$(
191
+ cat <<EOF
192
+ // @ts-ignore
193
+ import config from '$BOILERPLATE_MODULE_NAME/config/commitlint.config.js';
194
+
195
+ /** @type {import('@commitlint/types').UserConfig} */
196
+ export default config;
197
+ EOF
198
+ )"
199
+
200
+ make_config eslint.config.js "$(
201
+ cat <<EOF
202
+ // @ts-ignore
203
+ import config from '$BOILERPLATE_MODULE_NAME/config/eslint.config.js';
204
+
205
+ /** @type {import('eslint').Linter.FlatConfig[]} */
206
+ export default config;
207
+ EOF
208
+ )"
209
+
210
+ make_config jest.config.js "$(
211
+ cat <<EOF
212
+ // @ts-ignore
213
+ import config from '$BOILERPLATE_MODULE_NAME/config/jest.config.js';
214
+
215
+ /** @type {import('ts-jest').JestConfigWithTsJest} */
216
+ export default config;
217
+ EOF
218
+ )"
219
+
220
+ make_config tsconfig.json "$(
221
+ cat <<EOF
222
+ {
223
+ "compilerOptions": {
224
+ "outDir": "dist",
225
+ },
226
+ "extends": "$BOILERPLATE_MODULE_NAME/config/tsconfig.base.json",
227
+ "include": ["src/**/*"]
228
+ }
229
+ EOF
230
+ )"
231
+
232
+ make_config tsconfig.build.json "$(
233
+ cat <<EOF
234
+ {
235
+ "compilerOptions": {
236
+ "noEmit": false
237
+ },
238
+ "exclude": ["**/*.test.ts"],
239
+ "extends": "./tsconfig.json",
240
+ "include": ["src/**/*"]
241
+ }
242
+ EOF
243
+ )"
244
+
245
+ make_config tsconfig.meta.json "$(
246
+ cat <<EOF
247
+ {
248
+ "exclude": ["dist/**/*", "node_modules/**/*", "src/**/*"],
249
+ "extends": "$BOILERPLATE_MODULE_NAME/config/tsconfig.meta.json",
250
+ "include": ["**/*.js"]
251
+ }
252
+ EOF
253
+ )"
254
+
255
+ make_config .gitlab-ci.yml "$(if [[ "$BOILERPLATE_MODULE_NAME" == "$BOILERPLATE_MODULE_IDENTIFIER" ]]; then
256
+ cat <<EOF
257
+ include:
258
+ - project: "mrpelz/boilerplate"
259
+ ref: main
260
+ file: "/gitlab/.gitlab-ci.yml"
261
+ EOF
262
+ else
263
+ cat <<EOF
264
+ include: "/gitlab/.gitlab-ci.yml"
265
+ EOF
266
+ fi)"
267
+ fi
268
+
269
+ if check_response "💱 apply changes to \"package.json\"?" y; then
270
+ npm pkg set \
271
+ "license=UNLICENSED" \
272
+ "author=Lennart Pelz <mail@mrpelz.de>" \
273
+ "type=module" \
274
+ "main=dist/main.js" \
275
+ "module=dist/main.js" \
276
+ "types=dist/main.d.ts" \
277
+ "files[0]=dist/**/*.{js,map,ts}" \
278
+ "devDependencies.@mrpelz/boilerplate-common=latest"
279
+ fi
280
+
281
+ if check_response "🕳 run npm install?" y; then
282
+ npm install
283
+ fi
284
+
285
+ if check_response "📂 create \"src\" directory (this will *not* overwrite/empty out existing directories)?" y; then
286
+ mkdir -p src
287
+ fi
288
+
289
+ if check_response "📂 create \"dist\" directory (this will *not* overwrite/empty out existing directories)?" y; then
290
+ mkdir -p dist
291
+ fi
292
+
293
+ if check_command git; then
294
+ if [[ -d ".git" ]]; then
295
+ if check_response "🪝 install git hooks?" y; then
296
+ make_ln "${BOILERPLATE_MODULE_PATH}config/.husky/commit-msg" .husky/commit-msg
297
+ make util_install_git_hooks
298
+ fi
299
+ else
300
+ echo "❌ \"$PWD\" does not seem to be a git repository, not installing git hooks"
301
+ fi
302
+ else
303
+ echo "❌ \"git\" is not available, not istalling git hooks"
304
+ fi
305
+
306
+ make transform_package_json_sort
307
+
308
+ echo "✅ done"