Skip to content
This repository was archived by the owner on Oct 15, 2024. It is now read-only.

Commit 2fee251

Browse files
committed
Enable noUncheckedIndexedAccess.
1 parent 62a3add commit 2fee251

File tree

5 files changed

+20
-10
lines changed

5 files changed

+20
-10
lines changed

src/tools/lupdate.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,11 @@ function getTsPathForPylupdate(tool: Tool) {
4545
const matched = tool.args
4646
.join(' ')
4747
.match(/-ts\s+("(?<pathWithSpaces>[\S\s]+)"|(?<path>[\S]+))(\s+|$)/);
48-
if (matched?.groups)
49-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
50-
return path.dirname(matched.groups.pathWithSpaces ?? matched.groups.path);
48+
if (matched?.groups) {
49+
if (matched.groups.pathWithSpaces)
50+
return path.dirname(matched.groups.pathWithSpaces);
51+
if (matched.groups.path) return path.dirname(matched.groups.path);
52+
}
5153
return;
5254
}
5355

src/utils/error.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,6 @@ async function setToolPath(toolName: SupportedTool) {
8282
const toolUri = await vscode.window.showOpenDialog({
8383
canSelectMany: false,
8484
});
85-
if (!toolUri || toolUri.length === 0) return;
85+
if (!toolUri || !toolUri[0]) return;
8686
return new Tool(toolName).updatePath(toolUri[0].fsPath);
8787
}

src/utils/paths.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@ export function getExtensionPath() {
1111
}
1212

1313
export function getActiveWorkspaceFolderPath() {
14-
if (vscode.workspace.workspaceFolders)
15-
return vscode.workspace.workspaceFolders[0].uri.fsPath;
16-
return;
14+
if (
15+
!vscode.workspace.workspaceFolders ||
16+
!vscode.workspace.workspaceFolders[0]
17+
)
18+
return;
19+
return vscode.workspace.workspaceFolders[0].uri.fsPath;
1720
}
1821

1922
export function getActiveDocumentPath() {

src/utils/predefined-variable-resolver.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ interface PredefinedVariables {
2626

2727
class PredefinedVariableProvider implements PredefinedVariables {
2828
get workspaceFolder() {
29-
if (!vscode.workspace.workspaceFolders) return '';
29+
if (
30+
!vscode.workspace.workspaceFolders ||
31+
!vscode.workspace.workspaceFolders[0]
32+
)
33+
return '';
3034
return vscode.workspace.workspaceFolders[0].uri.fsPath;
3135
}
3236

@@ -83,7 +87,7 @@ class PredefinedVariableProvider implements PredefinedVariables {
8387
}
8488

8589
get selectedText() {
86-
if (vscode.workspace.textDocuments.length === 0) return '';
90+
if (!vscode.workspace.textDocuments[0]) return '';
8791
return vscode.workspace.textDocuments[0].getText(
8892
vscode.window.activeTextEditor?.selection
8993
);

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"strict": true,
1111
"noImplicitReturns": true,
1212
"noFallthroughCasesInSwitch": true,
13-
"noUnusedParameters": true
13+
"noUnusedParameters": true,
14+
"noUncheckedIndexedAccess": true
1415
},
1516
"exclude": ["node_modules", ".vscode-test"]
1617
}

0 commit comments

Comments
 (0)