Browse Source

eslint 规则修改与对应问题修复

dusenyao 3 years ago
parent
commit
4dc48c7be8

+ 9 - 9
.eslintrc.js

@@ -77,7 +77,7 @@ module.exports = {
     curly: [2, 'multi-line'],
     'dot-location': [2, 'property'],
     'eol-last': 2,
-    eqeqeq: [1, 'always'],
+    eqeqeq: [2, 'always'],
     'generator-star-spacing': [
       2,
       {
@@ -140,13 +140,7 @@ module.exports = {
         defaultAssignment: false
       }
     ],
-    'no-unused-vars': [
-      1,
-      {
-        vars: 'all',
-        args: 'none'
-      }
-    ],
+    'no-unused-vars': [1],
     'no-useless-computed-key': 2,
     'no-useless-constructor': 2,
     'no-whitespace-before-property': 2,
@@ -218,7 +212,11 @@ module.exports = {
     'no-empty': 1,
     'no-eq-null': 2,
     'no-extend-native': 2,
+    'no-multi-assign': 1,
+    'no-negated-condition': 2,
+    'no-duplicate-imports': 2,
     'no-extra-bind': 2,
+    'no-tabs': 2,
     'no-extra-parens': [2, 'functions'],
     'no-floating-decimal': 2,
     'no-implicit-coercion': 1,
@@ -251,6 +249,8 @@ module.exports = {
     'no-useless-call': 2,
     'no-void': 2,
     'no-var': 2,
+    'prefer-rest-params': 2,
+    'prefer-template': 2,
     'no-warning-comments': [
       1,
       {
@@ -264,7 +264,7 @@ module.exports = {
     'consistent-return': 0,
     'default-case': 1,
     'func-names': 1,
-    'func-style': [0, 'declaration'],
+    'func-style': 0,
     'guard-for-in': 0,
     'id-length': 0,
     'init-declarations': 1,

+ 1 - 1
src/api/app.js

@@ -24,7 +24,7 @@ export function GetLanguageList() {
 export function GetWordPack(data) {
   return request({
     method: 'post',
-    url: process.env.VUE_APP_FileServer + '?MethodName=language_manager-GetWordPack',
+    url: `${process.env.VUE_APP_FileServer}?MethodName=language_manager-GetWordPack`,
     data
   });
 }

+ 1 - 1
src/api/user.js

@@ -7,7 +7,7 @@ import { request, getRequestParams } from '@/utils/request';
 export function login(data) {
   return request({
     method: 'post',
-    url: process.env.VUE_APP_FileServer + '?MethodName=login_control-Login',
+    url: `${process.env.VUE_APP_FileServer}?MethodName=login_control-Login`,
     data
   });
 }

+ 1 - 1
src/common/SvgIcon/index.vue

@@ -30,7 +30,7 @@ export default {
     },
     svgClass() {
       if (this.className) {
-        return 'svg-icon ' + this.className;
+        return `svg-icon ${this.className}`;
       }
       return 'svg-icon';
     },

+ 1 - 1
src/layouts/index.vue

@@ -28,7 +28,7 @@ export default {
     }
   },
   created() {
-    window.onerror = (msg, source, lineno, colno, error) => {
+    window.onerror = (msg, source, lineno, colno) => {
       if (msg === 'Script error.' && lineno === 0 && colno === 0) return true;
     };
   }

+ 1 - 1
src/permission.js

@@ -20,7 +20,7 @@ router.beforeEach(async (to, from, next) => {
     } else {
       next();
     }
-  } else if (whiteList.indexOf(to.path) !== -1) {
+  } else if (whiteList.includes(to.path)) {
     // 在登录白名单中,直接进入
     next();
   } else {

+ 7 - 7
src/views/course_details/index.vue

@@ -298,14 +298,19 @@ export default {
         if (type === '1') {
           return str.split('.')[0];
         }
-        return '.' + str.split('.')[1];
+        return `.${str.split('.')[1]}`;
       } else if (type === '1') {
         return str;
       }
     },
     // 收藏
     addOrDeleteMyCollection() {
-      if (!this.collection) {
+      if (this.collection) {
+        CancelMyGoodsCollection({ goods_type: this.goods_type, goods_id_list: [this.CourseData.id] }).then(() => {
+          this.$message.success('取消收藏成功');
+          this.collection = false;
+        });
+      } else {
         let goods_person_name_desc = '';
         this.CourseData.teacher_list.forEach(item => {
           goods_person_name_desc += item.teacher_name;
@@ -322,11 +327,6 @@ export default {
           this.$message.success('收藏课程成功');
           this.collection = true;
         });
-      } else {
-        CancelMyGoodsCollection({ goods_type: this.goods_type, goods_id_list: [this.CourseData.id] }).then(() => {
-          this.$message.success('取消收藏成功');
-          this.collection = false;
-        });
       }
     },
     // 购买   需要先加入课程 审核 审核通过之后才能购买课程

+ 2 - 2
src/views/live/common.js

@@ -46,7 +46,7 @@ export function updateMcResult(stid, pid) {
       console.log('更新上麦结果请求成功,此处可处理应用层逻辑', data);
     },
     fail(data) {
-      console.log('更新上麦结果请求失败:' + JSON.stringify(data));
+      console.log(`更新上麦结果请求失败:${JSON.stringify(data)}`);
     }
   });
 }
@@ -101,7 +101,7 @@ export function createLocalStream(streamName) {
       // 创建本地流失败,应用层处理
       Message({
         type: 'error',
-        message: '创建本地流失败:' + data
+        message: `创建本地流失败:${data}`
       });
     }
   });

+ 1 - 1
src/views/live/student/audit.js

@@ -32,7 +32,7 @@ export function initListener(vue) {
   rtc.on('login_failed', data => {
     console.log('登录失败', data);
     Message({
-      message: '登录失败:' + JSON.stringify(data),
+      message: `登录失败:${JSON.stringify(data)}`,
       type: 'warning'
     });
   });

+ 3 - 6
src/views/live/student/group.js

@@ -49,7 +49,7 @@ function createLocalStream(vue) {
       // 创建本地流失败,应用层处理
       Message({
         type: 'error',
-        message: '创建本地流失败:' + data
+        message: `创建本地流失败:${data}`
       });
     }
   });
@@ -70,7 +70,7 @@ export function initListener(vue) {
   rtc.on('login_failed', data => {
     console.log('登录失败', data);
     Message({
-      message: '登录失败:' + JSON.stringify(data),
+      message: `登录失败:${JSON.stringify(data)}`,
       type: 'warning'
     });
   });
@@ -189,7 +189,7 @@ export function initListener(vue) {
   });
 
   rtc.on('publishStreamErr', data => {
-    console.log('推流意外终止:' + data.streamName);
+    console.log(`推流意外终止:${data.streamName}`);
     // 直播开启状态下,尝试重推这条流
   });
 
@@ -254,7 +254,4 @@ export function initListener(vue) {
     }
     vue.chatList.push(dat);
   });
-
-  // 接收自定义消息
-  rtc.on('publish_message', data => {});
 }

+ 3 - 3
src/views/live/student/live.js

@@ -69,7 +69,7 @@ export function initListener(vue) {
   rtc.on('login_failed', data => {
     console.log('登录失败', data);
     Message({
-      message: '登录失败:' + JSON.stringify(data),
+      message: `登录失败:${JSON.stringify(data)}`,
       type: 'warning'
     });
   });
@@ -207,7 +207,7 @@ export function initListener(vue) {
   });
 
   rtc.on('publishStreamErr', data => {
-    console.log('推流意外终止:' + data.streamName);
+    console.log(`推流意外终止:${data.streamName}`);
     // 直播开启状态下,尝试重推这条流
     publishStream('picture');
   });
@@ -302,7 +302,7 @@ export function initListener(vue) {
           // 创建本地流失败,应用层处理
           Message({
             type: 'error',
-            message: '创建本地流失败:' + data.err
+            message: `创建本地流失败:${data.err}`
           });
         }
       });

+ 3 - 3
src/views/live/teacher/group.js

@@ -38,7 +38,7 @@ function createLocalStream() {
       // 创建本地流失败,应用层处理
       Message({
         type: 'error',
-        message: '创建本地流失败:' + data
+        message: `创建本地流失败:${data}`
       });
     }
   });
@@ -71,7 +71,7 @@ export function initListener(vue) {
   rtc.on('login_failed', data => {
     console.log('登录失败', data);
     Message({
-      message: '登录失败:' + JSON.stringify(data),
+      message: `登录失败:${JSON.stringify(data)}`,
       type: 'warning'
     });
   });
@@ -178,7 +178,7 @@ export function initListener(vue) {
   });
 
   rtc.on('publishStreamErr', data => {
-    console.log('推流意外终止:' + data.streamName);
+    console.log(`推流意外终止:${data.streamName}`);
     // 直播开启状态下,尝试重推这条流
   });
 

+ 2 - 2
src/views/live/teacher/index.vue

@@ -533,7 +533,7 @@ export default {
                 console.log(data, '连麦音视频模式更新请求成功!');
                 this.inviteStudent(uid, student, mode);
               },
-              roomUpdateFailed: data => {
+              roomUpdateFailed: () => {
                 this.callLoading = false;
                 this.$message.error('连麦音视频模式更新请求失败! 请稍后再试!');
               }
@@ -590,7 +590,7 @@ export default {
     handsDown_Live(uid) {
       common.handsDown({
         uid,
-        success: str => {
+        success: () => {
           if (this.callLoading) {
             common.sendPublishMessage({
               type: 'handsDown-load',

+ 4 - 4
src/views/live/teacher/live.js

@@ -62,7 +62,7 @@ export function createLocalStream(vue) {
       // 创建本地流失败,应用层处理
       Message({
         type: 'error',
-        message: '创建本地流失败:' + data.err
+        message: `创建本地流失败:${data.err}`
       });
     }
   });
@@ -100,7 +100,7 @@ export function initListener(vue) {
   rtc.on('login_failed', data => {
     console.log('登录失败', data);
     Message({
-      message: '登录失败:' + JSON.stringify(data),
+      message: `登录失败:${JSON.stringify(data)}`,
       type: 'warning'
     });
   });
@@ -258,7 +258,7 @@ export function initListener(vue) {
   // 推流异常断开事件
   rtc.on('publishStreamErr', data => {
     // 直播开启状态下,尝试重推这条流
-    console.log('推流意外终止:' + data.streamName);
+    console.log(`推流意外终止:${data.streamName}`);
     publishStream('main');
   });
 
@@ -394,7 +394,7 @@ export function stopLive() {
     fail(data) {
       Message({
         type: 'error',
-        message: '结束直播失败:' + JSON.stringify(data)
+        message: `结束直播失败:${JSON.stringify(data)}`
       });
     }
   });

+ 1 - 1
src/views/login/index.vue

@@ -66,7 +66,7 @@ import { getConfigInformation } from '@/utils/index';
 export default {
   data() {
     const validateUsername = (rule, value, callback) => {
-      if (!value) {
+      if (value.length <= 0) {
         callback(new Error(this.$i18n.t('Learn_Login_user_warning')));
       } else {
         callback();

+ 1 - 1
src/views/task_details/ShowCourseware.vue

@@ -69,7 +69,7 @@ export default {
           let offsetWidth = document.querySelector('div.Big-Book-preview').offsetWidth;
           let transform = document.querySelector('div.Big-Book-preview').style.transform;
           document.querySelector('button.full-screen').style.left =
-            offsetWidth * Number(transform.slice(6, -1)) - 130 + 'px';
+            `${offsetWidth * Number(transform.slice(6, -1)) - 130}px`;
         });
         return;
       }

+ 1 - 1
src/views/teacher/create_course/step_table/AddItem.vue

@@ -95,7 +95,7 @@ export default {
   created() {
     for (let i = 0; i < 60; i++) {
       let item = String(i);
-      if (i < 10) item = '0' + item;
+      if (i < 10) item = `0${item}`;
       if (i < 24) this.hourArr.push(item);
       this.minuteArr.push(item);
     }

+ 1 - 1
src/views/teacher/create_course/step_table/NewTask.vue

@@ -251,7 +251,7 @@ export default {
   created() {
     for (let i = 0; i < 60; i++) {
       let item = String(i);
-      if (i < 10) item = '0' + item;
+      if (i < 10) item = `0${item}`;
       if (i < 24) this.hourArr.push(item);
       this.minuteArr.push(item);
     }