Skip to content

Commit f93421d

Browse files
Vibe Botclaude
andcommitted
Fix S121 missing curly braces in S6775 decorator
Add curly braces to 4 single-statement if blocks in decorator.ts to comply with S121 (Expected { after 'if' condition). These were flagged by SonarQube external analysis. No functional changes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent a1371b9 commit f93421d

File tree

2 files changed

+62
-4
lines changed

2 files changed

+62
-4
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
[
2+
{
3+
"rule": "typescript:S121",
4+
"component": "org.sonarsource.javascript:javascript:packages/jsts/src/rules/S6775/decorator.ts",
5+
"line": 263,
6+
"message": "Expected { after 'if' condition.",
7+
"textRange": {
8+
"startLine": 263,
9+
"endLine": 263,
10+
"startOffset": 50,
11+
"endOffset": 59
12+
}
13+
},
14+
{
15+
"rule": "typescript:S121",
16+
"component": "org.sonarsource.javascript:javascript:packages/jsts/src/rules/S6775/decorator.ts",
17+
"line": 284,
18+
"message": "Expected { after 'if' condition.",
19+
"textRange": {
20+
"startLine": 284,
21+
"endLine": 284,
22+
"startOffset": 21,
23+
"endOffset": 38
24+
}
25+
},
26+
{
27+
"rule": "typescript:S121",
28+
"component": "org.sonarsource.javascript:javascript:packages/jsts/src/rules/S6775/decorator.ts",
29+
"line": 363,
30+
"message": "Expected { after 'if' condition.",
31+
"textRange": {
32+
"startLine": 363,
33+
"endLine": 363,
34+
"startOffset": 19,
35+
"endOffset": 36
36+
}
37+
},
38+
{
39+
"rule": "typescript:S121",
40+
"component": "org.sonarsource.javascript:javascript:packages/jsts/src/rules/S6775/decorator.ts",
41+
"line": 376,
42+
"message": "Expected { after 'if' condition.",
43+
"textRange": {
44+
"startLine": 376,
45+
"endLine": 376,
46+
"startOffset": 19,
47+
"endOffset": 36
48+
}
49+
}
50+
]

packages/jsts/src/rules/S6775/decorator.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,9 @@ function findExternalPropTypes(
260260

261261
// Search for ComponentName.propTypes = {...}
262262
for (const statement of program.body) {
263-
if (statement.type !== 'ExpressionStatement') continue;
263+
if (statement.type !== 'ExpressionStatement') {
264+
continue;
265+
}
264266

265267
const expr = statement.expression;
266268
if (
@@ -281,7 +283,9 @@ function findExternalPropTypes(
281283
const classInfo = extractClassDeclaration(statement);
282284
if (classInfo && classInfo.id?.name === componentName) {
283285
const propTypes = findStaticPropTypes(classInfo.body);
284-
if (propTypes) return propTypes;
286+
if (propTypes) {
287+
return propTypes;
288+
}
285289
}
286290
}
287291

@@ -360,7 +364,9 @@ function findPropTypesInStatement(
360364
/* istanbul ignore next - Factory function pattern rare in practice */
361365
if (statement.type === 'FunctionDeclaration' && statement.body) {
362366
const propTypes = findPropTypesInFunctionBody(statement.body, defaultPropsConstantName);
363-
if (propTypes) return propTypes;
367+
if (propTypes) {
368+
return propTypes;
369+
}
364370
}
365371

366372
// Check for exported functions
@@ -373,7 +379,9 @@ function findPropTypesInStatement(
373379
statement.declaration.body,
374380
defaultPropsConstantName,
375381
);
376-
if (propTypes) return propTypes;
382+
if (propTypes) {
383+
return propTypes;
384+
}
377385
}
378386

379387
return null;

0 commit comments

Comments
 (0)