diff --git a/.github/workflows/frontend-checks.yml b/.github/workflows/frontend-checks.yml index d699674f2..914a634b9 100644 --- a/.github/workflows/frontend-checks.yml +++ b/.github/workflows/frontend-checks.yml @@ -36,6 +36,6 @@ jobs: - name: Check types working-directory: frontend run: yarn run typecheck - # - name: Linting - # working-directory: frontend - # run: yarn run lintcheck + - name: Linting + working-directory: frontend + run: yarn run lintcheck diff --git a/frontend/.eslintrc b/frontend/.eslintrc deleted file mode 100644 index d24bc883f..000000000 --- a/frontend/.eslintrc +++ /dev/null @@ -1,35 +0,0 @@ -{ - "root": true, - "parser": "vue-eslint-parser", - "plugins": [ - "jest", - "jest-dom", - "jest-formatting", - "testing-library", - "@typescript-eslint" - ], - "parserOptions": { - "parser": "@typescript-eslint/parser", - "sourceType": "module" - }, - "extends": [ - "eslint:recommended", - "@nuxtjs/eslint-config-typescript", - "plugin:jest/recommended", - "plugin:jest/style", - "plugin:jest-dom/recommended", - "plugin:jest-formatting/recommended", - "plugin:testing-library/vue", - "plugin:@typescript-eslint/recommended", - "plugin:vue/vue3-recommended", - "prettier" - ], - "ignorePatterns": ["src/types/generated.ts", "dist", ".output"], - "rules": { - "vue/multi-word-component-names": "off", - "testing-library/await-async-utils": "off", - "testing-library/await-fire-event": "off", - "@typescript-eslint/no-unused-vars": "off", - "vue/no-multiple-template-root": "off" - } -} diff --git a/frontend/eslint.config.mjs b/frontend/eslint.config.mjs new file mode 100644 index 000000000..db64679cf --- /dev/null +++ b/frontend/eslint.config.mjs @@ -0,0 +1,29 @@ +// @ts-check +import withNuxt from './.nuxt/eslint.config.mjs' +// @ts-expect-error No type definitions for this one. +import eslintConfigPrettier from 'eslint-config-prettier' + +export default withNuxt([ + // Ignore files generated from the GraphQL schema, and Nuxt output directories. + { ignores: ['src/types/generated.ts', 'dist', '.output'] }, + // Disable rules conflicting with prettier. + eslintConfigPrettier, +]) + .override('nuxt/vue/rules', { + rules: { + 'vue/multi-word-component-names': 'off', + // Disable check, since this is mostly relevant for older version of Vue (version 2). + 'vue/no-multiple-template-root': 'off', + }, + }) + // Reduce certain rules to be warnings instead of errors, since these might + // appear during development and are still prevented by the CI. + .override('nuxt/typescript/rules', { + rules: { + '@typescript-eslint/no-unused-vars': 'warn', + '@typescript-eslint/no-unused-expressions': 'warn', + '@typescript-eslint/consistent-type-imports': 'warn', + '@typescript-eslint/no-import-type-side-effects': 'warn', + }, + }) + .override('nuxt/rules', { rules: { 'no-empty': 'warn' } }) diff --git a/frontend/nuxt.config.ts b/frontend/nuxt.config.ts index 147ede18d..9dd08877d 100644 --- a/frontend/nuxt.config.ts +++ b/frontend/nuxt.config.ts @@ -65,4 +65,5 @@ export default defineNuxtConfig({ // Enable type-checking at build time. typeCheck: true, }, + modules: ['@nuxt/eslint'], }) diff --git a/frontend/package.json b/frontend/package.json index a42cd297b..278a99bd1 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -14,8 +14,8 @@ "test": "cross-env TZ=Universal jest", "test:watch": "cross-env TZ=Universal jest --watch", "typecheck": "nuxi typecheck", - "lint": "eslint --fix --max-warnings 0 --ext .js,.ts,.vue .", "lintcheck": "eslint --max-warnings 0 src", + "lint": "eslint --max-warnings 0 --fix src", "format": "prettier src --write", "formatcheck": "prettier src --check", "gql-codegen": "graphql-codegen --config graphql-codegen.yml" @@ -39,25 +39,16 @@ "@babel/preset-typescript": "^7.17.12", "@graphql-codegen/cli": "2.6.2", "@graphql-codegen/typescript": "^2.4.11", - "@nuxtjs/eslint-config-typescript": "10.0.0", + "@nuxt/eslint": "^0.6.1", "@testing-library/jest-dom": "^5.16.4", "@testing-library/vue": "^6.4.2", "@types/jest": "^27", "@types/node": "^16.11.11", - "@typescript-eslint/eslint-plugin": "^5.27.0", - "@typescript-eslint/parser": "^5.27.0", - "@vue/eslint-config-typescript": "^10.0.0", "@vue/vue3-jest": "^28", "autoprefixer": "^10.4.7", "babel-jest": "^28", - "eslint": "^8.16.0", - "eslint-config-prettier": "^8.5.0", - "eslint-plugin-jest": "^26.4.6", - "eslint-plugin-jest-dom": "^4.0.2", - "eslint-plugin-jest-formatting": "^3.1.0", - "eslint-plugin-nuxt": "^3.2.0", - "eslint-plugin-testing-library": "^5.5.1", - "eslint-plugin-vue": "^9.0.1", + "eslint": "^9.14.0", + "eslint-config-prettier": "^9.1.0", "husky": "^8.0.1", "jest": "^28", "jest-environment-jsdom": "^28.1.0", diff --git a/frontend/src/components/Accounts/AccountDetailsAccountStatement.vue b/frontend/src/components/Accounts/AccountDetailsAccountStatement.vue index 228ac6e33..40e34f422 100644 --- a/frontend/src/components/Accounts/AccountDetailsAccountStatement.vue +++ b/frontend/src/components/Accounts/AccountDetailsAccountStatement.vue @@ -103,11 +103,11 @@ > + /> + /> diff --git a/frontend/src/components/Accounts/AccountDetailsContainer.vue b/frontend/src/components/Accounts/AccountDetailsContainer.vue index 0b8002b99..6e2ce36c0 100644 --- a/frontend/src/components/Accounts/AccountDetailsContainer.vue +++ b/frontend/src/components/Accounts/AccountDetailsContainer.vue @@ -22,7 +22,7 @@ import Loader from '~/components/molecules/Loader.vue' import NotFound from '~/components/molecules/NotFound.vue' import AccountDetailsContent from '~/components/Accounts/AccountDetailsContent.vue' import { usePagination, PAGE_SIZE_SMALL } from '~/composables/usePagination' -import { type Subscription } from '~/types/generated' +import type { Subscription } from '~/types/generated' import { useAccountsUpdatedSubscription } from '~/subscriptions/useAccountsUpdatedSubscription' type Props = { @@ -102,7 +102,7 @@ const { data, error, componentState, executeQuery } = useAccountQuery({ transactionVariables, }) -const subscriptionHandler = (_prevData: void, newData: Subscription) => { +const subscriptionHandler = (_prevData: unknown, newData: Subscription) => { if ( newData.accountsUpdated.address === props.address && componentState.value !== 'loading' diff --git a/frontend/src/components/Accounts/AccountDetailsContent.vue b/frontend/src/components/Accounts/AccountDetailsContent.vue index 389514b3f..fb2c0da1b 100644 --- a/frontend/src/components/Accounts/AccountDetailsContent.vue +++ b/frontend/src/components/Accounts/AccountDetailsContent.vue @@ -133,8 +133,6 @@ import type { Account, PageInfo } from '~/types/generated' import { useDateNow } from '~/composables/useDateNow' import type { PaginationTarget } from '~/composables/usePagination' import AccountDetailsDelegation from '~/components/Accounts/AccountDetailsDelegation.vue' -import Tooltip from '~/components/atoms/Tooltip.vue' -import Amount from '~/components/atoms/Amount.vue' import AccountDetailsRewards from '~/components/Accounts/AccountDetailsRewards.vue' const { NOW } = useDateNow() diff --git a/frontend/src/components/Accounts/AccountDetailsToken.vue b/frontend/src/components/Accounts/AccountDetailsToken.vue index 231bfbb74..4779e92d5 100644 --- a/frontend/src/components/Accounts/AccountDetailsToken.vue +++ b/frontend/src/components/Accounts/AccountDetailsToken.vue @@ -73,7 +73,9 @@ watchEffect(() => { .forEach(async t => { try { t.metadata = await fetchMetadata(t.token.metadataUrl as string) - } catch {} + } catch { + return + } }) }) diff --git a/frontend/src/components/BakerDetails/BakerDetailsHeader.spec.ts b/frontend/src/components/BakerDetails/BakerDetailsHeader.spec.ts index c734a3908..67ff7acdb 100644 --- a/frontend/src/components/BakerDetails/BakerDetailsHeader.spec.ts +++ b/frontend/src/components/BakerDetails/BakerDetailsHeader.spec.ts @@ -1,6 +1,5 @@ import BakerDetailsHeader from './BakerDetailsHeader.vue' import { setupComponent, screen } from '~/utils/testing' -import { BakerPoolOpenStatus } from '~/types/generated' jest.mock('~/composables/useDrawer', () => ({ useDrawer: () => ({ diff --git a/frontend/src/components/BakerDetails/BakerDetailsPoolAmounts.vue b/frontend/src/components/BakerDetails/BakerDetailsPoolAmounts.vue index 218d6abc8..1e8888d47 100644 --- a/frontend/src/components/BakerDetails/BakerDetailsPoolAmounts.vue +++ b/frontend/src/components/BakerDetails/BakerDetailsPoolAmounts.vue @@ -2,7 +2,7 @@ diff --git a/frontend/src/components/molecules/BlockLink.vue b/frontend/src/components/molecules/BlockLink.vue index d767de0bb..806b1f704 100644 --- a/frontend/src/components/molecules/BlockLink.vue +++ b/frontend/src/components/molecules/BlockLink.vue @@ -44,7 +44,6 @@ const emitBlur = (newTarget: FocusEvent) => { } const handleOnClick = (hash?: string, id?: string) => { - ;(hash || id) && - drawer.push({ entityTypeName: 'block', hash: hash || '', id }) + if (hash || id) drawer.push({ entityTypeName: 'block', hash: hash || '', id }) } diff --git a/frontend/src/components/molecules/CarouselSlide.vue b/frontend/src/components/molecules/CarouselSlide.vue index 1683f8208..c719b9065 100644 --- a/frontend/src/components/molecules/CarouselSlide.vue +++ b/frontend/src/components/molecules/CarouselSlide.vue @@ -1,5 +1,5 @@  diff --git a/frontend/src/components/molecules/ChartCards/PoolRewardTotalChart.vue b/frontend/src/components/molecules/ChartCards/PoolRewardTotalChart.vue index bdb405d05..9bb3de597 100644 --- a/frontend/src/components/molecules/ChartCards/PoolRewardTotalChart.vue +++ b/frontend/src/components/molecules/ChartCards/PoolRewardTotalChart.vue @@ -17,7 +17,7 @@ :is-loading="isLoading" :label-formatter="formatLabel" > - +