Skip to content

Commit

Permalink
Add eslint indent rule
Browse files Browse the repository at this point in the history
Changes made:

- add an "indent" rule to .eslintrc to enforce correct indentation

- removed duplicate configuration in 'tests' folder,'
and just left the rules that need to be overridden for that folder

- auto fixed indentation on all files via the eslint --fix option

- re-enabled node 10 for travis checks and updated package-lock.json
with correct packages to avoid issues
  • Loading branch information
aberonni committed Jul 23, 2018
1 parent 077205f commit 77d89b0
Show file tree
Hide file tree
Showing 26 changed files with 1,423 additions and 1,639 deletions.
14 changes: 10 additions & 4 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
"eslint:recommended"
],
"parserOptions": {
"ecmaVersion": 6,
"ecmaVersion": 2018,
"sourceType": "module",
"ecmaFeatures": {
"jsx": false,
"experimentalObjectRestSpread": true
"jsx": false
}
},
"env": {
Expand Down Expand Up @@ -39,11 +38,18 @@
"warn",
{ "blankLine": "always", "prev": "*", "next": "return" },
{ "blankLine": "any", "prev": ["const"], "next": "*"}
],
"indent": [
"error",
2,
{
"SwitchCase": 1
}
]
},
"globals": {
"Promise": true,
"Proxy": true,
"Reflect": true
}
}
}
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ language: node_js
sudo: false
node_js:
- "8"
- "10"

before_script:
- npm install
Expand Down
2 changes: 1 addition & 1 deletion examples/globalsModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ module.exports = {
console.log('GLOBAL afterEach')


cb();
cb();


})
Expand Down
2 changes: 1 addition & 1 deletion examples/tests/nightwatchByIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ module.exports = {

});

client.end();
client.end();
}
};
2 changes: 1 addition & 1 deletion lib/core/queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ class AsyncQueue extends EventEmitter {
this.once('queue:finished', function() {
callback(null);
})
.once('error', callback);
.once('error', callback);
}

return this.traverse();
Expand Down
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class NightwatchClient extends EventEmitter {
this.settings.screenshotsPath = screenshots.path;

this.setApiProperty('screenshotsPath', screenshots.path)
.setApiOption('screenshotsPath', screenshots.path);
.setApiOption('screenshotsPath', screenshots.path);
} else {
this.settings.screenshots = {
enabled : false,
Expand Down
12 changes: 6 additions & 6 deletions lib/runner/test-runners/mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,12 @@ class CustomRunner extends Mocha.Runner {
testSuite.createClient(suite.client)
.createContext(context)
.createSession()
.then(data => {
resolve(data);
})
.catch(err => {
reject(err);
});
.then(data => {
resolve(data);
})
.catch(err => {
reject(err);
});
} catch (err) {
reject(err);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/testsuite/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ class Context {
}

return attrVal;
}
}

readAttributes() {
this.attributes = Object.keys(Context.DEFAULT_ATTRIBUTES).reduce((prev, key) => {
Expand Down
2 changes: 1 addition & 1 deletion lib/testsuite/testsuite.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class TestSuite extends EventEmitter {
// false by default when running unit tests
return false;
}
// true by default when not running unit tests
// true by default when not running unit tests
return settingsValueUndefined || this.settings.skip_testcases_on_fail;
}

Expand Down
26 changes: 18 additions & 8 deletions lib/transport/jsonwire.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,23 @@ class JsonWireProtocol extends Transport {
errorDetails = JsonWireProtocol.parseErrorDetails(result.value);
}

['additionalInformation', 'supportUrl', 'cause', 'suppressed',
'hCode', 'class', 'buildInformation', 'stacktrace', 'stackTrace',
'localizedMessage', 'message'].forEach(function(item) {
if (typeof result.value[item] != 'undefined') {
delete result.value[item];
}
});
[
'additionalInformation',
'supportUrl',
'cause',
'suppressed',
'hCode',
'class',
'buildInformation',
'stacktrace',
'stackTrace',
'localizedMessage',
'message'
].forEach(function(item) {
if (typeof result.value[item] != 'undefined') {
delete result.value[item];
}
});

if (errorDetails && errorDetails.length > 0) {
result.value.message = errorDetails.shift();
Expand All @@ -150,4 +160,4 @@ class JsonWireProtocol extends Transport {
}
}

module.exports = JsonWireProtocol;
module.exports = JsonWireProtocol;
32 changes: 17 additions & 15 deletions lib/transport/transport.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,20 +152,22 @@ class Transport extends EventEmitter {
}
});

request.on('error', err => {
this.handleErrorResponse(err);
})
.on('success', (data, response, isRedirect) => {
let sessionData = this.parseSessionResponse(data);

if (sessionData.sessionId) {
this.emit('transport:session.create', sessionData, request, response);
} else if (isRedirect) {
this.followRedirect(request, response);
} else {
this.handleErrorResponse(data);
}
}).post();
request
.on('error', err => {
this.handleErrorResponse(err);
})
.on('success', (data, response, isRedirect) => {
let sessionData = this.parseSessionResponse(data);

if (sessionData.sessionId) {
this.emit('transport:session.create', sessionData, request, response);
} else if (isRedirect) {
this.followRedirect(request, response);
} else {
this.handleErrorResponse(data);
}
})
.post();

return this;
}
Expand Down Expand Up @@ -491,4 +493,4 @@ class Transport extends EventEmitter {
}
}

module.exports = Transport;
module.exports = Transport;
18 changes: 10 additions & 8 deletions lib/transport/webdriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,16 @@ class WebdriverProtocol extends Transport {
let request = new HttpRequest(requestOptions);

return new Promise((resolve, reject) => {
request.on('success', (result, response) => {
resolve(result);
})
.on('error', (result, response, screenshotContent) => {
let errorResult = this.handleTestError(result, response, screenshotContent);
request
.on('success', (result, response) => {
resolve(result);
})
.on('error', (result, response, screenshotContent) => {
let errorResult = this.handleTestError(result, response, screenshotContent);

reject(errorResult);
}).send();
reject(errorResult);
})
.send();
});

}
Expand All @@ -77,4 +79,4 @@ class WebdriverProtocol extends Transport {
}
}

module.exports = WebdriverProtocol;
module.exports = WebdriverProtocol;
14 changes: 7 additions & 7 deletions lib/util/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,13 @@ class Utils {
static stackTraceFilter(parts) {
let stack = parts.reduce(function(list, line) {
if (contains(line, [
'node_modules',
'(node.js:',
'(timers.js:',
'(events.js:',
'(util.js:',
'(net.js:'
])) {
'node_modules',
'(node.js:',
'(timers.js:',
'(events.js:',
'(util.js:',
'(net.js:'
])) {
return list;
}

Expand Down
Loading

0 comments on commit 77d89b0

Please sign in to comment.