Skip to content

Commit cf2f41f

Browse files
committed
👷 remove then check from the code
Issue: CLDSRV-860
1 parent 8981239 commit cf2f41f

File tree

3 files changed

+6
-18
lines changed

3 files changed

+6
-18
lines changed

.github/scripts/check-diff-async.mjs

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
/**
22
* Check that all new/modified functions in the current git diff use async/await.
3-
* Fails with exit code 1 if any additions introduce callback-style functions or .then() chains.
3+
* Fails with exit code 1 if any additions introduce callback-style functions.
44
*
55
* Usage: node scripts/check-diff-async.mjs
66
* In CI: runs against the current PR diff (files changed vs base branch)
77
*/
88
import { execSync } from 'node:child_process';
99
import { Project, SyntaxKind } from 'ts-morph';
1010

11-
const CALLBACK_PARAM_PATTERN = /^(cb|callback|next|done|err)$/i;
11+
const CALLBACK_PARAM_PATTERN = /^(cb|callback|next|done)$/i;
1212

1313
function getChangedJsFiles() {
1414
const base = process.env.GITHUB_BASE_REF
@@ -112,20 +112,6 @@ for (const sourceFile of project.getSourceFiles()) {
112112
});
113113
}
114114
}
115-
116-
const propertyAccesses = sourceFile.getDescendantsOfKind(SyntaxKind.PropertyAccessExpression);
117-
for (const access of propertyAccesses) {
118-
if (access.getName() !== 'then') continue;
119-
const line = access.getStartLineNumber();
120-
if (addedLines.has(line)) {
121-
violations.push({
122-
file: filePath,
123-
line,
124-
type: 'then-chain',
125-
detail: 'use await instead of .then()',
126-
});
127-
}
128-
}
129115
}
130116

131117
if (violations.length === 0) {
@@ -137,6 +123,6 @@ console.error(`✗ Found ${violations.length} async/await violation(s) in the di
137123
for (const v of violations) {
138124
console.error(` ${v.file}:${v.line} [${v.type}] ${v.detail}`);
139125
}
140-
console.error('\nNew code must use async/await instead of callbacks or .then() chains.');
126+
console.error('\nNew code must use async/await instead of callbacks.');
141127
console.error('See the async/await migration guide in CONTRIBUTING.md for help.');
142128
process.exit(1);

.github/scripts/count-async-functions.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ console.log('');
7474
console.log(`Migration: ${asyncFunctions}/${totalFunctions} functions (${migrationPercent}%)`);
7575

7676
if (process.env.GITHUB_STEP_SUMMARY) {
77-
const { writeFileSync, appendFileSync } = await import('node:fs');
77+
const { appendFileSync } = await import('node:fs');
7878
appendFileSync(process.env.GITHUB_STEP_SUMMARY, [
7979
'## Async/Await Migration Progress',
8080
'',

.github/workflows/tests.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ jobs:
8080
steps:
8181
- name: Checkout
8282
uses: actions/checkout@v4
83+
with:
84+
fetch-depth: 0
8385
- uses: actions/setup-node@v4
8486
with:
8587
node-version: '22'

0 commit comments

Comments
 (0)