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

Commit

Permalink
chore(lint): add ESLint
Browse files Browse the repository at this point in the history
Fixes #274
Add ESLint
Remove JSHint
Lint the files and fix errors
  • Loading branch information
TDA committed Jun 17, 2015
1 parent fe7b035 commit 1531061
Show file tree
Hide file tree
Showing 25 changed files with 30 additions and 90 deletions.
11 changes: 11 additions & 0 deletions .eslintrc
@@ -0,0 +1,11 @@
{
"extends": "fxa",
"env": {
"mocha": true
},
"rules": {
"handle-callback-err": 0,
"complexity": [2, 10],
"strict": 0
}
}
28 changes: 0 additions & 28 deletions .jshintrc

This file was deleted.

4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Expand Up @@ -18,15 +18,15 @@ Patches should be submitted as pull requests (PR).

Before submitting a PR:
- Your code must run and pass all the automated tests before you submit your PR for review. "Work in progress" pull requests are allowed to be submitted, but should be clearly labeled as such and should not be merged until all tests pass and the code has been reviewed.
- Run `grunt jshint` to make sure your code passes linting.
- Run `grunt eslint` to make sure your code passes linting.
- Run `npm test` to make sure all tests still pass.
- Your patch should include new tests that cover your changes. It is your and your reviewer's responsibility to ensure your patch includes adequate tests.

When submitting a PR:
- You agree to license your code under the project's open source license ([MPL 2.0](/LICENSE)).
- Base your branch off the current `master` (see below for an example workflow).
- Add both your code and new tests if relevant.
- Run `grunt jshint` and `npm test` to make sure your code passes linting and tests.
- Run `grunt eslint` and `npm test` to make sure your code passes linting and tests.
- Please do not include merge commits in pull requests; include only commits with the new relevant code.

See the main [README.md](/README.md) for information on prerequisites, installing, running and testing.
Expand Down
2 changes: 1 addition & 1 deletion Gruntfile.js
Expand Up @@ -12,7 +12,7 @@ module.exports = function (grunt) {

grunt.initConfig({
pkg: grunt.file.readJSON('./package.json'),
// .js files for JSHint, JSCS, etc.
// .js files for ESLint, JSHint, JSCS, etc.
mainJsFiles: '{,lib/**/,scripts/**/,test/**/,tasks/**/,bin/**/}*.js'
});

Expand Down
3 changes: 0 additions & 3 deletions lib/db/memory.js
Expand Up @@ -180,7 +180,6 @@ MemoryStore.prototype = {
return P.resolve();
},
generateCode: function generateCode(clientId, userId, email, scope, authAt) {

var code = {};
code.clientId = clientId;
code.userId = userId;
Expand Down Expand Up @@ -306,10 +305,8 @@ MemoryStore.prototype = {
return self.getClientDevelopers(clientId);
})
.then(function (developers) {
var result;

function hasDeveloper(developer) {
result = developer;
return unbuf(developer.developerId) === unbuf(developerId);
}

Expand Down
9 changes: 4 additions & 5 deletions lib/db/mysql/index.js
Expand Up @@ -354,9 +354,9 @@ MysqlStore.prototype = {
type: 'bearer'
};
var _token = unique.token();
var me = this;
var self = this;
var hash = encrypt.hash(_token);
return me._write(QUERY_TOKEN_INSERT, [
return self._write(QUERY_TOKEN_INSERT, [
t.clientId,
t.userId,
t.email,
Expand Down Expand Up @@ -385,16 +385,15 @@ MysqlStore.prototype = {
getEncodingInfo: function getEncodingInfo() {
var info = {};

var me = this;
var self = this;
var qry = 'SHOW VARIABLES LIKE "%character\\_set\\_%"';
return this._read(qry).then(function(rows) {
/*jshint camelcase:false*/
rows.forEach(function(row) {
info[row.Variable_name] = row.Value;
});

qry = 'SHOW VARIABLES LIKE "%collation\\_%"';
return me._read(qry).then(function(rows) {
return self._read(qry).then(function(rows) {
rows.forEach(function(row) {
info[row.Variable_name] = row.Value;
});
Expand Down
2 changes: 0 additions & 2 deletions lib/error.js
Expand Up @@ -8,9 +8,7 @@ const DEFAULTS = {
code: 500,
error: 'Internal Server Error',
errno: 999,
/*jshint ignore:start,-W101*/
info: 'https://github.com/mozilla/fxa-oauth-server/blob/master/docs/api.md#errors',
/*jshint ignore:end,+W101*/
message: 'Unspecified error'
};

Expand Down
1 change: 0 additions & 1 deletion lib/logging/summary.js
Expand Up @@ -24,7 +24,6 @@ module.exports = function summary(request, response) {
path: request.path,
agent: request.headers['user-agent'],
t: Date.now() - request.info.received,
/*jshint camelcase: false*/
client_id: payload.client_id || query.client_id || params.client_id,
auth: auth,
payload: Object.keys(payload)
Expand Down
2 changes: 0 additions & 2 deletions lib/routes/authorization.js
Expand Up @@ -24,8 +24,6 @@ const UNTRUSTED_CLIENT_ALLOWED_SCOPES = [
'profile:display_name'
];

/*jshint camelcase: false*/

function set(arr) {
var obj = {};
for (var i = 0; i < arr.length; i++) {
Expand Down
1 change: 0 additions & 1 deletion lib/routes/client/delete.js
Expand Up @@ -7,7 +7,6 @@ const db = require('../../db');
const validators = require('../../validators');
const AppError = require('../../error');

/*jshint camelcase: false*/
module.exports = {
auth: {
strategy: auth.AUTH_STRATEGY,
Expand Down
1 change: 0 additions & 1 deletion lib/routes/client/get.js
Expand Up @@ -10,7 +10,6 @@ const db = require('../../db');
const logger = require('../../logging')('routes.client.get');
const validators = require('../../validators');

/*jshint camelcase: false*/
module.exports = {
validate: {
params: {
Expand Down
2 changes: 0 additions & 2 deletions lib/routes/client/list.js
Expand Up @@ -9,8 +9,6 @@ const auth = require('../../auth');
const db = require('../../db');
const validators = require('../../validators');

/*jshint camelcase: false*/

function serialize(client) {
return {
id: hex(client.id),
Expand Down
1 change: 0 additions & 1 deletion lib/routes/client/register.js
Expand Up @@ -12,7 +12,6 @@ const unique = require('../../unique');
const validators = require('../../validators');
const AppError = require('../../error');

/*jshint camelcase: false*/
module.exports = {
auth: {
strategy: auth.AUTH_STRATEGY,
Expand Down
1 change: 0 additions & 1 deletion lib/routes/client/update.js
Expand Up @@ -10,7 +10,6 @@ const db = require('../../db');
const validators = require('../../validators');
const AppError = require('../../error');

/*jshint camelcase: false*/
module.exports = {
auth: {
strategy: auth.AUTH_STRATEGY,
Expand Down
1 change: 0 additions & 1 deletion lib/routes/developer/activate.js
Expand Up @@ -14,7 +14,6 @@ function developerResponse(developer) {
};
}

/*jshint camelcase: false*/
module.exports = {
auth: {
strategy: auth.AUTH_STRATEGY,
Expand Down
2 changes: 0 additions & 2 deletions lib/routes/token.js
Expand Up @@ -19,7 +19,6 @@ function generateToken(code) {
}

function toToken(authAt, _, token) {
/*jshint camelcase: false*/
return {
access_token: token.token.toString('hex'),
token_type: token.type,
Expand All @@ -30,7 +29,6 @@ function toToken(authAt, _, token) {


var payloadSchema = Joi.object({
/*jshint camelcase: false*/
client_id: validators.clientId,
client_secret: validators.clientSecret,
code: Joi.string()
Expand Down
2 changes: 0 additions & 2 deletions lib/routes/verify.js
Expand Up @@ -8,8 +8,6 @@ const config = require('../config');
const token = require('../token');
const validators = require('../validators');

/*jshint camelcase: false*/

module.exports = {
validate: {
payload: {
Expand Down
2 changes: 0 additions & 2 deletions lib/server/internal.js
Expand Up @@ -19,8 +19,6 @@ exports.create = function createServer() {
require('./config')
);



server.auth.scheme(auth.AUTH_SCHEME, auth.strategy);
server.auth.strategy(auth.AUTH_STRATEGY, auth.AUTH_SCHEME);

Expand Down
2 changes: 0 additions & 2 deletions lib/token.js
Expand Up @@ -7,8 +7,6 @@ const auth = require('./auth');
const db = require('./db');
const encrypt = require('./encrypt');

/*jshint camelcase: false*/

exports.verify = function verify(token) {
return db.getToken(encrypt.hash(token))
.then(function(token) {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -39,17 +39,17 @@
"awsbox": "^0.7.0",
"blanket": "^1.1.6",
"browserid-crypto": "^0.7.0",
"eslint-config-fxa": "^1.4.0",
"grunt": "^0.4.5",
"grunt-cli": "^0.1.13",
"grunt-contrib-jshint": "^0.11.1",
"grunt-conventional-changelog": "^1.1.0",
"grunt-copyright": "^0.1.0",
"grunt-eslint": "^15.0.0",
"grunt-jscs": "^1.5.0",
"grunt-mocha-test": "^0.12.2",
"grunt-nodemon": "^0.4.0",
"grunt-nsp-shrinkwrap": "^0.0.3",
"insist": "0.x",
"jshint-stylish": "^1.0.1",
"load-grunt-tasks": "^3.1.0",
"mocha-text-cov": "^0.1.0",
"nock": "^1.2.1",
Expand Down
5 changes: 2 additions & 3 deletions tasks/jshint.js → tasks/eslint.js
Expand Up @@ -5,10 +5,9 @@
module.exports = function (grunt) {
'use strict';

grunt.config('jshint', {
grunt.config('eslint', {
options: {
jshintrc: '.jshintrc',
reporter: require('jshint-stylish')
eslintrc: '.eslintrc'
},
app: [
'<%= mainJsFiles %>'
Expand Down
2 changes: 1 addition & 1 deletion tasks/lint.js
Expand Up @@ -8,7 +8,7 @@ module.exports = function (grunt) {
'use strict';

grunt.registerTask('lint', [
'jshint',
'eslint',
'jscs'
]);
};

0 comments on commit 1531061

Please sign in to comment.