Skip to content

Commit

Permalink
Merge pull request #50 from rainlanguage/01/09/24-no-unsafe-optional-…
Browse files Browse the repository at this point in the history
…chaining

Linting 2 - no unsafe optional chaining
  • Loading branch information
hardyjosh authored Oct 1, 2024
2 parents e538020 + 1e68565 commit 8c387b0
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 24 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/rainix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,14 @@ jobs:
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- run: nix develop -c npm run format-check
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
fetch-depth: 0

- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- run: nix develop -c npm run lint-check
6 changes: 3 additions & 3 deletions app/_components/SubmissionModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export const SubmissionModal = ({
setError(
<>
<p className="mb-3">
You don't have enough {deposit.tokenInfo.symbol} to cover this deposit.
You don&apos;t have enough {deposit.tokenInfo.symbol} to cover this deposit.
</p>
<p className="mb-3">
Your balance: {formatUnits(BigInt(balance), deposit.tokenInfo.decimals)}
Expand Down Expand Up @@ -426,8 +426,8 @@ export const SubmissionModal = ({
<div className="flex flex-col items-start transition-opacity duration-1500 animate-fade-in gap-y-4">
<DialogTitle className="w-full font-light text-2xl">Your strategy is live!</DialogTitle>
<div>
It will continue to trade until removed. If you're interested in creating your own
strategies from scratch, try <a href="https://docs.rainlang.xyz"> Raindex.</a>
It will continue to trade until removed. If you&apos;re interested in creating your
own strategies from scratch, try <a href="https://docs.rainlang.xyz"> Raindex.</a>
</div>
<Button
className="mt-4"
Expand Down
2 changes: 1 addition & 1 deletion app/_queries/strategyAnalytics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export const transactionAnalytics = (transactionId: string) => `
export const getTransactionAnalyticsData = async (transactionId: string) => {
const networks = getNetworkSubgraphs();
// Find which subgraph has the transaction data by checking each subgraph
for (let [network, subgraphUrl] of Object.entries(networks)) {
for (const [network, subgraphUrl] of Object.entries(networks)) {
try {
const response = await fetch(subgraphUrl, {
method: 'POST',
Expand Down
15 changes: 11 additions & 4 deletions app/_services/buttonsData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,21 +66,28 @@ export const getFieldPresetsButtons = (field: Field): any[] => {
];
};

export const getDepositPresetsButtons = (deposit: Deposit, token: TokenInfo): any[] => {
export const getDepositPresetsButtons = (
deposit: Deposit | undefined | null,
token: TokenInfo
): any[] => {
if (!deposit) {
return [];
}

return [
{
buttonTarget: 'buttonValue',
buttonValue: 'back',
buttonText: '←'
},
...(deposit?.presets
? deposit.presets?.map((preset: number) => ({
...(deposit.presets
? deposit.presets.map((preset: number) => ({
buttonTarget: 'buttonValue',
buttonValue: `${preset}`,
buttonText: `${preset} ${token.symbol}`
}))
: []),
...(deposit?.min !== undefined
...(deposit.min !== undefined
? [
{
buttonTarget: 'textInputLabel',
Expand Down
2 changes: 1 addition & 1 deletion app/_services/getTokenInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export interface TokenInfo {
}

export const getTokenInfos = async (yaml: YamlData): Promise<TokenInfo[]> => {
let tokenInfos = [];
const tokenInfos = [];

for (const [tokenName, token] of Object.entries(yaml.tokens)) {
if (!isHex(token.address))
Expand Down
42 changes: 29 additions & 13 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import globals from 'globals';
import pluginJs from '@eslint/js';
import tseslint from 'typescript-eslint';
import pluginReact from 'eslint-plugin-react';
import reactPlugin from 'eslint-plugin-react';

export default [
{
Expand All @@ -14,19 +14,10 @@ export default [
'!.env.example',
'pnpm-lock.yaml',
'package-lock.json',
'yarn.lock'
'yarn.lock',
'.next'
]
},
{
rules: {
'no-console': process.env.NODE_ENV === 'production' || process.env.CI ? 'error' : 'off',
'no-trailing-spaces': 'error',
eqeqeq: 'off',
'no-unused-vars': 'error',
'prefer-const': ['error', { ignoreReadBeforeAssign: true }],
'react/react-in-jsx-scope': 'off'
}
},

{ files: ['**/*.{js,mjs,cjs,ts,jsx,tsx}'] },
{
Expand All @@ -43,7 +34,32 @@ export default [
}
}
},

pluginJs.configs.recommended,
...tseslint.configs.recommended,
pluginReact.configs.flat.recommended
reactPlugin.configs.flat.recommended,
reactPlugin.configs.flat['jsx-runtime'],
{
rules: {
'no-console':
process.env.NODE_ENV === 'production' || process.env.CI
? ['error', { allow: ['warn', 'error'] }]
: 'off',
'no-trailing-spaces': 'error',
eqeqeq: 'off',
'prefer-const': ['error', { ignoreReadBeforeAssign: true }],
'react/react-in-jsx-scope': 'off',
'react/jsx-filename-extension': ['error', { extensions: ['.js', '.jsx', '.ts', '.tsx'] }],
'react/prop-types': 'off',
'react/no-unknown-property': ['error', { ignore: ['tw'] }],
// Disabled for PRs to be merged
'react/jsx-key': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-empty-object-type': 'off',
'no-case-declarations': 'off'
// 'react/no-unescaped-entities': 'off'
// 'no-unsafe-optional-chaining': 'off',
}
}
];
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,10 @@
"dev": "node ./scripts/dev-script.js",
"start": "next start",
"build": "next build",
"lint": "eslint .",
"lint-check": "eslint .",
"lint:fix": "eslint . --fix",
"format-check": "prettier --list-different .",
"format": "prettier --write . --config ./.prettierrc.json"
"format": "prettier --write . --config ./.prettierrc.json",
"lint-format-check": "npm run lint-check && npm run format-check"
}
}

0 comments on commit 8c387b0

Please sign in to comment.