From 5600b6c0dc39cc048c841a99c1e928fe9cedd55c Mon Sep 17 00:00:00 2001 From: John Factotum <50942278+johnfactotum@users.noreply.github.com> Date: Tue, 23 Apr 2024 12:59:31 +0800 Subject: [PATCH] Migrate to ESLint 9 and fix linting issues --- .eslintrc.json | 24 ------------------------ eslint.config.js | 22 ++++++++++++++++++++++ mobi.js | 4 ++-- package.json | 37 +++++++++++++++++++++++++++++++++++++ view.js | 5 ----- 5 files changed, 61 insertions(+), 31 deletions(-) delete mode 100644 .eslintrc.json create mode 100644 eslint.config.js create mode 100644 package.json diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index fa2a1b1..0000000 --- a/.eslintrc.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "root": true, - "env": { - "es2022": true, - "browser": true - }, - "parserOptions": { - "ecmaVersion": 2022, - "sourceType": "module" - }, - "extends": "eslint:recommended", - "rules": { - "semi": ["error", "never"], - "indent": ["warn", 4, { "flatTernaryExpressions": true, "SwitchCase": 1 }], - "quotes": ["warn", "single"], - "comma-dangle": ["warn", "always-multiline"], - "no-trailing-spaces": "warn", - "no-unused-vars": "warn", - "no-console": ["warn", { "allow": ["debug", "warn", "error", "assert"] }], - "no-constant-condition": ["error", { "checkLoops": false }], - "no-empty": ["error", { "allowEmptyCatch": true }] - }, - "reportUnusedDisableDirectives": true -} diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 0000000..5a60a62 --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,22 @@ +import js from '@eslint/js' +import globals from 'globals' + +export default [js.configs.recommended, { ignores: ['vendor'] }, { + languageOptions: { + globals: globals.browser, + }, + linterOptions: { + reportUnusedDisableDirectives: true, + }, + rules: { + semi: ['error', 'never'], + indent: ['warn', 4, { flatTernaryExpressions: true, SwitchCase: 1 }], + quotes: ['warn', 'single', { avoidEscape: true }], + 'comma-dangle': ['warn', 'always-multiline'], + 'no-trailing-spaces': 'warn', + 'no-unused-vars': 'warn', + 'no-console': ['warn', { allow: ['debug', 'warn', 'error', 'assert'] }], + 'no-constant-condition': ['error', { checkLoops: false }], + 'no-empty': ['error', { allowEmptyCatch: true }], + }, +}] diff --git a/mobi.js b/mobi.js index 2152025..bc5b988 100644 --- a/mobi.js +++ b/mobi.js @@ -785,7 +785,7 @@ class MOBI6 { const recindex = img.getAttribute('recindex') try { img.src = await this.loadRecindex(recindex) - } catch (e) { + } catch { console.warn(`Failed to load image ${recindex}`) } } @@ -795,7 +795,7 @@ class MOBI6 { try { media.src = await this.loadRecindex(mediarecindex) if (recindex) media.poster = await this.loadRecindex(recindex) - } catch (e) { + } catch { console.warn(`Failed to load media ${mediarecindex}`) } } diff --git a/package.json b/package.json new file mode 100644 index 0000000..ae73441 --- /dev/null +++ b/package.json @@ -0,0 +1,37 @@ +{ + "name": "foliate", + "version": "0.0.0", + "description": "Render e-books in the browser", + "repository": { + "type": "git", + "url": "git+https://github.com/johnfactotum/foliate-js.git" + }, + "bugs": { + "url": "https://github.com/johnfactotum/foliate-js/issues" + }, + "homepage": "https://github.com/johnfactotum/foliate-js#readme", + "author": "John Factotum", + "license": "MIT", + "type": "module", + "exports": { + "./*.js": "./*.js" + }, + "devDependencies": { + "@eslint/js": "^9.1.0", + "globals": "^15.0.0" + }, + "keywords": [ + "ebook", + "reader", + "epub", + "cfi", + "mobi", + "azw", + "azw3", + "fb2", + "cbz", + "dictd", + "stardict", + "opds" + ] +} diff --git a/view.js b/view.js index ab1445d..e236691 100644 --- a/view.js +++ b/view.js @@ -67,11 +67,6 @@ export class View extends HTMLElement { #tocProgress #pageProgress #searchResults = new Map() - #ssml - #speechDoc - #speechRanges - #speechGranularity - #lastSpeechMark isFixedLayout = false lastLocation history = new History()