Skip to content

Commit

Permalink
WIP Fix eslint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
paullinator committed Oct 18, 2023
1 parent e32a172 commit 3c09c75
Show file tree
Hide file tree
Showing 30 changed files with 1,116 additions and 670 deletions.
16 changes: 14 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
{
"extends": [
"standard-kit/prettier",
"standard-kit/prettier/node",
"standard-kit/prettier/jsx",
"standard-kit/prettier/node",
"standard-kit/prettier/react",
"standard-kit/prettier/typescript"
],
"globals": {
"fetch": true
},
"overrides": [
{
"files": ["*.ts", "*.tsx"],
"rules": {
"@typescript-eslint/switch-exhaustiveness-check": "error"
}
}
],
"parserOptions": {
"project": "tsconfig.json"
},
"plugins": ["simple-import-sort"],
"rules": {
"simple-import-sort/sort": "error"
"simple-import-sort/imports": "error"
}
}
24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,20 @@
"@types/react": "^16.9.22",
"@types/react-dom": "^16.9.5",
"@types/react-router-dom": "^5.3.3",
"@typescript-eslint/eslint-plugin": "^6.8.0",
"@typescript-eslint/parser": "^6.8.0",
"@typescript-eslint/eslint-plugin": "^5.36.2",
"@typescript-eslint/parser": "^5.36.2",
"assert": "^2.0.0",
"browserify-zlib": "^0.2.0",
"chai": "^4.3.4",
"eslint": ">=6.2.2",
"eslint-config-standard-kit": "^0.15.1",
"eslint-plugin-import": ">=2.18.0",
"eslint-plugin-node": ">=9.1.0",
"eslint-plugin-prettier": "^3.0.0",
"eslint-plugin-promise": ">=4.2.1",
"eslint-plugin-react": ">=7.14.2",
"eslint-plugin-simple-import-sort": ">=4.0.0",
"eslint-plugin-standard": ">=4.0.0",
"eslint": "^8.19.0",
"eslint-config-standard-kit": "0.15.1",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-react": "^7.21.5",
"eslint-plugin-react-hooks": "^4.2.0",
"eslint-plugin-simple-import-sort": "^6.0.1",
"events": "^3.3.0",
"https-browserify": "^1.0.0",
"husky": ">=3.0.0",
Expand All @@ -96,7 +96,7 @@
"stream-browserify": "^3.0.0",
"stream-http": "^3.2.0",
"sucrase": "^3.20.0",
"typescript": "^5.2.2",
"typescript": "^4.8.4",
"url": "^0.11.0",
"util": "^0.12.4"
}
Expand Down
12 changes: 6 additions & 6 deletions src/apiAnalytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const getAnalytics = (
const dayArray: Bucket[] = []
const hourArray: Bucket[] = []
// monthly buckets creation
if (hasMonthBucket === true) {
if (hasMonthBucket) {
let { y, m } = utcVariables(start)
let monthStart = new Date(Date.UTC(y, m, 1, 0))
do {
Expand All @@ -68,7 +68,7 @@ export const getAnalytics = (
} while (monthStart.getTime() <= end * 1000)
}
// daily buckets Creation
if (hasDayBucket === true) {
if (hasDayBucket) {
let { y, m, d } = utcVariables(start)
let dayStart = new Date(Date.UTC(y, m, d, 0))
do {
Expand All @@ -85,7 +85,7 @@ export const getAnalytics = (
} while (dayStart.getTime() <= end * 1000)
}
// hourly buckets creation
if (hasHourBucket === true) {
if (hasHourBucket) {
let { y, m, d, h } = utcVariables(start)
let hourStart = new Date(Date.UTC(y, m, d, h))
do {
Expand All @@ -108,19 +108,19 @@ export const getAnalytics = (
let hourPointer = 0
for (const tx of txs) {
// month
if (hasMonthBucket === true) {
if (hasMonthBucket) {
// advances pointer to bucket that matches current txs timestamp
monthPointer = bucketScroller(monthArray, monthPointer, tx.timestamp)
// adds usdvalue, currencycode, and currencypair to that bucket
bucketAdder(monthArray[monthPointer], tx)
}
// day
if (hasDayBucket === true) {
if (hasDayBucket) {
dayPointer = bucketScroller(dayArray, dayPointer, tx.timestamp)
bucketAdder(dayArray[dayPointer], tx)
}
// hour
if (hasHourBucket === true) {
if (hasHourBucket) {
hourPointer = bucketScroller(hourArray, hourPointer, tx.timestamp)
bucketAdder(hourArray[hourPointer], tx)
}
Expand Down
10 changes: 6 additions & 4 deletions src/bin/bogReporter.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
/* eslint-disable @typescript-eslint/restrict-template-expressions */
/* eslint-disable @typescript-eslint/restrict-plus-operands */
import fetch from 'node-fetch'

import CONFIG from '../../config.json'

// @ts-ignore
// @ts-expect-error
const BITS_OF_GOLD_API_KEY = CONFIG.bog.apiKey

const dateRegex = RegExp(/([12]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01]))/)
const dateRegex = /([12]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01]))/

async function queryBog(): Promise<void> {
// Grab args and verify format
Expand Down Expand Up @@ -71,7 +73,7 @@ async function queryFiatRate(
method: 'GET'
}
)
if (result.ok !== true) {
if (!result.ok) {
throw new Error(`queryFiatRate failed with status code ${result.status}`)
}
const json = await result.json()
Expand All @@ -88,7 +90,7 @@ async function queryCryptoRate(
method: 'GET'
}
)
if (result.ok !== true) {
if (!result.ok) {
throw new Error(`queryCryptoRate failed with status code ${result.status}`)
}
const json = await result.json()
Expand Down
6 changes: 3 additions & 3 deletions src/bin/migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ async function migration(): Promise<void> {

try {
await reportsTransactions
// @ts-ignore
// @ts-expect-error
.partitionedList(appAndPluginId, { include_docs: true })
.then(body => {
body.rows.forEach(doc => {
Expand Down Expand Up @@ -151,7 +151,7 @@ async function migration(): Promise<void> {
usdValue: -1,
rawTx: tx
}
return standardTxReformat(
return await standardTxReformat(
newTx,
appAndPluginId,
reportsTransactions
Expand Down Expand Up @@ -196,7 +196,7 @@ async function migration(): Promise<void> {
usdValue: -1,
rawTx: undefined
}
return standardTxReformat(
return await standardTxReformat(
newTx,
appAndPluginId,
reportsTransactions
Expand Down
7 changes: 2 additions & 5 deletions src/cacheEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,15 @@ export async function cacheEngine(): Promise<void> {
const rawApps = await reportsApps.find(query)
const apps = asApps(rawApps.docs)
for (const app of apps) {
if (
config.soloAppIds != null &&
config.soloAppIds.includes(app.appId) === false
) {
if (config.soloAppIds != null && !config.soloAppIds.includes(app.appId)) {
continue
}
const partnerIds = Object.keys(app.partnerIds)

for (const partnerId of partnerIds) {
if (
config.soloPartnerIds != null &&
config.soloPartnerIds.includes(partnerId) === false
!config.soloPartnerIds.includes(partnerId)
) {
continue
}
Expand Down
5 changes: 4 additions & 1 deletion src/demo/components/ApiKeyScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ const ApiKeyScreen = (props: ApiKeyScreenProps): React.ReactElement => {
style={apiKeyInput}
onChange={e => props.handleApiKeyChange(e.target.value)}
/>
<button style={apiKeyButton} onClick={() => props.getAppId()}>
<button
style={apiKeyButton}
onClick={async () => await props.getAppId()}
>
Use
</button>
</li>
Expand Down
4 changes: 2 additions & 2 deletions src/demo/components/Custom.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ class Custom extends Component<CustomProps, CustomState> {
}

render(): JSX.Element {
if (this.state.redirect === true) {
if (this.state.redirect) {
return <Redirect to={{ pathname: '/' }} />
}
if (this.state.loading === true) {
if (this.state.loading) {
return (
<div key="Loader" style={customLoader}>
<Loader type="Oval" color="blue" height="30px" width="30px" />
Expand Down
2 changes: 1 addition & 1 deletion src/demo/components/Graphs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ const Graphs: any = (props: {
stroke="#000000"
allowDecimals={false}
/>
{/* @ts-ignore */}
{/* @ts-expect-error */}
<Tooltip
animationDuration={0}
content={({ active, payload }) => {
Expand Down
2 changes: 1 addition & 1 deletion src/demo/components/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const Modal: any = (props: ModalProps) => {
.slice(0, 15)
let modalStyle = styleTwo
let closable: JSX.Element | null = null
if (isClosable === true) {
if (isClosable) {
modalStyle = { ...styleTwo, paddingTop: '2px' }
closable = (
<span style={closeModalButton} onClick={closeModal}>
Expand Down
4 changes: 2 additions & 2 deletions src/demo/components/Preset.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,15 @@ class Preset extends Component<PresetProps, PresetState> {
}
const analyticsArray = Object.values(analyticsResults)

// @ts-ignore
// @ts-expect-error
this.setState({ [timeRange]: analyticsArray })
console.timeEnd(`${timeRange}`)
}
}
}

render(): JSX.Element {
if (this.state.redirect === true) {
if (this.state.redirect) {
return <Redirect to={{ pathname: '/' }} />
}
const dataSets = {
Expand Down
2 changes: 1 addition & 1 deletion src/demo/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ const getISOString = (date: Date, end: boolean): string => {
const year = date.getUTCFullYear()
const month = date.getUTCMonth()
const day = date.getUTCDate()
const isEnd = end === true ? 1 : 0
const isEnd = end ? 1 : 0
const timezonedDate = new Date(Date.UTC(year, month, day) - isEnd)
return timezonedDate.toISOString()
}
Expand Down
2 changes: 1 addition & 1 deletion src/initDbs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export async function initDbs(): Promise<void> {
datelog(result)
// if database does not exist, create it
for (const dbName of DB_NAMES) {
if (result.includes(dbName.name) === false) {
if (!result.includes(dbName.name)) {
await nanoDb.db.create(dbName.name, dbName.options)
}
if (dbName.indexes !== undefined) {
Expand Down
2 changes: 1 addition & 1 deletion src/partners/banxa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ async function fetchBanxaAPI(
'Content-Type': 'application/json'
}

return retryFetch(`${partnerUrl}${apiQuery}`, { headers: headers })
return await retryFetch(`${partnerUrl}${apiQuery}`, { headers: headers })
}

function processBanxaOrders(rawtxs, ssFormatTxs): void {
Expand Down
6 changes: 1 addition & 5 deletions src/partners/bitrefill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,7 @@ export async function queryBitrefill(
continue
}
const tx = asBitrefillTx(rawtx)
if (
tx.paymentReceived === true &&
tx.expired === false &&
tx.sent === true
) {
if (tx.paymentReceived && !tx.expired && tx.sent) {
const timestamp = tx.invoiceTime / 1000

let inputAmountStr = tx.satoshiPrice?.toString()
Expand Down
2 changes: 1 addition & 1 deletion src/partners/bity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export async function queryBity(
// status: 404
// statusText: "Not Found"
// on page 4
if (monthlyResponse.ok === true) {
if (monthlyResponse.ok) {
monthlyTxs = asBityResult(await monthlyResponse.json())
} else if (
monthlyResponse.status === 404 &&
Expand Down
9 changes: 3 additions & 6 deletions src/partners/changelly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,7 @@ export async function queryChangelly(
) {
firstAttempt = true
}
if (
typeof pluginParams.settings.offset === 'number' &&
firstAttempt === true
) {
if (typeof pluginParams.settings.offset === 'number' && firstAttempt) {
offset = pluginParams.settings.offset
}
if (
Expand Down Expand Up @@ -157,8 +154,8 @@ export async function queryChangelly(
}
if (
tx.createdAt < latestTimeStamp - QUERY_LOOKBACK &&
done === false &&
firstAttempt === false
!done &&
!firstAttempt
) {
datelog(
`Changelly done: date ${tx.createdAt} < ${latestTimeStamp -
Expand Down
2 changes: 1 addition & 1 deletion src/partners/exolix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export async function queryExolix(

const response = await retryFetch(request, options)

if (response.ok === true) {
if (response.ok) {
result = asExolixResult(await response.json())
}

Expand Down
2 changes: 1 addition & 1 deletion src/partners/foxExchange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export async function queryFoxExchange(
}
}
)
if (res.ok === true) {
if (res.ok) {
txs = asFoxExchangeTxs(await res.json())
}
} catch (e) {
Expand Down
2 changes: 1 addition & 1 deletion src/partners/letsexchange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export async function queryLetsExchange(
const url = `https://api.letsexchange.io/api/v1/affiliate/history/${affiliateId}?limit=${LIMIT}&page=${page}&types=0`

const result = await retryFetch(url, { headers, method: 'GET' })
if (result.ok === false) {
if (!result.ok) {
const text = await result.text()
datelog(text)
throw new Error(text)
Expand Down
6 changes: 3 additions & 3 deletions src/partners/moonpay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ export async function queryMoonpay(
pluginParams: PluginParams
): Promise<PluginResult> {
const ssFormatTxs: StandardTx[] = []
let apiKey

let headers
let latestTimestamp = 0
if (typeof pluginParams.settings.latestTimestamp === 'number') {
latestTimestamp = pluginParams.settings.latestTimestamp
}

if (typeof pluginParams.apiKeys.apiKey === 'string') {
apiKey = pluginParams.apiKeys.apiKey
const apiKey = pluginParams.apiKeys.apiKey
if (typeof apiKey === 'string') {
headers = {
Authorization: `Api-Key ${apiKey}`
}
Expand Down
2 changes: 1 addition & 1 deletion src/partners/sideshift.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export async function querySideshift(
const url = `https://sideshift.ai/api/affiliate/completedOrders?affiliateId=${sideshiftAffiliateId}&since=${startTime}&currentTime=${now}&signature=${signature}`
try {
const response = await retryFetch(url)
if (response.ok === false) {
if (!response.ok) {
const text = await response.text()
throw new Error(text)
}
Expand Down
2 changes: 1 addition & 1 deletion src/partners/simplex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export async function querySimplex(
}
}

if (csvData.data.has_more_pages === false) {
if (!csvData.data.has_more_pages) {
break
}
nextPageCursor = asString(csvData.data.next_page_cursor)
Expand Down
Loading

0 comments on commit 3c09c75

Please sign in to comment.