Skip to content
Snippets Groups Projects
Commit b195a61d authored by Lars Trieloff's avatar Lars Trieloff
Browse files

[trivial] function paren spacing

parent 626483e3
No related branches found
No related tags found
No related merge requests found
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
"after": true "after": true
}], }],
"space-unary-ops": 2, "space-unary-ops": 2,
"comma-spacing": ["error", { "before": false, "after": true }] "comma-spacing": ["error", { "before": false, "after": true }],
"space-before-function-paren": ["error", "always"]
} }
} }
...@@ -58,7 +58,7 @@ if (argv.s){ ...@@ -58,7 +58,7 @@ if (argv.s){
if (argv.m) { if (argv.m) {
if (_.isArray(argv.m)){ if (_.isArray(argv.m)){
_.each(argv.m, function(item){ _.each(argv.m, function (item){
var meta=item.split('='); var meta=item.split('=');
if (meta.length === 2) { if (meta.length === 2) {
metaElements[meta[0]] = meta[1]; metaElements[meta[0]] = meta[1];
......
...@@ -10,7 +10,7 @@ var fs = Promise.promisifyAll(require('fs')); ...@@ -10,7 +10,7 @@ var fs = Promise.promisifyAll(require('fs'));
// Reads a schema file and modifies a schema path map object based on the schema file. // Reads a schema file and modifies a schema path map object based on the schema file.
// Returns the schema path map object. // Returns the schema path map object.
module.exports = function readSchemaFile(schemaPathMap, fullPath) { module.exports = function readSchemaFile (schemaPathMap, fullPath) {
if (!schemaPathMap) { if (!schemaPathMap) {
schemaPathMap = {}; schemaPathMap = {};
} }
......
...@@ -18,7 +18,7 @@ var pointer = require('json-pointer'); ...@@ -18,7 +18,7 @@ var pointer = require('json-pointer');
var smap; //TODO remove global var smap; //TODO remove global
var sPath; var sPath;
var wmap={}; var wmap={};
function get$refType(refValue){ function get$refType (refValue){
var startpart = '', endpart = '', refType = ''; var startpart = '', endpart = '', refType = '';
var arr = refValue.split('#'); var arr = refValue.split('#');
if (arr.length > 1) {endpart=arr[1];} if (arr.length > 1) {endpart=arr[1];}
...@@ -52,7 +52,7 @@ function get$refType(refValue){ ...@@ -52,7 +52,7 @@ function get$refType(refValue){
return { startpart, endpart, refType }; return { startpart, endpart, refType };
} }
function normaliseLinks(obj, refArr){ function normaliseLinks (obj, refArr){
let basepath = refArr.startpart ; let basepath = refArr.startpart ;
let $linkVal = '', $linkPath = ''; let $linkVal = '', $linkPath = '';
if (basepath in smap){ if (basepath in smap){
...@@ -63,7 +63,7 @@ function normaliseLinks(obj, refArr){ ...@@ -63,7 +63,7 @@ function normaliseLinks(obj, refArr){
return { $linkVal, $linkPath }; return { $linkVal, $linkPath };
} }
} }
var resolve$ref = Promise.method(function(val, base$id){ var resolve$ref = Promise.method(function (val, base$id){
let obj, link; let obj, link;
if (!(base$id in wmap) ) {wmap[base$id] = {};} if (!(base$id in wmap) ) {wmap[base$id] = {};}
let refArr = get$refType(val['$ref']); let refArr = get$refType(val['$ref']);
...@@ -96,7 +96,7 @@ var resolve$ref = Promise.method(function(val, base$id){ ...@@ -96,7 +96,7 @@ var resolve$ref = Promise.method(function(val, base$id){
} }
} }
}); });
var processFurther = Promise.method(function(val, key, $id){ var processFurther = Promise.method(function (val, key, $id){
let base$id =$id; let base$id =$id;
if (val['$ref']){ if (val['$ref']){
return resolve$ref(val, base$id); return resolve$ref(val, base$id);
...@@ -116,14 +116,14 @@ var processFurther = Promise.method(function(val, key, $id){ ...@@ -116,14 +116,14 @@ var processFurther = Promise.method(function(val, key, $id){
return val; return val;
} }
}); });
function processISchema() {}; // define w/ function so it gets hoisted and we avoid eslint errors about what is defined first: processISchema or resolve$ref. Both rely on each other! function processISchema () {}; // define w/ function so it gets hoisted and we avoid eslint errors about what is defined first: processISchema or resolve$ref. Both rely on each other!
processISchema = Promise.method(function(schema, base$id){ processISchema = Promise.method(function (schema, base$id){
if (!(base$id in wmap) ) {wmap[base$id] = {};} if (!(base$id in wmap) ) {wmap[base$id] = {};}
if (schema['anyOf'] || schema['oneOf']){ if (schema['anyOf'] || schema['oneOf']){
// var $definitions=[] // var $definitions=[]
schema['type'] = schema['anyOf'] ? 'anyOf' : 'oneOf'; schema['type'] = schema['anyOf'] ? 'anyOf' : 'oneOf';
let arr = schema['anyOf']? schema['anyOf'] : schema['oneOf']; let arr = schema['anyOf']? schema['anyOf'] : schema['oneOf'];
_.each(arr, function(value, index) { _.each(arr, function (value, index) {
if (value['$ref']){ if (value['$ref']){
resolve$ref(value, base$id).then((piSchema)=>{ resolve$ref(value, base$id).then((piSchema)=>{
delete arr[index]; delete arr[index];
...@@ -160,14 +160,14 @@ processISchema = Promise.method(function(schema, base$id){ ...@@ -160,14 +160,14 @@ processISchema = Promise.method(function(schema, base$id){
// schema.$definitions = $definitions // schema.$definitions = $definitions
return schema; return schema;
}); });
function processSchema(schema){ function processSchema (schema){
return new Promise((resolve, reject)=>{ return new Promise((resolve, reject)=>{
if (!schema.properties) {schema.properties={};} if (!schema.properties) {schema.properties={};}
var $id = schema['$id'] || schema['id']; var $id = schema['$id'] || schema['id'];
var base$id = $id; var base$id = $id;
if (!(base$id in wmap)) {wmap[base$id] = {};} if (!(base$id in wmap)) {wmap[base$id] = {};}
if (schema['allOf']){ if (schema['allOf']){
_.each(schema['allOf'], function(value) { _.each(schema['allOf'], function (value) {
if (value['$ref']){ if (value['$ref']){
let obj, link; let obj, link;
var refArr = get$refType(value['$ref']); var refArr = get$refType(value['$ref']);
...@@ -239,7 +239,7 @@ function processSchema(schema){ ...@@ -239,7 +239,7 @@ function processSchema(schema){
} else { } else {
_.forOwn(value, function(val, key){ _.forOwn(value, function (val, key){
schema[key]=val; schema[key]=val;
// //
}); });
...@@ -276,12 +276,12 @@ function processSchema(schema){ ...@@ -276,12 +276,12 @@ function processSchema(schema){
} }
var Schema=function(ajv, schemaMap){ var Schema=function (ajv, schemaMap){
this._ajv = ajv; this._ajv = ajv;
this._schemaPathMap=schemaMap; this._schemaPathMap=schemaMap;
}; };
Schema.resolveRef=function(key, obj, currpath){ Schema.resolveRef=function (key, obj, currpath){
if (key === '$ref'){ if (key === '$ref'){
var refVal = obj[key]; var refVal = obj[key];
var temp; var temp;
...@@ -333,7 +333,7 @@ var traverseSchema = function(object,schemaFilePath){ ...@@ -333,7 +333,7 @@ var traverseSchema = function(object,schemaFilePath){
}; };
*/ */
Schema.getExamples = function(filePath, schema){ Schema.getExamples = function (filePath, schema){
var exampleFileNames=[]; var exampleFileNames=[];
var examples=[]; var examples=[];
var dirname=path.dirname(filePath); var dirname=path.dirname(filePath);
...@@ -358,7 +358,7 @@ Schema.getExamples = function(filePath, schema){ ...@@ -358,7 +358,7 @@ Schema.getExamples = function(filePath, schema){
}); });
}; };
Schema.getDescription = function(filePath, schema){ Schema.getDescription = function (filePath, schema){
var temp=path.basename(filePath, path.extname(filePath)); var temp=path.basename(filePath, path.extname(filePath));
//TODO should err be thrown here? //TODO should err be thrown here?
...@@ -374,11 +374,11 @@ Schema.getDescription = function(filePath, schema){ ...@@ -374,11 +374,11 @@ Schema.getDescription = function(filePath, schema){
}; };
Schema.setAjv=function(ajv){ Schema.setAjv=function (ajv){
this._ajv=ajv; this._ajv=ajv;
}; };
Schema.setSchemaPathMap=function(schemaMap){ Schema.setSchemaPathMap=function (schemaMap){
this._schemaPathMap=schemaMap; this._schemaPathMap=schemaMap;
}; };
/** /**
...@@ -389,7 +389,7 @@ Schema.setSchemaPathMap=function(schemaMap){ ...@@ -389,7 +389,7 @@ Schema.setSchemaPathMap=function(schemaMap){
* @param {string} schemaDir - where schemas will be generated, if null, `docDir` will be used * @param {string} schemaDir - where schemas will be generated, if null, `docDir` will be used
* @param {*} metaElements * @param {*} metaElements
*/ */
Schema.load = function(schemaMap, schemaPath, docDir, schemaDir, metaElements) { Schema.load = function (schemaMap, schemaPath, docDir, schemaDir, metaElements) {
schemaDir = schemaDir ? schemaDir : docDir; schemaDir = schemaDir ? schemaDir : docDir;
smap=schemaMap; smap=schemaMap;
let keys = Object.keys(schemaMap); let keys = Object.keys(schemaMap);
......
...@@ -18,7 +18,7 @@ var validUrl = require('valid-url'); ...@@ -18,7 +18,7 @@ var validUrl = require('valid-url');
// this._schemaPath = schemaPath; // this._schemaPath = schemaPath;
// }; // };
var Writer = {}; var Writer = {};
var writeFile = function(outputDir, fileName, data) { var writeFile = function (outputDir, fileName, data) {
if (!fs.existsSync(outputDir)){ if (!fs.existsSync(outputDir)){
return mkdirp(outputDir).then(()=>{ return mkdirp(outputDir).then(()=>{
return fs.writeFileAsync(path.join(outputDir, fileName), data); return fs.writeFileAsync(path.join(outputDir, fileName), data);
...@@ -28,7 +28,7 @@ var writeFile = function(outputDir, fileName, data) { ...@@ -28,7 +28,7 @@ var writeFile = function(outputDir, fileName, data) {
} }
}; };
Writer.generateMarkdown = function(filename, schema, schemaPath, outDir, dependencyMap) { Writer.generateMarkdown = function (filename, schema, schemaPath, outDir, dependencyMap) {
var ctx = { var ctx = {
schema: schema, schema: schema,
...@@ -37,14 +37,14 @@ Writer.generateMarkdown = function(filename, schema, schemaPath, outDir, depende ...@@ -37,14 +37,14 @@ Writer.generateMarkdown = function(filename, schema, schemaPath, outDir, depende
dependencyMap:dependencyMap dependencyMap:dependencyMap
}; };
ejs.renderFile(path.join(__dirname, '../templates/md/topSchema.ejs'), ctx, { debug: false }, function(err, str){ ejs.renderFile(path.join(__dirname, '../templates/md/topSchema.ejs'), ctx, { debug: false }, function (err, str){
if (err) {console.error(err);} if (err) {console.error(err);}
return writeFile(path.join(path.join(outDir), path.dirname(filename.substr(schemaPath.length))), path.basename(filename).slice(0, -5)+ '.md', str); return writeFile(path.join(path.join(outDir), path.dirname(filename.substr(schemaPath.length))), path.basename(filename).slice(0, -5)+ '.md', str);
}); });
}; };
Writer.generateNewSchemaFiles = function(filename, schema, schemaPath, outDir) { Writer.generateNewSchemaFiles = function (filename, schema, schemaPath, outDir) {
return writeFile(path.join(path.join(outDir), path.dirname(filename.substr(schemaPath.length))), path.basename(filename), JSON.stringify(schema, null, 4)); return writeFile(path.join(path.join(outDir), path.dirname(filename.substr(schemaPath.length))), path.basename(filename), JSON.stringify(schema, null, 4));
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment