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

draft: attempt to fix code cycles via eslint... #9105

Closed
wants to merge 1 commit into from
Closed
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
9 changes: 7 additions & 2 deletions .eslintrc-diff.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ module.exports = {
'@typescript-eslint/ban-types': 'off',
'import/extensions': 'off',
'import/no-unresolved': 'off',
'import/no-cycle': 'off',
'import/named': 'off',
'no-underscore-dangle': 0,
'no-console': 0,
camelcase: 0,
Expand Down Expand Up @@ -147,9 +145,16 @@ module.exports = {
// "functional/no-let": "error",
// "functional/no-method-signature": "error",
// "functional/prefer-readonly-type": "error"

// ** block cyclical imports

'import/no-cycle': 2,
'import/named': 0,
'import/namespace': 0,
},
ignorePatterns: ['server/scripts/setupPrerenderService.ts'],
extends: [
'plugin:import/recommended',
'eslint:recommended',
'plugin:@tanstack/eslint-plugin-query/recommended',
'plugin:react-hooks/recommended',
Expand Down
5 changes: 5 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module.exports = {
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'prettier',
'plugin:import/recommended',
],
plugins: ['@typescript-eslint', 'n'],
parser: '@typescript-eslint/parser',
Expand Down Expand Up @@ -33,5 +34,9 @@ module.exports = {
'@typescript-eslint/no-namespace': 'off',
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
'n/no-process-exit': 'error',

'import/no-cycle': 0,
'import/named': 0,
'import/namespace': 0,
},
};
2 changes: 2 additions & 0 deletions libs/adapters/src/rabbitmq/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
export * from './RabbitMQAdapter';
// eslint-disable-next-line import/export
export * from './rabbitMQConfig';
// eslint-disable-next-line import/export
export { getRabbitMQConfig } from './rabbitMQConfig';
export * from './types';
export * from './util';
3 changes: 3 additions & 0 deletions libs/core/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
export * from './config';
export * from './errors';
// eslint-disable-next-line import/no-cycle
export * from './framework';
// eslint-disable-next-line import/no-cycle
export * from './integration';
// eslint-disable-next-line import/no-cycle
export * from './logging';
export * from './ports';
11 changes: 6 additions & 5 deletions libs/core/src/integration/chain-event.utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// eslint-disable-next-line import/no-cycle
import { EventNames, EventPairs } from '@hicommonwealth/core';
import { ETHERS_BIG_NUMBER, EVM_ADDRESS } from '@hicommonwealth/schemas';
import ethers from 'ethers';

Check warning on line 4 in libs/core/src/integration/chain-event.utils.ts

View workflow job for this annotation

GitHub Actions / Code Quality Recommendations (20)

Using exported name 'ethers' as identifier for default export
import { decodeLog } from 'web3-eth-abi';
import { z } from 'zod';

Expand Down Expand Up @@ -260,17 +261,17 @@
type AbiTypeToTS<T> = T extends 'address'
? z.infer<typeof EVM_ADDRESS>
: T extends 'uint256'
? z.infer<typeof ETHERS_BIG_NUMBER>
: T extends 'bool'
? boolean
: never;
? z.infer<typeof ETHERS_BIG_NUMBER>
: T extends 'bool'
? boolean
: never;

type Transform<T extends ReadonlyArray<{ name: string; type: string }>> = {
[K in T[number] as K['name']]: AbiTypeToTS<K['type']>;
};

type DecodedEvmEvent<Signature extends EvmEventSignature> = Transform<
typeof EvmEventAbis[Signature]
(typeof EvmEventAbis)[Signature]
>;

// EvmMapper maps chain event args as input to a zod event schema type as output
Expand Down
1 change: 1 addition & 0 deletions libs/core/src/integration/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from './chain-event.schemas';
// eslint-disable-next-line import/no-cycle
export * from './chain-event.utils';
export * from './email.schemas';
export * from './events';
Expand Down
1 change: 1 addition & 0 deletions libs/core/src/logging/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './interfaces';
// eslint-disable-next-line import/no-cycle
export * from './logger';
export { rollbar } from './rollbar';
1 change: 1 addition & 0 deletions libs/core/src/logging/logger.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { fileURLToPath } from 'url';
import { config } from '../config';
import { GetLogger, ILogger, LoggerIds } from './interfaces';
// eslint-disable-next-line import/no-cycle
import { getPinoLogger } from './pinoLogger';
import { testLogger } from './testLogger';

Expand Down
1 change: 1 addition & 0 deletions libs/core/src/logging/pinoLogger.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pino, { DestinationStream } from 'pino';
import { config } from '../config';
import { GetLogger, LogContext, LoggerIds } from './interfaces';
// eslint-disable-next-line import/no-cycle
import { rollbar } from './rollbar';

let transport: DestinationStream;
Expand Down
1 change: 1 addition & 0 deletions libs/core/src/logging/rollbar.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// eslint-disable-next-line import/no-cycle
import { config } from '@hicommonwealth/core';
import Rollbar from 'rollbar';

Expand Down
1 change: 1 addition & 0 deletions libs/core/src/ports/in-memory-brokers.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// eslint-disable-next-line import/no-cycle
import { RoutingKey } from '@hicommonwealth/core';

export const successfulInMemoryBroker = {
Expand Down
1 change: 1 addition & 0 deletions libs/core/src/ports/in-memory-notification-providers.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// eslint-disable-next-line import/no-cycle
import { NotificationsProvider } from '@hicommonwealth/core';
import sinon from 'sinon';

Expand Down
1 change: 1 addition & 0 deletions libs/core/src/ports/port.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { delay } from '@hicommonwealth/shared';
import { config } from '../config';
// eslint-disable-next-line import/no-cycle
import { logger, rollbar } from '../logging';
import { ExitCode } from './enums';
import { inMemoryBlobStorage } from './in-memory-blob-storage';
Expand Down
1 change: 1 addition & 0 deletions libs/model/src/webhook/util.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// eslint-disable-next-line import/no-cycle
import { config } from '@hicommonwealth/model';
import { Community } from '@hicommonwealth/schemas';
import z from 'zod';

Check warning on line 4 in libs/model/src/webhook/util.ts

View workflow job for this annotation

GitHub Actions / Code Quality Recommendations (20)

Using exported name 'z' as identifier for default export

export const REGEX_IMAGE =
/\b(https?:\/\/\S*?\.(?:png|jpe?g|gif)(?:\?(?:(?:(?:[\w_-]+=[\w_-]+)(?:&[\w_-]+=[\w_-]+)*)|(?:[\w_-]+)))?)\b/;
Expand Down
1 change: 1 addition & 0 deletions libs/shared/src/canvas/chainMappings.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// eslint-disable-next-line import/no-cycle
import { ChainBase } from '@hicommonwealth/shared';

export const COSMOS_CHAIN_ID = 'cosmoshub-1';
Expand Down
1 change: 1 addition & 0 deletions libs/shared/src/canvas/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// eslint-disable-next-line import/no-cycle
export * from './chainMappings';
export * from './sessionSigners';
export * from './types';
Expand Down
1 change: 1 addition & 0 deletions libs/shared/src/canvas/sessionSigners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { CosmosSigner } from '@canvas-js/chain-cosmos';
import { SubstrateSigner } from '@canvas-js/chain-substrate';
import { AbstractSessionData, Session } from '@canvas-js/interfaces';
import { fromBech32, toBech32 } from '@cosmjs/encoding';
// eslint-disable-next-line import/no-cycle
import { addressSwapper } from '@hicommonwealth/shared';

/**
Expand Down
1 change: 1 addition & 0 deletions libs/shared/src/canvas/verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { ed25519 } from '@canvas-js/signatures';

import assert from 'assert';

// eslint-disable-next-line import/no-cycle
import { CosmosSignerCW, SubstrateSignerCW } from './sessionSigners';
import { CanvasSignedData } from './types';
import { CANVAS_TOPIC, assertMatches, caip2AddressEquals } from './utils';
Expand Down
2 changes: 2 additions & 0 deletions libs/shared/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// eslint-disable-next-line import/no-cycle
export * from './canvas';
// eslint-disable-next-line import/no-cycle
export * as commonProtocol from './commonProtocol';
export * from './constants';
export * from './types';
Expand Down
1 change: 1 addition & 0 deletions libs/shared/src/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// eslint-disable-next-line import/no-cycle
export * from './notification';
export * from './proposal';
export * from './protocol';
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@
"eslint-plugin-promise": "^7.1.0",
"eslint-plugin-react": "^7.35.0",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-import": "^2.29.1",
"eslint-import-resolver-typescript": "^3.6.3",
"events": "3.3.0",
"faker": "^4.1.0",
"husky": "^8.0.0",
Expand Down
Loading
Loading