diff --git a/.eslintrc.yml b/.eslintrc.yml index a7b620b8..36db78a8 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -20,4 +20,9 @@ rules: strict: - 2 - global - guard-for-in: 0 + guard-for-in: 1 + no-param-reassign: + - 2 + - props: false + arrow-body-style: 1 + max-len: 1 diff --git a/package.json b/package.json index 609731bb..0be3bf03 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "devDependencies": { "bower": "^1.7.1", "eslint": "^1.10.3", - "eslint-config-airbnb": "^2.0.0", + "eslint-config-airbnb": "^4.0.0", "fs-extra": "^0.26.2", "grunt": "^0.4.5", "grunt-cli": "^0.1.13", diff --git a/scripts/archive.js b/scripts/archive.js index 1dadfee4..c0d9974b 100644 --- a/scripts/archive.js +++ b/scripts/archive.js @@ -41,7 +41,7 @@ function compress(sourcePath, destPath) { 'a', '-r', destPath, - '.' + path.sep + path.join(sourcePath, '*'), + path.join('.', sourcePath, '*'), ]); } @@ -192,13 +192,22 @@ vulcanize(rootPath); const releasePaths = helpers.getAppReleasePaths(rootPath); for (let i = 0; i < releasePaths.length; ++i) { if (releasePaths[i].label) { - createAppArchive(rootPath, releasePaths[i].path, tempPath, path.join(rootPath, 'build', 'LOOT ' + gitDesc + ' (' + releasePaths[i].label + ').7z')); + const filename = `LOOT ${gitDesc} (${releasePaths[i].label}).7z`; + createAppArchive(rootPath, + releasePaths[i].path, + tempPath, + path.join(rootPath, 'build', filename)); } else { - createAppArchive(releasePaths[i].path, path.join(rootPath, 'build', 'LOOT ' + gitDesc + '.7z')); + createAppArchive(releasePaths[i].path, + path.join(rootPath, 'build', `LOOT ${gitDesc}.7z`)); } } const binaryPaths = helpers.getApiBinaryPaths(rootPath); for (let i = 0; i < binaryPaths.length; ++i) { - createApiArchive(rootPath, binaryPaths[i].path, tempPath, path.join(rootPath, 'build', 'LOOT API ' + gitDesc + ' (' + binaryPaths[i].label + ').7z')); + const filename = `LOOT API ${gitDesc} (${binaryPaths[i].label}).7z`; + createApiArchive(rootPath, + binaryPaths[i].path, + tempPath, + path.join(rootPath, 'build', filename)); } diff --git a/scripts/vulcanize.js b/scripts/vulcanize.js index af00c399..f8965284 100755 --- a/scripts/vulcanize.js +++ b/scripts/vulcanize.js @@ -40,4 +40,4 @@ helpers.getAppReleasePaths(rootPath).forEach((releasePath) => { output: path.join(outputPath, 'index.html'), input: path.join(rootPath, 'src', 'gui', 'html', 'index.html'), }, runVulcanize); -}) +}); diff --git a/src/gui/html/js/dom.js b/src/gui/html/js/dom.js index 7e754b30..5f8c2475 100644 --- a/src/gui/html/js/dom.js +++ b/src/gui/html/js/dom.js @@ -13,9 +13,9 @@ getElementInTableRowTemplate(rowTemplateId, elementClass) { const select = document.querySelector('link[rel="import"][href$="editable-table.html"]'); if (select) { - return select.import.querySelector('#' + rowTemplateId).content.querySelector('.' + elementClass); + return select.import.querySelector(`#${rowTemplateId}`).content.querySelector(`.${elementClass}`); } - return document.querySelector('#' + rowTemplateId).content.querySelector('.' + elementClass); + return document.querySelector(`#${rowTemplateId}`).content.querySelector(`.${elementClass}`); }, show(elementId) { @@ -34,7 +34,9 @@ for (let i = 0; i < table.tBodies[0].rows.length; ++i) { const folderElements = table.tBodies[0].rows[i].getElementsByClassName('folder'); if (folderElements.length === 1) { - table.setReadOnly(table.tBodies[0].rows[i], ['delete'], folderElements[0].value === gameFolder); + table.setReadOnly(table.tBodies[0].rows[i], + ['delete'], + folderElements[0].value === gameFolder); } } }, diff --git a/src/gui/html/js/filters.js b/src/gui/html/js/filters.js index 7f229173..2581f046 100644 --- a/src/gui/html/js/filters.js +++ b/src/gui/html/js/filters.js @@ -33,15 +33,18 @@ return false; } - if (this.conflictingPluginNames.length !== 0 && this.conflictingPluginNames.indexOf(plugin.name) === -1) { + if (this.conflictingPluginNames.length !== 0 + && this.conflictingPluginNames.indexOf(plugin.name) === -1) { return false; } - if (this.hideMessagelessPlugins && plugin.getCardContent(this).messages.length === 0) { + if (this.hideMessagelessPlugins + && plugin.getCardContent(this).messages.length === 0) { return false; } - if (this.contentSearchString.length !== 0 && !plugin.getCardContent(this).containsText(this.contentSearchString)) { + if (this.contentSearchString.length !== 0 + && !plugin.getCardContent(this).containsText(this.contentSearchString)) { return false; } @@ -57,7 +60,8 @@ return false; } - if (this.hideDoNotCleanMessages && message.content.toLowerCase().indexOf(this._doNotCleanString) !== -1) { + if (this.hideDoNotCleanMessages + && message.content.toLowerCase().indexOf(this._doNotCleanString) !== -1) { return false; } diff --git a/src/gui/html/js/plugin.js b/src/gui/html/js/plugin.js index 835fae65..72a3f8b5 100644 --- a/src/gui/html/js/plugin.js +++ b/src/gui/html/js/plugin.js @@ -99,7 +99,7 @@ } /* Pad CRC string to 8 characters. */ - return ('00000000' + this._crc.toString(16).toUpperCase()).slice(-8); + return (`00000000${this._crc.toString(16).toUpperCase()}`).slice(-8); } get tags() { diff --git a/src/gui/html/js/query.js b/src/gui/html/js/query.js index 8c5c7696..a5be1158 100644 --- a/src/gui/html/js/query.js +++ b/src/gui/html/js/query.js @@ -28,7 +28,7 @@ persistent: false, onSuccess: resolve, onFailure: (errorCode, errorMessage) => { - reject(new Error('Error code: ' + errorCode + '; ' + errorMessage)); + reject(new Error(`Error code: ${errorCode}; ${errorMessage}`)); }, }); }); diff --git a/src/gui/html/js/translator.js b/src/gui/html/js/translator.js index 60720c77..1bffcfc5 100644 --- a/src/gui/html/js/translator.js +++ b/src/gui/html/js/translator.js @@ -3,7 +3,9 @@ (function exportModule(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. - define(['bower_components/Jed/jed', 'bower_components/jed-gettext-parser/jedGettextParser'], factory); + define(['bower_components/Jed/jed', + 'bower_components/jed-gettext-parser/jedGettextParser'], + factory); } else { // Browser globals root.loot = root.loot || {}; @@ -19,11 +21,11 @@ load() { const defaultTranslationData = { - 'messages': { + messages: { '': { - 'domain': 'messages', - 'lang': 'en', - 'plural_forms': 'nplurals=2; plural=(n != 1);', + domain: 'messages', + lang: 'en', + plural_forms: 'nplurals=2; plural=(n != 1);', }, }, }; @@ -34,7 +36,7 @@ translationDataPromise = Promise.resolve(defaultTranslationData); } else { translationDataPromise = new Promise((resolve, reject) => { - const url = 'loot://l10n/' + this.locale + '/LC_MESSAGES/loot.mo'; + const url = `loot://l10n/${this.locale}/LC_MESSAGES/loot.mo`; const xhr = new XMLHttpRequest(); xhr.open('GET', url); xhr.responseType = 'arraybuffer'; @@ -53,12 +55,12 @@ } return translationDataPromise.catch((error) => { - console.log('Error loading translation data: ' + error.message); // eslint-disable-line no-console + console.log(`Error loading translation data: ${error.message}`); // eslint-disable-line no-console return defaultTranslationData; }).then((result) => { this.jed = new Jed({ - 'locale_data': result, - 'domain': 'messages', + locale_data: result, + domain: 'messages', }); }); }