From 2ecddf9890bc65dfa0b7b68fad8768c0f18626c4 Mon Sep 17 00:00:00 2001 From: Alexander Drozdov Date: Fri, 19 Feb 2021 17:33:31 +0200 Subject: [PATCH] reenable eslint --- .eslintrc.js | 43 ++++++++++++------- src/assets/data/index.ts | 4 +- src/ipc/types.ts | 2 +- src/main/LogWatcher.ts | 1 + src/main/PoeWindow.ts | 4 +- src/main/poll-clipboard.ts | 2 +- src/main/price-check.ts | 2 +- src/main/shortcuts.ts | 2 +- src/main/tray.ts | 4 +- src/parser/Parser.ts | 4 +- src/parser/modifiers.ts | 6 +-- src/shims-libs.d.ts | 1 + src/web/background/Leagues.ts | 4 +- src/web/background/Prices.ts | 10 ++--- src/web/map-check/MapStatButton.vue | 2 +- src/web/overlay/LoadingAnimation.vue | 4 +- src/web/overlay/OverlayWindow.vue | 4 +- src/web/overlay/WidgetDebug.vue | 4 +- src/web/overlay/WidgetMenu.vue | 4 +- src/web/overlay/interfaces.ts | 16 +++---- .../filters/create-item-filters.ts | 2 +- .../filters/create-stat-filters.ts | 2 +- src/web/price-check/filters/interfaces.ts | 18 ++------ .../filters/pseudo/item-property-unique.ts | 2 +- .../price-check/filters/pseudo/resistances.ts | 2 +- src/web/price-check/filters/pseudo/util.ts | 10 ++--- .../price-check/price-prediction/poeprices.ts | 1 + src/web/price-check/trade/RateLimiter.ts | 13 +++--- src/web/price-check/trade/TradeListing.vue | 2 +- .../price-check/trade/artificial-slowdown.ts | 2 +- src/web/price-check/trade/pathofexile-bulk.ts | 32 +++++++------- .../price-check/trade/pathofexile-trade.ts | 30 ++++++------- src/web/router.ts | 2 + src/web/settings/HotkeyInput.vue | 12 +++--- src/web/ui/Popover.vue | 10 ++--- 35 files changed, 136 insertions(+), 127 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 042057ec..40880cc0 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -4,8 +4,8 @@ module.exports = { node: true }, plugins: [ - '@typescript-eslint', - 'only-warn' + '@typescript-eslint' + // 'only-warn' ], extends: [ 'plugin:vue/base', @@ -14,25 +14,36 @@ module.exports = { rules: { 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off', 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off', + 'quote-props': ['error', 'consistent-as-needed'], + 'no-labels': ['error', { allowLoop: true }], + 'multiline-ternary': 'off', 'no-unused-vars': 'off', '@typescript-eslint/no-unused-vars': ['error'], - // 'spaced-comment': ['error', 'always', { markers: ['#region'], exceptions: ['#endregion'] }], - 'quote-props': ['error', 'consistent-as-needed'], '@typescript-eslint/strict-boolean-expressions': 'off', - // '@typescript-eslint/no-use-before-define': 'off', - // 'vue/no-mutating-props': 'off', - // '@typescript-eslint/member-delimiter-style': 'off', - // '@typescript-eslint/camelcase': 'off', - // '@typescript-eslint/no-inferrable-types': 'off', - // 'vue/no-deprecated-v-on-native-modifier': 'off', - // 'vue/no-deprecated-filter': 'off', - // 'vue/no-deprecated-slot-attribute': 'off', - // 'no-unused-vars': 'off', - '@typescript-eslint/no-non-null-assertion': 'off' + '@typescript-eslint/no-non-null-assertion': 'off', + '@typescript-eslint/explicit-function-return-type': 'off', + '@typescript-eslint/restrict-template-expressions': 'off', + '@typescript-eslint/prefer-nullish-coalescing': 'off', + '@typescript-eslint/prefer-optional-chain': 'off', + '@typescript-eslint/prefer-readonly': 'off', + '@typescript-eslint/no-floating-promises': 'off', + '@typescript-eslint/no-misused-promises': 'off', + // TODO: refactor IPC and enable + '@typescript-eslint/consistent-type-assertions': 'off' }, + overrides: [{ + files: ['src/main/**/*'], + env: { + node: true + } + }, { + files: ['*.ts'], + parserOptions: { + project: './tsconfig.json' + } + }], parserOptions: { parser: '@typescript-eslint/parser', - extraFileExtensions: ['.vue'], - project: './tsconfig.json' + extraFileExtensions: ['.vue'] } } diff --git a/src/assets/data/index.ts b/src/assets/data/index.ts index 9144e002..d9b94a5b 100644 --- a/src/assets/data/index.ts +++ b/src/assets/data/index.ts @@ -1,3 +1,5 @@ +/* eslint-disable @typescript-eslint/no-var-requires */ + import type { TranslationDict } from '@/assets/data/en/client_strings' import type { ClientLogDict } from '@/assets/data/en/client_log' import type { BaseType, DropEntry, Stat, StatMatcher, UniqueItem } from './interfaces' @@ -28,7 +30,7 @@ export let MAP_IMGS: Map export const ITEM_DROP = new Map() -;(async function initData () { /* eslint-disable no-lone-blocks */ +;(function initData () { /* eslint-disable no-lone-blocks */ { CLIENT_STRINGS = (require(`./${Config.store.language}/client_strings`).default) CLIENTLOG_STRINGS = (require(`./${Config.store.language}/client_log`).default) diff --git a/src/ipc/types.ts b/src/ipc/types.ts index 3b6b8a81..58971cd0 100644 --- a/src/ipc/types.ts +++ b/src/ipc/types.ts @@ -47,7 +47,7 @@ interface Widget { wmTitle: string wmWants: 'show' | 'hide' wmZorder: number | 'exclusive' | null - wmFlags: (WidgetWellKnownFlag | string)[] + wmFlags: Array // --------------- [key: string]: any } diff --git a/src/main/LogWatcher.ts b/src/main/LogWatcher.ts index 580533f4..ca0b5b58 100644 --- a/src/main/LogWatcher.ts +++ b/src/main/LogWatcher.ts @@ -11,6 +11,7 @@ const COMMON_PATH = [ 'D:/Program Files (x86)/Steam/steamapps/common/Path of Exile/logs/Client.txt' ] +// eslint-disable-next-line @typescript-eslint/no-extraneous-class export class LogWatcher { static offset = 0 static filePath?: string diff --git a/src/main/PoeWindow.ts b/src/main/PoeWindow.ts index 58d016fe..23566227 100644 --- a/src/main/PoeWindow.ts +++ b/src/main/PoeWindow.ts @@ -1,11 +1,11 @@ -import { Rectangle, BrowserWindow, Point } from 'electron' +import type { Rectangle, BrowserWindow } from 'electron' import { EventEmitter } from 'events' import { logger } from './logger' import { config } from './config' import { overlayWindow as OW, AttachEvent } from 'electron-overlay-window' interface PoeWindowClass { - on(event: 'active-change', listener: (isActive: boolean) => void): this + on: (event: 'active-change', listener: (isActive: boolean) => void) => this } class PoeWindowClass extends EventEmitter { private _isActive: boolean = false diff --git a/src/main/poll-clipboard.ts b/src/main/poll-clipboard.ts index 4ebe69ac..4154dd4f 100644 --- a/src/main/poll-clipboard.ts +++ b/src/main/poll-clipboard.ts @@ -13,7 +13,7 @@ export async function pollClipboard (): Promise { isPollingClipboard = true elapsed = 0 if (clipboardPromise) { - return clipboardPromise + return await clipboardPromise } let textBefore = clipboard.readText() diff --git a/src/main/price-check.ts b/src/main/price-check.ts index 3073662e..6ede7d12 100644 --- a/src/main/price-check.ts +++ b/src/main/price-check.ts @@ -28,7 +28,7 @@ export function showWidget (opts: { const poeBounds = PoeWindow.bounds! activeAreaRect = { - x: getOffsetX(checkPressPosition!, poeBounds), + x: getOffsetX(checkPressPosition, poeBounds), y: poeBounds.y, width: Math.floor(WIDTH_96DPI * DPR * config.get('fontSize')), height: poeBounds.height diff --git a/src/main/shortcuts.ts b/src/main/shortcuts.ts index 8c57e9c8..e2b8a8a9 100644 --- a/src/main/shortcuts.ts +++ b/src/main/shortcuts.ts @@ -184,7 +184,7 @@ export function setupShortcuts () { logger.debug('Keyup', { source: 'shortcuts', key: UiohookToName[e.keycode] || 'unknown' }) }) - uIOhook.on('wheel', async (e) => { + uIOhook.on('wheel', (e) => { if (!e.ctrlKey || !PoeWindow.bounds || !PoeWindow.isActive || !config.get('stashScroll')) return const stashCheckX = PoeWindow.bounds.x + PoeWindow.uiSidebarWidth diff --git a/src/main/tray.ts b/src/main/tray.ts index 091987e0..27498090 100644 --- a/src/main/tray.ts +++ b/src/main/tray.ts @@ -29,12 +29,12 @@ function leaguesMenuItem () { const menuItem = new MenuItem({ label: 'League', - submenu: leagues.map(league => ({ + submenu: leagues.map(league => ({ label: league.id, type: 'checkbox', checked: league.selected, click: () => { selectLeague(league) } - } as MenuItemConstructorOptions)) + })) }) return [menuItem] diff --git a/src/parser/Parser.ts b/src/parser/Parser.ts index 0f9c98bf..5948d8e0 100644 --- a/src/parser/Parser.ts +++ b/src/parser/Parser.ts @@ -20,9 +20,7 @@ type SectionParseResult = typeof SECTION_SKIPPED | typeof PARSER_SKIPPED -interface ParserFn { - (section: string[], item: ParsedItem): SectionParseResult -} +type ParserFn = (section: string[], item: ParsedItem) => SectionParseResult const parsers: ParserFn[] = [ parseUnidentified, diff --git a/src/parser/modifiers.ts b/src/parser/modifiers.ts index e69bcf33..55b3d86b 100644 --- a/src/parser/modifiers.ts +++ b/src/parser/modifiers.ts @@ -11,9 +11,9 @@ export enum ModifierType { Fractured = 'fractured' } -export interface ItemModifier extends Stat, - Pick -{ +export interface ItemModifier extends + Stat, + Pick { values?: number[] type: ModifierType } diff --git a/src/shims-libs.d.ts b/src/shims-libs.d.ts index f9921adb..3108c6f3 100644 --- a/src/shims-libs.d.ts +++ b/src/shims-libs.d.ts @@ -10,4 +10,5 @@ declare module '*.json' { export default value } +// eslint-disable-next-line @typescript-eslint/naming-convention declare const __static: string diff --git a/src/web/background/Leagues.ts b/src/web/background/Leagues.ts index 7272dbc2..991b7c2f 100644 --- a/src/web/background/Leagues.ts +++ b/src/web/background/Leagues.ts @@ -40,10 +40,10 @@ export async function load () { } } - MainProcess.sendLeaguesReady(tradeLeagues.value.map(league => ({ + MainProcess.sendLeaguesReady(tradeLeagues.value.map(league => ({ id: league.id, selected: league.id === selected.value - } as League))) + }))) } catch (e) { error.value = e.message } finally { diff --git a/src/web/background/Prices.ts b/src/web/background/Prices.ts index 78df9095..69b0854c 100644 --- a/src/web/background/Prices.ts +++ b/src/web/background/Prices.ts @@ -38,7 +38,7 @@ interface NinjaItemInfo { artFilename: null links: number itemClass: number - sparkline: { data: number[], totalChange: number } + sparkline: { data: Array, totalChange: number } lowConfidenceSparkline: { data: number[], totalChange: number[] } implicitModifiers: [] explicitModifiers: Array<{ text: string, optional: boolean }> @@ -131,10 +131,10 @@ async function load (force: boolean = false) { name: currency.currencyTypeName, receive: { chaosValue: currency.receive.value, - graphPoints: currency.receiveSparkLine.data.filter(d => d != null), + graphPoints: currency.receiveSparkLine.data.filter((point): point is number => point != null), totalChange: currency.receiveSparkLine.totalChange } - } as ItemInfo) + }) if (currency.detailsId === 'exalted-orb') { chaosExaRate.value = currency.receive.value @@ -155,10 +155,10 @@ async function load (force: boolean = false) { name: item.name, receive: { chaosValue: item.chaosValue, - graphPoints: item.sparkline.data.filter(d => d != null), + graphPoints: item.sparkline.data.filter((point): point is number => point != null), totalChange: item.sparkline.totalChange } - } as ItemInfo) + }) } } diff --git a/src/web/map-check/MapStatButton.vue b/src/web/map-check/MapStatButton.vue index 43c162d6..553e86fc 100644 --- a/src/web/map-check/MapStatButton.vue +++ b/src/web/map-check/MapStatButton.vue @@ -24,7 +24,7 @@