Skip to content

Commit d3a3b66

Browse files
Required new error
1 parent 7291c99 commit d3a3b66

59 files changed

Lines changed: 148 additions & 145 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.oxlintrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@
7676
"typescript/no-base-to-string": "off",
7777
"typescript/restrict-template-expressions": "off",
7878
"typescript/unbound-method": "off",
79-
"unicorn/prefer-module": "warn"
79+
"unicorn/prefer-module": "warn",
80+
"unicorn/throw-new-error": "warn"
8081
},
8182
"overrides": [
8283
{

packages/app-neovim/cursorless.nvim/node/command-server/index/index.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ function injectCommandRunner(cmdRunner) {
272272
}
273273
function commandRunner() {
274274
if (cmdRunner_ == null) {
275-
throw Error("Tried to access CommandRunner before it was injected");
275+
throw new Error("Tried to access CommandRunner before it was injected");
276276
}
277277
return cmdRunner_;
278278
}

packages/app-vscode/src/ide/vscode/VscodeConfiguration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ function evaluateStringVariables(value: string): string {
7171
case "userHome":
7272
return os.homedir();
7373
default:
74-
throw Error(`Unknown vscode configuration variable '${variable}'`);
74+
throw new Error(`Unknown vscode configuration variable '${variable}'`);
7575
}
7676
});
7777
}

packages/app-vscode/src/ide/vscode/VscodeOpenLink.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export default async function vscodeOpenLink(
1717
);
1818

1919
if (filteredLinks.length > 1) {
20-
throw Error("Multiple links found at location");
20+
throw new Error("Multiple links found at location");
2121
}
2222

2323
if (filteredLinks.length === 0) {
@@ -61,7 +61,7 @@ async function getLinksForEditor(
6161

6262
function openLink(link: vscode.DocumentLink, openAside: boolean) {
6363
if (link.target == null) {
64-
throw Error("Document link is missing uri");
64+
throw new Error("Document link is missing uri");
6565
}
6666
return openUri(link.target, openAside);
6767
}
@@ -83,6 +83,6 @@ async function openUri(uri: vscode.Uri, openAside: boolean) {
8383
);
8484
break;
8585
default:
86-
throw Error(`Unknown uri scheme '${uri.scheme}'`);
86+
throw new Error(`Unknown uri scheme '${uri.scheme}'`);
8787
}
8888
}

packages/app-vscode/src/ide/vscode/toVscodeEditor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ export function toVscodeEditor(editor: TextEditor): vscode.TextEditor {
66
if ("vscodeEditor" in editor) {
77
return (editor as VscodeTextEditor).vscodeEditor;
88
}
9-
throw Error("Can't get vscode editor from non vscode implementation");
9+
throw new Error("Can't get vscode editor from non vscode implementation");
1010
}

packages/app-vscode/src/keyboard/KeyboardCommandsModalLayer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export class KeyboardCommandsModalLayer<Param extends { type: any }> {
5656
// character was a false start so we should cancel the whole thing.
5757
const errorMessage = `Invalid key '${text}'`;
5858
void vscode.window.showErrorMessage(errorMessage);
59-
throw Error(errorMessage);
59+
throw new Error(errorMessage);
6060
}
6161
}
6262

packages/app-vscode/src/keyboard/KeyboardCommandsTargeted.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ export default class KeyboardCommandsTargeted {
194194
case "editNew":
195195
case "getText":
196196
case "parsed":
197-
throw Error(`Unsupported keyboard action: ${name}`);
197+
throw new Error(`Unsupported keyboard action: ${name}`);
198198
case "replaceWithTarget":
199199
case "moveToTarget":
200200
return {

packages/app-vscode/src/scripts/populateDist/populateDist.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export async function run() {
3131
(source == null && generateContent == null) ||
3232
(source != null && generateContent != null)
3333
) {
34-
throw Error(
34+
throw new Error(
3535
"Must specify either `source` or `generateContent`, but not both",
3636
);
3737
}
@@ -56,7 +56,7 @@ export async function run() {
5656

5757
if (!(await exists(fullSource))) {
5858
if (context.isCi || !optionalInDev) {
59-
throw Error(`Missing asset: ${fullSource}`);
59+
throw new Error(`Missing asset: ${fullSource}`);
6060
}
6161
console.warn(`Missing asset: ${fullSource}`);
6262
return;

packages/app-web-docs/src/docs/components/util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export function getFacetInfo(
5252
: scopeSupportFacetInfos[facetId as ScopeSupportFacet];
5353

5454
if (facetInfo == null) {
55-
throw Error(`Missing scope support facet info for: ${facetId}`);
55+
throw new Error(`Missing scope support facet info for: ${facetId}`);
5656
}
5757

5858
return facetInfo;

packages/app-web-docs/src/plugins/scope-tests-plugin.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ function parseTest(test: ScopeTestPath) {
6262
const delimiterIndex = fixture.match(/^---$/m)?.index;
6363

6464
if (delimiterIndex === undefined) {
65-
throw Error(`Can't find delimiter '---' in scope fixture ${test.path}`);
65+
throw new Error(`Can't find delimiter '---' in scope fixture ${test.path}`);
6666
}
6767

6868
const code = fixture.slice(0, delimiterIndex - 1);
@@ -104,7 +104,7 @@ function parseTest(test: ScopeTestPath) {
104104
// Do nothing
105105
break;
106106
default:
107-
throw Error(`Unknown type '${type}' in scope fixture ${test.path}`);
107+
throw new Error(`Unknown type '${type}' in scope fixture ${test.path}`);
108108
}
109109
}
110110

@@ -147,10 +147,12 @@ function parseTest(test: ScopeTestPath) {
147147
scopes.push(currentScope);
148148

149149
if (scopes.some((s) => s.targets.some((t) => !t.content))) {
150-
throw Error(`Scope fixture ${test.path} contains targets without content.`);
150+
throw new Error(
151+
`Scope fixture ${test.path} contains targets without content.`,
152+
);
151153
}
152154
if (scopes.some((s) => s.targets.length === 0)) {
153-
throw Error(`Scope fixture ${test.path} contains empty scopes.`);
155+
throw new Error(`Scope fixture ${test.path} contains empty scopes.`);
154156
}
155157

156158
const result: Fixture = {

0 commit comments

Comments
 (0)