Skip to content

Commit 6ce783f

Browse files
committed
chore(eslint): require block statements via curly: all
Adds the `curly: ["error", "all"]` ESLint rule so single-line bodies on `if`/`else`/`for`/`while` must be wrapped in `{ }`. Runs `eslint --fix` + `oxfmt` over the affected files (8 packages, 25 sources).
1 parent e961715 commit 6ce783f

26 files changed

Lines changed: 178 additions & 59 deletions

.eslintrc.cjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ module.exports = {
2424
"@typescript-eslint/no-empty-interfaces": "off",
2525
// For doc purposes, prefer interfaces
2626
"@typescript-eslint/consistent-type-definitions": ["error", "interface"],
27+
curly: ["error", "all"],
2728
},
2829
overrides: [
2930
{

packages/agents/src/tools/imageToText.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ export const imageToTextTool: Tool = {
1212
],
1313
call: async (input, inference) => {
1414
const data = await input;
15-
if (typeof data === "string") throw "Input must be a blob.";
15+
if (typeof data === "string") {
16+
throw "Input must be a blob.";
17+
}
1618

1719
return (
1820
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion

packages/agents/src/tools/speechToText.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ export const speechToTextTool: Tool = {
1212
],
1313
call: async (input, inference) => {
1414
const data = await input;
15-
if (typeof data === "string") throw "Input must be a blob.";
15+
if (typeof data === "string") {
16+
throw "Input must be a blob.";
17+
}
1618

1719
return (
1820
await inference.automaticSpeechRecognition({

packages/agents/src/tools/textToImage.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ export const textToImageTool: Tool = {
1717
],
1818
call: async (input, inference) => {
1919
const data = await input;
20-
if (typeof data !== "string") throw "Input must be a string.";
20+
if (typeof data !== "string") {
21+
throw "Input must be a string.";
22+
}
2123

2224
return await inference.textToImage({
2325
inputs: data,

packages/agents/src/tools/textToSpeech.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ export const textToSpeechTool: Tool = {
1717
],
1818
call: async (input, inference) => {
1919
const data = await input;
20-
if (typeof data !== "string") throw "Input must be a string.";
20+
if (typeof data !== "string") {
21+
throw "Input must be a string.";
22+
}
2123

2224
return inference.textToSpeech({
2325
inputs: data,

packages/gguf/scripts/generate-llm.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,9 @@ async function main() {
188188
const tensorMatched = line.match(/LLM_TENSOR_[A-Z0-9_]+[,\s]+"(?<name>.+?)"/);
189189
if (tensorMatched?.groups) {
190190
const arch = archList.find((a) => a.cppConst === currCppConst);
191-
if (arch) arch.tensorNames.push(tensorMatched.groups.name);
191+
if (arch) {
192+
arch.tensorNames.push(tensorMatched.groups.name);
193+
}
192194
}
193195
}
194196

packages/hub/cli.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ class UploadProgressManager {
3838
}
3939

4040
async initialize(): Promise<void> {
41-
if (this.isQuiet) return;
41+
if (this.isQuiet) {
42+
return;
43+
}
4244

4345
try {
4446
const cliProgress = await import("cli-progress");
@@ -60,7 +62,9 @@ class UploadProgressManager {
6062
}
6163

6264
handleEvent(event: CommitProgressEvent): void {
63-
if (this.isQuiet) return;
65+
if (this.isQuiet) {
66+
return;
67+
}
6468

6569
if (event.event === "phase") {
6670
this.logPhase(event.phase);
@@ -70,7 +74,9 @@ class UploadProgressManager {
7074
}
7175

7276
private logPhase(phase: string): void {
73-
if (this.isQuiet) return;
77+
if (this.isQuiet) {
78+
return;
79+
}
7480

7581
const phaseMessages = {
7682
preuploading: "📋 Preparing files for upload...",
@@ -82,7 +88,9 @@ class UploadProgressManager {
8288
}
8389

8490
private updateFileProgress(path: string, progress: number, state: string): void {
85-
if (this.isQuiet) return;
91+
if (this.isQuiet) {
92+
return;
93+
}
8694

8795
if (this.cliProgressAvailable && this.multibar) {
8896
// Use progress bars
@@ -124,7 +132,9 @@ class UploadProgressManager {
124132
}
125133

126134
private truncateFilename(filename: string, maxLength: number): string {
127-
if (filename.length <= maxLength) return filename;
135+
if (filename.length <= maxLength) {
136+
return filename;
137+
}
128138
return "..." + filename.slice(-(maxLength - 3));
129139
}
130140

packages/hub/src/lib/cache-management.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ export interface HFCacheInfo {
7070
}
7171

7272
export async function scanCacheDir(cacheDir: string | undefined = undefined): Promise<HFCacheInfo> {
73-
if (!cacheDir) cacheDir = getHFHubCachePath();
73+
if (!cacheDir) {
74+
cacheDir = getHFHubCachePath();
75+
}
7476

7577
const s = await stat(cacheDir);
7678
if (!s.isDirectory()) {
@@ -85,7 +87,9 @@ export async function scanCacheDir(cacheDir: string | undefined = undefined): Pr
8587
const directories = await readdir(cacheDir);
8688
for (const repo of directories) {
8789
// skip .locks folder
88-
if (repo === ".locks") continue;
90+
if (repo === ".locks") {
91+
continue;
92+
}
8993

9094
// get the absolute path of the repo
9195
const absolute = join(cacheDir, repo);
@@ -144,7 +148,9 @@ export async function scanCachedRepo(repoPath: string): Promise<CachedRepoInfo>
144148

145149
const snapshotDirs = await readdir(snapshotsPath);
146150
for (const dir of snapshotDirs) {
147-
if (FILES_TO_IGNORE.includes(dir)) continue; // Ignore unwanted files
151+
if (FILES_TO_IGNORE.includes(dir)) {
152+
continue;
153+
} // Ignore unwanted files
148154

149155
const revisionPath = join(snapshotsPath, dir);
150156
const revisionStat = await stat(revisionPath);
@@ -205,7 +211,9 @@ export async function scanRefsDir(refsPath: string, refsByHash: Map<string, stri
205211
const refFiles = await readdir(refsPath, { withFileTypes: true });
206212
for (const refFile of refFiles) {
207213
const refFilePath = join(refsPath, refFile.name);
208-
if (refFile.isDirectory()) continue; // Skip directories
214+
if (refFile.isDirectory()) {
215+
continue;
216+
} // Skip directories
209217

210218
const commitHash = await readFile(refFilePath, "utf-8");
211219
const refName = refFile.name;
@@ -223,7 +231,9 @@ export async function scanSnapshotDir(
223231
): Promise<void> {
224232
const files = await readdir(revisionPath, { withFileTypes: true });
225233
for (const file of files) {
226-
if (file.isDirectory()) continue; // Skip directories
234+
if (file.isDirectory()) {
235+
continue;
236+
} // Skip directories
227237

228238
const filePath = join(revisionPath, file.name);
229239
const blobPath = await realpath(filePath);

packages/hub/src/lib/download-file-to-cache-dir.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ export async function downloadFileToCacheDir(
7979
if (revision && REGEX_COMMIT_HASH.test(revision)) {
8080
commitHash = revision;
8181
const pointerPath = getFilePointer(storageFolder, revision, params.path);
82-
if (await exists(pointerPath, true)) return pointerPath;
82+
if (await exists(pointerPath, true)) {
83+
return pointerPath;
84+
}
8385
}
8486

8587
const pathsInformation: PathInfo[] = await pathsInfo({
@@ -88,7 +90,9 @@ export async function downloadFileToCacheDir(
8890
revision,
8991
expand: true,
9092
});
91-
if (!pathsInformation || pathsInformation.length !== 1) throw new Error(`cannot get path info for ${params.path}`);
93+
if (!pathsInformation || pathsInformation.length !== 1) {
94+
throw new Error(`cannot get path info for ${params.path}`);
95+
}
9296

9397
const info = pathsInformation[0];
9498
let etag: string;

packages/hub/src/lib/jobs/stream-job-events.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ export async function* streamJobEvents(
5151
try {
5252
while (true) {
5353
const { done, value } = await reader.read();
54-
if (done) break;
54+
if (done) {
55+
break;
56+
}
5557

5658
buffer += decoder.decode(value, { stream: true });
5759
const lines = buffer.split("\n");

0 commit comments

Comments
 (0)