Merge pull request #1854 from freqtrade/eslint_9.0

use eslint flat config
This commit is contained in:
Matthias 2024-04-26 08:56:12 +02:00 committed by GitHub
commit 8f9f76dcb6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 112 additions and 142 deletions

View File

@ -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)'],
},
],
};

View File

@ -31,7 +31,9 @@ updates:
patterns:
- "eslint"
- "eslint-*"
- "@eslint/*"
- "@typescript-eslint/*"
- "typescript-eslint"
- "@vue/eslint-*"
vue:
patterns:

View File

@ -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 }) => {

36
eslint.config.js Normal file
View File

@ -0,0 +1,36 @@
import { FlatCompat } from '@eslint/eslintrc';
import pluginJs from '@eslint/js';
import pluginVue from 'eslint-plugin-vue';
import globals from 'globals';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import tseslint from 'typescript-eslint';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
});
export default [
{ languageOptions: { globals: globals.browser } },
pluginJs.configs.recommended,
...tseslint.configs.recommended,
...pluginVue.configs['flat/recommended'],
...compat.extends('@vue/eslint-config-typescript/recommended'),
...compat.extends('@vue/eslint-config-prettier'),
{
languageOptions: {
parserOptions: {
parser: '@typescript-eslint/parser',
},
},
rules: {
// // disable eslint no-shadow as it's causing false positives on typescript enums
// 'no-shadow': 'off',
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
},
},
];

View File

@ -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 e2e",
"lint-ci": "eslint --no-fix src tests e2e",
"test:e2e": "yarn playwright test",
"test:e2e-chromium": "yarn playwright test --project=chromium",
"test:e2e-msedge": "yarn playwright test --project=msedge"
@ -34,13 +34,13 @@
"pinia-plugin-persistedstate": "^3.2.1",
"sortablejs": "^1.15.2",
"vue": "^3.4.24",
"vue-class-component": "^7.2.5",
"vue-demi": "^0.14.7",
"vue-echarts": "^6.7.1",
"vue-router": "^4.3.2",
"vue-select": "^4.0.0-beta.6"
},
"devDependencies": {
"@eslint/js": "^9.1.1",
"@iconify-json/mdi": "^1.1.66",
"@playwright/test": "^1.43.1",
"@types/echarts": "^4.9.22",
@ -56,12 +56,14 @@
"eslint": "^8.57.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-vue": "^9.25.0",
"globals": "^15.0.0",
"happy-dom": "^14.7.1",
"mutationobserver-shim": "^0.3.7",
"portal-vue": "^3.0.0",
"prettier": "^3.2.5",
"sass": "^1.75.0",
"typescript": "~5.4.5",
"typescript-eslint": "^7.7.1",
"unplugin-auto-import": "^0.17.5",
"unplugin-icons": "^0.18.5",
"unplugin-vue-components": "^0.26.0",

View File

@ -56,12 +56,10 @@ const tradeModesTyped = computed(() => {
const tradeModes = computed(() => {
return tradeModesTyped.value.map((tm) => {
return (
{
return {
text: `${tm.margin_mode} ${tm.trading_mode}`,
value: tm,
} ?? []
);
};
});
});

View File

@ -93,7 +93,6 @@
</template>
<script setup lang="ts">
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { formatPercent, formatPrice } from '@/shared/formatters';
import { MultiDeletePayload, MultiForcesellPayload, Trade } from '@/types';

View File

@ -22,7 +22,6 @@ const props = defineProps({
},
});
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const modeDescs: { [key in modes]: string } = {
default: 'Current profit',
total: 'Total profit',

1
src/env.d.ts vendored
View File

@ -6,7 +6,6 @@ interface ImportMetaEnv extends Readonly<Record<string, string>> {
readonly DEV: boolean;
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface ImportMeta {
readonly env: ImportMetaEnv;
}

View File

@ -1,4 +1,3 @@
export default function () {
// eslint-disable-next-line no-bitwise
return `#${((Math.random() * 0xffffff) << 0).toString(16)}`;
}

View File

@ -267,7 +267,6 @@ export function createBotSubStore(botId: string, botName: string) {
// Don't use Promise.all - this would fire all requests at once, which can
// cause problems for big sqlite databases
do {
// eslint-disable-next-line no-await-in-loop
const res = await fetchTrades(pageLength, trades.length);
const result: TradeResponse = res.data;

View File

@ -1,15 +0,0 @@
/* eslint-disable max-classes-per-file */
// declare module 'vue-grid-layout' {
// export class GridLayout extends Vue {}
// export class GridItem extends Vue {}
// export interface GridItemData {
// x: number;
// y: number;
// w: number;
// h: number;
// i: string;
// }
// }

View File

@ -52,7 +52,7 @@ const availablePairs = computed<string[]>(() => {
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;
})

103
yarn.lock
View File

@ -275,6 +275,13 @@ __metadata:
languageName: node
linkType: hard
"@eslint/js@npm:^9.1.1":
version: 9.1.1
resolution: "@eslint/js@npm:9.1.1"
checksum: 10/21ade080d2067830e9f32698e16d390487a3994736a784ff14c28189e215291a671f6fc1a5bc12789414adb7c7e5ea2efe470f39e880a0718a78fb8c23447459
languageName: node
linkType: hard
"@floating-ui/core@npm:^1.0.0":
version: 1.6.0
resolution: "@floating-ui/core@npm:1.6.0"
@ -893,6 +900,31 @@ __metadata:
languageName: node
linkType: hard
"@typescript-eslint/eslint-plugin@npm:7.7.1, @typescript-eslint/eslint-plugin@npm:^7.7.1":
version: 7.7.1
resolution: "@typescript-eslint/eslint-plugin@npm:7.7.1"
dependencies:
"@eslint-community/regexpp": "npm:^4.10.0"
"@typescript-eslint/scope-manager": "npm:7.7.1"
"@typescript-eslint/type-utils": "npm:7.7.1"
"@typescript-eslint/utils": "npm:7.7.1"
"@typescript-eslint/visitor-keys": "npm:7.7.1"
debug: "npm:^4.3.4"
graphemer: "npm:^1.4.0"
ignore: "npm:^5.3.1"
natural-compare: "npm:^1.4.0"
semver: "npm:^7.6.0"
ts-api-utils: "npm:^1.3.0"
peerDependencies:
"@typescript-eslint/parser": ^7.0.0
eslint: ^8.56.0
peerDependenciesMeta:
typescript:
optional: true
checksum: 10/54064fe466edcebece50cf4cfc4cb18753bcba7da0e3f0db29bf628586716b14945cadf01529ebc3d823e35bc62debf21aa636ae1f5e4fa92670dce65b3dec8c
languageName: node
linkType: hard
"@typescript-eslint/eslint-plugin@npm:^7.1.1":
version: 7.5.0
resolution: "@typescript-eslint/eslint-plugin@npm:7.5.0"
@ -918,28 +950,21 @@ __metadata:
languageName: node
linkType: hard
"@typescript-eslint/eslint-plugin@npm:^7.7.1":
"@typescript-eslint/parser@npm:7.7.1, @typescript-eslint/parser@npm:^7.7.1":
version: 7.7.1
resolution: "@typescript-eslint/eslint-plugin@npm:7.7.1"
resolution: "@typescript-eslint/parser@npm:7.7.1"
dependencies:
"@eslint-community/regexpp": "npm:^4.10.0"
"@typescript-eslint/scope-manager": "npm:7.7.1"
"@typescript-eslint/type-utils": "npm:7.7.1"
"@typescript-eslint/utils": "npm:7.7.1"
"@typescript-eslint/types": "npm:7.7.1"
"@typescript-eslint/typescript-estree": "npm:7.7.1"
"@typescript-eslint/visitor-keys": "npm:7.7.1"
debug: "npm:^4.3.4"
graphemer: "npm:^1.4.0"
ignore: "npm:^5.3.1"
natural-compare: "npm:^1.4.0"
semver: "npm:^7.6.0"
ts-api-utils: "npm:^1.3.0"
peerDependencies:
"@typescript-eslint/parser": ^7.0.0
eslint: ^8.56.0
peerDependenciesMeta:
typescript:
optional: true
checksum: 10/54064fe466edcebece50cf4cfc4cb18753bcba7da0e3f0db29bf628586716b14945cadf01529ebc3d823e35bc62debf21aa636ae1f5e4fa92670dce65b3dec8c
checksum: 10/39cd5c686e9f7e86da669fc3622b203e1025f162d42c4f45373e827c659b8823535fe4ea62ccb5e672ef999f8491d74c8c5c4c497367c884672fc835497ea180
languageName: node
linkType: hard
@ -961,24 +986,6 @@ __metadata:
languageName: node
linkType: hard
"@typescript-eslint/parser@npm:^7.7.1":
version: 7.7.1
resolution: "@typescript-eslint/parser@npm:7.7.1"
dependencies:
"@typescript-eslint/scope-manager": "npm:7.7.1"
"@typescript-eslint/types": "npm:7.7.1"
"@typescript-eslint/typescript-estree": "npm:7.7.1"
"@typescript-eslint/visitor-keys": "npm:7.7.1"
debug: "npm:^4.3.4"
peerDependencies:
eslint: ^8.56.0
peerDependenciesMeta:
typescript:
optional: true
checksum: 10/39cd5c686e9f7e86da669fc3622b203e1025f162d42c4f45373e827c659b8823535fe4ea62ccb5e672ef999f8491d74c8c5c4c497367c884672fc835497ea180
languageName: node
linkType: hard
"@typescript-eslint/scope-manager@npm:7.5.0":
version: 7.5.0
resolution: "@typescript-eslint/scope-manager@npm:7.5.0"
@ -2631,6 +2638,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "frequi@workspace:."
dependencies:
"@eslint/js": "npm:^9.1.1"
"@iconify-json/mdi": "npm:^1.1.66"
"@noction/vue-draggable-grid": "npm:1.9.16"
"@playwright/test": "npm:^1.43.1"
@ -2659,6 +2667,7 @@ __metadata:
eslint-plugin-prettier: "npm:^5.1.3"
eslint-plugin-vue: "npm:^9.25.0"
favico.js: "npm:^0.3.10"
globals: "npm:^15.0.0"
happy-dom: "npm:^14.7.1"
humanize-duration: "npm:^3.32.0"
mutationobserver-shim: "npm:^0.3.7"
@ -2669,13 +2678,13 @@ __metadata:
sass: "npm:^1.75.0"
sortablejs: "npm:^1.15.2"
typescript: "npm:~5.4.5"
typescript-eslint: "npm:^7.7.1"
unplugin-auto-import: "npm:^0.17.5"
unplugin-icons: "npm:^0.18.5"
unplugin-vue-components: "npm:^0.26.0"
vite: "npm:^5.2.10"
vitest: "npm:^1.5.0"
vue: "npm:^3.4.24"
vue-class-component: "npm:^7.2.5"
vue-demi: "npm:^0.14.7"
vue-echarts: "npm:^6.7.1"
vue-router: "npm:^4.3.2"
@ -2831,6 +2840,13 @@ __metadata:
languageName: node
linkType: hard
"globals@npm:^15.0.0":
version: 15.0.0
resolution: "globals@npm:15.0.0"
checksum: 10/f2f927fe457a5ed2c27b00b77ca22ec31fe5624aac2da178e228a5bcc9928df0f1853e79d6499e04283d184ea13e26cc8127e890098490c9fee616363cdf0d76
languageName: node
linkType: hard
"globby@npm:^11.1.0":
version: 11.1.0
resolution: "globby@npm:11.1.0"
@ -4515,6 +4531,22 @@ __metadata:
languageName: node
linkType: hard
"typescript-eslint@npm:^7.7.1":
version: 7.7.1
resolution: "typescript-eslint@npm:7.7.1"
dependencies:
"@typescript-eslint/eslint-plugin": "npm:7.7.1"
"@typescript-eslint/parser": "npm:7.7.1"
"@typescript-eslint/utils": "npm:7.7.1"
peerDependencies:
eslint: ^8.56.0
peerDependenciesMeta:
typescript:
optional: true
checksum: 10/fd77c7b31b66438164edc2ad3eb79a14f8621162994af04e7e9a8b93a863bfcb25476bb339b8891044b56f7c42355b74ecc4b47e3fb4a848821d14ee38c4af26
languageName: node
linkType: hard
"typescript@npm:~5.4.5":
version: 5.4.5
resolution: "typescript@npm:5.4.5"
@ -4844,15 +4876,6 @@ __metadata:
languageName: node
linkType: hard
"vue-class-component@npm:^7.2.5":
version: 7.2.6
resolution: "vue-class-component@npm:7.2.6"
peerDependencies:
vue: ^2.0.0
checksum: 10/d0ff279fa5d22f15b291fc07cabb116a4a3f748070a478cdd42f73bd9ceb6d46f0dc86bb2bad2ac408d4f11c53290207268d6cfdf3d27039ff34de02adfd5a8f
languageName: node
linkType: hard
"vue-component-type-helpers@npm:^2.0.0":
version: 2.0.10
resolution: "vue-component-type-helpers@npm:2.0.10"