]> source.dussan.org Git - gitea.git/commitdiff
Add two eslint plugins (#24776)
authorsilverwind <me@silverwind.io>
Thu, 18 May 2023 01:14:31 +0000 (03:14 +0200)
committerGitHub <noreply@github.com>
Thu, 18 May 2023 01:14:31 +0000 (09:14 +0800)
Add these two plugins and autofix issues:

-
[eslint-plugin-no-use-extend-native](https://github.com/dustinspecker/eslint-plugin-no-use-extend-native)
-
[eslint-plugin-array-func](https://github.com/freaktechnik/eslint-plugin-array-func)

.eslintrc.yaml
package-lock.json
package.json
web_src/js/features/copycontent.js
web_src/js/features/repo-projects.js
web_src/js/utils/match.js

index fd1b6da2c0cd5606d2c1e2dc55989252e0d67b1b..f4b1e675346360d3b92b89510f1f74f2bea8b091 100644 (file)
@@ -10,10 +10,12 @@ parserOptions:
 
 plugins:
   - "@eslint-community/eslint-plugin-eslint-comments"
+  - eslint-plugin-array-func
   - eslint-plugin-custom-elements
   - eslint-plugin-import
   - eslint-plugin-jquery
   - eslint-plugin-no-jquery
+  - eslint-plugin-no-use-extend-native
   - eslint-plugin-regexp
   - eslint-plugin-sonarjs
   - eslint-plugin-unicorn
@@ -59,6 +61,12 @@ rules:
   array-bracket-spacing: [2, never]
   array-callback-return: [2, {checkForEach: true}]
   array-element-newline: [0]
+  array-func/avoid-reverse: [2]
+  array-func/from-map: [2]
+  array-func/no-unnecessary-this-arg: [2]
+  array-func/prefer-array-from: [2]
+  array-func/prefer-flat-map: [0] # handled by unicorn/prefer-array-flat-map
+  array-func/prefer-flat: [0] # handled by unicorn/prefer-array-flat
   arrow-body-style: [0]
   arrow-parens: [2, always]
   arrow-spacing: [2, {before: true, after: true}]
@@ -444,6 +452,7 @@ rules:
   no-unused-private-class-members: [2]
   no-unused-vars: [2, {args: all, argsIgnorePattern: ^_, varsIgnorePattern: ^_, caughtErrorsIgnorePattern: ^_, destructuredArrayIgnorePattern: ^_, ignoreRestSiblings: false}]
   no-use-before-define: [2, {functions: false, classes: true, variables: true, allowNamedExports: true}]
+  no-use-extend-native/no-use-extend-native: [2]
   no-useless-backreference: [2]
   no-useless-call: [2]
   no-useless-catch: [2]
index 7f30fe5ebc7bd56259d496cb044441572c0e66bc..c9d4bca3d771f6339f1b775cb7acf8f4397d746b 100644 (file)
         "@stoplight/spectral-cli": "6.6.0",
         "@vitejs/plugin-vue": "4.2.3",
         "eslint": "8.40.0",
+        "eslint-plugin-array-func": "3.1.8",
         "eslint-plugin-custom-elements": "0.0.8",
         "eslint-plugin-import": "2.27.5",
         "eslint-plugin-jquery": "1.5.1",
         "eslint-plugin-no-jquery": "2.7.0",
+        "eslint-plugin-no-use-extend-native": "0.5.0",
         "eslint-plugin-regexp": "1.15.0",
         "eslint-plugin-sonarjs": "0.19.0",
         "eslint-plugin-unicorn": "47.0.0",
         "ms": "^2.1.1"
       }
     },
+    "node_modules/eslint-plugin-array-func": {
+      "version": "3.1.8",
+      "resolved": "https://registry.npmjs.org/eslint-plugin-array-func/-/eslint-plugin-array-func-3.1.8.tgz",
+      "integrity": "sha512-BjnbJvw+knaHgVddIL3q5xYcoqAZoK8wOdT7QF+mkvSAjXdZCdhL0z71Y7oRtgXA8BpN9QLJ2uHgD3I6ymlbOw==",
+      "dev": true,
+      "engines": {
+        "node": ">= 6.8.0"
+      },
+      "peerDependencies": {
+        "eslint": ">=3.0.0"
+      }
+    },
     "node_modules/eslint-plugin-custom-elements": {
       "version": "0.0.8",
       "resolved": "https://registry.npmjs.org/eslint-plugin-custom-elements/-/eslint-plugin-custom-elements-0.0.8.tgz",
         "eslint": ">=2.3.0"
       }
     },
+    "node_modules/eslint-plugin-no-use-extend-native": {
+      "version": "0.5.0",
+      "resolved": "https://registry.npmjs.org/eslint-plugin-no-use-extend-native/-/eslint-plugin-no-use-extend-native-0.5.0.tgz",
+      "integrity": "sha512-dBNjs8hor8rJgeXLH4HTut5eD3RGWf9JUsadIfuL7UosVQ/dnvOKwxEcRrXrFxrMZ8llUVWT+hOimxJABsAUzQ==",
+      "dev": true,
+      "dependencies": {
+        "is-get-set-prop": "^1.0.0",
+        "is-js-type": "^2.0.0",
+        "is-obj-prop": "^1.0.0",
+        "is-proto-prop": "^2.0.0"
+      },
+      "engines": {
+        "node": ">=6.0.0"
+      }
+    },
     "node_modules/eslint-plugin-regexp": {
       "version": "1.15.0",
       "resolved": "https://registry.npmjs.org/eslint-plugin-regexp/-/eslint-plugin-regexp-1.15.0.tgz",
         "url": "https://github.com/sponsors/ljharb"
       }
     },
+    "node_modules/get-set-props": {
+      "version": "0.1.0",
+      "resolved": "https://registry.npmjs.org/get-set-props/-/get-set-props-0.1.0.tgz",
+      "integrity": "sha512-7oKuKzAGKj0ag+eWZwcGw2fjiZ78tXnXQoBgY0aU7ZOxTu4bB7hSuQSDgtKy978EDH062P5FmD2EWiDpQS9K9Q==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
     "node_modules/get-source": {
       "version": "2.0.12",
       "resolved": "https://registry.npmjs.org/get-source/-/get-source-2.0.12.tgz",
         "node": ">=8"
       }
     },
+    "node_modules/is-get-set-prop": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/is-get-set-prop/-/is-get-set-prop-1.0.0.tgz",
+      "integrity": "sha512-DvAYZ1ZgGUz4lzxKMPYlt08qAUqyG9ckSg2pIjfvcQ7+pkVNUHk8yVLXOnCLe5WKXhLop8oorWFBJHpwWQpszQ==",
+      "dev": true,
+      "dependencies": {
+        "get-set-props": "^0.1.0",
+        "lowercase-keys": "^1.0.0"
+      }
+    },
     "node_modules/is-glob": {
       "version": "4.0.3",
       "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz",
         "node": ">=0.10.0"
       }
     },
+    "node_modules/is-js-type": {
+      "version": "2.0.0",
+      "resolved": "https://registry.npmjs.org/is-js-type/-/is-js-type-2.0.0.tgz",
+      "integrity": "sha512-Aj13l47+uyTjlQNHtXBV8Cji3jb037vxwMWCgopRR8h6xocgBGW3qG8qGlIOEmbXQtkKShKuBM9e8AA1OeQ+xw==",
+      "dev": true,
+      "dependencies": {
+        "js-types": "^1.0.0"
+      }
+    },
     "node_modules/is-negative-zero": {
       "version": "2.0.2",
       "resolved": "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.2.tgz",
         "url": "https://github.com/sponsors/ljharb"
       }
     },
+    "node_modules/is-obj-prop": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/is-obj-prop/-/is-obj-prop-1.0.0.tgz",
+      "integrity": "sha512-5Idb61slRlJlsAzi0Wsfwbp+zZY+9LXKUAZpvT/1ySw+NxKLRWfa0Bzj+wXI3fX5O9hiddm5c3DAaRSNP/yl2w==",
+      "dev": true,
+      "dependencies": {
+        "lowercase-keys": "^1.0.0",
+        "obj-props": "^1.0.0"
+      }
+    },
     "node_modules/is-path-inside": {
       "version": "3.0.3",
       "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz",
       "integrity": "sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ==",
       "dev": true
     },
+    "node_modules/is-proto-prop": {
+      "version": "2.0.0",
+      "resolved": "https://registry.npmjs.org/is-proto-prop/-/is-proto-prop-2.0.0.tgz",
+      "integrity": "sha512-jl3NbQ/fGLv5Jhan4uX+Ge9ohnemqyblWVVCpAvtTQzNFvV2xhJq+esnkIbYQ9F1nITXoLfDDQLp7LBw/zzncg==",
+      "dev": true,
+      "dependencies": {
+        "lowercase-keys": "^1.0.0",
+        "proto-props": "^2.0.0"
+      }
+    },
     "node_modules/is-reference": {
       "version": "1.2.1",
       "resolved": "https://registry.npmjs.org/is-reference/-/is-reference-1.2.1.tgz",
       "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
       "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ=="
     },
+    "node_modules/js-types": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/js-types/-/js-types-1.0.0.tgz",
+      "integrity": "sha512-bfwqBW9cC/Lp7xcRpug7YrXm0IVw+T9e3g4mCYnv0Pjr3zIzU9PCQElYU9oSGAWzXlbdl9X5SAMPejO9sxkeUw==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
     "node_modules/js-yaml": {
       "version": "4.1.0",
       "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz",
         "get-func-name": "^2.0.0"
       }
     },
+    "node_modules/lowercase-keys": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-1.0.1.tgz",
+      "integrity": "sha512-G2Lj61tXDnVFFOi8VZds+SoQjtQC3dgokKdDG2mTm1tx4m50NUHBOZSBwQQHyy0V12A0JTG4icfZQH+xPyh8VA==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
     "node_modules/lru-cache": {
       "version": "5.1.1",
       "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz",
       "integrity": "sha512-NHj4rzRo0tQdijE9ZqAx6kYDcoRwYwSYzCA8MY3JzfxlrvEU0jhnhJT9BhqhJs7I/dKcrDm6TyulaRqZPIhN5g==",
       "dev": true
     },
+    "node_modules/obj-props": {
+      "version": "1.4.0",
+      "resolved": "https://registry.npmjs.org/obj-props/-/obj-props-1.4.0.tgz",
+      "integrity": "sha512-p7p/7ltzPDiBs6DqxOrIbtRdwxxVRBj5ROukeNb9RgA+fawhrz5n2hpNz8DDmYR//tviJSj7nUnlppGmONkjiQ==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
     "node_modules/object-assign": {
       "version": "4.1.1",
       "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
         "react-is": "^16.13.1"
       }
     },
+    "node_modules/proto-props": {
+      "version": "2.0.0",
+      "resolved": "https://registry.npmjs.org/proto-props/-/proto-props-2.0.0.tgz",
+      "integrity": "sha512-2yma2tog9VaRZY2mn3Wq51uiSW4NcPYT1cQdBagwyrznrilKSZwIZ0UG3ZPL/mx+axEns0hE35T5ufOYZXEnBQ==",
+      "dev": true,
+      "engines": {
+        "node": ">=4"
+      }
+    },
     "node_modules/proxy-agent": {
       "version": "5.0.0",
       "resolved": "https://registry.npmjs.org/proxy-agent/-/proxy-agent-5.0.0.tgz",
index 6ec0d755dcb195bb4705b1916c841781f65e8672..179f0beb2d63341418c81863755c2064af72c489 100644 (file)
     "@stoplight/spectral-cli": "6.6.0",
     "@vitejs/plugin-vue": "4.2.3",
     "eslint": "8.40.0",
+    "eslint-plugin-array-func": "3.1.8",
     "eslint-plugin-custom-elements": "0.0.8",
     "eslint-plugin-import": "2.27.5",
     "eslint-plugin-jquery": "1.5.1",
     "eslint-plugin-no-jquery": "2.7.0",
+    "eslint-plugin-no-use-extend-native": "0.5.0",
     "eslint-plugin-regexp": "1.15.0",
     "eslint-plugin-sonarjs": "0.19.0",
     "eslint-plugin-unicorn": "47.0.0",
index 646fafeb0f4ebb92651d819b9dd574004d98c1ee..621d6dab73c4356a5c9f31f4b090c4f7e4279b39 100644 (file)
@@ -36,7 +36,7 @@ export function initCopyContent() {
       }
     } else { // text, read from DOM
       const lineEls = document.querySelectorAll('.file-view .lines-code');
-      content = Array.from(lineEls).map((el) => el.textContent).join('');
+      content = Array.from(lineEls(el) => el.textContent).join('');
     }
 
     // try copy original first, if that fails and it's an image, convert it to png
index abbe23458e144115059ceca567da0e0c3e8c1458..b8cb651f69df8e86426cd9e3d18f0ffca0dd2c6a 100644 (file)
@@ -15,7 +15,7 @@ function moveIssue({item, from, to, oldIndex}) {
   updateIssueCount(to);
 
   const columnSorting = {
-    issues: [...columnCards].map((card, i) => ({
+    issues: Array.from(columnCards, (card, i) => ({
       issueID: parseInt($(card).attr('data-issue')),
       sorting: i
     }))
index 0d20ca336fe4319b022eba4b5bcdc9d13b56fc0a..31763b0940cf2bf0e2914a95410466bd9a967f0d 100644 (file)
@@ -3,7 +3,7 @@ import emojis from '../../../assets/emoji.json';
 const maxMatches = 6;
 
 function sortAndReduce(map) {
-  const sortedMap = new Map([...map.entries()].sort((a, b) => a[1] - b[1]));
+  const sortedMap = new Map(Array.from(map.entries()).sort((a, b) => a[1] - b[1]));
   return Array.from(sortedMap.keys()).slice(0, maxMatches);
 }