Skip to content

Commit 64be874

Browse files
committed
fix: move external imports to top of file
1 parent 6688b8f commit 64be874

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

.github/workflows/types-codegen-pr.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ on:
66
- main
77
paths:
88
- 'types/codegen/schema/**'
9-
workflow_dispatch:
109

1110
jobs:
1211
validate-pr:
@@ -21,7 +20,6 @@ jobs:
2120
uses: actions/setup-node@v4
2221
with:
2322
node-version: '20.x'
24-
#should we cache: 'npm'
2523

2624
- name: Install root dependencies
2725
working-directory: .

types/codegen/custom-templates/typescript/index.mustache

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* tslint:disable */
2-
/* eslint-disable */
31
{{!This is a comment. Removed the export of runtimes because we do not need
42
those functions. Was causing error because exported a def called ResponseError
53
which is also used by vscode LSP}}

types/codegen/scripts/post-typescript.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,19 @@ const importResult = processImportMappings()
7878
// Read the generated index.ts file
7979
let indexContent = fs.readFileSync(indexPath, 'utf8')
8080

81-
// Find the position after existing imports
82-
const importEndPos = indexContent.lastIndexOf('import')
81+
// Find the insertion position - either at top of file or after lint disable comments
8382
let insertPos = 0
8483

85-
if (importEndPos !== -1) {
86-
insertPos = indexContent.indexOf('\n', importEndPos) + 1
84+
// Check if file starts with lint disable comments
85+
const lintDisablePattern = /^(\s*\/\*\s*tslint:disable\s*\*\/\s*\/\*\s*eslint-disable\s*\*\/\s*)/
86+
const lintDisableMatch = indexContent.match(lintDisablePattern)
87+
88+
if (lintDisableMatch) {
89+
// Insert after the lint disable comments
90+
insertPos = lintDisableMatch[0].length
91+
} else {
92+
// Insert at the very top of the file
93+
insertPos = 0
8794
}
8895

8996
// Insert import statements and constants after existing imports

0 commit comments

Comments
 (0)