lint fixes

This commit is contained in:
Kyle Spearrin 2017-07-14 15:34:05 -04:00
parent cf850838b5
commit e4baa19232
24 changed files with 94 additions and 83 deletions

View File

@ -23,7 +23,16 @@ paths.cssDir = paths.popupDir + 'css/';
paths.webfontsDir = './src/webfonts/';
gulp.task('lint', function () {
return gulp.src(paths.popupDir + 'app/**/*.js')
return gulp.src([
paths.popupDir + '**/*.js',
'./src/services/**/*.js',
'./src/notification/**/*.js',
'./src/models/**/*.js',
'./src/scripts/**/*.js',
//'./src/content/**/*.js',
'./src/overlay/**/*.js',
'./src/background.js'
])
.pipe(jshint())
.pipe(jshint.reporter('default'));
});

View File

@ -386,7 +386,7 @@ function messageTab(tabId, command, data, callback) {
};
if (data) {
obj['data'] = data;
obj.data = data;
}
chrome.tabs.sendMessage(tabId, obj, function () {

View File

@ -5,13 +5,13 @@
if (window.location.hostname.indexOf('bitwarden.com') === -1) {
chrome.storage.local.get('neverDomains', function (obj) {
var domains = obj['neverDomains'];
var domains = obj.neverDomains;
if (domains && domains.hasOwnProperty(window.location.hostname)) {
return;
}
chrome.storage.local.get('disableAddLoginNotification', function (obj) {
if (!obj || !obj['disableAddLoginNotification']) {
if (!obj || !obj.disableAddLoginNotification) {
chrome.runtime.sendMessage({
command: 'bgCollectPageDetails'
});

View File

@ -1,7 +1,7 @@
// THIS FILE IS NOT CURRENTLY IN USE
// IT IS NOT LOADED IN THE MANIFEST
!(function () {
(function () {
chrome.runtime.onMessage.addListener(function (msg, sender, sendResponse) {
if (msg.command === 'openOverlayPopup') {
closePopup();

View File

@ -41,7 +41,7 @@ var TokenRequest = function (email, masterPasswordHash, provider, token, remembe
obj.devicePushToken = this.device.pushToken;
}
if (this.token && this.provider != null && (typeof this.provider !== 'undefined')) {
if (this.token && this.provider !== null && (typeof this.provider !== 'undefined')) {
obj.twoFactorToken = this.token;
obj.twoFactorProvider = this.provider;
obj.twoFactorRemember = this.remember ? '1' : '0';

View File

@ -149,7 +149,7 @@ var Folder = function (obj, alreadyEncrypted) {
}
};
!function () {
(function () {
CipherString.prototype.decrypt = function (orgId) {
if (this.decryptedValue) {
var deferred = Q.defer();
@ -274,4 +274,4 @@ var Folder = function (obj, alreadyEncrypted) {
return deferred.promise;
};
}();
})();

View File

@ -10,7 +10,7 @@ window[window.GoogleAnalyticsObject] = function (action, param1, param2, param3,
chrome.storage.local.get('disableGa', function (obj) {
// Default for Firefox is disabled.
if ((isFirefox && obj['disableGa'] === undefined) || obj['disableGa']) {
if ((isFirefox && obj.disableGa === undefined) || obj.disableGa) {
return;
}

View File

@ -4,7 +4,7 @@
this.info = infoCallback;
this.iframe = null;
this.connectorLink = document.createElement('a');
};
}
U2f.prototype.init = function (data) {
var self = this;
@ -44,7 +44,7 @@ U2f.prototype.validMessage = function (event) {
}
return event.data.indexOf('success|') === 0 || event.data.indexOf('error|') === 0 || event.data.indexOf('info|') === 0;
}
};
U2f.prototype.stop = function () {
this.sendMessage('stop');
@ -67,4 +67,4 @@ U2f.prototype.base64Encode = function (str) {
return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function (match, p1) {
return String.fromCharCode('0x' + p1);
}));
}
};

View File

@ -25,7 +25,7 @@ function ApiService(tokenService, appIdService, utilsService, logoutCallback) {
this.utilsService = utilsService;
initApiService();
};
}
function initApiService() {
// Auth APIs
@ -482,7 +482,7 @@ function initApiService() {
console.log('Logging out from apiService at ' + new Date() + '. Reason: Status ' + jqXHR.status + '.');
console.log(jqXHR);
if (self && self.logoutCallback) {
self.logoutCallback(true, function () { })
self.logoutCallback(true, function () { });
}
else {
chrome.runtime.sendMessage({ command: 'logout', expired: true });
@ -539,7 +539,7 @@ function initApiService() {
});
});
return deferred.promise
return deferred.promise;
}
function refreshToken(self, success, error) {
@ -588,4 +588,4 @@ function initApiService() {
}
});
}
};
}

View File

@ -1,6 +1,6 @@
function AppIdService() {
initAppIdService();
};
}
function initAppIdService() {
AppIdService.prototype.getAppId = function (callback) {
@ -41,4 +41,4 @@ function initAppIdService() {
return v.toString(16);
});
}
};
}

View File

@ -1,6 +1,6 @@
function AutofillService() {
initAutofill();
};
}
function initAutofill() {
AutofillService.prototype.generateFillScript = function (pageDetails, fillUsername, fillPassword) {
@ -29,9 +29,10 @@ function initAutofill() {
passwordFields = loadPasswordFields(pageDetails, true);
}
var i;
for (var formKey in pageDetails.forms) {
var passwordFieldsForForm = [];
for (var i = 0; i < passwordFields.length; i++) {
for (i = 0; i < passwordFields.length; i++) {
if (formKey === passwordFields[i].form) {
passwordFieldsForForm.push(passwordFields[i]);
}
@ -156,4 +157,4 @@ function initAutofill() {
return usernameField;
}
};
}

View File

@ -67,4 +67,4 @@ function ConstantsService() {
}
]
};
};
}

View File

@ -1,7 +1,7 @@
function CryptoService(constantsService) {
this.constantsService = constantsService;
initCryptoService(constantsService);
};
}
function initCryptoService(constantsService) {
var _key,
@ -34,7 +34,7 @@ function initCryptoService(constantsService) {
callback();
});
});
}
};
CryptoService.prototype.setKeyHash = function (keyHash, callback) {
if (!callback || typeof callback !== 'function') {
@ -48,7 +48,7 @@ function initCryptoService(constantsService) {
}, function () {
callback();
});
}
};
CryptoService.prototype.setEncKey = function (encKey) {
var deferred = Q.defer();
@ -66,7 +66,7 @@ function initCryptoService(constantsService) {
});
return deferred.promise;
}
};
CryptoService.prototype.setEncPrivateKey = function (encPrivateKey) {
var deferred = Q.defer();
@ -84,7 +84,7 @@ function initCryptoService(constantsService) {
});
return deferred.promise;
}
};
CryptoService.prototype.setOrgKeys = function (orgs) {
var deferred = Q.defer();
@ -101,7 +101,7 @@ function initCryptoService(constantsService) {
});
return deferred.promise;
}
};
CryptoService.prototype.getKey = function () {
var deferred = Q.defer();
@ -410,7 +410,7 @@ function initCryptoService(constantsService) {
});
}
plainValueEncoding = plainValueEncoding || 'utf8'
plainValueEncoding = plainValueEncoding || 'utf8';
if (plainValueEncoding === 'utf8') {
plainValue = fromUtf8ToArray(plainValue);
}
@ -428,7 +428,7 @@ function initCryptoService(constantsService) {
return aesEncrypt(this, plainValue, key).then(function (encValue) {
var macLen = 0;
if (encValue.mac) {
macLen = encValue.mac.length
macLen = encValue.mac.length;
}
var encBytes = new Uint8Array(1 + encValue.iv.length + macLen + encValue.ct.length);
@ -480,7 +480,7 @@ function initCryptoService(constantsService) {
}
CryptoService.prototype.decrypt = function (cipherString, key, outputEncoding) {
outputEncoding = outputEncoding || 'utf8'
outputEncoding = outputEncoding || 'utf8';
var ivBuf = fromB64ToArray(cipherString.initializationVector).buffer;
var ctBuf = fromB64ToArray(cipherString.cipherText).buffer;
@ -615,14 +615,14 @@ function initCryptoService(constantsService) {
padding = {
name: 'RSA-OAEP',
hash: { name: 'SHA-256' }
}
};
break;
case constantsService.encType.Rsa2048_OaepSha1_B64:
case constantsService.encType.Rsa2048_OaepSha1_HmacSha256_B64:
padding = {
name: 'RSA-OAEP',
hash: { name: 'SHA-1' }
}
};
break;
default:
throw 'encType unavailable.';
@ -853,4 +853,4 @@ function initCryptoService(constantsService) {
}
return arr;
}
};
}

View File

@ -6,11 +6,11 @@ function FolderService(cryptoService, userService, apiService, i18nService) {
this.decryptedFolderCache = null;
initFolderService();
};
}
function initFolderService() {
FolderService.prototype.clearCache = function () {
this.decryptedFolderCache = null
this.decryptedFolderCache = null;
};
FolderService.prototype.encrypt = function (folder) {
@ -112,12 +112,12 @@ function initFolderService() {
if (!folder.id) {
self.apiService.postFolder(request, apiSuccess, function (response) {
handleError(response, deferred)
handleError(response, deferred);
});
}
else {
self.apiService.putFolder(folder.id, request, apiSuccess, function (response) {
handleError(response, deferred)
handleError(response, deferred);
});
}
@ -251,7 +251,7 @@ function initFolderService() {
deferred.resolve();
});
}, function (response) {
handleError(response, deferred)
handleError(response, deferred);
});
return deferred.promise;
@ -260,4 +260,4 @@ function initFolderService() {
function handleError(error, deferred) {
deferred.reject(error);
}
};
}

View File

@ -7,4 +7,4 @@ function i18nService() {
throw 'set not allowed for i18n';
}
});
};
}

View File

@ -8,7 +8,7 @@
this.refreshBadgeAndMenu = refreshBadgeAndMenu;
initLockService(this);
};
}
function initLockService(self) {
checkLock();
@ -128,4 +128,4 @@ function initLockService(self) {
return deferred.promise;
}
};
}

View File

@ -6,11 +6,11 @@ function LoginService(cryptoService, userService, apiService, settingsService) {
this.decryptedLoginCache = null;
initLoginService();
};
}
function initLoginService() {
LoginService.prototype.clearCache = function () {
this.decryptedLoginCache = null
this.decryptedLoginCache = null;
};
LoginService.prototype.encrypt = function (login) {
@ -185,12 +185,12 @@ function initLoginService() {
if (!login.id) {
self.apiService.postLogin(request, apiSuccess, function (response) {
handleError(response, deferred)
handleError(response, deferred);
});
}
else {
self.apiService.putLogin(login.id, request, apiSuccess, function (response) {
handleError(response, deferred)
handleError(response, deferred);
});
}
@ -420,7 +420,7 @@ function initLoginService() {
});
}
else {
callback()
callback();
}
});
});
@ -460,4 +460,4 @@ function initLoginService() {
deferred.reject(error.message);
return;
}
};
}

View File

@ -2,7 +2,7 @@
this.optionsCache = null;
initPasswordGenerationService();
};
}
function initPasswordGenerationService() {
var optionsKey = 'passwordGenerationOptions';
@ -181,4 +181,4 @@ function initPasswordGenerationService() {
return deferred.promise;
};
};
}

View File

@ -3,11 +3,11 @@ function SettingsService(userService) {
this.settingsCache = null;
initSettingsService();
};
}
function initSettingsService() {
SettingsService.prototype.clearCache = function () {
this.settingsCache = null
this.settingsCache = null;
};
SettingsService.prototype.getSettings = function (callback) {
@ -103,4 +103,4 @@ function initSettingsService() {
function handleError(error, deferred) {
deferred.reject(error);
}
};
}

View File

@ -11,7 +11,7 @@
this.lastRevisionCheck = null;
initSyncService();
};
}
function initSyncService() {
SyncService.prototype.fullSync = function (forceSync, callback) {
@ -133,7 +133,7 @@ function initSyncService() {
deferred.reject();
});
return deferred.promise
return deferred.promise;
}
function syncFolders(self, userId) {
@ -153,7 +153,7 @@ function initSyncService() {
deferred.reject();
});
return deferred.promise
return deferred.promise;
}
function syncCiphers(self, userId) {
@ -176,7 +176,7 @@ function initSyncService() {
deferred.reject();
});
return deferred.promise
return deferred.promise;
}
function syncSettings(self, userId) {
@ -203,7 +203,7 @@ function initSyncService() {
});
return deferred.promise;
};
}
SyncService.prototype.getLastSync = function (callback) {
if (!callback || typeof callback !== 'function') {
@ -250,4 +250,4 @@ function initSyncService() {
this.syncInProgress = false;
chrome.runtime.sendMessage({ command: 'syncCompleted', successfully: successfully });
};
};
}

View File

@ -1,6 +1,6 @@
function TokenService() {
initTokenService();
};
}
function initTokenService() {
var _token,
@ -287,5 +287,5 @@ function initTokenService() {
//polyfill https://github.com/davidchambers/Base64.js
return window.decodeURIComponent(escape(window.atob(output)));
};
};
}
}

View File

@ -1,6 +1,6 @@
function TotpService() {
initTotpService();
};
}
function initTotpService() {
var b32Chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567';
@ -41,7 +41,8 @@ function initTotpService() {
var b32tohex = function (s) {
s = s.toUpperCase();
var cleanedInput = '';
for (var i = 0; i < s.length; i++) {
var i;
for (i = 0; i < s.length; i++) {
if (b32Chars.indexOf(s[i]) < 0) {
continue;
}
@ -52,14 +53,14 @@ function initTotpService() {
var bits = '';
var hex = '';
for (var i = 0; i < s.length; i++) {
for (i = 0; i < s.length; i++) {
var byteIndex = b32Chars.indexOf(s.charAt(i));
if (byteIndex < 0) {
continue;
}
bits += leftpad(byteIndex.toString(2), 5, '0');
}
for (var i = 0; i + 4 <= bits.length; i += 4) {
for (i = 0; i + 4 <= bits.length; i += 4) {
var chunk = bits.substr(i, 4);
hex = hex + parseInt(chunk, 2).toString(16);
}
@ -104,4 +105,4 @@ function initTotpService() {
return otp;
});
};
};
}

View File

@ -4,7 +4,7 @@
this.cryptoService = cryptoService;
initUserService();
};
}
function initUserService() {
var userIdKey = 'userId',
@ -51,7 +51,7 @@ function initUserService() {
deferred.resolve();
});
return deferred.promise
return deferred.promise;
};
UserService.prototype.getUserId = function (callback) {
@ -105,7 +105,7 @@ function initUserService() {
deferred.resolve(_stamp);
});
return deferred.promise
return deferred.promise;
};
UserService.prototype.clear = function (callback) {
@ -142,4 +142,4 @@ function initUserService() {
});
});
};
};
}

View File

@ -3,7 +3,7 @@ function UtilsService() {
this.browserCache = null;
this.analyticsIdCache = null;
};
}
function initUtilsService() {
UtilsService.prototype.getBrowser = function () {
@ -29,19 +29,19 @@ function initUtilsService() {
UtilsService.prototype.isFirefox = function () {
return this.getBrowser() === 'firefox';
}
};
UtilsService.prototype.isChrome = function () {
return this.getBrowser() === 'chrome';
}
};
UtilsService.prototype.isEdge = function () {
return this.getBrowser() === 'edge';
}
};
UtilsService.prototype.isOpera = function () {
return this.getBrowser() === 'opera';
}
};
UtilsService.prototype.analyticsId = function () {
if (this.analyticsIdCache) {
@ -62,7 +62,7 @@ function initUtilsService() {
}
return this.analyticsIdCache;
}
};
UtilsService.prototype.getDeviceType = function () {
if (this.isChrome()) {
@ -79,7 +79,7 @@ function initUtilsService() {
}
return -1;
}
};
UtilsService.prototype.initListSectionItemListeners = function (doc, angular) {
if (!doc) {
@ -127,7 +127,7 @@ function initUtilsService() {
doc.on('blur', '.list-section-item input, .list-section-item select, .list-section-item textarea', function (e) {
$(this).parent().removeClass('active');
});
}
};
UtilsService.prototype.getDomain = function (uriString) {
if (!uriString) {
@ -171,7 +171,7 @@ function initUtilsService() {
}
return null;
}
};
UtilsService.prototype.getHostname = function (uriString) {
if (!uriString) {
@ -198,10 +198,10 @@ function initUtilsService() {
}
return null;
}
};
function validIpAddress(ipString) {
var ipRegex = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
return ipRegex.test(ipString);
}
};
}