Skip to content

Commit

Permalink
Merge pull request #3401 from novuhq/fix-deepsource-analysis-recommen…
Browse files Browse the repository at this point in the history
…dations

fix(deepsource): analysis recommendations improvements
  • Loading branch information
Pablo Fernández committed May 14, 2023
2 parents 0469633 + 2c35def commit e75d926
Show file tree
Hide file tree
Showing 27 changed files with 50 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ describe('Get My Environments - /environments (GET)', async () => {
const { body } = await session.testAgent.get('/v1/environments');

expect(body.data.length).to.be.greaterThanOrEqual(2);
for (let i = 0; i < body.data.length; i++) {
expect(body.data[i]._organizationId).to.eq(session.organization._id);
for (const elem of body.data) {
expect(elem._organizationId).to.eq(session.organization._id);
}
});
});
4 changes: 2 additions & 2 deletions apps/web/cypress/tests/activity-graph.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
describe('Activity page', function () {
beforeEach(function () {
// @ts-ignore
// @ts-expect-error
cy.initializeSession()
.as('session')
.then((session: any) => {
Expand All @@ -18,7 +18,7 @@ describe('Activity page', function () {
cy.visit('/activities');
cy.location('pathname').should('equal', '/activities');

// @ts-ignore
// @ts-expect-error
cy.getByTestId('activity-stats-weekly-sent').contains('25');
});
});
2 changes: 1 addition & 1 deletion apps/web/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ if (SENTRY_DSN) {
* can not be null because of the check in the if statement above.
*/
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
// @ts-expect-error
event.extra.LogRocket = logRocketSession;

return event;
Expand Down
3 changes: 2 additions & 1 deletion apps/web/src/hooks/useEnvironmentChanges.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useQuery } from '@tanstack/react-query';

import { useEnvController } from '../hooks';
import { useEnvController } from './useEnvController';

import { getPromotedChanges, getUnpromotedChanges } from '../api/changes';
import { QueryKeys } from '../api/query.keys';

Expand Down
6 changes: 4 additions & 2 deletions apps/web/src/hooks/useLayouts.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { useQuery } from '@tanstack/react-query';
import { useEnvController } from '../hooks';
import { ILayoutEntity } from '@novu/shared';

import { useEnvController } from './useEnvController';

import { QueryKeys } from '../api/query.keys';
import { getLayoutsList } from '../api/layouts';
import { ILayoutEntity } from '@novu/shared';

export function useLayouts(page = 0, pageSize = 10) {
const { environment } = useEnvController();
Expand Down
3 changes: 2 additions & 1 deletion apps/web/src/hooks/useSubscribers.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { useQuery } from '@tanstack/react-query';
import { ISubscriber } from '@novu/shared';

import { useEnvController } from './useEnvController';

import { getSubscribersList } from '../api/subscribers';
import { useEnvController } from '../hooks';

export function useSubscribers(page = 0, limit = 10) {
const { environment } = useEnvController();
Expand Down
3 changes: 2 additions & 1 deletion apps/web/src/hooks/useTemplates.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { useQuery } from '@tanstack/react-query';
import { INotificationTemplate } from '@novu/shared';

import { useEnvController } from '../hooks';
import { useEnvController } from './useEnvController';

import { getNotificationsList } from '../api/notification-templates';

export function useTemplates(page = 0, limit = 10) {
Expand Down
2 changes: 0 additions & 2 deletions apps/web/src/pages/brand/tabs/LayoutEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ export function LayoutEditor({
const [showModal, confirmNavigation, cancelNavigation] = usePrompt(isDirty);

const layoutContent = watch('content');
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const variablesArray = useFieldArray({ control, name: `variables` });
const variableArray = watch(`variables`, []);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Stack } from '@mantine/core';

import { LinkProjectContainer } from './components/LinkProjectContainer';

import { PartnerIntegrationLayout } from '../../components/layout/components/PartnerIntegrationLayout';
import { LinkProjectContainer } from './components//LinkProjectContainer';
import { Container, Text, Title } from '../../design-system';
import { ThemeProvider } from '../../design-system/ThemeProvider';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { LinkMoreProjectRow } from './LinkMoreProjectRow';
import { ProjectRow } from './ProjectRow';
import { Text, colors, Button } from '../../../design-system';
import { errorMessage, successMessage } from '../../../utils/notifications';
import SetupLoader from '../../../pages/auth/components/SetupLoader';
import SetupLoader from '../../auth/components/SetupLoader';

export type ProjectLinkFormValues = {
projectLinkState: {
Expand Down Expand Up @@ -115,12 +115,12 @@ export function LinkProjectContainer({ type }: { type: 'edit' | 'create' }) {
};

const submitProjectLink = (data: ProjectLinkFormValues) => {
const payload = data.projectLinkState.reduce((acc, curr) => {
const payload = data.projectLinkState.reduce<Record<string, string[]>>((acc, curr) => {
const { organizationId, projectIds } = curr;
acc[organizationId] = projectIds;

return acc;
}, {} as Record<string, string[]>);
}, {});

if (configurationId) {
if (type === 'create') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ import { Badge, Card, Container, Group, Space, useMantineTheme } from '@mantine/
import { useState } from 'react';
import { formatDistanceToNow, subMinutes } from 'date-fns';
import { IMessageAction } from '@novu/shared';
import { colors, shadows, Text, Title } from '../../../../../design-system';
import { ButtonsTemplatesPopover } from '../../in-app-editor/ButtonsTemplatesPopover';

import { ActionBlockContainer } from './ActionBlockContainer';
import AvatarContainer from './AvatarContainer';

import { colors, shadows, Text, Title } from '../../../../../design-system';
import { ButtonsTemplatesPopover } from '../ButtonsTemplatesPopover';

function minutesAgo(num: number): string {
return formatDistanceToNow(subMinutes(new Date(), num), { addSuffix: true });
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { CacheKeyPrefixEnum } from '../key-builders';
const LOG_CONTEXT = 'CachedInterceptor';

// eslint-disable-next-line @typescript-eslint/naming-convention
function Cached(storeKeyPrefix: CacheKeyPrefixEnum) {
export function Cached(storeKeyPrefix: CacheKeyPrefixEnum) {
const injectCache = Inject(CacheService);

return (target: any, key: string, descriptor: any) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Handlebars.registerHelper(
HandlebarHelpersEnum.EQUALS,
function (arg1, arg2, options) {
// eslint-disable-next-line
// @ts-ignore
// @ts-expect-error
return arg1 == arg2 ? options.fn(this) : options.inverse(this);
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ import React, { useState } from 'react';
import styled from '@emotion/styled';
import { css, cx } from '@emotion/css';

import { Loader } from '../Loader';
import { Header } from '../layout/header/Header';
import { Header } from './header/Header';
import { UserPreferenceHeader } from './header/UserPreferenceHeader';
import { FooterContainer as Footer } from './footer/FooterContainer';

import { Loader } from '../Loader';
import { useNotificationCenter, useNovuContext, useNovuTheme } from '../../../../hooks';
import { UserPreferenceHeader } from './header/UserPreferenceHeader';
import { SubscriberPreference } from '../user-preference/SubscriberPreference';
import { FeedsTabs } from '../FeedsTabs';
import { INovuTheme } from '../../../../store/novu-theme.context';
Expand Down
10 changes: 5 additions & 5 deletions packages/notification-center/src/utils/react-to-webcomponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export default function (
let rendering = false;
// Create the web component "class"
const WebComponent = function (...args) {
// @ts-ignore
// @ts-expect-error
const self = Reflect.construct(HTMLElement, args, this.constructor);
if (typeof options.shadow === 'string') {
self.attachShadow({ mode: options.shadow });
Expand Down Expand Up @@ -189,7 +189,7 @@ export default function (
moveUpdateToNextTick(() => this[renderSymbol]());
};
targetPrototype.disconnectedCallback = function () {
// @ts-ignore
// @ts-expect-error
if (typeof ReactDOM.createRoot === 'function') {
this[rootSymbol].unmount();
} else {
Expand All @@ -201,7 +201,7 @@ export default function (
const data = {};
Object.keys(this).forEach(function (key) {
if (renderAddedProperties[key] !== false) {
// @ts-ignore
// @ts-expect-error
data[key] = this[key];
}
}, this);
Expand All @@ -212,10 +212,10 @@ export default function (
const element = React.createElement(ReactComponent, data, children);

// Use react to render element in container
// @ts-ignore
// @ts-expect-error
if (typeof ReactDOM.createRoot === 'function') {
if (!this[rootSymbol]) {
// @ts-ignore
// @ts-expect-error
this[rootSymbol] = ReactDOM.createRoot(container);
}

Expand Down
2 changes: 0 additions & 2 deletions providers/clickatell/src/lib/clickatell.provider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ test('should trigger clickatellSmsProvider library correctly', async () => {
});

const spy = jest
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
.spyOn(provider, 'sendMessage')
.mockImplementation(async () => {
return {
Expand Down
2 changes: 0 additions & 2 deletions providers/discord/src/lib/discord.provider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { DiscordProvider } from './discord.provider';
test('should trigger Discord provider correctly', async () => {
const provider = new DiscordProvider({});
const spy = jest
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
.spyOn(provider, 'sendMessage')
.mockImplementation(async () => {
return {
Expand Down
4 changes: 2 additions & 2 deletions providers/expo/src/lib/expo.provider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ test('should trigger expo correctly', async () => {

const spy = jest
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
// @ts-expect-error
.spyOn(provider.expo, 'sendPushNotificationsAsync')
.mockImplementation(async () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand All @@ -23,7 +23,7 @@ test('should trigger expo correctly', async () => {
},
});
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
// @ts-expect-error
expect(provider.expo).toBeDefined();
expect(spy).toHaveBeenCalled();
expect(spy).toHaveBeenCalledWith([
Expand Down
2 changes: 1 addition & 1 deletion providers/fcm/src/lib/fcm.provider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ beforeEach(() => {

spy = jest
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
// @ts-expect-error
.spyOn(provider.messaging, 'sendMulticast')
.mockImplementation(async () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down
4 changes: 2 additions & 2 deletions providers/infobip/src/lib/infobip.provider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ test('should trigger infobip library correctly - SMS', async () => {

const spy = jest
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
// @ts-expect-error
.spyOn(provider.infobipClient.channels.sms, 'send')
.mockImplementation(async () => {
return {
Expand Down Expand Up @@ -49,7 +49,7 @@ test('should trigger infobip library correctly - E-mail', async () => {

const spy = jest
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
// @ts-expect-error
.spyOn(provider.infobipClient.channels.email, 'send')
.mockImplementation(async () => {
return {
Expand Down
2 changes: 1 addition & 1 deletion providers/maqsam/src/lib/maqsam.provider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ test('should trigger Maqsam correctly', async () => {
});
const spy = jest
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
// @ts-expect-error
.spyOn(provider.axiosInstance, 'request')
.mockImplementation(async () => {
return {
Expand Down
2 changes: 1 addition & 1 deletion providers/nexmo/src/lib/nexmo.provider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ test('should trigger nexmo library correctly', async () => {

const spy = jest
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
// @ts-expect-error
.spyOn(provider.vonageClient.message, 'sendSms')
.mockImplementation(async (_a, _b, _c, _d, cb) => {
cb(null, {
Expand Down
2 changes: 1 addition & 1 deletion providers/plivo/src/lib/plivo.provider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ test('should trigger plivo correctly', async () => {

const spy = jest
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
// @ts-expect-error
.spyOn(provider.plivoClient.messages, 'create')
.mockImplementation(async () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down
2 changes: 0 additions & 2 deletions providers/slack/src/lib/slack.provider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { SlackProvider } from './slack.provider';
test('should trigger Slack correctly', async () => {
const provider = new SlackProvider();
const spy = jest
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
.spyOn(provider, 'sendMessage')
.mockImplementation(async () => {
return {
Expand Down
2 changes: 1 addition & 1 deletion providers/sms77/src/lib/sms77.provider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ test('should trigger sms77 correctly', async () => {

const spy = jest
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
// @ts-expect-error
.spyOn(provider.sms77Client, 'sms')
.mockImplementation(async () => {
return {
Expand Down
8 changes: 4 additions & 4 deletions providers/telnyx/src/lib/telnyx.provider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import { TelnyxSmsProvider } from './telnyx.provider';

test('should trigger Telnyx correctly', async () => {
const provider = new TelnyxSmsProvider({
apiKey: 'API-KEY-MOCKI023893KLSPP',
apiKey: 'API-KEY-MOCK1023893INAPP',
from: 'TelynxTest',
messageProfileId: 'jap-ops-pkd-pn-pdkd',
messageProfileId: 'jap-ops-pkd-pn-pair',
});

const spy = jest
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
// @ts-expect-error
.spyOn(provider.telnyxClient.messages, 'create')
.mockImplementation(async () => {
return {
Expand All @@ -30,6 +30,6 @@ test('should trigger Telnyx correctly', async () => {
from: 'TelynxTest',
text: 'We are testing',
to: '+2347069652019',
messaging_profile_id: 'jap-ops-pkd-pn-pdkd',
messaging_profile_id: 'jap-ops-pkd-pn-pair',
});
});
2 changes: 1 addition & 1 deletion providers/twilio/src/lib/twilio.provider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ test('should trigger Twilio correctly', async () => {
});
const spy = jest
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
// @ts-expect-error
.spyOn(provider.twilioClient.messages, 'create')
.mockImplementation(async () => {
return {
Expand Down

0 comments on commit e75d926

Please sign in to comment.