From 7cbd70bd36814391d69cf30ad09510fefced7483 Mon Sep 17 00:00:00 2001 From: Johann150 Date: Mon, 4 Jul 2022 16:39:04 +0200 Subject: [PATCH] fix lint no-prototype-builtins --- packages/client/src/components/form-dialog.vue | 2 +- packages/client/src/plugin.ts | 2 +- packages/client/src/scripts/array.ts | 2 +- packages/client/src/widgets/widget.ts | 5 +++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/client/src/components/form-dialog.vue b/packages/client/src/components/form-dialog.vue index 5fd9ec460..f05dde16f 100644 --- a/packages/client/src/components/form-dialog.vue +++ b/packages/client/src/components/form-dialog.vue @@ -98,7 +98,7 @@ export default defineComponent({ created() { for (const item in this.form) { - this.values[item] = this.form[item].hasOwnProperty('default') ? this.form[item].default : null; + this.values[item] = this.form[item].default ?? null; } }, diff --git a/packages/client/src/plugin.ts b/packages/client/src/plugin.ts index ca7b4b73d..de1c95567 100644 --- a/packages/client/src/plugin.ts +++ b/packages/client/src/plugin.ts @@ -38,7 +38,7 @@ export function install(plugin) { function createPluginEnv(opts) { const config = new Map(); for (const [k, v] of Object.entries(opts.plugin.config || {})) { - config.set(k, jsToVal(opts.plugin.configData.hasOwnProperty(k) ? opts.plugin.configData[k] : v.default)); + config.set(k, jsToVal(typeof opts.plugin.configData[k] !== 'undefined' ? opts.plugin.configData[k] : v.default)); } return { diff --git a/packages/client/src/scripts/array.ts b/packages/client/src/scripts/array.ts index 29d027de1..26c6195d6 100644 --- a/packages/client/src/scripts/array.ts +++ b/packages/client/src/scripts/array.ts @@ -98,7 +98,7 @@ export function groupOn(f: (x: T) => S, xs: T[]): T[][] { export function groupByX(collections: T[], keySelector: (x: T) => string) { return collections.reduce((obj: Record, item: T) => { const key = keySelector(item); - if (!obj.hasOwnProperty(key)) { + if (typeof obj[key] === 'undefined') { obj[key] = []; } diff --git a/packages/client/src/widgets/widget.ts b/packages/client/src/widgets/widget.ts index 9626d0161..9fdfe7f3e 100644 --- a/packages/client/src/widgets/widget.ts +++ b/packages/client/src/widgets/widget.ts @@ -36,8 +36,9 @@ export const useWidgetPropsManager = { for (const prop of Object.keys(propsDef)) { - if (widgetProps.hasOwnProperty(prop)) continue; - widgetProps[prop] = propsDef[prop].default; + if (typeof widgetProps[prop] === 'undefined') { + widgetProps[prop] = propsDef[prop].default; + } } }; watch(widgetProps, () => {