Skip to content

Commit

Permalink
Fix space-infix-ops rule.
Browse files Browse the repository at this point in the history
  • Loading branch information
garg3133 committed Aug 22, 2023
1 parent 4ff2aac commit 078ecb6
Show file tree
Hide file tree
Showing 24 changed files with 76 additions and 76 deletions.
2 changes: 1 addition & 1 deletion lib/api/assertions/_assertionInstance.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class AssertionInstance {
}

static init({nightwatchInstance, args, fileName, options}) {
if (Utils.isFunction(args[args.length-1])) {
if (Utils.isFunction(args[args.length - 1])) {
this.__doneCallback = args.pop();
} else {
this.__doneCallback = function(result) {
Expand Down
14 changes: 7 additions & 7 deletions lib/api/expect/assertions/_baseAssertion.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class BaseAssertion {
init() {
const {waitForConditionTimeout, waitForConditionPollInterval, abortOnAssertionFailure} = this.client.api.globals;

let assertions = this.flag('assertions') || 0;
const assertions = this.flag('assertions') || 0;
this.flag('assertions', assertions + 1);

this.promise = this.flag('promise');
Expand Down Expand Up @@ -340,7 +340,7 @@ class BaseAssertion {
}

getResult(value, fn) {
let result = fn.call(this);
const result = fn.call(this);
this.setNegate();

return this.negate ? !result : result;
Expand All @@ -357,7 +357,7 @@ class BaseAssertion {
}

getElapsedTime() {
let timeNow = new Date().getTime();
const timeNow = new Date().getTime();

return timeNow - this.emitter.startTime;
}
Expand Down Expand Up @@ -467,8 +467,8 @@ class BaseAssertion {
}

'@matchesFlag'(re) {
let adverb = this.hasFlag('that') || this.hasFlag('which');
let verb = adverb ? 'matches' : 'match';
const adverb = this.hasFlag('that') || this.hasFlag('which');
const verb = adverb ? 'matches' : 'match';

this.conditionFlag(re, function() {
return re.test(this.resultValue);
Expand All @@ -483,15 +483,15 @@ class BaseAssertion {
conditionFlag(value, conditionFn, arrverb) {
this.passed = this.getResult(value, conditionFn);

let verb = this.negate ? arrverb[0]: arrverb[1];
let verb = this.negate ? arrverb[0] : arrverb[1];
this.expected = `${verb} '${value}'`;
this.actual = this.resultValue;

if (this.retries > 0) {
return;
}

let needsSpace = this.messageParts.length === 0 ? true : this.messageParts[this.messageParts.length-1].slice(-1) !== ' ';
const needsSpace = this.messageParts.length === 0 ? true : this.messageParts[this.messageParts.length - 1].slice(-1) !== ' ';
if (needsSpace) {
verb = ' ' + verb;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/api/expect/assertions/element/type.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class TypeAssertion extends BaseAssertion {
this.article = ['a', 'e', 'i', 'o'].indexOf(type.toString().substring(0, 1)) > -1 ? 'an' : 'a';
this.hasCustomMessage = typeof msg != 'undefined';
this.flag('typeFlag', true);
this.message = msg || 'Expected element %s to ' + (this.negate ? 'not be' : 'be') + ' ' + this.article +' ' + type;
this.message = msg || 'Expected element %s to ' + (this.negate ? 'not be' : 'be') + ' ' + this.article + ' ' + type;

this.start();
}
Expand Down
2 changes: 1 addition & 1 deletion lib/core/asynctree.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class AsyncTree extends EventEmitter{
}

shouldRejectNodePromise(err, node = this.currentNode) {
if ((err.isExpect|| node.namespace === 'assert') && this.currentNode.isES6Async) {
if ((err.isExpect || node.namespace === 'assert') && this.currentNode.isES6Async) {
return true;
}

Expand Down
4 changes: 2 additions & 2 deletions lib/element/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ class ElementCommand extends EventEmitter {
}

if (passedArgs < expectedArgs - 1 || passedArgs > expectedArgs) {
const error = new Error(`${this.commandName} method expects ${(expectedArgs - 1)} `+
const error = new Error(`${this.commandName} method expects ${(expectedArgs - 1)} ` +
`(or ${expectedArgs} if using implicit "css selector" strategy) arguments - ${passedArgs} given.`);
error.rejectPromise = rejectPromise;

Expand Down Expand Up @@ -339,7 +339,7 @@ class ElementCommand extends EventEmitter {
this.__retryOnFailure = retryAction;
}

let {WebdriverElementId} = this.selector;
const {WebdriverElementId} = this.selector;
if (WebdriverElementId) {
this.WebdriverElementId = WebdriverElementId;
}
Expand Down
14 changes: 7 additions & 7 deletions lib/http/formatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ class ResponseFormatter {
*/
static jsonStringify(s) {
try {
let json = JSON.stringify(s);
const json = JSON.stringify(s);
if (json) {
return json.replace(jsonRegex, function jsonRegexReplace(c) {
return '\\u'+('0000'+c.charCodeAt(0).toString(16)).slice(-4);
return '\\u' + ('0000' + c.charCodeAt(0).toString(16)).slice(-4);
});
}

Expand All @@ -29,9 +29,9 @@ class ResponseFormatter {
}

static stripUnknownChars(str) {
let x = [];
const x = [];
let i = 0;
let length = str.length;
const length = str.length;

for (i; i < length; i++) {
if (str.charCodeAt(i)) {
Expand All @@ -43,9 +43,9 @@ class ResponseFormatter {
}

static formatHostname(hostname, port, useSSL) {
let isLocalHost = ['127.0.0.1', 'localhost'].indexOf(hostname) > -1;
let protocol = useSSL ? 'https://' : 'http://';
let isPortDefault = [80, 443].indexOf(port) > -1;
const isLocalHost = ['127.0.0.1', 'localhost'].indexOf(hostname) > -1;
const protocol = useSSL ? 'https://' : 'http://';
const isPortDefault = [80, 443].indexOf(port) > -1;

if (isLocalHost) {
return '';
Expand Down
2 changes: 1 addition & 1 deletion lib/http/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ class HttpRequest extends EventEmitter {

createHttpRequest() {
try {
const req = (this.use_ssl ? https: http).request(this.reqOptions, response => {
const req = (this.use_ssl ? https : http).request(this.reqOptions, response => {
this.httpResponse = new HttpResponse(response, this);
this.httpResponse.on('complete', this.onRequestComplete.bind(this));
this.proxyEvents(this.httpResponse, ['response', 'error', 'success']);
Expand Down
6 changes: 3 additions & 3 deletions lib/reporter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,11 @@ class Reporter extends SimplifiedReporter {
logTestCase(testName) {
if (this.settings.live_output || !this.settings.parallel_mode) {
// eslint-disable-next-line no-console
console.log(`${(!this.settings.silent?'\n\n':'')}\n Running ${colors.green(testName)}${colors.stack_trace(':')}`);
console.log(`${(!this.settings.silent ? '\n\n' : '')}\n Running ${colors.green(testName)}${colors.stack_trace(':')}`);

const {columns = 100} = process.stdout;
// eslint-disable-next-line no-console
console.log(colors.stack_trace(new Array(Math.max(100, Math.floor(columns/2))).join('─')));
console.log(colors.stack_trace(new Array(Math.max(100, Math.floor(columns / 2))).join('─')));
//}
} else {
// eslint-disable-next-line no-console
Expand Down Expand Up @@ -327,7 +327,7 @@ class Reporter extends SimplifiedReporter {
printSimplifiedTestResult(ok, elapsedTime, isWorker) {
const {currentTest} = this;

const result = [colors[ok ? 'green': 'red'](Utils.symbols[ok ? 'ok' : 'fail'])];
const result = [colors[ok ? 'green' : 'red'](Utils.symbols[ok ? 'ok' : 'fail'])];
if (!this.unitTestsMode) {
if (isWorker) {
result.push(colors.bgBlack.white.bold(this.settings.testEnv));
Expand Down
2 changes: 1 addition & 1 deletion lib/reporter/summary.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module.exports = class Summary {
*/
static getFailedSuiteContent({testSuite, testSuiteName, index = 0, startSessionEnabled = true}) {
const testcases = Object.keys(testSuite.completed);
const initial = [colors.red(` ${Utils.symbols.fail} ${index+1}) ${testSuiteName}`)];
const initial = [colors.red(` ${Utils.symbols.fail} ${index + 1}) ${testSuiteName}`)];

return testcases.reduce((prev, name) => {
const testcase = testSuite.completed[name];
Expand Down
4 changes: 2 additions & 2 deletions lib/runner/concurrency/child-process.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class ChildProcess extends EventEmitter {
writeToStdout(data) {
data = data.toString().trim();

const color_pair = this.availColors[this.index%4];
const color_pair = this.availColors[this.index % 4];
let output = '';

if (ChildProcess.prevIndex !== this.index) {
Expand Down Expand Up @@ -148,7 +148,7 @@ class ChildProcess extends EventEmitter {
}));
}

const color_pair = this.availColors[this.index%4];
const color_pair = this.availColors[this.index % 4];

this.printLog(' Running: ' + Logger.colors[color_pair[0]][color_pair[1]](` ${this.env_itemKey} `));

Expand Down
2 changes: 1 addition & 1 deletion lib/runner/concurrency/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ class Concurrency extends EventEmitter {

return this.runChildProcess(childProcess, outputLabel, availColors, 'workers')
.then(_ => {
remaining -=1;
remaining -= 1;

if (remaining > 0) {
next();
Expand Down
4 changes: 2 additions & 2 deletions lib/runner/test-runners/mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class MochaRunner {

if (this.isTestWorker()) {
const filePath = this.argv.test;
const reportFilename = filePath.substring(filePath.lastIndexOf('/')+1).split('.')[0];
const reportFilename = filePath.substring(filePath.lastIndexOf('/') + 1).split('.')[0];
this.mochaOpts.isWorker = true;

if (argv.reporter.includes('mocha-junit-reporter')) {
Expand Down Expand Up @@ -194,7 +194,7 @@ class MochaRunner {
const client = mochaSuite && mochaSuite.client;

if (client && client.sessionId) {
let request = client.transport.createHttpRequest({
const request = client.transport.createHttpRequest({
path: `/session/${client.sessionId}`
});

Expand Down
2 changes: 1 addition & 1 deletion lib/transport/selenium-webdriver/cdp.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class Cdp {
async getConnection(driver, reset=false) {
async getConnection(driver, reset = false) {
if (!reset && this._connection) {
return this._connection;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/logger/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ class Logger {
if (errorObj.help) {
content.push(this.colors.brown('\n Try fixing by :'));
errorObj.help.forEach((step, index) => {
content.push(` ${this.colors.blue(index+1)}. ${step}`);
content.push(` ${this.colors.blue(index + 1)}. ${step}`);
});
}

Expand Down
2 changes: 1 addition & 1 deletion test/extra/pageobjects/commands/workingCommandsClass.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = class RealCommands {
selector,
suppressNotFoundErrors: true
}, function(result) {
return callback(result ? result.value: []);
return callback(result ? result.value : []);
});
}

Expand Down
4 changes: 2 additions & 2 deletions test/lib/command-mocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ module.exports = {
}, true);
},

w3cSelected(elementId ='5cc459b8-36a8-3042-8b4a-258883ea642b', value = true) {
w3cSelected(elementId = '5cc459b8-36a8-3042-8b4a-258883ea642b', value = true) {
MockServer.addMock({
url: `/session/13521-10219-202/element/${elementId}/selected`,
method: 'GET',
Expand All @@ -279,7 +279,7 @@ module.exports = {
}, true);
},

w3cEnabled(elementId ='5cc459b8-36a8-3042-8b4a-258883ea642b', value = true) {
w3cEnabled(elementId = '5cc459b8-36a8-3042-8b4a-258883ea642b', value = true) {
MockServer.addMock({
url: `/session/13521-10219-202/element/${elementId}/enabled`,
method: 'GET',
Expand Down
4 changes: 2 additions & 2 deletions test/lib/nightwatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ module.exports = new function () {
}

this.createClient = function(options = {}, reporter = null, argv = {}) {
let opts = {
const opts = {
selenium: {
port: 10195,
host: 'localhost',
Expand Down Expand Up @@ -118,7 +118,7 @@ module.exports = new function () {
});
};

this.initW3CClient = function(opts = {}, argv={}) {
this.initW3CClient = function(opts = {}, argv = {}) {
const settings = Object.assign({
selenium: {
version2: false,
Expand Down
8 changes: 4 additions & 4 deletions test/lib/nocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ module.exports = {
return this;
},

childElementsNotFound(selector='#badElement') {
childElementsNotFound(selector = '#badElement') {
nock('http://localhost:10195')
.post('/wd/hub/session/1352110219202/element/0/elements', {'using': 'css selector', 'value': selector})
.reply(200, {
Expand All @@ -203,14 +203,14 @@ module.exports = {
return this;
},

childElementsFound(selector='#weblogin') {
childElementsFound(selector = '#weblogin') {
nock('http://localhost:10195')
.post('/wd/hub/session/1352110219202/element/0/elements', {'using': 'css selector', 'value': selector})
.reply(200, {
status: 0,
state: 'success',
value: [{'element-6066-11e4-a52e-4f735466cecf': '0'}]
})
});

return this;
},
Expand Down Expand Up @@ -589,7 +589,7 @@ module.exports = {
.reply(200, {
status: 0,
state: 'success',
value : {
value: {
domain: 'cookie-domain',
name: name,
value: value
Expand Down
2 changes: 1 addition & 1 deletion test/src/analytics/testAnalytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ describe('test analytics utility', function() {

const analyticsNock = Nocks.analyticsCollector(analytics.__getGoogleAnalyticsPath());
const err = new Error('test');
err.name ='UserGeneratedError';
err.name = 'UserGeneratedError';

await analytics.collectErrorEvent(err);

Expand Down
Loading

0 comments on commit 078ecb6

Please sign in to comment.