diff --git a/src/lib/auth-utils.js b/src/lib/auth-utils.js index 673c3c38c..67e7142dc 100644 --- a/src/lib/auth-utils.js +++ b/src/lib/auth-utils.js @@ -20,11 +20,11 @@ export function allow_action(action) { export function getDefaultPlugins() { return { - authenticate: function(user, password, cb) { + authenticate(user, password, cb) { cb(ErrorCode.getForbidden(API_ERROR.BAD_USERNAME_PASSWORD)); }, - add_user: function(user, password, cb) { + add_user(user, password, cb) { return cb(ErrorCode.getConflict(API_ERROR.BAD_USERNAME_PASSWORD)); }, diff --git a/src/lib/config-utils.js b/src/lib/config-utils.js index 59a0c5c11..2b712402d 100644 --- a/src/lib/config-utils.js +++ b/src/lib/config-utils.js @@ -30,7 +30,7 @@ export function normalizeUserlist(oldFormat: any, newFormat: any) { } // if it's a string, split it to array - if (typeof(arguments[i]) === 'string') { + if (_.isString(arguments[i])) { result.push(arguments[i].split(/\s+/)); } else if (Array.isArray(arguments[i])) { result.push(arguments[i]); @@ -60,7 +60,7 @@ export function uplinkSanityCheck(uplinks: UpLinksConfList, users: any = BLACKLI export function sanityCheckNames(item: string, users: any) { assert(item !== 'all' && item !== 'owner' && item !== 'anonymous' && item !== 'undefined' && item !== 'none', 'CONFIG: reserved uplink name: ' + item); assert(!item.match(/\s/), 'CONFIG: invalid uplink name: ' + item); - assert(users[item] == null, 'CONFIG: duplicate uplink name: ' + item); + assert(_.isNil(users[item]), 'CONFIG: duplicate uplink name: ' + item); users[item] = true; return users; @@ -87,12 +87,7 @@ export function hasProxyTo(pkg: string, upLink: string, packages: PackageList): const matchedPkg: MatchedPackage = (getMatchedPackagesSpec(pkg, packages): MatchedPackage); const proxyList = typeof matchedPkg !== 'undefined' ? matchedPkg.proxy : []; if (proxyList) { - return proxyList.reduce((prev, curr) => { - if (upLink === curr) { - return true; - } - return prev; - }, false); + return proxyList.some((curr) => upLink === curr); } return false; diff --git a/src/lib/config.js b/src/lib/config.js index 823b57be4..c28673380 100644 --- a/src/lib/config.js +++ b/src/lib/config.js @@ -78,11 +78,11 @@ class Config implements AppConfig { this.packages = normalisePackageAccess(self.packages); // loading these from ENV if aren't in config - allowedEnvConfig.forEach((function(v) { - if (!(v in self)) { - self[v] = process.env[v] || process.env[v.toUpperCase()]; + allowedEnvConfig.forEach((envConf) => { + if (!(envConf in self)) { + self[envConf] = process.env[envConf] || process.env[envConf.toUpperCase()]; } - })); + }); // unique identifier of self server (or a cluster), used to avoid loops if (!this.server_id) { diff --git a/types/index.js b/types/index.js index a4698005b..451a624c3 100644 --- a/types/index.js +++ b/types/index.js @@ -96,13 +96,6 @@ export interface IStorageHandler { _updateVersionsHiddenUpLink(versions: Versions, upLink: IProxy): void; } -// export interface ConfigHandler { -// checkSecretKey(token: string): string; -// hasProxyTo(pkg: string, upLink: string): boolean; -// getMatchedPackagesSpec(storage: string): verdaccio$PackageAccess | void; -// [key: string]: number; -// } - export type StartUpConfig = { storage: string; self_path: string;