Skip to content

Commit 872d302

Browse files
committed
working lint with fixes
1 parent 446205a commit 872d302

14 files changed

Lines changed: 120 additions & 67 deletions

eslint.config.mjs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import {
2+
typescriptConfig,
3+
unicornConfig,
4+
workspacesConfig,
5+
rulesConfig,
6+
sonarConfig,
7+
importConfig,
8+
} from '@xylabs/eslint-config-flat'
9+
10+
export default [
11+
{ ignores: ['.yarn', '**/dist', '**/build', 'scripts', 'node_modules', '*.cjs', '*.mjs'] },
12+
{ files: ['**/*.ts'] },
13+
unicornConfig,
14+
workspacesConfig,
15+
rulesConfig,
16+
typescriptConfig,
17+
sonarConfig,
18+
{
19+
...importConfig,
20+
rules: {
21+
...importConfig.rules,
22+
'import-x/no-internal-modules': ['warn', { allow: ['*/index.ts'] }],
23+
'import-x/no-unresolved': ['off'],
24+
'import-x/no-relative-packages': ['error'],
25+
'import-x/no-self-import': ['error'],
26+
'import-x/no-useless-path-segments': ['warn'],
27+
'sonarjs/prefer-single-boolean-return': ['off'],
28+
},
29+
},
30+
{
31+
rules: {
32+
'@typescript-eslint/no-unused-vars': [
33+
'warn',
34+
{
35+
argsIgnorePattern: '^_', varsIgnorePattern: '^_', ignoreRestSiblings: true,
36+
},
37+
],
38+
},
39+
},
40+
]

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"type": "module",
2323
"scripts": {
2424
"build": "vite build --mode production",
25+
"lint": "eslint",
2526
"package-build": "npm run build",
2627
"serve": "npm run build && npx serve ./build",
2728
"start-cli": "npx xl1 --logLevel='warn'",
@@ -49,8 +50,11 @@
4950
"@types/react": "~19.1.10",
5051
"@types/react-dom": "~19.1.7",
5152
"@vitejs/plugin-react-swc": "~4.0.0",
53+
"@xylabs/eslint-config-flat": "~7.1.7",
5254
"@xylabs/tsconfig-react": "~7.1.3",
5355
"@xyo-network/xl1-cli": "^1.12.6",
56+
"eslint": "~9.33.0",
57+
"eslint-import-resolver-typescript": "~4.4.4",
5458
"dotenv": "~17.2.1",
5559
"npm-check-updates": "~18.0.2",
5660
"typescript": "~5.9.2",

src/Sample.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
import {
22
Alert,
3-
Container, Stack
3+
Container, Stack,
44
} from '@mui/material'
55
import { assertEx } from '@xylabs/assert'
66
import type { Hash } from '@xylabs/hex'
77
import { isHash } from '@xylabs/hex'
88
import { isUndefined } from '@xylabs/typeof'
99
import { useState } from 'react'
1010

11-
import { Onboarding, SubmitTransactionButton, TxConfirmedAlert, WelcomeStack } from './components/index.ts'
11+
import {
12+
Onboarding, SubmitTransactionButton, TxConfirmedAlert, WelcomeStack,
13+
} from './components/index.ts'
1214
import { buildSamplePayloads } from './helpers/index.ts'
1315
import { useDefaultGateway } from './hooks/index.ts'
1416

@@ -44,7 +46,7 @@ export const XL1BrowserSample = () => {
4446
{error ? <Alert severity="error">{error.message}</Alert> : null}
4547
<WelcomeStack />
4648
<Onboarding />
47-
<SubmitTransactionButton onClick={() => void submitTransaction()} disabled={isUndefined(gateway)}>Submit Transaction</SubmitTransactionButton>
49+
<SubmitTransactionButton onClick={() => void submitTransaction()} disabled={isUndefined(gateway)}>Submit Transaction</SubmitTransactionButton>
4850
<TxConfirmedAlert hash={confirmed} />
4951
</Stack>
5052

src/components/Onboarding.tsx

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react'
2+
23
import { useOnBoarding } from '../hooks/index.ts'
3-
import { WalletAlerts } from './alerts/index.ts'
4-
import { RunProducerAlerts } from './alerts/index.ts'
4+
import { RunProducerAlerts, WalletAlerts } from './alerts/index.ts'
55

66
export const Onboarding: React.FC = () => {
77
const {
@@ -10,11 +10,13 @@ export const Onboarding: React.FC = () => {
1010
walletIsNotInstalled,
1111
} = useOnBoarding()
1212

13-
return <>
14-
{producerIsReachable ? <RunProducerAlerts.Found /> : <RunProducerAlerts.NotFound />}
15-
{producerIsReachable && <RunProducerAlerts.CopyPhrase />}
16-
{walletIsNotInstalled === true && <WalletAlerts.NotInstalled />}
17-
{walletIsInstalled === true && <WalletAlerts.Installed />}
18-
{walletIsInstalled === true && <WalletAlerts.Setup />}
19-
</>
20-
}
13+
return (
14+
<>
15+
{producerIsReachable ? <RunProducerAlerts.Found /> : <RunProducerAlerts.NotFound />}
16+
{producerIsReachable && <RunProducerAlerts.CopyPhrase />}
17+
{walletIsNotInstalled === true && <WalletAlerts.NotInstalled />}
18+
{walletIsInstalled === true && <WalletAlerts.Installed />}
19+
{walletIsInstalled === true && <WalletAlerts.Setup />}
20+
</>
21+
)
22+
}

src/components/WelcomeStack.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import { Stack, StackProps, Typography } from "@mui/material";
1+
import type { StackProps } from '@mui/material'
2+
import { Stack, Typography } from '@mui/material'
3+
24
// eslint-disable-next-line import-x/no-internal-modules
35
import Xl13DLogo from '../images/XL1_3D_Token_Mainnet.svg'
46

@@ -12,4 +14,4 @@ export const WelcomeStack: React.FC<StackProps> = (props) => {
1214
<Typography variant="subtitle1">This is a sample page for adding payloads to the XL1 chain for the browser environment.</Typography>
1315
</Stack>
1416
)
15-
}
17+
}

src/components/alerts/TxConfirmedAlert.tsx

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,17 @@ export interface TxConfirmedAlertProps extends AlertProps {
88
}
99

1010
export const TxConfirmedAlert: React.FC<TxConfirmedAlertProps> = ({ hash, ...props }) => {
11-
return hash ? (
12-
<Alert severity="success" {...props}>
13-
<AlertTitle>Transaction successfully confirmed!</AlertTitle>
14-
See your local
15-
{' '}
16-
<Link href={`https://explore.xyo.network/xl1/local/transaction/${hash}`} target="_blank">transaction</Link>
17-
{' '}
18-
through our Blockchain Explorer.
19-
{' '}
20-
</Alert>
21-
) : null
11+
return hash
12+
? (
13+
<Alert severity="success" {...props}>
14+
<AlertTitle>Transaction successfully confirmed!</AlertTitle>
15+
See your local
16+
{' '}
17+
<Link href={`https://explore.xyo.network/xl1/local/transaction/${hash}`} target="_blank">transaction</Link>
18+
{' '}
19+
through our Blockchain Explorer.
20+
{' '}
21+
</Alert>
22+
)
23+
: null
2224
}
Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
import { Button, ButtonProps } from "@mui/material";
2-
import { useDefaultGateway, useOnBoarding } from "../../hooks/index.ts";
3-
import { isUndefined } from "@xylabs/typeof";
1+
import type { ButtonProps } from '@mui/material'
2+
import { Button } from '@mui/material'
3+
import { isUndefined } from '@xylabs/typeof'
4+
5+
import { useDefaultGateway, useOnBoarding } from '../../hooks/index.ts'
46

57
export const SubmitTransactionButton: React.FC<ButtonProps> = (props) => {
68
const { gateway } = useDefaultGateway()
79
const { showSubmitTransaction } = useOnBoarding()
810

9-
return showSubmitTransaction ? <Button variant="contained" disabled={isUndefined(gateway)} sx={{ alignSelf: 'start' }} {...props}>Submit Transaction</Button> : null
10-
}
11+
return showSubmitTransaction
12+
? <Button variant="contained" disabled={isUndefined(gateway)} sx={{ alignSelf: 'start' }} {...props}>Submit Transaction</Button>
13+
: null
14+
}

src/components/buttons/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export * from './SubmitTransactionButton.tsx'
1+
export * from './SubmitTransactionButton.tsx'

src/components/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
export * from './alerts/index.ts'
2+
export * from './buttons/index.ts'
23
export * from './Onboarding.tsx'
34
export * from './WelcomeStack.tsx'
4-
export * from './buttons/index.ts'

src/helpers/buildSamplePayloads.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { Id } from "@xyo-network/id-payload-plugin"
2-
import { PayloadBuilder } from "@xyo-network/payload-builder"
3-
import { HashPayload } from "@xyo-network/xl1-protocol"
1+
import type { Id } from '@xyo-network/id-payload-plugin'
2+
import { PayloadBuilder } from '@xyo-network/payload-builder'
3+
import type { HashPayload } from '@xyo-network/xl1-protocol'
44

55
export const buildSamplePayloads = async () => {
66
// Data to store off-chain
@@ -15,4 +15,4 @@ export const buildSamplePayloads = async () => {
1515
hash: await PayloadBuilder.hash(offChainPayloads[index]),
1616
})))
1717
return { offChainPayloads, hashPayloads }
18-
}
18+
}

0 commit comments

Comments
 (0)