Skip to content

Commit ca19972

Browse files
committed
Lint samples, eslint remove comments
1 parent 9cbc5a5 commit ca19972

File tree

6 files changed

+23
-35
lines changed

6 files changed

+23
-35
lines changed

.eslintignore

-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@
44

55
node_modules
66
lib
7-
samples
87
spec/development

.eslintrc.json

+3-5
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
"plugins": ["@typescript-eslint", "prettier", "simple-import-sort"],
55
"extends": ["eslint:recommended", "plugin:@typescript-eslint/eslint-recommended", "plugin:@typescript-eslint/recommended", "prettier"],
66
"rules": {
7-
"no-useless-catch": "error", //TODO- Remove the unnecessary try-catch lines used and enable no-useless-catch rule.
8-
"prefer-rest-params": "off",
9-
"no-constant-condition": "error",
10-
// @typescript-eslint rules
117
"@typescript-eslint/no-empty-interface": "warn",
128
"@typescript-eslint/ban-types": "off",
139
"@typescript-eslint/no-unused-vars": "error",
@@ -155,7 +151,9 @@
155151
"@typescript-eslint/no-namespace": "off",
156152
"@typescript-eslint/no-parameter-properties": "off",
157153
"@typescript-eslint/no-array-constructor": "error",
158-
// eslint rules
154+
"no-useless-catch": "error",
155+
"prefer-rest-params": "off",
156+
"no-constant-condition": "error",
159157
"simple-import-sort/imports": "error",
160158
"brace-style": "error",
161159
"constructor-super": "error",

samples/tokenCredentialSamples/AuthenticationCodeFlow/src/index.ts

+11-13
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,17 @@
88
/**
99
* This sample is referenced from - https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/identity/identity/samples/manual/authorizationCodeSample.ts
1010
*/
11+
import "isomorphic-fetch";
12+
1113
import { AuthorizationCodeCredential } from "@azure/identity";
14+
import { Client } from "@microsoft/microsoft-graph-client";
15+
import { TokenCredentialAuthenticationProvider } from "@microsoft/microsoft-graph-client/authProviders/azureTokenCredentials";
1216
import express from "express";
1317
import { Server } from "http";
14-
import "isomorphic-fetch";
1518
import open from "open";
1619
import qs from "qs";
1720

18-
import { TokenCredentialAuthenticationProvider } from "@microsoft/microsoft-graph-client/authProviders/azureTokenCredentials";
19-
import { Client } from "@microsoft/microsoft-graph-client";
20-
import { port, tenantId, clientSecret, clientId, scopes, authorityHost, redirectUri } from "./secrets";
21+
import { authorityHost, clientId, clientSecret, port, redirectUri, scopes, tenantId } from "./secrets";
2122

2223
if (tenantId === undefined || clientId === undefined) {
2324
console.error("AZURE_TENANT_ID and AZURE_CLIENT_ID environment variables must be set");
@@ -40,8 +41,7 @@ async function getCredential(): Promise<AuthorizationCodeCredential> {
4041
// authentication redirect to be sent to the local redirect URI.
4142
const authCodePromise = new Promise<string>((resolve, reject) => {
4243
const app = express();
43-
let server: Server | undefined = undefined;
44-
44+
const server: Server = app.listen(port, () => console.log(`Authorization code redirect server listening on port ${port}`));
4545
app.get("/authresponse", (req, res) => {
4646
// Close the temporary server once we've received the redirect.
4747
res.sendStatus(200);
@@ -57,14 +57,12 @@ async function getCredential(): Promise<AuthorizationCodeCredential> {
5757
reject(new Error(`Authentication Error "${req.query["error"]}":\n\n${req.query["error_description"]}`));
5858
}
5959
});
60-
61-
server = app.listen(port, () => console.log(`Authorization code redirect server listening on port ${port}`));
6260
});
6361

6462
// Direct the user to the authentication URI either by opening a
6563
// browser (desktop and mobile apps) or redirecting their browser
6664
// using a Location header (web apps and APIs).
67-
const authorizeUrl = getAuthorizeUrl(tenantId!, clientId!, scopes);
65+
const authorizeUrl = getAuthorizeUrl(tenantId, clientId, scopes);
6866
console.log("Opening user's browser to URL:", authorizeUrl);
6967
await open(authorizeUrl);
7068

@@ -77,8 +75,8 @@ async function getCredential(): Promise<AuthorizationCodeCredential> {
7775
// refreshing the access token from this point forward.
7876
if (clientSecret) {
7977
return new AuthorizationCodeCredential(
80-
tenantId!,
81-
clientId!,
78+
tenantId,
79+
clientId,
8280
clientSecret,
8381
authorizationCode,
8482
redirectUri,
@@ -92,8 +90,8 @@ async function getCredential(): Promise<AuthorizationCodeCredential> {
9290
// NOTE: If there is no client secret, we can construct an auth code credential
9391
// using this method.
9492
return new AuthorizationCodeCredential(
95-
tenantId!,
96-
clientId!,
93+
tenantId,
94+
clientId,
9795
authorizationCode,
9896
redirectUri,
9997
// NOTE: It is not necessary to explicitly pass the authorityHost when using

samples/tokenCredentialSamples/ClientCredentialFlow/typescript/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { ClientSecretCredential } from "@azure/identity";
2-
31
import "isomorphic-fetch";
42

5-
import { TokenCredentialAuthenticationProvider } from "@microsoft/microsoft-graph-client/authProviders/azureTokenCredentials";
3+
import { ClientSecretCredential } from "@azure/identity";
64
import { Client } from "@microsoft/microsoft-graph-client";
5+
import { TokenCredentialAuthenticationProvider } from "@microsoft/microsoft-graph-client/authProviders/azureTokenCredentials";
6+
77
import { clientId, clientSecret, scopes, tenantId } from "./secrets";
88

99
async function runExample() {

src/GraphRequest.ts

+6-12
Original file line numberDiff line numberDiff line change
@@ -655,8 +655,7 @@ export class GraphRequest {
655655
this.setHeaderContentType();
656656
options.headers = this._headers;
657657
}
658-
const response = await this.send(url, options, callback);
659-
return response;
658+
return await this.send(url, options, callback);
660659
}
661660

662661
/**
@@ -686,8 +685,7 @@ export class GraphRequest {
686685
method: RequestMethod.PUT,
687686
body: serializeContent(content),
688687
};
689-
const response = await this.send(url, options, callback);
690-
return response;
688+
return await this.send(url, options, callback);
691689
}
692690

693691
/**
@@ -705,8 +703,7 @@ export class GraphRequest {
705703
method: RequestMethod.PATCH,
706704
body: serializeContent(content),
707705
};
708-
const response = await this.send(url, options, callback);
709-
return response;
706+
return await this.send(url, options, callback);
710707
}
711708

712709
/**
@@ -733,8 +730,7 @@ export class GraphRequest {
733730
const options: FetchOptions = {
734731
method: RequestMethod.DELETE,
735732
};
736-
const response = await this.send(url, options, callback);
737-
return response;
733+
return await this.send(url, options, callback);
738734
}
739735

740736
/**
@@ -761,8 +757,7 @@ export class GraphRequest {
761757
method: RequestMethod.GET,
762758
};
763759
this.responseType(ResponseType.STREAM);
764-
const stream = await this.send(url, options, callback);
765-
return stream;
760+
return await this.send(url, options, callback);
766761
}
767762

768763
/**
@@ -782,7 +777,6 @@ export class GraphRequest {
782777
},
783778
body: stream,
784779
};
785-
const response = await this.send(url, options, callback);
786-
return response;
780+
return await this.send(url, options, callback);
787781
}
788782
}

src/middleware/HTTPMessageHandler.ts

-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,5 @@ export class HTTPMessageHandler implements Middleware {
2727
*/
2828
public async execute(context: Context): Promise<void> {
2929
context.response = await fetch(context.request, context.options);
30-
return;
3130
}
3231
}

0 commit comments

Comments
 (0)