Commit 066ad946 authored by Julien Fontanet's avatar Julien Fontanet

chore: add ESLint

parent 4b7d8773
module.exports = {
"env": {
"node": true
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 5
},
"rules": {
"indent": "off",
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"single",
{
"avoidEscape": true
}
],
"semi": [
"error",
"always"
]
}
};
......@@ -18,7 +18,7 @@ module.exports = function(path, cb) {
SMB2Request('open', { path: path }, connection, function(err, file) {
if (err) cb && cb(null, false);
else
SMB2Request('close', file, connection, function(err) {
SMB2Request('close', file, connection, function() {
cb && cb(null, true);
});
});
......
......@@ -31,7 +31,7 @@ module.exports = function(path, mode, cb) {
if (err) cb && cb(err);
// SMB2 query directory
else
SMB2Request('close', file, connection, function(err) {
SMB2Request('close', file, connection, function() {
cb && cb(null);
});
});
......
......@@ -26,7 +26,7 @@ module.exports = function(path, cb) {
if (err) cb && cb(err);
// SMB2 close directory
else
SMB2Request('close', file, connection, function(err) {
SMB2Request('close', file, connection, function() {
cb &&
cb(
null,
......
......@@ -38,7 +38,7 @@ module.exports = function(filename, options, cb) {
}
var result = new Buffer(fileLength);
// callback manager
function callback(offset) {
var callback = function(offset) {
return function(err, content) {
if (stop) return;
if (err) {
......@@ -50,22 +50,22 @@ module.exports = function(filename, options, cb) {
checkDone();
}
};
}
};
// callback manager
function checkDone() {
var checkDone = function() {
if (stop) return;
createPackets();
if (nbRemainingPackets == 0 && offset.ge(fileLength)) {
SMB2Request('close', file, connection, function(err) {
SMB2Request('close', file, connection, function() {
if (options.encoding) {
result = result.toString(options.encoding);
}
cb && cb(null, result);
});
}
}
};
// create packets
function createPackets() {
var createPackets = function() {
while (
nbRemainingPackets < connection.packetConcurrency &&
offset.lt(fileLength)
......@@ -89,7 +89,7 @@ module.exports = function(filename, options, cb) {
offset = offset.add(packetSize);
nbRemainingPackets++;
}
}
};
checkDone();
}
});
......
......@@ -51,7 +51,7 @@ function rename(connection, file, newPath, cb) {
if (err) cb && cb(err);
// SMB2 close file
else
SMB2Request('close', file, connection, function(err) {
SMB2Request('close', file, connection, function() {
cb && cb(null);
});
}
......
......@@ -41,7 +41,7 @@ module.exports = function(path, cb) {
if (err) cb && cb(err);
// SMB2 close directory
else
SMB2Request('close', file, connection, function(err) {
SMB2Request('close', file, connection, function() {
cb && cb(null, files);
});
}
......
......@@ -38,7 +38,7 @@ module.exports = function(path, cb) {
if (err) cb && cb(err);
// SMB2 close directory
else
SMB2Request('close', file, connection, function(err) {
SMB2Request('close', file, connection, function() {
cb && cb(null, files);
});
}
......
......@@ -75,7 +75,7 @@ module.exports = function(filename, data, options, cb) {
nbRemainingPackets = 0,
maxPacketSize = new bigint(8, 0x00010000 - 0x71);
// callback manager
function callback(offset) {
function callback() {
return function(err) {
if (stop) return;
if (err) {
......
......@@ -80,13 +80,13 @@ BigInt.prototype.add = function(v) {
return result;
};
BigInt.prototype.neg = function(v) {
BigInt.prototype.neg = function() {
var result = new BigInt(this);
result.sign *= -1;
return result;
};
BigInt.prototype.abs = function(v) {
BigInt.prototype.abs = function() {
var result = new BigInt(this);
result.sign = 1;
return result;
......
......@@ -37,7 +37,7 @@ SMB2Connection.requireConnect = function(method) {
args.push(cb);
cb = function(err) {
if (err) {
if (!err instanceof Error) {
if (!(err instanceof Error)) {
err = new Error(String(err));
}
throw err;
......@@ -73,8 +73,8 @@ SMB2Connection.init = function(connection) {
connection.errorHandler[0].call(null, err);
}
if (connection.debug) {
console.log('-- error');
console.log(arguments);
console.log('-- error'); // eslint-disable-line no-console
console.log(arguments); // eslint-disable-line no-console
}
});
};
......
......@@ -53,8 +53,8 @@ SMB2Forge.response = function(c) {
message.parseBuffer(r);
//debug
if (c.debug) {
console.log('--response');
console.log(r.toString('hex'));
console.log('--response'); // eslint-disable-line no-console
console.log(r.toString('hex')); // eslint-disable-line no-console
}
// get the message id
var mId = message.getHeaders().MessageId.toString('hex');
......@@ -81,8 +81,8 @@ function sendNetBiosMessage(connection, message) {
var smbRequest = message.getBuffer(connection);
if (connection.debug) {
console.log('--request');
console.log(smbRequest.toString('hex'));
console.log('--request'); // eslint-disable-line no-console
console.log(smbRequest.toString('hex')); // eslint-disable-line no-console
}
// create NetBios package
......
/*
* CONSTANTS
*/
const protocolId = new Buffer([
var protocolId = new Buffer([
0xfe,
'S'.charCodeAt(0),
'M'.charCodeAt(0),
......@@ -30,6 +30,7 @@ const protocolId = new Buffer([
OPLOCK_BREAK: 0x0012,
},
},
// eslint-disable-next-line no-unused-vars
flags = {
SERVER_TO_REDIR: 0x00000001,
ASYNC_COMMAND: 0x00000002,
......
......@@ -34,11 +34,13 @@
],
"scripts": {
"build": "./node_modules/.bin/babel --source-maps --out-dir=lib/api/ lib/api/src",
"prepublish": "npm run build"
"prepublish": "npm run build",
"test": "eslint ./lib"
},
"devDependencies": {
"babel": "^5.8.34",
"babel-eslint": "^4.1.6",
"eslint": "^5.0.1",
"prettier": "^1.13.7",
"source-map-support": "^0.4.0",
"standard": "^5.4.1"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment