From 81a44a02845b48b7281d396bd6136165280caebb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8A=B1=E8=A3=A4=E8=A1=A9?= Date: Wed, 9 Oct 2019 21:12:03 +0800 Subject: [PATCH] perf: fix eslint warning --- src/components/ImageCropper/index.vue | 3 ++- src/store/modules/settings.js | 3 ++- src/store/modules/user.js | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/ImageCropper/index.vue b/src/components/ImageCropper/index.vue index 13ae9a11..7bb33685 100644 --- a/src/components/ImageCropper/index.vue +++ b/src/components/ImageCropper/index.vue @@ -248,7 +248,8 @@ export default { // 浏览器是否支持该控件 isSupported, // 浏览器是否支持触屏事件 - isSupportTouch: document.hasOwnProperty('ontouchstart'), + + isSupportTouch: Object.prototype.hasOwnProperty.call(document, 'ontouchstart'), // 步骤 step: 1, // 1选择文件 2剪裁 3上传 // 上传状态及进度 diff --git a/src/store/modules/settings.js b/src/store/modules/settings.js index e389af79..67bd4160 100644 --- a/src/store/modules/settings.js +++ b/src/store/modules/settings.js @@ -13,7 +13,8 @@ const state = { const mutations = { CHANGE_SETTING: (state, { key, value }) => { - if (state.hasOwnProperty(key)) { + // https://eslint.org/docs/rules/no-prototype-builtins + if (Object.prototype.hasOwnProperty.call(state, key)) { state[key] = value } } diff --git a/src/store/modules/user.js b/src/store/modules/user.js index 1391fa4a..f9d725b8 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -104,6 +104,7 @@ const actions = { // dynamically modify permissions changeRoles({ commit, dispatch }, role) { + // eslint-disable-next-line return new Promise(async resolve => { const token = role + '-token'