Skip to content

Commit ed75ea2

Browse files
committed
fix: ESLint errors in config and editable-json
- Fix import sort order in config.test.mts (promises as fs sorted by alias name) - Add no-await-in-loop eslint-disable comments for retry loops in editable-json.mts - Remove unused eslint-disable directive
1 parent b3b4bf4 commit ed75ea2

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

src/utils/config.mts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ export function updateConfigValue<Key extends keyof LocalConfig>(
381381
// Note: We need to handle deletions explicitly since editor.update() only merges.
382382
// First, get all keys from the existing content.
383383
const existingKeys = new Set(
384-
Object.keys(editor.content).filter(k => typeof k === 'string')
384+
Object.keys(editor.content).filter(k => typeof k === 'string'),
385385
)
386386
const newKeys = new Set(Object.keys(configToSave))
387387

@@ -410,8 +410,11 @@ export function updateConfigValue<Key extends keyof LocalConfig>(
410410
}
411411

412412
// Stringify with formatting preserved.
413-
const jsonContent = JSON.stringify(contentToSave, undefined, indent)
414-
.replace(/\n/g, newline)
413+
const jsonContent = JSON.stringify(
414+
contentToSave,
415+
undefined,
416+
indent,
417+
).replace(/\n/g, newline)
415418
writeFileSync(
416419
configFilePath,
417420
Buffer.from(jsonContent + newline).toString('base64'),

src/utils/config.test.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import {
2+
promises as fs,
23
mkdtempSync,
34
readFileSync,
45
rmSync,
56
writeFileSync,
6-
promises as fs,
77
} from 'node:fs'
88
import os from 'node:os'
99
import path from 'node:path'

src/utils/editable-json.mts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ function detectNewline(json: string): string {
6161
return match ? match[0] : '\n'
6262
}
6363

64-
6564
/**
6665
* Sort object keys alphabetically.
6766
* Creates a new object with sorted keys (does not mutate input).
@@ -159,12 +158,13 @@ async function retryWrite(
159158
): Promise<void> {
160159
for (let attempt = 0; attempt <= retries; attempt++) {
161160
try {
161+
// eslint-disable-next-line no-await-in-loop
162162
await fs.writeFile(filepath, content)
163163
if (process.platform === 'win32') {
164+
// eslint-disable-next-line no-await-in-loop
164165
await setTimeout(50)
165166
let accessRetries = 0
166167
const maxAccessRetries = 5
167-
// eslint-disable-next-line no-await-in-loop
168168
while (accessRetries < maxAccessRetries) {
169169
try {
170170
// eslint-disable-next-line no-await-in-loop
@@ -211,6 +211,7 @@ async function readFile(filepath: string): Promise<string> {
211211
const maxRetries = process.platform === 'win32' ? 5 : 1
212212
for (let attempt = 0; attempt <= maxRetries; attempt++) {
213213
try {
214+
// eslint-disable-next-line no-await-in-loop
214215
return await fs.readFile(filepath, 'utf8')
215216
} catch (err) {
216217
const isLastAttempt = attempt === maxRetries

0 commit comments

Comments
 (0)