Skip to content

Commit 5bc60a7

Browse files
Merge pull request #12374 from gitbutlerapp/remove-extra-type-casts
Enable `@typescript-eslint/no-unnecessary-type-assertion`
2 parents 31f621f + 3cafb2b commit 5bc60a7

File tree

11 files changed

+21
-20
lines changed

11 files changed

+21
-20
lines changed

apps/desktop/src/lib/codegen/messages.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ export function formatMessages(
226226
} else if (payload.data.type === 'user') {
227227
const content = payload.data.message.content;
228228
if (Array.isArray(content) && content[0]!.type === 'tool_result') {
229-
const result = content[0]!;
229+
const result = content[0];
230230

231231
// Check if this is a response to an AskUserQuestion
232232
const askMessage = askUserQuestionToolCalls[result.tool_use_id];

apps/desktop/src/lib/irc/parser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ export function parseIRCMessage(line: string): IrcMessage {
472472
}
473473

474474
return {
475-
command: command as IrcMessage['command'],
475+
command: command,
476476
tags,
477477
prefix,
478478
params,

apps/desktop/src/lib/prompt/promptService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export class PromptService {
109109
abortHandle.abort('timeout');
110110
return null;
111111
})
112-
: <Promise<string | null>>new Promise(() => null)
112+
: new Promise<string | null>(() => null)
113113
])
114114
)
115115
);

apps/desktop/src/lib/utils/codegenTools.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ function formatAskUserQuestion(input: Record<string, any>): string {
172172
.filter(Boolean);
173173
const count = questionTexts.length;
174174
if (count === 1) {
175-
return `Question: ${truncate(questionTexts[0]!, 160)}`;
175+
return `Question: ${truncate(questionTexts[0], 160)}`;
176176
}
177177
const joined = questionTexts.join('; ');
178178
return `Questions (${count}): ${truncate(joined, 240)}`;

eslint.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export default ts.config(
4747
'@typescript-eslint/return-await': ['error', 'always'],
4848
'@typescript-eslint/promise-function-async': 'error',
4949
'@typescript-eslint/await-thenable': 'error',
50+
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
5051

5152
eqeqeq: ['error', 'always'],
5253
'import-x/no-cycle': 'error',

packages/no-relative-imports/src/paths.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export class ConfigPaths {
117117
for (const target of relativePaths) {
118118
if (!isHandledGlob(target)) continue;
119119
const entry = new PathEntry(configDirectory, key, target);
120-
this.paths[key]!.push(entry);
120+
this.paths[key].push(entry);
121121
}
122122
}
123123
}

packages/ui/src/lib/components/file/getFileIcon.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export function getFileIcon(fileName: string) {
66

77
// Check if fileName is directly an icon name
88
if (fileIcons[fileName]) {
9-
return fileIcons[fileName] as string;
9+
return fileIcons[fileName];
1010
}
1111

1212
const splitName = fileName.split('.');
@@ -31,7 +31,7 @@ export function getFileIcon(fileName: string) {
3131
}
3232
let icon = fileIcons[iconName];
3333
if (!icon) {
34-
icon = fileIcons['document'] as string;
34+
icon = fileIcons['document'];
3535
}
3636
return icon;
3737
}

packages/ui/src/lib/focus/focusManager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ export class FocusManager {
398398

399399
private handleFModeInput(event: KeyboardEvent): boolean {
400400
if (event.key === 'f' || event.key === 'F' || this.fModeManager.active) {
401-
return this.fModeManager.handleKeypress(event, this.nodeMap, this.currentNode!);
401+
return this.fModeManager.handleKeypress(event, this.nodeMap, this.currentNode);
402402
}
403403
return false;
404404
}

packages/ui/src/lib/richText/linewrap.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ function updateParagraphsWithWrappedLines(
215215

216216
// Update the first paragraph with the first wrapped line
217217
const children = paragraph.getChildren();
218-
const firstTextNode = children.find((child) => isTextNode(child)) as TextNode | undefined;
218+
const firstTextNode = children.find((child) => isTextNode(child));
219219

220220
if (firstTextNode) {
221221
firstTextNode.setTextContent(wrappedLines[0]);
@@ -282,9 +282,9 @@ function repositionCursor(
282282
}
283283

284284
// Navigate to the target paragraph
285-
let currentPara: ParagraphNode | null = paragraph.getNextSibling() as ParagraphNode | null;
285+
let currentPara: ParagraphNode | null = paragraph.getNextSibling();
286286
for (let i = 1; i < targetLineIndex && currentPara; i++) {
287-
currentPara = currentPara.getNextSibling() as ParagraphNode | null;
287+
currentPara = currentPara.getNextSibling();
288288
}
289289

290290
if (currentPara && $isParagraphNode(currentPara)) {

packages/ui/src/lib/utils/diffParsing.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -539,12 +539,12 @@ export type DiffLine = {
539539
export function encodeDiffLineRange(lineSelection: DiffLine[]): DiffLineRange | undefined {
540540
if (lineSelection.length === 0) return undefined;
541541
if (lineSelection.length === 1)
542-
return encodeSingleDiffLine(lineSelection[0]!.oldLine, lineSelection[0]!.newLine);
542+
return encodeSingleDiffLine(lineSelection[0].oldLine, lineSelection[0].newLine);
543543

544-
const firstLine = encodeSingleDiffLine(lineSelection[0]!.oldLine, lineSelection[0]!.newLine);
544+
const firstLine = encodeSingleDiffLine(lineSelection[0].oldLine, lineSelection[0].newLine);
545545
const lastLine = encodeSingleDiffLine(
546-
lineSelection[lineSelection.length - 1]!.oldLine,
547-
lineSelection[lineSelection.length - 1]!.newLine
546+
lineSelection[lineSelection.length - 1].oldLine,
547+
lineSelection[lineSelection.length - 1].newLine
548548
);
549549

550550
if (firstLine === undefined || lastLine === undefined) {
@@ -718,8 +718,8 @@ function computeBaseWordDiff(
718718
// Loop through every line in the section
719719
// We're only bothered with prev/next sections with equal # of lines changes
720720
for (let i = 0; i < numberOfLines; i++) {
721-
const oldLine = prevSection.lines[i] as Line;
722-
const newLine = nextSection.lines[i] as Line;
721+
const oldLine = prevSection.lines[i];
722+
const newLine = nextSection.lines[i];
723723
const prevSectionRow: BaseRow = {
724724
encodedLineId: encodeDiffFileLine(
725725
filename,
@@ -787,8 +787,8 @@ function computeBaseInlineWordDiff(
787787
// Loop through every line in the section
788788
// We're only bothered with prev/next sections with equal # of lines changes
789789
for (let i = 0; i < numberOfLines; i++) {
790-
const oldLine = prevSection.lines[i] as Line;
791-
const newLine = nextSection.lines[i] as Line;
790+
const oldLine = prevSection.lines[i];
791+
const newLine = nextSection.lines[i];
792792

793793
const sectionRow: BaseRow = {
794794
encodedLineId: encodeDiffFileLine(

0 commit comments

Comments
 (0)