Skip to content

Commit

Permalink
remove eslint disablers
Browse files Browse the repository at this point in the history
  • Loading branch information
balanza committed Apr 13, 2021
1 parent c83a107 commit ddcf4ca
Show file tree
Hide file tree
Showing 33 changed files with 29 additions and 136 deletions.
48 changes: 22 additions & 26 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
module.exports = {
"env": {
"browser": true,
"es6": true,
"node": true
},
"ignorePatterns": [
"node_modules",
"generated",
"**/__tests__/*",
"**/__mocks__/*",
"**/__integrations__/*",
"Dangerfile.*",
"*.d.ts"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "tsconfig.json",
"sourceType": "module"
},
"extends": [
"@pagopa/eslint-config/strong",
],
"rules": {
"jsdoc/check-indentation": "off"
}
}
env: {
browser: true,
es6: true,
node: true
},
ignorePatterns: [
"node_modules",
"generated",
"**/__tests__/*",
"**/__mocks__/*",
"**/__integrations__/*",
"Dangerfile.*",
"*.d.ts"
],
parser: "@typescript-eslint/parser",
parserOptions: {
project: "tsconfig.json",
sourceType: "module"
},
extends: ["@pagopa/eslint-config/strong"],
rules: {}
};
3 changes: 0 additions & 3 deletions src/entities/validation_token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,12 @@ export const VALIDATION_TOKEN_TABLE_NAME = "ValidationTokens";
* Used to describe properties of the ValidationToken storage table.
* By convention storage table properties uses PascalCase.
*/
/* eslint-disable @typescript-eslint/naming-convention */
export const ValidationToken = t.interface({
Email: EmailAddress,
FiscalCode,
InvalidAfter: UTCISODateFromString
});
/* eslint-enable @typescript-eslint/naming-convention */

// eslint-disable-next-line @typescript-eslint/naming-convention
export const ValidationTokenEntity = t.intersection([
ValidationToken,
TableEntity
Expand Down
15 changes: 3 additions & 12 deletions src/mailer/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import { MailMultiTransportConnectionsFromString } from "./multi_transport_conne

// exclude a specific value from a type
// as strict equality is performed, allowed input types are constrained to be values not references (object, arrays, etc)
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/naming-convention
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
export const AnyBut = <A extends string | number | boolean | symbol, O = A>(
but: A,
base: t.Type<A, O> = t.any
) =>
t.brand(
base,
// eslint-disable-next-line @typescript-eslint/naming-convention

(s): s is t.Branded<t.TypeOf<typeof base>, { readonly AnyBut: symbol }> =>
s !== but,
"AnyBut"
Expand All @@ -20,7 +20,6 @@ export const AnyBut = <A extends string | number | boolean | symbol, O = A>(
// Using sendgrid
// we allow mailup values as well, as sendgrid would be selected first if present
// see here for the rationale: https://github.com/pagopa/io-functions-admin/pull/89#commitcomment-42917672
/* eslint-disable @typescript-eslint/naming-convention */
export const SendgridMailerConfig = t.intersection([
t.interface({
MAILHOG_HOSTNAME: t.undefined,
Expand All @@ -33,10 +32,8 @@ export const SendgridMailerConfig = t.intersection([
MAILUP_USERNAME: NonEmptyString
})
]);
/* eslint-enable @typescript-eslint/naming-convention */

// using mailup
/* eslint-disable @typescript-eslint/naming-convention */
export const MailupMailerConfig = t.interface({
MAILHOG_HOSTNAME: t.undefined,
MAILUP_SECRET: NonEmptyString,
Expand All @@ -45,14 +42,12 @@ export const MailupMailerConfig = t.interface({
NODE_ENV: t.literal("production"),
SENDGRID_API_KEY: t.undefined
});
/* eslint-enable @typescript-eslint/naming-convention */

// Using multi-transport definition
// Optional multi provider connection string
// The connection string must be in the format:
// [mailup:username:password;][sendgrid:apikey:;]
// Note that multiple instances of the same provider can be provided.
/* eslint-disable @typescript-eslint/naming-convention */
export const MultiTrasnsportMailerConfig = t.interface({
MAILHOG_HOSTNAME: t.undefined,
MAILUP_SECRET: t.undefined,
Expand All @@ -61,10 +56,8 @@ export const MultiTrasnsportMailerConfig = t.interface({
NODE_ENV: t.literal("production"),
SENDGRID_API_KEY: t.undefined
});
/* eslint-enable @typescript-eslint/naming-convention */

// the following states that a mailhog configuration is optional and can be provided only if not in prod
/* eslint-disable @typescript-eslint/naming-convention */
export const MailhogMailerConfig = t.interface({
MAILHOG_HOSTNAME: NonEmptyString,
MAILUP_SECRET: t.undefined,
Expand All @@ -73,15 +66,13 @@ export const MailhogMailerConfig = t.interface({
NODE_ENV: AnyBut("production", t.string),
SENDGRID_API_KEY: t.undefined
});
/* eslint-enable @typescript-eslint/naming-convention */

// configuration to send email
export type MailerConfig = t.TypeOf<typeof MailerConfig>;
// eslint-disable-next-line @typescript-eslint/naming-convention

export const MailerConfig = t.intersection([
// common required fields
t.interface({
// eslint-disable-next-line @typescript-eslint/naming-convention
MAIL_FROM: NonEmptyString
}),
// the following union includes the possible configuration variants for different mail transports we use in prod
Expand Down
2 changes: 0 additions & 2 deletions src/mailer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ export const getMailerTransporter = (
? some(
MailUpTransport({
creds: {
// eslint-disable-next-line @typescript-eslint/naming-convention
Secret: config.MAILUP_SECRET,
// eslint-disable-next-line @typescript-eslint/naming-convention
Username: config.MAILUP_USERNAME
},
// HTTPS-only fetch with optional keepalive agent
Expand Down
4 changes: 0 additions & 4 deletions src/mailer/mailup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,7 @@ const NameValue = t.interface({

type NameValue = t.TypeOf<typeof NameValue>;

// eslint-disable-next-line @typescript-eslint/naming-convention
const Html = t.interface({
// eslint-disable-next-line @typescript-eslint/naming-convention
Body: NonEmptyString
});

Expand Down Expand Up @@ -180,15 +178,13 @@ const toMailupAddresses = (
addresses: ReadonlyArray<NodemailerAddress>
): ReadonlyArray<Address> =>
addresses.map((address: NodemailerAddress) => ({
// eslint-disable-next-line @typescript-eslint/naming-convention
Email: EmailString.decode(address.address).getOrElseL(() => {
// this never happens as nodemailer has already parsed
// the email address (so it's a valid one)
throw new Error(
`Error while parsing email address (toMailupAddresses): invalid format '${address.address}'.`
);
}),
// eslint-disable-next-line @typescript-eslint/naming-convention
Name: address.name || address.address
}));

Expand Down
3 changes: 0 additions & 3 deletions src/mailer/multi_transport_connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { NonEmptyString } from "@pagopa/ts-commons/lib/strings";
/**
* Describes a nodemailer transport connection
*/
// eslint-disable-next-line @typescript-eslint/naming-convention
export const MailTransportConnection = t.interface({
password: t.string,
transport: NonEmptyString,
Expand All @@ -19,7 +18,6 @@ export type MailTransportConnection = t.TypeOf<typeof MailTransportConnection>;
/**
* An array of nodemailer transport connections
*/
// eslint-disable-next-line @typescript-eslint/naming-convention
export const MailMultiTransportConnections = t.readonlyArray(
MailTransportConnection
);
Expand Down Expand Up @@ -61,7 +59,6 @@ const parseMultiProviderConnection = (
* Decodes an array of nodemailer transport connections from a multi
* transport connection string.
*/
// eslint-disable-next-line @typescript-eslint/naming-convention
export const MailMultiTransportConnectionsFromString = new t.Type<
MailMultiTransportConnections,
string,
Expand Down
3 changes: 0 additions & 3 deletions src/mailer/transports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import { MailMultiTransportConnections } from "./multi_transport_connection";
*
* @returns maybe a mailer transport
*/
// eslint-disable-next-line @typescript-eslint/naming-convention
const MultiTransport = (
transports: ReadonlyArray<Transport>
): Transport | undefined => {
Expand Down Expand Up @@ -101,9 +100,7 @@ const getTransportsForConnections = (
return some(
MailUpTransport({
creds: {
// eslint-disable-next-line @typescript-eslint/naming-convention
Secret: config.password,
// eslint-disable-next-line @typescript-eslint/naming-convention
Username: config.username
},
fetchAgent
Expand Down
3 changes: 0 additions & 3 deletions src/models/created_message_event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,17 @@ import { NewMessageWithoutContent } from "./message";

import { CreatedMessageEventSenderMetadata } from "./created_message_sender_metadata";

// eslint-disable-next-line @typescript-eslint/naming-convention
const CreatedMessageEventR = t.interface({
content: MessageContent,
message: NewMessageWithoutContent,
senderMetadata: CreatedMessageEventSenderMetadata,
serviceVersion: NonNegativeNumber
});

// eslint-disable-next-line @typescript-eslint/naming-convention
const CreatedMessageEventO = t.partial({
defaultAddresses: NewMessageDefaultAddresses
});

// eslint-disable-next-line @typescript-eslint/naming-convention
export const CreatedMessageEvent = t.intersection(
[CreatedMessageEventR, CreatedMessageEventO],
"CreatedMessageEvent"
Expand Down
1 change: 0 additions & 1 deletion src/models/created_message_sender_metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { OrganizationFiscalCode } from "../../generated/definitions/Organization
/**
* Sender metadata associated to a message
*/
// eslint-disable-next-line @typescript-eslint/naming-convention
export const CreatedMessageEventSenderMetadata = t.interface({
departmentName: NonEmptyString,
organizationFiscalCode: OrganizationFiscalCode,
Expand Down
13 changes: 0 additions & 13 deletions src/models/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ export const MESSAGE_MODEL_PK_FIELD = "fiscalCode" as const;

const MESSAGE_BLOB_STORAGE_SUFFIX = ".json";

// eslint-disable-next-line @typescript-eslint/naming-convention
const MessageBaseR = t.interface({
// when the message was accepted by the system
createdAt: Timestamp,
Expand All @@ -71,7 +70,6 @@ const MessageBaseR = t.interface({
timeToLiveSeconds: TimeToLiveSeconds
});

// eslint-disable-next-line @typescript-eslint/naming-convention
const MessageBaseO = t.partial({
// When true, the message is still being processed and should be
// hidden from the result of getMessages requests. This is needed to avoid
Expand All @@ -81,7 +79,6 @@ const MessageBaseO = t.partial({
isPending: t.boolean
});

// eslint-disable-next-line @typescript-eslint/naming-convention
const MessageBase = t.intersection([MessageBaseR, MessageBaseO], "MessageBase");

/**
Expand All @@ -96,7 +93,6 @@ type MessageBase = t.TypeOf<typeof MessageBase>;
* to have the content of the messages permanently stored in his inbox.
*/
export type MessageWithoutContent = MessageBase;
// eslint-disable-next-line @typescript-eslint/naming-convention
export const MessageWithoutContent = MessageBase;

/**
Expand All @@ -105,7 +101,6 @@ export const MessageWithoutContent = MessageBase;
* A Message gets stored with content if the recipient opted-in
* to have the content of the messages permanently stored in his inbox.
*/
// eslint-disable-next-line @typescript-eslint/naming-convention
export const MessageWithContent = t.intersection([
t.interface({
content: MessageContent
Expand All @@ -118,20 +113,17 @@ export type MessageWithContent = t.TypeOf<typeof MessageWithContent>;
/**
* A Message can be with our without content
*/
// eslint-disable-next-line @typescript-eslint/naming-convention
export const Message = t.union([MessageWithoutContent, MessageWithContent]);

export type Message = t.TypeOf<typeof Message>;

// eslint-disable-next-line @typescript-eslint/naming-convention
export const NewMessageWithContent = wrapWithKind(
t.intersection([MessageWithContent, BaseModel]),
"INewMessageWithContent" as const
);

export type NewMessageWithContent = t.TypeOf<typeof NewMessageWithContent>;

// eslint-disable-next-line @typescript-eslint/naming-convention
export const NewMessageWithoutContent = wrapWithKind(
t.intersection([MessageWithoutContent, BaseModel]),
"INewMessageWithoutContent" as const
Expand All @@ -144,15 +136,13 @@ export type NewMessageWithoutContent = t.TypeOf<
/**
* A (yet to be saved) Message
*/
// eslint-disable-next-line @typescript-eslint/naming-convention
export const NewMessage = t.union([
NewMessageWithContent,
NewMessageWithoutContent
]);

export type NewMessage = t.TypeOf<typeof NewMessage>;

// eslint-disable-next-line @typescript-eslint/naming-convention
export const RetrievedMessageWithContent = wrapWithKind(
t.intersection([MessageWithContent, CosmosResource]),
"IRetrievedMessageWithContent" as const
Expand All @@ -162,7 +152,6 @@ export type RetrievedMessageWithContent = t.TypeOf<
typeof RetrievedMessageWithContent
>;

// eslint-disable-next-line @typescript-eslint/naming-convention
export const RetrievedMessageWithoutContent = wrapWithKind(
t.intersection([MessageWithoutContent, CosmosResource]),
"IRetrievedMessageWithoutContent" as const
Expand All @@ -172,7 +161,6 @@ export type RetrievedMessageWithoutContent = t.TypeOf<
typeof RetrievedMessageWithoutContent
>;

// eslint-disable-next-line @typescript-eslint/naming-convention
export const ActiveMessage = t.refinement(
MessageBase,
message =>
Expand All @@ -186,7 +174,6 @@ export type NotExpiredMessage = t.TypeOf<typeof ActiveMessage>;
/**
* A (previously saved) retrieved Message
*/
// eslint-disable-next-line @typescript-eslint/naming-convention
export const RetrievedMessage = t.union([
RetrievedMessageWithContent,
RetrievedMessageWithoutContent
Expand Down
3 changes: 0 additions & 3 deletions src/models/message_status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export const MESSAGE_STATUS_MODEL_PK_FIELD = "messageId" as const;

// We cannot intersect with MessageStatus
// as it is a *strict* interface
// eslint-disable-next-line @typescript-eslint/naming-convention
export const MessageStatus = t.interface({
messageId: NonEmptyString,
status: MessageStatusValue,
Expand All @@ -31,15 +30,13 @@ export const MessageStatus = t.interface({

export type MessageStatus = t.TypeOf<typeof MessageStatus>;

// eslint-disable-next-line @typescript-eslint/naming-convention
export const NewMessageStatus = wrapWithKind(
MessageStatus,
"INewMessageStatus" as const
);

export type NewMessageStatus = t.TypeOf<typeof NewMessageStatus>;

// eslint-disable-next-line @typescript-eslint/naming-convention
export const RetrievedMessageStatus = wrapWithKind(
t.intersection([MessageStatus, RetrievedVersionedModel]),
"IRetrievedMessageStatus" as const
Expand Down
Loading

0 comments on commit ddcf4ca

Please sign in to comment.