Skip to content

chore: fix all lint warnings #111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/optimizely-sdk/lib/core/decision_service/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ DecisionService.prototype.getVariation = function(experimentKey, userId, attribu
if (!fns.isEmpty(attributes)) {
if (attributes.hasOwnProperty(enums.CONTROL_ATTRIBUTES.BUCKETING_ID)) {
bucketingId = attributes[enums.CONTROL_ATTRIBUTES.BUCKETING_ID];
this.logger.log(LOG_LEVEL.DEBUG, sprintf('Setting the bucketing ID to %s.', bucketingId))
this.logger.log(LOG_LEVEL.DEBUG, sprintf('Setting the bucketing ID to %s.', bucketingId));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ describe('lib/core/decision_service', function() {

var testUserAttributes = {
'browser_type': 'firefox',
}
};
var userAttributesWithBucketingId = {
'browser_type': 'firefox',
'$opt_bucketing_id': '123456789'
Expand Down Expand Up @@ -436,7 +436,7 @@ describe('lib/core/decision_service', function() {
var userProfileServiceInstance = {
lookup: function () {
},
}
};
userProfileLookupStub = sinon.stub(userProfileServiceInstance, 'lookup');
userProfileLookupStub.returns({
user_id: 'test_user',
Expand Down
4 changes: 2 additions & 2 deletions packages/optimizely-sdk/lib/core/event_builder/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function getCommonEventParams(options) {
key: attributeKey,
type: CUSTOM_ATTRIBUTE_FEATURE_TYPE,
value: attributes[attributeKey],
});
});
}
});

Expand All @@ -77,7 +77,7 @@ function getCommonEventParams(options) {
type: CUSTOM_ATTRIBUTE_FEATURE_TYPE,
value: botFiltering,
});
};
}
return commonParams;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ describe('lib/core/event_builder', function() {

assert.deepEqual(actualParams, expectedParams);
});

it('should fill in userFeatures for user agent and bot filtering (bot filtering enabled)', function() {
var v4ConfigObj = projectConfig.createProjectConfig(testData.getTestProjectConfigWithFeatures());
var expectedParams = {
Expand Down
4 changes: 2 additions & 2 deletions packages/optimizely-sdk/lib/core/project_config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ module.exports = {
var hasReservedPrefix = attributeKey.indexOf(RESERVED_ATTRIBUTE_PREFIX) === 0;
if (attribute) {
if (hasReservedPrefix) {
logger.log(LOG_LEVEL.WARN,
logger.log(LOG_LEVEL.WARN,
sprintf('Attribute %s unexpectedly has reserved prefix %s; using attribute ID instead of reserved attribute name.', attributeKey, RESERVED_ATTRIBUTE_PREFIX));
}
return attribute.id;
Expand Down Expand Up @@ -372,7 +372,7 @@ module.exports = {
} else {
// catching improperly formatted experiments
logger.log(LOG_LEVEL.ERROR, sprintf(ERROR_MESSAGES.IMPROPERLY_FORMATTED_EXPERIMENT, MODULE_NAME, experimentKey));
return null
return null;
}
} catch (ex) {
// catching experiment not in datafile
Expand Down
98 changes: 49 additions & 49 deletions packages/optimizely-sdk/lib/core/project_config/index.tests.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion packages/optimizely-sdk/lib/index.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ module.exports = {
}
}

if (config.skipJSONValidation == null) {
// Explicitly check for null or undefined
if (config.skipJSONValidation == null) { // eslint-disable-line eqeqeq
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

config.skipJSONValidation = true;
}

Expand Down
28 changes: 14 additions & 14 deletions packages/optimizely-sdk/lib/index.browser.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ describe('javascript-sdk', function() {
xhr = sinon.useFakeXMLHttpRequest();
global.XMLHttpRequest = xhr;
requests = [];
xhr.onCreate = function (xhr) {
requests.push(xhr);
xhr.onCreate = function (req) {
requests.push(req);
};
});

Expand Down Expand Up @@ -124,7 +124,7 @@ describe('javascript-sdk', function() {
assert.strictEqual(didSetVariation, true);

var variation = optlyInstance.getForcedVariation('testExperiment', 'testUser');
assert.strictEqual(variation, 'control')
assert.strictEqual(variation, 'control');
done();
});

Expand All @@ -140,13 +140,13 @@ describe('javascript-sdk', function() {
assert.strictEqual(didSetVariation, true);

var variation = optlyInstance.getForcedVariation('testExperiment', 'testUser');
assert.strictEqual(variation, 'control')
assert.strictEqual(variation, 'control');

var didSetVariation2 = optlyInstance.setForcedVariation('testExperiment', 'testUser', null);
assert.strictEqual(didSetVariation2, true);

var variation2 = optlyInstance.getForcedVariation('testExperiment', 'testUser');
assert.strictEqual(variation2, null)
assert.strictEqual(variation2, null);
done();
});

Expand All @@ -166,10 +166,10 @@ describe('javascript-sdk', function() {


var variation = optlyInstance.getForcedVariation('testExperiment', 'testUser');
assert.strictEqual(variation, 'control')
assert.strictEqual(variation, 'control');

var variation2 = optlyInstance.getForcedVariation('testExperimentLaunched', 'testUser');
assert.strictEqual(variation2, 'controlLaunched')
assert.strictEqual(variation2, 'controlLaunched');
done();
});

Expand All @@ -191,10 +191,10 @@ describe('javascript-sdk', function() {
assert.strictEqual(didSetVariation2, true);

var variation = optlyInstance.getForcedVariation('testExperiment', 'testUser');
assert.strictEqual(variation, 'control')
assert.strictEqual(variation, 'control');

var variation2 = optlyInstance.getForcedVariation('testExperimentLaunched', 'testUser');
assert.strictEqual(variation2, null)
assert.strictEqual(variation2, null);
done();
});

Expand All @@ -216,10 +216,10 @@ describe('javascript-sdk', function() {
assert.strictEqual(didSetVariation2, true);

var variation = optlyInstance.getForcedVariation('testExperiment', 'testUser');
assert.strictEqual(variation, 'control')
assert.strictEqual(variation, 'control');

var variation2 = optlyInstance.getForcedVariation('testExperimentLaunched', 'testUser');
assert.strictEqual(variation2, 'variationLaunched')
assert.strictEqual(variation2, 'variationLaunched');
done();
});

Expand All @@ -235,13 +235,13 @@ describe('javascript-sdk', function() {
assert.strictEqual(didSetVariation, true);

var variation = optlyInstance.getVariation('testExperiment', 'testUser');
assert.strictEqual(variation, 'control')
assert.strictEqual(variation, 'control');

var didSetVariation2 = optlyInstance.setForcedVariation('testExperiment', 'testUser', 'variation');
assert.strictEqual(didSetVariation2, true);

var variation = optlyInstance.getVariation('testExperiment', 'testUser');
assert.strictEqual(variation, 'variation')
assert.strictEqual(variation, 'variation');
done();
});

Expand All @@ -257,7 +257,7 @@ describe('javascript-sdk', function() {
assert.strictEqual(didSetVariation, true);

var variation = optlyInstance.getVariation('testExperimentNotRunning', 'testUser');
assert.strictEqual(variation, null)
assert.strictEqual(variation, null);

done();
});
Expand Down
30 changes: 15 additions & 15 deletions packages/optimizely-sdk/lib/optimizely/index.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ describe('lib/optimizely', function() {
});
bucketStub.returns('111129');

var activate = instance.activate('testExperiment', 'testUser');;
var activate = instance.activate('testExperiment', 'testUser');

assert.strictEqual(activate, 'variation');
eventDispatcherPromise.then(function() {
Expand All @@ -302,7 +302,7 @@ describe('lib/optimizely', function() {
'testUser',
'testExperiment'));
done();
})
});
});

it('should execute a custom dispatchEvent\'s promise in track', function(done) {
Expand All @@ -317,7 +317,7 @@ describe('lib/optimizely', function() {
});
bucketStub.returns('111129');

var activate = instance.activate('testExperiment', 'testUser');;
var activate = instance.activate('testExperiment', 'testUser');

assert.strictEqual(activate, 'variation');
instance.track('testEvent', 'testUser');
Expand All @@ -329,9 +329,9 @@ describe('lib/optimizely', function() {
'testEvent',
'testUser'));
done();
})
});
});
})
});

describe('APIs', function() {
var optlyInstance;
Expand Down Expand Up @@ -662,7 +662,7 @@ describe('lib/optimizely', function() {
sinon.assert.callCount(createdLogger.log, 3);

var logMessage0 = createdLogger.log.args[0][1];
assert.strictEqual(logMessage0, sprintf(LOG_MESSAGES.USER_HAS_NO_FORCED_VARIATION,'PROJECT_CONFIG','testUser'));
assert.strictEqual(logMessage0, sprintf(LOG_MESSAGES.USER_HAS_NO_FORCED_VARIATION, 'PROJECT_CONFIG', 'testUser'));

var logMessage1 = createdLogger.log.args[1][1];
assert.strictEqual(logMessage1, sprintf(LOG_MESSAGES.USER_NOT_IN_EXPERIMENT, 'DECISION_SERVICE', 'testUser', 'testExperimentWithAudiences'));
Expand All @@ -676,7 +676,7 @@ describe('lib/optimizely', function() {
sinon.assert.callCount(createdLogger.log, 3);

var logMessage0 = createdLogger.log.args[0][1];
assert.strictEqual(logMessage0, sprintf(LOG_MESSAGES.USER_HAS_NO_FORCED_VARIATION,'PROJECT_CONFIG','testUser'));
assert.strictEqual(logMessage0, sprintf(LOG_MESSAGES.USER_HAS_NO_FORCED_VARIATION, 'PROJECT_CONFIG', 'testUser'));

var logMessage1 = createdLogger.log.args[1][1];
assert.strictEqual(logMessage1, sprintf(LOG_MESSAGES.USER_NOT_IN_EXPERIMENT, 'DECISION_SERVICE', 'testUser', 'groupExperiment1'));
Expand Down Expand Up @@ -776,7 +776,7 @@ describe('lib/optimizely', function() {
sinon.assert.calledThrice(createdLogger.log);

var logMessage0 = createdLogger.log.args[0][1];
assert.strictEqual(logMessage0, sprintf(LOG_MESSAGES.USER_HAS_NO_FORCED_VARIATION,'PROJECT_CONFIG','user1'));
assert.strictEqual(logMessage0, sprintf(LOG_MESSAGES.USER_HAS_NO_FORCED_VARIATION, 'PROJECT_CONFIG', 'user1'));
var logMessage1 = createdLogger.log.args[1][1];
assert.strictEqual(logMessage1, sprintf(LOG_MESSAGES.USER_FORCED_IN_VARIATION, 'DECISION_SERVICE', 'user1', 'control'));

Expand Down Expand Up @@ -1219,7 +1219,7 @@ describe('lib/optimizely', function() {

sinon.assert.callCount(createdLogger.log, 4);
var logMessage0 = createdLogger.log.args[0][1];
assert.strictEqual(logMessage0, sprintf(LOG_MESSAGES.USER_HAS_NO_FORCED_VARIATION,'PROJECT_CONFIG','testUser'));
assert.strictEqual(logMessage0, sprintf(LOG_MESSAGES.USER_HAS_NO_FORCED_VARIATION, 'PROJECT_CONFIG', 'testUser'));
var logMessage1 = createdLogger.log.args[1][1];
assert.strictEqual(logMessage1, sprintf(LOG_MESSAGES.USER_NOT_IN_EXPERIMENT, 'DECISION_SERVICE', 'testUser', 'testExperimentWithAudiences'));
var logMessage2 = createdLogger.log.args[2][1];
Expand All @@ -1242,7 +1242,7 @@ describe('lib/optimizely', function() {
optlyInstance.track('testEvent', 'testUser');
sinon.assert.notCalled(eventDispatcher.dispatchEvent);
var logMessage0 = createdLogger.log.args[0][1];
assert.strictEqual(logMessage0, sprintf(LOG_MESSAGES.USER_HAS_NO_FORCED_VARIATION,'PROJECT_CONFIG','testUser'));
assert.strictEqual(logMessage0, sprintf(LOG_MESSAGES.USER_HAS_NO_FORCED_VARIATION, 'PROJECT_CONFIG', 'testUser'));
var logMessage1 = createdLogger.log.args[1][1];
assert.strictEqual(logMessage1, sprintf(LOG_MESSAGES.NOT_TRACKING_USER_FOR_EXPERIMENT, 'OPTIMIZELY', 'testUser', 'testExperiment'));
});
Expand Down Expand Up @@ -1320,9 +1320,9 @@ describe('lib/optimizely', function() {
assert.deepEqual(eventDispatcherCall[0], expectedObj);

var logMessage0 = createdLogger.log.args[0][1];
assert.strictEqual(logMessage0, sprintf(LOG_MESSAGES.USER_HAS_NO_FORCED_VARIATION,'PROJECT_CONFIG','testUser'));
assert.strictEqual(logMessage0, sprintf(LOG_MESSAGES.USER_HAS_NO_FORCED_VARIATION, 'PROJECT_CONFIG', 'testUser'));
var logMessage1 = createdLogger.log.args[1][1];
assert.strictEqual(logMessage1, sprintf(LOG_MESSAGES.USER_HAS_NO_FORCED_VARIATION,'PROJECT_CONFIG','testUser'));
assert.strictEqual(logMessage1, sprintf(LOG_MESSAGES.USER_HAS_NO_FORCED_VARIATION, 'PROJECT_CONFIG', 'testUser'));
var logMessage2 = createdLogger.log.args[2][1];
assert.strictEqual(logMessage2, sprintf(LOG_MESSAGES.EXPERIMENT_NOT_RUNNING, 'DECISION_SERVICE', 'testExperimentNotRunning'));
var logMessage3 = createdLogger.log.args[3][1];
Expand Down Expand Up @@ -1421,7 +1421,7 @@ describe('lib/optimizely', function() {
sinon.assert.calledThrice(createdLogger.log);

var logMessage0 = createdLogger.log.args[0][1];
assert.strictEqual(logMessage0, sprintf(LOG_MESSAGES.USER_HAS_NO_FORCED_VARIATION,'PROJECT_CONFIG','user1'));
assert.strictEqual(logMessage0, sprintf(LOG_MESSAGES.USER_HAS_NO_FORCED_VARIATION, 'PROJECT_CONFIG', 'user1'));
var logMessage1 = createdLogger.log.args[1][1];
assert.strictEqual(logMessage1, sprintf(LOG_MESSAGES.USER_FORCED_IN_VARIATION, 'DECISION_SERVICE', 'user1', 'control'));

Expand Down Expand Up @@ -1524,7 +1524,7 @@ describe('lib/optimizely', function() {
sinon.assert.calledThrice(createdLogger.log);

var logMessage0 = createdLogger.log.args[0][1];
assert.strictEqual(logMessage0, sprintf(LOG_MESSAGES.USER_HAS_NO_FORCED_VARIATION,'PROJECT_CONFIG','testUser'));
assert.strictEqual(logMessage0, sprintf(LOG_MESSAGES.USER_HAS_NO_FORCED_VARIATION, 'PROJECT_CONFIG', 'testUser'));
var logMessage1 = createdLogger.log.args[1][1];
assert.strictEqual(logMessage1, sprintf(LOG_MESSAGES.USER_NOT_IN_EXPERIMENT, 'DECISION_SERVICE', 'testUser', 'testExperimentWithAudiences'));
var logMessage2 = createdLogger.log.args[2][1];
Expand Down Expand Up @@ -1591,7 +1591,7 @@ describe('lib/optimizely', function() {
sinon.assert.calledTwice(createdLogger.log);

var logMessage0 = createdLogger.log.args[0][1];
assert.strictEqual(logMessage0, sprintf(LOG_MESSAGES.USER_HAS_NO_FORCED_VARIATION,'PROJECT_CONFIG','user1'));
assert.strictEqual(logMessage0, sprintf(LOG_MESSAGES.USER_HAS_NO_FORCED_VARIATION, 'PROJECT_CONFIG', 'user1'));
var logMessage = createdLogger.log.args[1][1];
assert.strictEqual(logMessage, sprintf(LOG_MESSAGES.USER_FORCED_IN_VARIATION, 'DECISION_SERVICE', 'user1', 'control'));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ describe('lib/plugins/event_dispatcher/browser', function() {
xhr = sinon.useFakeXMLHttpRequest();
global.XMLHttpRequest = xhr;
requests = [];
xhr.onCreate = function (xhr) {
requests.push(xhr);
xhr.onCreate = function (req) {
requests.push(req);
};
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ module.exports = {
};

var requestCallback = function(error, response, body) {
if (response && response.statusCode && response.statusCode >= 200 && response.statusCode < 400 && callback && typeof callback == 'function') {
if (response && response.statusCode && response.statusCode >= 200 && response.statusCode < 400 && callback && typeof callback === 'function') {
callback();
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('lib/plugins/event_dispatcher/node', function() {

eventDispatcher.dispatchEvent(eventObj)
.on('response', function(response) {
assert.isTrue(response.statusCode == 200);
assert.isTrue(response.statusCode === 200);
done();
})
.on('error', function(error) {
Expand Down
2 changes: 1 addition & 1 deletion packages/optimizely-sdk/lib/plugins/logger/index.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ describe('lib/plugins/logger', function() {
defaultLogger.setLogLevel(undefined);
expect(defaultLogger.logLevel).to.equal(LOG_LEVEL.ERROR);

defaultLogger.setLogLevel("abc");
defaultLogger.setLogLevel('abc');
expect(defaultLogger.logLevel).to.equal(LOG_LEVEL.ERROR);
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/optimizely-sdk/lib/tests/test_data.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ var config = {

var getParsedAudiences = [{
name: 'Firefox users',
conditions: ["and", ["or", ["or", {"name": "browser_type", "type": "custom_attribute", "value": "firefox"}]]],
conditions: ['and', ['or', ['or', {'name': 'browser_type', 'type': 'custom_attribute', 'value': 'firefox'}]]],
id: '11154'
}];

Expand Down