Upgraded to ESLint 7

This commit is contained in:
Bobby Wibowo 2020-10-30 22:54:02 +07:00
parent 0307730251
commit c40478dd0a
No known key found for this signature in database
GPG Key ID: 51C3A1E1E22D26CF
7 changed files with 485 additions and 601 deletions

View File

@ -1,37 +1,25 @@
module.exports = { module.exports = {
"root": true, root: true,
"parserOptions": { parserOptions: {
"ecmaVersion": 9 // 2018 ecmaVersion: 9 // 2018
}, },
"env": { env: {
"node": true node: true
}, },
"extends": [ extends: [
"standard" 'standard'
], ],
"rules": { rules: {
"curly": [ curly: [
"error", 'error',
"multi", 'multi',
"consistent" 'consistent'
], ],
"no-throw-literal": 0, 'no-throw-literal': 0,
"no-var": "error", 'object-shorthand': [
"prefer-const": [ 'error',
"error", 'always'
{
"destructuring": "any",
"ignoreReadBeforeAssign": false
}
], ],
"object-shorthand": [ 'standard/no-callback-literal': 0
"error",
"always"
],
"quotes": [
"error",
"single"
],
"standard/no-callback-literal": 0
} }
} }

View File

@ -3,7 +3,7 @@ const gulp = require('gulp')
const cssnano = require('cssnano') const cssnano = require('cssnano')
const del = require('del') const del = require('del')
const buble = require('gulp-buble') const buble = require('gulp-buble')
const eslint = require('gulp-eslint') const eslint = require('gulp-eslint7')
const gulpif = require('gulp-if') const gulpif = require('gulp-if')
const nodemon = require('gulp-nodemon') const nodemon = require('gulp-nodemon')
const postcss = require('gulp-postcss') const postcss = require('gulp-postcss')

View File

@ -59,17 +59,17 @@
"bulma": "~0.9.1", "bulma": "~0.9.1",
"cssnano": "~4.1.10", "cssnano": "~4.1.10",
"del": "~6.0.0", "del": "~6.0.0",
"eslint": "~6.8.0", "eslint": "~7.12.1",
"eslint-config-standard": "~14.1.1", "eslint-config-standard": "~16.0.0",
"eslint-plugin-compat": "~3.8.0", "eslint-plugin-compat": "~3.8.0",
"eslint-plugin-import": "~2.22.1", "eslint-plugin-import": "~2.22.1",
"eslint-plugin-node": "~11.1.0", "eslint-plugin-node": "~11.1.0",
"eslint-plugin-promise": "~4.2.1", "eslint-plugin-promise": "~4.2.1",
"eslint-plugin-standard": "~4.0.1", "eslint-plugin-standard": "~4.0.2",
"gulp": "~4.0.2", "gulp": "~4.0.2",
"gulp-buble": "~0.9.0", "gulp-buble": "~0.9.0",
"gulp-cli": "~2.3.0", "gulp-cli": "~2.3.0",
"gulp-eslint": "~6.0.0", "gulp-eslint7": "~0.3.0",
"gulp-if": "~3.0.0", "gulp-if": "~3.0.0",
"gulp-nodemon": "~2.5.0", "gulp-nodemon": "~2.5.0",
"gulp-postcss": "~9.0.0", "gulp-postcss": "~9.0.0",

View File

@ -1,36 +1,25 @@
module.exports = { module.exports = {
"root": true, root: true,
"parserOptions": { parserOptions: {
"ecmaVersion": 7, // 2016 ecmaVersion: 7, // 2016
"sourceType": "script" sourceType: 'script'
}, },
"env": { env: {
"browser": true browser: true
}, },
"extends": [ extends: [
"standard", 'standard',
"plugin:compat/recommended" 'plugin:compat/recommended'
], ],
"rules": { rules: {
"curly": [ curly: [
"error", 'error',
"multi", 'multi',
"consistent" 'consistent'
], ],
"quotes": [ 'object-shorthand': [
"error", 'error',
"single" 'always'
],
"object-shorthand": [
"error",
"always"
],
"prefer-const": [
"error",
{
"destructuring": "any",
"ignoreReadBeforeAssign": false
}
] ]
} }
} }

View File

@ -625,8 +625,9 @@ page.getUploads = (params = {}) => {
<i class="icon-cancel"></i> <i class="icon-cancel"></i>
</span> </span>
</a> </a>
${params.all ? '' : ` ${params.all
<a class="button is-small is-warning is-outlined" title="Bulk add to album" data-action="add-selected-uploads-to-album"> ? ''
: `<a class="button is-small is-warning is-outlined" title="Bulk add to album" data-action="add-selected-uploads-to-album">
<span class="icon"> <span class="icon">
<i class="icon-plus"></i> <i class="icon-plus"></i>
</span> </span>
@ -736,12 +737,13 @@ page.getUploads = (params = {}) => {
div.innerHTML += ` div.innerHTML += `
<input type="checkbox" class="checkbox" title="Select" data-index="${i}" data-action="select"${upload.selected ? ' checked' : ''}> <input type="checkbox" class="checkbox" title="Select" data-index="${i}" data-action="select"${upload.selected ? ' checked' : ''}>
<div class="controls"> <div class="controls">
${upload.thumb ? ` ${upload.thumb
<a class="button is-small is-primary" title="Display preview" data-action="display-preview"> ? `<a class="button is-small is-primary" title="Display preview" data-action="display-preview">
<span class="icon"> <span class="icon">
<i class="${upload.type !== 'other' ? `icon-${upload.type}` : 'icon-doc-inv'}"></i> <i class="${upload.type !== 'other' ? `icon-${upload.type}` : 'icon-doc-inv'}"></i>
</span> </span>
</a>` : ''} </a>`
: ''}
<a class="button is-small is-info clipboard-js" title="Copy link to clipboard" data-clipboard-text="${upload.file}"> <a class="button is-small is-info clipboard-js" title="Copy link to clipboard" data-clipboard-text="${upload.file}">
<span class="icon"> <span class="icon">
<i class="icon-clipboard"></i> <i class="icon-clipboard"></i>
@ -762,8 +764,9 @@ page.getUploads = (params = {}) => {
<p class="name" title="${upload.file}">${upload.name}</p> <p class="name" title="${upload.file}">${upload.name}</p>
${showOriginalNames ? `<p class="originalname" title="${upload.original}">${upload.original}</p>` : ''} ${showOriginalNames ? `<p class="originalname" title="${upload.original}">${upload.original}</p>` : ''}
<p class="prettybytes">${upload.appendix ? `<span>${upload.appendix}</span> ` : ''}${upload.prettyBytes}</p> <p class="prettybytes">${upload.appendix ? `<span>${upload.appendix}</span> ` : ''}${upload.prettyBytes}</p>
${hasExpiryDateColumn && upload.prettyExpiryDate ? ` ${hasExpiryDateColumn && upload.prettyExpiryDate
<p class="prettyexpirydate">EXP: ${upload.prettyExpiryDate}</p>` : ''} ? `<p class="prettyexpirydate">EXP: ${upload.prettyExpiryDate}</p>`
: ''}
</div> </div>
` `
@ -828,8 +831,9 @@ page.getUploads = (params = {}) => {
<i class="icon-clipboard"></i> <i class="icon-clipboard"></i>
</span> </span>
</a> </a>
${params.all ? '' : ` ${params.all
<a class="button is-small is-warning is-outlined" title="Add to album" data-action="add-to-album"> ? ''
: `<a class="button is-small is-warning is-outlined" title="Add to album" data-action="add-to-album">
<span class="icon"> <span class="icon">
<i class="icon-plus"></i> <i class="icon-plus"></i>
</span> </span>
@ -1098,8 +1102,8 @@ page.uploadFiltersHelp = element => {
const all = Boolean(element.dataset.all) const all = Boolean(element.dataset.all)
const content = document.createElement('div') const content = document.createElement('div')
content.style = 'text-align: left' content.style = 'text-align: left'
content.innerHTML = `${all ? ` content.innerHTML = `${all
There are 2 filter keys, namely <b>user</b> (username) and <b>ip</b>. ? `There are 2 filter keys, namely <b>user</b> (username) and <b>ip</b>.
These keys can be specified more than once. These keys can be specified more than once.
For usernames with whitespaces, wrap them with double quotes (<code>"</code>). For usernames with whitespaces, wrap them with double quotes (<code>"</code>).
Special cases such as uploads by non-registered users or have no IPs respectively, use <code>user:-</code> or <code>ip:-</code>. Special cases such as uploads by non-registered users or have no IPs respectively, use <code>user:-</code> or <code>ip:-</code>.
@ -1108,15 +1112,14 @@ page.uploadFiltersHelp = element => {
Negation sign can also be used to exclude the special cases mentioned above (i.e. <code>-user:-</code> or <code>-ip:-</code>). Negation sign can also be used to exclude the special cases mentioned above (i.e. <code>-user:-</code> or <code>-ip:-</code>).
If you know the ID of a user's album, you can list its uploads with <b>albumid</b> key. If you know the ID of a user's album, you can list its uploads with <b>albumid</b> key.
Negation sign works for this key as well. Negation sign works for this key as well.`
` : ` : `There is only 1 filter key, namely <b>albumid</b>.
There is only 1 filter key, namely <b>albumid</b>.
This key can be specified more than once. This key can be specified more than once.
Special case such as uploads with no albums, use <code>albumid:-</code>. Special case such as uploads with no albums, use <code>albumid:-</code>.
To exclude certain albums while still listing every other uploads, add negation sign (<code>-</code>) before the keys. To exclude certain albums while still listing every other uploads, add negation sign (<code>-</code>) before the keys.
Negation sign can also be used to exclude the special case mentioned above (i.e. <code>-albumid:-</code>). Negation sign can also be used to exclude the special case mentioned above (i.e. <code>-albumid:-</code>).`}
`}
There are 2 range keys: <b>date</b> (upload date) and <b>expiry</b> (expiry date). There are 2 range keys: <b>date</b> (upload date) and <b>expiry</b> (expiry date).
Their format is: <code>"YYYY/MM/DD HH:MM:SS-YYYY/MM/DD HH:MM:SS"</code> ("from" date and "to" date respectively). Their format is: <code>"YYYY/MM/DD HH:MM:SS-YYYY/MM/DD HH:MM:SS"</code> ("from" date and "to" date respectively).
You may specify only one of the dates. You may specify only one of the dates.
@ -1146,8 +1149,10 @@ page.uploadFiltersHelp = element => {
Excluding certain keywords is also supported by adding negation sign before the keywords. Excluding certain keywords is also supported by adding negation sign before the keywords.
<b>Internal steps:</b> <b>Internal steps:</b>
${all ? `- Query uploads passing ALL exclusion filter keys OR matching ANY filter keys, if any. ${all
- Refine matches` : '- Filter uploads'} using date key, if any. ? `- Query uploads passing ALL exclusion filter keys OR matching ANY filter keys, if any.
- Refine matches`
: '- Filter uploads'} using date key, if any.
- Refine matches using expiry key, if any. - Refine matches using expiry key, if any.
- Refine matches using type-is keys, if any. - Refine matches using type-is keys, if any.
- Refine matches using ANY non-keyed keywords, if any. - Refine matches using ANY non-keyed keywords, if any.
@ -1155,13 +1160,15 @@ page.uploadFiltersHelp = element => {
- Sort matches using sorting keys, if any. - Sort matches using sorting keys, if any.
<b>Examples:</b> <b>Examples:</b>
${all ? `- Uploads from users named "demo" AND/OR "John Doe" AND/OR non-registered users: ${all
? `- Uploads from users named "demo" AND/OR "John Doe" AND/OR non-registered users:
<code>user:demo user:"John Doe" user:-</code> <code>user:demo user:"John Doe" user:-</code>
- ALL uploads, but NOT the ones from user named "demo" AND "John Doe": - ALL uploads, but NOT the ones from user named "demo" AND "John Doe":
<code>-user:demo -user:"John Doe"</code> <code>-user:demo -user:"John Doe"</code>
- Uploads from IP "127.0.0.1" AND which file names match "*.rar" OR "*.zip": - Uploads from IP "127.0.0.1" AND which file names match "*.rar" OR "*.zip":
<code>ip:127.0.0.1 *.rar *.zip</code> <code>ip:127.0.0.1 *.rar *.zip</code>
` : ''}- Uploads without albums: `
: ''}- Uploads without albums:
<code>albumid:-</code> <code>albumid:-</code>
- ALL uploads, but NOT the ones from album with ID 69: - ALL uploads, but NOT the ones from album with ID 69:
<code>-albumid:69</code> <code>-albumid:69</code>
@ -1176,9 +1183,9 @@ page.uploadFiltersHelp = element => {
- Sort matches by "size" column in ascending and descending order respectively: - Sort matches by "size" column in ascending and descending order respectively:
<code>${all ? 'user:"John Doe"' : '*.txt'} sort:size</code> <code>${all ? 'user:"John Doe"' : '*.txt'} sort:size</code>
<code>*.mp4 ${all ? 'user:- ' : ''}sort:size:d</code> <code>*.mp4 ${all ? 'user:- ' : ''}sort:size:d</code>
${!page.permissions.moderator ? ` ${!page.permissions.moderator
<b>Notice:</b> Regular users may face some limitations in the amount of keys that can be used at a time. ? '<b>Notice:</b> Regular users may face some limitations in the amount of keys that can be used at a time.'
` : ''} : ''}
<b>Friendly reminder:</b> This window can be scrolled up! <b>Friendly reminder:</b> This window can be scrolled up!
`.trim().replace(/^\s*/g, '').replace(/\n/g, '<br>') `.trim().replace(/^\s*/g, '').replace(/\n/g, '<br>')
@ -1399,11 +1406,10 @@ page.postBulkDeleteUploads = (params = {}) => {
if (!response) return if (!response) return
if (response.data.success === false) if (response.data.success === false)
if (response.data.description === 'No token provided') { if (response.data.description === 'No token provided')
return page.verifyToken(page.token) return page.verifyToken(page.token)
} else { else
return swal('An error occurred!', response.data.description, 'error') return swal('An error occurred!', response.data.description, 'error')
}
const failed = Array.isArray(response.data.failed) ? response.data.failed : [] const failed = Array.isArray(response.data.failed) ? response.data.failed : []
if (failed.length === params.values.length) if (failed.length === params.values.length)
@ -1907,11 +1913,10 @@ page.editAlbum = id => {
if (!response) return if (!response) return
if (response.data.success === false) if (response.data.success === false)
if (response.data.description === 'No token provided') { if (response.data.description === 'No token provided')
return page.verifyToken(page.token) return page.verifyToken(page.token)
} else { else
return swal('An error occurred!', response.data.description, 'error') return swal('An error occurred!', response.data.description, 'error')
}
if (response.data.identifier) if (response.data.identifier)
swal('Success!', `The album's new identifier is: ${response.data.identifier}.`, 'success') swal('Success!', `The album's new identifier is: ${response.data.identifier}.`, 'success')
@ -1998,11 +2003,10 @@ page.submitAlbum = element => {
page.updateTrigger(element) page.updateTrigger(element)
if (response.data.success === false) if (response.data.success === false)
if (response.data.description === 'No token provided') { if (response.data.description === 'No token provided')
return page.verifyToken(page.token) return page.verifyToken(page.token)
} else { else
return swal('An error occurred!', response.data.description, 'error') return swal('An error occurred!', response.data.description, 'error')
}
swal('Woohoo!', 'Album was created successfully.', 'success', { swal('Woohoo!', 'Album was created successfully.', 'success', {
buttons: false, buttons: false,
@ -2023,11 +2027,10 @@ page.getAlbumsSidebar = () => {
if (!response) return if (!response) return
if (response.data.success === false) if (response.data.success === false)
if (response.data.description === 'No token provided') { if (response.data.description === 'No token provided')
return page.verifyToken(page.token) return page.verifyToken(page.token)
} else { else
return swal('An error occurred!', response.data.description, 'error') return swal('An error occurred!', response.data.description, 'error')
}
const albums = response.data.albums const albums = response.data.albums
const count = response.data.count const count = response.data.count
@ -2514,11 +2517,10 @@ page.createUser = () => {
if (!response) return if (!response) return
if (response.data.success === false) if (response.data.success === false)
if (response.data.description === 'No token provided') { if (response.data.description === 'No token provided')
return page.verifyToken(page.token) return page.verifyToken(page.token)
} else { else
return swal('An error occurred!', response.data.description, 'error') return swal('An error occurred!', response.data.description, 'error')
}
const div = document.createElement('div') const div = document.createElement('div')
div.innerHTML = ` div.innerHTML = `
@ -2613,11 +2615,10 @@ page.editUser = id => {
if (!response) return if (!response) return
if (response.data.success === false) if (response.data.success === false)
if (response.data.description === 'No token provided') { if (response.data.description === 'No token provided')
return page.verifyToken(page.token) return page.verifyToken(page.token)
} else { else
return swal('An error occurred!', response.data.description, 'error') return swal('An error occurred!', response.data.description, 'error')
}
let autoClose = true let autoClose = true
const div = document.createElement('div') const div = document.createElement('div')

View File

@ -802,12 +802,14 @@ page.prepareUploadConfig = () => {
fileLength: { fileLength: {
display: fileIdentifierLength, display: fileIdentifierLength,
label: 'File identifier length', label: 'File identifier length',
number: fileIdentifierLength ? { number: fileIdentifierLength
? {
min: page.fileIdentifierLength.min, min: page.fileIdentifierLength.min,
max: page.fileIdentifierLength.max, max: page.fileIdentifierLength.max,
default: page.fileIdentifierLength.default, default: page.fileIdentifierLength.default,
round: true round: true
} : undefined, }
: undefined,
help: true, // true means auto-generated, for number-based configs only help: true, // true means auto-generated, for number-based configs only
disabled: fileIdentifierLength && page.fileIdentifierLength.force disabled: fileIdentifierLength && page.fileIdentifierLength.force
}, },
@ -820,10 +822,12 @@ page.prepareUploadConfig = () => {
stripTags: { stripTags: {
display: page.stripTagsConfig, display: page.stripTagsConfig,
label: 'Strip tags', label: 'Strip tags',
select: page.stripTagsConfig ? [ select: page.stripTagsConfig
? [
{ value: page.stripTagsConfig.default ? 'default' : '1', text: 'Yes' }, { value: page.stripTagsConfig.default ? 'default' : '1', text: 'Yes' },
{ value: page.stripTagsConfig.default ? '0' : 'default', text: 'No' } { value: page.stripTagsConfig.default ? '0' : 'default', text: 'No' }
] : null, ]
: null,
help: `Whether to strip tags (e.g. EXIF) from your uploads.<br> help: `Whether to strip tags (e.g. EXIF) from your uploads.<br>
This only applies to regular image${page.stripTagsConfig && page.stripTagsConfig.video ? ' and video' : ''} uploads (i.e. not URL uploads).`, This only applies to regular image${page.stripTagsConfig && page.stripTagsConfig.video ? ' and video' : ''} uploads (i.e. not URL uploads).`,
disabled: page.stripTagsConfig && page.stripTagsConfig.force disabled: page.stripTagsConfig && page.stripTagsConfig.force

878
yarn.lock

File diff suppressed because it is too large Load Diff