Skip to content

Commit 13384ec

Browse files
Copilothotlong
andcommitted
fix: wrap case blocks with lexical declarations in braces to fix no-case-declarations violations
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 0fa2b3d commit 13384ec

6 files changed

Lines changed: 84 additions & 29 deletions

File tree

eslint.config.mjs.bak

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import eslint from '@eslint/js';
2+
import tseslint from 'typescript-eslint';
3+
4+
export default tseslint.config(
5+
eslint.configs.recommended,
6+
...tseslint.configs.recommended,
7+
{
8+
ignores: ["**/dist/**", "**/node_modules/**", "**/*.js", "**/out/**", "**/generated/**", "**/*.d.ts", "**/templates/**"],
9+
},
10+
{
11+
rules: {
12+
"@typescript-eslint/no-explicit-any": "off",
13+
"@typescript-eslint/no-unused-vars": "off",
14+
"@typescript-eslint/no-require-imports": "off",
15+
"@typescript-eslint/no-empty-object-type": "off",
16+
"no-case-declarations": "off",
17+
"no-useless-escape": "off",
18+
"prefer-const": "error",
19+
"no-empty": "warn",
20+
"no-undef": "off",
21+
"no-useless-catch": "error",
22+
"@typescript-eslint/no-this-alias": "off",
23+
"@typescript-eslint/no-unsafe-function-type": "off"
24+
}
25+
}
26+
);

packages/drivers/memory/src/index.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,7 +1083,7 @@ export class MemoryDriver implements Driver {
10831083
const cmdOptions = { ...options, ...command.options };
10841084

10851085
switch (command.type) {
1086-
case 'create':
1086+
case 'create': {
10871087
if (!command.data) {
10881088
throw new ObjectQLError({ code: 'DRIVER_QUERY_FAILED', message: 'Create command requires data' });
10891089
}
@@ -1093,8 +1093,9 @@ export class MemoryDriver implements Driver {
10931093
data: created,
10941094
affected: 1
10951095
};
1096+
}
10961097

1097-
case 'update':
1098+
case 'update': {
10981099
if (!command.id || !command.data) {
10991100
throw new ObjectQLError({ code: 'DRIVER_QUERY_FAILED', message: 'Update command requires id and data' });
11001101
}
@@ -1104,6 +1105,7 @@ export class MemoryDriver implements Driver {
11041105
data: updated,
11051106
affected: 1
11061107
};
1108+
}
11071109

11081110
case 'delete':
11091111
if (!command.id) {
@@ -1115,7 +1117,7 @@ export class MemoryDriver implements Driver {
11151117
affected: 1
11161118
};
11171119

1118-
case 'bulkCreate':
1120+
case 'bulkCreate': {
11191121
if (!command.records || !Array.isArray(command.records)) {
11201122
throw new ObjectQLError({ code: 'DRIVER_QUERY_FAILED', message: 'BulkCreate command requires records array' });
11211123
}
@@ -1129,8 +1131,9 @@ export class MemoryDriver implements Driver {
11291131
data: bulkCreated,
11301132
affected: command.records.length
11311133
};
1134+
}
11321135

1133-
case 'bulkUpdate':
1136+
case 'bulkUpdate': {
11341137
if (!command.updates || !Array.isArray(command.updates)) {
11351138
throw new ObjectQLError({ code: 'DRIVER_QUERY_FAILED', message: 'BulkUpdate command requires updates array' });
11361139
}
@@ -1144,8 +1147,9 @@ export class MemoryDriver implements Driver {
11441147
data: updateResults,
11451148
affected: command.updates.length
11461149
};
1150+
}
11471151

1148-
case 'bulkDelete':
1152+
case 'bulkDelete': {
11491153
if (!command.ids || !Array.isArray(command.ids)) {
11501154
throw new ObjectQLError({ code: 'DRIVER_QUERY_FAILED', message: 'BulkDelete command requires ids array' });
11511155
}
@@ -1158,6 +1162,7 @@ export class MemoryDriver implements Driver {
11581162
success: true,
11591163
affected: deleted
11601164
};
1165+
}
11611166

11621167
default:
11631168
throw new ObjectQLError({ code: 'DRIVER_UNSUPPORTED_OPERATION', message: `Unknown command type: ${(command as any).type}` });

packages/drivers/mongo/src/index.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,7 @@ export class MongoDriver implements Driver {
822822
const cmdOptions = { ...options, ...command.options };
823823

824824
switch (command.type) {
825-
case 'create':
825+
case 'create': {
826826
if (!command.data) {
827827
throw new ObjectQLError({ code: 'DRIVER_QUERY_FAILED', message: 'Create command requires data' });
828828
}
@@ -832,8 +832,9 @@ export class MongoDriver implements Driver {
832832
data: created,
833833
affected: 1
834834
};
835+
}
835836

836-
case 'update':
837+
case 'update': {
837838
if (!command.id || !command.data) {
838839
throw new ObjectQLError({ code: 'DRIVER_QUERY_FAILED', message: 'Update command requires id and data' });
839840
}
@@ -843,8 +844,9 @@ export class MongoDriver implements Driver {
843844
data: updated,
844845
affected: updated ? 1 : 0
845846
};
847+
}
846848

847-
case 'delete':
849+
case 'delete': {
848850
if (!command.id) {
849851
throw new ObjectQLError({ code: 'DRIVER_QUERY_FAILED', message: 'Delete command requires id' });
850852
}
@@ -853,8 +855,9 @@ export class MongoDriver implements Driver {
853855
success: true,
854856
affected: deleteCount
855857
};
858+
}
856859

857-
case 'bulkCreate':
860+
case 'bulkCreate': {
858861
if (!command.records || !Array.isArray(command.records)) {
859862
throw new ObjectQLError({ code: 'DRIVER_QUERY_FAILED', message: 'BulkCreate command requires records array' });
860863
}
@@ -864,8 +867,9 @@ export class MongoDriver implements Driver {
864867
data: bulkCreated,
865868
affected: command.records.length
866869
};
870+
}
867871

868-
case 'bulkUpdate':
872+
case 'bulkUpdate': {
869873
if (!command.updates || !Array.isArray(command.updates)) {
870874
throw new ObjectQLError({ code: 'DRIVER_QUERY_FAILED', message: 'BulkUpdate command requires updates array' });
871875
}
@@ -881,8 +885,9 @@ export class MongoDriver implements Driver {
881885
data: updateResults,
882886
affected: updateCount
883887
};
888+
}
884889

885-
case 'bulkDelete':
890+
case 'bulkDelete': {
886891
if (!command.ids || !Array.isArray(command.ids)) {
887892
throw new ObjectQLError({ code: 'DRIVER_QUERY_FAILED', message: 'BulkDelete command requires ids array' });
888893
}
@@ -895,10 +900,12 @@ export class MongoDriver implements Driver {
895900
success: true,
896901
affected: deleted
897902
};
903+
}
898904

899-
default:
905+
default: {
900906
const validTypes = ['create', 'update', 'delete', 'bulkCreate', 'bulkUpdate', 'bulkDelete'];
901907
throw new ObjectQLError({ code: 'DRIVER_UNSUPPORTED_OPERATION', message: `Unknown command type: ${(command as any).type}. Valid types are: ${validTypes.join(', ')}` });
908+
}
902909
}
903910
} catch (error: any) {
904911
return {

packages/drivers/redis/src/index.ts

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ export class RedisDriver implements Driver {
791791
const cmdOptions = { ...options, ...command.options };
792792

793793
switch (command.type) {
794-
case 'create':
794+
case 'create': {
795795
if (!command.data) {
796796
throw new ObjectQLError({ code: 'DRIVER_QUERY_FAILED', message: 'Create command requires data' });
797797
}
@@ -801,8 +801,9 @@ export class RedisDriver implements Driver {
801801
data: created,
802802
affected: 1
803803
};
804+
}
804805

805-
case 'update':
806+
case 'update': {
806807
if (!command.id || !command.data) {
807808
throw new ObjectQLError({ code: 'DRIVER_QUERY_FAILED', message: 'Update command requires id and data' });
808809
}
@@ -812,6 +813,7 @@ export class RedisDriver implements Driver {
812813
data: updated,
813814
affected: 1
814815
};
816+
}
815817

816818
case 'delete':
817819
if (!command.id) {
@@ -823,7 +825,7 @@ export class RedisDriver implements Driver {
823825
affected: 1
824826
};
825827

826-
case 'bulkCreate':
828+
case 'bulkCreate': {
827829
if (!command.records || !Array.isArray(command.records)) {
828830
throw new ObjectQLError({ code: 'DRIVER_QUERY_FAILED', message: 'BulkCreate command requires records array' });
829831
}
@@ -852,8 +854,9 @@ export class RedisDriver implements Driver {
852854
data: bulkCreated,
853855
affected: command.records.length
854856
};
857+
}
855858

856-
case 'bulkUpdate':
859+
case 'bulkUpdate': {
857860
if (!command.updates || !Array.isArray(command.updates)) {
858861
throw new ObjectQLError({ code: 'DRIVER_QUERY_FAILED', message: 'BulkUpdate command requires updates array' });
859862
}
@@ -901,8 +904,9 @@ export class RedisDriver implements Driver {
901904
data: updateResults,
902905
affected: updateResults.length
903906
};
907+
}
904908

905-
case 'bulkDelete':
909+
case 'bulkDelete': {
906910
if (!command.ids || !Array.isArray(command.ids)) {
907911
throw new ObjectQLError({ code: 'DRIVER_QUERY_FAILED', message: 'BulkDelete command requires ids array' });
908912
}
@@ -923,6 +927,7 @@ export class RedisDriver implements Driver {
923927
success: true,
924928
affected: deleted
925929
};
930+
}
926931

927932
default:
928933
throw new ObjectQLError({ code: 'DRIVER_UNSUPPORTED_OPERATION', message: `Unknown command type: ${(command as any).type}` });
@@ -1372,18 +1377,21 @@ export class RedisDriver implements Driver {
13721377
return sum + (typeof value === 'number' ? value : 0);
13731378
}, 0);
13741379

1375-
case '$avg':
1380+
case '$avg': {
13761381
const values = records.map(rec => this.evaluateExpression(operand, rec));
13771382
const numbers = values.filter(v => typeof v === 'number');
13781383
return numbers.length > 0 ? numbers.reduce((a, b) => a + b, 0) / numbers.length : null;
1384+
}
13791385

1380-
case '$min':
1386+
case '$min': {
13811387
const minValues = records.map(rec => this.evaluateExpression(operand, rec));
13821388
return Math.min(...minValues.filter(v => typeof v === 'number'));
1389+
}
13831390

1384-
case '$max':
1391+
case '$max': {
13851392
const maxValues = records.map(rec => this.evaluateExpression(operand, rec));
13861393
return Math.max(...maxValues.filter(v => typeof v === 'number'));
1394+
}
13871395

13881396
case '$first':
13891397
return records.length > 0 ? this.evaluateExpression(operand, records[0]) : null;
@@ -1394,7 +1402,7 @@ export class RedisDriver implements Driver {
13941402
case '$push':
13951403
return records.map(rec => this.evaluateExpression(operand, rec));
13961404

1397-
case '$addToSet':
1405+
case '$addToSet': {
13981406
const set = new Set(records.map(rec => {
13991407
const val = this.evaluateExpression(operand, rec);
14001408
return typeof val === 'object' ? JSON.stringify(val) : val;
@@ -1409,6 +1417,7 @@ export class RedisDriver implements Driver {
14091417
}
14101418
return v;
14111419
});
1420+
}
14121421

14131422
default:
14141423
return null;

packages/drivers/sql/src/index.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -218,14 +218,16 @@ export class SqlDriver implements Driver {
218218
case '$lte':
219219
builder[method](field, '<=', opValue);
220220
break;
221-
case '$in':
221+
case '$in': {
222222
const methodIn = logicalOp === 'or' ? 'orWhereIn' : 'whereIn';
223223
builder[methodIn](field, opValue as any[]);
224224
break;
225-
case '$nin':
225+
}
226+
case '$nin': {
226227
const methodNotIn = logicalOp === 'or' ? 'orWhereNotIn' : 'whereNotIn';
227228
builder[methodNotIn](field, opValue as any[]);
228229
break;
230+
}
229231
case '$contains':
230232
builder[method](field, 'like', `%${opValue}%`);
231233
break;
@@ -1289,7 +1291,7 @@ export class SqlDriver implements Driver {
12891291
const cmdOptions = { ...options, ...command.options };
12901292

12911293
switch (command.type) {
1292-
case 'create':
1294+
case 'create': {
12931295
if (!command.data) {
12941296
throw new ObjectQLError({ code: 'DRIVER_QUERY_FAILED', message: 'Create command requires data' });
12951297
}
@@ -1299,8 +1301,9 @@ export class SqlDriver implements Driver {
12991301
data: created,
13001302
affected: 1
13011303
};
1304+
}
13021305

1303-
case 'update':
1306+
case 'update': {
13041307
if (!command.id || !command.data) {
13051308
throw new ObjectQLError({ code: 'DRIVER_QUERY_FAILED', message: 'Update command requires id and data' });
13061309
}
@@ -1310,6 +1313,7 @@ export class SqlDriver implements Driver {
13101313
data: updated,
13111314
affected: 1
13121315
};
1316+
}
13131317

13141318
case 'delete':
13151319
if (!command.id) {
@@ -1321,7 +1325,7 @@ export class SqlDriver implements Driver {
13211325
affected: 1
13221326
};
13231327

1324-
case 'bulkCreate':
1328+
case 'bulkCreate': {
13251329
if (!command.records || !Array.isArray(command.records)) {
13261330
throw new ObjectQLError({ code: 'DRIVER_QUERY_FAILED', message: 'BulkCreate command requires records array' });
13271331
}
@@ -1334,8 +1338,9 @@ export class SqlDriver implements Driver {
13341338
data: bulkCreated,
13351339
affected: command.records.length
13361340
};
1341+
}
13371342

1338-
case 'bulkUpdate':
1343+
case 'bulkUpdate': {
13391344
if (!command.updates || !Array.isArray(command.updates)) {
13401345
throw new ObjectQLError({ code: 'DRIVER_QUERY_FAILED', message: 'BulkUpdate command requires updates array' });
13411346
}
@@ -1350,8 +1355,9 @@ export class SqlDriver implements Driver {
13501355
data: updateResults,
13511356
affected: command.updates.length
13521357
};
1358+
}
13531359

1354-
case 'bulkDelete':
1360+
case 'bulkDelete': {
13551361
if (!command.ids || !Array.isArray(command.ids)) {
13561362
throw new ObjectQLError({ code: 'DRIVER_QUERY_FAILED', message: 'BulkDelete command requires ids array' });
13571363
}
@@ -1362,6 +1368,7 @@ export class SqlDriver implements Driver {
13621368
success: true,
13631369
affected: deleted || command.ids.length
13641370
};
1371+
}
13651372

13661373
default:
13671374
throw new ObjectQLError({ code: 'DRIVER_UNSUPPORTED_OPERATION', message: `Unknown command type: ${(command as any).type}` });

packages/foundation/core/src/optimizations/SQLQueryOptimizer.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,10 +272,11 @@ export class SQLQueryOptimizer {
272272
case '$lte':
273273
conditions.push(`${key} <= '${val}'`);
274274
break;
275-
case '$in':
275+
case '$in': {
276276
const inValues = (val as any[]).map(v => `'${v}'`).join(', ');
277277
conditions.push(`${key} IN (${inValues})`);
278278
break;
279+
}
279280
}
280281
}
281282
} else {

0 commit comments

Comments
 (0)