Skip to content

Commit

Permalink
eslint->prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick Balestra committed Jun 7, 2017
1 parent a3eebe5 commit 2b34e7a
Show file tree
Hide file tree
Showing 38 changed files with 92 additions and 68 deletions.
12 changes: 10 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,15 @@
"oc": "./src/oc-cli.js"
},
"scripts": {
"format": "prettier-eslint --single-quote --write \"src/**/*.js\"",
"precommit": "lint-staged",
"test": "grunt test"
},
"lint-staged": {
"*.js": [
"prettier-eslint --single-quote --write",
"git add"
]
},
"engines": {
"node": ">=4"
},
Expand All @@ -36,17 +42,19 @@
"grunt-git": "^1.0.0",
"grunt-karma": "^2.0.0",
"grunt-mocha-test": "^0.12.7",
"husky": "^0.13.4",
"injectr": "0.5.1",
"jasmine-core": "^2.5.1",
"karma": "^1.3.0",
"karma-jasmine": "^1.0.2",
"karma-phantomjs-launcher": "^1.0.2",
"karma-sauce-launcher": "^1.0.0",
"karma-sinon": "^1.0.5",
"lint-staged": "^3.6.0",
"load-grunt-tasks": "^3.5.2",
"mocha": "^3.0.2",
"phantomjs-prebuilt": "^2.1.12",
"prettier-eslint-cli": "^4.0.3",
"prettier-eslint-cli": "^4.0.4",
"semver-sort": "0.0.4",
"sinon": "^1.17.5"
},
Expand Down
2 changes: 1 addition & 1 deletion src/cli/domain/get-components-deps.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const _ = require('lodash');
const settings = require('../../resources');

module.exports = function(components) {
const deps = {modules: {}, withVersions: {}, templates: {}};
const deps = { modules: {}, withVersions: {}, templates: {} };

const legacyTemplates = {
jade: true,
Expand Down
2 changes: 1 addition & 1 deletion src/cli/domain/local.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ module.exports = function() {

fs.outputJsonSync(componentPath, component);

return callback(null, {ok: true});
return callback(null, { ok: true });
} catch (e) {
return callback(e);
}
Expand Down
2 changes: 1 addition & 1 deletion src/cli/domain/mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module.exports = function() {
return fs.writeJson(
settings.configFile.src,
localConfig,
{spaces: 2},
{ spaces: 2 },
callback
);
});
Expand Down
2 changes: 1 addition & 1 deletion src/cli/domain/package-server-script/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const hashBuilder = require('../../../utils/hash-builder');
module.exports = function packageServerScript(params, callback) {
const fileName = 'server.js';
const publishPath = params.publishPath;
const webpackParams = {stats: params.verbose ? 'verbose' : 'errors-only'};
const webpackParams = { stats: params.verbose ? 'verbose' : 'errors-only' };

const bundleParams = {
webpack: params.webpack || webpackParams,
Expand Down
2 changes: 1 addition & 1 deletion src/cli/domain/package-static-files/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ module.exports = function(params, callback) {
async.eachSeries(
staticList,
(staticDir, cb) => {
copyDir(_.extend(params, {staticDir: staticDir}), cb);
copyDir(_.extend(params, { staticDir: staticDir }), cb);
},
errors => {
if (errors) {
Expand Down
4 changes: 2 additions & 2 deletions src/cli/domain/package-static-files/minify-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ module.exports = function(fileExt, fileContent) {
modules: false
};

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

return uglifyJs.minify(es5, {fromString: true}).code;
return uglifyJs.minify(es5, { fromString: true }).code;
} else if (fileExt === '.css') {
return new CleanCss().minify(fileContent).styles;
}
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 @@ -35,7 +35,7 @@ const compileView = function(viewPath, type, cb) {
return cb(err);
}

ocTemplate.compile({template, viewPath}, (err, compiledView) => {
ocTemplate.compile({ template, viewPath }, (err, compiledView) => {
if (err) {
return cb(err);
}
Expand All @@ -45,7 +45,7 @@ const compileView = function(viewPath, type, cb) {

return cb(null, {
hash: hashView,
view: uglifyJs.minify(javaScriptizedView, {fromString: true}).code
view: uglifyJs.minify(javaScriptizedView, { fromString: true }).code
});
});
};
Expand Down
6 changes: 4 additions & 2 deletions src/cli/facade/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ module.exports = function(dependencies) {
baseUrl = opts.baseUrl || format('http://localhost:{0}/', port),
errors = strings.errors.cli,
fallbackRegistryUrl = opts.fallbackRegistryUrl,
hotReloading = _.isUndefined(opts.hotReloading) ? true : opts.hotReloading;
hotReloading = _.isUndefined(opts.hotReloading)
? true
: opts.hotReloading;
let packaging = false;

callback = wrapCliCallback(callback);
Expand Down Expand Up @@ -185,7 +187,7 @@ module.exports = function(dependencies) {
path: path.resolve(componentsDir),
port: port,
baseUrl: baseUrl,
env: {name: 'local'},
env: { name: 'local' },
dependencies: dependencies.modules,
templates: dependencies.templates
});
Expand Down
6 changes: 3 additions & 3 deletions src/cli/facade/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ module.exports = function(dependencies) {
read({}, (err, username) => {
logger.warn(strings.messages.cli.ENTER_PASSWORD);

read({silent: true}, (err, password) => {
cb(null, {username: username, password: password});
read({ silent: true }, (err, password) => {
cb(null, { username: username, password: password });
});
});
};
Expand Down Expand Up @@ -150,7 +150,7 @@ module.exports = function(dependencies) {
);

putComponentToRegistry(
{route: componentRoute, path: compressedPackagePath},
{ route: componentRoute, path: compressedPackagePath },
next
);
},
Expand Down
4 changes: 3 additions & 1 deletion src/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ function validate(argv, level) {
argv._.length > level &&
!_.includes(_.keys(commands.commands), argv._[level])
) {
throw new Error(format(strings.messages.cli.NO_SUCH_COMMAND, argv._[level]));
throw new Error(
format(strings.messages.cli.NO_SUCH_COMMAND, argv._[level])
);
}

return true;
Expand Down
4 changes: 2 additions & 2 deletions src/components/oc-client/server.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

export const data = (context, callback) => {
const {staticPath, templates} = context;
return callback(null, {staticPath, templates});
const { staticPath, templates } = context;
return callback(null, { staticPath, templates });
};
10 changes: 5 additions & 5 deletions src/components/oc-client/src/oc-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
/* eslint no-var: 'off' */
/* eslint prefer-arrow-callback: 'off' */

var oc = oc || {}

;(function(root, factory) {
var oc = oc || {};
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module
define(['exports', 'jquery'], function(exports, $) {
Expand Down Expand Up @@ -65,7 +64,8 @@ var oc = oc || {}
'Error loading component: view engine "{0}" not supported',
MESSAGES_LOADING_COMPONENT = oc.conf.loadingMessage || '',
MESSAGES_RENDERED = "Component '{0}' correctly rendered",
MESSAGES_RETRIEVING = 'Unrendered component found. Trying to retrieve it...';
MESSAGES_RETRIEVING =
'Unrendered component found. Trying to retrieve it...';

// The code
var debug = oc.conf.debug || false,
Expand Down Expand Up @@ -459,7 +459,7 @@ var oc = oc || {}

oc.$.ajax({
url: hrefWithCount,
headers: {Accept: 'application/vnd.oc.unrendered+json'},
headers: { Accept: 'application/vnd.oc.unrendered+json' },
contentType: 'text/plain',
crossDomain: true,
async: true,
Expand Down
2 changes: 1 addition & 1 deletion src/registry/app-start.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = function(repository, options, callback) {
return callback(null, 'ok');
}

const logger = options.verbosity ? console : {log: _.noop};
const logger = options.verbosity ? console : { log: _.noop };

logger.log(
format(
Expand Down
2 changes: 1 addition & 1 deletion src/registry/domain/components-cache/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ module.exports = (conf, cdn) => {
};

const returnError = (code, message, callback) => {
eventsHandler.fire('error', {code, message});
eventsHandler.fire('error', { code, message });
return callback(code);
};

Expand Down
4 changes: 2 additions & 2 deletions src/registry/domain/components-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const getUnixUTCTimestamp = require('../../utils/get-unix-utc-timestamp');

module.exports = (conf, cdn) => {
const returnError = (code, message, callback) => {
eventsHandler.fire('error', {code, message});
eventsHandler.fire('error', { code, message });
return callback(code);
};

Expand Down Expand Up @@ -63,7 +63,7 @@ module.exports = (conf, cdn) => {

const refresh = (componentsList, callback) => {
getFromJson((jsonErr, details) => {
getFromDirectories({componentsList, details}, (dirErr, dirDetails) => {
getFromDirectories({ componentsList, details }, (dirErr, dirDetails) => {
if (dirErr) {
return returnError('components_details_get', dirErr, callback);
} else if (
Expand Down
8 changes: 6 additions & 2 deletions src/registry/domain/nested-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const sanitise = {
});
},
headers: function(h) {
return _.extend({}, h, {accept: settings.registry.acceptRenderedHeader});
return _.extend({}, h, { accept: settings.registry.acceptRenderedHeader });
},
options: function(options, callback) {
if (!callback && _.isFunction(options)) {
Expand Down Expand Up @@ -64,7 +64,11 @@ const validate = {
module.exports = function(renderer, conf) {
return {
renderComponent: function(componentName, renderOptions, callback) {
const p = sanitise.componentParams(componentName, renderOptions, callback);
const p = sanitise.componentParams(
componentName,
renderOptions,
callback
);
validate.componentParams(p);

return renderer(
Expand Down
2 changes: 1 addition & 1 deletion src/registry/domain/options-sanitiser.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module.exports = function(input) {

if (!options.publishValidation) {
options.publishValidation = function() {
return {isValid: true};
return { isValid: true };
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/registry/domain/repository.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ module.exports = function(conf) {
if (err) {
return callback(`component not available: ${err}`, null);
}
callback(null, _.extend(component, {allVersions}));
callback(null, _.extend(component, { allVersions }));
}
);
});
Expand Down
2 changes: 1 addition & 1 deletion src/registry/domain/s3.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module.exports = function(conf) {
accessKeyId: conf.s3.key,
secretAccessKey: conf.s3.secret,
region: conf.s3.region,
httpOptions: {timeout: conf.s3.timeout || 10000}
httpOptions: { timeout: conf.s3.timeout || 10000 }
});

const bucket = conf.s3.bucket;
Expand Down
4 changes: 2 additions & 2 deletions src/registry/domain/url-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const _ = require('lodash');

function componentForType(component, baseUrl, type) {
if (_.isString(component)) {
component = {name: component};
component = { name: component };
}

let href = url.resolve(baseUrl, component.name) + '/';
Expand All @@ -23,7 +23,7 @@ function componentForType(component, baseUrl, type) {
const build = {
component: function(component, baseUrl) {
if (_.isString(component)) {
component = {name: component};
component = { name: component };
}

let componentUrl = url.resolve(baseUrl, component.name);
Expand Down
2 changes: 1 addition & 1 deletion src/registry/domain/validators/component-parameters.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const validateParameter = function(parameter, expectedType) {
};

module.exports = function(requestParameters, expectedParameters) {
const result = {isValid: true, errors: {}},
const result = { isValid: true, errors: {} },
mandatoryParameters = [];

_.forEach(
Expand Down
2 changes: 1 addition & 1 deletion src/registry/domain/validators/node-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const semver = require('semver');
const packageInfo = require('../../../../package.json');

module.exports = function(userAgent, nodeVersion) {
const result = {isValid: false};
const result = { isValid: false };
const error = {
suggestedVersion: packageInfo.engines.node || '*',
registryNodeVersion: nodeVersion,
Expand Down
2 changes: 1 addition & 1 deletion src/registry/domain/validators/oc-cli-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const semver = require('semver');
const packageInfo = require('../../../../package.json');

module.exports = function(userAgent) {
const result = {isValid: false};
const result = { isValid: false };
const error = {
suggestedVersion: format(
'{0}.{1}.X',
Expand Down
2 changes: 1 addition & 1 deletion src/registry/domain/validators/package-json-validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = function(pkgDetails) {
let result = pkgDetails.customValidator(pkgDetails.packageJson);

if (_.isBoolean(result)) {
result = {isValid: result};
result = { isValid: result };

if (!result.isValid) {
result.error = 'unknown';
Expand Down
2 changes: 1 addition & 1 deletion src/registry/domain/validators/plugins-requirements.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const _ = require('lodash');

module.exports = function(componentRequirements, registryPlugins) {
const result = {isValid: true},
const result = { isValid: true },
missing = [];

_.forEach(componentRequirements || [], requiredPlugin => {
Expand Down
2 changes: 1 addition & 1 deletion src/registry/domain/validators/registry-configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const auth = require('../authentication');
const strings = require('../../../resources');

module.exports = function(conf) {
const response = {isValid: true};
const response = { isValid: true };

const returnError = function(message) {
response.isValid = false;
Expand Down
2 changes: 1 addition & 1 deletion src/registry/domain/validators/uploaded-package.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const _ = require('lodash');

module.exports = function(input) {
const response = {isValid: true};
const response = { isValid: true };

const returnError = function(message) {
response.isValid = false;
Expand Down
6 changes: 3 additions & 3 deletions src/registry/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ module.exports = function(options) {
};

this.register = function(plugin, callback) {
plugins.push(_.extend(plugin, {callback}));
plugins.push(_.extend(plugin, { callback }));
};

this.start = function(callback) {
Expand Down Expand Up @@ -100,11 +100,11 @@ module.exports = function(options) {
}
}

callback(null, {app: self.app, server});
callback(null, { app: self.app, server });
});

server.on('error', message => {
eventsHandler.fire('error', {code: 'EXPRESS_ERROR', message});
eventsHandler.fire('error', { code: 'EXPRESS_ERROR', message });
callback(message);
});
}
Expand Down
Loading

0 comments on commit 2b34e7a

Please sign in to comment.