Skip to content
This repository has been archived by the owner on Aug 26, 2024. It is now read-only.

Commit

Permalink
refs opencomponents#436 Run eslint --fix
Browse files Browse the repository at this point in the history
  • Loading branch information
elboletaire committed Apr 7, 2017
1 parent fe5ab2b commit 87d3cde
Show file tree
Hide file tree
Showing 167 changed files with 1,680 additions and 1,680 deletions.
8 changes: 4 additions & 4 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
'use strict';

var _ = require('underscore');
const _ = require('underscore');

module.exports = function(grunt){

var taskObject = { pkg: grunt.file.readJSON('package.json') };
const taskObject = { pkg: grunt.file.readJSON('package.json') };

grunt.file.expand('tasks/*.js', '!tasks/_*.js').forEach(function(file) {
var name = file.split('/');
let name = file.split('/');
name = name[name.length - 1].replace('.js', '');
var task = require('./' + file);
const task = require('./' + file);

if(_.isFunction(task)) {
task(grunt);
Expand Down
18 changes: 9 additions & 9 deletions client/src/components-renderer.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
'use strict';

var Cache = require('nice-cache');
const Cache = require('nice-cache');

var GetComponentsData = require('./get-components-data');
var ProcessClientResponse = require('./process-client-responses');
var RenderComponents = require('./render-components');
var sanitiser = require('./sanitiser');
var _ = require('./utils/helpers');
const GetComponentsData = require('./get-components-data');
const ProcessClientResponse = require('./process-client-responses');
const RenderComponents = require('./render-components');
const sanitiser = require('./sanitiser');
const _ = require('./utils/helpers');

module.exports = function(config, renderTemplate){

var cache = new Cache(config.cache),
let cache = new Cache(config.cache),
getComponentsData = new GetComponentsData(config),
renderComponents = new RenderComponents(cache, renderTemplate),
processClientReponses = new ProcessClientResponse(cache, config);
Expand All @@ -19,7 +19,7 @@ module.exports = function(config, renderTemplate){

options = sanitiser.sanitiseGlobalRenderOptions(options, config);

var toDo = [];
const toDo = [];

_.each(components, function(component, i){
component.version = component.version || config.components[component.name];
Expand All @@ -35,7 +35,7 @@ module.exports = function(config, renderTemplate){
getComponentsData(toDo, options, function(){
renderComponents(toDo, options, function(){
processClientReponses(toDo, options, function(){
var errors = [],
let errors = [],
results = [],
hasErrors = false;

Expand Down
22 changes: 11 additions & 11 deletions client/src/get-compiled-template.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
'use strict';

var format = require('stringformat');
var request = require('minimal-request');
const format = require('stringformat');
const request = require('minimal-request');

var settings = require('./settings');
var TryGetCached = require('./try-get-cached');
var requireTemplate = require('./utils/require-template');
const settings = require('./settings');
const TryGetCached = require('./try-get-cached');
const requireTemplate = require('./utils/require-template');

module.exports = function(cache){
var tryGetCached = new TryGetCached(cache);
const tryGetCached = new TryGetCached(cache);

return function(template, useCache, timeout, callback){
var getTemplateFromS3 = function(cb){
const getTemplateFromS3 = function(cb){
request({
url: template.src,
timeout: timeout
}, function(err, templateText){
if(!!err){
if(err){
return cb({
status: err,
response: {
Expand All @@ -25,11 +25,11 @@ module.exports = function(cache){
});
}

var type = template.type;
let type = template.type;
if (type === 'jade') { type = 'oc-template-jade'; }
if (type === 'handlebars') { type = 'oc-template-handlebars'; }

var ocTemplate;
let ocTemplate;
try {
ocTemplate = requireTemplate(type);
} catch (err) {
Expand All @@ -40,7 +40,7 @@ module.exports = function(cache){
});
};

if(!!useCache){
if(useCache){
return tryGetCached('template', template.key, getTemplateFromS3, callback);
}

Expand Down
44 changes: 22 additions & 22 deletions client/src/get-components-data.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
'use strict';

var format = require('stringformat');
var request = require('minimal-request');
const format = require('stringformat');
const request = require('minimal-request');

var settings = require('./settings');
var HrefBuilder = require('./href-builder');
var _ = require('./utils/helpers');
const settings = require('./settings');
const HrefBuilder = require('./href-builder');
const _ = require('./utils/helpers');

module.exports = function(config){
var hrefBuilder = new HrefBuilder(config);
const hrefBuilder = new HrefBuilder(config);

var handleErrorResponse = function(requestDetails, error, response, components) {
var errorDetails = error ? error.toString() : undefined;
const handleErrorResponse = function(requestDetails, error, response, components) {
let errorDetails = error ? error.toString() : undefined;

if (response && response.error) {
if (errorDetails) {
Expand All @@ -25,7 +25,7 @@ module.exports = function(config){
errorDetails = settings.emptyResponse;
}

var responses = [];
const responses = [];
_.each(components, function(){
responses.push({
response: {
Expand All @@ -37,8 +37,8 @@ module.exports = function(config){
return responses;
};

var performPost = function(endpoint, serverRendering, options, callback) {
var requestDetails = {
const performPost = function(endpoint, serverRendering, options, callback) {
const requestDetails = {
url: endpoint,
method: 'post',
headers: options.headers,
Expand All @@ -59,11 +59,11 @@ module.exports = function(config){
});
};

var performGet = function(endpoint, serverRendering, options, callback) {
var component = serverRendering.components[0];
var requestUrl = hrefBuilder.prepareServerGet(endpoint, component, options);
const performGet = function(endpoint, serverRendering, options, callback) {
const component = serverRendering.components[0];
const requestUrl = hrefBuilder.prepareServerGet(endpoint, component, options);

var requestDetails = {
const requestDetails = {
url: requestUrl,
method: 'get',
headers: options.headers,
Expand All @@ -87,7 +87,7 @@ module.exports = function(config){
};

return function(toDo, options, cb){
var serverRenderingFail = settings.serverSideRenderingFail,
let serverRenderingFail = settings.serverSideRenderingFail,
serverRendering = { components: [], positions: [] },
serverRenderingEndpoint = hrefBuilder.server(options);

Expand All @@ -103,7 +103,7 @@ module.exports = function(config){
} else if(!serverRenderingEndpoint){
_.each(toDo, function(action){
action.result.error = serverRenderingFail;
if(!!options.disableFailoverRendering){
if(options.disableFailoverRendering){
action.result.html = '';
action.done = true;
} else {
Expand All @@ -115,21 +115,21 @@ module.exports = function(config){
return cb(serverRenderingFail);
}

var performRequest = (serverRendering.components.length === 1) ? performGet : performPost;
const performRequest = (serverRendering.components.length === 1) ? performGet : performPost;

performRequest(serverRenderingEndpoint, serverRendering, options, function(responses) {
_.each(responses, function(response, i){
var action = toDo[serverRendering.positions[i]];
const action = toDo[serverRendering.positions[i]];

if(action.render === 'server'){
if(response.status !== 200){

var errorDetails;
let errorDetails;
if(!response.status && response.response.error){
errorDetails = response.response.error;
} else {

var errorDescription = (response.response && response.response.error);
let errorDescription = (response.response && response.response.error);
if(errorDescription && response.response.details && response.response.details.originalError){
errorDescription += response.response.details.originalError;
}
Expand All @@ -138,7 +138,7 @@ module.exports = function(config){
}

action.result.error = new Error(format(serverRenderingFail, errorDetails));
if(!!options.disableFailoverRendering){
if(options.disableFailoverRendering){
action.result.html = '';
action.done = true;
} else {
Expand Down
28 changes: 14 additions & 14 deletions client/src/get-components-info.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
'use strict';

var format = require('stringformat');
var request = require('minimal-request');
const format = require('stringformat');
const request = require('minimal-request');

var settings = require('./settings');
var sanitiser = require('./sanitiser');
var _ = require('./utils/helpers');
const settings = require('./settings');
const sanitiser = require('./sanitiser');
const _ = require('./utils/helpers');

module.exports = function(config) {

Expand All @@ -20,14 +20,14 @@ module.exports = function(config) {

options = sanitiser.sanitiseGlobalGetInfoOptions(options);

var serverRenderingEndpoint;
let serverRenderingEndpoint;
if(!!options && !!options.registries && !!options.registries.serverRendering){
serverRenderingEndpoint = options.registries.serverRendering;
} else if(!!config && !!config.registries){
serverRenderingEndpoint = config.registries.serverRendering;
}

var actions = { requestedComponents: [], responseData: [] };
const actions = { requestedComponents: [], responseData: [] };

_.each(components, function(component) {
actions.requestedComponents.push({
Expand All @@ -41,7 +41,7 @@ module.exports = function(config) {
});
});

var requestDetails = {
const requestDetails = {
url: serverRenderingEndpoint,
method: 'post',
headers: options.headers,
Expand All @@ -55,7 +55,7 @@ module.exports = function(config) {
request(requestDetails, function(error, responses) {
if(!!error || !responses || _.isEmpty(responses)) {
responses = [];
var errorDetails = !!error ? error.toString() : settings.emptyResponse;
const errorDetails = error ? error.toString() : settings.emptyResponse;
_.each(actions.requestedComponents, function(){
responses.push({
response: {
Expand All @@ -65,18 +65,18 @@ module.exports = function(config) {
});
}

var errors = [];
var hasErrors = false;
const errors = [];
let hasErrors = false;

_.each(responses, function(response, i) {
var responseData = actions.responseData[i];
const responseData = actions.responseData[i];

if (response.status !== 200) {
var errorDetails;
let errorDetails;
if (!response.status && response.response.error) {
errorDetails = response.response.error;
} else {
var errorDescription = (response.response && response.response.error);
let errorDescription = (response.response && response.response.error);
if (errorDescription && response.response.details && response.response.details.originalError) {
errorDescription += response.response.details.originalError;
}
Expand Down
8 changes: 4 additions & 4 deletions client/src/get-oc-client-script.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
'use strict';

var fs = require('fs');
var path = require('path');
const fs = require('fs');
const path = require('path');

var TryGetCached = require('./try-get-cached');
const TryGetCached = require('./try-get-cached');

module.exports = function(cache){

var tryGetCached = new TryGetCached(cache);
const tryGetCached = new TryGetCached(cache);

return function(callback){
tryGetCached('scripts', 'oc-client', function(cb){
Expand Down
20 changes: 10 additions & 10 deletions client/src/href-builder.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
'use strict';

var querystring = require('querystring');
var url = require('url');
var settings = require('./settings');
var mergeObjects = require('./utils/merge-objects');
const querystring = require('querystring');
const url = require('url');
const settings = require('./settings');
const mergeObjects = require('./utils/merge-objects');

module.exports = function(config){
return {
client: function(component, options){
var clientRenderingEndpoint;
let clientRenderingEndpoint;

if(!!options && !!options.registries && !!options.registries.clientRendering){
clientRenderingEndpoint = options.registries.clientRendering;
Expand All @@ -22,7 +22,7 @@ module.exports = function(config){
throw settings.missingComponentName;
}

var lang = options.headers['accept-language'],
let lang = options.headers['accept-language'],
forwardLang = config.forwardAcceptLanguageToClient === true;

if(!forwardLang && options.forwardAcceptLanguageToClient === true){
Expand All @@ -34,10 +34,10 @@ module.exports = function(config){
component.parameters['__ocAcceptLanguage'] = lang;
}

var versionSegment = !!component.version ? ('/' + component.version) : '',
let versionSegment = component.version ? ('/' + component.version) : '',
registryUrl = clientRenderingEndpoint,
registrySegment = registryUrl.slice(-1) === '/' ? registryUrl : (registryUrl + '/'),
qs = !!component.parameters ? ('/?' + querystring.stringify(component.parameters)) : '';
qs = component.parameters ? ('/?' + querystring.stringify(component.parameters)) : '';

return url.resolve(registrySegment, component.name) + versionSegment + qs;
},
Expand All @@ -51,9 +51,9 @@ module.exports = function(config){
},

prepareServerGet: function(baseUrl, component, options) {
var urlPath = component.name + (component.version ? '/' + component.version : '');
const urlPath = component.name + (component.version ? '/' + component.version : '');

var qs = '';
let qs = '';
if (component.parameters || options.parameters) {
qs = '/?' + querystring.stringify(mergeObjects(component.parameters, options.parameters));
}
Expand Down
4 changes: 2 additions & 2 deletions client/src/html-renderer.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict';

var format = require('stringformat');
const format = require('stringformat');

var templates = require('./templates');
const templates = require('./templates');

module.exports = {
renderedComponent: function(data){
Expand Down
Loading

0 comments on commit 87d3cde

Please sign in to comment.