Skip to content

Commit e592f09

Browse files
authored
[Axon 129] Add line rule for disallowing the use of var (#119)
* Add eslint rule: Require let or const instead of var * add prefer-const too * improvements * fixed file
1 parent fabd795 commit e592f09

File tree

95 files changed

+251
-243
lines changed

Some content is hidden

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

95 files changed

+251
-243
lines changed

.eslintrc.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,13 @@ module.exports = {
6060
"ignoreRestSiblings": false,
6161
}],
6262
'brace-style': 'off',
63+
'no-throw-literal': 'error',
64+
'no-var': 'error',
65+
'prefer-const': 'error',
6366
curly: 'error',
6467
eqeqeq: ['error', 'always'],
6568
semi: 'off',
6669
'@stylistic/js/semi': ['error', 'always'],
67-
'no-throw-literal': 'error',
6870
},
6971
settings: {
7072
react: {

e2e/tests/auth.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe('Auth User', async () => {
2626
after(async () => {});
2727

2828
it('in SideBarView should see Create issue... button', async () => {
29-
let atlasDrawer = sideBarView.findElement(By.id('workbench.view.extension.atlascode-drawer'));
29+
const atlasDrawer = sideBarView.findElement(By.id('workbench.view.extension.atlascode-drawer'));
3030
expect(atlasDrawer).to.not.be.undefined;
3131

3232
const createIssueButton = atlasDrawer.findElement(By.css('[aria-label="Create issue..."]'));

e2e/tests/no-auth.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ describe('Atlassian Extension SideBar', async () => {
4040
after(async () => {});
4141

4242
it('should have a login action suggestion', async () => {
43-
let atlasDrawer = sideBarView.findElement(By.id('workbench.view.extension.atlascode-drawer'));
43+
const atlasDrawer = sideBarView.findElement(By.id('workbench.view.extension.atlascode-drawer'));
4444
expect(atlasDrawer).to.not.be.undefined;
4545

4646
// find element by aria-label: "Please login to Jira"

src/analytics.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export async function launchedEvent(location: string): Promise<TrackEvent> {
5757
}
5858

5959
export async function featureChangeEvent(featureId: string, enabled: boolean): Promise<TrackEvent> {
60-
let action = enabled ? 'enabled' : 'disabled';
60+
const action = enabled ? 'enabled' : 'disabled';
6161
return trackEvent(action, 'feature', { actionSubjectId: featureId });
6262
}
6363

@@ -164,7 +164,7 @@ export async function prCommentEvent(site: DetailedSiteInfo): Promise<TrackEvent
164164
}
165165

166166
export async function prTaskEvent(site: DetailedSiteInfo, source: string): Promise<TrackEvent> {
167-
let attributesObject: any = instanceType({}, site);
167+
const attributesObject: any = instanceType({}, site);
168168
attributesObject.attributes.source = source;
169169
return trackEvent('created', 'pullRequestComment', attributesObject);
170170
}
@@ -590,7 +590,7 @@ async function instanceTrackEvent(
590590
actionSubject: string,
591591
eventProps: any = {},
592592
): Promise<TrackEvent> {
593-
let event: TrackEvent =
593+
const event: TrackEvent =
594594
site.isCloud && site.product.key === ProductJira.key
595595
? await tenantTrackEvent(site.id, action, actionSubject, instanceType(eventProps, site))
596596
: await trackEvent(action, actionSubject, instanceType(eventProps, site));
@@ -623,7 +623,7 @@ async function tenantTrackEvent(
623623
}
624624

625625
function event(action: string, actionSubject: string, attributes: any): any {
626-
var event = {
626+
const event = {
627627
origin: 'desktop',
628628
platform: AnalyticsPlatform.for(process.platform),
629629
action: action,
@@ -648,19 +648,18 @@ function anyUserOrAnonymous<T>(e: Object): T {
648648

649649
function tenantOrNull<T>(e: Object, tenantId?: string): T {
650650
let tenantType: string | null = 'cloudId';
651-
let newObj: Object;
652651

653652
if (!tenantId) {
654653
tenantType = null;
655654
}
656-
newObj = { ...e, ...{ tenantIdType: tenantType, tenantId: tenantId } };
657655

656+
const newObj: Object = { ...e, ...{ tenantIdType: tenantType, tenantId: tenantId } };
658657
return newObj as T;
659658
}
660659

661660
function instanceType(eventProps: Object, site?: DetailedSiteInfo, product?: Product): Object {
662661
let attrs: Object | undefined = undefined;
663-
let newObj = eventProps;
662+
const newObj = eventProps;
664663

665664
if (product) {
666665
attrs = { hostProduct: product.name };
@@ -679,7 +678,7 @@ function instanceType(eventProps: Object, site?: DetailedSiteInfo, product?: Pro
679678
}
680679

681680
function excludeFromActivity(eventProps: Object): Object {
682-
let newObj = eventProps;
681+
const newObj = eventProps;
683682

684683
if (newObj['attributes']) {
685684
newObj['attributes'] = { ...newObj['attributes'], ...{ excludeFromActivity: true } };

src/atlclients/authStore.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export class CredentialManager implements Disposable {
122122
): Promise<AuthInfo | undefined> {
123123
Logger.debug(`Retrieving auth info for product: ${site.product.key} credentialID: ${site.credentialId}`);
124124
let foundInfo: AuthInfo | undefined = undefined;
125-
let productAuths = this._memStore.get(site.product.key);
125+
const productAuths = this._memStore.get(site.product.key);
126126

127127
if (allowCache && productAuths && productAuths.has(site.credentialId)) {
128128
foundInfo = productAuths.get(site.credentialId);
@@ -275,7 +275,7 @@ export class CredentialManager implements Disposable {
275275
if (!authInfo) {
276276
return undefined;
277277
}
278-
let info: AuthInfo = JSON.parse(authInfo);
278+
const info: AuthInfo = JSON.parse(authInfo);
279279

280280
// When in doubt, assume credentials are valid
281281
if (info.state === undefined) {
@@ -309,7 +309,7 @@ export class CredentialManager implements Disposable {
309309
return undefined;
310310
}
311311

312-
let info: AuthInfo = JSON.parse(authInfo);
312+
const info: AuthInfo = JSON.parse(authInfo);
313313

314314
// When in doubt, assume credentials are valid
315315
if (info.state === undefined) {
@@ -330,7 +330,7 @@ export class CredentialManager implements Disposable {
330330
Logger.debug(`refreshingAccessToken for ${site.baseApiUrl} credentialID: ${site.credentialId}`);
331331

332332
const provider: OAuthProvider | undefined = oauthProviderForSite(site);
333-
let newTokens = undefined;
333+
const newTokens = undefined;
334334
if (provider && credentials) {
335335
const tokenResponse = await this._refresher.getNewTokens(provider, credentials.refresh);
336336
if (tokenResponse.tokens) {
@@ -356,7 +356,7 @@ export class CredentialManager implements Disposable {
356356
* Removes an auth item from both the in-memory store and the secretstorage.
357357
*/
358358
public async removeAuthInfo(site: DetailedSiteInfo): Promise<boolean> {
359-
let productAuths = this._memStore.get(site.product.key);
359+
const productAuths = this._memStore.get(site.product.key);
360360
let wasKeyDeleted = false;
361361
let wasMemDeleted = false;
362362
if (productAuths) {
@@ -371,7 +371,7 @@ export class CredentialManager implements Disposable {
371371
setCommandContext(cmdctx, false);
372372
}
373373

374-
let name = site.name;
374+
const name = site.name;
375375

376376
const removeEvent: RemoveAuthInfoEvent = {
377377
type: AuthChangeType.Remove,

src/atlclients/bitbucketAuthenticator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export class BitbucketAuthenticator implements Authenticator {
1414
let newSites: DetailedSiteInfo[] = [];
1515

1616
if (resources.length > 0) {
17-
let resource = resources[0];
17+
const resource = resources[0];
1818
const hostname = provider === OAuthProvider.BitbucketCloud ? 'bitbucket.org' : 'staging.bb-inf.net';
1919
const baseApiUrl =
2020
provider === OAuthProvider.BitbucketCloud

src/atlclients/jiraAuthenticator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export class JiraAuthentictor implements Authenticator {
1111
): Promise<DetailedSiteInfo[]> {
1212
let newSites: DetailedSiteInfo[] = [];
1313

14-
let apiUri = provider === OAuthProvider.JiraCloudStaging ? 'api.stg.atlassian.com' : 'api.atlassian.com';
14+
const apiUri = provider === OAuthProvider.JiraCloudStaging ? 'api.stg.atlassian.com' : 'api.atlassian.com';
1515

1616
//TODO: [VSCODE-505] call serverInfo endpoint when it supports OAuth
1717
//const baseUrlString = await getJiraCloudBaseUrl(`https://${apiUri}/ex/jira/${newResource.id}/rest/2`, authInfo.access);

src/atlclients/oauthDancer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export class OAuthDancer implements Disposable {
7777
}
7878

7979
private createApp(): any {
80-
let app = express();
80+
const app = express();
8181

8282
this.addPathForProvider(app, OAuthProvider.BitbucketCloud);
8383
this.addPathForProvider(app, OAuthProvider.BitbucketCloudStaging);

src/atlclients/responseHandlers/JiraPKCEResponseHandler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export class JiraPKCEResponseHandler extends ResponseHandler {
4848

4949
async user(accessToken: string, resource: AccessibleResource): Promise<UserInfo> {
5050
try {
51-
let apiUri = this.strategy.apiUrl();
51+
const apiUri = this.strategy.apiUrl();
5252
const url = `https://${apiUri}/ex/jira/${resource.id}/rest/api/2/myself`;
5353

5454
const userResponse = await this.axios(url, {

src/bitbucket/bbUtils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export function urlForRemote(remote: Remote): string {
9191
}
9292

9393
export async function clientForRemote(remote: Remote): Promise<BitbucketApi> {
94-
let site = siteDetailsForRemote(remote);
94+
const site = siteDetailsForRemote(remote);
9595

9696
if (site) {
9797
return await Container.clientManager.bbClient(site);
@@ -101,7 +101,7 @@ export async function clientForRemote(remote: Remote): Promise<BitbucketApi> {
101101
}
102102

103103
export async function clientForHostname(hostname: string): Promise<BitbucketApi> {
104-
let site = Container.siteManager.getSiteForHostname(ProductBitbucket, hostname);
104+
const site = Container.siteManager.getSiteForHostname(ProductBitbucket, hostname);
105105

106106
if (site) {
107107
return await Container.clientManager.bbClient(site);

0 commit comments

Comments
 (0)