Skip to content

Commit

Permalink
fix(eslint): pass #9 (#1928)
Browse files Browse the repository at this point in the history
## Describe your changes

- Run automated fix `npx eslint --fix`
- Added `.js` on type import (unfortunately it's a known limitation from
the package)
- Sync our usage of `ms` (types conflict)
- Bonus: naming the testcontainers was nice but it can conflict if you
relaunch the process very fast
  • Loading branch information
bodinsamuel authored Apr 2, 2024
1 parent c28f027 commit 974d8e8
Show file tree
Hide file tree
Showing 45 changed files with 92 additions and 80 deletions.
1 change: 0 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module",
"ecmaFeatures": {
"impliedStrict": true,
Expand Down
13 changes: 8 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/server/lib/controllers/flow.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ class FlowController {
const syncs = await getSyncsByConnectionIdsAndEnvironmentIdAndSyncName(connections, environmentId, syncName);

for (const sync of syncs) {
await syncOrchestrator.softDeleteSync(sync.id!, environmentId);
await syncOrchestrator.softDeleteSync(sync.id, environmentId);
}
}

Expand Down
4 changes: 2 additions & 2 deletions packages/server/lib/controllers/sync.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ class SyncController {
const setFrequency = `every ${frequency}`;
for (const sync of syncs) {
const { success: updateScheduleSuccess, error: updateScheduleError } = await updateSyncScheduleFrequency(
sync.id as string,
sync.id,
setFrequency,
sync.name,
environment.id
Expand Down Expand Up @@ -868,7 +868,7 @@ class SyncController {
res.status(400).send({ message: 'Invalid sync_name' });
return;
}
const syncId = syncs[0]!.id!;
const syncId = syncs[0]!.id;

// When "frequency === null" we revert the value stored in the sync config
if (!newFrequency) {
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/lib/db/seeders/account.seeder.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { v4 as uuid } from 'uuid';
import type { Account } from '../../models';
import type { Account } from '../../models/index.js';

import accountService from '../../services/account.service';
import accountService from '../../services/account.service.js';

export async function createAccount(): Promise<Account> {
const acc = await accountService.createAccount(uuid());
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/lib/db/seeders/activity.seeder.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as activityService from '../../services/activity/activity.service.js';
import type { ActivityLog } from '../../models/Activity';
import type { ActivityLog } from '../../models/Activity.js';

export const createActivityLogSeed = async (environmentId: number): Promise<number> => {
const log = {
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/lib/models/Onboarding.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Timestamps } from './Generic';
import type { Timestamps } from './Generic.js';

export interface Onboarding extends Timestamps {
id?: number;
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/lib/models/SlackNotification.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Timestamps } from './Generic';
import type { SyncConfigType } from './Sync';
import type { Timestamps } from './Generic.js';
import type { SyncConfigType } from './Sync.js';

export interface SlackNotification extends Timestamps {
id?: number;
Expand Down
1 change: 1 addition & 0 deletions packages/shared/lib/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ export * from './Flow.js';
export * from './NangoConfig.js';
export * from './Proxy.js';
export * from './Runner.js';
export * from './Onboarding.js';
2 changes: 1 addition & 1 deletion packages/shared/lib/sdk/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import paginateService from '../services/paginate.service.js';
import proxyService from '../services/proxy.service.js';
import axios from 'axios';
import { getPersistAPIUrl, safeStringify } from '../utils/utils.js';
import type { IntegrationWithCreds } from '@nangohq/node/lib/types.js';
import type { IntegrationWithCreds } from '@nangohq/node';
import type { UserProvidedProxyConfiguration } from '../models/Proxy.js';
import { getLogger } from '../utils/temp/logger.js';
import telemetry, { MetricTypes } from '../utils/telemetry.js';
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/lib/services/account.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import db from '../db/database.js';
import type { Account } from '../models/Admin';
import type { Environment } from '../models/Environment';
import type { Account } from '../models/Admin.js';
import type { Environment } from '../models/Environment.js';
import { LogActionEnum } from '../models/Activity.js';
import environmentService from './environment.service.js';
import errorManager, { ErrorSourceEnum } from '../utils/error.manager.js';
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/lib/services/flow.service.unit.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect, describe, it, vi, afterEach } from 'vitest';
import type { Config } from './flow.service';
import FlowService from './flow.service';
import type { Config } from './flow.service.js';
import FlowService from './flow.service.js';

const flows = {
integrations: {
Expand Down
6 changes: 3 additions & 3 deletions packages/shared/lib/services/notification/slack.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { schema, dbNamespace } from '../../db/database.js';
import type { SlackNotification } from '../../models/SlackNotification';
import type { NangoConnection } from '../../models/Connection';
import type { ServiceResponse } from '../../models/Generic';
import type { SlackNotification } from '../../models/SlackNotification.js';
import type { NangoConnection } from '../../models/Connection.js';
import type { ServiceResponse } from '../../models/Generic.js';
import { SyncType, SyncConfigType } from '../../models/Sync.js';
import environmentService from '../environment.service.js';
import type { LogLevel } from '../../models/Activity.js';
Expand Down
3 changes: 1 addition & 2 deletions packages/shared/lib/services/notification/webhook.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ import { backOff } from 'exponential-backoff';
import crypto from 'crypto';
import { SyncType } from '../../models/Sync.js';
import type { NangoConnection, RecentlyCreatedConnection } from '../../models/Connection.js';
import type { Environment } from '../../models/Environment';
import type { Environment, SyncResult } from '../../models/index.js';
import type { LogLevel } from '../../models/Activity.js';
import { LogActionEnum } from '../../models/Activity.js';
import type { SyncResult } from '../../models/Sync';
import type { NangoSyncWebhookBody, NangoAuthWebhookBody, NangoForwardWebhookBody } from '../../models/Webhook.js';
import { WebhookType } from '../../models/Webhook.js';
import environmentService from '../environment.service.js';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import environmentService from '../environment.service.js';
import { SyncType } from '../../models/Sync.js';
import type { RecentlyCreatedConnection, NangoConnection } from '../../models/Connection.js';
import WebhookService from './webhook.service.js';
import type { Environment } from '../../models/Environment';
import type { Environment } from '../../models/Environment.js';
import { mockCreateActivityLog } from '../activity/mocks.js';

vi.mock('axios', () => ({
Expand Down
3 changes: 1 addition & 2 deletions packages/shared/lib/services/onboarding.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { Onboarding } from '../models/Onboarding';
import type { Onboarding, Config } from '../models/index.js';
import db, { dbNamespace } from '../db/database.js';
import configService from './config.service.js';
import type { Config } from '../models';

export const DEFAULT_GITHUB_CLIENT_ID = process.env['DEFAULT_GITHUB_CLIENT_ID'] || '';
export const DEFAULT_GITHUB_CLIENT_SECRET = process.env['DEFAULT_GITHUB_CLIENT_SECRET'] || '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { SyncConfigType } from '../../../models/Sync.js';
import type { NangoConnection } from '../../../models/Connection.js';
import type { HTTP_VERB } from '../../../models/Generic.js';
import { OpenApiBuilder } from 'openapi3-ts/oas31';
import type { ParameterObject } from 'openapi3-ts/dist/oas30.js';
import type { ParameterObject } from 'openapi3-ts/oas31';

const ENDPOINT_TABLE = dbNamespace + 'sync_endpoints';
const SYNC_CONFIG_TABLE = dbNamespace + 'sync_configs';
Expand Down
18 changes: 9 additions & 9 deletions packages/shared/lib/services/sync/orchestrator.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import type {
} from '../../models/Sync.js';
import { NangoError } from '../../utils/error.js';
import type { Config as ProviderConfig } from '../../models/Provider.js';
import type { ServiceResponse } from '../../models/Generic';
import type { ServiceResponse } from '../../models/Generic.js';
import { SyncStatus, ScheduleStatus, SyncConfigType, SyncCommand, CommandToActivityLog } from '../../models/Sync.js';

interface CreateSyncArgs {
Expand Down Expand Up @@ -144,7 +144,7 @@ export class Orchestrator {
}

for (const sync of syncs) {
await this.softDeleteSync(sync.id!, connection.environment_id);
await this.softDeleteSync(sync.id, connection.environment_id);
}
}

Expand All @@ -156,7 +156,7 @@ export class Orchestrator {
}

for (const sync of syncs) {
await this.softDeleteSync(sync.id as string, environmentId);
await this.softDeleteSync(sync.id, environmentId);
}
}

Expand Down Expand Up @@ -210,14 +210,14 @@ export class Orchestrator {
if (!sync) {
throw new Error(`Sync "${syncName}" doesn't exists.`);
}
const schedule = await getSchedule(sync.id as string);
const schedule = await getSchedule(sync.id);
if (!schedule) {
continue;
}

await syncClient.runSyncCommand(
schedule.schedule_id,
sync?.id as string,
sync?.id,
command,
activityLogId,
environmentId,
Expand All @@ -244,7 +244,7 @@ export class Orchestrator {
}

for (const sync of syncs) {
const schedule = await getSchedule(sync.id as string);
const schedule = await getSchedule(sync.id);
if (!schedule) {
continue;
}
Expand All @@ -256,7 +256,7 @@ export class Orchestrator {

await syncClient.runSyncCommand(
schedule.schedule_id,
sync.id as string,
sync.id,
command,
activityLogId,
environmentId,
Expand Down Expand Up @@ -310,7 +310,7 @@ export class Orchestrator {
continue;
}

const { schedule, latestJob, status, nextScheduledSyncAt } = await this.fetchSyncData(sync?.id as string, environmentId);
const { schedule, latestJob, status, nextScheduledSyncAt } = await this.fetchSyncData(sync?.id, environmentId);
const reportedStatus = await this.reportedStatus(sync, latestJob, schedule, status, nextScheduledSyncAt, includeJobStatus);

syncsWithStatus.push(reportedStatus);
Expand All @@ -326,7 +326,7 @@ export class Orchestrator {
}

for (const sync of syncs) {
const { schedule, latestJob, status, nextScheduledSyncAt } = await this.fetchSyncData(sync?.id as string, environmentId);
const { schedule, latestJob, status, nextScheduledSyncAt } = await this.fetchSyncData(sync?.id, environmentId);
const reportedStatus = await this.reportedStatus(sync, latestJob, schedule, status, nextScheduledSyncAt, includeJobStatus);

syncsWithStatus.push(reportedStatus);
Expand Down
5 changes: 2 additions & 3 deletions packages/shared/lib/services/sync/run.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Context } from '@temporalio/activity';
import { loadLocalNangoConfig, nangoConfigFile } from '../nango-config.service.js';
import type { NangoConnection } from '../../models/Connection.js';
import type { NangoConnection, Metadata } from '../../models/Connection.js';
import type { SyncResult, SyncType, Job as SyncJob, IntegrationServiceInterface } from '../../models/Sync.js';
import { SyncStatus } from '../../models/Sync.js';
import type { ServiceResponse } from '../../models/Generic.js';
Expand All @@ -21,8 +21,7 @@ import telemetry, { LogTypes, MetricTypes } from '../../utils/telemetry.js';
import type { NangoIntegrationData, NangoIntegration } from '../../models/NangoConfig.js';
import type { UpsertSummary } from '../../models/Data.js';
import { LogActionEnum } from '../../models/Activity.js';
import type { Environment } from '../../models/Environment';
import type { Metadata } from '../../models/Connection';
import type { Environment } from '../../models/Environment.js';
import * as recordsService from './data/records.service.js';

interface BigQueryClientInterface {
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/lib/services/sync/sync.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ export const getAndReconcileDifferences = async (
for (const connection of connections) {
const syncId = await getSyncByIdAndName(connection.id as number, existingSync.sync_name);
if (syncId) {
await syncOrchestrator.softDeleteSync(syncId.id!, environmentId);
await syncOrchestrator.softDeleteSync(syncId.id, environmentId);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/lib/utils/encryption.manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { CipherGCMTypes } from 'crypto';
import utils from 'node:util';
import crypto from 'crypto';
import { getLogger } from '../utils/temp/logger.js';
import type { Config as ProviderConfig } from '../models/Provider';
import type { Config as ProviderConfig } from '../models/Provider.js';
import type { DBConfig } from '../models/Generic.js';
import type { Environment } from '../models/Environment.js';
import type { EnvironmentVariable } from '../models/EnvironmentVariable.js';
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/lib/utils/error.manager.mocks.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { vi } from 'vitest';
import environmentService from '../services/environment.service';
import userService from '../services/user.service';
import environmentService from '../services/environment.service.js';
import userService from '../services/user.service.js';

export function mockErrorManagerReport() {
vi.spyOn(environmentService, 'getEnvironmentName').mockImplementation(() => {
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/lib/utils/kvstore/InMemoryStore.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { KVStore } from './KVStore';
import type { KVStore } from './KVStore.js';

interface Value {
value: string;
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/lib/utils/kvstore/RedisStore.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { KVStore } from './KVStore';
import type { KVStore } from './KVStore.js';
import { createClient } from 'redis';
import type { RedisClientType } from 'redis';

Expand Down
4 changes: 4 additions & 0 deletions packages/shared/lib/vitest.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ declare module 'vitest' {
export interface AsymmetricMatchersContaining extends CustomMatchers {}
export interface ExpectStatic<T = any> extends CustomMatchers<T> {}
}

declare module 'ms' {
export interface StringValue {}
}
2 changes: 1 addition & 1 deletion packages/webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"env-cmd": "10.1.0",
"js-cookie": "3.0.5",
"lodash": "4.17.21",
"ms": "2.1.3",
"ms": "3.0.0-canary.1",
"postcss": "8.4.35",
"postcss-loader": "8.1.1",
"posthog-js": "1.116.2",
Expand Down
4 changes: 3 additions & 1 deletion packages/webapp/src/components/ErrorBoundary.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import React, { Component, ErrorInfo } from 'react';
import type { ErrorInfo } from 'react';
import type React from 'react';
import { Component } from 'react';

interface Props {
children: React.ReactNode;
Expand Down
2 changes: 1 addition & 1 deletion packages/webapp/src/components/ui/Info.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import type React from 'react';
import { Info as InfoIcon } from '@geist-ui/icons';

interface InfoProps {
Expand Down
6 changes: 4 additions & 2 deletions packages/webapp/src/components/ui/button/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { Loader } from '@geist-ui/icons';
import { cva, VariantProps } from 'class-variance-authority';
import type { VariantProps } from 'class-variance-authority';
import { cva } from 'class-variance-authority';
import classNames from 'classnames';
import React, { forwardRef } from 'react';
import type React from 'react';
import { forwardRef } from 'react';

const buttonStyles = cva('disabled:pointer-events-none disabled:opacity-50 rounded-md text-sm', {
variants: {
Expand Down
3 changes: 2 additions & 1 deletion packages/webapp/src/components/ui/input/SecretTextArea.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { forwardRef, useCallback, useState, ChangeEvent, TextareaHTMLAttributes } from 'react';
import type { ChangeEvent, TextareaHTMLAttributes } from 'react';
import { forwardRef, useCallback, useState } from 'react';
import { EyeIcon, EyeSlashIcon } from '@heroicons/react/24/outline';
import classNames from 'classnames';
import CopyButton from '../button/CopyButton';
Expand Down
2 changes: 1 addition & 1 deletion packages/webapp/src/components/ui/label/http.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FlowEndpoint } from '../../../types';
import type { FlowEndpoint } from '../../../types';

interface HttpLabelProp {
path: string;
Expand Down
3 changes: 2 additions & 1 deletion packages/webapp/src/components/ui/typography/Typography.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React, { forwardRef } from 'react';
import { Tooltip } from '@geist-ui/core';
import { HelpCircle } from '@geist-ui/icons';
import { cva, VariantProps } from 'class-variance-authority';
import type { VariantProps } from 'class-variance-authority';
import { cva } from 'class-variance-authority';
import classNames from 'classnames';

const typographyStyles = cva('flex gap-2 items-center tracking-tight font-bold', {
Expand Down
3 changes: 2 additions & 1 deletion packages/webapp/src/layout/DashboardLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { DebugMode } from '../components/DebugMode';
import LeftNavBar, { LeftNavBarItems } from '../components/LeftNavBar';
import type { LeftNavBarItems } from '../components/LeftNavBar';
import LeftNavBar from '../components/LeftNavBar';
import TopNavBar from '../components/TopNavBar';

interface DashboardLayoutI {
Expand Down
Loading

0 comments on commit 974d8e8

Please sign in to comment.