Skip to content

Commit 1c361d5

Browse files
committed
fix: Prettier
1 parent e6e0c12 commit 1c361d5

File tree

10 files changed

+373
-363
lines changed

10 files changed

+373
-363
lines changed

eslint.config.mjs

Lines changed: 152 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -1,142 +1,167 @@
1-
import typescriptEslint from "@typescript-eslint/eslint-plugin";
2-
import tsdoc from "eslint-plugin-tsdoc";
3-
import tsParser from "@typescript-eslint/parser";
4-
import path from "node:path";
5-
import { fileURLToPath } from "node:url";
6-
import js from "@eslint/js";
7-
import { FlatCompat } from "@eslint/eslintrc";
8-
9-
const __filename = fileURLToPath(import.meta.url);
10-
const __dirname = path.dirname(__filename);
1+
import typescriptEslint from '@typescript-eslint/eslint-plugin'
2+
import tsdoc from 'eslint-plugin-tsdoc'
3+
import tsParser from '@typescript-eslint/parser'
4+
import path from 'node:path'
5+
import { fileURLToPath } from 'node:url'
6+
import js from '@eslint/js'
7+
import { FlatCompat } from '@eslint/eslintrc'
8+
9+
const __filename = fileURLToPath(import.meta.url)
10+
const __dirname = path.dirname(__filename)
1111
const compat = new FlatCompat({
12-
baseDirectory: __dirname,
13-
recommendedConfig: js.configs.recommended,
14-
allConfig: js.configs.all
15-
});
12+
baseDirectory: __dirname,
13+
recommendedConfig: js.configs.recommended,
14+
allConfig: js.configs.all,
15+
})
1616

17-
export default [{
17+
export default [
18+
{
1819
ignores: [
19-
"**/node_modules",
20-
"**/dist",
21-
"**/coverage",
22-
"scripts/generator-adapter",
23-
"**/.yarn",
24-
"**/.vscode",
20+
'**/node_modules',
21+
'**/dist',
22+
'**/coverage',
23+
'scripts/generator-adapter',
24+
'**/.yarn',
25+
'**/.vscode',
2526
],
26-
}, ...compat.extends("eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier"), {
27+
},
28+
...compat.extends('eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier'),
29+
{
2730
plugins: {
28-
"@typescript-eslint": typescriptEslint,
29-
tsdoc,
31+
'@typescript-eslint': typescriptEslint,
32+
tsdoc,
3033
},
3134

3235
languageOptions: {
33-
parser: tsParser,
36+
parser: tsParser,
3437
},
3538

3639
rules: {
37-
"tsdoc/syntax": "warn",
38-
39-
"array-callback-return": ["error", {
40-
allowImplicit: false,
41-
checkForEach: true,
42-
}],
43-
44-
"no-constant-binary-expression": "error",
45-
"no-constructor-return": "error",
46-
"no-duplicate-imports": "error",
47-
"no-promise-executor-return": "error",
48-
"no-self-compare": "error",
49-
"no-template-curly-in-string": "error",
50-
"no-unmodified-loop-condition": "error",
51-
"no-unreachable-loop": "error",
52-
"no-unused-private-class-members": "error",
53-
"require-atomic-updates": "error",
54-
55-
"@typescript-eslint/no-unused-vars": ["warn", {
56-
argsIgnorePattern: "^_",
57-
caughtErrorsIgnorePattern: "^_"
58-
}],
59-
60-
"capitalized-comments": ["error", "always", {
61-
ignoreConsecutiveComments: true,
62-
}],
63-
64-
complexity: ["error", 25],
65-
curly: "error",
66-
"default-case-last": "error",
67-
"default-param-last": "error",
68-
eqeqeq: ["error", "smart"],
69-
"func-names": "error",
70-
71-
"func-style": ["error", "declaration", {
72-
allowArrowFunctions: true,
73-
}],
74-
75-
"grouped-accessor-pairs": ["error", "getBeforeSet"],
76-
"max-depth": ["error", 4],
77-
"max-nested-callbacks": ["error", 3],
78-
"max-params": ["error", 4],
79-
80-
"new-cap": ["error", {
81-
newIsCapExceptions: ["ctor"],
82-
}],
83-
84-
"no-caller": "error",
85-
86-
"no-confusing-arrow": ["error", {
87-
allowParens: true,
88-
}],
89-
90-
"no-console": ["warn"],
91-
"no-div-regex": "error",
92-
"no-eval": "error",
93-
"no-extend-native": "error",
94-
"no-extra-bind": "error",
95-
"no-extra-label": "error",
96-
"no-extra-semi": "error",
97-
"no-floating-decimal": "error",
98-
"no-implied-eval": "error",
99-
"no-invalid-this": "error",
100-
"no-labels": "error",
101-
"no-lonely-if": "error",
102-
"no-multi-assign": "error",
103-
"no-multi-str": "error",
104-
"no-nested-ternary": "error",
105-
"no-new": "error",
106-
"no-new-func": "error",
107-
"no-new-object": "error",
108-
"no-new-wrappers": "error",
109-
"no-param-reassign": "error",
110-
"no-proto": "error",
111-
"no-return-assign": "error",
112-
"no-return-await": "error",
113-
"no-sequences": "error",
114-
"no-shadow": "off",
115-
"@typescript-eslint/no-shadow": "error",
116-
"no-unneeded-ternary": "error",
117-
"no-useless-call": "error",
118-
"no-useless-computed-key": "error",
119-
"no-useless-concat": "error",
120-
"no-useless-rename": "error",
121-
"no-var": "error",
122-
"operator-assignment": ["error", "always"],
123-
"prefer-arrow-callback": "error",
124-
"prefer-const": "error",
125-
"prefer-exponentiation-operator": "error",
126-
"prefer-object-spread": "error",
127-
"prefer-promise-reject-errors": "error",
128-
"prefer-regex-literals": "error",
129-
"prefer-rest-params": "error",
130-
"prefer-spread": "error",
131-
"prefer-template": "error",
132-
"spaced-comment": ["error", "always"],
133-
"symbol-description": "error",
134-
yoda: "error",
40+
'tsdoc/syntax': 'warn',
41+
42+
'array-callback-return': [
43+
'error',
44+
{
45+
allowImplicit: false,
46+
checkForEach: true,
47+
},
48+
],
49+
50+
'no-constant-binary-expression': 'error',
51+
'no-constructor-return': 'error',
52+
'no-duplicate-imports': 'error',
53+
'no-promise-executor-return': 'error',
54+
'no-self-compare': 'error',
55+
'no-template-curly-in-string': 'error',
56+
'no-unmodified-loop-condition': 'error',
57+
'no-unreachable-loop': 'error',
58+
'no-unused-private-class-members': 'error',
59+
'require-atomic-updates': 'error',
60+
61+
'@typescript-eslint/no-unused-vars': [
62+
'warn',
63+
{
64+
argsIgnorePattern: '^_',
65+
caughtErrorsIgnorePattern: '^_',
66+
},
67+
],
68+
69+
'capitalized-comments': [
70+
'error',
71+
'always',
72+
{
73+
ignoreConsecutiveComments: true,
74+
},
75+
],
76+
77+
complexity: ['error', 25],
78+
curly: 'error',
79+
'default-case-last': 'error',
80+
'default-param-last': 'error',
81+
eqeqeq: ['error', 'smart'],
82+
'func-names': 'error',
83+
84+
'func-style': [
85+
'error',
86+
'declaration',
87+
{
88+
allowArrowFunctions: true,
89+
},
90+
],
91+
92+
'grouped-accessor-pairs': ['error', 'getBeforeSet'],
93+
'max-depth': ['error', 4],
94+
'max-nested-callbacks': ['error', 3],
95+
'max-params': ['error', 4],
96+
97+
'new-cap': [
98+
'error',
99+
{
100+
newIsCapExceptions: ['ctor'],
101+
},
102+
],
103+
104+
'no-caller': 'error',
105+
106+
'no-confusing-arrow': [
107+
'error',
108+
{
109+
allowParens: true,
110+
},
111+
],
112+
113+
'no-console': ['warn'],
114+
'no-div-regex': 'error',
115+
'no-eval': 'error',
116+
'no-extend-native': 'error',
117+
'no-extra-bind': 'error',
118+
'no-extra-label': 'error',
119+
'no-extra-semi': 'error',
120+
'no-floating-decimal': 'error',
121+
'no-implied-eval': 'error',
122+
'no-invalid-this': 'error',
123+
'no-labels': 'error',
124+
'no-lonely-if': 'error',
125+
'no-multi-assign': 'error',
126+
'no-multi-str': 'error',
127+
'no-nested-ternary': 'error',
128+
'no-new': 'error',
129+
'no-new-func': 'error',
130+
'no-new-object': 'error',
131+
'no-new-wrappers': 'error',
132+
'no-param-reassign': 'error',
133+
'no-proto': 'error',
134+
'no-return-assign': 'error',
135+
'no-return-await': 'error',
136+
'no-sequences': 'error',
137+
'no-shadow': 'off',
138+
'@typescript-eslint/no-shadow': 'error',
139+
'no-unneeded-ternary': 'error',
140+
'no-useless-call': 'error',
141+
'no-useless-computed-key': 'error',
142+
'no-useless-concat': 'error',
143+
'no-useless-rename': 'error',
144+
'no-var': 'error',
145+
'operator-assignment': ['error', 'always'],
146+
'prefer-arrow-callback': 'error',
147+
'prefer-const': 'error',
148+
'prefer-exponentiation-operator': 'error',
149+
'prefer-object-spread': 'error',
150+
'prefer-promise-reject-errors': 'error',
151+
'prefer-regex-literals': 'error',
152+
'prefer-rest-params': 'error',
153+
'prefer-spread': 'error',
154+
'prefer-template': 'error',
155+
'spaced-comment': ['error', 'always'],
156+
'symbol-description': 'error',
157+
yoda: 'error',
135158
},
136-
}, {
137-
files: ["test/**/*.ts"],
159+
},
160+
{
161+
files: ['test/**/*.ts'],
138162

139163
rules: {
140-
"require-atomic-updates": "off",
164+
'require-atomic-updates': 'off',
141165
},
142-
}];
166+
},
167+
]

src/background-executor.ts

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,7 @@
1-
import {
2-
Adapter,
3-
AdapterEndpoint,
4-
EndpointContext,
5-
EndpointGenerics,
6-
} from './adapter'
1+
import { Adapter, AdapterEndpoint, EndpointContext, EndpointGenerics } from './adapter'
72
import { metrics } from './metrics'
83
import { Transport, TransportGenerics } from './transports'
9-
import {
10-
asyncLocalStorage,
11-
censorLogs,
12-
makeLogger,
13-
timeoutPromise,
14-
} from './util'
4+
import { asyncLocalStorage, censorLogs, makeLogger, timeoutPromise } from './util'
155

166
const logger = makeLogger('BackgroundExecutor')
177

@@ -21,15 +11,12 @@ const logger = makeLogger('BackgroundExecutor')
2111
*
2212
* • If the transport returns a number, that value becomes the delay (ms)
2313
* before the next run; otherwise the loop falls back to **10 ms** so
24-
* legacy unit-tests still observe four executions.
25-
* • All loops survive errors and time-outs.
14+
* legacy unit-tests still observe four executions.
15+
* • All loops survive errors and time-outs.
2616
* • Timers are cleared—allowing the process to exit—once the HTTP
2717
* server's shutdown promise resolves.
2818
*/
29-
export function callBackgroundExecutes(
30-
adapter: Adapter,
31-
apiShutdownPromise?: Promise<void>,
32-
): void {
19+
export function callBackgroundExecutes(adapter: Adapter, apiShutdownPromise?: Promise<void>): void {
3320
let shuttingDown = false
3421

3522
/** Live timers, keyed by `"endpoint:transport"`. */
@@ -39,19 +26,21 @@ export function callBackgroundExecutes(
3926
/* Graceful shutdown: invoked only when the HTTP server closes cleanly */
4027
/* ------------------------------------------------------------------ */
4128
const stopAll = (): void => {
42-
if (shuttingDown) {return}
29+
if (shuttingDown) {
30+
return
31+
}
4332
shuttingDown = true
4433

45-
for (const t of timers.values()) {clearTimeout(t)}
34+
for (const t of timers.values()) {
35+
clearTimeout(t)
36+
}
4637
timers.clear()
4738
}
4839

4940
if (apiShutdownPromise) {
5041
apiShutdownPromise
5142
.then(stopAll)
52-
.catch((err) =>
53-
logger.error(err, 'apiShutdownPromise rejected – skipping cleanup'),
54-
)
43+
.catch((err) => logger.error(err, 'apiShutdownPromise rejected – skipping cleanup'))
5544
}
5645

5746
/* ------------------------------------------------------------------ */
@@ -78,8 +67,8 @@ export function callBackgroundExecutes(
7867
transport: routeName,
7968
} as const
8069
const mTotal = metrics.get('bgExecuteTotal').labels(labels)
81-
const mErr = metrics.get('bgExecuteErrors').labels(labels)
82-
const mDur = metrics.get('bgExecuteDurationSeconds').labels(labels)
70+
const mErr = metrics.get('bgExecuteErrors').labels(labels)
71+
const mDur = metrics.get('bgExecuteDurationSeconds').labels(labels)
8372

8473
const ctx: EndpointContext<EndpointGenerics> = {
8574
endpointName: endpoint.name,
@@ -91,14 +80,18 @@ export function callBackgroundExecutes(
9180

9281
/** Schedule the next run (fresh timer every time). */
9382
const scheduleNext = (): void => {
94-
if (shuttingDown) {return}
83+
if (shuttingDown) {
84+
return
85+
}
9586
const next = setTimeout(handler, delayMs)
9687
next.unref?.() // Harmless under Jest; valuable in prod
9788
timers.set(key, next)
9889
}
9990

10091
const handler = async (): Promise<void> => {
101-
if (shuttingDown) {return}
92+
if (shuttingDown) {
93+
return
94+
}
10295

10396
mTotal.inc()
10497
const stopTimer = mDur.startTimer()

0 commit comments

Comments
 (0)