diff --git a/.eslintrc.yaml b/.eslintrc.yaml index db85b143dd..a4967d170e 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -656,6 +656,7 @@ rules: unicorn/catch-error-name: [0] unicorn/consistent-destructuring: [2] unicorn/consistent-empty-array-spread: [2] + unicorn/consistent-existence-index-check: [2] unicorn/consistent-function-scoping: [2] unicorn/custom-error-definition: [0] unicorn/empty-brace-spaces: [2] @@ -732,10 +733,12 @@ rules: unicorn/prefer-dom-node-text-content: [2] unicorn/prefer-event-target: [2] unicorn/prefer-export-from: [0] + unicorn/prefer-global-this: [0] unicorn/prefer-includes: [2] unicorn/prefer-json-parse-buffer: [0] unicorn/prefer-keyboard-event-key: [2] unicorn/prefer-logical-operator-over-ternary: [2] + unicorn/prefer-math-min-max: [2] unicorn/prefer-math-trunc: [2] unicorn/prefer-modern-dom-apis: [0] unicorn/prefer-modern-math-apis: [2] diff --git a/package-lock.json b/package-lock.json index da97fed7e4..1887edf456 100644 --- a/package-lock.json +++ b/package-lock.json @@ -79,7 +79,7 @@ "eslint-plugin-playwright": "1.6.2", "eslint-plugin-regexp": "2.6.0", "eslint-plugin-sonarjs": "2.0.3", - "eslint-plugin-unicorn": "55.0.0", + "eslint-plugin-unicorn": "56.0.0", "eslint-plugin-vitest-globals": "1.5.0", "eslint-plugin-vue": "9.28.0", "eslint-plugin-vue-scoped-css": "2.8.1", @@ -9174,19 +9174,19 @@ } }, "node_modules/eslint-plugin-unicorn": { - "version": "55.0.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-unicorn/-/eslint-plugin-unicorn-55.0.0.tgz", - "integrity": "sha512-n3AKiVpY2/uDcGrS3+QsYDkjPfaOrNrsfQxU9nt5nitd9KuvVXrfAvgCO9DYPSfap+Gqjw9EOrXIsBp5tlHZjA==", + "version": "56.0.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-unicorn/-/eslint-plugin-unicorn-56.0.0.tgz", + "integrity": "sha512-aXpddVz/PQMmd69uxO98PA4iidiVNvA0xOtbpUoz1WhBd4RxOQQYqN618v68drY0hmy5uU2jy1bheKEVWBjlPw==", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-validator-identifier": "^7.24.5", + "@babel/helper-validator-identifier": "^7.24.7", "@eslint-community/eslint-utils": "^4.4.0", "ci-info": "^4.0.0", "clean-regexp": "^1.0.0", - "core-js-compat": "^3.37.0", - "esquery": "^1.5.0", - "globals": "^15.7.0", + "core-js-compat": "^3.38.1", + "esquery": "^1.6.0", + "globals": "^15.9.0", "indent-string": "^4.0.0", "is-builtin-module": "^3.2.1", "jsesc": "^3.0.2", @@ -9194,7 +9194,7 @@ "read-pkg-up": "^7.0.1", "regexp-tree": "^0.1.27", "regjsparser": "^0.10.0", - "semver": "^7.6.1", + "semver": "^7.6.3", "strip-indent": "^3.0.0" }, "engines": { diff --git a/package.json b/package.json index 3dbc100b68..5054b073e1 100644 --- a/package.json +++ b/package.json @@ -78,7 +78,7 @@ "eslint-plugin-playwright": "1.6.2", "eslint-plugin-regexp": "2.6.0", "eslint-plugin-sonarjs": "2.0.3", - "eslint-plugin-unicorn": "55.0.0", + "eslint-plugin-unicorn": "56.0.0", "eslint-plugin-vitest-globals": "1.5.0", "eslint-plugin-vue": "9.28.0", "eslint-plugin-vue-scoped-css": "2.8.1", diff --git a/web_src/js/features/comp/ComboMarkdownEditor.js b/web_src/js/features/comp/ComboMarkdownEditor.js index 70e92de0c9..65ca7db882 100644 --- a/web_src/js/features/comp/ComboMarkdownEditor.js +++ b/web_src/js/features/comp/ComboMarkdownEditor.js @@ -363,7 +363,7 @@ class ComboMarkdownEditor { const lineStart = Math.max(0, value.lastIndexOf('\n', start - 1) + 1); // Find the end and extract the line. const lineEnd = value.indexOf('\n', start); - const line = value.slice(lineStart, lineEnd < 0 ? value.length : lineEnd); + const line = value.slice(lineStart, lineEnd === -1 ? value.length : lineEnd); // Match any whitespace at the start + any repeatable prefix + exactly one space after. const prefix = line.match(/^\s*((\d+)[.)]\s|[-*+]\s+(\[[ x]\]\s?)?|(>\s+)+)?/); diff --git a/web_src/js/features/eventsource.sharedworker.js b/web_src/js/features/eventsource.sharedworker.js index 62581cf687..15d028ea0c 100644 --- a/web_src/js/features/eventsource.sharedworker.js +++ b/web_src/js/features/eventsource.sharedworker.js @@ -28,7 +28,7 @@ class Source { deregister(port) { const portIdx = this.clients.indexOf(port); - if (portIdx < 0) { + if (portIdx === -1) { return this.clients.length; } this.clients.splice(portIdx, 1); diff --git a/web_src/js/utils.js b/web_src/js/utils.js index ce0fb66343..8805b702c8 100644 --- a/web_src/js/utils.js +++ b/web_src/js/utils.js @@ -3,13 +3,13 @@ import {encode, decode} from 'uint8-to-base64'; // transform /path/to/file.ext to file.ext export function basename(path = '') { const lastSlashIndex = path.lastIndexOf('/'); - return lastSlashIndex < 0 ? path : path.substring(lastSlashIndex + 1); + return lastSlashIndex === -1 ? path : path.substring(lastSlashIndex + 1); } // transform /path/to/file.ext to .ext export function extname(path = '') { const lastPointIndex = path.lastIndexOf('.'); - return lastPointIndex < 0 ? '' : path.substring(lastPointIndex); + return lastPointIndex === -1 ? '' : path.substring(lastPointIndex); } // test whether a variable is an object diff --git a/web_src/js/utils/dom.js b/web_src/js/utils/dom.js index 44adc795c5..54f7335186 100644 --- a/web_src/js/utils/dom.js +++ b/web_src/js/utils/dom.js @@ -155,7 +155,7 @@ export function autosize(textarea, {viewportMarginBottom = 0} = {}) { const isBorderBox = computedStyle.boxSizing === 'border-box'; const borderAddOn = isBorderBox ? topBorderWidth + bottomBorderWidth : 0; - const adjustedViewportMarginBottom = bottom < viewportMarginBottom ? bottom : viewportMarginBottom; + const adjustedViewportMarginBottom = Math.min(bottom, viewportMarginBottom); const curHeight = parseFloat(computedStyle.height); const maxHeight = curHeight + bottom - adjustedViewportMarginBottom;