Skip to content

Commit

Permalink
Fix all lib/ files with ESLint rules with 0 errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
gunta committed Jan 19, 2016
1 parent 994977e commit 434f63b
Show file tree
Hide file tree
Showing 69 changed files with 654 additions and 625 deletions.
8 changes: 4 additions & 4 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"no-new-wrappers": 2,
"no-new": 2,
"no-octal-escape": 2,
"no-octal": 2,
"no-octal": 1, // TODO: accept until we use ES6 0o755 notation
"no-param-reassign": 2,
"no-process-env": 0, // `2` is recommended
"no-proto": 2,
Expand All @@ -62,7 +62,7 @@
"no-useless-call": 2, // `2` is recommended
"no-useless-concat": 2,
"no-void": 2,
"no-warning-comments": 1, // `[0, { "terms": ["todo", "fixme", "xxx"], "location": "start" }]` is recommended
"no-warning-comments": [1, { "terms": ["todo", "fixme", "@todo", "@fixme"]}], // `[0, { "terms": ["todo", "fixme", "xxx"], "location": "start" }]` is recommended
"no-with": 2,
"radix": 1, // `2` is recommended
"vars-on-top": 0, // `2` is recommended TODO: review this
Expand All @@ -78,15 +78,15 @@
"no-label-var": 2,
"no-shadow-restricted-names": 2,
"no-shadow": 0, // TODO: 1 may be ok
"no-undefined": 2,
"no-undefined": 1,
"no-unused-vars": 1,
"no-use-before-define": 1, // TODO: 0 or 2 may be ok, sometimes there are ciclic dependencies

// Style
"array-bracket-spacing": [2, "never"], // optionally set `[2, "never", {"singleValue": true, "objectsInArrays": true, "arraysInArrays": true}]`
"block-spacing": [2, "always"], // optionally set `[2, "always"]`
"brace-style": [2, "stroustrup", {"allowSingleLine": false}],
"camelcase": [2, {"properties": "always"}], // TODO: 2 might be too much
"camelcase": [2, {"properties": "never"}], // TODO: 2 might be too much
"comma-spacing": [2, {"before": false, "after": true}],
"comma-style": [1, "first"], // optionally set `[2, "first", {"exceptions": {"ArrayExpression": true, "ObjectExpression": true}}]`
"computed-property-spacing": [2, "never"],
Expand Down
19 changes: 11 additions & 8 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@ program
.description('migrates the database to the latest version')
.action(function() {
var log = logger.createLogger('cli:migrate')
, db = require('./db')
var db = require('./db')

db.setup()
.then(function() {
Expand All @@ -924,21 +924,21 @@ program
, 1)
.action(function(model, options) {
var log = logger.createLogger('cli:generate-fake-device')
, fake = require('./util/fakedevice')
, n = options.number
var fake = require('./util/fakedevice')
var n = options.number

function next() {
function nextDevice() {
return fake.generate(model)
.then(function(serial) {
log.info('Created fake device "%s"', serial)

if (--n) {
return next()
return nextDevice()
}
})
}

next()
nextDevice()
.then(function() {
process.exit(0)
})
Expand Down Expand Up @@ -1069,7 +1069,7 @@ program
, 'whether to lock rotation when devices are being used')
.action(function(serials, options) {
var log = logger.createLogger('cli:local')
, procutil = require('./util/procutil')
var procutil = require('./util/procutil')

// Each forked process waits for signals to stop, and so we run over the
// default limit of 10. So, it's not a leak, but a refactor wouldn't hurt.
Expand Down Expand Up @@ -1156,7 +1156,10 @@ program
'http://%s:%d/auth/%s/'
, options.publicIp
, options.poorxyPort
, ({oauth2: 'oauth', saml2: 'saml'}[options.authType]) || options.authType
, {
oauth2: 'oauth'
, saml2: 'saml'
}[options.authType] || options.authType
)
, '--websocket-url', util.format(
'http://%s:%d/'
Expand Down
2 changes: 1 addition & 1 deletion lib/db/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ dbapi.saveUserAccessToken = function(email, token) {
dbapi.removeUserAccessToken = function(email, title) {
return db.run(r.table('accessTokens').getAll(email, {
index: 'email'
}).filter({'title': title}).delete())
}).filter({title: title}).delete())
}

dbapi.loadAccessTokens = function(email) {
Expand Down
2 changes: 1 addition & 1 deletion lib/db/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function connect() {
// Export connection as a Promise
db.connect = (function() {
var connection
, queue = []
var queue = []

lifecycle.observe(function() {
if (connection) {
Expand Down
2 changes: 1 addition & 1 deletion lib/db/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module.exports = function(conn) {

function createIndex(table, index, options) {
var args = [index]
, rTable = r.table(table)
var rTable = r.table(table)

if (options) {
if (options.indexFunction) {
Expand Down
8 changes: 4 additions & 4 deletions lib/units/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ var markdownServe = require('markdown-serve')

module.exports = function(options) {
var log = logger.createLogger('app')
, app = express()
, server = http.createServer(app)
var app = express()
var server = http.createServer(app)

app.use('/static/wiki', markdownServe.middleware({
rootDirectory: pathutil.root('node_modules/stf-wiki')
Expand All @@ -50,9 +50,9 @@ module.exports = function(options) {
}))
}
else {
log.info('Using webpack')
// Keep webpack-related requires here, as our prebuilt package won't
// have them at all.
log.info('Using webpack')
var webpackServerConfig = require('./../../../webpack.config').webpackServer
app.use('/static/app/build',
require('./middleware/webpack')(webpackServerConfig))
Expand Down Expand Up @@ -115,7 +115,7 @@ module.exports = function(options) {
}

if (options.userProfileUrl) {
state.config.userProfileUrl = (function () {
state.config.userProfileUrl = (function() {
return options.userProfileUrl
})()
}
Expand Down
2 changes: 1 addition & 1 deletion lib/units/app/middleware/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = function(options) {
if (req.query.jwt) {
// Coming from auth client
var data = jwtutil.decode(req.query.jwt, options.secret)
, redir = urlutil.removeParam(req.url, 'jwt')
var redir = urlutil.removeParam(req.url, 'jwt')
if (data) {
// Redirect once to get rid of the token
dbapi.saveUserAfterLogin({
Expand Down
15 changes: 7 additions & 8 deletions lib/units/app/middleware/webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ var globalOptions = require('../../../../webpack.config').webpack
// Similar to webpack-dev-middleware, but integrates with our custom
// lifecycle, behaves more like normal express middleware, and removes
// all unnecessary features.
module.exports = function(options) {
module.exports = function(localOptions) {
var log = logger.createLogger('middleware:webpack')
options = _.defaults(options || {}, globalOptions)
var options = _.defaults(localOptions || {}, globalOptions)

var compiler = webpack(options)
var fs = compiler.outputFileSystem = new MemoryFileSystem()
Expand Down Expand Up @@ -77,12 +77,11 @@ module.exports = function(options) {
if (valid) {
return Promise.resolve()
}
else {
log.info('Waiting for bundle to finish')
var resolver = Promise.defer()
queue.push(resolver)
return resolver.promise
}

log.info('Waiting for bundle to finish')
var resolver = Promise.defer()
queue.push(resolver)
return resolver.promise
}

return function(req, res, next) {
Expand Down
6 changes: 3 additions & 3 deletions lib/units/auth/ldap.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ var lifecycle = require('../../util/lifecycle')

module.exports = function(options) {
var log = logger.createLogger('auth-ldap')
, app = express()
, server = Promise.promisifyAll(http.createServer(app))
var app = express()
var server = Promise.promisifyAll(http.createServer(app))

lifecycle.observe(function() {
log.info('Waiting for client connections to end')
Expand All @@ -46,7 +46,7 @@ module.exports = function(options) {
app.use('/static/auth/ldap', serveStatic(pathutil.resource('auth/ldap')))

app.use(function(req, res, next) {
res.cookie('XSRF-TOKEN', req.csrfToken());
res.cookie('XSRF-TOKEN', req.csrfToken())
next()
})

Expand Down
6 changes: 3 additions & 3 deletions lib/units/auth/mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ var lifecycle = require('../../util/lifecycle')

module.exports = function(options) {
var log = logger.createLogger('auth-mock')
, app = express()
, server = Promise.promisifyAll(http.createServer(app))
var app = express()
var server = Promise.promisifyAll(http.createServer(app))

lifecycle.observe(function() {
log.info('Waiting for client connections to end')
Expand All @@ -45,7 +45,7 @@ module.exports = function(options) {
app.use('/static/auth/mock', serveStatic(pathutil.resource('auth/mock')))

app.use(function(req, res, next) {
res.cookie('XSRF-TOKEN', req.csrfToken());
res.cookie('XSRF-TOKEN', req.csrfToken())
next()
})

Expand Down
4 changes: 2 additions & 2 deletions lib/units/auth/oauth2/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ var Strategy = require('./strategy')

module.exports = function(options) {
var log = logger.createLogger('auth-oauth2')
, app = express()
, server = http.createServer(app)
var app = express()
var server = http.createServer(app)

app.set('strict routing', true)
app.set('case sensitive routing', true)
Expand Down
13 changes: 6 additions & 7 deletions lib/units/auth/oauth2/strategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@ Strategy.prototype.userProfile = function(accessToken, callback) {
if (err) {
return callback(err)
}
else {
try {
return callback(null, JSON.parse(data))
}
catch (err) {
return callback(err)
}

try {
return callback(null, JSON.parse(data))
}
catch (err) {
return callback(err)
}
})
}
Expand Down
14 changes: 7 additions & 7 deletions lib/units/auth/saml2.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ var jwtutil = require('../../util/jwtutil')

module.exports = function(options) {
var log = logger.createLogger('auth-saml2')
, app = express()
, server = http.createServer(app)
var app = express()
var server = http.createServer(app)

app.set('strict routing', true)
app.set('case sensitive routing', true)
app.use(bodyParser.urlencoded({ extended: false }))
app.use(bodyParser.urlencoded({extended: false}))
app.use(passport.initialize())

passport.serializeUser(function(user, done) {
done(null, user);
});
done(null, user)
})
passport.deserializeUser(function(user, done) {
done(null, user);
});
done(null, user)
})

var verify = function(profile, done) {
return done(null, profile)
Expand Down
22 changes: 11 additions & 11 deletions lib/units/device/plugins/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module.exports = syrup.serial()
return service.getAccounts({type: type})
.timeout(30000)
.then(function(accounts) {
if(accounts.indexOf(account) >= 0) {
if (accounts.indexOf(account) >= 0) {
return true
}
throw new Error('The account is not added')
Expand All @@ -28,7 +28,7 @@ module.exports = syrup.serial()
router.on(wire.AccountCheckMessage, function(channel, message) {
var reply = wireutil.reply(options.serial)

log.info('Checking if account "%s" is added',message.account)
log.info('Checking if account "%s" is added', message.account)
checkAccount(message.type, message.account)
.then(function() {
push.send([
Expand All @@ -55,7 +55,7 @@ module.exports = syrup.serial()
.then(function(accounts) {
push.send([
channel
, reply.okay('success',accounts)
, reply.okay('success', accounts)
])
})
.catch(function(err) {
Expand Down Expand Up @@ -113,12 +113,12 @@ module.exports = syrup.serial()

router.on(wire.AccountAddMessage, function(channel, message) {
var reply = wireutil.reply(options.serial)
var type = "com.google"
var account = message.user + "@gmail.com";
var type = 'com.google'
var account = message.user + '@gmail.com'

log.info('Adding Google Account automatedly')

var version = identity.version.substring(0,3)
var version = identity.version.substring(0, 3)

function automation() {
switch (version) {
Expand Down Expand Up @@ -235,8 +235,8 @@ module.exports = syrup.serial()
.then(function() {
return service.pressKey('enter')
})
//case '4.3': // tested: 4.3
//case '4.4': // tested: 4.4.2
// case '4.3': // tested: 4.3
// case '4.4': // tested: 4.4.2
default:
return service.pressKey('tab').delay(1000)
.then(function() {
Expand Down Expand Up @@ -293,17 +293,17 @@ module.exports = syrup.serial()
.delay(5000)
.then(function() {
// Just in case the add account menu has any button focused
return touch.tap({x:0, y:0.9})
return touch.tap({x: 0, y: 0.9})
})
.delay(500)
.then(function() {
return automation()
})
.delay(3000)
.then(function () {
.then(function() {
return service.pressKey('home')
})
.then(function () {
.then(function() {
return checkAccount(type, account)
})
.then(function() {
Expand Down
13 changes: 11 additions & 2 deletions lib/units/device/plugins/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,17 @@ module.exports = syrup.serial()

function compareIgnoreCase(a, b) {
var la = (a || '').toLowerCase()
, lb = (b || '').toLowerCase()
return la === lb ? 0 : (la < lb ? -1 : 1)
var lb = (b || '').toLowerCase()

if (la === lb) {
return 0
}
else if (la < lb) {
return -1
}
else {
return 1
}
}

function updateBrowsers(data) {
Expand Down
1 change: 0 additions & 1 deletion lib/units/device/plugins/cleanup.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ module.exports = syrup.serial()
group.on('leave', function() {
plugin.removePackages()
})

})
.return(plugin)
})
Loading

0 comments on commit 434f63b

Please sign in to comment.