From 61ff5c10137bcf55d8942054064033624312ada4 Mon Sep 17 00:00:00 2001 From: Josh <8677174+bijij@users.noreply.github.com> Date: Tue, 25 Jun 2024 15:14:58 +1000 Subject: [PATCH] Update eslint --- .eslintignore | 2 -- .eslintrc.json | 39 -------------------------------- .github/workflows/main.yml | 5 +---- eslint.config.mjs | 46 ++++++++++++++++++++++++++++++++++++++ js/content-script.js | 10 ++++----- 5 files changed, 52 insertions(+), 50 deletions(-) delete mode 100644 .eslintignore delete mode 100644 .eslintrc.json create mode 100644 eslint.config.mjs diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 76da239..0000000 --- a/.eslintignore +++ /dev/null @@ -1,2 +0,0 @@ -node_modules/* -.eslintrc.json \ No newline at end of file diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index 17821f3..0000000 --- a/.eslintrc.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "env": { - "browser": true, - "es2020": true - }, - "extends": "eslint:recommended", - "globals": { - "chrome": false, - "browser": false - }, - "plugins": [ - "json" - ], - "rules": { - "no-global-assign": [ - "error" - ], - "indent": [ - "error", - 4, - { - "SwitchCase": 1 - } - ], - "linebreak-style": "off", - "quotes": [ - "error", - "single" - ], - "semi": [ - "error", - "always" - ], - "eol-last": "error" - }, - "parserOptions": { - "sourceType": "module" - } -} \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a689f34..32082a3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,9 +2,6 @@ name: CI on: [push, pull_request] -env: - ESLINT_USE_FLAT_CONFIG: false - jobs: build: @@ -16,7 +13,7 @@ jobs: - name: Install Deps run: | - npm install eslint + npm install globals @eslint/js @eslint/eslintrc npm install eslint-plugin-json - name: Lint with ESLint run: | diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 0000000..a33b46c --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,46 @@ +import json from "eslint-plugin-json"; +import globals from "globals"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; +import js from "@eslint/js"; +import { FlatCompat } from "@eslint/eslintrc"; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); +const compat = new FlatCompat({ + baseDirectory: __dirname, + recommendedConfig: js.configs.recommended, + allConfig: js.configs.all +}); + +export default [{ + ignores: ["node_modules/*", "**/eslint.config.mjs"], +}, ...compat.extends("eslint:recommended"), { + plugins: { + json, + }, + + languageOptions: { + globals: { + ...globals.browser, + chrome: false, + browser: false, + }, + + ecmaVersion: 2020, + sourceType: "module", + }, + + rules: { + "no-global-assign": ["error"], + + indent: ["error", 4, { + SwitchCase: 1, + }], + + "linebreak-style": "off", + quotes: ["error", "single"], + semi: ["error", "always"], + "eol-last": "error", + }, +}]; \ No newline at end of file diff --git a/js/content-script.js b/js/content-script.js index 1f5d9da..90a1df9 100644 --- a/js/content-script.js +++ b/js/content-script.js @@ -31,8 +31,8 @@ function getContainer(node) { [ ['.irc_c[style*="visibility: visible;"][style*="transform: translate3d(0px, 0px, 0px);"]', VERSIONS.FEB18], ['.irc_c[data-ved]', VERSIONS.JUL19], - ['.tvh9oe[style*="display: block;"]', VERSIONS.OCT19] - ['.EIehLd[style*="display: block;"]', VERSIONS.OCT19] + ['.tvh9oe[style*="display: block;"]', VERSIONS.OCT19], + ['.EIehLd[style*="display: block;"]', VERSIONS.OCT19], ['.fHE6De[style*="display: block;"]', VERSIONS.OCT19] ].forEach(element => { var child = node.querySelector(element[0]); @@ -202,7 +202,7 @@ function addViewImageButton(container, node, imageURL, version) { console.log('ViewImage: Adding Disabled View-Image button with no URL'); viewImageLink.style = 'pointer-events: none;'; - viewImageLink.title = "No full-sized image was found." + viewImageLink.title = 'No full-sized image was found.'; var viewImageDiv = viewImageLink.querySelector('div'); if (viewImageDiv) { @@ -384,7 +384,7 @@ function parseDataSource(array) { for (var i = 0; i < meta.length; i++) { try { images[meta[i][1][2][0]] = meta[i][1][3][0]; - } catch (error) { + } catch { if (DEBUG) console.log('ViewImage: Skipping image'); } @@ -399,7 +399,7 @@ function parseDataSource(array) { try { var data = Object.values(meta[i][0][0])[0]; images[data[1][2][0]] = data[1][3][0]; - } catch (error) { + } catch { if (DEBUG) console.log('ViewImage: Skipping image'); }