Skip to content
This repository has been archived by the owner on Apr 3, 2019. It is now read-only.

Commit

Permalink
refactor(lint): remove jscs, update eslint rules (#477), r=@vbudhram
Browse files Browse the repository at this point in the history
  • Loading branch information
vladikoff authored and vbudhram committed Aug 31, 2017
1 parent 176c828 commit 8bc148a
Show file tree
Hide file tree
Showing 36 changed files with 1,203 additions and 1,427 deletions.
18 changes: 7 additions & 11 deletions .eslintrc
@@ -1,11 +1,7 @@
{
"extends": "fxa/server",
"env": {
"mocha": true
},
"rules": {
"handle-callback-err": 0,
"complexity": [2, 10],
"semi": [2, "always"]
}
}
plugins:
- fxa
extends: plugin:fxa/server

rules:
handle-callback-err: 0
semi: [2, "always"]
19 changes: 0 additions & 19 deletions .jscsrc

This file was deleted.

2 changes: 2 additions & 0 deletions Dockerfile-build
@@ -1,5 +1,7 @@
FROM node:6.11.1-alpine

RUN apk add --no-cache git

RUN addgroup -g 10001 app && \
adduser -D -G app -h /app -u 10001 app
WORKDIR /app
Expand Down
4 changes: 2 additions & 2 deletions bin/purge_expired_tokens.js
Expand Up @@ -36,7 +36,7 @@ program

program.parse(process.argv);

if (!program.config) {
if (! program.config) {
program.config = 'dev';
}

Expand All @@ -45,7 +45,7 @@ process.env.NODE_ENV = program.config;
const db = require('../lib/db');
const logger = require('../lib/logging')('bin.purge_expired_tokens');

if (!program.pocketId) {
if (! program.pocketId) {
logger.error('invalid', { message: 'Required pocket client id!' });
process.exit(1);
}
Expand Down
16 changes: 0 additions & 16 deletions grunttasks/jscs.js

This file was deleted.

3 changes: 1 addition & 2 deletions grunttasks/lint.js
Expand Up @@ -8,7 +8,6 @@ module.exports = function (grunt) {
'use strict';

grunt.registerTask('lint', [
'eslint',
'jscs'
'eslint'
]);
};
6 changes: 3 additions & 3 deletions lib/auth.js
Expand Up @@ -22,19 +22,19 @@ exports.strategy = function() {
authenticate: function dogfoodStrategy(req, reply) {
var auth = req.headers.authorization;
logger.debug('check.auth', { header: auth });
if (!auth || auth.indexOf('Bearer ') !== 0) {
if (! auth || auth.indexOf('Bearer ') !== 0) {
return reply(AppError.unauthorized('Bearer token not provided'));
}
var tok = auth.split(' ')[1];

if (!validators.HEX_STRING.test(tok)) {
if (! validators.HEX_STRING.test(tok)) {
return reply(AppError.unauthorized('Illegal Bearer token'));
}

token.verify(tok).done(function tokenFound(details) {
if (details.scope.indexOf(exports.SCOPE_CLIENT_MANAGEMENT) !== -1) {
logger.debug('check.whitelist');
var blocked = !WHITELIST.some(function(re) {
var blocked = ! WHITELIST.some(function(re) {
return re.test(details.email);
});
if (blocked) {
Expand Down
4 changes: 2 additions & 2 deletions lib/auth_bearer.js
Expand Up @@ -21,12 +21,12 @@ exports.strategy = function() {
var auth = req.headers.authorization;

logger.debug(authName + '.check', { header: auth });
if (!auth || auth.indexOf('Bearer ') !== 0) {
if (! auth || auth.indexOf('Bearer ') !== 0) {
return reply(AppError.unauthorized('Bearer token not provided'));
}
var tok = auth.split(' ')[1];

if (!validators.HEX_STRING.test(tok)) {
if (! validators.HEX_STRING.test(tok)) {
return reply(AppError.unauthorized('Illegal Bearer token'));
}

Expand Down
4 changes: 2 additions & 2 deletions lib/browserid.js
Expand Up @@ -65,7 +65,7 @@ module.exports = function verifyAssertion(assertion) {
d.reject(AppError.invalidAssertion());
}

if (!body || body.status !== 'okay') {
if (! body || body.status !== 'okay') {
return error('non-okay response', body);
}
var email = body.email;
Expand All @@ -84,7 +84,7 @@ module.exports = function verifyAssertion(assertion) {
}

var claims = body.idpClaims;
if (!claims || !claims['fxa-verifiedEmail']) {
if (! claims || ! claims['fxa-verifiedEmail']) {
return error('incorrect idpClaims', claims);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/config.js
Expand Up @@ -383,7 +383,7 @@ if (Object.keys(oldKey).length) {
'openid.key.kid must differ from oldKey');
assert(oldKey.n, 'openid.oldKey.n is required');
assert(oldKey.e, 'openid.oldKey.e is required');
assert(!oldKey.d, 'openid.oldKey.d is forbidden');
assert(! oldKey.d, 'openid.oldKey.d is forbidden');
}

module.exports = conf;
12 changes: 6 additions & 6 deletions lib/db/index.js
Expand Up @@ -38,7 +38,7 @@ function convertClientToConfigFormat(client) {
if (key === 'hashedSecret' || key === 'hashedSecretPrevious') {
out[key] = unbuf(client[key]);
} else if (key === 'trusted' || key === 'canGrant') {
out[key] = !!client[key]; // db stores booleans as 0 or 1.
out[key] = !! client[key]; // db stores booleans as 0 or 1.
} else if (typeof client[key] !== 'function') {
out[key] = unbuf(client[key]);
}
Expand Down Expand Up @@ -66,7 +66,7 @@ function preClients() {
var REQUIRED_CLIENTS_KEYS = [ 'id', 'hashedSecret', 'name', 'imageUri',
'redirectUri', 'trusted', 'canGrant' ];
REQUIRED_CLIENTS_KEYS.forEach(function(key) {
if (!(key in c)) {
if (! (key in c)) {
var data = { key: key, name: c.name || 'unknown' };
logger.error('client.missing.keys', data);
err = new Error('Client config has missing keys');
Expand All @@ -77,13 +77,13 @@ function preClients() {
}

// ensure booleans are boolean and not undefined
c.trusted = !!c.trusted;
c.canGrant = !!c.canGrant;
c.publicClient = !!c.publicClient;
c.trusted = !! c.trusted;
c.canGrant = !! c.canGrant;
c.publicClient = !! c.publicClient;

// Modification of the database at startup in production and stage is
// not preferred. This option will be set to false on those stacks.
if (!config.get('db.autoUpdateClients')) {
if (! config.get('db.autoUpdateClients')) {
return P.resolve();
}

Expand Down
16 changes: 8 additions & 8 deletions lib/db/memory.js
Expand Up @@ -80,7 +80,7 @@ const MAX_TTL = config.get('expiration.accessToken');
* }
*/
function MemoryStore() {
if (!(this instanceof MemoryStore)) {
if (! (this instanceof MemoryStore)) {
return new MemoryStore();
}
this.clients = {};
Expand All @@ -96,7 +96,7 @@ MemoryStore.connect = function memoryConnect() {
};

function clone(obj) {
if (!obj) {
if (! obj) {
return obj;
}
var clone = {};
Expand Down Expand Up @@ -131,19 +131,19 @@ MemoryStore.prototype = {
client.createdAt = new Date();
client.imageUri = client.imageUri || '';
client.redirectUri = client.redirectUri || '';
client.canGrant = !!client.canGrant;
client.trusted = !!client.trusted;
client.canGrant = !! client.canGrant;
client.trusted = !! client.trusted;
this.clients[hex] = client;
client.hashedSecret = client.hashedSecret;
client.hashedSecretPrevious = client.hashedSecretPrevious || '';
return P.resolve(client);
},
updateClient: function updateClient(client) {
if (!client.id) {
if (! client.id) {
return P.reject(new Error('Update client needs an id'));
}
var hex = unbuf(client.id);
if (!this.clients[hex]) {
if (! this.clients[hex]) {
return P.reject(new Error('Client does not exist'));
}
var old = this.clients[hex];
Expand Down Expand Up @@ -316,11 +316,11 @@ MemoryStore.prototype = {
return P.resolve(clone(this.refreshTokens[unbuf(token)]));
},
usedRefreshToken: function usedRefreshToken(token) {
if (!token) {
if (! token) {
return P.reject(new Error('Update needs a token'));
}
var hex = unbuf(token);
if (!this.refreshTokens[hex]) {
if (! this.refreshTokens[hex]) {
return P.reject(new Error('Token does not exist'));
}
var old = this.refreshTokens[hex];
Expand Down
14 changes: 7 additions & 7 deletions lib/db/mysql/index.js
Expand Up @@ -239,17 +239,17 @@ MysqlStore.prototype = {
buf(client.hashedSecret),
client.hashedSecretPrevious ? buf(client.hashedSecretPrevious) : null,
client.redirectUri,
!!client.trusted,
!!client.canGrant,
!!client.publicClient
!! client.trusted,
!! client.canGrant,
!! client.publicClient
]).then(function() {
logger.debug('registerClient.success', { id: hex(id) });
client.id = id;
return client;
});
},
registerClientDeveloper: function regClientDeveloper(developerId, clientId) {
if (!developerId || !clientId) {
if (! developerId || ! clientId) {
var err = new Error('Owner registration requires user and developer id');
return P.reject(err);
}
Expand Down Expand Up @@ -319,7 +319,7 @@ MysqlStore.prototype = {
});
},
updateClient: function updateClient(client) {
if (!client.id) {
if (! client.id) {
return P.reject(new Error('Update client needs an id'));
}
var secret = client.hashedSecret;
Expand Down Expand Up @@ -364,7 +364,7 @@ MysqlStore.prototype = {
codeObj.email,
codeObj.scope.join(' '),
codeObj.authAt,
!!codeObj.offline,
!! codeObj.offline,
hash,
codeObj.codeChallengeMethod,
codeObj.codeChallenge
Expand Down Expand Up @@ -650,7 +650,7 @@ MysqlStore.prototype = {
needToSetMode = true;
}
});
if (!needToSetMode) {
if (! needToSetMode) {
conn._fxa_initialized = true;
return resolve(conn);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/events.js
Expand Up @@ -11,7 +11,7 @@ const HEX_STRING = require('./validators').HEX_STRING;

var fxaEvents;

if (!config.events.region || !config.events.queueUrl) {
if (! config.events.region || ! config.events.queueUrl) {
fxaEvents = {
start: function start() {
if (env.isProdLike()) {
Expand All @@ -28,7 +28,7 @@ if (!config.events.region || !config.events.queueUrl) {
logger.verbose('data', message);
if (message.event === 'delete') {
var userId = message.uid.split('@')[0];
if (!HEX_STRING.test(userId)) {
if (! HEX_STRING.test(userId)) {
message.del();
return logger.warn('badDelete', { userId: userId });
}
Expand Down
8 changes: 4 additions & 4 deletions lib/routes/authorization.js
Expand Up @@ -190,7 +190,7 @@ module.exports = {
P.all([
verify(req.payload.assertion).then(function(claims) {
logger.info('time.browserid_verify', { ms: Date.now() - start });
if (!claims) {
if (! claims) {
exitEarly = true;
throw AppError.invalidAssertion();
}
Expand All @@ -202,10 +202,10 @@ module.exports = {
// assertion was invalid, we can just stop here
return;
}
if (!client) {
if (! client) {
logger.debug('notFound', { id: req.payload.client_id });
throw AppError.unknownClient(req.payload.client_id);
} else if (!client.trusted) {
} else if (! client.trusted) {
var invalidScopes = detectInvalidScopes(scope.values(),
UNTRUSTED_CLIENT_ALLOWED_SCOPES);

Expand Down Expand Up @@ -243,7 +243,7 @@ module.exports = {

}

if (wantsGrant && !client.canGrant) {
if (wantsGrant && ! client.canGrant) {
logger.warn('implicitGrant.notAllowed', {
id: req.payload.client_id
});
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/client/get.js
Expand Up @@ -28,7 +28,7 @@ module.exports = {
handler: function requestInfoEndpoint(req, reply) {
var params = req.params;
db.getClient(Buffer(params.client_id, 'hex')).then(function(client) {
if (!client) {
if (! client) {
logger.debug('notFound', { id: params.client_id });
throw AppError.unknownClient(params.client_id);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/routes/client/register.js
Expand Up @@ -46,8 +46,8 @@ module.exports = {
name: payload.name,
redirectUri: payload.redirect_uri,
imageUri: payload.image_uri || '',
canGrant: !!payload.can_grant,
trusted: !!payload.trusted
canGrant: !! payload.can_grant,
trusted: !! payload.trusted
};
var developerEmail = req.auth.credentials.email;
var developerId = null;
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/destroy.js
Expand Up @@ -34,7 +34,7 @@ module.exports = {
}

db[getToken](token).then(function(tok) {
if (!tok) {
if (! tok) {
throw AppError.invalidToken();
}
return db[removeToken](token);
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/redirect.js
Expand Up @@ -36,7 +36,7 @@ module.exports = {
if (! err) {
delete req.query.action;

if (req.query.login_hint && !req.query.email) {
if (req.query.login_hint && ! req.query.email) {
req.query.email = req.query.login_hint;
delete req.query.login_hint;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/root.js
Expand Up @@ -13,7 +13,7 @@ try {
var info = require('../../config/version.json');
commitHash = info.version.hash;
source = info.version.source;
} catch(e) {
} catch (e) {
/* ignore */
}

Expand Down

0 comments on commit 8bc148a

Please sign in to comment.