Adding eslint.
This commit is contained in:
parent
31d3d96590
commit
fba0422adb
23
.eslintrc.json
Normal file
23
.eslintrc.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"root": true,
|
||||
"env": {
|
||||
"browser": true,
|
||||
"es6": true
|
||||
},
|
||||
"extends": [
|
||||
"standard"
|
||||
],
|
||||
"globals": {},
|
||||
"plugins": [],
|
||||
"ignorePatterns": ["node_modules/", "dist/", "webpack.config.js"],
|
||||
"rules": {
|
||||
"max-len": [
|
||||
"error",
|
||||
{
|
||||
"code": 120,
|
||||
"comments": 120
|
||||
}
|
||||
],
|
||||
"no-unused-vars": [2, {"argsIgnorePattern": "^_"}]
|
||||
}
|
||||
}
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
node_modules
|
||||
.cache
|
||||
dist
|
||||
.vscode
|
||||
|
@ -1,4 +1,4 @@
|
||||
"use strict"
|
||||
'use strict'
|
||||
|
||||
const logger = {
|
||||
log: (s) => console.log('[peertube-plugin-livechat] ' + s),
|
||||
@ -53,7 +53,7 @@ function displayButton (buttons, name, label, callback) {
|
||||
|
||||
function displayChatButtons (peertubeHelpers, uuid) {
|
||||
logger.log('Adding buttons in the DOM...')
|
||||
const p = new Promise((resolve, reject) => {
|
||||
const p = new Promise((resolve) => {
|
||||
Promise.all([
|
||||
peertubeHelpers.translate('Open chat'),
|
||||
peertubeHelpers.translate('Open chat in a new window'),
|
||||
@ -81,10 +81,10 @@ function displayChatButtons (peertubeHelpers, uuid) {
|
||||
function toggleShowHideButtons (chatOpened) {
|
||||
// showing/hiding buttons...
|
||||
document.querySelectorAll('.peertube-plugin-livechat-button-open')
|
||||
.forEach(button => button.style.display = (chatOpened === true || chatOpened === null ? 'none' : ''))
|
||||
.forEach(button => (button.style.display = (chatOpened === true || chatOpened === null ? 'none' : '')))
|
||||
|
||||
document.querySelectorAll('.peertube-plugin-livechat-button-close')
|
||||
.forEach(button => button.style.display = (chatOpened === false || chatOpened === null ? 'none' : ''))
|
||||
.forEach(button => (button.style.display = (chatOpened === false || chatOpened === null ? 'none' : '')))
|
||||
}
|
||||
|
||||
function openChat () {
|
||||
@ -92,14 +92,14 @@ function openChat () {
|
||||
const uuid = lastUUID
|
||||
if (!uuid) {
|
||||
logger.log('No current uuid.')
|
||||
return reject()
|
||||
return reject(new Error('No current uuid.'))
|
||||
}
|
||||
|
||||
logger.info('Trying to load the chat for video ' + uuid + '.')
|
||||
const iframeUri = getIframeUri(uuid)
|
||||
if (!iframeUri) {
|
||||
logger.error('Incorrect iframe uri')
|
||||
return reject()
|
||||
return reject(new Error('Incorrect iframe uri'))
|
||||
}
|
||||
const additionalStyles = settings['chat-style'] || ''
|
||||
|
||||
@ -127,6 +127,7 @@ function openChat () {
|
||||
|
||||
resolve()
|
||||
})
|
||||
return p
|
||||
}
|
||||
|
||||
function closeChat () {
|
||||
@ -157,7 +158,7 @@ function register ({ registerHook, peertubeHelpers }) {
|
||||
const nonLiveOn = !!settings['chat-all-non-lives']
|
||||
const uuids = parseUUIDs(settings['chat-videos-list'])
|
||||
const iframeUri = settings['chat-uri'] || ''
|
||||
if ( iframeUri === '' ) {
|
||||
if (iframeUri === '') {
|
||||
logger.log('no uri, can\'t add chat.')
|
||||
return
|
||||
}
|
||||
|
13
main.js
13
main.js
@ -1,11 +1,11 @@
|
||||
async function register ({
|
||||
registerHook,
|
||||
_registerHook,
|
||||
registerSetting,
|
||||
settingsManager,
|
||||
storageManager,
|
||||
videoCategoryManager,
|
||||
videoLicenceManager,
|
||||
videoLanguageManager
|
||||
_settingsManager,
|
||||
_storageManager,
|
||||
_videoCategoryManager,
|
||||
_videoLicenceManager,
|
||||
_videoLanguageManager
|
||||
}) {
|
||||
registerSetting({
|
||||
name: 'chat-auto-display',
|
||||
@ -63,7 +63,6 @@ async function register ({
|
||||
}
|
||||
|
||||
async function unregister () {
|
||||
return
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
1370
package-lock.json
generated
1370
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -17,6 +17,11 @@
|
||||
],
|
||||
"devDependencies": {
|
||||
"@purtuga/esm-webpack-plugin": "^1.1.1",
|
||||
"eslint": "^7.20.0",
|
||||
"eslint-config-standard": "^16.0.2",
|
||||
"eslint-plugin-import": "^2.22.1",
|
||||
"eslint-plugin-node": "^11.1.0",
|
||||
"eslint-plugin-promise": "^4.3.1",
|
||||
"webpack": "^4.41.2",
|
||||
"webpack-cli": "^3.3.10"
|
||||
},
|
||||
@ -31,7 +36,8 @@
|
||||
"library": "./main.js",
|
||||
"scripts": {
|
||||
"prepare": "npm run build",
|
||||
"build": "webpack --mode=production"
|
||||
"build": "webpack --mode=production",
|
||||
"lint": "npx eslint --ext .js ."
|
||||
},
|
||||
"staticDirs": {},
|
||||
"translations": {
|
||||
|
Loading…
x
Reference in New Issue
Block a user