From 007278035cda8777d157dfdad65ba0d40358d1e1 Mon Sep 17 00:00:00 2001 From: Winnie Hellmann <31919422+gitlab-winnie@users.noreply.github.com> Date: Wed, 13 Mar 2019 00:11:54 +0100 Subject: [PATCH 01/10] feat: add BOOTSTRAP_VUE_NO_WARN environment variable to hide warnings --- src/utils/warn.js | 4 ++++ src/utils/warn.spec.js | 45 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 src/utils/warn.spec.js diff --git a/src/utils/warn.js b/src/utils/warn.js index f11e9fea515..9c025f51b4d 100644 --- a/src/utils/warn.js +++ b/src/utils/warn.js @@ -4,6 +4,10 @@ */ /* istanbul ignore next */ function warn(message) { + if (process && process.env && process.env.BOOTSTRAP_VUE_NO_WARN) { + return + } + console.warn(`[BootstrapVue warn]: ${message}`) } diff --git a/src/utils/warn.spec.js b/src/utils/warn.spec.js new file mode 100644 index 00000000000..993f5a11c70 --- /dev/null +++ b/src/utils/warn.spec.js @@ -0,0 +1,45 @@ +import warn from './warn' + +describe('utils/warn', () => { + const dummyWarning = 'A Rush Of Blood To The Head' + + let originalProcess + + beforeAll(() => { + jest.spyOn(console, 'warn').mockImplementation(() => {}) + originalProcess = global.process + }) + + afterEach(() => { + console.warn.mockClear() + global.process = originalProcess + }) + + describe('with BOOTSTRAP_VUE_NO_WARN environment variable set', () => { + beforeEach(() => { + global.process = { + env: { + BOOTSTRAP_VUE_NO_WARN: true + } + } + }) + + it('does not call console.warn()', () => { + warn(dummyWarning) + + expect(console.warn).not.toHaveBeenCalled() + }) + }) + + describe('without process object', () => { + beforeEach(() => { + global.process = null + }) + + it('calls console.warn()', () => { + warn(dummyWarning) + + expect(console.warn).toHaveBeenCalledWith(`[BootstrapVue warn]: ${dummyWarning}`) + }) + }) +}) From af41830b13a678ff86325ed2d1bf72e042751119 Mon Sep 17 00:00:00 2001 From: Troy Morehouse Date: Fri, 22 Mar 2019 22:07:10 -0300 Subject: [PATCH 02/10] Update env.js --- src/utils/env.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/utils/env.js b/src/utils/env.js index 5395044e97e..e83e0c83b56 100644 --- a/src/utils/env.js +++ b/src/utils/env.js @@ -8,3 +8,5 @@ export const hasTouchSupport = inBrowser && ('ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0) export const hasPointerEvent = inBrowser && Boolean(window.PointerEvent || window.MSPointerEvent) + +export const noWarn = process && process.env && process.env.BOOTSTRAP_VUE_NO_WARN From a663dbdf4fb0e359253028c225d1c5e4dd371556 Mon Sep 17 00:00:00 2001 From: Troy Morehouse Date: Fri, 22 Mar 2019 22:08:20 -0300 Subject: [PATCH 03/10] Update warn.js --- src/utils/warn.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/utils/warn.js b/src/utils/warn.js index 0381b930c0d..e92360a0c2c 100644 --- a/src/utils/warn.js +++ b/src/utils/warn.js @@ -1,13 +1,14 @@ +import { noWarn } from './env' + /** * Log a warning message to the console with bootstrap-vue formatting sugar. * @param {string} message */ /* istanbul ignore next */ const warn = message => { - if (process && process.env && process.env.BOOTSTRAP_VUE_NO_WARN) { - return + if (!noWarn) { + console.warn(`[BootstrapVue warn]: ${message}`) } - console.warn(`[BootstrapVue warn]: ${message}`) } export default warn From 75eed302dcdf3838fd2269bc0904c283b86b342b Mon Sep 17 00:00:00 2001 From: Troy Morehouse Date: Fri, 22 Mar 2019 22:15:34 -0300 Subject: [PATCH 04/10] Update env.js --- src/utils/env.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/utils/env.js b/src/utils/env.js index e83e0c83b56..800aebba97a 100644 --- a/src/utils/env.js +++ b/src/utils/env.js @@ -1,5 +1,7 @@ // Info about the current environment +// Constants + export const inBrowser = typeof document !== 'undefined' && typeof window !== 'undefined' export const isServer = !inBrowser @@ -9,4 +11,6 @@ export const hasTouchSupport = export const hasPointerEvent = inBrowser && Boolean(window.PointerEvent || window.MSPointerEvent) -export const noWarn = process && process.env && process.env.BOOTSTRAP_VUE_NO_WARN +// Getters + +export const getNoWarn = () => process && process.env && process.env.BOOTSTRAP_VUE_NO_WARN From 59c75bf96d702a254341ee4cfb939e2ba2ec8a66 Mon Sep 17 00:00:00 2001 From: Troy Morehouse Date: Fri, 22 Mar 2019 22:16:36 -0300 Subject: [PATCH 05/10] Update warn.js --- src/utils/warn.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/warn.js b/src/utils/warn.js index e92360a0c2c..53f7f6ddeb9 100644 --- a/src/utils/warn.js +++ b/src/utils/warn.js @@ -1,4 +1,4 @@ -import { noWarn } from './env' +import { getNoWarn } from './env' /** * Log a warning message to the console with bootstrap-vue formatting sugar. @@ -6,7 +6,7 @@ import { noWarn } from './env' */ /* istanbul ignore next */ const warn = message => { - if (!noWarn) { + if (!getNoWarn()) { console.warn(`[BootstrapVue warn]: ${message}`) } } From e851a122eb65f3770541ed2376ad9953f557f984 Mon Sep 17 00:00:00 2001 From: Troy Morehouse Date: Fri, 22 Mar 2019 22:21:52 -0300 Subject: [PATCH 06/10] Create README.md --- docs/markdown/misc/settings/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 docs/markdown/misc/settings/README.md diff --git a/docs/markdown/misc/settings/README.md b/docs/markdown/misc/settings/README.md new file mode 100644 index 00000000000..24e5d316d44 --- /dev/null +++ b/docs/markdown/misc/settings/README.md @@ -0,0 +1,3 @@ +# Miscelaneous settings + +TBD From 1839e3fd8e16d0643178c0c15c9866c4ac1c086f Mon Sep 17 00:00:00 2001 From: Troy Morehouse Date: Fri, 22 Mar 2019 22:22:17 -0300 Subject: [PATCH 07/10] Create meta.json --- docs/markdown/misc/settings/meta.json | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 docs/markdown/misc/settings/meta.json diff --git a/docs/markdown/misc/settings/meta.json b/docs/markdown/misc/settings/meta.json new file mode 100644 index 00000000000..1ed130b5c74 --- /dev/null +++ b/docs/markdown/misc/settings/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Settings" +} From 733944a7bc97395cbab59f73e1835b08542a254c Mon Sep 17 00:00:00 2001 From: Troy Morehouse Date: Fri, 22 Mar 2019 22:30:22 -0300 Subject: [PATCH 08/10] Update README.md --- docs/markdown/misc/settings/README.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/docs/markdown/misc/settings/README.md b/docs/markdown/misc/settings/README.md index 24e5d316d44..98e3f6cbc9d 100644 --- a/docs/markdown/misc/settings/README.md +++ b/docs/markdown/misc/settings/README.md @@ -1,3 +1,19 @@ # Miscelaneous settings -TBD +## Disabling BootstrapVue console warnings + +BootstrapVue will warn (via `console.warn`) when you try and use a depreated prop, or pass +an invalid value to certain props. THese warnings are provided to help you ensure your +application is using the correct props and values. + +Warnings should be corrected before moving your project into production. + +In some cases, you may want to disable these warnings (not recommended). You can do so by +setting the following process envinroment variable: + + + +```js +process.env.BOOTSTRAP_VUE_NO_WARN = true +``` + From 1405f66af2d7b9bdd6a31101c6c203f4ad4f5995 Mon Sep 17 00:00:00 2001 From: Troy Morehouse Date: Fri, 22 Mar 2019 22:42:04 -0300 Subject: [PATCH 09/10] Update README.md --- docs/markdown/misc/settings/README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/markdown/misc/settings/README.md b/docs/markdown/misc/settings/README.md index 98e3f6cbc9d..de8071f1a4a 100644 --- a/docs/markdown/misc/settings/README.md +++ b/docs/markdown/misc/settings/README.md @@ -1,15 +1,15 @@ -# Miscelaneous settings +# Miscellaneous Settings ## Disabling BootstrapVue console warnings BootstrapVue will warn (via `console.warn`) when you try and use a depreated prop, or pass -an invalid value to certain props. THese warnings are provided to help you ensure your +an invalid value to certain props. These warnings are provided to help you ensure that your application is using the correct props and values. -Warnings should be corrected before moving your project into production. +Warnings should be corrected before moving your project into production! In some cases, you may want to disable these warnings (not recommended). You can do so by -setting the following process envinroment variable: +setting the following process envinronment variable: @@ -17,3 +17,5 @@ setting the following process envinroment variable: process.env.BOOTSTRAP_VUE_NO_WARN = true ``` +By ignoring warnings, you may find that your project fails/breaks when using future releases +of bootstrapVue where deprecated props have been removed. From 9f1dd0c7c131d55e07269ab1aeb8c4dbb9109a86 Mon Sep 17 00:00:00 2001 From: Troy Morehouse Date: Fri, 22 Mar 2019 22:42:45 -0300 Subject: [PATCH 10/10] Update README.md --- docs/markdown/misc/settings/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/markdown/misc/settings/README.md b/docs/markdown/misc/settings/README.md index de8071f1a4a..8ddb63f3227 100644 --- a/docs/markdown/misc/settings/README.md +++ b/docs/markdown/misc/settings/README.md @@ -6,8 +6,6 @@ BootstrapVue will warn (via `console.warn`) when you try and use a depreated pro an invalid value to certain props. These warnings are provided to help you ensure that your application is using the correct props and values. -Warnings should be corrected before moving your project into production! - In some cases, you may want to disable these warnings (not recommended). You can do so by setting the following process envinronment variable: @@ -19,3 +17,5 @@ process.env.BOOTSTRAP_VUE_NO_WARN = true By ignoring warnings, you may find that your project fails/breaks when using future releases of bootstrapVue where deprecated props have been removed. + +Warnings should be corrected before moving your project into production!