Skip to content

Commit

Permalink
fix: lint warnings (#12180)
Browse files Browse the repository at this point in the history
* fix: lint warnings

* fix: lint warnings

* fix: lint warnings
  • Loading branch information
sobolk committed Mar 6, 2023
1 parent 1912a93 commit 83d9bf3
Show file tree
Hide file tree
Showing 65 changed files with 104 additions and 159 deletions.
1 change: 1 addition & 0 deletions .eslint-dictionary.json
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@
"xcconfig",
"xcode",
"xcodeproj",
"xray",
"yaml",
"yarnrc",
"ulid",
Expand Down
7 changes: 7 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,13 @@ module.exports = {
'spellcheck/spell-checker': 'off',
},
},
{
// Disable no-unused-vars for templates
files: ['packages/amplify-cli/templates/**'],
rules: {
'@typescript-eslint/no-unused-vars': 'off',
},
},
],
// Files / paths / globs that shouldn't be linted at all
// (note that only .js, .jsx, .ts, and .tsx files are linted in the first place)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"link-aa-win": "node ./scripts/link-bin.js packages/amplify-app/bin/amplify-app amplify-app-dev",
"link-dev": "cd packages/amplify-cli && ln -s \"$(pwd)/bin/amplify\" \"$(yarn global bin)/amplify-dev\" && cd -",
"link-win": "node ./scripts/link-bin.js packages/amplify-cli/bin/amplify amplify-dev",
"lint-check": "yarn eslint . --ext .js,.jsx,.ts,.tsx --max-warnings=955",
"lint-check": "yarn eslint . --ext .js,.jsx,.ts,.tsx --max-warnings=846",
"lint-fix": "git diff --name-only --cached --diff-filter d | grep -E '\\.(js|jsx|ts|tsx)$' | xargs eslint --fix --quiet",
"lint-fix-package-json": "yarn lint-check-package-json --fix",
"lint-check-package-json": "yarn eslint --no-eslintrc --config .eslint.package.json.js '**/package.json'",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { printer } from 'amplify-prompts';
export class OpenSearchDataLoader implements AmplifyAppSyncSimulatorDataLoader {
constructor(private _config) {}

async load(payload, extraData) {
async load(payload) {
try {
if (process?.platform?.startsWith('win')) {
return null;
Expand Down
1 change: 0 additions & 1 deletion packages/amplify-appsync-simulator/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ export class AmplifyAppSyncSimulator {
}, new Map());

this.functions = (config.functions || []).reduce((map, fn) => {
const { dataSourceName, requestMappingTemplateLocation, responseMappingTemplateLocation } = fn;
map.set(fn.name, new AmplifySimulatorFunction(fn, this));
return map;
}, new Map());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { AmplifyAppSyncSimulator } from '..';
import { AppSyncSimulatorFunctionResolverConfig } from '../type-definition';
import { VelocityTemplate } from '../velocity';
import { AppSyncBaseResolver } from './base-resolver';

export class AmplifySimulatorFunction extends AppSyncBaseResolver {
Expand Down
2 changes: 1 addition & 1 deletion packages/amplify-appsync-simulator/src/schema/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export function generateResolvers(
},
...(typeName === 'Subscription'
? {
subscribe: (source, args, context, info) => {
subscribe: (source, args, context) => {
// Connect time error. Not allowing subscription
if (context.appsyncErrors.length) {
throw new Error('Subscription failed');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ export class WebsocketSubscriptionServer {
switch (message.type) {
case MESSAGE_TYPES.GQL_CONNECTION_INIT:
if (isSubscriptionConnectionInitMessage(message)) {
return this.onConnectionInit(connectionContext, message);
return this.onConnectionInit(connectionContext);
}
break;
case MESSAGE_TYPES.GQL_START:
Expand Down Expand Up @@ -227,7 +227,7 @@ export class WebsocketSubscriptionServer {
}, this.options.keepAlive) as any;
};

private onConnectionInit = (connectionContext: ConnectionContext, message: GQLMessageConnectionInit): void => {
private onConnectionInit = (connectionContext: ConnectionContext): void => {
connectionContext.isConnectionInitialized = true;
const response: GQLMessageConnectionAck = {
type: MESSAGE_TYPES.GQL_CONNECTION_ACK,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const parseTimestamp = (dateTime: string, format?: string, timezone?: string): m
};

export const time = () => ({
nowISO8601(t): string {
nowISO8601(): string {
return moment().toISOString();
},
nowEpochSeconds(): number {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const uuid = require('uuid');
const { booleanOptions, oAuthScopes } = require('./string-maps');
const { oAuthScopes } = require('./string-maps');

const [sharedId] = uuid.v4().split('-');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ export class AmplifyAuthCognitoStack extends cdk.Stack implements AmplifyAuthCog
/**
* add Function for Custom Resource in Root stack
*/
public renderCloudFormationTemplate = (__: cdk.ISynthesisSession): string => JSONUtilities.stringify(this._toCloudFormation())!;
public renderCloudFormationTemplate = (): string => JSONUtilities.stringify(this._toCloudFormation())!;

/**
* creates userpool client custom resource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export class AmplifyUserPoolGroupStack extends cdk.Stack implements AmplifyUserP
}

// add Function for Custom Resource in Root stack
public renderCloudFormationTemplate = (__: cdk.ISynthesisSession): string => JSON.stringify(this._toCloudFormation(), undefined, 2);
public renderCloudFormationTemplate = (): string => JSON.stringify(this._toCloudFormation(), undefined, 2);

generateUserPoolGroupResources = async (props: AmplifyUserPoolGroupStackOptions): Promise<void> => {
props.groups.forEach((group) => {
Expand Down Expand Up @@ -393,5 +393,5 @@ export class AmplifyUserPoolGroupStackOutputs extends cdk.Stack {
throw new Error('Method not implemented.');
}

public renderCloudFormationTemplate = (__: cdk.ISynthesisSession): string => JSONUtilities.stringify(this._toCloudFormation())!;
public renderCloudFormationTemplate = (): string => JSONUtilities.stringify(this._toCloudFormation())!;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AmplifyFault, JSONUtilities } from 'amplify-cli-core';
import { FileAssetSource, ISynthesisSession, Stack, LegacyStackSynthesizer } from 'aws-cdk-lib';
import { FileAssetSource, Stack, LegacyStackSynthesizer } from 'aws-cdk-lib';
import { Template } from 'cloudform-types';
import crypto from 'crypto';
import { AmplifyAuthCognitoStack } from './auth-cognito-stack-builder';
Expand All @@ -16,14 +16,14 @@ export class AuthStackSynthesizer extends LegacyStackSynthesizer {
* This method has been deprecated by cdk and is not used in runtime.
* @deprecated Replaced by synthesizeTemplate.
*/
protected synthesizeStackTemplate(stack: Stack, session: ISynthesisSession): void {
protected synthesizeStackTemplate(stack: Stack): void {
if (
stack instanceof AmplifyAuthCognitoStack ||
stack instanceof AmplifyUserPoolGroupStack ||
stack instanceof AmplifyUserPoolGroupStackOutputs
) {
this.addStack(stack);
const template = stack.renderCloudFormationTemplate(session) as string;
const template = stack.renderCloudFormationTemplate() as string;
const templateName = stack.node.id;
this.setStackAsset(templateName, template);
} else {
Expand All @@ -34,15 +34,15 @@ export class AuthStackSynthesizer extends LegacyStackSynthesizer {
}
}

protected synthesizeTemplate(session: ISynthesisSession): FileAssetSource {
protected synthesizeTemplate(): FileAssetSource {
const stack = this.boundStack;
if (
stack instanceof AmplifyAuthCognitoStack ||
stack instanceof AmplifyUserPoolGroupStack ||
stack instanceof AmplifyUserPoolGroupStackOutputs
) {
this.addStack(stack);
const template = stack.renderCloudFormationTemplate(session) as string;
const template = stack.renderCloudFormationTemplate() as string;
const templateName = stack.node.id;
this.setStackAsset(templateName, template);
const contentHash = crypto.createHash('sha256').update(template).digest('hex');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export const getUpdateAuthHandler = (context: AuthContext) => async (request: Se
}

await getPostUpdateAuthMetaUpdater(context)(cognitoCLIInputs.cognitoConfig.resourceName);
await getPostUpdateAuthMessagePrinter(context.print)(cognitoCLIInputs.cognitoConfig.resourceName);
await getPostUpdateAuthMessagePrinter()(cognitoCLIInputs.cognitoConfig.resourceName);

if (doesConfigurationIncludeSMS(cliInputs)) {
await printSMSSandboxWarning();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const getPostAddAuthMessagePrinter = (resourceName: string, skipNextSteps
* A factory function that returns a function that prints the "success message" after updating auth
* @param context The amplify print object
*/
export const getPostUpdateAuthMessagePrinter = (print: any) => (resourceName: string) => {
export const getPostUpdateAuthMessagePrinter = () => (resourceName: string) => {
printer.success(`Successfully updated auth resource ${resourceName} locally`);
printCommonText();
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const { JSONUtilities, pathManager } = require('amplify-cli-core');
const path = require('path');
const { generateUserPoolGroupStackTemplate } = require('./generate-user-pool-group-stack-template');
const { AuthInputState } = require('../auth-inputs-manager/auth-input-state');

async function transformUserPoolGroupSchema(context) {
const userPoolPrecedencePath = path.join(pathManager.getBackendDirPath(), 'auth', 'userPoolGroups', 'user-pool-group-precedence.json');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import {
$TSAny,
$TSContext,
AmplifyCategories,
AmplifySupportedService,
JSONUtilities,
open,
PathConstants,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { $TSContext, ResourceName, stateManager } from 'amplify-cli-core';
import { SecretDeltas } from 'amplify-function-plugin-interface';
import _ from 'lodash';
import { categoryName } from '../../../constants';
import { cloneEnvWalkthrough } from '../service-walkthroughs/secretValuesWalkthrough';
import { FunctionSecretsStateManager, getLocalFunctionSecretNames } from './functionSecretsStateManager';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import _ from 'lodash';
import { Packager } from '../types/packaging-types';
import { ServiceName } from './constants';
import { packageFunction } from './packageFunction';
Expand Down
2 changes: 1 addition & 1 deletion packages/amplify-category-geo/src/commands/geo/add.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { chooseServiceMessageAdd, provider } from '../../service-utils/constants';
import { category } from '../../constants';
import { supportedServices } from '../../supportedServices';
import { $TSAny, $TSContext } from 'amplify-cli-core';
import { $TSContext } from 'amplify-cli-core';
import { addResource } from '../../provider-controllers';
import { printer } from 'amplify-prompts';

Expand Down
2 changes: 1 addition & 1 deletion packages/amplify-category-geo/src/commands/geo/import.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { $TSAny, $TSContext } from 'amplify-cli-core';
import { $TSContext } from 'amplify-cli-core';
import { printer } from 'amplify-prompts';
import { importResource } from '../../provider-controllers/import';

Expand Down
2 changes: 1 addition & 1 deletion packages/amplify-category-geo/src/commands/geo/remove.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { chooseServiceMessageRemove, provider } from '../../service-utils/constants';
import { category } from '../../constants';
import { supportedServices } from '../../supportedServices';
import { $TSAny, $TSContext } from 'amplify-cli-core';
import { $TSContext } from 'amplify-cli-core';
import { removeResource } from '../../provider-controllers';
import { printer } from 'amplify-prompts';

Expand Down
2 changes: 1 addition & 1 deletion packages/amplify-category-geo/src/commands/geo/update.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { chooseServiceMessageUpdate, provider } from '../../service-utils/constants';
import { category } from '../../constants';
import { supportedServices } from '../../supportedServices';
import { $TSAny, $TSContext } from 'amplify-cli-core';
import { $TSContext } from 'amplify-cli-core';
import { updateResource } from '../../provider-controllers';
import { printer } from 'amplify-prompts';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { getTemplateMappings } from '../provider-controllers';
* creates amplify geofence collection resource
*/
export const createGeofenceCollectionResource = async (context: $TSContext, parameters: GeofenceCollectionParameters): Promise<void> => {
const authResourceName = await getAuthResourceName(context);
const authResourceName = await getAuthResourceName();
// generate CFN files
const templateMappings = await getTemplateMappings(context);
const geofenceCollectionStack = new GeofenceCollectionStack(new App(), 'GeofenceCollectionStack', {
Expand Down Expand Up @@ -53,7 +53,7 @@ export const createGeofenceCollectionResource = async (context: $TSContext, para
* modify amplify geofence resource
*/
export const modifyGeofenceCollectionResource = async (context: $TSContext, parameters: GeofenceCollectionParameters): Promise<void> => {
const authResourceName = await getAuthResourceName(context);
const authResourceName = await getAuthResourceName();
// generate CFN files
const templateMappings = await getTemplateMappings(context);
const geofenceCollectionStack = new GeofenceCollectionStack(new App(), 'GeofenceCollectionStack', {
Expand Down
4 changes: 2 additions & 2 deletions packages/amplify-category-geo/src/service-utils/mapUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const createMapResource = async (context: $TSContext, parameters: MapPara
// allow unauth access for identity pool if guest access is enabled
await checkAuthConfig(context, parameters, ServiceName.Map);

const authResourceName = await getAuthResourceName(context);
const authResourceName = await getAuthResourceName();
// generate CFN files
const templateMappings = await getTemplateMappings(context);
const mapStack = new MapStack(new App(), 'MapStack', { ...parameters, ...templateMappings, authResourceName });
Expand Down Expand Up @@ -54,7 +54,7 @@ export const modifyMapResource = async (context: $TSContext, parameters: MapPara
// allow unauth access for identity pool if guest access is enabled
await checkAuthConfig(context, parameters, ServiceName.Map);

const authResourceName = await getAuthResourceName(context);
const authResourceName = await getAuthResourceName();
// generate CFN files
const templateMappings = await getTemplateMappings(context);
const mapStack = new MapStack(new App(), 'MapStack', { ...parameters, ...templateMappings, authResourceName });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const createPlaceIndexResource = async (context: $TSContext, parameters:
// allow unauth access for identity pool if guest access is enabled
await checkAuthConfig(context, parameters, ServiceName.PlaceIndex);

const authResourceName = await getAuthResourceName(context);
const authResourceName = await getAuthResourceName();

// generate CFN files
const templateMappings = await getTemplateMappings(context);
Expand Down Expand Up @@ -55,7 +55,7 @@ export const modifyPlaceIndexResource = async (context: $TSContext, parameters:
// allow unauth access for identity pool if guest access is enabled
await checkAuthConfig(context, parameters, ServiceName.PlaceIndex);

const authResourceName = await getAuthResourceName(context);
const authResourceName = await getAuthResourceName();
// generate CFN files
const templateMappings = await getTemplateMappings(context);
const placeIndexStack = new PlaceIndexStack(new App(), 'PlaceIndexStack', { ...parameters, ...templateMappings, authResourceName });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export const checkAnyGeoResourceExists = async (): Promise<boolean> => {
return geoMeta && Object.keys(geoMeta) && Object.keys(geoMeta).length > 0;
};

export const getAuthResourceName = async (context: $TSContext): Promise<string> => {
export const getAuthResourceName = async (): Promise<string> => {
const authMeta = stateManager.getMeta()?.[authCategoryName];
const cognitoResources = authMeta ? Object.keys(authMeta).filter((authResource) => authMeta[authResource].service === 'Cognito') : [];
if (cognitoResources.length === 0) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import _ from 'lodash';
import { v4 as uuid } from 'uuid';
import { merge } from '../service-utils/resourceUtils';
import { GeofenceCollectionParameters } from '../service-utils/geofenceCollectionParams';
Expand All @@ -21,7 +20,7 @@ export const createGeofenceCollectionWalkthrough = async (
parameters: Partial<GeofenceCollectionParameters>,
): Promise<Partial<GeofenceCollectionParameters>> => {
// get the geofence collection name
parameters = merge(parameters, await geofenceCollectionNameWalkthrough(context));
parameters = merge(parameters, await geofenceCollectionNameWalkthrough());

// get the access
parameters = merge(parameters, await geofenceCollectionAccessWalkthrough(context, parameters));
Expand All @@ -37,7 +36,7 @@ export const createGeofenceCollectionWalkthrough = async (
return parameters;
};

export const geofenceCollectionNameWalkthrough = async (context: any): Promise<Pick<GeofenceCollectionParameters, 'name'>> => {
export const geofenceCollectionNameWalkthrough = async (): Promise<Pick<GeofenceCollectionParameters, 'name'>> => {
const [shortId] = uuid().split('-');
const nameValidationErrMsg =
'Geofence Collection name can only use the following characters: a-z 0-9 and should have minimum 1 character and max of 95 characters';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { printer, formatter, prompter, alphanumeric } from 'amplify-prompts';
*/
export const createMapWalkthrough = async (context: $TSContext, parameters: Partial<MapParameters>): Promise<Partial<MapParameters>> => {
// get the map name
parameters = merge(parameters, await mapNameWalkthrough(context));
parameters = merge(parameters, await mapNameWalkthrough());

// get the access
parameters = merge(parameters, await resourceAccessWalkthrough(context, parameters, ServiceName.Map));
Expand All @@ -35,7 +35,7 @@ export const createMapWalkthrough = async (context: $TSContext, parameters: Part
return parameters;
};

export const mapNameWalkthrough = async (context: any): Promise<Partial<MapParameters>> => {
export const mapNameWalkthrough = async (): Promise<Partial<MapParameters>> => {
let mapName;
while (!mapName) {
const [shortId] = uuid().split('-');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import _ from 'lodash';
import { v4 as uuid } from 'uuid';
import { merge } from '../service-utils/resourceUtils';
import { DataSourceIntendedUse, PlaceIndexParameters } from '../service-utils/placeIndexParams';
Expand All @@ -21,7 +20,7 @@ export const createPlaceIndexWalkthrough = async (
parameters: Partial<PlaceIndexParameters>,
): Promise<Partial<PlaceIndexParameters>> => {
// get the place index name
parameters = merge(parameters, await placeIndexNameWalkthrough(context));
parameters = merge(parameters, await placeIndexNameWalkthrough());

// get the access
parameters = merge(parameters, await resourceAccessWalkthrough(context, parameters, ServiceName.PlaceIndex));
Expand All @@ -40,7 +39,7 @@ export const createPlaceIndexWalkthrough = async (
return parameters;
};

export const placeIndexNameWalkthrough = async (context: any): Promise<Partial<PlaceIndexParameters>> => {
export const placeIndexNameWalkthrough = async (): Promise<Partial<PlaceIndexParameters>> => {
let indexName;
while (!indexName) {
const [shortId] = uuid().split('-');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export const servicesMetadata = {
{
slotType: 'FlowerTypes',
slotTypeDescription: 'Types of flowers to pick up',
slotValues: ['tulips', 'lillies', 'roses'],
slotValues: ['tulips', 'lilies', 'roses'],
},
],
},
Expand Down
2 changes: 1 addition & 1 deletion packages/amplify-category-notifications/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const initEnv: (context: $TSContext) => Promise<void>;
export const migrate: (context: $TSContext) => Promise<void>;

// @public (undocumented)
export const notificationsAPIGetAvailableChannelNames: (__context: $TSContext) => Promise<string[]>;
export const notificationsAPIGetAvailableChannelNames: () => Promise<string[]>;

// @public (undocumented)
export const notificationsPluginAPIGetResource: (context: $TSContext) => Promise<INotificationsResource | undefined>;
Expand Down

0 comments on commit 83d9bf3

Please sign in to comment.