Skip to content

Commit

Permalink
Fix linter issues & actions workflow (#107)
Browse files Browse the repository at this point in the history
* fix eslintrc.json

* Add lint action to PR into main, and add eslint key

* Add ts overrides

* try moving parser opt into ovverrides

* unbundle lint from prettier, run npm run fix:lint in workflow

* fix eslint manual errors

* disable no-useless-catch

* fix eslint disable next line

* add types/ and test/ ignorePatterns

* add some disables

* add @typescript-eslint/ prefix

* fix

* fix

* npm run fix:lint

* disable all errors

* Fix code style issues with Prettier

* test

* re add PR

* autofix: false

* run local package.json prettier f ix instead

* remove comments

Co-authored-by: Lint Action <[email protected]>
  • Loading branch information
zhongeric and lint-action committed Jul 5, 2022
1 parent 55ba738 commit cd8587a
Show file tree
Hide file tree
Showing 56 changed files with 100 additions and 17 deletions.
9 changes: 3 additions & 6 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"parser": "@typescript-eslint/parser",
"parserOptions": { "project": "./tsconfig.json" },
"env": { "es6": true },
"ignorePatterns": ["node_modules", "build", "coverage"],
"ignorePatterns": ["node_modules", "build", "coverage", "types", "test"],
"plugins": ["import", "eslint-comments"],
"extends": [
"eslint:recommended",
Expand All @@ -15,6 +15,7 @@
],
"globals": { "BigInt": true, "console": true, "WebAssembly": true },
"rules": {
"eslint-comments/no-unlimited-disable": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"eslint-comments/disable-enable-pair": [
"error",
Expand All @@ -36,11 +37,7 @@
{
"name": "ethers",
"message": "Please import from '@ethersproject/module' directly to support tree-shaking."
}
]
},
{
"paths": [
},
{
"name": "mnemonist",
"message": "Please import from 'mnemonist/module' directly to support tree-shaking."
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:
branches:
- main
pull_request:
branches:
- main

jobs:
run-linters:
Expand All @@ -24,10 +26,8 @@ jobs:
- name: Install dependencies
run: npm ci

- name: Run linters
uses: wearerequired/lint-action@v1
with:
github_token: ${{ secrets.github_token }}
prettier: true
auto_fix: true
prettier_extensions: 'css,html,js,json,jsx,md,sass,scss,ts,tsx,vue,yaml,yml,sol'
- name: Run linter
run: npm run fix:lint

- name: Run Prettier
run: npm run fix:prettier
2 changes: 1 addition & 1 deletion cli/commands/quote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
parseAmount,
SwapRoute,
} from '../../src';
import { TO_PROTOCOL } from '../../src/util/protocols';
import { TO_PROTOCOL } from '../../src/util';
import { BaseCommand } from '../base-command';

dotenv.config();
Expand Down
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = {
testEnvironment: 'node',
moduleFileExtensions: ['js', 'jsx', 'ts', 'tsx', 'json', 'node', 'd.ts'],
/**
* @note use this if we have multiple integration test files
* @dev use this if we have multiple integration test files
*/
// testEnvironment: "jest-environment-hardhat"
};
1 change: 1 addition & 0 deletions src/providers/cache-node.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import NodeCache from 'node-cache';

import { ICache } from './cache';

export class NodeJSCache<T> implements ICache<T> {
Expand Down
1 change: 1 addition & 0 deletions src/providers/caching-gas-provider.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ChainId } from '../util/chains';
import { log } from '../util/log';

import { ICache } from './cache';
import { GasPrice, IGasPriceProvider } from './gas-price-provider';

Expand Down
2 changes: 2 additions & 0 deletions src/providers/caching-token-list-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ import { Token } from '@uniswap/sdk-core';
import { TokenInfo, TokenList } from '@uniswap/token-lists';
import axios from 'axios';
import _ from 'lodash';

import { ChainId } from '../util/chains';
import { log } from '../util/log';
import { metric, MetricLoggerUnit } from '../util/metric';

import { ICache } from './cache';
import { ITokenProvider, TokenAccessor } from './token-provider';

Expand Down
2 changes: 2 additions & 0 deletions src/providers/caching-token-provider.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Token } from '@uniswap/sdk-core';
import _ from 'lodash';

import { ChainId, log, WRAPPED_NATIVE_CURRENCY } from '../util';

import { ICache } from './cache';
import {
CELO,
Expand Down
2 changes: 2 additions & 0 deletions src/providers/eip-1559-gas-price-provider.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { BigNumber } from '@ethersproject/bignumber';
import { JsonRpcProvider } from '@ethersproject/providers';
import _ from 'lodash';

import { log } from '../util/log';

import { GasPrice, IGasPriceProvider } from './gas-price-provider';

export type RawFeeHistoryResponse = {
Expand Down
2 changes: 2 additions & 0 deletions src/providers/eth-gas-station-info-gas-price-provider.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { BigNumber } from '@ethersproject/bignumber';
import retry from 'async-retry';
import axios from 'axios';

import { log } from '../util/log';

import { GasPrice, IGasPriceProvider } from './gas-price-provider';

// Gas prices from ethgasstation are in x10 Gwei. Must divide by 10 to use.
Expand Down
2 changes: 2 additions & 0 deletions src/providers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export * from './legacy-gas-price-provider';
export * from './multicall-provider';
export * from './multicall-uniswap-provider';
export * from './on-chain-gas-price-provider';
export * from './static-gas-price-provider';
export * from './swap-router-provider';
export * from './token-provider';
export * from './uri-subgraph-provider';
Expand All @@ -19,6 +20,7 @@ export * from './v2/quote-provider';
export * from './v2/static-subgraph-provider';
export * from './v2/subgraph-provider';
export * from './v2/subgraph-provider-with-fallback';
export * from './v2/uri-subgraph-provider';
export * from './v3/caching-pool-provider';
export * from './v3/caching-subgraph-provider';
export * from './v3/pool-provider';
Expand Down
2 changes: 2 additions & 0 deletions src/providers/legacy-gas-price-provider.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { JsonRpcProvider } from '@ethersproject/providers';

import { log } from '../util';

import { GasPrice, IGasPriceProvider } from './gas-price-provider';

export class LegacyGasPriceProvider extends IGasPriceProvider {
Expand Down
1 change: 1 addition & 0 deletions src/providers/multicall-provider.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Interface } from '@ethersproject/abi';
import { BigNumber } from '@ethersproject/bignumber';

import { ProviderConfig } from './provider';

export type CallSameFunctionOnMultipleContractsParams<
Expand Down
2 changes: 2 additions & 0 deletions src/providers/multicall-uniswap-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ import { BigNumber } from '@ethersproject/bignumber';
import { BaseProvider } from '@ethersproject/providers';
import _ from 'lodash';
import stats from 'stats-lite';

import { UniswapInterfaceMulticall__factory } from '../types/v3/factories/UniswapInterfaceMulticall__factory';
import { UniswapInterfaceMulticall } from '../types/v3/UniswapInterfaceMulticall';
import { ChainId } from '../util';
import { UNISWAP_MULTICALL_ADDRESSES } from '../util/addresses';
import { log } from '../util/log';

import {
CallMultipleFunctionsOnSameContractParams,
CallSameFunctionOnContractWithMultipleParams,
Expand Down
1 change: 1 addition & 0 deletions src/providers/on-chain-gas-price-provider.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ChainId } from '../util/chains';

import { EIP1559GasPriceProvider } from './eip-1559-gas-price-provider';
import { GasPrice, IGasPriceProvider } from './gas-price-provider';
import { LegacyGasPriceProvider } from './legacy-gas-price-provider';
Expand Down
2 changes: 2 additions & 0 deletions src/providers/static-gas-price-provider.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// eslint-disable-next-line no-restricted-imports
import { BigNumber } from 'ethers';

import { GasPrice, IGasPriceProvider } from './gas-price-provider';

export class StaticGasPriceProvider implements IGasPriceProvider {
Expand Down
2 changes: 2 additions & 0 deletions src/providers/swap-router-provider.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { ApprovalTypes } from '@uniswap/router-sdk';
import { Currency, CurrencyAmount } from '@uniswap/sdk-core';

import { SwapRouter02__factory } from '../types/other/factories/SwapRouter02__factory';
import { log } from '../util';

import { IMulticallProvider } from './multicall-provider';

type TokenApprovalTypes = {
Expand Down
2 changes: 2 additions & 0 deletions src/providers/token-provider.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { Token } from '@uniswap/sdk-core';
import _ from 'lodash';

import { IERC20Metadata__factory } from '../types/v3/factories/IERC20Metadata__factory';
import { ChainId, log, WRAPPED_NATIVE_CURRENCY } from '../util';

import { IMulticallProvider } from './multicall-provider';
import { ProviderConfig } from './provider';

Expand Down
2 changes: 2 additions & 0 deletions src/providers/token-validator-provider.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { Token } from '@uniswap/sdk-core';
import _ from 'lodash';

import { ITokenValidator__factory } from '../types/other/factories/ITokenValidator__factory';
import { ChainId, log, WRAPPED_NATIVE_CURRENCY } from '../util';

import { ICache } from './cache';
import { IMulticallProvider } from './multicall-provider';
import { ProviderConfig } from './provider';
Expand Down
4 changes: 4 additions & 0 deletions src/providers/uri-subgraph-provider.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import retry from 'async-retry';
import Timeout from 'await-timeout';
import axios from 'axios';

import { ChainId } from '../util/chains';
import { log } from '../util/log';

import { V2SubgraphPool } from './v2/subgraph-provider';
import { V3SubgraphPool } from './v3/subgraph-provider';

Expand Down Expand Up @@ -44,13 +46,15 @@ export class URISubgraphProvider<

let response;

/* eslint-disable no-useless-catch */
try {
response = await Promise.race([axios.get(this.uri), timerPromise]);
} catch (err) {
throw err;
} finally {
timeout.clear();
}
/* eslint-enable no-useless-catch */

const { data: poolsBuffer, status } = response;

Expand Down
1 change: 1 addition & 0 deletions src/providers/v2/caching-subgraph-provider.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ChainId } from '../../util/chains';

import { ICache } from './../cache';
import { IV2SubgraphProvider, V2SubgraphPool } from './subgraph-provider';

Expand Down
1 change: 1 addition & 0 deletions src/providers/v2/pool-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Token } from '@uniswap/sdk-core';
import { Pair } from '@uniswap/v2-sdk';
import retry, { Options as RetryOptions } from 'async-retry';
import _ from 'lodash';

import { IUniswapV2Pair__factory } from '../../types/v2/factories/IUniswapV2Pair__factory';
import { ChainId, CurrencyAmount } from '../../util';
import { log } from '../../util/log';
Expand Down
3 changes: 3 additions & 0 deletions src/providers/v2/quote-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
InsufficientInputAmountError,
InsufficientReservesError,
} from '@uniswap/v2-sdk';

import { V2Route } from '../../routers/router';
import { CurrencyAmount } from '../../util/amounts';
import { log } from '../../util/log';
Expand Down Expand Up @@ -37,7 +38,9 @@ export interface IV2QuoteProvider {
* @class V2QuoteProvider
*/
export class V2QuoteProvider implements IV2QuoteProvider {
/* eslint-disable @typescript-eslint/no-empty-function */
constructor() {}
/* eslint-enable @typescript-eslint/no-empty-function */

public async getQuotesManyExactIn(
amountIns: CurrencyAmount[],
Expand Down
2 changes: 2 additions & 0 deletions src/providers/v2/static-subgraph-provider.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Token } from '@uniswap/sdk-core';
import { Pair } from '@uniswap/v2-sdk';
import _ from 'lodash';

import { ChainId, WRAPPED_NATIVE_CURRENCY } from '../../util/chains';
import { log } from '../../util/log';
import {
Expand All @@ -11,6 +12,7 @@ import {
USDT_MAINNET,
WBTC_MAINNET,
} from '../token-provider';

import { IV2SubgraphProvider, V2SubgraphPool } from './subgraph-provider';

type ChainTokenList = {
Expand Down
2 changes: 2 additions & 0 deletions src/providers/v2/subgraph-provider-with-fallback.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Token } from '@uniswap/sdk-core';

import { log } from '../../util';
import { ProviderConfig } from '../provider';

import { IV2SubgraphProvider, V2SubgraphPool } from './subgraph-provider';

/**
Expand Down
3 changes: 3 additions & 0 deletions src/providers/v2/subgraph-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import retry from 'async-retry';
import Timeout from 'await-timeout';
import { gql, GraphQLClient } from 'graphql-request';
import _ from 'lodash';

import { ChainId } from '../../util/chains';
import { log } from '../../util/log';
import { ProviderConfig } from '../provider';
Expand Down Expand Up @@ -151,6 +152,7 @@ export class V2SubgraphProvider implements IV2SubgraphProvider {
return pairs;
};

/* eslint-disable no-useless-catch */
try {
const getPoolsPromise = getPools();
const timerPromise = timeout.set(this.timeout).then(() => {
Expand All @@ -165,6 +167,7 @@ export class V2SubgraphProvider implements IV2SubgraphProvider {
} finally {
timeout.clear();
}
/* eslint-enable no-useless-catch */
},
{
retries: this.retries,
Expand Down
1 change: 1 addition & 0 deletions src/providers/v2/uri-subgraph-provider.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { URISubgraphProvider } from '../uri-subgraph-provider';

import { IV2SubgraphProvider, V2SubgraphPool } from './subgraph-provider';

export class V2URISubgraphProvider
Expand Down
2 changes: 2 additions & 0 deletions src/providers/v3/caching-pool-provider.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { Token } from '@uniswap/sdk-core';
import { FeeAmount, Pool } from '@uniswap/v3-sdk';

import { ChainId } from '../../util/chains';
import { log } from '../../util/log';

import { ICache } from './../cache';
import { ProviderConfig } from './../provider';
import { IV3PoolProvider, V3PoolAccessor } from './pool-provider';
Expand Down
1 change: 1 addition & 0 deletions src/providers/v3/caching-subgraph-provider.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ChainId } from '../../util/chains';

import { ICache } from './../cache';
import { IV3SubgraphProvider, V3SubgraphPool } from './subgraph-provider';

Expand Down
1 change: 1 addition & 0 deletions src/providers/v3/gas-data-provider.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { BigNumber } from '@ethersproject/bignumber';
import { BaseProvider } from '@ethersproject/providers';

import { GasDataArbitrum__factory } from '../../types/other/factories/GasDataArbitrum__factory';
import { GasPriceOracle__factory } from '../../types/other/factories/GasPriceOracle__factory';
import {
Expand Down
1 change: 1 addition & 0 deletions src/providers/v3/pool-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Token } from '@uniswap/sdk-core';
import { computePoolAddress, FeeAmount, Pool } from '@uniswap/v3-sdk';
import retry, { Options as RetryOptions } from 'async-retry';
import _ from 'lodash';

import { IUniswapV3PoolState__factory } from '../../types/v3/factories/IUniswapV3PoolState__factory';
import { ChainId } from '../../util';
import { V3_CORE_FACTORY_ADDRESSES } from '../../util/addresses';
Expand Down
1 change: 1 addition & 0 deletions src/providers/v3/quote-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { encodeRouteToPath } from '@uniswap/v3-sdk';
import retry, { Options as RetryOptions } from 'async-retry';
import _ from 'lodash';
import stats from 'stats-lite';

import { V3Route } from '../../routers/router';
import { IQuoterV2__factory } from '../../types/v3/factories/IQuoterV2__factory';
import { ChainId, metric, MetricLoggerUnit } from '../../util';
Expand Down
2 changes: 2 additions & 0 deletions src/providers/v3/static-subgraph-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Token } from '@uniswap/sdk-core';
import { FeeAmount, Pool } from '@uniswap/v3-sdk';
import JSBI from 'jsbi';
import _ from 'lodash';

import { unparseFeeAmount } from '../../util/amounts';
import { ChainId, WRAPPED_NATIVE_CURRENCY } from '../../util/chains';
import { log } from '../../util/log';
Expand Down Expand Up @@ -60,6 +61,7 @@ import {
WMATIC_POLYGON_MUMBAI,
WXDAI_GNOSIS,
} from '../token-provider';

import { IV3PoolProvider } from './pool-provider';
import { IV3SubgraphProvider, V3SubgraphPool } from './subgraph-provider';

Expand Down
2 changes: 2 additions & 0 deletions src/providers/v3/subgraph-provider-with-fallback.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Token } from '@uniswap/sdk-core';

import { log } from '../../util';
import { ProviderConfig } from '../provider';

import { IV3SubgraphProvider, V3SubgraphPool } from './subgraph-provider';

/**
Expand Down
Loading

0 comments on commit cd8587a

Please sign in to comment.