Skip to content

refactor(core): Run Prettier on packages/optimizely-sdk #420

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 1 commit into from
Mar 4, 2020
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
30 changes: 12 additions & 18 deletions packages/optimizely-sdk/karma.base.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module.exports = {
//browserStack setup
browserStack: {
username: process.env.BROWSER_STACK_USERNAME,
accessKey: process.env.BROWSER_STACK_ACCESS_KEY
accessKey: process.env.BROWSER_STACK_ACCESS_KEY,
},

// to avoid DISCONNECTED messages when connecting to BrowserStack
Expand All @@ -45,46 +45,46 @@ module.exports = {
browser: 'chrome',
browser_version: '21.0',
os: 'OS X',
os_version: 'Mountain Lion'
os_version: 'Mountain Lion',
},
bs_edge: {
base: 'BrowserStack',
os: 'Windows',
os_version: '10',
browser: 'edge',
device: null,
browser_version: '15.0'
browser_version: '15.0',
},
bs_firefox_mac: {
base: 'BrowserStack',
browser: 'firefox',
browser_version: '21.0',
os: 'OS X',
os_version: 'Mountain Lion'
os_version: 'Mountain Lion',
},
bs_ie: {
base: 'BrowserStack',
os: 'Windows',
os_version: '7',
browser: 'ie',
device: null,
browser_version: '10.0'
browser_version: '10.0',
},
bs_opera_mac: {
base: 'BrowserStack',
browser: 'opera',
browser_version: '37',
os: 'OS X',
os_version: 'Mountain Lion'
os_version: 'Mountain Lion',
},
bs_safari: {
base: 'BrowserStack',
os: 'OS X',
os_version: 'Mountain Lion',
browser: 'safari',
device: null,
browser_version: '6.2'
}
browser_version: '6.2',
},
},

browsers: ['bs_chrome_mac', 'bs_edge', 'bs_firefox_mac', 'bs_ie', 'bs_opera_mac', 'bs_safari'],
Expand All @@ -94,31 +94,25 @@ module.exports = {
frameworks: ['mocha'],

// list of files to exclude
exclude: [
],

exclude: [],

// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'./lib/**/*tests.js': ['webpack']
'./lib/**/*tests.js': ['webpack'],
},


// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress'],


// web server port
port: 9876,


// enable / disable colors in the output (reporters and logs)
colors: true,


// enable / disable watching file and executing tests whenever any file changes
autoWatch: false,

Expand All @@ -128,5 +122,5 @@ module.exports = {

// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity
}
concurrency: Infinity,
};
6 changes: 2 additions & 4 deletions packages/optimizely-sdk/karma.bs.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

// Karma configuration for cross-browser testing
const baseConfig = require('./karma.base.conf.js')
const baseConfig = require('./karma.base.conf.js');

module.exports = function(config) {
config.set({
Expand All @@ -26,8 +26,6 @@ module.exports = function(config) {
logLevel: config.LOG_INFO,

// list of files / patterns to load in the browser
files: [
'./lib/index.browser.tests.js'
],
files: ['./lib/index.browser.tests.js'],
});
};
7 changes: 2 additions & 5 deletions packages/optimizely-sdk/karma.umd.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

// Karma configuration for UMD bundle testing
const baseConfig = require('./karma.base.conf.js')
const baseConfig = require('./karma.base.conf.js');

module.exports = function(config) {
config.set({
Expand All @@ -26,9 +26,6 @@ module.exports = function(config) {
logLevel: config.LOG_INFO,

// list of files / patterns to load in the browser
files: [
'./dist/optimizely.browser.umd.min.js',
'./lib/index.browser.umdtests.js'
],
files: ['./dist/optimizely.browser.umd.min.js', './lib/index.browser.umdtests.js'],
});
};
18 changes: 13 additions & 5 deletions packages/optimizely-sdk/lib/core/audience_evaluator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ var LOG_LEVEL = enums.LOG_LEVEL;
var LOG_MESSAGES = enums.LOG_MESSAGES;
var MODULE_NAME = 'AUDIENCE_EVALUATOR';


/**
* Construct an instance of AudienceEvaluator with given options
* @param {Object=} UNSTABLE_conditionEvaluators A map of condition evaluators provided by the consumer. This enables matching
Expand All @@ -36,7 +35,7 @@ var MODULE_NAME = 'AUDIENCE_EVALUATOR';
*/
function AudienceEvaluator(UNSTABLE_conditionEvaluators) {
this.typeToEvaluatorMap = fns.assign({}, UNSTABLE_conditionEvaluators, {
'custom_attribute': customAttributeConditionEvaluator
custom_attribute: customAttributeConditionEvaluator,
});
}

Expand Down Expand Up @@ -66,8 +65,14 @@ AudienceEvaluator.prototype.evaluate = function(audienceConditions, audiencesByI
var evaluateAudience = function(audienceId) {
var audience = audiencesById[audienceId];
if (audience) {
logger.log(LOG_LEVEL.DEBUG, sprintf(LOG_MESSAGES.EVALUATING_AUDIENCE, MODULE_NAME, audienceId, JSON.stringify(audience.conditions)));
var result = conditionTreeEvaluator.evaluate(audience.conditions, this.evaluateConditionWithUserAttributes.bind(this, userAttributes));
logger.log(
LOG_LEVEL.DEBUG,
sprintf(LOG_MESSAGES.EVALUATING_AUDIENCE, MODULE_NAME, audienceId, JSON.stringify(audience.conditions))
);
var result = conditionTreeEvaluator.evaluate(
audience.conditions,
this.evaluateConditionWithUserAttributes.bind(this, userAttributes)
);
var resultText = result === null ? 'UNKNOWN' : result.toString().toUpperCase();
logger.log(LOG_LEVEL.INFO, sprintf(LOG_MESSAGES.AUDIENCE_EVALUATION_RESULT, MODULE_NAME, audienceId, resultText));
return result;
Expand Down Expand Up @@ -95,7 +100,10 @@ AudienceEvaluator.prototype.evaluateConditionWithUserAttributes = function(userA
try {
return evaluator.evaluate(condition, userAttributes, logger);
} catch (err) {
logger.log(LOG_LEVEL.ERROR, sprintf(ERROR_MESSAGES.CONDITION_EVALUATOR_ERROR, MODULE_NAME, condition.type, err.message));
logger.log(
LOG_LEVEL.ERROR,
sprintf(ERROR_MESSAGES.CONDITION_EVALUATOR_ERROR, MODULE_NAME, condition.type, err.message)
);
}
return null;
};
Expand Down
Loading