diff options
author | Cashew <52880648+Scrub1492@users.noreply.github.com> | 2023-12-25 17:13:34 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-25 08:13:34 +0000 |
commit | bdaa77ff0d7c23f1594575ac22fb9693f1802b24 (patch) | |
tree | 87cef502658dfb1ba62434eef51f994a08ec5739 /ext/js/core.js | |
parent | 89994427c7dfb25e7879948061a531f34cb1e9ab (diff) |
Narrow down enum types (#431)
* narrow down enum types
* add enum types
* change from default to case
* add enum types
* remove comments
* remove comments
* fix
* Move getErrorLevelValue to Logger
* Add enum type for LogErrorLevelValue
* add eslint switch-exhaustiveness-check rule
* Revert "add eslint switch-exhaustiveness-check"
This reverts commit 49f9caabf0af900bc5ba2b80f5baff72c27e02cd.
* move from labelled loop to helper functions
* move helper functions downward
Diffstat (limited to 'ext/js/core.js')
-rw-r--r-- | ext/js/core.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/ext/js/core.js b/ext/js/core.js index 9995ee5b..63c2f527 100644 --- a/ext/js/core.js +++ b/ext/js/core.js @@ -734,6 +734,21 @@ export class Logger extends EventDispatcher { error(error, context = null) { this.log(error, 'error', context); } + + /** + * @param {import('log').LogLevel} errorLevel + * @returns {import('log').LogErrorLevelValue} + */ + getLogErrorLevelValue(errorLevel) { + switch (errorLevel) { + case 'log': + case 'info': + case 'debug': + return 0; + case 'warn': return 1; + case 'error': return 2; + } + } } /** |