1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2024-11-05 01:56:21 +00:00

Fix JSHint warnings.

This commit is contained in:
devlinjd 2015-12-09 21:44:35 -05:00
parent 91aba39050
commit 541198321e
10 changed files with 42 additions and 39 deletions

View File

@ -34,8 +34,8 @@ FluentDate/*.prototype*/.fmt = function( dt ) {
else if( /^\D+\s+\d{4}$/.test(dt) ) { // "Mar 2015"
var parts = dt.split(' ');
var month = (months[parts[0]] || abbr[parts[0]]);
var dt = parts[1] + '-' + (month < 10 ? '0' + month : month.toString());
return moment( dt, 'YYYY-MM' );
var temp = parts[1] + '-' + (month < 10 ? '0' + month : month.toString());
return moment( temp, 'YYYY-MM' );
}
else if( /^\d{4}-\d{1,2}$/.test(dt) ) { // "2015-03", "1998-4"
return moment( dt, 'YYYY-MM' );

View File

@ -55,7 +55,7 @@ Definition of the FRESHResume class.
FS.writeFileSync( this.imp.fileName, FreshResume.stringify( newRep ), 'utf8' );
}
return this;
}
};
FreshResume.prototype.dupe = function() {
var rnew = new FreshResume();
@ -75,7 +75,7 @@ Definition of the FRESHResume class.
) ? undefined : value;
}
return JSON.stringify( obj, replacer, 2 );
},
};
/**
Create a copy of this resume in which all fields have been interpreted as
@ -87,7 +87,7 @@ Definition of the FRESHResume class.
var ret = this.dupe();
function MDIN(txt){
return MD(txt || '' ).replace(/^\s*\<p\>|\<\/p\>\s*$/gi, '');
return MD(txt || '' ).replace(/^\s*<p>|<\/p>\s*$/gi, '');
}
// TODO: refactor recursion
@ -120,6 +120,7 @@ Definition of the FRESHResume class.
markdownifyStringsInObject( sub );
});
}
}
Object.keys( ret ).forEach(function(member){
@ -188,7 +189,7 @@ Definition of the FRESHResume class.
*/
FreshResume.prototype.updateData = function( str ) {
this.clear( false );
this.parse( str )
this.parse( str );
return this;
};
@ -216,7 +217,7 @@ Definition of the FRESHResume class.
FreshResume.default = function() {
return new FreshResume().open(
PATH.join( __dirname, 'empty-fresh.json'), 'Empty' );
}
};
/**
Add work experience to the sheet.
@ -245,9 +246,9 @@ Definition of the FRESHResume class.
FreshResume.prototype.getProfile = function( socialNetwork ) {
socialNetwork = socialNetwork.trim().toLowerCase();
return this.social && _.find( this.social, function(sn) {
return sn.network.trim().toLowerCase() === socialNetwork
return sn.network.trim().toLowerCase() === socialNetwork;
});
}
};
/**
Return an array of profiles for the specified network, for when the user
@ -256,9 +257,9 @@ Definition of the FRESHResume class.
FreshResume.prototype.getProfiles = function( socialNetwork ) {
socialNetwork = socialNetwork.trim().toLowerCase();
return this.social && _.filter( this.social, function(sn){
return sn.network.trim().toLowerCase() === socialNetwork
return sn.network.trim().toLowerCase() === socialNetwork;
});
}
};
/**
Determine if the sheet includes a specific skill.
@ -277,7 +278,7 @@ Definition of the FRESHResume class.
*/
FreshResume.prototype.isValid = function( info ) {
var schemaObj = require('FRESCA');
var validator = require('is-my-json-valid')
var validator = require('is-my-json-valid');
var validate = validator( schemaObj, { // Note [1]
formats: { date: /^\d{4}(?:-(?:0[0-9]{1}|1[0-2]{1})(?:-[0-9]{2})?)?$/ }
});

View File

@ -94,14 +94,14 @@ Definition of the JRSResume class.
});
}
return flatSkills;
},
};
/**
Update the sheet's raw data. TODO: remove/refactor
*/
JRSResume.prototype.updateData = function( str ) {
this.clear( false );
this.parse( str )
this.parse( str );
return this;
};
@ -127,7 +127,7 @@ Definition of the JRSResume class.
*/
JRSResume.default = function() {
return new JRSResume().open( PATH.join( __dirname, 'empty-jrs.json'), 'Empty' );
}
};
/**
Add work experience to the sheet.
@ -168,7 +168,7 @@ Definition of the JRSResume class.
JRSResume.prototype.isValid = function( ) { // TODO: ↓ fix this path ↓
var schema = FS.readFileSync( PATH.join( __dirname, 'resume.json' ), 'utf8' );
var schemaObj = JSON.parse( schema );
var validator = require('is-my-json-valid')
var validator = require('is-my-json-valid');
var validate = validator( schemaObj );
return validate( this );
};

View File

@ -50,8 +50,8 @@ Abstract theme representation.
}
// Add freebie formats every theme gets
formatsHash[ 'json' ] = { title: 'json', outFormat: 'json', pre: 'json', ext: 'json', path: null, data: null };
formatsHash[ 'yml' ] = { title: 'yaml', outFormat: 'yml', pre: 'yml', ext: 'yml', path: null, data: null };
formatsHash.json = { title: 'json', outFormat: 'json', pre: 'json', ext: 'json', path: null, data: null };
formatsHash.yml = { title: 'yaml', outFormat: 'yml', pre: 'yml', ext: 'yml', path: null, data: null };
// Cache
this.formats = formatsHash;
@ -141,7 +141,7 @@ Abstract theme representation.
.forEach(function( cssf ) {
// For each CSS file, get its corresponding HTML file
var idx = _.findIndex(fmts, function( fmt ) {
return fmt.pre === cssf.pre && fmt.ext === 'html'
return fmt.pre === cssf.pre && fmt.ext === 'html';
});
cssf.action = null;
fmts[ idx ].css = cssf.data;
@ -203,7 +203,7 @@ Abstract theme representation.
// compact-[outputformat].[extension], for ex, compact-pdf.html.
if( !outFmt ) {
var idx = pathInfo.name.lastIndexOf('-');
outFmt = ( idx === -1 ) ? pathInfo.name : pathInfo.name.substr( idx + 1 )
outFmt = ( idx === -1 ) ? pathInfo.name : pathInfo.name.substr( idx + 1 );
}
// We should have a valid output format now.
@ -237,7 +237,7 @@ Abstract theme representation.
.forEach(function( cssf ) {
// For each CSS file, get its corresponding HTML file
var idx = _.findIndex(fmts, function( fmt ) {
return fmt.pre === cssf.pre && fmt.ext === 'html'
return fmt.pre === cssf.pre && fmt.ext === 'html';
});
fmts[ idx ].css = cssf.data;
fmts[ idx ].cssPath = cssf.path;

View File

@ -11,7 +11,7 @@ Handlebars template generate for FluentCV.
module.exports = function( json, jst, format, cssInfo, opts ) {
var template = HANDLEBARS.compile(jst);
return template( { r: json, filt: opts.filters, cssInfo: cssInfo, headFragment: opts.headFragment || '' } )
return template( { r: json, filt: opts.filters, cssInfo: cssInfo, headFragment: opts.headFragment || '' } );
};

View File

@ -13,7 +13,7 @@ Underscore template generate for FluentCV.
var delims = opts.themeObj.delimeters || opts.template;
if( opts.themeObj.delimeters ) {
delims = _.mapObject( delims, function(val,key) {
return new RegExp( val, "ig")
return new RegExp( val, "ig");
});
}
_.templateSettings = delims;

View File

@ -76,7 +76,7 @@ Internal resume generation logic for FluentCV.
targets.push.apply(targets, fmat === '.all' ?
Object.keys( theTheme.formats ).map(function(k){
var z = theTheme.formats[k];
return { file: to.replace(/all$/g,z.outFormat), fmt: z }
return { file: to.replace(/all$/g,z.outFormat), fmt: z };
}) : [{ file: to, fmt: theTheme.getFormat( fmat.slice(1) ) }]);
});
@ -97,7 +97,8 @@ Internal resume generation logic for FluentCV.
try {
var f = targInfo.file
, fType = targInfo.fmt.outFormat
, fName = path.basename(f, '.' + fType);
, fName = path.basename(f, '.' + fType)
, theFormat;
// If targInfo.fmt.files exists, this theme has an explicit "files"
// section in its theme.json file.
@ -107,7 +108,7 @@ Internal resume generation logic for FluentCV.
targInfo.fmt.outFormat.toUpperCase().useful.bold +
' resume: '.useful + path.relative(process.cwd(), f ).useful.bold);
var theFormat = _fmts.filter(
theFormat = _fmts.filter(
function(fmt) { return fmt.name === targInfo.fmt.outFormat; })[0];
MKDIRP.sync( path.dirname( f ) ); // Ensure dest folder exists;
theFormat.gen.generate( rez, f, _opts );
@ -134,7 +135,7 @@ Internal resume generation logic for FluentCV.
targInfo.fmt.outFormat.toUpperCase().useful.bold +
' resume: '.useful + path.relative(process.cwd(), f ).useful.bold);
var theFormat = _fmts.filter(
theFormat = _fmts.filter(
function(fmt) { return fmt.name === targInfo.fmt.outFormat; })[0];
MKDIRP.sync( path.dirname( f ) ); // Ensure dest folder exists;
theFormat.gen.generate( rez, f, _opts );
@ -181,8 +182,9 @@ Internal resume generation logic for FluentCV.
sheets.forEach( function( rep ) {
var rez;
try {
var rez = JSON.parse( rep.raw );
rez = JSON.parse( rep.raw );
}
catch( ex ) {
_log('Validating '.info + rep.file.infoBold +
@ -204,11 +206,11 @@ Internal resume generation logic for FluentCV.
var isValid = false;
var style = 'useful';
var errors = [];
var fmt = rez.meta &&
(rez.meta.format === 'FRESH@0.1.0') ? 'fresh':'jars';
try {
var fmt = rez.meta &&
(rez.meta.format === 'FRESH@0.1.0') ? 'fresh':'jars';
var validate = validator( schemas[ fmt ], { // Note [1]
formats: {
date: /^\d{4}(?:-(?:0[0-9]{1}|1[0-2]{1})(?:-[0-9]{2})?)?$/
@ -272,8 +274,8 @@ Internal resume generation logic for FluentCV.
dst = src || ['resume.json'];
dst.forEach( function( t ) {
var safeFormat = opts.format.toUpperCase();
_log('Creating new '.useful +safeFormat.useful.bold+ ' resume: '.useful
+ t.useful.bold);
_log('Creating new '.useful +safeFormat.useful.bold +
' resume: '.useful + t.useful.bold);
MKDIRP.sync( path.dirname( t ) ); // Ensure dest folder exists;
FLUENT[ safeFormat + 'Resume' ].default().save( t );
});

View File

@ -37,10 +37,10 @@ Template-based resume generator base for FluentCV.
raw: function( txt ) { return txt; },
xml: function( txt ) { return XML(txt); },
md: function( txt ) { return MD( txt || '' ); },
mdin: function( txt ) { return MD(txt || '' ).replace(/^\s*\<p\>|\<\/p\>\s*$/gi, ''); },
mdin: function( txt ) { return MD(txt || '' ).replace(/^\s*<p>|<\/p>\s*$/gi, ''); },
lower: function( txt ) { return txt.toLowerCase(); },
link: function( name, url ) { return url ?
'<a href="' + url + '">' + name + '</a>' : name }
'<a href="' + url + '">' + name + '</a>' : name; }
},
prettify: { // ← See https://github.com/beautify-web/js-beautify#options
indent_size: 2,

View File

@ -79,7 +79,7 @@ function logMsg( msg ) {
}
function getOpts( args ) {
var noPretty = args['nopretty'] || args.n;
var noPretty = args.nopretty || args.n;
noPretty = noPretty && (noPretty === true || noPretty === 'true');
return {
theme: args.t || 'modern',
@ -101,15 +101,15 @@ function handleError( ex ) {
case 3: msg = 'Please '.guide + 'specify a valid input resume'.guide.bold + ' in FRESH or JSON Resume format.'.guide; break;
case 4: msg = title + "\nPlease ".guide + "specify a command".guide.bold + " (".guide +
Object.keys( FCMD.verbs ).map( function(v, idx, ar) {
return (idx === ar.length - 1 ? 'or '.guide : '')
+ v.toUpperCase().guide;
return (idx === ar.length - 1 ? 'or '.guide : '') +
v.toUpperCase().guide;
}).join(', '.guide) + ").\n\n".guide + FS.readFileSync( PATH.join(__dirname, 'use.txt'), 'utf8' ).info.bold;
break;
//case 4: msg = title + '\n' + ; break;
case 5: msg = 'Please '.guide + 'specify the output resume file'.guide.bold + ' that should be created in the new format.'.guide; break;
case 6: msg = 'Please '.guide + 'specify a valid input resume'.guide.bold + ' in either FRESH or JSON Resume format.'.guide; break;
case 7: msg = 'Please '.guide + 'specify an output file name'.guide.bold + ' for every input file you wish to convert.'.guide; break;
};
}
exitCode = ex.fluenterror;
}

View File

@ -41,7 +41,7 @@
return ret;
};
})(name, prop[name]) :
})(name, prop[name]) : // jshint ignore:line
prop[name];
}