Skip to content

Commit

Permalink
Replaced JSLint with ESLint.
Browse files Browse the repository at this point in the history
  • Loading branch information
lightswitch05 committed Jul 30, 2016
1 parent db47483 commit 82b7ef6
Show file tree
Hide file tree
Showing 10 changed files with 248 additions and 36 deletions.
218 changes: 218 additions & 0 deletions .eslintrc.json
@@ -0,0 +1,218 @@
{
"extends": "eslint:recommended",
"env": {
"node": true,
"es6": false
},
"rules": {
// Possible Errors
// These rules relate to possible syntax or logic errors in JavaScript code:
"no-cond-assign": "error",
"no-console": "warn",
"no-constant-condition": "error",
"no-control-regex": "error",
"no-debugger": "warn",
"no-dupe-args": "error",
"no-dupe-keys": "error",
"no-duplicate-case": "error",
"no-empty-character-class": "error",
"no-empty": "error",
"no-ex-assign": "error",
"no-extra-boolean-cast": "error",
"no-extra-parens": ["error", "functions"],
"no-extra-semi": "error",
"no-func-assign": "error",
"no-inner-declarations": "error",
"no-invalid-regexp": "error",
"no-irregular-whitespace": "error",
"no-negated-in-lhs": "error",
"no-obj-calls": "error",
"no-prototype-builtins": "error",
"no-regex-spaces": "error",
"no-sparse-arrays": "error",
"no-unexpected-multiline": "error",
"no-unreachable": "error",
"no-unsafe-finally": "error",
"use-isnan": "error",
"valid-jsdoc": "off",
"valid-typeof": "error",

// Best Practices
// These rules relate to better ways of doing things to help you avoid problems:
"accessor-pairs": "error",
"array-callback-return": "error",
"block-scoped-var": "error",
"complexity": "error",
"consistent-return": "error",
"curly": "error",
"default-case": "error",
"dot-location": "error",
"dot-notation": "error",
"eqeqeq": "error",
"guard-for-in": "error",
"no-alert": "error",
"no-caller": "error",
"no-case-declarations": "error",
"no-div-regex": "error",
"no-else-return": "error",
"no-empty-function": ["error", { "allow": ["functions"] }],
"no-empty-pattern": "error",
"no-eq-null": "error",
"no-eval": "error",
"no-extend-native": "error",
"no-extra-bind": "error",
"no-extra-label": "error",
"no-fallthrough": "error",
"no-floating-decimal": "error",
"no-implicit-coercion": "error",
"no-implicit-globals": "error",
"no-implied-eval": "error",
"no-invalid-this": "error",
"no-iterator": "error",
"no-labels": "error",
"no-lone-blocks": "error",
"no-loop-func": "error",
"no-magic-numbers": "off",
"no-multi-spaces": ["error", {"exceptions": { "VariableDeclarator": true }}],
"no-multi-str": "error",
"no-native-reassign": "error",
"no-new-func": "error",
"no-new-wrappers": "error",
"no-new": "error",
"no-octal-escape": "error",
"no-octal": "error",
"no-param-reassign": "off",
"no-proto": "error",
"no-redeclare": "error",
"no-return-assign": "error",
"no-script-url": "error",
"no-self-assign": "error",
"no-self-compare": "error",
"no-sequences": "error",
"no-throw-literal": "error",
"no-unmodified-loop-condition": "error",
"no-unused-expressions": "error",
"no-unused-labels": "error",
"no-useless-call": "error",
"no-useless-concat": "error",
"no-useless-escape": "error",
"no-void": "error",
"no-warning-comments": "off",
"no-with": "error",
"radix": "error",
"vars-on-top": "off",
"wrap-iife": "error",
"yoda": "error",

// Strict Mode
// These rules relate to strict mode directives:
"strict": "off",

// Variables
// These rules relate to variable declarations:
"init-declarations": "off",
"no-catch-shadow": "error",
"no-delete-var": "error",
"no-label-var": "error",
"no-restricted-globals": "error",
"no-shadow-restricted-names": "error",
"no-shadow": "error",
"no-undef-init": "error",
"no-undef": "error",
"no-undefined": "off",
"no-unused-vars": "off",
"no-use-before-define": "error",

// Node.js and CommonJS
// These rules relate to code running in Node.js, or in browsers with CommonJS:
"callback-return": "off",
"global-require": "error",
"handle-callback-err": "error",
"no-mixed-requires": "error",
"no-new-require": "error",
"no-path-concat": "error",
"no-process-env": "error",
"no-process-exit": "error",
"no-restricted-modules": "error",
"no-sync": "error",

// Stylistic Issues
// These rules relate to style guidelines, and are therefore quite subjective:
"array-bracket-spacing": "error",
"block-spacing": "error",
"brace-style": "error",
"camelcase": "error",
"comma-dangle": "error",
"comma-spacing": "error",
"comma-style": "error",
"computed-property-spacing": "error",
"consistent-this": "off",
"eol-last": "error",
"func-names": "off",
"func-style": "off",
"id-blacklist": "error",
"id-length": "off",
"id-match": "error",
"indent": "error",
"jsx-quotes": "error",
"key-spacing": "off",
"keyword-spacing": "error",
"linebreak-style": "error",
"lines-around-comment": "error",
"max-depth": "error",
"max-len": ["error", 85],
"max-lines": "off",
"max-nested-callbacks": "error",
"max-params": ["error", 5],
"max-statements-per-line": "error",
"max-statements": "off",
"multiline-ternary": "off",
"new-cap": "error",
"new-parens": "error",
"newline-after-var": "error",
"newline-before-return": "off",
"newline-per-chained-call": "error",
"no-array-constructor": "error",
"no-bitwise": "error",
"no-continue": "error",
"no-inline-comments": "off",
"no-lonely-if": "error",
"no-mixed-operators": "error",
"no-mixed-spaces-and-tabs": "error",
"no-multiple-empty-lines": "error",
"no-negated-condition": "off",
"no-nested-ternary": "error",
"no-new-object": "error",
"no-plusplus": "error",
"no-restricted-syntax": "error",
"no-spaced-func": "error",
"no-tabs": "error",
"no-ternary": "off",
"no-trailing-spaces": "error",
"no-underscore-dangle": "error",
"no-unneeded-ternary": "error",
"no-whitespace-before-property": "error",
"object-curly-newline": ["error", {"minProperties": 1}],
"object-curly-spacing": "error",
"object-property-newline": "error",
"one-var-declaration-per-line": "error",
"one-var": "off",
"operator-assignment": "error",
"operator-linebreak": "error",
"padded-blocks": ["off", "never"],
"quote-props": ["error", "consistent-as-needed"],
"quotes": ["error", "single", {"avoidEscape": true}],
"require-jsdoc": "off",
"semi-spacing": "error",
"semi": "error",
"sort-vars": "off",
"space-before-blocks": "error",
"space-before-function-paren": ["off", "always"],
"space-in-parens": "error",
"space-infix-ops": "error",
"space-unary-ops": "error",
"spaced-comment": "error",
"unicode-bom": "error",
"wrap-regex": "off"
}
}
3 changes: 2 additions & 1 deletion index.js
Expand Up @@ -120,6 +120,7 @@ function attempt(self, fn, callback) {
},
function (next) {
var attempts = count;

count += 1;

fn(attempts, function (error) {
Expand Down Expand Up @@ -873,7 +874,7 @@ Client.prototype.mkdirp = function (path, data, acls, mode, callback) {

async.eachSeries(nodes, function (node, next) {
currentPath = currentPath + '/' + node;
self.create(currentPath, data, acls, mode, function (error, path) {
self.create(currentPath, data, acls, mode, function (error) {
// Skip node exist error.
if (error && error.getCode() === Exception.NODE_EXISTS) {
next(null);
Expand Down
39 changes: 19 additions & 20 deletions lib/ConnectionManager.js
Expand Up @@ -113,7 +113,7 @@ ConnectionManager.prototype.updateTimeout = function (sessionTimeout) {
// We at least send out one ping one third of the session timeout, so
// the read timeout is two third of the session timeout.
this.pingTimeout = Math.floor(this.sessionTimeout / 3);
//this.readTimeout = Math.floor(sessionTimeout * 2 / 3);
// this.readTimeout = Math.floor(sessionTimeout * 2 / 3);
};

/**
Expand Down Expand Up @@ -334,7 +334,7 @@ ConnectionManager.prototype.onSocketConnected = function () {
authRequest = new jute.Request(header, payload);
this.queue(authRequest);

}, this);
}, this);
}

// Reset the watchers if we have any.
Expand Down Expand Up @@ -379,6 +379,7 @@ ConnectionManager.prototype.onSocketTimeout = function () {
}
};

/* eslint-disable complexity,max-depth */
ConnectionManager.prototype.onSocketData = function (buffer) {
var self = this,
offset = 0,
Expand Down Expand Up @@ -455,7 +456,7 @@ ConnectionManager.prototype.onSocketData = function (buffer) {
responseHeader = new jute.protocol.ReplyHeader();
offset += responseHeader.deserialize(buffer, offset);

//TODO BETTTER LOGGING
// TODO BETTTER LOGGING
switch (responseHeader.xid) {
case jute.XID_PING:
break;
Expand Down Expand Up @@ -490,12 +491,12 @@ ConnectionManager.prototype.onSocketData = function (buffer) {
if (pendingPacket.request.header.xid !== responseHeader.xid) {
// TODO, better error handling/logging need to bee done here.
// Need to clean up and do a reconnect.
//throw new Error(
//'Xid out of order. Got xid: ' +
//responseHeader.xid + ' with error code: ' +
//responseHeader.err + ', expected xid: ' +
//pendingPacket.request.header.xid + '.'
//);
// throw new Error(
// 'Xid out of order. Got xid: ' +
// responseHeader.xid + ' with error code: ' +
// responseHeader.err + ', expected xid: ' +
// pendingPacket.request.header.xid + '.'
// );
self.socket.destroy(); // this will trigger reconnect
return;
}
Expand Down Expand Up @@ -544,8 +545,8 @@ ConnectionManager.prototype.onSocketData = function (buffer) {
responsePayload = new jute.TransactionResponse();
break;
default:
//throw new Error('Unknown request OP_CODE: ' +
//pendingPacket.request.header.type);
// throw new Error('Unknown request OP_CODE: ' +
// pendingPacket.request.header.type);
self.socket.destroy(); // this will trigger reconnect
return;
}
Expand All @@ -564,13 +565,11 @@ ConnectionManager.prototype.onSocketData = function (buffer) {
new jute.Response(responseHeader, responsePayload)
);
}
} else {
if (pendingPacket.callback) {
pendingPacket.callback(
Exception.create(responseHeader.err),
new jute.Response(responseHeader, null)
);
}
} else if (pendingPacket.callback) {
pendingPacket.callback(
Exception.create(responseHeader.err),
new jute.Response(responseHeader, null)
);
}
}
}
Expand All @@ -581,6 +580,8 @@ ConnectionManager.prototype.onSocketData = function (buffer) {
}
};

/* eslint-enable complexity,max-depth */

ConnectionManager.prototype.onSocketDrain = function () {
// Trigger write on socket.
this.onPacketQueueReadable();
Expand Down Expand Up @@ -730,7 +731,5 @@ ConnectionManager.prototype.queue = function (request, callback) {
}
};



module.exports = ConnectionManager;
module.exports.STATES = STATES;
1 change: 1 addition & 0 deletions lib/ConnectionStringParser.js
Expand Up @@ -59,6 +59,7 @@ function ConnectionStringParser(connectionString) {
return item;
}).forEach(function (item) {
var parts = item.split(':');

servers.push({
host : parts[0],
port : parts[1] || DEFAULT_PORT
Expand Down
1 change: 1 addition & 0 deletions lib/CreateMode.js
Expand Up @@ -6,6 +6,7 @@
*/

var CREATE_MODES = {

/**
* The znode will not be automatically deleted upon client's disconnect.
*/
Expand Down
1 change: 1 addition & 0 deletions lib/Event.js
Expand Up @@ -33,6 +33,7 @@ function validateType(type) {
throw new Error('Unknown type: ' + type);
}
}

/**
* Watcher event.
*
Expand Down
2 changes: 0 additions & 2 deletions lib/PacketQueue.js
Expand Up @@ -13,8 +13,6 @@
var util = require('util');
var events = require('events');



function PacketQueue() {
events.EventEmitter.call(this);

Expand Down
2 changes: 0 additions & 2 deletions lib/Permission.js
Expand Up @@ -5,8 +5,6 @@
* for terms.
*/



var PERMISSIONS = {
READ : 1,
WRITE : 2,
Expand Down

0 comments on commit 82b7ef6

Please sign in to comment.