Skip to content

Commit

Permalink
[chore] Apply more lint (#2509)
Browse files Browse the repository at this point in the history
  • Loading branch information
wschurman authored Aug 21, 2024
1 parent 2c8f9a6 commit 9b49fe3
Show file tree
Hide file tree
Showing 37 changed files with 163 additions and 107 deletions.
2 changes: 1 addition & 1 deletion packages/eas-cli/src/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module.exports = {
},
],
'@typescript-eslint/prefer-nullish-coalescing': ['warn', { ignorePrimitives: true }],
// '@typescript-eslint/no-confusing-void-expression': 'warn',
'@typescript-eslint/no-confusing-void-expression': 'warn',
// '@typescript-eslint/await-thenable': 'error',
// '@typescript-eslint/no-misused-promises': [
// 'error',
Expand Down
4 changes: 3 additions & 1 deletion packages/eas-cli/src/branch/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ export async function listAndRenderBranchesOnAppAsync(
queryBranchesOnProjectAsync(graphqlClient, limit, offset, projectId),
promptOptions: {
title: 'Load more branches?',
renderListItems: branches => renderPageOfBranches(branches, paginatedQueryOptions),
renderListItems: branches => {
renderPageOfBranches(branches, paginatedQueryOptions);
},
},
});
}
Expand Down
4 changes: 3 additions & 1 deletion packages/eas-cli/src/build/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@ export async function prepareBuildRequestForPlatformAsync<

await withAnalyticsAsync(
ctx.analytics,
async () => await builder.syncProjectConfigurationAsync(ctx),
async () => {
await builder.syncProjectConfigurationAsync(ctx);
},
{
attemptEvent: BuildEvent.CONFIGURE_PROJECT_ATTEMPT,
successEvent: BuildEvent.CONFIGURE_PROJECT_SUCCESS,
Expand Down
5 changes: 3 additions & 2 deletions packages/eas-cli/src/build/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ export async function listAndRenderBuildsOnAppAsync(
}),
promptOptions: {
title: 'Load more builds?',
renderListItems: builds =>
renderPageOfBuilds({ builds, projectDisplayName, paginatedQueryOptions }),
renderListItems: builds => {
renderPageOfBuilds({ builds, projectDisplayName, paginatedQueryOptions });
},
},
});
}
Expand Down
10 changes: 6 additions & 4 deletions packages/eas-cli/src/build/utils/printBuildInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ export function printBuildResults(builds: (BuildFragment | null)[]): void {
assert(build, 'Build should be defined');
printBuildResult(build);
} else {
(builds.filter(i => i) as BuildFragment[]).forEach(build => printBuildResult(build));
(builds.filter(i => i) as BuildFragment[]).forEach(build => {
printBuildResult(build);
});
}
}

Expand Down Expand Up @@ -97,9 +99,9 @@ function printBuildResult(build: BuildFragment): void {
// to the build details page and let people press the button to download there
const qrcodeUrl =
build.platform === AppPlatform.Ios ? getInternalDistributionInstallUrl(build) : logsUrl;
qrcodeTerminal.generate(qrcodeUrl, { small: true }, code =>
Log.log(`${indentString(code, 2)}\n`)
);
qrcodeTerminal.generate(qrcodeUrl, { small: true }, code => {
Log.log(`${indentString(code, 2)}\n`);
});
Log.log(
`${appPlatformEmojis[build.platform]} Open this link on your ${
appPlatformDisplayNames[build.platform]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ import {

describe(assertVersion, () => {
it('throws if the branch mapping is not the correct version', () => {
expect(() => assertVersion(testChannelBasicInfo, 5)).toThrowError(BranchMappingValidationError);
expect(() => {
assertVersion(testChannelBasicInfo, 5);
}).toThrowError(BranchMappingValidationError);
});
it('asserts the correct version', () => {
assertVersion(testChannelBasicInfo, 0);
Expand Down
9 changes: 6 additions & 3 deletions packages/eas-cli/src/channel/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ export async function listAndRenderChannelsOnAppAsync(
queryChannelsOnAppAsync(graphqlClient, { limit, offset, appId: projectId }),
promptOptions: {
title: 'Load more channels?',
renderListItems: channels => renderPageOfChannels(channels, paginatedQueryOptions),
renderListItems: channels => {
renderPageOfChannels(channels, paginatedQueryOptions);
},
},
});
}
Expand Down Expand Up @@ -131,8 +133,9 @@ export async function listAndRenderBranchesAndUpdatesOnChannelAsync(
}),
promptOptions: {
title: 'Load more channels?',
renderListItems: branches =>
renderPageOfBranchesOnChannel(channel, branches, paginatedQueryOptions),
renderListItems: branches => {
renderPageOfBranchesOnChannel(channel, branches, paginatedQueryOptions);
},
},
});
}
Expand Down
8 changes: 6 additions & 2 deletions packages/eas-cli/src/commandUtils/gating/FeatureGating.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ export default class FeatureGating {
}

public static overrideKeyForEachInTest(key: FeatureGateKey, enabled: boolean): void {
beforeEach(() => FeatureGateTestOverrides.setOverride(key, enabled));
afterEach(() => FeatureGateTestOverrides.removeOverride(key));
beforeEach(() => {
FeatureGateTestOverrides.setOverride(key, enabled);
});
afterEach(() => {
FeatureGateTestOverrides.removeOverride(key);
});
}
}
6 changes: 4 additions & 2 deletions packages/eas-cli/src/commands/metadata/lint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ export default class MetadataLint extends EasCommand {
await loadConfigAsync({ projectDir, profile: submitProfile });

if (flags.json) {
return printJsonOnlyOutput([]);
printJsonOnlyOutput([]);
return;
}

Log.log('✅ Store configuration is valid.');
Expand All @@ -70,7 +71,8 @@ export default class MetadataLint extends EasCommand {
}

if (flags.json) {
return printJsonOnlyOutput(error.errors);
printJsonOnlyOutput(error.errors);
return;
}

logMetadataValidationError(error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ jest.mock('../../../utils/code-signing');
jest.mock('../../../fetch');

describe(UpdateRepublish.name, () => {
afterEach(() => vol.reset());
afterEach(() => {
vol.reset();
});

it('errors when providing both --group and --branch', async () => {
const flags = ['--group=1234', '--branch=main'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ jest.mock('../../../project/publish', () => ({
}));

describe(UpdateRollBackToEmbedded.name, () => {
afterEach(() => vol.reset());
afterEach(() => {
vol.reset();
});

it('errors with both --channel and --branch', async () => {
const flags = ['--channel=channel123', '--branch=branch123'];
Expand Down
6 changes: 3 additions & 3 deletions packages/eas-cli/src/credentials/android/api/GraphqlClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ export async function deleteKeystoreAsync(
graphqlClient: ExpoGraphqlClient,
keystore: AndroidKeystoreFragment
): Promise<void> {
return await AndroidKeystoreMutation.deleteAndroidKeystoreAsync(graphqlClient, keystore.id);
await AndroidKeystoreMutation.deleteAndroidKeystoreAsync(graphqlClient, keystore.id);
}

export async function createFcmAsync(
Expand All @@ -299,7 +299,7 @@ export async function deleteFcmAsync(
graphqlClient: ExpoGraphqlClient,
fcm: AndroidFcmFragment
): Promise<void> {
return await AndroidFcmMutation.deleteAndroidFcmAsync(graphqlClient, fcm.id);
await AndroidFcmMutation.deleteAndroidFcmAsync(graphqlClient, fcm.id);
}

export async function createGoogleServiceAccountKeyAsync(
Expand All @@ -318,7 +318,7 @@ export async function deleteGoogleServiceAccountKeyAsync(
graphqlClient: ExpoGraphqlClient,
googleServiceAccountKey: GoogleServiceAccountKeyFragment
): Promise<void> {
return await GoogleServiceAccountKeyMutation.deleteGoogleServiceAccountKeyAsync(
await GoogleServiceAccountKeyMutation.deleteGoogleServiceAccountKeyAsync(
graphqlClient,
googleServiceAccountKey.id
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,37 +39,49 @@ describe('validateKeystore', () => {
it('validates a correctly formatted jks keystore', async () => {
const keystoreWithType = getKeystoreWithType(testKeystore);
expect(keystoreWithType.type).toBe(AndroidKeystoreType.Jks);
expect(() => validateKeystore(keystoreWithType)).not.toThrow();
expect(() => {
validateKeystore(keystoreWithType);
}).not.toThrow();
});
it('doesnt validate a jks keystore with wrong alias', async () => {
const keystoreWithType = getKeystoreWithType({
...testKeystore,
keyAlias: 'non-existent-alias',
});
expect(() => validateKeystore(keystoreWithType)).toThrow();
expect(() => {
validateKeystore(keystoreWithType);
}).toThrow();
});
it('doesnt validate a jks keystore with wrong key password', async () => {
const keystoreWithType = getKeystoreWithType({
...testKeystore,
keyPassword: 'not-the-password',
});
expect(() => validateKeystore(keystoreWithType)).toThrow();
expect(() => {
validateKeystore(keystoreWithType);
}).toThrow();
});
it('validates a correctly formatted pkcs 12 keystore', async () => {
const keystoreWithType = getKeystoreWithType(testPKCS12Keystore);
expect(keystoreWithType.type).toBe(AndroidKeystoreType.Pkcs12);
expect(() => validateKeystore(keystoreWithType)).not.toThrow();
expect(() => {
validateKeystore(keystoreWithType);
}).not.toThrow();
});
it('doesnt validate a PKCS 12 keystore with wrong alias', async () => {
const keystoreWithType = getKeystoreWithType({
...testPKCS12Keystore,
keyAlias: 'non-existent-alias',
});
expect(() => validateKeystore(keystoreWithType)).toThrow();
expect(() => {
validateKeystore(keystoreWithType);
}).toThrow();
});
it('validates an PKCS 12 Keystore with an empty password', async () => {
const keystoreWithType = getKeystoreWithType(testPKCS12EmptyPasswordKeystore);
expect(keystoreWithType.type).toBe(AndroidKeystoreType.Pkcs12);
expect(() => validateKeystore(keystoreWithType)).not.toThrow();
expect(() => {
validateKeystore(keystoreWithType);
}).not.toThrow();
});
});
11 changes: 4 additions & 7 deletions packages/eas-cli/src/credentials/ios/api/GraphqlClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ export async function deleteProvisioningProfilesAsync(
graphqlClient: ExpoGraphqlClient,
appleProvisioningProfileIds: string[]
): Promise<void> {
return await AppleProvisioningProfileMutation.deleteAppleProvisioningProfilesAsync(
await AppleProvisioningProfileMutation.deleteAppleProvisioningProfilesAsync(
graphqlClient,
appleProvisioningProfileIds
);
Expand Down Expand Up @@ -445,7 +445,7 @@ export async function deleteDistributionCertificateAsync(
graphqlClient: ExpoGraphqlClient,
distributionCertificateId: string
): Promise<void> {
return await AppleDistributionCertificateMutation.deleteAppleDistributionCertificateAsync(
await AppleDistributionCertificateMutation.deleteAppleDistributionCertificateAsync(
graphqlClient,
distributionCertificateId
);
Expand Down Expand Up @@ -493,7 +493,7 @@ export async function deletePushKeyAsync(
graphqlClient: ExpoGraphqlClient,
pushKeyId: string
): Promise<void> {
return await ApplePushKeyMutation.deleteApplePushKeyAsync(graphqlClient, pushKeyId);
await ApplePushKeyMutation.deleteApplePushKeyAsync(graphqlClient, pushKeyId);
}

export async function createAscApiKeyAsync(
Expand Down Expand Up @@ -543,10 +543,7 @@ export async function deleteAscApiKeyAsync(
graphqlClient: ExpoGraphqlClient,
ascApiKeyId: string
): Promise<void> {
return await AppStoreConnectApiKeyMutation.deleteAppStoreConnectApiKeyAsync(
graphqlClient,
ascApiKeyId
);
await AppStoreConnectApiKeyMutation.deleteAppStoreConnectApiKeyAsync(graphqlClient, ascApiKeyId);
}

function convertUserRoleToGraphqlType(userRole: UserRole): AppStoreConnectUserRole {
Expand Down
8 changes: 4 additions & 4 deletions packages/eas-cli/src/credentials/ios/appstore/AppStoreApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export default class AppStoreApi {
options?: IosCapabilitiesOptions
): Promise<void> {
const ctx = await this.ensureAuthenticatedAsync();
return await ensureBundleIdExistsAsync(ctx, app, options);
await ensureBundleIdExistsAsync(ctx, app, options);
}

public async listDistributionCertificatesAsync(): Promise<DistributionCertificateStoreInfo[]> {
Expand All @@ -99,7 +99,7 @@ export default class AppStoreApi {

public async revokeDistributionCertificateAsync(ids: string[]): Promise<void> {
const ctx = await this.ensureAuthenticatedAsync();
return await revokeDistributionCertificateAsync(ctx, ids);
await revokeDistributionCertificateAsync(ctx, ids);
}

public async listPushKeysAsync(): Promise<PushKeyStoreInfo[]> {
Expand All @@ -114,7 +114,7 @@ export default class AppStoreApi {

public async revokePushKeyAsync(ids: string[]): Promise<void> {
const userCtx = await this.ensureUserAuthenticatedAsync();
return await revokePushKeyAsync(userCtx, ids);
await revokePushKeyAsync(userCtx, ids);
}

public async useExistingProvisioningProfileAsync(
Expand Down Expand Up @@ -164,7 +164,7 @@ export default class AppStoreApi {
profileClass?: ProfileClass
): Promise<void> {
const ctx = await this.ensureAuthenticatedAsync();
return await revokeProvisioningProfileAsync(ctx, bundleIdentifier, applePlatform, profileClass);
await revokeProvisioningProfileAsync(ctx, bundleIdentifier, applePlatform, profileClass);
}

public async createOrReuseAdhocProvisioningProfileAsync(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ describe(assertValidOptions, () => {
const classifier = CapabilityMapping.find(
({ capabilityIdPrefix }) => capabilityIdPrefix === 'merchant.'
)!;
expect(() => assertValidOptions(classifier, ['foobar'])).toThrowError(
/Expected an array of strings, where each string is prefixed with "merchant."/
);
expect(() => {
assertValidOptions(classifier, ['foobar']);
}).toThrowError(/Expected an array of strings, where each string is prefixed with "merchant."/);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export async function ensureBundleIdExistsAsync(
{ accountName, projectName, bundleIdentifier }: AppLookupParams,
options?: IosCapabilitiesOptions
): Promise<void> {
return await ensureBundleIdExistsWithNameAsync(
await ensureBundleIdExistsWithNameAsync(
authCtx,
{
name: `@${accountName}/${projectName}`,
Expand Down
6 changes: 4 additions & 2 deletions packages/eas-cli/src/credentials/ios/appstore/keychain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ export async function deletePasswordAsync({
(error: Error) => {
if (error) {
if (error.message.match(NO_PASSWORD_REGEX)) {
return resolve(false);
resolve(false);
return;
}
reject(error);
} else {
Expand All @@ -52,7 +53,8 @@ export async function getPasswordAsync({
(error: Error, password: string) => {
if (error) {
if (error.message.match(NO_PASSWORD_REGEX)) {
return resolve(null);
resolve(null);
return;
}
reject(error);
} else {
Expand Down
3 changes: 2 additions & 1 deletion packages/eas-cli/src/credentials/manager/ManageAndroid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ export class ManageAndroid {
currentActions = highLevelActions;
continue;
} else if (chosenAction === AndroidActionType.GoBackToCaller) {
return await this.callingAction.runAsync(ctx);
await this.callingAction.runAsync(ctx);
return;
}
}

Expand Down
3 changes: 2 additions & 1 deletion packages/eas-cli/src/credentials/manager/ManageIos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ export class ManageIos {
currentActions = highLevelActions;
continue;
} else if (chosenAction === IosActionType.GoBackToCaller) {
return await this.callingAction.runAsync(ctx);
await this.callingAction.runAsync(ctx);
return;
}
} else if (actionInfo.scope === Scope.Project) {
assert(
Expand Down
5 changes: 3 additions & 2 deletions packages/eas-cli/src/credentials/manager/SelectPlatform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ export class SelectPlatform {
const platform = await selectPlatformAsync(this.flagPlatform);

if (platform === 'ios') {
return await new ManageIos(this, process.cwd()).runAsync();
await new ManageIos(this, process.cwd()).runAsync();
return;
}
return await new ManageAndroid(this, process.cwd()).runAsync();
await new ManageAndroid(this, process.cwd()).runAsync();
}
}
Loading

0 comments on commit 9b49fe3

Please sign in to comment.