-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add runtime warning/errors to components (#2007)
- add utility function for doing the logging - use in various components (Link, Button, util.s) - fix violations in EDS identified by these checks - add additional tests * chore: address PR comments
- Loading branch information
1 parent
807485e
commit 661130b
Showing
11 changed files
with
154 additions
and
20 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
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
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
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
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
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
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
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
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
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
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,22 @@ | ||
import identity from 'lodash/identity'; | ||
|
||
type Check = boolean; | ||
type LogLevel = 'warn' | 'error'; | ||
|
||
/** | ||
* Logging function used to check whether a usage of EDS is proper and advised. When using, it defaults | ||
* to warning, where it will print a message to the console for developers to see. LogLevel supported. | ||
* | ||
* @param checks set of boolean checks to assert whether the component usages are compatible | ||
* @param message Message to print when the component is not being used as advised | ||
* @param [loglevel] Severity of the tracked issue | ||
*/ | ||
export function assertEdsUsage( | ||
checks: Check[], | ||
message: string, | ||
loglevel: LogLevel = 'warn', | ||
): void { | ||
if (process.env.NODE_ENV !== 'production' && [...checks].some(identity)) { | ||
console[loglevel](message); | ||
} | ||
} |