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) { ...@@ -18,7 +18,7 @@ module.exports = function(path, cb) {
SMB2Request('open', { path: path }, connection, function(err, file) { SMB2Request('open', { path: path }, connection, function(err, file) {
if (err) cb && cb(null, false); if (err) cb && cb(null, false);
else else
SMB2Request('close', file, connection, function(err) { SMB2Request('close', file, connection, function() {
cb && cb(null, true); cb && cb(null, true);
}); });
}); });
......
...@@ -31,7 +31,7 @@ module.exports = function(path, mode, cb) { ...@@ -31,7 +31,7 @@ module.exports = function(path, mode, cb) {
if (err) cb && cb(err); if (err) cb && cb(err);
// SMB2 query directory // SMB2 query directory
else else
SMB2Request('close', file, connection, function(err) { SMB2Request('close', file, connection, function() {
cb && cb(null); cb && cb(null);
}); });
}); });
......
...@@ -26,7 +26,7 @@ module.exports = function(path, cb) { ...@@ -26,7 +26,7 @@ module.exports = function(path, cb) {
if (err) cb && cb(err); if (err) cb && cb(err);
// SMB2 close directory // SMB2 close directory
else else
SMB2Request('close', file, connection, function(err) { SMB2Request('close', file, connection, function() {
cb && cb &&
cb( cb(
null, null,
......
...@@ -38,7 +38,7 @@ module.exports = function(filename, options, cb) { ...@@ -38,7 +38,7 @@ module.exports = function(filename, options, cb) {
} }
var result = new Buffer(fileLength); var result = new Buffer(fileLength);
// callback manager // callback manager
function callback(offset) { var callback = function(offset) {
return function(err, content) { return function(err, content) {
if (stop) return; if (stop) return;
if (err) { if (err) {
...@@ -50,22 +50,22 @@ module.exports = function(filename, options, cb) { ...@@ -50,22 +50,22 @@ module.exports = function(filename, options, cb) {
checkDone(); checkDone();
} }
}; };
} };
// callback manager // callback manager
function checkDone() { var checkDone = function() {
if (stop) return; if (stop) return;
createPackets(); createPackets();
if (nbRemainingPackets == 0 && offset.ge(fileLength)) { if (nbRemainingPackets == 0 && offset.ge(fileLength)) {
SMB2Request('close', file, connection, function(err) { SMB2Request('close', file, connection, function() {
if (options.encoding) { if (options.encoding) {
result = result.toString(options.encoding); result = result.toString(options.encoding);
} }
cb && cb(null, result); cb && cb(null, result);
}); });
} }
} };
// create packets // create packets
function createPackets() { var createPackets = function() {
while ( while (
nbRemainingPackets < connection.packetConcurrency && nbRemainingPackets < connection.packetConcurrency &&
offset.lt(fileLength) offset.lt(fileLength)
...@@ -89,7 +89,7 @@ module.exports = function(filename, options, cb) { ...@@ -89,7 +89,7 @@ module.exports = function(filename, options, cb) {
offset = offset.add(packetSize); offset = offset.add(packetSize);
nbRemainingPackets++; nbRemainingPackets++;
} }
} };
checkDone(); checkDone();
} }
}); });
......
...@@ -51,7 +51,7 @@ function rename(connection, file, newPath, cb) { ...@@ -51,7 +51,7 @@ function rename(connection, file, newPath, cb) {
if (err) cb && cb(err); if (err) cb && cb(err);
// SMB2 close file // SMB2 close file
else else
SMB2Request('close', file, connection, function(err) { SMB2Request('close', file, connection, function() {
cb && cb(null); cb && cb(null);
}); });
} }
......
...@@ -41,7 +41,7 @@ module.exports = function(path, cb) { ...@@ -41,7 +41,7 @@ module.exports = function(path, cb) {
if (err) cb && cb(err); if (err) cb && cb(err);
// SMB2 close directory // SMB2 close directory
else else
SMB2Request('close', file, connection, function(err) { SMB2Request('close', file, connection, function() {
cb && cb(null, files); cb && cb(null, files);
}); });
} }
......
...@@ -38,7 +38,7 @@ module.exports = function(path, cb) { ...@@ -38,7 +38,7 @@ module.exports = function(path, cb) {
if (err) cb && cb(err); if (err) cb && cb(err);
// SMB2 close directory // SMB2 close directory
else else
SMB2Request('close', file, connection, function(err) { SMB2Request('close', file, connection, function() {
cb && cb(null, files); cb && cb(null, files);
}); });
} }
......
...@@ -75,7 +75,7 @@ module.exports = function(filename, data, options, cb) { ...@@ -75,7 +75,7 @@ module.exports = function(filename, data, options, cb) {
nbRemainingPackets = 0, nbRemainingPackets = 0,
maxPacketSize = new bigint(8, 0x00010000 - 0x71); maxPacketSize = new bigint(8, 0x00010000 - 0x71);
// callback manager // callback manager
function callback(offset) { function callback() {
return function(err) { return function(err) {
if (stop) return; if (stop) return;
if (err) { if (err) {
......
...@@ -80,13 +80,13 @@ BigInt.prototype.add = function(v) { ...@@ -80,13 +80,13 @@ BigInt.prototype.add = function(v) {
return result; return result;
}; };
BigInt.prototype.neg = function(v) { BigInt.prototype.neg = function() {
var result = new BigInt(this); var result = new BigInt(this);
result.sign *= -1; result.sign *= -1;
return result; return result;
}; };
BigInt.prototype.abs = function(v) { BigInt.prototype.abs = function() {
var result = new BigInt(this); var result = new BigInt(this);
result.sign = 1; result.sign = 1;
return result; return result;
......
...@@ -37,7 +37,7 @@ SMB2Connection.requireConnect = function(method) { ...@@ -37,7 +37,7 @@ SMB2Connection.requireConnect = function(method) {
args.push(cb); args.push(cb);
cb = function(err) { cb = function(err) {
if (err) { if (err) {
if (!err instanceof Error) { if (!(err instanceof Error)) {
err = new Error(String(err)); err = new Error(String(err));
} }
throw err; throw err;
...@@ -73,8 +73,8 @@ SMB2Connection.init = function(connection) { ...@@ -73,8 +73,8 @@ SMB2Connection.init = function(connection) {
connection.errorHandler[0].call(null, err); connection.errorHandler[0].call(null, err);
} }
if (connection.debug) { if (connection.debug) {
console.log('-- error'); console.log('-- error'); // eslint-disable-line no-console
console.log(arguments); console.log(arguments); // eslint-disable-line no-console
} }
}); });
}; };
......
...@@ -53,8 +53,8 @@ SMB2Forge.response = function(c) { ...@@ -53,8 +53,8 @@ SMB2Forge.response = function(c) {
message.parseBuffer(r); message.parseBuffer(r);
//debug //debug
if (c.debug) { if (c.debug) {
console.log('--response'); console.log('--response'); // eslint-disable-line no-console
console.log(r.toString('hex')); console.log(r.toString('hex')); // eslint-disable-line no-console
} }
// get the message id // get the message id
var mId = message.getHeaders().MessageId.toString('hex'); var mId = message.getHeaders().MessageId.toString('hex');
...@@ -81,8 +81,8 @@ function sendNetBiosMessage(connection, message) { ...@@ -81,8 +81,8 @@ function sendNetBiosMessage(connection, message) {
var smbRequest = message.getBuffer(connection); var smbRequest = message.getBuffer(connection);
if (connection.debug) { if (connection.debug) {
console.log('--request'); console.log('--request'); // eslint-disable-line no-console
console.log(smbRequest.toString('hex')); console.log(smbRequest.toString('hex')); // eslint-disable-line no-console
} }
// create NetBios package // create NetBios package
......
/* /*
* CONSTANTS * CONSTANTS
*/ */
const protocolId = new Buffer([ var protocolId = new Buffer([
0xfe, 0xfe,
'S'.charCodeAt(0), 'S'.charCodeAt(0),
'M'.charCodeAt(0), 'M'.charCodeAt(0),
...@@ -30,6 +30,7 @@ const protocolId = new Buffer([ ...@@ -30,6 +30,7 @@ const protocolId = new Buffer([
OPLOCK_BREAK: 0x0012, OPLOCK_BREAK: 0x0012,
}, },
}, },
// eslint-disable-next-line no-unused-vars
flags = { flags = {
SERVER_TO_REDIR: 0x00000001, SERVER_TO_REDIR: 0x00000001,
ASYNC_COMMAND: 0x00000002, ASYNC_COMMAND: 0x00000002,
......
...@@ -34,11 +34,13 @@ ...@@ -34,11 +34,13 @@
], ],
"scripts": { "scripts": {
"build": "./node_modules/.bin/babel --source-maps --out-dir=lib/api/ lib/api/src", "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": { "devDependencies": {
"babel": "^5.8.34", "babel": "^5.8.34",
"babel-eslint": "^4.1.6", "babel-eslint": "^4.1.6",
"eslint": "^5.0.1",
"prettier": "^1.13.7", "prettier": "^1.13.7",
"source-map-support": "^0.4.0", "source-map-support": "^0.4.0",
"standard": "^5.4.1" "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