feat: update src/js/.eslintrc.js

enable no-undefined rule, and disable no-void rule
This commit is contained in:
Bobby 2022-10-06 02:46:13 +07:00
parent e7c91b8ad0
commit 364e16af7f
No known key found for this signature in database
GPG Key ID: 941839794CBF5A09
4 changed files with 10 additions and 8 deletions

View File

@ -12,6 +12,8 @@ module.exports = {
'plugin:compat/recommended'
],
rules: {
'no-undefined': 'error',
'no-void': 0,
'object-shorthand': [
'error',
'always'

View File

@ -763,7 +763,7 @@ page.getUploads = (params = {}) => {
div.className = 'image-container column'
div.dataset.id = upload.id
if (upload.thumb === undefined) {
if (typeof upload.thumb === 'undefined') {
div.innerHTML = `<a class="image" href="${upload.file}" target="_blank"><h1 class="title">${upload.extname || 'N/A'}</h1></a>`
} else {
div.innerHTML = `<a class="image" href="${upload.file}" target="_blank"><img alt="${upload.name}" data-src="${upload.thumb}"/></a>`
@ -934,7 +934,7 @@ page.setUploadsView = (view, element) => {
if (view === 'list') {
delete localStorage[lsKeys.viewType[page.currentView]]
page.views[page.currentView].type = undefined
page.views[page.currentView].type = void 0
} else {
localStorage[lsKeys.viewType[page.currentView]] = view
page.views[page.currentView].type = view
@ -3127,7 +3127,7 @@ page.getStatistics = (params = {}) => {
case 'byteUsage': {
if (typeof value === 'object') {
// Reasoning: https://github.com/sebhildebrandt/systeminformation/issues/464#issuecomment-756406053
const totalForPercentage = value.available !== undefined
const totalForPercentage = typeof value.available !== 'undefined'
? (value.used + value.available)
: value.total
parsed = `${page.getPrettyBytes(value.used)} / ${page.getPrettyBytes(value.total)} (${(value.used / totalForPercentage * 100).toFixed(2)}%)`

View File

@ -850,7 +850,7 @@ page.prepareUploadConfig = () => {
default: page.fileIdentifierLength.default,
round: true
}
: undefined,
: void 0,
help: true, // true means auto-generated, for number-based configs only
disabled: fileIdentifierLength && page.fileIdentifierLength.force
},
@ -979,9 +979,9 @@ page.prepareUploadConfig = () => {
} else {
const stored = localStorage[lsKeys[key]]
if (Array.isArray(conf.select)) {
value = conf.select.find(sel => sel.value === stored)
? stored
: undefined
if (conf.select.find(sel => sel.value === stored)) {
value = stored
}
} else {
value = stored
}

View File

@ -52,7 +52,7 @@ render.showTogglePrompt = () => {
if (value === 'reload') {
render.do(true)
} else if (value) {
const newValue = div.querySelector('#swalRender').checked ? undefined : '0'
const newValue = div.querySelector('#swalRender').checked ? void 0 : '0'
if (newValue !== localStorage[render.lsKey]) {
if (newValue) localStorage[render.lsKey] = newValue
else localStorage.removeItem(render.lsKey)