Skip to content
This repository has been archived by the owner on Apr 11, 2023. It is now read-only.

Commit

Permalink
chore: eslint import order (#151)
Browse files Browse the repository at this point in the history
* chore: add eslint import order

* chore: add lint:fix script

* chore: apply eslint import order rules on existing files
  • Loading branch information
jdambron authored Oct 27, 2021
1 parent 5688394 commit 5203a69
Show file tree
Hide file tree
Showing 51 changed files with 186 additions and 139 deletions.
8 changes: 6 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"plugins": [
"@typescript-eslint",
"prettier",
"jest"
"jest",
"simple-import-sort"
],
"env": {
"node": true,
Expand Down Expand Up @@ -45,6 +46,9 @@
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-shadow": [
"error"
],
"simple-import-sort/imports": [
"error"
]
},
"overrides": [
Expand All @@ -59,4 +63,4 @@
}
}
]
}
}
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"clean": "rimraf node_modules dist packages/**/dist",
"dev": "lerna run dev --stream --parallel",
"lint": "eslint --cache --max-warnings=0 .",
"lint:fix": "yarn lint --fix",
"link-packages": "node scripts/linkPackages.js link",
"unlink-packages": "node scripts/linkPackages.js unlink",
"test": "jest",
Expand Down Expand Up @@ -41,6 +42,7 @@
"eslint-plugin-jest": "24.3.6",
"eslint-plugin-jsx-a11y": "6.4.1",
"eslint-plugin-prettier": "3.4.0",
"eslint-plugin-simple-import-sort": "^7.0.0",
"jest": "^27.1.0",
"jest-mock-extended": "^1.0.9",
"lerna": "^4.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/asset-service/src/generateAssetData/baseAssets.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BaseAsset, ContractTypes, NetworkTypes, ChainTypes } from '@shapeshiftoss/types'
import { BaseAsset, ChainTypes, ContractTypes, NetworkTypes } from '@shapeshiftoss/types'

export const baseAssets: Array<BaseAsset> = [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import axios from 'axios'
import { ContractTypes, TokenAsset } from '@shapeshiftoss/types'
import axios from 'axios'
import lodash from 'lodash'

import { tokensToOverride } from './overrides'

type CoingeckoTokenData = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TokenAsset, ContractTypes } from '@shapeshiftoss/types'
import { ContractTypes, TokenAsset } from '@shapeshiftoss/types'

export const tokensToOverride: Array<TokenAsset> = [
// example overriding FOX token with custom values instead of goingecko
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { BaseAsset, ChainTypes, NetworkTypes } from '@shapeshiftoss/types'
import fs from 'fs'

import { baseAssets } from './baseAssets'
import { getTokens } from './ethTokens'
import { BaseAsset, ChainTypes, NetworkTypes } from '@shapeshiftoss/types'

const generateAssetData = async () => {
const generatedAssetData = await Promise.all(
Expand Down
5 changes: 3 additions & 2 deletions packages/asset-service/src/service/AssetService.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import axios from 'axios'
import { Asset, ChainTypes, NetworkTypes } from '@shapeshiftoss/types'
import axios from 'axios'

import { AssetService, flattenAssetData, indexAssetData } from './AssetService'
import { mockBaseAssets, mockAssets, mockIndexedAssetData } from './AssetServiceTestData'
import { mockAssets, mockBaseAssets, mockIndexedAssetData } from './AssetServiceTestData'

jest.mock('axios')

Expand Down
3 changes: 2 additions & 1 deletion packages/asset-service/src/service/AssetService.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { BaseAsset, Asset, NetworkTypes, ChainTypes } from '@shapeshiftoss/types'
import { Asset, BaseAsset, ChainTypes, NetworkTypes } from '@shapeshiftoss/types'
import axios from 'axios'

import localAssetData from './generatedAssetData.json'

export const flattenAssetData = (assetData: BaseAsset[]): Asset[] => {
Expand Down
3 changes: 2 additions & 1 deletion packages/asset-service/src/service/AssetServiceTestData.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { IndexedAssetData } from '..'
import { Asset, BaseAsset, ChainTypes, ContractTypes, NetworkTypes } from '@shapeshiftoss/types'

import { IndexedAssetData } from '..'

export const mockBaseAssets: BaseAsset[] = [
{
chain: ChainTypes.Ethereum,
Expand Down
1 change: 1 addition & 0 deletions packages/caip/src/caip19/caip19.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ChainTypes, ContractTypes, NetworkTypes } from '@shapeshiftoss/types'

import { fromCAIP19, toCAIP19 } from './caip19'

describe('caip19', () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/caip/src/caip19/caip19.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { fromCAIP2, toCAIP2 } from './../caip2/caip2'
// https://github.com/ChainAgnostic/CAIPs/blob/master/CAIPs/caip-19.md

import { ChainTypes, ContractTypes, NetworkTypes } from '@shapeshiftoss/types'

import { fromCAIP2, toCAIP2 } from './../caip2/caip2'

export enum AssetNamespace {
ERC20 = 'erc20',
ERC721 = 'erc721',
Expand Down
5 changes: 3 additions & 2 deletions packages/chain-adapters/src/ChainAdapterCLI.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import dotenv from 'dotenv'
import { BTCInputScriptType } from '@shapeshiftoss/hdwallet-core'
import { NativeAdapterArgs, NativeHDWallet } from '@shapeshiftoss/hdwallet-native'
import { BIP32Params, ChainTypes, chainAdapters } from '@shapeshiftoss/types'
import { BIP32Params, chainAdapters, ChainTypes } from '@shapeshiftoss/types'
import dotenv from 'dotenv'

import { ChainAdapterManager } from './ChainAdapterManager'

dotenv.config()
Expand Down
1 change: 1 addition & 0 deletions packages/chain-adapters/src/ChainAdapterManager.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
import { ChainTypes } from '@shapeshiftoss/types'

import { ChainAdapterManager } from './ChainAdapterManager'
import * as ethereum from './ethereum'

Expand Down
1 change: 1 addition & 0 deletions packages/chain-adapters/src/ChainAdapterManager.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ChainTypes } from '@shapeshiftoss/types'
import * as unchained from '@shapeshiftoss/unchained-client'

import { ChainAdapter } from './api'
import * as bitcoin from './bitcoin'
import * as ethereum from './ethereum'
Expand Down
2 changes: 1 addition & 1 deletion packages/chain-adapters/src/api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { chainAdapters, ChainTypes, BIP32Params } from '@shapeshiftoss/types'
import { BIP32Params, chainAdapters, ChainTypes } from '@shapeshiftoss/types'

export interface ChainAdapter<T extends ChainTypes> {
/**
Expand Down
1 change: 1 addition & 0 deletions packages/chain-adapters/src/bip32.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { BIP32Params } from '@shapeshiftoss/types'

import { fromPath, toPath } from './bip32'

describe('fromPath', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
* @group unit
*/

import axios from 'axios'
import { BTCInputScriptType, HDWallet } from '@shapeshiftoss/hdwallet-core'
import { NativeAdapterArgs, NativeHDWallet } from '@shapeshiftoss/hdwallet-native'
import { BIP32Params, chainAdapters, ChainTypes } from '@shapeshiftoss/types'
import * as unchained from '@shapeshiftoss/unchained-client'
import { BIP32Params, ChainTypes, chainAdapters } from '@shapeshiftoss/types'
import axios from 'axios'

import * as bitcoin from './BitcoinChainAdapter'

jest.mock('axios')
Expand Down
7 changes: 4 additions & 3 deletions packages/chain-adapters/src/bitcoin/BitcoinChainAdapter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import coinSelect from 'coinselect'
import WAValidator from 'multicoin-address-validator'
import {
bip32ToAddressNList,
BTCInputScriptType,
BTCOutputAddressType,
BTCOutputScriptType,
Expand All @@ -9,11 +8,13 @@ import {
BTCSignTxOutput,
HDWallet,
PublicKey,
bip32ToAddressNList,
supportsBTC
} from '@shapeshiftoss/hdwallet-core'
import { BIP32Params, chainAdapters, ChainTypes, NetworkTypes } from '@shapeshiftoss/types'
import { bitcoin } from '@shapeshiftoss/unchained-client'
import coinSelect from 'coinselect'
import WAValidator from 'multicoin-address-validator'

import { ChainAdapter as IChainAdapter } from '../api'
import { toPath, toRootDerivationPath } from '../bip32'
import { ErrorHandler } from '../error/ErrorHandler'
Expand Down
9 changes: 5 additions & 4 deletions packages/chain-adapters/src/ethereum/EthereumChainAdapter.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
import axios from 'axios'
import BigNumber from 'bignumber.js'
import WAValidator from 'multicoin-address-validator'
import { numberToHex } from 'web3-utils'
import { Contract } from '@ethersproject/contracts'
import { bip32ToAddressNList, ETHSignTx, ETHWallet } from '@shapeshiftoss/hdwallet-core'
import {
Expand All @@ -12,6 +8,11 @@ import {
NetworkTypes
} from '@shapeshiftoss/types'
import { ethereum, unchained } from '@shapeshiftoss/unchained-client'
import axios from 'axios'
import BigNumber from 'bignumber.js'
import WAValidator from 'multicoin-address-validator'
import { numberToHex } from 'web3-utils'

import { ChainAdapter as IChainAdapter } from '../api'
import { toPath } from '../bip32'
import { ErrorHandler } from '../error/ErrorHandler'
Expand Down
2 changes: 1 addition & 1 deletion packages/logger/src/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { loggerFactory, Logger, LogLevel } from './index'
import { Logger, loggerFactory, LogLevel } from './index'

describe('Logger', () => {
it('should export loggerFactory', () => {
Expand Down
3 changes: 2 additions & 1 deletion packages/market-service/src/coingecko/coingecko.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ChainTypes, HistoryTimeframe } from '@shapeshiftoss/types'
import axios from 'axios'

import { getMarketData, getPriceHistory } from '..'
import { ChainTypes, HistoryTimeframe } from '@shapeshiftoss/types'

jest.mock('axios')

Expand Down
10 changes: 5 additions & 5 deletions packages/market-service/src/coingecko/coingecko.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import axios from 'axios'
import dayjs from 'dayjs'
import {
ChainTypes,
MarketData,
HistoryData,
HistoryTimeframe,
PriceHistoryArgs,
MarketDataArgs
MarketData,
MarketDataArgs,
PriceHistoryArgs
} from '@shapeshiftoss/types'
import axios from 'axios'
import dayjs from 'dayjs'

import { MarketService } from '../api'

Expand Down
5 changes: 3 additions & 2 deletions packages/market-service/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { CoinGeckoMarketService } from './coingecko/coingecko'
import { MarketService } from './api'
import {
HistoryData,
MarketDataArgs,
Expand All @@ -8,6 +6,9 @@ import {
PriceHistoryType
} from '@shapeshiftoss/types'

import { MarketService } from './api'
import { CoinGeckoMarketService } from './coingecko/coingecko'

export const getDefaultMarketService = (): MarketService => {
return new CoinGeckoMarketService()
}
Expand Down
10 changes: 5 additions & 5 deletions packages/swapper/src/api.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { HDWallet } from '@shapeshiftoss/hdwallet-core'
import {
Asset,
ApprovalNeededInput,
ApprovalNeededOutput,
ApproveInfiniteInput,
Asset,
BuildQuoteTxInput,
GetQuoteInput,
Quote,
SwapperType,
ChainTypes,
ExecQuoteInput,
ExecQuoteOutput,
GetQuoteInput,
MinMaxOutput,
ChainTypes
Quote,
SwapperType
} from '@shapeshiftoss/types'

export class SwapError extends Error {}
Expand Down
5 changes: 3 additions & 2 deletions packages/swapper/src/manager/SwapperManager.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
import { ChainAdapterManager } from '@shapeshiftoss/chain-adapters'
import { SwapperType } from '@shapeshiftoss/types'
import Web3 from 'web3'

import { ThorchainSwapper, ZrxSwapper } from '../swappers'
import { SwapperManager } from './SwapperManager'
import { ChainAdapterManager } from '@shapeshiftoss/chain-adapters'
import { SwapperType } from '@shapeshiftoss/types'

describe('SwapperManager', () => {
const zrxSwapperDeps = {
Expand Down
3 changes: 2 additions & 1 deletion packages/swapper/src/manager/SwapperManager.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Swapper } from '..'
import { GetQuoteInput, SwapperType } from '@shapeshiftoss/types'

import { Swapper } from '..'

export class SwapperError extends Error {
constructor(message: string) {
super(message)
Expand Down
10 changes: 5 additions & 5 deletions packages/swapper/src/swappercli.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { AssetService } from '@shapeshiftoss/asset-service'
import { ChainAdapterManager } from '@shapeshiftoss/chain-adapters'
import { NativeAdapterArgs, NativeHDWallet } from '@shapeshiftoss/hdwallet-native'
import { Asset, ChainTypes, NetworkTypes, SwapperType } from '@shapeshiftoss/types'
import BigNumber from 'bignumber.js'
import dotenv from 'dotenv'
import readline from 'readline-sync'
import Web3 from 'web3'
import BigNumber from 'bignumber.js'

import { Asset, NetworkTypes, SwapperType, ChainTypes } from '@shapeshiftoss/types'
import { NativeAdapterArgs, NativeHDWallet } from '@shapeshiftoss/hdwallet-native'
import { ChainAdapterManager } from '@shapeshiftoss/chain-adapters'
import { AssetService } from '@shapeshiftoss/asset-service'
import { SwapperManager } from './manager/SwapperManager'
import { ZrxSwapper } from './swappers/zrx/ZrxSwapper'

Expand Down
11 changes: 6 additions & 5 deletions packages/swapper/src/swappers/thorchain/ThorchainSwapper.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import {
Asset,
ApprovalNeededOutput,
SwapperType,
Quote,
Asset,
ChainTypes,
ExecQuoteOutput,
MinMaxOutput,
GetQuoteInput,
ChainTypes
MinMaxOutput,
Quote,
SwapperType
} from '@shapeshiftoss/types'

import { Swapper } from '../../api'

export class ThorchainSwapper implements Swapper {
Expand Down
19 changes: 10 additions & 9 deletions packages/swapper/src/swappers/zrx/ZrxSwapper.test.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import Web3 from 'web3'
import { HDWallet } from '@shapeshiftoss/hdwallet-core'
import { ChainAdapterManager } from '@shapeshiftoss/chain-adapters'
import { ChainTypes, GetQuoteInput, SwapperType, Quote } from '@shapeshiftoss/types'
import { ZrxSwapper } from '..'
import { HDWallet } from '@shapeshiftoss/hdwallet-core'
import { ChainTypes, GetQuoteInput, Quote, SwapperType } from '@shapeshiftoss/types'
import Web3 from 'web3'

import { ZrxError } from '../..'
import { setupQuote } from './utils/test-data/setupSwapQuote'
import { FOX, WETH, BTC } from './utils/test-data/assets'
import { ZrxSwapper } from '..'
import { buildQuoteTx } from '../zrx/buildQuoteTx/buildQuoteTx'
import { executeQuote } from '../zrx/executeQuote/executeQuote'
import { getZrxQuote } from './getQuote/getQuote'
import { getUsdRate } from './utils/helpers/helpers'
import { getMinMax } from './getMinMax/getMinMax'
import { approvalNeeded } from './approvalNeeded/approvalNeeded'
import { approveInfinite } from './approveInfinite/approveInfinite'
import { getMinMax } from './getMinMax/getMinMax'
import { getZrxQuote } from './getQuote/getQuote'
import { getUsdRate } from './utils/helpers/helpers'
import { BTC, FOX, WETH } from './utils/test-data/assets'
import { setupQuote } from './utils/test-data/setupSwapQuote'

jest.mock('./utils/helpers/helpers')
jest.mock('../zrx/executeQuote/executeQuote', () => ({
Expand Down
Loading

0 comments on commit 5203a69

Please sign in to comment.