Skip to content

Commit

Permalink
chores: linter
Browse files Browse the repository at this point in the history
  • Loading branch information
wrap-that-potassium committed Mar 13, 2024
1 parent afe0759 commit a662f43
Show file tree
Hide file tree
Showing 20 changed files with 242 additions and 255 deletions.
27 changes: 12 additions & 15 deletions frontend/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
const path = require('path');
const synpressPath = path.join(
process.cwd(),
'/node_modules/@synthetixio/synpress',
);
const path = require('path')
const synpressPath = path.join(process.cwd(), '/node_modules/@synthetixio/synpress')

module.exports = {
root: true,
Expand All @@ -20,7 +17,7 @@ module.exports = {
],
parserOptions: {
ecmaVersion: 2020,
sourceType: "module",
sourceType: 'module',
},
rules: {
// 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
Expand All @@ -32,13 +29,13 @@ module.exports = {
'import/no-unresolved': 'error',
},
settings: {
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx"]
},
"import/resolver": {
typescript: {
alwaysTryTypes: true, // always try to resolve types under `<root>@types` directory even it doesn't contain any source code, like `@types/unist`
}
}
}
'import/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx'],
},
'import/resolver': {
typescript: {
alwaysTryTypes: true, // always try to resolve types under `<root>@types` directory even it doesn't contain any source code, like `@types/unist`
},
},
},
}
2 changes: 1 addition & 1 deletion frontend/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
presets: ['@vue/cli-plugin-babel/preset']
presets: ['@vue/cli-plugin-babel/preset'],
}
36 changes: 18 additions & 18 deletions frontend/cypress.config.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
const { defineConfig } = require("cypress");
const synpressPlugins = require("@synthetixio/synpress/plugins");
const { defineConfig } = require('cypress')
const synpressPlugins = require('@synthetixio/synpress/plugins')

module.exports = defineConfig({
projectId: "2p7qw6",
userAgent: "synpress",
chromeWebSecurity: true,
defaultCommandTimeout: 30000,
pageLoadTimeout: 30000,
requestTimeout: 30000,
e2e: {
testIsolation: true,
setupNodeEvents(on, config) {
synpressPlugins(on, config);
},
baseUrl: "http://localhost:8080",
supportFile: "tests/support/e2e.ts",
specPattern: "tests/e2e/**/*.spec.{js,jsx,ts,tsx}",
},
});
projectId: '2p7qw6',
userAgent: 'synpress',
chromeWebSecurity: true,
defaultCommandTimeout: 30000,
pageLoadTimeout: 30000,
requestTimeout: 30000,
e2e: {
testIsolation: true,
setupNodeEvents(on, config) {
synpressPlugins(on, config)
},
baseUrl: 'http://localhost:8080',
supportFile: 'tests/support/e2e.ts',
specPattern: 'tests/e2e/**/*.spec.{js,jsx,ts,tsx}',
},
})
49 changes: 16 additions & 33 deletions frontend/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,45 +1,30 @@
const {
compilerOptions
} = require('./tsconfig');
const { compilerOptions } = require('./tsconfig')

const {
resolve
} = require('path');
const { resolve } = require('path')

module.exports = {
globals: {
__DEV__: true
__DEV__: true,
},
setupFiles: [
"fake-indexeddb/auto"
],
setupFilesAfterEnv: [
'<rootDir>/tests/unit/jest.setup.ts'
],
setupFiles: ['fake-indexeddb/auto'],
setupFilesAfterEnv: ['<rootDir>/tests/unit/jest.setup.ts'],
preset: '@vue/cli-plugin-unit-jest/presets/typescript-and-babel',
collectCoverage: true,
collectCoverageFrom: [
'<rootDir>/src/**/*.vue',
'<rootDir>/src/**/*.js',
'<rootDir>/src/**/*.ts',
'<rootDir>/src/**/*.jsx'
'<rootDir>/src/**/*.jsx',
],
coverageThreshold: {
global: {
statements: 15.3,
branches: 6.5,
functions: 7.2,
lines: 15,
}
},
},
moduleFileExtensions: [
'vue',
'js',
'jsx',
'json',
'ts',
'tsx',
],
moduleFileExtensions: ['vue', 'js', 'jsx', 'json', 'ts', 'tsx'],
moduleNameMapper: {
//"^vue$": "<rootDir>/node_modules/vue/dist/vue.esm.js",
'^vue$': '<rootDir>/node_modules/vue/dist/vue.common.js',
Expand All @@ -49,19 +34,17 @@ module.exports = {
'^@artifacts/(.*)$': resolve(__dirname, '../artifacts/$1'),
},
transform: {
'.*\\.vue$': 'vue-jest',
'.*\\.js$': 'babel-jest',
'.+\\.(css|styl|less|sass|scss|svg|png|jpg|ttf|woff|woff2)$': 'jest-transform-stub',
// use these if NPM is being flaky
// '.*\\.vue$': '<rootDir>/node_modules/@quasar/quasar-app-extension-testing-unit-jest/node_modules/vue-jest',
// '.*\\.js$': '<rootDir>/node_modules/@quasar/quasar-app-extension-testing-unit-jest/node_modules/babel-jest'
},
'.*\\.vue$': 'vue-jest',
'.*\\.js$': 'babel-jest',
'.+\\.(css|styl|less|sass|scss|svg|png|jpg|ttf|woff|woff2)$': 'jest-transform-stub',
// use these if NPM is being flaky
// '.*\\.vue$': '<rootDir>/node_modules/@quasar/quasar-app-extension-testing-unit-jest/node_modules/vue-jest',
// '.*\\.js$': '<rootDir>/node_modules/@quasar/quasar-app-extension-testing-unit-jest/node_modules/babel-jest'
},
/*
transformIgnorePatterns: [
'<rootDir>/node_modules/(?!quasar/lang)'
],
*/
snapshotSerializers: [
'<rootDir>/node_modules/jest-serializer-vue'
]
snapshotSerializers: ['<rootDir>/node_modules/jest-serializer-vue'],
}
2 changes: 1 addition & 1 deletion frontend/src/models/ClaimRequest.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ethers } from "ethers"
import { ethers } from 'ethers'

type ClaimRequest = {
banAddress: string
Expand Down
10 changes: 5 additions & 5 deletions frontend/src/models/GaslessSettings.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
type GaslessSettings = {
enabled: boolean,
swapAllowed: boolean,
banThreshold: number,
cryptoThreshold: number,
swapContract: string,
enabled: boolean
swapAllowed: boolean
banThreshold: number
cryptoThreshold: number
swapContract: string
}

export { GaslessSettings }
24 changes: 12 additions & 12 deletions frontend/src/models/GaslessSwapRequest.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { Web3Provider } from "@ethersproject/providers";
import { Web3Provider } from '@ethersproject/providers'

declare type Permit = {
amount: string; // amount of wBAN to swap
deadline: number; // permit deadline
signature: string; // Permit signature to spend wBAN
};
amount: string // amount of wBAN to swap
deadline: number // permit deadline
signature: string // Permit signature to spend wBAN
}

declare type GaslessSwapRequest = {
banWallet: string;
recipient: string; // blockchain address of the user requesting the gasless swap
permit: Permit;
gasLimit: number;
swapCallData: string; // the 0x `data` field from the API response
banWallet: string
recipient: string // blockchain address of the user requesting the gasless swap
permit: Permit
gasLimit: number
swapCallData: string // the 0x `data` field from the API response
provider: Web3Provider
};
}

export { GaslessSwapRequest };
export { GaslessSwapRequest }
4 changes: 2 additions & 2 deletions frontend/src/services/dex/DEXAggregator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { SwapQuoteRequest, QuoteResponse, SwapResponse } from '@/models/dex/Swap
import { OneInchAggregator } from './1inchAggregator'

interface DEXAggregator {
getQuote(request: SwapQuoteRequest, skipValidation: boolean): Promise<QuoteResponse>;
getSwap(request: SwapQuoteRequest, gaslessSwap: boolean, skipValidation: boolean): Promise<SwapResponse>;
getQuote(request: SwapQuoteRequest, skipValidation: boolean): Promise<QuoteResponse>
getSwap(request: SwapQuoteRequest, gaslessSwap: boolean, skipValidation: boolean): Promise<SwapResponse>
}

export { DEXAggregator }
6 changes: 5 additions & 1 deletion frontend/src/utils/dialogs/FarmDepositDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,11 @@ export default class FarmDepositDialog extends Vue {
if (this.farm.quoteToken.address) {
const otherToken = this.farm.quoteToken.address[FarmDepositDialog.ENV_NAME as keyof Address]
if (getDexUrl() === 'https://app.sushi.com/legacy' || getDexUrl().startsWith('https://pancakeswap.finance')) {
openURL(`${getDexUrl()}/add/0xe20B9e246db5a0d21BF9209E4858Bc9A3ff7A034/${otherToken}?chainId=${this.network.chainIdNumber}`)
openURL(
`${getDexUrl()}/add/0xe20B9e246db5a0d21BF9209E4858Bc9A3ff7A034/${otherToken}?chainId=${
this.network.chainIdNumber
}`,
)
} else if (getDexUrl() === 'https://app.uniswap.org') {
openURL(`${getDexUrl()}/#/add/v2/${this.wbanAddress}/${otherToken}`)
} else {
Expand Down
38 changes: 19 additions & 19 deletions frontend/tests/e2e/auto-reconnect.spec.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
describe("Auto Reconnect Web3 Wallet", () => {
const banAddy = 'ban_1burnbabyburndiscoinferno111111111111111111111111111aj49sw3w';
describe('Auto Reconnect Web3 Wallet', () => {
const banAddy = 'ban_1burnbabyburndiscoinferno111111111111111111111111111aj49sw3w'

afterEach(() => {
cy.disconnectMetamaskWalletFromAllDapps();
cy.disconnectMetamaskWalletFromAllDapps()
//cy.resetMetamaskAccount();
});
})

it("Should automatically reconnect wallet when reloading main page", () => {
cy.login(banAddy, 'ethereum');
it('Should automatically reconnect wallet when reloading main page', () => {
cy.login(banAddy, 'ethereum')
// we should be on home page with wBAN statistics displayed
cy.contains('wBAN Statistics');
cy.contains('wBAN Statistics')

// reload page
cy.reload();
cy.reload()

// we should still be on the main page
cy.contains('wBAN Statistics');
});
cy.contains('wBAN Statistics')
})

it("Should automatically reconnect wallet when reloading farms page", () => {
cy.login(banAddy, 'ethereum');
it('Should automatically reconnect wallet when reloading farms page', () => {
cy.login(banAddy, 'ethereum')
// we should be on home page with wBAN statistics displayed
cy.contains('wBAN Statistics');
cy.contains('wBAN Statistics')

// let's go to farms page
cy.findByText(/Stake & farm/i).click();
cy.contains('wBAN Earned');
cy.findByText(/Stake & farm/i).click()
cy.contains('wBAN Earned')

// reload page
cy.reload();
cy.reload()

// we should still be on the main page
cy.contains('wBAN Earned');
});
});
cy.contains('wBAN Earned')
})
})
21 changes: 10 additions & 11 deletions frontend/tests/e2e/bridge-relink.spec.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
describe("Bridge Relink", () => {
afterEach(() => {
cy.disconnectMetamaskWalletFromAllDapps();
//cy.resetMetamaskAccount();
});
describe('Bridge Relink', () => {
afterEach(() => {
cy.disconnectMetamaskWalletFromAllDapps()
//cy.resetMetamaskAccount();
})

it("Should restore bridge setup", () => {
cy.loginByBridgeRelink('ban_1burnbabyburndiscoinferno111111111111111111111111111aj49sw3w');
it('Should restore bridge setup', () => {
cy.loginByBridgeRelink('ban_1burnbabyburndiscoinferno111111111111111111111111111aj49sw3w')

// we should be on home page with wBAN statistics displayed
cy.contains('wBAN Statistics');
});
cy.contains('wBAN Statistics')
})

// TODO
/*
Expand All @@ -22,5 +22,4 @@ describe("Bridge Relink", () => {
it.skip('Should notify user when trying to restore bridge setup that was never done', () => {
});
*/

});
})
Loading

0 comments on commit a662f43

Please sign in to comment.