diff --git a/src/webui/www/.eslintrc.json b/src/webui/www/.eslintrc.json deleted file mode 100644 index 69e9d3abf..000000000 --- a/src/webui/www/.eslintrc.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "env": { - "browser": true, - "es2022": true - }, - "extends": [ - "eslint:recommended", - "plugin:@stylistic/disable-legacy" - ], - "plugins": [ - "html", - "@stylistic" - ], - "rules": { - "eqeqeq": "error", - "no-undef": "off", - "no-unused-vars": "off", - "@stylistic/no-mixed-operators": [ - "error", - { - "groups": [ - ["&", "|", "^", "~", "<<", ">>", ">>>", "==", "!=", "===", "!==", ">", ">=", "<", "<=", "&&", "||", "in", "instanceof"] - ] - } - ], - "@stylistic/nonblock-statement-body-position": ["error", "below"], - "@stylistic/semi": "error" - } -} diff --git a/src/webui/www/eslint.config.mjs b/src/webui/www/eslint.config.mjs new file mode 100644 index 000000000..ba6f91a0d --- /dev/null +++ b/src/webui/www/eslint.config.mjs @@ -0,0 +1,44 @@ +import Globals from 'globals'; +import Html from 'eslint-plugin-html'; +import Js from '@eslint/js'; +import Stylistic from '@stylistic/eslint-plugin'; +import * as RegexpPlugin from 'eslint-plugin-regexp'; + +export default [ + Js.configs.recommended, + RegexpPlugin.configs["flat/recommended"], + Stylistic.configs["disable-legacy"], + { + files: [ + "**/*.html", + "**/*.js", + "**/*.mjs" + ], + languageOptions: { + ecmaVersion: 2022, + globals: { + ...Globals.browser + } + }, + plugins: { + Html, + RegexpPlugin, + Stylistic + }, + rules: { + "eqeqeq": "error", + "no-undef": "off", + "no-unused-vars": "off", + "Stylistic/no-mixed-operators": [ + "error", + { + "groups": [ + ["&", "|", "^", "~", "<<", ">>", ">>>", "==", "!=", "===", "!==", ">", ">=", "<", "<=", "&&", "||", "in", "instanceof"] + ] + } + ], + "Stylistic/nonblock-statement-body-position": ["error", "below"], + "Stylistic/semi": "error" + } + } +]; diff --git a/src/webui/www/package.json b/src/webui/www/package.json index 95e8ad9dc..975a90014 100644 --- a/src/webui/www/package.json +++ b/src/webui/www/package.json @@ -12,8 +12,9 @@ }, "devDependencies": { "@stylistic/eslint-plugin": "*", - "eslint": "^8", - "eslint-plugin-html": "^8", + "eslint": "*", + "eslint-plugin-html": "*", + "eslint-plugin-regexp": "*", "html-validate": "*", "i18next-parser": "*", "js-beautify": "*", diff --git a/src/webui/www/private/scripts/client.js b/src/webui/www/private/scripts/client.js index 5b612aeea..496ca43da 100644 --- a/src/webui/www/private/scripts/client.js +++ b/src/webui/www/private/scripts/client.js @@ -1527,8 +1527,8 @@ window.addEventListener("DOMContentLoaded", function() { return lowercaseStr.startsWith("http:") || lowercaseStr.startsWith("https:") || lowercaseStr.startsWith("magnet:") - || ((str.length === 40) && !(/[^0-9A-Fa-f]/.test(str))) // v1 hex-encoded SHA-1 info-hash - || ((str.length === 32) && !(/[^2-7A-Za-z]/.test(str))); // v1 Base32 encoded SHA-1 info-hash + || ((str.length === 40) && !(/[^0-9A-F]/i.test(str))) // v1 hex-encoded SHA-1 info-hash + || ((str.length === 32) && !(/[^2-7A-Z]/i.test(str))); // v1 Base32 encoded SHA-1 info-hash }); if (urls.length <= 0) diff --git a/src/webui/www/private/scripts/misc.js b/src/webui/www/private/scripts/misc.js index 7ca895ae3..529d19e70 100644 --- a/src/webui/www/private/scripts/misc.js +++ b/src/webui/www/private/scripts/misc.js @@ -143,7 +143,7 @@ window.qBittorrent.Misc = (function() { * JS counterpart of the function in src/misc.cpp */ const parseHtmlLinks = function(text) { - const exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#/%?=~_|!:,.;]*[-A-Z0-9+&@#/%=~_|])/ig; + const exp = /(\b(https?|ftp|file):\/\/[-\w+&@#/%?=~|!:,.;]*[-\w+&@#/%=~|])/gi; return text.replace(exp, "$1"); };