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/background | |
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/background')
-rw-r--r-- | ext/js/background/backend.js | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/ext/js/background/backend.js b/ext/js/background/backend.js index df4b9777..a4cf6949 100644 --- a/ext/js/background/backend.js +++ b/ext/js/background/backend.js @@ -342,8 +342,9 @@ export class Backend { * @param {{level: import('log').LogLevel}} params */ _onLog({level}) { - const levelValue = this._getErrorLevelValue(level); - if (levelValue <= this._getErrorLevelValue(this._logErrorLevel)) { return; } + const levelValue = log.getLogErrorLevelValue(level); + const currentLogErrorLevel = this._logErrorLevel !== null ? log.getLogErrorLevelValue(this._logErrorLevel) : 0; + if (levelValue <= currentLogErrorLevel) { return; } this._logErrorLevel = level; this._updateBadge(); @@ -1452,20 +1453,6 @@ export class Backend { } /** - * @param {?import('log').LogLevel} errorLevel - * @returns {number} - */ - _getErrorLevelValue(errorLevel) { - switch (errorLevel) { - case 'info': return 0; - case 'debug': return 0; - case 'warn': return 1; - case 'error': return 2; - default: return 0; - } - } - - /** * @param {import('settings-modifications').OptionsScope} target * @returns {import('settings').Options|import('settings').ProfileOptions} * @throws {Error} |