Skip to content

Commit

Permalink
updated eslint rules
Browse files Browse the repository at this point in the history
  • Loading branch information
beatfactor committed Apr 26, 2021
1 parent 708d6c4 commit f522d01
Show file tree
Hide file tree
Showing 80 changed files with 331 additions and 193 deletions.
32 changes: 26 additions & 6 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,22 @@
"no-extra-boolean-cast": 0,
"quotes": ["error", "single"],
"curly": ["error", "all"],
"no-console": ["warn", { "allow": ["error"] }],
"no-console": [
"error",
{
"allow": [
"error"
]
}
],
"no-debugger": 1,
"semi": [1, "always"],
"semi": [
"error",
"always",
{
"omitLastInOneLineBlock": true
}
],
"no-trailing-spaces": 0,
"no-else-return": 0,
"no-extra-bind": 0,
Expand All @@ -30,14 +43,21 @@
"no-return-assign": 0,
"eol-last": 0,
"no-unused-vars": 0,
"no-extra-semi": 1,
"no-extra-semi": 0,
"no-underscore-dangle": 0,
"no-lone-blocks": 0,
"array-bracket-spacing": 2,
"brace-style": [2, "1tbs", {"allowSingleLine": true}],
"comma-spacing": 2,
"comma-style": 2,
"key-spacing": 2,
"one-var": ["error", "never"],
"semi-style": ["error", "last"],
"space-in-parens": ["error", "never"],
"keyword-spacing": [2, {"before": true, "after": true}],
"padding-line-between-statements": [
"warn",
{ "blankLine": "always", "prev": "*", "next": "return" },
{ "blankLine": "any", "prev": ["const"], "next": "*"}
"error",
{ "blankLine": "always", "prev": "*", "next": "return" }
],
"indent": [
"error",
Expand Down
8 changes: 4 additions & 4 deletions examples/globalsModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ module.exports = {
// Automatically retrying failed assertions - You can tell Nightwatch to automatically retry failed assertions until a given timeout is reached, before the test runner gives up and fails the test.
retryAssertionTimeout: 1000,

'default' : {
myGlobal : function() {
'default': {
myGlobal: function() {
return 'I\'m a method';
}
},

'test_env' : {
'test_env': {
myGlobal: 'test_global',
beforeEach : function() {
beforeEach: function() {

}
},
Expand Down
2 changes: 1 addition & 1 deletion examples/mocha/googleDemoTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('Google demo test for Mocha', function() {
client
.setValue('input[type=text]', ['nightwatch', client.Keys.ENTER])
.pause(1000)
.assert.containsText('#main', 'Night Watch')
.assert.containsText('#main', 'Night Watch');
});

});
Expand Down
13 changes: 7 additions & 6 deletions examples/pages/nightwatchFeatures.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,24 @@ var featuresCommands = {
var countResult = {
status: 0,
value: result.value.length
}
};
callback.call(this, countResult);
} else {
callback.call(this, result);
}
}.bind(this));

return this;
}
};

module.exports = {
commands : [featuresCommands],
elements : {
featuresHeading : {
selector : '#index-container h2',
commands: [featuresCommands],
elements: {
featuresHeading: {
selector: '#index-container h2',
index: 1
},
features : '#index-container .features h3'
features: '#index-container .features h3'
}
};
2 changes: 1 addition & 1 deletion examples/tests/ecosia.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('Ecosia.org Demo', function() {
.setValue('input[type=search]', 'nightwatch')
.assert.visible('button[type=submit]')
.click('button[type=submit]')
.assert.containsText('.mainline-results', 'Nightwatch.js')
.assert.containsText('.mainline-results', 'Nightwatch.js');
});

after(browser => browser.end());
Expand Down
2 changes: 1 addition & 1 deletion examples/tests/github/github.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
tags: ['git'],
'Demo test GitHub' : function (client) {
'Demo test GitHub': function (client) {
client
.url('http://github.com/nightwatchjs/nightwatch')
.waitForElementVisible('xbody', 1000)
Expand Down
2 changes: 1 addition & 1 deletion examples/tests/google.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module.exports = {
tags: ['google'],
'@disabled': true,

'Demo test Google' : function (client) {
'Demo test Google': function (client) {
client
.url('http://google.no')
.pause(1000);
Expand Down
4 changes: 2 additions & 2 deletions examples/tests/google/googleDemoTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
module.exports = {
'@disabled': false,

'demo test google' : function (client) {
'demo test google': function (client) {
client
.url('http://google.com')
.waitForElementPresent('body', 1000);
},

'part two' : function(client) {
'part two': function(client) {
client
.setValue('input[type=text]', ['nightwatch', client.Keys.ENTER])
.pause(1000)
Expand Down
2 changes: 1 addition & 1 deletion examples/tests/googlePageObject.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
'Demo Google search test using page objects' : function (client) {
'Demo Google search test using page objects': function (client) {
var homePage = client.page.home();
homePage.navigate();
homePage.expect.element('@searchBar').to.be.enabled;
Expand Down
7 changes: 4 additions & 3 deletions examples/tests/nightwatch.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
disabled : true,
disabled: true,
'@tags': ['website'],

beforeEach: function(client, done) {
Expand All @@ -8,7 +8,7 @@ module.exports = {
});
},

'Demo test NightwatchJS.org' : function (client) {
'Demo test NightwatchJS.org': function (client) {
client
.waitForElementVisible('body', 1000)
.elements('css selector', '#index-container ul.features li', function (result) {
Expand All @@ -22,7 +22,8 @@ module.exports = {
'Finished': function(client) {
client
.perform(() => {
console.log('[perform]: Finished Test:', client.currentTest.name)
// eslint-disable-next-line no-console
console.log('[perform]: Finished Test:', client.currentTest.name);
})
.end();
}
Expand Down
2 changes: 1 addition & 1 deletion examples/tests/nightwatchByIndex.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
'@disabled': true,

'Show getting Nightwatch features using index' : function (client) {
'Show getting Nightwatch features using index': function (client) {

client.url('http://nightwatchjs.org');

Expand Down
4 changes: 2 additions & 2 deletions examples/tests/onbeforeunload.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ module.exports = {

},

'go to nightwatch' : function(c) {
'go to nightwatch': function(c) {
c.url('http://nightwatchjs.org')
.waitForElementVisible('body', 1000);
},

after : function(c) {
after: function(c) {
c.end();
}
};
4 changes: 2 additions & 2 deletions examples/unittests/demoTestAsync.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const assert = require('assert');

module.exports = {
'@unitTest' : true,
'@unitTest': true,

'demo UnitTest' : function (done) {
'demo UnitTest': function (done) {
assert.equal('TEST', 'TEST');
setTimeout(function() {
done();
Expand Down
4 changes: 2 additions & 2 deletions examples/unittests/testUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const assert = require('assert');
const Utils = require('../../lib/util/utils.js');

module.exports = {
testFormatElapsedTime : function() {
testFormatElapsedTime: function() {
var resultMs = Utils.formatElapsedTime(999);
assert.equal(resultMs, '999ms');

Expand All @@ -13,7 +13,7 @@ module.exports = {
assert.equal(resultMin, '2m 2s / 122299ms');
},

testGetTestSuiteName : function() {
testGetTestSuiteName: function() {
assert.equal(Utils.getTestSuiteName('test-case-one'), 'Test Case One');
assert.equal(Utils.getTestSuiteName('test_case_two'), 'Test Case Two');
assert.equal(Utils.getTestSuiteName('test.case.one'), 'Test Case One');
Expand Down
4 changes: 2 additions & 2 deletions examples/unittests/testUtilsWithChai.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var Utils = require('../../lib/util/utils.js');
var expect = require('chai').expect;

module.exports = {
testFormatElapsedTime : function() {
testFormatElapsedTime: function() {
var resultMs = Utils.formatElapsedTime(999);
var resultSec = Utils.formatElapsedTime(1999);
var resultMin = Utils.formatElapsedTime(122299, true);
Expand All @@ -12,7 +12,7 @@ module.exports = {
expect(resultMin).to.equal('2m 2s / 122299ms');
},

testFormatElapsedTimeMore : function() {
testFormatElapsedTimeMore: function() {
var resultMs = Utils.formatElapsedTime(999);
expect(resultMs).to.equal('999ms');
},
Expand Down
2 changes: 1 addition & 1 deletion lib/api/_loaders/assertion-scheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class AssertionScheduler {
return err;
})
.then(cbResult => {
Utils.makePromise(this.instance.doneCallback, this, [cbResult, this.instance])
Utils.makePromise(this.instance.doneCallback, this, [cbResult, this.instance]);
});
}.bind(this), this.instance);
}
Expand Down
3 changes: 2 additions & 1 deletion lib/api/_loaders/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class CommandLoader extends BaseCommandLoader {
static transportActions({actions, api}) {
return new Proxy(actions, {
get(target, name) {
return function (...args) {
return function(...args) {
let callback;
let method;
let isLastArgFunction = Utils.isFunction(args[args.length-1]);
Expand Down Expand Up @@ -160,6 +160,7 @@ class CommandLoader extends BaseCommandLoader {
.catch(err => {
if (instance instanceof EventEmitter) {
instance.emit('error', err);

return;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/api/_loaders/expect-assertion.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class ExpectAssertionLoader extends BaseCommandLoader {
assertion.emitter.once('error', error => {
reject(error);
});
})
});
});
});
}
Expand Down
4 changes: 1 addition & 3 deletions lib/api/assertions/_assertionInstance.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,7 @@ class AssertionInstance {

getActual() {
if (this.hasFailure()) {
return this.options.elementSelector ?
'element could not be located' :
''
return this.options.elementSelector ? 'element could not be located' : '';
}

if (Utils.isFunction(this.actual)) {
Expand Down
2 changes: 1 addition & 1 deletion lib/api/assertions/attributeContains.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ exports.assertion = function(definition, attribute, expected, msg) {
return {
message,
args: [`'${attribute}'`, this.elementSelector, `'${expected}'`]
}
};
};

this.evaluate = function(value) {
Expand Down
2 changes: 1 addition & 1 deletion lib/api/assertions/attributeEquals.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ exports.assertion = function(definition, attribute, expected, msg) {
return {
message,
args: [`'${attribute}'`, this.elementSelector, `'${expected}'`]
}
};
};

this.evaluate = function(value) {
Expand Down
2 changes: 1 addition & 1 deletion lib/api/assertions/containsText.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ exports.assertion = function(definition, expectedText, msg) {
return {
message,
args: [this.elementSelector, `'${expectedText}'`]
}
};
};

/*!
Expand Down
3 changes: 2 additions & 1 deletion lib/api/assertions/cssClassNotPresent.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ exports.assertion = function(selector, className, msg) {
elementSelector: true
};

// eslint-disable-next-line no-console
console.warn('DEPRECATED: the assertion .cssClassNotPresent() has been deprecated and will be ' +
'removed from future versions. Use assert.not.cssClassPresent().');

Expand All @@ -31,7 +32,7 @@ exports.assertion = function(selector, className, msg) {
return {
message,
args: [this.elementSelector, `'${className}'`]
}
};
};

this.expected = function() {
Expand Down
2 changes: 1 addition & 1 deletion lib/api/assertions/cssClassPresent.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ exports.assertion = function(selector, expected, msg) {
return {
message,
args: [this.elementSelector, `'${Array.isArray(expected) ? expected.join(' ') : expected}'`]
}
};
};

this.expected = function() {
Expand Down
2 changes: 1 addition & 1 deletion lib/api/assertions/cssProperty.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ exports.assertion = function(definition, cssProperty, expected, msg) {
return {
message,
args: [this.elementSelector, `'${cssProperty}`, `${expected}'`]
}
};
};

this.actual = function(passed) {
Expand Down
2 changes: 1 addition & 1 deletion lib/api/assertions/domPropertyEquals.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function formatMsg({msg, domProperty, expected, verb = function(negate) {}}) {
return {
message,
args: [`'${domProperty}'`, this.elementSelector, `'${expectedArg}'`]
}
};
}

exports.assertion = function(selector, domProperty, expected, msg) {
Expand Down
3 changes: 2 additions & 1 deletion lib/api/assertions/elementNotPresent.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ exports.assertion = function(selector, msg) {
elementSelector: true
};

// eslint-disable-next-line no-console
console.warn('DEPRECATED: the assertion .elementNotPresent() has been deprecated and will be ' +
'removed from future versions. Use assert.not.elementPresent().');

Expand All @@ -29,7 +30,7 @@ exports.assertion = function(selector, msg) {
return {
message,
args: [this.elementSelector]
}
};
};

this.pass = function(value) {
Expand Down

0 comments on commit f522d01

Please sign in to comment.