You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
build(lint): throw error on JSON.stringify within a logging statement (#5878)
## Problem
contributors often use `JSON.stringify` to get a printable form of an
object in log messages, but this is hard for humans to read.
## Solution
Implement a custom eslint rule that checks for instances of
`JSON.stringify` inside of a logging statement. The implementation
involves a few heuristics for catching edge cases that are explained in
the comments.
In addition to implementing the lint rule, existing cases are migrated
to use `%O` string substitution.
Within the lint message, we mention the depth limit. There is a
workaround this depth limit by manually converting it to a string first
with `util.format`:
https://stackoverflow.com/questions/10729276/how-can-i-get-the-full-object-in-node-jss-console-log-rather-than-object,
but seems rather involved, and uncommon enough to leave out of
suggestion message.
---
<!--- REMINDER: Ensure that your PR meets the guidelines in
CONTRIBUTING.md -->
License: I confirm that my contribution is made under the terms of the
Apache 2.0 license.
`crashMonitoring: CHECKED: Result of cleaning up crashed instances\nBEFORE: ${JSON.stringify(before)}\nAFTER: ${JSON.stringify(after)}\nACTUAL: ${JSON.stringify(afterActual)}`
321
+
`crashMonitoring: CHECKED: Result of cleaning up crashed instances\nBEFORE: %O \nAFTER: %O \nACTUAL: %O`,
0 commit comments