Skip to content

Commit 0fa2b3d

Browse files
Copilothotlong
andcommitted
refactor: enable ESLint Wave 1 rules (prefer-const, no-useless-catch, no-empty) and fix all violations
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 6fbfde8 commit 0fa2b3d

10 files changed

Lines changed: 19 additions & 26 deletions

File tree

eslint.config.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ export default tseslint.config(
1515
"@typescript-eslint/no-empty-object-type": "off",
1616
"no-case-declarations": "off",
1717
"no-useless-escape": "off",
18-
"prefer-const": "off",
19-
"no-empty": "off",
18+
"prefer-const": "error",
19+
"no-empty": "warn",
2020
"no-undef": "off",
21-
"no-useless-catch": "off",
21+
"no-useless-catch": "error",
2222
"@typescript-eslint/no-this-alias": "off",
2323
"@typescript-eslint/no-unsafe-function-type": "off"
2424
}

packages/drivers/memory/src/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ export class MemoryDriver implements Driver {
345345
}
346346

347347
// Get all records for this object type
348-
let records: any[] = [];
348+
const records: any[] = [];
349349
for (const [key, value] of this.store.entries()) {
350350
if (key.startsWith(pattern)) {
351351
records.push(value);
@@ -422,7 +422,7 @@ export class MemoryDriver implements Driver {
422422
const pattern = `${objectName}:`;
423423

424424
// Get all records for this object type
425-
let records: any[] = [];
425+
const records: any[] = [];
426426
const recordKeys = new Map<string, string>();
427427

428428
for (const [key, record] of this.store.entries()) {
@@ -468,7 +468,7 @@ export class MemoryDriver implements Driver {
468468
const pattern = `${objectName}:`;
469469

470470
// Get all records for this object type
471-
let records: any[] = [];
471+
const records: any[] = [];
472472
const recordKeys = new Map<string, string>();
473473

474474
for (const [key, record] of this.store.entries()) {
@@ -554,7 +554,7 @@ export class MemoryDriver implements Driver {
554554
const pattern = `${objectName}:`;
555555

556556
// Get all records for this object type
557-
let records: any[] = [];
557+
const records: any[] = [];
558558
for (const [key, value] of this.store.entries()) {
559559
if (key.startsWith(pattern)) {
560560
records.push({ ...value });

packages/drivers/redis/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,8 +1175,8 @@ export class RedisDriver implements Driver {
11751175
return true;
11761176
}
11771177

1178-
let conditions: boolean[] = [];
1179-
let operators: string[] = [];
1178+
const conditions: boolean[] = [];
1179+
const operators: string[] = [];
11801180

11811181
for (const item of filters) {
11821182
if (typeof item === 'string') {

packages/drivers/sql/src/index.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,9 @@ export class SqlDriver implements Driver {
139139
const field = this.mapSortField(fieldRaw);
140140
// Handle specific operators that map to different knex methods
141141
const apply = (b: any) => {
142-
let method = nextJoin === 'or' ? 'orWhere' : 'where';
143-
let methodIn = nextJoin === 'or' ? 'orWhereIn' : 'whereIn';
144-
let methodNotIn = nextJoin === 'or' ? 'orWhereNotIn' : 'whereNotIn';
142+
const method = nextJoin === 'or' ? 'orWhere' : 'where';
143+
const methodIn = nextJoin === 'or' ? 'orWhereIn' : 'whereIn';
144+
const methodNotIn = nextJoin === 'or' ? 'orWhereNotIn' : 'whereNotIn';
145145

146146
// Fix for 'contains' mapping
147147
if (op === 'contains') {
@@ -857,7 +857,7 @@ export class SqlDriver implements Driver {
857857
const config = this.config;
858858
const connection = config.connection;
859859
let dbName = '';
860-
let adminConfig = { ...config };
860+
const adminConfig = { ...config };
861861

862862
if (typeof connection === 'string') {
863863
const url = new URL(connection);
@@ -872,8 +872,6 @@ export class SqlDriver implements Driver {
872872
const adminKnex = knex(adminConfig);
873873
try {
874874
await adminKnex.raw(`CREATE DATABASE "${dbName}"`);
875-
} catch (e: any) {
876-
throw e;
877875
} finally {
878876
await adminKnex.destroy();
879877
}

packages/foundation/core/src/app.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -286,12 +286,7 @@ export class ObjectQL implements IObjectQL {
286286
return callback(ctx);
287287
}
288288

289-
let trx: any;
290-
try {
291-
trx = await driver.beginTransaction();
292-
} catch (e) {
293-
throw e;
294-
}
289+
const trx: any = await driver.beginTransaction();
295290

296291
const trxCtx: ObjectQLContext = {
297292
...ctx,

packages/foundation/platform-node/src/module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export async function loadModules(loader: ObjectLoader, modules: string[]) {
4949
packageRoot = currentDir;
5050
break;
5151
}
52-
} catch (e) {}
52+
} catch (_e) { /* package.json parse error — skip directory */ }
5353
}
5454
currentDir = path.dirname(currentDir);
5555
}

packages/foundation/plugin-workflow/__tests__/state-machine-engine.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ describe('StateMachineEngine', () => {
313313
const engine = new StateMachineEngine(config, guardEvaluator, actionExecutor);
314314

315315
// Transition within compound state using absolute path
316-
let result = await engine.transition('editing.draft', 'editing.review', {
316+
const result = await engine.transition('editing.draft', 'editing.review', {
317317
record: { status: 'editing.draft' },
318318
operation: 'update',
319319
});

packages/protocols/graphql/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1115,7 +1115,7 @@ export class GraphQLPlugin implements RuntimePlugin {
11151115
}
11161116

11171117
// Handle cursor-based pagination
1118-
let limit = args.first || args.last || 20;
1118+
const limit = args.first || args.last || 20;
11191119
let offset = 0;
11201120

11211121
if (args.after) {

packages/tools/create/src/bin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ program
9898
// 5. Initialize Git
9999
try {
100100
await fs.writeFile(path.join(root, '.gitignore'), `node_modules/\ndist/\n*.log\n.DS_Store\n*.sqlite3\n.env\n.env.local\n`);
101-
} catch {}
101+
} catch (_e) { /* .gitignore write failure is non-critical */ }
102102

103103
console.log(chalk.green('\n✅ Done! Now run:\n'));
104104
console.log(chalk.cyan(` cd ${targetDir}`));

packages/tools/vscode-objectql/src/commands/createFile.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export async function createNewFile(
9393
function getTemplate(context: vscode.ExtensionContext, fileType: string, name: string): string {
9494
try {
9595
// Look for templates in the 'templates' folder at the root of the extension
96-
let templatePath = vscode.Uri.joinPath(context.extensionUri, 'templates', `${fileType}.template.yml`).fsPath;
96+
const templatePath = vscode.Uri.joinPath(context.extensionUri, 'templates', `${fileType}.template.yml`).fsPath;
9797

9898
if (fs.existsSync(templatePath)) {
9999
let content = fs.readFileSync(templatePath, 'utf8');

0 commit comments

Comments
 (0)