From 541198321e0372860e3edd0f6cba1f1cb6ab178b Mon Sep 17 00:00:00 2001 From: devlinjd Date: Wed, 9 Dec 2015 21:44:35 -0500 Subject: [PATCH] Fix JSHint warnings. --- src/core/fluent-date.js | 4 ++-- src/core/fresh-resume.js | 21 +++++++++++---------- src/core/jrs-resume.js | 8 ++++---- src/core/theme.js | 10 +++++----- src/eng/handlebars-generator.js | 2 +- src/eng/underscore-generator.js | 2 +- src/fluentcmd.js | 20 +++++++++++--------- src/gen/template-generator.js | 4 ++-- src/index.js | 8 ++++---- src/utils/class.js | 2 +- 10 files changed, 42 insertions(+), 39 deletions(-) diff --git a/src/core/fluent-date.js b/src/core/fluent-date.js index df57d72..7a3d967 100644 --- a/src/core/fluent-date.js +++ b/src/core/fluent-date.js @@ -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' ); diff --git a/src/core/fresh-resume.js b/src/core/fresh-resume.js index 4e8f488..a0f5287 100644 --- a/src/core/fresh-resume.js +++ b/src/core/fresh-resume.js @@ -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\>\s*$/gi, ''); + return MD(txt || '' ).replace(/^\s*

|<\/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})?)?$/ } }); diff --git a/src/core/jrs-resume.js b/src/core/jrs-resume.js index b7bfba3..4ec8749 100644 --- a/src/core/jrs-resume.js +++ b/src/core/jrs-resume.js @@ -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 ); }; diff --git a/src/core/theme.js b/src/core/theme.js index bb86a06..9d43efd 100644 --- a/src/core/theme.js +++ b/src/core/theme.js @@ -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; diff --git a/src/eng/handlebars-generator.js b/src/eng/handlebars-generator.js index 807c891..4d04a2a 100644 --- a/src/eng/handlebars-generator.js +++ b/src/eng/handlebars-generator.js @@ -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 || '' } ); }; diff --git a/src/eng/underscore-generator.js b/src/eng/underscore-generator.js index 329550f..c2a0543 100644 --- a/src/eng/underscore-generator.js +++ b/src/eng/underscore-generator.js @@ -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; diff --git a/src/fluentcmd.js b/src/fluentcmd.js index cb8b6c9..2d5accb 100644 --- a/src/fluentcmd.js +++ b/src/fluentcmd.js @@ -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 ); }); diff --git a/src/gen/template-generator.js b/src/gen/template-generator.js index 2db20b1..5c68832 100644 --- a/src/gen/template-generator.js +++ b/src/gen/template-generator.js @@ -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\>\s*$/gi, ''); }, + mdin: function( txt ) { return MD(txt || '' ).replace(/^\s*

|<\/p>\s*$/gi, ''); }, lower: function( txt ) { return txt.toLowerCase(); }, link: function( name, url ) { return url ? - '' + name + '' : name } + '' + name + '' : name; } }, prettify: { // ← See https://github.com/beautify-web/js-beautify#options indent_size: 2, diff --git a/src/index.js b/src/index.js index b5dd466..e50315f 100644 --- a/src/index.js +++ b/src/index.js @@ -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; } diff --git a/src/utils/class.js b/src/utils/class.js index 2640865..9479e89 100644 --- a/src/utils/class.js +++ b/src/utils/class.js @@ -41,7 +41,7 @@ return ret; }; - })(name, prop[name]) : + })(name, prop[name]) : // jshint ignore:line prop[name]; }