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

feat: use strangelove style guide #262

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
40 changes: 40 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// @ts-check

const { TYPESCRIPT_FILES } = require('@strangelovelabs/style-guide/eslint/constants')
const { getTsconfigPath } = require('@strangelovelabs/style-guide/eslint/helpers')

/** @type {import("eslint").Linter.Config} */
const eslintConfig = {
extends: [
require.resolve('@strangelovelabs/style-guide/eslint/browser-node'),
require.resolve('@strangelovelabs/style-guide/eslint/react'),
require.resolve('@strangelovelabs/style-guide/eslint/next'),
require.resolve('@strangelovelabs/style-guide/eslint/typescript'),
require.resolve('@strangelovelabs/style-guide/eslint/tailwindcss'),
],
ignorePatterns: ['.next', 'node_modules', 'out'],
parserOptions: {
project: getTsconfigPath(),
},
rules: {
'@next/next/no-img-element': ['off'],
'no-console': ['warn'],
'react/function-component-definition': ['off'],
'unicorn/filename-case': ['off'],
},
overrides: [
{
files: TYPESCRIPT_FILES,
rules: {
'@typescript-eslint/no-misused-promises': ['warn'],
'@typescript-eslint/no-unsafe-argument': ['warn'],
'@typescript-eslint/no-unsafe-assignment': ['warn'],
'@typescript-eslint/no-unsafe-member-access': ['warn'],
'@typescript-eslint/no-unsafe-return': ['warn'],
},
},
],
root: true,
}

module.exports = eslintConfig
10 changes: 0 additions & 10 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,5 @@
"css.validate": false,
"editor.formatOnSave": true,
"eslint.packageManager": "yarn",
"eslint.workingDirectories": [
{
"!cwd": false,
"pattern": "packages/*"
},
{
"!cwd": false,
"directory": "."
}
],
"npm.packageManager": "yarn"
}
2 changes: 1 addition & 1 deletion components/forms/AddressBalances.hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function useAddressBalancesState() {
}

function update(key: string, balance = record[key]) {
setRecord((prev) => ({ ...prev, [key]: balance }))
setRecord((prev) => ({ ...prev, [key]: balance! }))
}

function remove(key: string) {
Expand Down
2 changes: 1 addition & 1 deletion components/forms/AddressList.hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function useAddressListState() {
}

function update(key: string, balance = record[key]) {
setRecord((prev) => ({ ...prev, [key]: balance }))
setRecord((prev) => ({ ...prev, [key]: balance! }))
}

function remove(key: string) {
Expand Down
12 changes: 6 additions & 6 deletions config/keplr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,22 @@ export const keplrConfig = (config: AppConfig): ChainInfo => ({
},
currencies: [
{
coinDenom: config.coinMap[config.feeToken].denom,
coinDenom: config.coinMap[config.feeToken]!.denom,
coinMinimalDenom: config.feeToken,
coinDecimals: config.coinMap[config.feeToken].fractionalDigits,
coinDecimals: config.coinMap[config.feeToken]!.fractionalDigits,
},
],
feeCurrencies: [
{
coinDenom: config.coinMap[config.feeToken].denom,
coinDenom: config.coinMap[config.feeToken]!.denom,
coinMinimalDenom: config.feeToken,
coinDecimals: config.coinMap[config.feeToken].fractionalDigits,
coinDecimals: config.coinMap[config.feeToken]!.fractionalDigits,
},
],
stakeCurrency: {
coinDenom: config.coinMap[config.stakingToken].denom,
coinDenom: config.coinMap[config.stakingToken]!.denom,
coinMinimalDenom: config.stakingToken,
coinDecimals: config.coinMap[config.stakingToken].fractionalDigits,
coinDecimals: config.coinMap[config.stakingToken]!.fractionalDigits,
},
gasPriceStep: {
low: config.gasPrice / 2,
Expand Down
3 changes: 2 additions & 1 deletion contexts/wallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ const WalletSubscription = () => {
throw new Error('window.keplr not found')
}
const balance: Coin[] = []
const address = (await signer.getAccounts())[0].address
const address = (await signer.getAccounts())[0]!.address
const account = await client.getAccount(address)
const key = await window.keplr.getKey(config.chainId)
await refreshBalance(address, balance)
Expand Down Expand Up @@ -274,6 +274,7 @@ const createClient = ({ signer }: { signer: OfflineSigner }) => {
const { config } = useWalletStore.getState()
return SigningCosmWasmClient.connectWithSigner(config.rpcUrl, signer, {
gasPrice: {
// @ts-expect-error different @cosmjs/math transitive dependencies being used
amount: Decimal.fromUserInput('0.0025', 100),
denom: config.feeToken,
},
Expand Down
29 changes: 13 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
{
"name": "juno-tools",
"version": "1.3.0",
"workspaces": [
"packages/*"
],
"scripts": {
"build": "next build",
"dev": "next dev",
Expand Down Expand Up @@ -51,28 +48,22 @@
"zustand": "^3"
},
"devDependencies": {
"@strangelovelabs/style-guide": "latest",
"@types/node": "^14",
"@types/react": "^18",
"@types/react-datetime-picker": "^3",
"@types/react-dom": "^17.0.11",
"@types/react-dom": "^18",
"autoprefixer": "^10",
"eslint": "^8",
"husky": "^7",
"lint-staged": "^12",
"postcss": "^8",
"prettier": "^2",
"tailwindcss": "^3",
"typescript": "^4"
},
"eslintConfig": {
"extends": [
"@juno-tools/eslint-config"
],
"ignorePatterns": [
".next",
"node_modules",
"out",
"public"
],
"root": true
"resolutions": {
"@cosmjs/math": "^0"
},
"lint-staged": {
"*.{json,md}": [
Expand All @@ -82,6 +73,12 @@
"eslint --fix"
]
},
"prettier": "@juno-tools/prettier-config",
"prettier": {
"endOfLine": "auto",
"printWidth": 120,
"semi": false,
"singleQuote": true,
"trailingComma": "all"
},
"private": true
}
71 changes: 0 additions & 71 deletions packages/eslint-config/index.js

This file was deleted.

31 changes: 0 additions & 31 deletions packages/eslint-config/package.json

This file was deleted.

12 changes: 0 additions & 12 deletions packages/prettier-config/index.js

This file was deleted.

26 changes: 0 additions & 26 deletions packages/prettier-config/package.json

This file was deleted.

6 changes: 3 additions & 3 deletions pages/airdrops/[address]/claim.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const ClaimAirdropPage: NextPage = () => {
}, [contractAddress, wallets])

useEffect(() => {
setTerraAddress(wallets[0]?.terraAddress)
setTerraAddress(wallets[0]!.terraAddress)
}, [wallets[0]?.terraAddress])

useEffect(() => {
Expand Down Expand Up @@ -159,7 +159,7 @@ const ClaimAirdropPage: NextPage = () => {
}

const claim = Buffer.from(JSON.stringify(prepareSignBytes(signDoc))).toString('base64')
const publickey = signResult.result.auth_info.signer_infos[0].public_key.toAmino().value
const publickey = signResult.result.auth_info.signer_infos[0]!.public_key.toAmino().value
const sig = Buffer.from(
JSON.stringify({ pub_key: publickey, signature: signResult.result.signatures[0] }),
).toString('base64')
Expand All @@ -183,7 +183,7 @@ const ClaimAirdropPage: NextPage = () => {

const airdrop = await getAirdrop(contractAddress)

const address = airdrop.isTerraAirdrop ? wallets[0]?.terraAddress : wallet.address
const address = airdrop.isTerraAirdrop ? wallets[0]!.terraAddress : wallet.address

const { data } = await axios.get(
`${process.env.NEXT_PUBLIC_API_URL}/proofs/contract/${contractAddress}/wallet/${address}`,
Expand Down
2 changes: 1 addition & 1 deletion pages/airdrops/create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ const CreateAirdropPage: NextPage = () => {

const onFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {
if (!e.target.files) return
setAccountsFile(e.target.files[0])
setAccountsFile(e.target.files[0]!)
}

const removeFileOnClick = () => {
Expand Down
2 changes: 1 addition & 1 deletion pages/airdrops/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const AIRDROPS_ENDPOINT = `${process.env.NEXT_PUBLIC_API_URL}/airdrops`

const getAirdrops = async ({ queryKey }: QueryFunctionContext<string[]>) => {
const [endpoint, address, page, search] = queryKey
const { data } = await axios.get(endpoint, {
const { data } = await axios.get(endpoint!, {
params: { address, page, search },
})
return data
Expand Down
2 changes: 1 addition & 1 deletion pages/contracts/upload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const UploadContract: NextPage = () => {

const onFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {
if (!e.target.files) return
setWasmFile(e.target.files[0])
setWasmFile(e.target.files[0]!)
}

useEffect(() => {
Expand Down
Loading