Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#IP-86] Eslint migration, new rules and less comments #114

Merged
merged 6 commits into from
Apr 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,5 @@ module.exports = {
"extends": [
"@pagopa/eslint-config/strong",
],
"rules": {

}
"rules": {}
}
9 changes: 3 additions & 6 deletions CreateMessage/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,8 @@ import {
import { NonEmptyString } from "italia-ts-commons/lib/strings";
import { PromiseType } from "italia-ts-commons/lib/types";

// eslint-disable-next-line @typescript-eslint/naming-convention
const ApiNewMessageWithDefaults = t.intersection([
ApiNewMessage,
// eslint-disable-next-line @typescript-eslint/naming-convention
t.interface({ time_to_live: TimeToLiveSeconds })
]);
export type ApiNewMessageWithDefaults = t.TypeOf<
Expand All @@ -91,7 +89,6 @@ export type ApiNewMessageWithDefaults = t.TypeOf<
/**
* A request middleware that validates the Message payload.
*/
// eslint-disable-next-line @typescript-eslint/naming-convention
export const MessagePayloadMiddleware: IRequestMiddleware<
"IResponseErrorValidation",
ApiNewMessageWithDefaults
Expand Down Expand Up @@ -333,7 +330,7 @@ const redirectToNewMessage = (
/**
* Returns a type safe CreateMessage handler.
*/
// eslint-disable-next-line prefer-arrow/prefer-arrow-functions, @typescript-eslint/naming-convention
// eslint-disable-next-line prefer-arrow/prefer-arrow-functions
export function CreateMessageHandler(
telemetryClient: ReturnType<typeof initAppInsights>,
messageModel: MessageModel,
Expand Down Expand Up @@ -474,7 +471,7 @@ export function CreateMessageHandler(
/**
* Wraps a CreateMessage handler inside an Express request handler.
*/
// eslint-disable-next-line prefer-arrow/prefer-arrow-functions, @typescript-eslint/naming-convention
// eslint-disable-next-line prefer-arrow/prefer-arrow-functions
export function CreateMessage(
telemetryClient: ReturnType<typeof initAppInsights>,
serviceModel: ServiceModel,
Expand Down Expand Up @@ -503,7 +500,7 @@ export function CreateMessage(
);
return wrapRequestHandler(
middlewaresWrap(
// eslint-disable-next-line @typescript-eslint/naming-convention, max-params
// eslint-disable-next-line max-params
checkSourceIpForHandler(handler, (_, __, c, u, ___, ____) =>
ipTuple(c, u)
)
Expand Down
4 changes: 0 additions & 4 deletions CreateNotificationActivity/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ async function createNotification(
};
}

// eslint-disable-next-line @typescript-eslint/naming-convention
export const CreateNotificationActivityInput = t.interface({
createdMessageEvent: CreatedMessageEvent,
storeMessageContentActivityResult: SuccessfulStoreMessageContentActivityResult
Expand All @@ -84,7 +83,6 @@ export type CreateNotificationActivityInput = t.TypeOf<
typeof CreateNotificationActivityInput
>;

// eslint-disable-next-line @typescript-eslint/naming-convention
const CreateNotificationActivitySomeResult = t.interface({
hasEmail: t.boolean,
hasWebhook: t.boolean,
Expand All @@ -96,7 +94,6 @@ type CreateNotificationActivitySomeResult = t.TypeOf<
typeof CreateNotificationActivitySomeResult
>;

// eslint-disable-next-line @typescript-eslint/naming-convention
const CreateNotificationActivityNoneResult = t.interface({
kind: t.literal("none")
});
Expand All @@ -105,7 +102,6 @@ type CreateNotificationActivityNoneResult = t.TypeOf<
typeof CreateNotificationActivityNoneResult
>;

// eslint-disable-next-line @typescript-eslint/naming-convention
export const CreateNotificationActivityResult = t.taggedUnion("kind", [
CreateNotificationActivitySomeResult,
CreateNotificationActivityNoneResult
Expand Down
15 changes: 3 additions & 12 deletions CreateService/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,9 @@ const createSubscriptionTask = (
() =>
apiClient.createSubscription({
body: {
// eslint-disable-next-line @typescript-eslint/naming-convention
product_name: productName
},
email: userEmail,
// eslint-disable-next-line @typescript-eslint/naming-convention
subscription_id: subscriptionId
}),
200
Expand Down Expand Up @@ -133,14 +131,10 @@ const createServiceTask = (
apiClient.createService({
body: {
...servicePayload,
// eslint-disable-next-line @typescript-eslint/naming-convention
authorized_recipients: [sandboxFiscalCode],
// eslint-disable-next-line @typescript-eslint/naming-convention
service_id: subscriptionId,
// eslint-disable-next-line @typescript-eslint/naming-convention
service_metadata: {
...servicePayload.service_metadata,
// eslint-disable-next-line @typescript-eslint/naming-convention
token_name: adb2cTokenName
}
}
Expand All @@ -151,15 +145,15 @@ const createServiceTask = (
/**
* Handles requests for create a service by a Service Payload.
*/
// eslint-disable-next-line prefer-arrow/prefer-arrow-functions, @typescript-eslint/naming-convention
// eslint-disable-next-line prefer-arrow/prefer-arrow-functions
export function CreateServiceHandler(
telemetryClient: ReturnType<typeof initAppInsights>,
apiClient: APIClient,
generateObjectId: ObjectIdGenerator,
productName: NonEmptyString,
sandboxFiscalCode: NonEmptyString
): ICreateServiceHandler {
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/naming-convention
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
return (context, __, ___, userAttributes, servicePayload) => {
const subscriptionId = generateObjectId();
context.log.info(
Expand Down Expand Up @@ -196,9 +190,7 @@ export function CreateServiceHandler(
});
return ResponseSuccessJson({
...service,
// eslint-disable-next-line @typescript-eslint/naming-convention
primary_key: subscription.primary_key,
// eslint-disable-next-line @typescript-eslint/naming-convention
secondary_key: subscription.secondary_key
});
})
Expand All @@ -212,7 +204,7 @@ export function CreateServiceHandler(
/**
* Wraps a CreateService handler inside an Express request handler.
*/
// eslint-disable-next-line prefer-arrow/prefer-arrow-functions, @typescript-eslint/naming-convention
// eslint-disable-next-line prefer-arrow/prefer-arrow-functions
export function CreateService(
telemetryClient: ReturnType<typeof initAppInsights>,
serviceModel: ServiceModel,
Expand All @@ -236,7 +228,6 @@ export function CreateService(
);
return wrapRequestHandler(
middlewaresWrap(
// eslint-disable-next-line @typescript-eslint/naming-convention
checkSourceIpForHandler(handler, (_, __, c, u, ___) => ipTuple(c, u))
)
);
Expand Down
8 changes: 0 additions & 8 deletions CreatedMessageOrchestrator/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export type HandlerInputType<T> = T extends Function2<any, infer A, any>
? A
: never;

// eslint-disable-next-line @typescript-eslint/naming-convention
const MessageProcessingEvent = t.interface({
name: t.string,
properties: t.interface({
Expand Down Expand Up @@ -43,18 +42,11 @@ export const trackMessageProcessing = (
: null;

export enum MessageProcessingEventNames {
// eslint-disable-next-line @typescript-eslint/naming-convention
DECODE_INPUT = "api.messages.create.decodeinput",
// eslint-disable-next-line @typescript-eslint/naming-convention
STORE_MESSAGE_DECODE = "api.messages.create.storemessagedecode",
// eslint-disable-next-line @typescript-eslint/naming-convention
UPDATE_NOTIFICATION_STATUS = "api.messages.create.updatenotificationstatus",
// eslint-disable-next-line @typescript-eslint/naming-convention
NO_CHANNEL = "api.messages.create.nochannel",
// eslint-disable-next-line @typescript-eslint/naming-convention
EMAIL_SENT = "api.messages.create.emailsent",
// eslint-disable-next-line @typescript-eslint/naming-convention
WEBHOOK = "api.messages.create.webhook",
// eslint-disable-next-line @typescript-eslint/naming-convention
UPDATE_MESSAGE_STATUS = "api.messages.create.updatemessagestatus"
}
9 changes: 1 addition & 8 deletions EmailNotificationActivity/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,10 @@ import { sendMail } from "@pagopa/io-functions-commons/dist/src/mailer";
import { generateDocumentHtml } from "./utils";

export interface INotificationDefaults {
// eslint-disable-next-line @typescript-eslint/naming-convention
readonly HTML_TO_TEXT_OPTIONS: HtmlToTextOptions;
// eslint-disable-next-line @typescript-eslint/naming-convention
readonly MAIL_FROM: NonEmptyString;
}

// eslint-disable-next-line @typescript-eslint/naming-convention
export const EmailNotificationActivityInput = t.interface({
notificationEvent: NotificationEvent
});
Expand All @@ -34,16 +31,14 @@ export type EmailNotificationActivityInput = t.TypeOf<
typeof EmailNotificationActivityInput
>;

// eslint-disable-next-line @typescript-eslint/naming-convention
export const EmailNotificationActivityResult = t.taggedUnion("kind", [
t.interface({
kind: t.literal("SUCCESS"),
// eslint-disable-next-line @typescript-eslint/naming-convention, sort-keys
// eslint-disable-next-line sort-keys
result: t.keyof({ OK: null, EXPIRED: null })
}),
t.interface({
kind: t.literal("FAILURE"),
// eslint-disable-next-line @typescript-eslint/naming-convention
reason: t.keyof({ DECODE_ERROR: null })
})
]);
Expand Down Expand Up @@ -159,9 +154,7 @@ export const getEmailNotificationActivityHandler = (
await sendMail(lMailerTransporter, {
from: notificationDefaultParams.MAIL_FROM,
headers: {
// eslint-disable-next-line @typescript-eslint/naming-convention
"X-Italia-Messages-MessageId": message.id,
// eslint-disable-next-line @typescript-eslint/naming-convention
"X-Italia-Messages-NotificationId": notificationId
},
html: documentHtml,
Expand Down
2 changes: 0 additions & 2 deletions EmailNotificationActivity/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ const activityFunction: AzureFunction = getEmailNotificationActivityHandler(
mailerTransporter,
notificationModel,
{
// eslint-disable-next-line @typescript-eslint/naming-convention
HTML_TO_TEXT_OPTIONS,
// eslint-disable-next-line @typescript-eslint/naming-convention
MAIL_FROM
}
);
Expand Down
4 changes: 2 additions & 2 deletions GetLimitedProfile/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ type IGetLimitedProfileHandler = (
/**
* Returns a type safe GetLimitedProfile handler.
*/
// eslint-disable-next-line prefer-arrow/prefer-arrow-functions, @typescript-eslint/naming-convention
// eslint-disable-next-line prefer-arrow/prefer-arrow-functions
export function GetLimitedProfileHandler(
profileModel: ProfileModel
): IGetLimitedProfileHandler {
Expand Down Expand Up @@ -127,7 +127,7 @@ export function GetLimitedProfileHandler(
/**
* Wraps a GetLimitedProfile handler inside an Express request handler.
*/
// eslint-disable-next-line prefer-arrow/prefer-arrow-functions, @typescript-eslint/naming-convention
// eslint-disable-next-line prefer-arrow/prefer-arrow-functions
export function GetLimitedProfile(
serviceModel: ServiceModel,
profileModel: ProfileModel
Expand Down
4 changes: 2 additions & 2 deletions GetLimitedProfileByPOST/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ type IGetLimitedProfileByPOSTHandler = (
/**
* Returns a type safe GetLimitedProfileByPOST handler.
*/
// eslint-disable-next-line prefer-arrow/prefer-arrow-functions, @typescript-eslint/naming-convention
// eslint-disable-next-line prefer-arrow/prefer-arrow-functions
export function GetLimitedProfileByPOSTHandler(
profileModel: ProfileModel
): IGetLimitedProfileByPOSTHandler {
Expand Down Expand Up @@ -129,7 +129,7 @@ export function GetLimitedProfileByPOSTHandler(
/**
* Wraps a GetLimitedProfileByPOST handler inside an Express request handler.
*/
// eslint-disable-next-line prefer-arrow/prefer-arrow-functions, @typescript-eslint/naming-convention
// eslint-disable-next-line prefer-arrow/prefer-arrow-functions
export function GetLimitedProfileByPOST(
serviceModel: ServiceModel,
profileModel: ProfileModel
Expand Down
6 changes: 3 additions & 3 deletions GetMessage/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ type IGetMessageHandler = (
/**
* Handles requests for getting a single message for a recipient.
*/
// eslint-disable-next-line prefer-arrow/prefer-arrow-functions, @typescript-eslint/naming-convention
// eslint-disable-next-line prefer-arrow/prefer-arrow-functions
export function GetMessageHandler(
messageModel: MessageModel,
messageStatusModel: MessageStatusModel,
Expand Down Expand Up @@ -214,7 +214,7 @@ export function GetMessageHandler(
/**
* Wraps a GetMessage handler inside an Express request handler.
*/
// eslint-disable-next-line max-params, prefer-arrow/prefer-arrow-functions, @typescript-eslint/naming-convention
// eslint-disable-next-line max-params, prefer-arrow/prefer-arrow-functions
export function GetMessage(
serviceModel: ServiceModel,
messageModel: MessageModel,
Expand All @@ -240,7 +240,7 @@ export function GetMessage(
);
return wrapRequestHandler(
middlewaresWrap(
// eslint-disable-next-line @typescript-eslint/naming-convention, max-params
// eslint-disable-next-line max-params
checkSourceIpForHandler(handler, (_, __, c, u, ___, ____) =>
ipTuple(c, u)
)
Expand Down
9 changes: 3 additions & 6 deletions GetService/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ const getServiceTask = (
logger,
() =>
apiClient.getService({
// eslint-disable-next-line @typescript-eslint/naming-convention
service_id: serviceId
}),
200
Expand All @@ -88,7 +87,6 @@ const getSubscriptionKeysTask = (
logger,
() =>
apiClient.getSubscriptionKeys({
// eslint-disable-next-line @typescript-eslint/naming-convention
service_id: serviceId
}),
200
Expand All @@ -97,9 +95,9 @@ const getSubscriptionKeysTask = (
/**
* Handles requests for getting a single service by a service ID.
*/
// eslint-disable-next-line prefer-arrow/prefer-arrow-functions, @typescript-eslint/naming-convention
// eslint-disable-next-line prefer-arrow/prefer-arrow-functions
export function GetServiceHandler(apiClient: APIClient): IGetServiceHandler {
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/naming-convention
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
return (_, apiAuth, ___, ____, serviceId) =>
serviceOwnerCheckTask(serviceId, apiAuth.subscriptionId)
.chain(() =>
Expand Down Expand Up @@ -130,7 +128,7 @@ export function GetServiceHandler(apiClient: APIClient): IGetServiceHandler {
/**
* Wraps a GetService handler inside an Express request handler.
*/
// eslint-disable-next-line prefer-arrow/prefer-arrow-functions, @typescript-eslint/naming-convention
// eslint-disable-next-line prefer-arrow/prefer-arrow-functions
export function GetService(
serviceModel: ServiceModel,
client: APIClient
Expand All @@ -145,7 +143,6 @@ export function GetService(
);
return wrapRequestHandler(
middlewaresWrap(
// eslint-disable-next-line @typescript-eslint/naming-convention
checkSourceIpForHandler(handler, (_, __, c, u, ___) => ipTuple(c, u))
)
);
Expand Down
5 changes: 2 additions & 3 deletions GetSubscriptionsFeed/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ type IGetSubscriptionsFeedHandler = (
/**
* Handles requests for getting a single message for a recipient.
*/
// eslint-disable-next-line prefer-arrow/prefer-arrow-functions, @typescript-eslint/naming-convention
// eslint-disable-next-line prefer-arrow/prefer-arrow-functions
export function GetSubscriptionsFeedHandler(
tableService: TableService,
subscriptionsFeedTable: string
Expand Down Expand Up @@ -190,7 +190,6 @@ export function GetSubscriptionsFeedHandler(
/**
* A string that represents a date in the format YYYY-MM-DD
*/
// eslint-disable-next-line @typescript-eslint/naming-convention
const ShortDateString = t.refinement(
PatternString("\\d\\d\\d\\d-\\d\\d-\\d\\d"),
s => !isNaN(new Date(s).getTime()),
Expand All @@ -200,7 +199,7 @@ const ShortDateString = t.refinement(
/**
* Wraps a GetMessage handler inside an Express request handler.
*/
// eslint-disable-next-line prefer-arrow/prefer-arrow-functions, @typescript-eslint/naming-convention
// eslint-disable-next-line prefer-arrow/prefer-arrow-functions
export function GetSubscriptionsFeed(
serviceModel: ServiceModel,
tableService: TableService,
Expand Down
1 change: 0 additions & 1 deletion GetSubscriptionsFeed/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { FiscalCodeHash } from "../generated/definitions/FiscalCodeHash";
* A minimal storage table Entry
*/
type TableEntry = Readonly<{
// eslint-disable-next-line @typescript-eslint/naming-convention
readonly RowKey: Readonly<{
readonly _: string;
}>;
Expand Down
Loading