Skip to content

Commit

Permalink
remove deprecation warning for 2 antd components
Browse files Browse the repository at this point in the history
Summary:
There warnings are not actionable and pollute test output. Lets comment these out

* antd about deprecated component api (removes ~7k lines)
* react-dom about mounting app (removes ~2.5k lines)
* a few flipper logs that are commonly used during many test startup (~500 lines)

Number of lines that is outputed by `yarn run test`
```
Before: 10139
After:   1065
```

**New output**
{P1486339650}

There are still some console logs that are present in the output which are less common.

The reason I didn't add process.env.NODE_ENV check in our logger itself is that then people won't be able to use console.XXX methods in tests to inspect values which would be a nightmare to debug.

Reviewed By: lblasa

Differential Revision: D59962243

fbshipit-source-id: d8096b21deeff555d0025dd1e8814b745283a55c
  • Loading branch information
antonk52 authored and facebook-github-bot committed Jul 22, 2024
1 parent 5ff667a commit 2e4e3cc
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 12 deletions.
10 changes: 6 additions & 4 deletions desktop/flipper-ui/src/Client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,12 @@ export default class Client extends EventEmitter {
},
);
this.plugins = new Set(response.plugins ?? []);
console.info(
`Received plugins from '${this.query.app}' on device '${this.query.device}'`,
[...this.plugins],
);
if (process.env.NODE_ENV !== 'test') {
console.info(
`Received plugins from '${this.query.app}' on device '${this.query.device}'`,
[...this.plugins],
);
}
if (phase === 'init') {
await this.waitForPluginsInit();
}
Expand Down
14 changes: 9 additions & 5 deletions desktop/flipper-ui/src/dispatcher/flipperServer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ export function handleDeviceConnected(
.connections.devices.find((device) => device.serial === deviceInfo.serial);
// handled outside reducer, as it might emit new redux actions...
if (existing) {
if (existing.connected.get()) {
if (existing.connected.get() && process.env.NODE_ENV !== 'test') {
console.warn(
`Tried to replace still connected device '${existing.serial}' with a new instance.`,
);
Expand Down Expand Up @@ -474,9 +474,11 @@ export async function handleClientConnected(
});
}

console.log(
`Searching matching device ${query.device_id} for client ${query.app}...`,
);
if (process.env.NODE_ENV !== 'test') {
console.log(
`Searching matching device ${query.device_id} for client ${query.app}...`,
);
}
const device =
getDeviceBySerial(store.getState(), query.device_id) ??
(await findDeviceForConnection(store, query.app, query.device_id).catch(
Expand Down Expand Up @@ -537,7 +539,9 @@ export async function handleClientConnected(
client.init(),
`Failed to initialize client ${query.app} on ${query.device_id} in a timely manner`,
);
console.log(`${query.app} on ${query.device_id} connected and ready.`);
if (process.env.NODE_ENV !== 'test') {
console.log(`${query.app} on ${query.device_id} connected and ready.`);
}
} catch (e) {
if (e instanceof NoLongerConnectedToClientError) {
console.warn(
Expand Down
44 changes: 42 additions & 2 deletions desktop/patches/antd+4.24.13.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/node_modules/antd/es/button/button.js b/node_modules/antd/es/button/button.js
index 635e056..611d5b4 100644
index 635e056..805ebfa 100644
--- a/node_modules/antd/es/button/button.js
+++ b/node_modules/antd/es/button/button.js
@@ -165,6 +165,7 @@ var InternalButton = function InternalButton(props, ref) {
Expand All @@ -25,8 +25,21 @@ index 635e056..611d5b4 100644
};
process.env.NODE_ENV !== "production" ? warning(!(typeof icon === 'string' && icon.length > 2), 'Button', "`icon` is using ReactNode instead of string naming in v4. Please check `".concat(icon, "` at https://ant.design/components/icon")) : void 0;
process.env.NODE_ENV !== "production" ? warning(!(ghost && isUnBorderedButtonType(type)), 'Button', "`link` or `text` button can't be a `ghost` button.") : void 0;
diff --git a/node_modules/antd/es/tabs/hooks/useLegacyItems.js b/node_modules/antd/es/tabs/hooks/useLegacyItems.js
index 5f06ff5..568f3b5 100644
--- a/node_modules/antd/es/tabs/hooks/useLegacyItems.js
+++ b/node_modules/antd/es/tabs/hooks/useLegacyItems.js
@@ -19,7 +19,7 @@ export default function useLegacyItems(items, children) {
if (items) {
return items;
}
- process.env.NODE_ENV !== "production" ? warning(!children, 'Tabs', 'Tabs.TabPane is deprecated. Please use `items` directly.') : void 0;
+ // process.env.NODE_ENV !== "production" ? warning(!children, 'Tabs', 'Tabs.TabPane is deprecated. Please use `items` directly.') : void 0;
var childrenItems = toArray(children).map(function (node) {
if ( /*#__PURE__*/React.isValidElement(node)) {
var key = node.key,
diff --git a/node_modules/antd/es/typography/Link.js b/node_modules/antd/es/typography/Link.js
index 9156f1d..3978c6a 100644
index 9156f1d..0d6090c 100644
--- a/node_modules/antd/es/typography/Link.js
+++ b/node_modules/antd/es/typography/Link.js
@@ -19,12 +19,24 @@ var Link = /*#__PURE__*/React.forwardRef(function (_a, ref) {
Expand Down Expand Up @@ -55,3 +68,30 @@ index 9156f1d..3978c6a 100644
}));
});
export default Link;
\ No newline at end of file
diff --git a/node_modules/antd/lib/dropdown/dropdown.js b/node_modules/antd/lib/dropdown/dropdown.js
index 05175ab..cf735f2 100644
--- a/node_modules/antd/lib/dropdown/dropdown.js
+++ b/node_modules/antd/lib/dropdown/dropdown.js
@@ -39,7 +39,7 @@ var Dropdown = function Dropdown(props) {
newName = _ref2[1];
process.env.NODE_ENV !== "production" ? (0, _warning["default"])(!(deprecatedName in props), 'Dropdown', "`".concat(deprecatedName, "` is deprecated which will be removed in next major version, please use `").concat(newName, "` instead.")) : void 0;
});
- process.env.NODE_ENV !== "production" ? (0, _warning["default"])(!('overlay' in props), 'Dropdown', '`overlay` is deprecated. Please use `menu` instead.') : void 0;
+ // process.env.NODE_ENV !== "production" ? (0, _warning["default"])(!('overlay' in props), 'Dropdown', '`overlay` is deprecated. Please use `menu` instead.') : void 0;
}
var getTransitionName = function getTransitionName() {
var rootPrefixCls = getPrefixCls();
diff --git a/node_modules/antd/lib/tabs/hooks/useLegacyItems.js b/node_modules/antd/lib/tabs/hooks/useLegacyItems.js
index 7cf5363..45c579e 100644
--- a/node_modules/antd/lib/tabs/hooks/useLegacyItems.js
+++ b/node_modules/antd/lib/tabs/hooks/useLegacyItems.js
@@ -27,7 +27,7 @@ function useLegacyItems(items, children) {
if (items) {
return items;
}
- process.env.NODE_ENV !== "production" ? (0, _warning["default"])(!children, 'Tabs', 'Tabs.TabPane is deprecated. Please use `items` directly.') : void 0;
+ // process.env.NODE_ENV !== "production" ? (0, _warning["default"])(!children, 'Tabs', 'Tabs.TabPane is deprecated. Please use `items` directly.') : void 0;
var childrenItems = (0, _toArray["default"])(children).map(function (node) {
if ( /*#__PURE__*/React.isValidElement(node)) {
var key = node.key,
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --git a/node_modules/react-dom/cjs/react-dom.development.js b/node_modules/react-dom/cjs/react-dom.development.js
index ae216b2..02c457f 100644
--- a/node_modules/react-dom/cjs/react-dom.development.js
+++ b/node_modules/react-dom/cjs/react-dom.development.js
@@ -83,7 +83,9 @@ function printWarning(level, format, args) {
// breaks IE9: https://github.com/facebook/react/issues/13610
// eslint-disable-next-line react-internal/no-production-logging

- Function.prototype.apply.call(console[level], console, argsWithFormat);
+ if (process.env.NODE_ENV !== "test") {
+ Function.prototype.apply.call(console[level], console, argsWithFormat);
+ }
}
}

1 change: 0 additions & 1 deletion desktop/plugins/public/logs/__tests__/logs.node.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ test('it supports deeplink and select nodes + navigating to bottom', async () =>
await sleep(1000);

const current = instance.tableManagerRef.current;
console.error('ref', current);
expect(current?.getSelectedItems()).toEqual([
{
...entry2,
Expand Down

0 comments on commit 2e4e3cc

Please sign in to comment.