Apply new ES syntax: Optional Chaining
This commit is contained in:
parent
7b3b528e6c
commit
37f8355dd4
@ -2,7 +2,9 @@
|
||||
"presets": [
|
||||
"@babel/preset-typescript"
|
||||
],
|
||||
"plugins": [],
|
||||
"plugins": [
|
||||
["@babel/plugin-proposal-optional-chaining", { "loose": false }]
|
||||
],
|
||||
"env": {
|
||||
"production": {
|
||||
"presets": [
|
||||
|
@ -33,6 +33,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.7.4",
|
||||
"@babel/plugin-proposal-optional-chaining": "^7.7.5",
|
||||
"@babel/plugin-transform-runtime": "^7.7.4",
|
||||
"@babel/preset-env": "^7.7.4",
|
||||
"@babel/preset-typescript": "^7.7.4",
|
||||
|
@ -1,6 +1,4 @@
|
||||
const chooser = document.querySelector<HTMLInputElement>('#language-chooser')
|
||||
if (chooser) {
|
||||
chooser.addEventListener('change', () => {
|
||||
window.location.href = `?lang=${chooser.value}`
|
||||
})
|
||||
}
|
||||
chooser?.addEventListener('change', () => {
|
||||
window.location.href = `?lang=${chooser.value}`
|
||||
})
|
||||
|
@ -17,7 +17,5 @@ export async function logout() {
|
||||
}
|
||||
|
||||
const button = document.querySelector('#logout-button')
|
||||
/* istanbul ignore next, not all pages contains this button. */
|
||||
if (button) {
|
||||
button.addEventListener('click', logout)
|
||||
}
|
||||
button?.addEventListener('click', logout)
|
||||
|
||||
|
@ -27,10 +27,10 @@ export const init: RequestInit = {
|
||||
}
|
||||
|
||||
function retrieveToken() {
|
||||
const csrfField: HTMLMetaElement | null =
|
||||
document.querySelector('meta[name="csrf-token"]')
|
||||
const csrfField =
|
||||
document.querySelector<HTMLMetaElement>('meta[name="csrf-token"]')
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
||||
return (csrfField && csrfField.content) || ''
|
||||
return csrfField?.content || ''
|
||||
}
|
||||
|
||||
export async function walkFetch(request: Request): Promise<any> {
|
||||
|
@ -5,27 +5,17 @@ import emailFormHandler from './email'
|
||||
import deleteAccountFormHandler from './deleteAccount'
|
||||
|
||||
const btnResetAvatar = document.querySelector('#reset-avatar')
|
||||
if (btnResetAvatar) {
|
||||
btnResetAvatar.addEventListener('click', resetAvatar)
|
||||
}
|
||||
btnResetAvatar?.addEventListener('click', resetAvatar)
|
||||
|
||||
const passwordForm = document.querySelector<HTMLFormElement>('#change-password')
|
||||
if (passwordForm) {
|
||||
passwordForm.addEventListener('submit', passwordFormHandler)
|
||||
}
|
||||
passwordForm?.addEventListener('submit', passwordFormHandler)
|
||||
|
||||
const nicknameForm = document.querySelector<HTMLFormElement>('#change-nickname')
|
||||
if (nicknameForm) {
|
||||
nicknameForm.addEventListener('submit', nicknameFormHandler)
|
||||
}
|
||||
nicknameForm?.addEventListener('submit', nicknameFormHandler)
|
||||
|
||||
const emailForm = document.querySelector<HTMLFormElement>('#change-email')
|
||||
if (emailForm) {
|
||||
emailForm.addEventListener('submit', emailFormHandler)
|
||||
}
|
||||
emailForm?.addEventListener('submit', emailFormHandler)
|
||||
|
||||
const deleteAccountForm = document
|
||||
.querySelector<HTMLFormElement>('#modal-delete-account')
|
||||
if (deleteAccountForm) {
|
||||
deleteAccountForm.addEventListener('submit', deleteAccountFormHandler)
|
||||
}
|
||||
deleteAccountForm?.addEventListener('submit', deleteAccountFormHandler)
|
||||
|
15
yarn.lock
15
yarn.lock
@ -380,6 +380,14 @@
|
||||
"@babel/helper-plugin-utils" "^7.0.0"
|
||||
"@babel/plugin-syntax-optional-catch-binding" "^7.7.4"
|
||||
|
||||
"@babel/plugin-proposal-optional-chaining@^7.7.5":
|
||||
version "7.7.5"
|
||||
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-optional-chaining/-/plugin-proposal-optional-chaining-7.7.5.tgz#f0835f044cef85b31071a924010a2a390add11d4"
|
||||
integrity sha512-sOwFqT8JSchtJeDD+CjmWCaiFoLxY4Ps7NjvwHC/U7l4e9i5pTRNt8nDMIFSOUL+ncFbYSwruHM8WknYItWdXw==
|
||||
dependencies:
|
||||
"@babel/helper-plugin-utils" "^7.0.0"
|
||||
"@babel/plugin-syntax-optional-chaining" "^7.7.4"
|
||||
|
||||
"@babel/plugin-proposal-unicode-property-regex@^7.7.4":
|
||||
version "7.7.4"
|
||||
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-unicode-property-regex/-/plugin-proposal-unicode-property-regex-7.7.4.tgz#7c239ccaf09470dbe1d453d50057460e84517ebb"
|
||||
@ -430,6 +438,13 @@
|
||||
dependencies:
|
||||
"@babel/helper-plugin-utils" "^7.0.0"
|
||||
|
||||
"@babel/plugin-syntax-optional-chaining@^7.7.4":
|
||||
version "7.7.4"
|
||||
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-optional-chaining/-/plugin-syntax-optional-chaining-7.7.4.tgz#c91fdde6de85d2eb8906daea7b21944c3610c901"
|
||||
integrity sha512-2MqYD5WjZSbJdUagnJvIdSfkb/ucOC9/1fRJxm7GAxY6YQLWlUvkfxoNbUPcPLHJyetKUDQ4+yyuUyAoc0HriA==
|
||||
dependencies:
|
||||
"@babel/helper-plugin-utils" "^7.0.0"
|
||||
|
||||
"@babel/plugin-syntax-top-level-await@^7.7.4":
|
||||
version "7.7.4"
|
||||
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-top-level-await/-/plugin-syntax-top-level-await-7.7.4.tgz#bd7d8fa7b9fee793a36e4027fd6dd1aa32f946da"
|
||||
|
Loading…
Reference in New Issue
Block a user