Skip to content

Commit

Permalink
Merge pull request #453 from elboletaire/f/eslint-indent
Browse files Browse the repository at this point in the history
Fix indentation
  • Loading branch information
matteofigus authored Apr 8, 2017
2 parents d52d28f + a830ba9 commit 875e1f0
Show file tree
Hide file tree
Showing 94 changed files with 828 additions and 828 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"id-blacklist": "error",
"id-length": "off",
"id-match": "error",
"indent": "off",
"indent": ["error", 2],
"init-declarations": "off",
"jsx-quotes": "error",
"key-spacing": "off",
Expand Down
10 changes: 5 additions & 5 deletions client/src/components-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ var _ = require('./utils/helpers');
module.exports = function(config, renderTemplate){

var cache = new Cache(config.cache),
getComponentsData = new GetComponentsData(config),
renderComponents = new RenderComponents(cache, renderTemplate),
processClientReponses = new ProcessClientResponse(cache, config);
getComponentsData = new GetComponentsData(config),
renderComponents = new RenderComponents(cache, renderTemplate),
processClientReponses = new ProcessClientResponse(cache, config);

return function(components, options, callback){

Expand All @@ -36,8 +36,8 @@ module.exports = function(config, renderTemplate){
renderComponents(toDo, options, function(){
processClientReponses(toDo, options, function(){
var errors = [],
results = [],
hasErrors = false;
results = [],
hasErrors = false;

_.each(toDo, function(action){
if(action.result.error) {
Expand Down
2 changes: 1 addition & 1 deletion client/src/get-compiled-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ module.exports = function(cache){
}

cb(null, ocTemplate.getCompiledTemplate(templateText, template.key));
});
});
};

if(!!useCache){
Expand Down
4 changes: 2 additions & 2 deletions client/src/get-components-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ module.exports = function(config){

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

_.each(toDo, function(action){
if(action.render === 'server'){
Expand Down
8 changes: 4 additions & 4 deletions client/src/href-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module.exports = function(config){
}

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

if(!forwardLang && options.forwardAcceptLanguageToClient === true){
forwardLang = true;
Expand All @@ -35,9 +35,9 @@ module.exports = function(config){
}

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

return url.resolve(registrySegment, component.name) + versionSegment + qs;
},
Expand Down
8 changes: 4 additions & 4 deletions client/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ var _ = require('./utils/helpers');
module.exports = function(conf){

var config = sanitiser.sanitiseConfiguration(conf),
validationResult = validator.validateConfiguration(config),
renderTemplate = new TemplateRenderer(),
renderComponents = new ComponentsRenderer(config, renderTemplate),
getComponentsInfo = new GetComponentsInfo(config);
validationResult = validator.validateConfiguration(config),
renderTemplate = new TemplateRenderer(),
renderComponents = new ComponentsRenderer(config, renderTemplate),
getComponentsInfo = new GetComponentsInfo(config);

if(!validationResult.isValid){
throw new Error(validationResult.error);
Expand Down
2 changes: 1 addition & 1 deletion client/src/process-client-responses.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var _ = require('./utils/helpers');
module.exports = function(cache, config){

var getOCClientScript = new GetOCClientScript(cache),
buildHref = new HrefBuilder(config);
buildHref = new HrefBuilder(config);

return function(toDo, options, cb){
var toProcess = [];
Expand Down
4 changes: 2 additions & 2 deletions client/src/render-components.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ module.exports = function(cache, renderTemplate){
var fetchTemplateAndRender = function(component, options, cb){

var data = component.data,
isLocal = component.type === 'oc-component-local',
useCache = !isLocal;
isLocal = component.type === 'oc-component-local',
useCache = !isLocal;

getCompiledTemplate(component.template, useCache, options.timeout, function(err, template){
if(!!err){ return cb(err); }
Expand Down
14 changes: 7 additions & 7 deletions client/src/sanitiser.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ var getDefaultUserAgent = function() {

var sanitiseDefaultOptions = function(options) {
if(_.isFunction(options)){
options = {};
}
options = {};
}

options = options || {};
options.headers = lowerHeaderKeys(options.headers);
options.headers['user-agent'] = options.headers['user-agent'] || getDefaultUserAgent();
options = options || {};
options.headers = lowerHeaderKeys(options.headers);
options.headers['user-agent'] = options.headers['user-agent'] || getDefaultUserAgent();

options.timeout = options.timeout || 5;
return options;
options.timeout = options.timeout || 5;
return options;
};

module.exports = {
Expand Down
12 changes: 6 additions & 6 deletions client/src/warmup.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module.exports = function(config, renderComponents){
options.headers = options.headers || {};

var urls = [],
toWarmup = [];
toWarmup = [];

_.each(config.components, function(version, name){
var versionSegment = version ? (version + '/') : '';
Expand All @@ -49,11 +49,11 @@ module.exports = function(config, renderComponents){
}

var parameters = componentInfo.oc.parameters,
componentToWarmup = {
name: componentInfo.name,
version: componentInfo.version,
parameters: {}
};
componentToWarmup = {
name: componentInfo.name,
version: componentInfo.version,
parameters: {}
};

if(!!parameters){
_.each(parameters, function(value, parameter){
Expand Down
4 changes: 2 additions & 2 deletions src/cli/domain/get-components-by-dir.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ module.exports = function(){
var isOcComponent = function(file){

var filePath = path.resolve(componentsDir, file),
packagePath = path.join(filePath, 'package.json'),
content;
packagePath = path.join(filePath, 'package.json'),
content;

try {
content = fs.readJsonSync(packagePath);
Expand Down
4 changes: 2 additions & 2 deletions src/cli/domain/get-local-npm-modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ module.exports = function(){
return fs.readdirSync(nodeFolder).filter(function(file){

var filePath = path.resolve(nodeFolder, file),
isBin = file === '.bin',
isDir = fs.lstatSync(filePath).isDirectory();
isBin = file === '.bin',
isDir = fs.lstatSync(filePath).isDirectory();

return isDir && !isBin;
});
Expand Down
2 changes: 1 addition & 1 deletion src/cli/domain/get-missing-deps.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = function(dependencies){
_.forEach(dependencies, function(npmModule){

var index = npmModule.indexOf('@'),
moduleName = npmModule;
moduleName = npmModule;

if (index > 0) {
moduleName = npmModule.substr(0, index);
Expand Down
10 changes: 5 additions & 5 deletions src/cli/domain/get-mocked-plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ var registerDynamicMocks = function(ocJsonLocation, mocks, logger){
var findPath = function(pathToResolve, fileName) {

var rootDir = fs.realpathSync('.'),
fileToResolve = path.join(pathToResolve, fileName);
fileToResolve = path.join(pathToResolve, fileName);

if (!fs.existsSync(fileToResolve)) {
if (pathToResolve === rootDir) {
return undefined;
} else {
var getParent = function(x){ return x.split('/').slice(0, -1).join('/'); },
parentDir = pathToResolve ? getParent(pathToResolve) : rootDir;
parentDir = pathToResolve ? getParent(pathToResolve) : rootDir;

return findPath(parentDir, fileName);
}
Expand All @@ -77,15 +77,15 @@ module.exports = function(logger, componentsDir){
componentsDir = path.resolve(componentsDir || '.');

var plugins = [],
ocJsonFileName = settings.configFile.src.replace('./', ''),
ocJsonPath = findPath(componentsDir, ocJsonFileName);
ocJsonFileName = settings.configFile.src.replace('./', ''),
ocJsonPath = findPath(componentsDir, ocJsonFileName);

if(!ocJsonPath){
return plugins;
}

var content = fs.readJsonSync(ocJsonPath),
ocJsonLocation = ocJsonPath.slice(0, -ocJsonFileName.length);
ocJsonLocation = ocJsonPath.slice(0, -ocJsonFileName.length);

if(!content.mocks || !content.mocks.plugins){
return plugins;
Expand Down
4 changes: 2 additions & 2 deletions src/cli/domain/local.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ module.exports = function(){
try {

var pathDir = '../../components/base-component-' + templateType,
baseComponentDir = path.resolve(__dirname, pathDir),
npmIgnorePath = path.resolve(__dirname, pathDir + '/.npmignore');
baseComponentDir = path.resolve(__dirname, pathDir),
npmIgnorePath = path.resolve(__dirname, pathDir + '/.npmignore');

fs.ensureDirSync(componentName);
fs.copySync(baseComponentDir, componentName);
Expand Down
6 changes: 3 additions & 3 deletions src/cli/domain/package-components.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module.exports = function(){
var minify = options.minify === true;

var files = fs.readdirSync(componentPath),
publishPath = path.join(componentPath, '_package');
publishPath = path.join(componentPath, '_package');

if(_.contains(files, '_package')){
fs.removeSync(publishPath);
Expand All @@ -27,7 +27,7 @@ module.exports = function(){
fs.mkdirSync(publishPath);

var componentPackagePath = path.join(componentPath, 'package.json'),
ocPackagePath = path.join(__dirname, '../../../package.json');
ocPackagePath = path.join(__dirname, '../../../package.json');

if(!fs.existsSync(componentPackagePath)){
return callback(new Error('component does not contain package.json'));
Expand All @@ -36,7 +36,7 @@ module.exports = function(){
}

var component = fs.readJsonSync(componentPackagePath),
ocInfo = fs.readJsonSync(ocPackagePath);
ocInfo = fs.readJsonSync(ocPackagePath);

if(!validator.validateComponentName(component.name)){
return callback(new Error('name not valid'));
Expand Down
14 changes: 7 additions & 7 deletions src/cli/domain/package-static-files/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ var strings = require('../../../resources');

var copyDir = function(params, cb){
var staticPath = path.join(params.componentPath, params.staticDir),
exists = fs.existsSync(staticPath),
isDir = exists && fs.lstatSync(staticPath).isDirectory();
exists = fs.existsSync(staticPath),
isDir = exists && fs.lstatSync(staticPath).isDirectory();

if(!exists){
return cb(format(strings.errors.cli.FOLDER_NOT_FOUND, staticPath));
Expand All @@ -25,16 +25,16 @@ var copyDir = function(params, cb){
_.forEach(res.files, function(filePath){

var fileName = path.basename(filePath),
fileExt = path.extname(filePath).toLowerCase(),
fileRelativePath = path.relative(staticPath, path.dirname(filePath)),
fileDestinationPath = path.join(params.publishPath, params.staticDir, fileRelativePath),
fileDestination = path.join(fileDestinationPath, fileName);
fileExt = path.extname(filePath).toLowerCase(),
fileRelativePath = path.relative(staticPath, path.dirname(filePath)),
fileDestinationPath = path.join(params.publishPath, params.staticDir, fileRelativePath),
fileDestination = path.join(fileDestinationPath, fileName);

fs.ensureDirSync(fileDestinationPath);

if(params.minify && params.ocOptions.minify !== false && (fileExt === '.js' || fileExt === '.css')){
var fileContent = fs.readFileSync(filePath).toString(),
minified = minifyFile(fileExt, fileContent);
minified = minifyFile(fileExt, fileContent);

fs.writeFileSync(fileDestination, minified);
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/cli/domain/package-static-files/minify-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = function(fileExt, fileContent){
};

var babelOptions = { presets: [[babelPresetEnv, presetOptions]] },
es5 = babel.transform(fileContent, babelOptions).code;
es5 = babel.transform(fileContent, babelOptions).code;

return uglifyJs.minify(es5, { fromString: true }).code;

Expand Down
4 changes: 2 additions & 2 deletions src/cli/domain/package-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var compileView = function(viewPath, type, cb) {
if (err) { return cb(err);}

var hashView = hashBuilder.fromString(compiledView.toString()),
javaScriptizedView = javaScriptizeTemplate(hashView, compiledView);
javaScriptizedView = javaScriptizeTemplate(hashView, compiledView);

return cb(null, {
hash: hashView,
Expand All @@ -43,7 +43,7 @@ var compileView = function(viewPath, type, cb) {
module.exports = function(params, callback){

var viewSrc = params.ocOptions.files.template.src,
viewPath = path.join(params.componentPath, viewSrc);
viewPath = path.join(params.componentPath, viewSrc);

if(!fs.existsSync(viewPath)){
return callback(format(strings.errors.cli.TEMPLATE_NOT_FOUND, viewSrc));
Expand Down
4 changes: 2 additions & 2 deletions src/cli/domain/registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var urlParser = require('../domain/url-parser');
var getOcVersion = function(){

var ocPackagePath = path.join(__dirname, '../../../package.json'),
ocInfo = fs.readJsonSync(ocPackagePath);
ocInfo = fs.readJsonSync(ocPackagePath);

return ocInfo.version;
};
Expand Down Expand Up @@ -67,7 +67,7 @@ module.exports = function(opts){
},
get: function(callback){
if(opts.registry){
return callback(null, [opts.registry]);
return callback(null, [opts.registry]);
}

fs.readJson(settings.configFile.src, function(err, res){
Expand Down
12 changes: 6 additions & 6 deletions src/cli/domain/url-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ module.exports = {
parse: function(parsed){

var requestedVersion = parsed.requestVersion,
href = url.parse(parsed.href),
relativePath = removeFinalSlashes(href.pathname),
withoutVersion = removeFinalSlashes(relativePath.replace(requestedVersion, '')),
componentName = withoutVersion.substr(withoutVersion.lastIndexOf('/') + 1),
withoutComponent = removeFinalSlashes(withoutVersion.replace(componentName, '')),
registryUrl = href.protocol + '//' + href.host + withoutComponent + '/';
href = url.parse(parsed.href),
relativePath = removeFinalSlashes(href.pathname),
withoutVersion = removeFinalSlashes(relativePath.replace(requestedVersion, '')),
componentName = withoutVersion.substr(withoutVersion.lastIndexOf('/') + 1),
withoutComponent = removeFinalSlashes(withoutVersion.replace(componentName, '')),
registryUrl = href.protocol + '//' + href.host + withoutComponent + '/';

return {
clientHref: registryUrl + 'oc-client/client.js',
Expand Down
Loading

0 comments on commit 875e1f0

Please sign in to comment.