-
Notifications
You must be signed in to change notification settings - Fork 429
/
Copy pathdeprecated-property.js
37 lines (31 loc) · 1.18 KB
/
deprecated-property.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */
/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */
/* eslint-disable import/no-mutable-exports */
// This function will deliver an error message to the browser console about the removal of a property.
import warning from 'warning';
let deprecated = function deprecatedFunction() {};
if (process.env.NODE_ENV !== 'production') {
const hasWarned = {};
deprecated = function deprecatedFunction(
control,
propValue,
oldProp,
newProp,
comment,
silenceDeprecatedPropertyWarning
) {
const additionalComment = comment ? ` ${comment}` : '';
const newProperty = newProp ? `Use \`${newProp}\`` : '';
const newPropertySentence = newProp ? ` ${newProperty} instead.` : '';
if (!silenceDeprecatedPropertyWarning && !hasWarned[control + oldProp]) {
/* eslint-disable max-len */
warning(
propValue === undefined,
`[Design System React] \`${oldProp}\` will be removed in the next major version of ${control}.${newPropertySentence}${additionalComment}`
);
/* eslint-enable max-len */
hasWarned[control + oldProp] = propValue !== undefined;
}
};
}
export default deprecated;