@wordpress/deprecated
Advanced tools
Comparing version 2.12.0 to 2.12.1-next.5c9849e156.0
@@ -18,2 +18,3 @@ /** | ||
* @param {Object} [options] Personalisation options | ||
* @param {string} [options.since] Version in which the feature was deprecated. | ||
* @param {string} [options.version] Version in which the feature will be removed. | ||
@@ -30,3 +31,4 @@ * @param {string} [options.alternative] Feature to use instead | ||
* deprecated( 'Eating meat', { | ||
* version: 'the future', | ||
* since: '2019.01.01' | ||
* version: '2020.01.01', | ||
* alternative: 'vegetables', | ||
@@ -37,3 +39,3 @@ * plugin: 'the earth', | ||
* | ||
* // Logs: 'Eating meat is deprecated and will be removed from the earth in the future. Please use vegetables instead. Note: You may find it beneficial to transition gradually.' | ||
* // Logs: 'Eating meat is deprecated since version 2019.01.01 and will be removed from the earth in version 2020.01.01. Please use vegetables instead. Note: You may find it beneficial to transition gradually.' | ||
* ``` | ||
@@ -44,3 +46,4 @@ */ | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var version = options.version, | ||
var since = options.since, | ||
version = options.version, | ||
alternative = options.alternative, | ||
@@ -51,2 +54,3 @@ plugin = options.plugin, | ||
var pluginMessage = plugin ? " from ".concat(plugin) : ''; | ||
var sinceMessage = since ? " since version ".concat(since) : ''; | ||
var versionMessage = version ? " and will be removed".concat(pluginMessage, " in version ").concat(version) : ''; | ||
@@ -56,3 +60,3 @@ var useInsteadMessage = alternative ? " Please use ".concat(alternative, " instead.") : ''; | ||
var hintMessage = hint ? " Note: ".concat(hint) : ''; | ||
var message = "".concat(feature, " is deprecated").concat(versionMessage, ".").concat(useInsteadMessage).concat(linkMessage).concat(hintMessage); // Skip if already logged. | ||
var message = "".concat(feature, " is deprecated").concat(sinceMessage).concat(versionMessage, ".").concat(useInsteadMessage).concat(linkMessage).concat(hintMessage); // Skip if already logged. | ||
@@ -67,2 +71,3 @@ if (message in logged) { | ||
* @param {?Object} options Personalisation options | ||
* @param {string} options.since Version in which the feature was deprecated. | ||
* @param {?string} options.version Version in which the feature will be removed. | ||
@@ -69,0 +74,0 @@ * @param {?string} options.alternative Feature to use instead |
@@ -6,2 +6,3 @@ /** | ||
* @param {Object} [options] Personalisation options | ||
* @param {string} [options.since] Version in which the feature was deprecated. | ||
* @param {string} [options.version] Version in which the feature will be removed. | ||
@@ -18,3 +19,4 @@ * @param {string} [options.alternative] Feature to use instead | ||
* deprecated( 'Eating meat', { | ||
* version: 'the future', | ||
* since: '2019.01.01' | ||
* version: '2020.01.01', | ||
* alternative: 'vegetables', | ||
@@ -25,6 +27,7 @@ * plugin: 'the earth', | ||
* | ||
* // Logs: 'Eating meat is deprecated and will be removed from the earth in the future. Please use vegetables instead. Note: You may find it beneficial to transition gradually.' | ||
* // Logs: 'Eating meat is deprecated since version 2019.01.01 and will be removed from the earth in version 2020.01.01. Please use vegetables instead. Note: You may find it beneficial to transition gradually.' | ||
* ``` | ||
*/ | ||
export default function deprecated(feature: string, options?: { | ||
since?: string | undefined; | ||
version?: string | undefined; | ||
@@ -31,0 +34,0 @@ alternative?: string | undefined; |
@@ -27,2 +27,3 @@ "use strict"; | ||
* @param {Object} [options] Personalisation options | ||
* @param {string} [options.since] Version in which the feature was deprecated. | ||
* @param {string} [options.version] Version in which the feature will be removed. | ||
@@ -39,3 +40,4 @@ * @param {string} [options.alternative] Feature to use instead | ||
* deprecated( 'Eating meat', { | ||
* version: 'the future', | ||
* since: '2019.01.01' | ||
* version: '2020.01.01', | ||
* alternative: 'vegetables', | ||
@@ -46,3 +48,3 @@ * plugin: 'the earth', | ||
* | ||
* // Logs: 'Eating meat is deprecated and will be removed from the earth in the future. Please use vegetables instead. Note: You may find it beneficial to transition gradually.' | ||
* // Logs: 'Eating meat is deprecated since version 2019.01.01 and will be removed from the earth in version 2020.01.01. Please use vegetables instead. Note: You may find it beneficial to transition gradually.' | ||
* ``` | ||
@@ -55,3 +57,4 @@ */ | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var version = options.version, | ||
var since = options.since, | ||
version = options.version, | ||
alternative = options.alternative, | ||
@@ -62,2 +65,3 @@ plugin = options.plugin, | ||
var pluginMessage = plugin ? " from ".concat(plugin) : ''; | ||
var sinceMessage = since ? " since version ".concat(since) : ''; | ||
var versionMessage = version ? " and will be removed".concat(pluginMessage, " in version ").concat(version) : ''; | ||
@@ -67,3 +71,3 @@ var useInsteadMessage = alternative ? " Please use ".concat(alternative, " instead.") : ''; | ||
var hintMessage = hint ? " Note: ".concat(hint) : ''; | ||
var message = "".concat(feature, " is deprecated").concat(versionMessage, ".").concat(useInsteadMessage).concat(linkMessage).concat(hintMessage); // Skip if already logged. | ||
var message = "".concat(feature, " is deprecated").concat(sinceMessage).concat(versionMessage, ".").concat(useInsteadMessage).concat(linkMessage).concat(hintMessage); // Skip if already logged. | ||
@@ -78,2 +82,3 @@ if (message in logged) { | ||
* @param {?Object} options Personalisation options | ||
* @param {string} options.since Version in which the feature was deprecated. | ||
* @param {?string} options.version Version in which the feature will be removed. | ||
@@ -80,0 +85,0 @@ * @param {?string} options.alternative Feature to use instead |
{ | ||
"name": "@wordpress/deprecated", | ||
"version": "2.12.0", | ||
"version": "2.12.1-next.5c9849e156.0", | ||
"description": "Deprecation utility for WordPress.", | ||
@@ -27,4 +27,4 @@ "author": "The WordPress Contributors", | ||
"dependencies": { | ||
"@babel/runtime": "^7.12.5", | ||
"@wordpress/hooks": "^2.12.0" | ||
"@babel/runtime": "^7.13.10", | ||
"@wordpress/hooks": "^2.12.1-next.5c9849e156.0" | ||
}, | ||
@@ -34,3 +34,3 @@ "publishConfig": { | ||
}, | ||
"gitHead": "054f7d722fe561b2bede2d1e89e1add59a6b7093" | ||
"gitHead": "595352e9f9c483d00f19d2b2f89ccca41f92e9a6" | ||
} |
@@ -45,3 +45,4 @@ # Deprecated | ||
deprecated( 'Eating meat', { | ||
version: 'the future', | ||
since: '2019.01.01' | ||
version: '2020.01.01', | ||
alternative: 'vegetables', | ||
@@ -52,3 +53,3 @@ plugin: 'the earth', | ||
// Logs: 'Eating meat is deprecated and will be removed from the earth in the future. Please use vegetables instead. Note: You may find it beneficial to transition gradually.' | ||
// Logs: 'Eating meat is deprecated since version 2019.01.01 and will be removed from the earth in version 2020.01.01. Please use vegetables instead. Note: You may find it beneficial to transition gradually.' | ||
``` | ||
@@ -60,2 +61,3 @@ | ||
- _options_ `[Object]`: Personalisation options | ||
- _options.since_ `[string]`: Version in which the feature was deprecated. | ||
- _options.version_ `[string]`: Version in which the feature will be removed. | ||
@@ -62,0 +64,0 @@ - _options.alternative_ `[string]`: Feature to use instead |
@@ -19,2 +19,3 @@ /** | ||
* @param {Object} [options] Personalisation options | ||
* @param {string} [options.since] Version in which the feature was deprecated. | ||
* @param {string} [options.version] Version in which the feature will be removed. | ||
@@ -31,3 +32,4 @@ * @param {string} [options.alternative] Feature to use instead | ||
* deprecated( 'Eating meat', { | ||
* version: 'the future', | ||
* since: '2019.01.01' | ||
* version: '2020.01.01', | ||
* alternative: 'vegetables', | ||
@@ -38,9 +40,10 @@ * plugin: 'the earth', | ||
* | ||
* // Logs: 'Eating meat is deprecated and will be removed from the earth in the future. Please use vegetables instead. Note: You may find it beneficial to transition gradually.' | ||
* // Logs: 'Eating meat is deprecated since version 2019.01.01 and will be removed from the earth in version 2020.01.01. Please use vegetables instead. Note: You may find it beneficial to transition gradually.' | ||
* ``` | ||
*/ | ||
export default function deprecated( feature, options = {} ) { | ||
const { version, alternative, plugin, link, hint } = options; | ||
const { since, version, alternative, plugin, link, hint } = options; | ||
const pluginMessage = plugin ? ` from ${ plugin }` : ''; | ||
const sinceMessage = since ? ` since version ${ since }` : ''; | ||
const versionMessage = version | ||
@@ -54,3 +57,3 @@ ? ` and will be removed${ pluginMessage } in version ${ version }` | ||
const hintMessage = hint ? ` Note: ${ hint }` : ''; | ||
const message = `${ feature } is deprecated${ versionMessage }.${ useInsteadMessage }${ linkMessage }${ hintMessage }`; | ||
const message = `${ feature } is deprecated${ sinceMessage }${ versionMessage }.${ useInsteadMessage }${ linkMessage }${ hintMessage }`; | ||
@@ -67,2 +70,3 @@ // Skip if already logged. | ||
* @param {?Object} options Personalisation options | ||
* @param {string} options.since Version in which the feature was deprecated. | ||
* @param {?string} options.version Version in which the feature will be removed. | ||
@@ -69,0 +73,0 @@ * @param {?string} options.alternative Feature to use instead |
@@ -24,2 +24,10 @@ /** | ||
it( 'should show a deprecation warning with a since', () => { | ||
deprecated( 'Eating meat', { since: '2019.01.01' } ); | ||
expect( console ).toHaveWarnedWith( | ||
'Eating meat is deprecated since version 2019.01.01.' | ||
); | ||
} ); | ||
it( 'should show a deprecation warning with a version', () => { | ||
@@ -35,2 +43,3 @@ deprecated( 'Eating meat', { version: '2020.01.01' } ); | ||
deprecated( 'Eating meat', { | ||
since: '2019.01.01', | ||
version: '2020.01.01', | ||
@@ -41,3 +50,3 @@ alternative: 'vegetables', | ||
expect( console ).toHaveWarnedWith( | ||
'Eating meat is deprecated and will be removed in version 2020.01.01. Please use vegetables instead.' | ||
'Eating meat is deprecated since version 2019.01.01 and will be removed in version 2020.01.01. Please use vegetables instead.' | ||
); | ||
@@ -73,2 +82,3 @@ } ); | ||
deprecated( 'Eating meat', { | ||
since: '2019.01.01', | ||
version: '2020.01.01', | ||
@@ -81,3 +91,3 @@ alternative: 'vegetables', | ||
expect( console ).toHaveWarnedWith( | ||
'Eating meat is deprecated and will be removed from the earth in version 2020.01.01. Please use vegetables instead. Note: You may find it beneficial to transition gradually.' | ||
'Eating meat is deprecated since version 2019.01.01 and will be removed from the earth in version 2020.01.01. Please use vegetables instead. Note: You may find it beneficial to transition gradually.' | ||
); | ||
@@ -84,0 +94,0 @@ } ); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
70506
363
79
8
1