From d7a9ef96460fa7297863dc6a913c94991708ad51 Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 25 Apr 2024 15:27:15 +0200 Subject: [PATCH 01/12] Update package.json for eslint.config.js files --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 769a008b..c5de54a3 100644 --- a/package.json +++ b/package.json @@ -9,8 +9,8 @@ "preview": "vite preview", "test:unit": "vitest", "check-types": "vue-tsc --noEmit", - "lint": "eslint --ext .ts,vue src tests", - "lint-ci": "eslint --no-fix --ext .ts,vue src tests", + "lint": "eslint src tests", + "lint-ci": "eslint --no-fix src tests", "test:e2e": "yarn playwright test", "test:e2e-chromium": "yarn playwright test --project=chromium", "test:e2e-msedge": "yarn playwright test --project=msedge" From c0ec94b20b723b2d7b0eb72c3bd15affb1a6acf9 Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 25 Apr 2024 15:27:45 +0200 Subject: [PATCH 02/12] Add eslint.config.js, fix one gotcha --- eslint.config.js | 71 ++++++++++++++++++++++++++++++++++++++++ src/views/ChartsView.vue | 2 +- 2 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 eslint.config.js diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 00000000..579d73e7 --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,71 @@ +import Vue from 'eslint-plugin-vue'; + +import { FlatCompat } from '@eslint/eslintrc'; +import js from '@eslint/js'; +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); + +const compat = new FlatCompat({ + baseDirectory: __dirname, +}); + +export default [ + ...Vue.configs['flat/recommended'], + js.configs.recommended, + ...compat.extends('@vue/eslint-config-typescript/recommended'), + ...compat.extends('@vue/eslint-config-prettier'), + { + languageOptions: { + parserOptions: { + parser: '@typescript-eslint/parser', + }, + }, + }, + { + files: ['**/*.{js,mjs,cjs,ts,mts,cts,tsx,vue}'], + + rules: { + 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off', + 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off', + 'class-methods-use-this': 0, + // disable eslint no-shadow as it's causing false positives on typescript enums + 'no-shadow': 'off', + 'prettier/prettier': ['error'], + '@typescript-eslint/no-explicit-any': 'warn', + '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }], + // '@typescript-eslint/naming-convention': [ + // 'error', + // { + // selector: 'default', + // format: ['camelCase'], + // }, + // { + // selector: 'variable', + // format: ['camelCase', 'UPPER_CASE'], + // }, + // { + // selector: 'parameter', + // format: ['camelCase'], + // leadingUnderscore: 'allow', + // }, + // { + // selector: 'memberLike', + // modifiers: ['private'], + // format: ['camelCase'], + // leadingUnderscore: 'require', + // }, + // { + // selector: 'typeLike', + // format: ['PascalCase'], + // }, + // { + // selector: 'class', + // format: ['PascalCase'], + // }, + // ], + }, + }, +]; diff --git a/src/views/ChartsView.vue b/src/views/ChartsView.vue index 1d9ee16c..fd01e2e7 100644 --- a/src/views/ChartsView.vue +++ b/src/views/ChartsView.vue @@ -52,7 +52,7 @@ const availablePairs = computed(() => { if (finalTimeframe.value && finalTimeframe.value !== '') { const tf = finalTimeframe.value; return botStore.activeBot.pairlistWithTimeframe - .filter(([pair, timeframe]) => { + .filter(([_, timeframe]) => { // console.log(pair, timeframe, tf); return timeframe === tf; }) From 2dcec30f263c70caed173dceac69bc51f18b8b18 Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 25 Apr 2024 15:31:31 +0200 Subject: [PATCH 03/12] Remove outdated eslintrc config --- .eslintrc.cjs | 71 --------------------------------------------------- 1 file changed, 71 deletions(-) delete mode 100644 .eslintrc.cjs diff --git a/.eslintrc.cjs b/.eslintrc.cjs deleted file mode 100644 index 34772c9b..00000000 --- a/.eslintrc.cjs +++ /dev/null @@ -1,71 +0,0 @@ -module.exports = { - root: true, - - env: { - node: true, - }, - - extends: [ - // vue/recommended includes all higher levels (vue/strongly-recommended, vue/essential) - 'plugin:vue/vue3-recommended', - '@vue/typescript/recommended', - 'eslint:recommended', - '@vue/eslint-config-typescript', - '@vue/eslint-config-prettier', - // '@vue/prettier/@typescript-eslint', - ], - - parser: 'vue-eslint-parser', - - parserOptions: { - parser: '@typescript-eslint/parser', - sourceType: 'module', - ecmaVersion: 2020, - }, - - rules: { - 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off', - 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off', - 'class-methods-use-this': 0, - // disable eslint no-shadow as it's causing false positives on typescript enums - 'no-shadow': 'off', - 'prettier/prettier': ['error'], - '@typescript-eslint/no-explicit-any': 'warn', - // '@typescript-eslint/naming-convention': [ - // 'error', - // { - // selector: 'default', - // format: ['camelCase'], - // }, - // { - // selector: 'variable', - // format: ['camelCase', 'UPPER_CASE'], - // }, - // { - // selector: 'parameter', - // format: ['camelCase'], - // leadingUnderscore: 'allow', - // }, - // { - // selector: 'memberLike', - // modifiers: ['private'], - // format: ['camelCase'], - // leadingUnderscore: 'require', - // }, - // { - // selector: 'typeLike', - // format: ['PascalCase'], - // }, - // { - // selector: 'class', - // format: ['PascalCase'], - // }, - // ], - }, - - overrides: [ - { - files: ['**/__tests__/*.{j,t}s?(x)', '**/tests/unit/**/*.spec.{j,t}s?(x)'], - }, - ], -}; From 7d9e2d038a3acc492b53e0405f706d6d39e97e1b Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 25 Apr 2024 16:31:34 +0200 Subject: [PATCH 04/12] Remove unused imports --- e2e/login.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/login.spec.ts b/e2e/login.spec.ts index d27f8ffc..bb000b3f 100644 --- a/e2e/login.spec.ts +++ b/e2e/login.spec.ts @@ -1,5 +1,5 @@ import { test, expect } from '@playwright/test'; -import { setLoginInfo, defaultMocks, tradeMocks } from './helpers'; +import { defaultMocks } from './helpers'; test.describe('Login', () => { test('Is not logged in', async ({ page }) => { From f09bfd18aa8686473fbbf01b51f172bcba646ce6 Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 25 Apr 2024 16:39:03 +0200 Subject: [PATCH 05/12] Remove some unused "eslint-ignore" calls --- src/components/ftbot/ExchangeSelect.vue | 10 ++++------ src/components/ftbot/TradeList.vue | 1 - src/env.d.ts | 1 - 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/components/ftbot/ExchangeSelect.vue b/src/components/ftbot/ExchangeSelect.vue index bdf36304..7fa6cbcc 100644 --- a/src/components/ftbot/ExchangeSelect.vue +++ b/src/components/ftbot/ExchangeSelect.vue @@ -56,12 +56,10 @@ const tradeModesTyped = computed(() => { const tradeModes = computed(() => { return tradeModesTyped.value.map((tm) => { - return ( - { - text: `${tm.margin_mode} ${tm.trading_mode}`, - value: tm, - } ?? [] - ); + return { + text: `${tm.margin_mode} ${tm.trading_mode}`, + value: tm, + }; }); }); diff --git a/src/components/ftbot/TradeList.vue b/src/components/ftbot/TradeList.vue index 2dcd696b..49e2167e 100644 --- a/src/components/ftbot/TradeList.vue +++ b/src/components/ftbot/TradeList.vue @@ -93,7 +93,6 @@