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

Linting 2 - no unsafe optional chaining #50

Merged
merged 25 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
aacf1b7
package
hardingjam Oct 1, 2024
1ce5596
Merge branch '30-09-24-format' into 01-09-24-add-linter
hardingjam Oct 1, 2024
ab1f432
prefer const
hardingjam Oct 1, 2024
c2e2448
no chaining
hardingjam Oct 1, 2024
ccbf4c6
escape apostrophes
hardingjam Oct 1, 2024
fc552c8
Merge branch '30-24-09-format' into 01/09/24-no-unsafe-optional-chaining
hardingjam Oct 1, 2024
6e376a8
format
hardingjam Oct 1, 2024
61571e7
no chain
hardingjam Oct 1, 2024
71dafb6
const
hardingjam Oct 1, 2024
88f8692
apos
hardingjam Oct 1, 2024
8125bd6
unsafe chain
hardingjam Oct 1, 2024
5052660
addlint to ci
hardingjam Oct 1, 2024
bb6aeb8
lint check
hardingjam Oct 1, 2024
9922b36
Merge branch '30-24-09-format' into 01-09-24-add-linter
hardingjam Oct 1, 2024
cbb690d
Merge branch '01-09-24-add-linter' into 01/09/24-no-unsafe-optional-c…
hardingjam Oct 1, 2024
b002692
const
hardingjam Oct 1, 2024
a0f611a
fix
hardingjam Oct 1, 2024
6f42558
Merge branch '01-09-24-add-linter' into 01/09/24-no-unsafe-optional-c…
hardingjam Oct 1, 2024
597f43b
add
hardingjam Oct 1, 2024
e7f3c8c
Merge branch '01-09-24-add-linter' into 01/09/24-no-unsafe-optional-c…
hardingjam Oct 1, 2024
ef0268c
Merge branch 'main' into 01-09-24-add-linter
hardingjam Oct 1, 2024
53a6ee2
Merge branch '01-09-24-add-linter' into 01/09/24-no-unsafe-optional-c…
hardingjam Oct 1, 2024
5a362aa
format linter
hardingjam Oct 1, 2024
629b80d
Merge branch '01-09-24-add-linter' into 01/09/24-no-unsafe-optional-c…
hardingjam Oct 1, 2024
1e68565
Merge branch 'main' into 01/09/24-no-unsafe-optional-chaining
hardyjosh Oct 1, 2024
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
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"
}
}
Loading