Explorar o código

improve eslint rule

Michael Wang %!s(int64=3) %!d(string=hai) anos
pai
achega
f8c56e27d5

+ 2 - 2
.eslintrc.js

@@ -28,8 +28,8 @@ module.exports = {
     "prettier",
   ],
   rules: {
-    // 和 $ref let 冲突
-    "prefer-const": "off",
+    // 和 $ref let 冲突, fixed vue@3.2.26
+    // "prefer-const": "off",
     "@typescript-eslint/no-explicit-any": "off",
     "@typescript-eslint/ban-ts-comment": "off",
     "@typescript-eslint/no-unsafe-assignment": "off",

+ 3 - 3
src/api/jsonMark.ts

@@ -36,10 +36,10 @@ export async function getPaper(store: MarkStore) {
     }
   } else {
     const details: OExamPaperJSON = res.data.details;
-    for (let order1 of details) {
-      for (let order2 of order1.questions) {
+    for (const order1 of details) {
+      for (const order2 of order1.questions) {
         if (order2.subQuestions) {
-          for (let order3 of order2.subQuestions) {
+          for (const order3 of order2.subQuestions) {
             const tempQuestion = {
               unionOrder:
                 order1.number + "-" + order2.number + "-" + order3.number,

+ 1 - 1
src/features/mark/use/draggable.ts

@@ -3,7 +3,7 @@ import { onMounted, onUnmounted } from "vue";
 export function dragImage() {
   // grab moving
   let pos = { top: 0, left: 0, x: 0, y: 0 };
-  let dragContainer = $ref<HTMLDivElement>();
+  const dragContainer = $ref<HTMLDivElement>();
   // let isGrabbing = $ref(false);
 
   const mouseDownHandler = function (e: MouseEvent) {

+ 1 - 1
src/features/mark/use/splitPane.ts

@@ -2,7 +2,7 @@ import { onMounted, onUnmounted, watchEffect } from "vue";
 
 export function dragSplitPane() {
   let pos = { y: 0 };
-  let dragSpliter = $ref<HTMLDivElement>();
+  const dragSpliter = $ref<HTMLDivElement>();
   let topPercent = $ref(40);
 
   const mouseDownHandler = function (e: MouseEvent) {

+ 1 - 1
src/plugins/axiosApp.ts

@@ -56,7 +56,7 @@ _axiosApp.interceptors.response.use(
       return Promise.reject(error);
     }
     // 这里是返回状态码不为200时候的错误处理
-    let status = error.response.status;
+    const status = error.response.status;
 
     // 登录失效 跳转登录页面
     if (status == 403 || status == 401) {

+ 5 - 5
src/utils/renderJSON.ts

@@ -13,8 +13,8 @@ let clozeIndex = 0;
 export function renderRichText(body: RichTextJSON, container?: HTMLDivElement) {
   _container = container || document.createElement("div");
   clozeIndex = 0;
-  let sections = body?.sections || [];
-  let nodes = [] as Array<Node>;
+  const sections = body?.sections || [];
+  const nodes = [] as Array<Node>;
   sections.forEach((section) => {
     nodes.push(renderSection(section));
   });
@@ -36,9 +36,9 @@ export function renderRichText(body: RichTextJSON, container?: HTMLDivElement) {
  * @returns {HTMLDivElement} 返回根据 section 渲染好的 HTMLDivElement
  */
 function renderSection(section: RichTextSectionJSON) {
-  let blocks = section.blocks || [];
-  let inline = blocks.length > 1;
-  let node = document.createElement("div");
+  const blocks = section.blocks || [];
+  const inline = blocks.length > 1;
+  const node = document.createElement("div");
   // node.style = "display: flex;";
   blocks.forEach((block) => {
     node.appendChild(renderBlock(block, inline));