-
Notifications
You must be signed in to change notification settings - Fork 47.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Suppress known/expected warnings and errors in local DEV shell
- Loading branch information
Brian Vaughn
committed
Aug 4, 2019
1 parent
db8542a
commit 6b3ae64
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// @flow | ||
|
||
function ignoreStrings( | ||
methodName: string, | ||
stringsToIgnore: Array<string> | ||
): void { | ||
const originalMethod = console[methodName]; | ||
console[methodName] = (...args) => { | ||
const maybeString = args[0]; | ||
if (typeof maybeString === 'string') { | ||
for (let i = 0; i < stringsToIgnore.length; i++) { | ||
if (maybeString.startsWith(stringsToIgnore[i])) { | ||
return; | ||
} | ||
} | ||
} | ||
originalMethod(...args); | ||
}; | ||
} | ||
|
||
export function ignoreErrors(errorsToIgnore: Array<string>): void { | ||
ignoreStrings('error', errorsToIgnore); | ||
} | ||
|
||
export function ignoreWarnings(warningsToIgnore: Array<string>): void { | ||
ignoreStrings('warn', warningsToIgnore); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters