Skip to content

Commit 0d99fbc

Browse files
committed
Re-adds single line statement (if) rules
1 parent b629ff9 commit 0d99fbc

File tree

8 files changed

+43
-8
lines changed

8 files changed

+43
-8
lines changed

eslint.config.mjs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export default ts.config(
2323
},
2424
rules: {
2525
'anti-trojan-source/no-bidi': 'error',
26+
curly: ['error', 'multi-line', 'consistent'],
2627
'no-constant-condition': ['warn', { checkLoops: false }],
2728
'no-constant-binary-expression': 'error',
2829
'no-caller': 'error',
@@ -44,6 +45,31 @@ export default ts.config(
4445
'no-mixed-spaces-and-tabs': 'off',
4546
'no-restricted-globals': ['error', 'process'],
4647
'no-restricted-imports': 'off',
48+
'no-restricted-syntax': [
49+
'error',
50+
{
51+
selector:
52+
'IfStatement:not(:has(BlockStatement)):not(:has(ReturnStatement)):not(:has(BreakStatement)):not(:has(ContinueStatement)):not(:has(YieldExpression)):not(:has(ThrowStatement))',
53+
message:
54+
'Single-line if statements are only allowed for control flow (return, break, continue, throw, yield).',
55+
},
56+
{
57+
selector: 'WhileStatement:not(:has(BlockStatement))',
58+
message: 'Single-line while statements are not allowed.',
59+
},
60+
{
61+
selector: 'ForStatement:not(:has(BlockStatement))',
62+
message: 'Single-line for statements are not allowed.',
63+
},
64+
{
65+
selector: 'ForInStatement:not(:has(BlockStatement))',
66+
message: 'Single-line for-in statements are not allowed.',
67+
},
68+
{
69+
selector: 'ForOfStatement:not(:has(BlockStatement))',
70+
message: 'Single-line for-of statements are not allowed.',
71+
},
72+
],
4773
'no-return-assign': 'error',
4874
'no-return-await': 'warn',
4975
'no-self-compare': 'error',

src/commands/quickCommand.steps.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1267,8 +1267,9 @@ export function* pickCommitsStep<
12671267
},
12681268
): StepResultGenerator<GitRevisionReference[]> {
12691269
async function getItems(log: GitLog | undefined) {
1270-
if (log == null)
1270+
if (log == null) {
12711271
return [createDirectiveQuickPickItem(Directive.Back, true), createDirectiveQuickPickItem(Directive.Cancel)];
1272+
}
12721273

12731274
const items = [];
12741275

src/plus/gk/account/subscriptionService.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,9 @@ export class SubscriptionService implements Disposable {
814814
window.onDidChangeWindowState,
815815
2,
816816
)(e => {
817-
if (e.focused) resolve(true);
817+
if (e.focused) {
818+
resolve(true);
819+
}
818820
}),
819821
),
820822
new Promise<boolean>(resolve =>

src/plus/integrations/providers/github/githubGitProvider.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3713,7 +3713,9 @@ export class GitHubGitProvider implements GitProvider, Disposable {
37133713
]);
37143714

37153715
ref = getSettledValue(branchResults)?.values[0]?.sha ?? getSettledValue(tagResults)?.values[0]?.sha;
3716-
if (ref == null) debugger;
3716+
if (ref == null) {
3717+
debugger;
3718+
}
37173719

37183720
return ref;
37193721
}

src/plus/launchpad/launchpadIndicator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ export class LaunchpadIndicator implements Disposable {
104104
private async maybeLoadData(forceIfConnected: boolean = false) {
105105
if (this.pollingEnabled) {
106106
if (await this.provider.hasConnectedIntegration()) {
107-
if (this._state === 'load' && this._categorizedItems != null && !forceIfConnected)
107+
if (this._state === 'load' && this._categorizedItems != null && !forceIfConnected) {
108108
this.updateStatusBarState('load', this._categorizedItems);
109-
else {
109+
} else {
110110
this.updateStatusBarState('loading');
111111
}
112112
} else {

src/plus/webviews/graph/graphWebview.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3695,8 +3695,9 @@ export class GraphWebviewProvider implements WebviewProvider<State, State, Graph
36953695

36963696
switch (refType) {
36973697
case 'branch':
3698-
if (!isGraphItemRefContext(item, 'branch') && !isGraphItemTypedContext(item, 'upstreamStatus'))
3698+
if (!isGraphItemRefContext(item, 'branch') && !isGraphItemTypedContext(item, 'upstreamStatus')) {
36993699
return { active: undefined, selection: [] };
3700+
}
37003701
break;
37013702
case 'revision':
37023703
if (!isGraphItemRefContext(item, 'revision')) return { active: undefined, selection: [] };

src/system/logger.scope.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,13 @@ export function getLogScope(): LogScope | undefined {
3333
}
3434

3535
export function getNewLogScope(prefix: string, scope: LogScope | boolean | undefined): LogScope {
36-
if (scope != null && typeof scope !== 'boolean')
36+
if (scope != null && typeof scope !== 'boolean') {
3737
return {
3838
scopeId: scope.scopeId,
3939
prevScopeId: scope.prevScopeId,
4040
prefix: `${scope.prefix}${prefix}`,
4141
};
42+
}
4243

4344
const prevScopeId = scope ? logScopeIdGenerator.current : undefined;
4445
const scopeId = logScopeIdGenerator.next();

tests/e2e/specs/baseTest.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ export const test = base.extend<TestFixtures>({
7575
tempDirs.push(tempDir);
7676
return tempDir;
7777
});
78-
for (const tempDir of tempDirs) await fs.promises.rm(tempDir, { recursive: true });
78+
for (const tempDir of tempDirs) {
79+
await fs.promises.rm(tempDir, { recursive: true });
80+
}
7981
},
8082
});

0 commit comments

Comments
 (0)