Browse Source

Adds eslint rule to enforce promise reject errors

main
Eric Amodio 1 year ago
parent
commit
b3600cb339
3 changed files with 4 additions and 4 deletions
  1. +2
    -4
      .eslintrc.base.json
  2. +1
    -0
      src/codelens/codeLensProvider.ts
  3. +1
    -0
      src/plus/subscription/serverConnection.ts

+ 2
- 4
.eslintrc.base.json View File

@ -46,7 +46,6 @@
"no-floating-decimal": "error",
"no-implicit-coercion": "error",
"no-implied-eval": "error",
// Turn off until fix for: https://github.com/typescript-eslint/typescript-eslint/issues/239
"no-inner-declarations": "off",
"no-lone-blocks": "error",
"no-lonely-if": "error",
@ -115,6 +114,7 @@
"no-throw-literal": "error",
"no-unmodified-loop-condition": "warn",
"no-unneeded-ternary": "error",
"no-unused-expressions": "error",
"no-use-before-define": "off",
"no-useless-call": "error",
"no-useless-catch": "error",
@ -136,6 +136,7 @@
],
"prefer-numeric-literals": "error",
"prefer-object-spread": "error",
"prefer-promise-reject-errors": ["error", { "allowEmptyReject": true }],
"prefer-rest-params": "error",
"prefer-spread": "error",
"prefer-template": "error",
@ -153,10 +154,7 @@
}
],
"yoda": "error",
"import/export": "off",
"import/extensions": ["error", "never"],
"import/named": "off",
"import/namespace": "off",
"import/newline-after-import": "warn",
"import/no-absolute-path": "error",
"import/no-cycle": "off",

+ 1
- 0
src/codelens/codeLensProvider.ts View File

@ -475,6 +475,7 @@ export class GitCodeLensProvider implements CodeLensProvider {
resolveCodeLens(lens: CodeLens, token: CancellationToken): CodeLens | Promise<CodeLens> {
if (lens instanceof GitRecentChangeCodeLens) return this.resolveGitRecentChangeCodeLens(lens, token);
if (lens instanceof GitAuthorsCodeLens) return this.resolveGitAuthorsCodeLens(lens, token);
// eslint-disable-next-line prefer-promise-reject-errors
return Promise.reject<CodeLens>(undefined);
}

+ 1
- 0
src/plus/subscription/serverConnection.ts View File

@ -142,6 +142,7 @@ export class ServerConnection implements Disposable {
return Promise.race([
deferredCodeExchange.promise,
new Promise<string>((_, reject) =>
// eslint-disable-next-line prefer-promise-reject-errors
this._cancellationSource?.token.onCancellationRequested(() => reject('Cancelled')),
),
new Promise<string>((_, reject) => setTimeout(reject, 120000, 'Cancelled')),

Loading…
Cancel
Save