1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2024-11-24 17:30:10 +00:00

style: fix eslint violations

This commit is contained in:
hacksalot 2018-02-12 04:01:00 -05:00
parent 922c1968ca
commit 407f9f8cd7
No known key found for this signature in database
GPG Key ID: 2F343EC247CA4B06
7 changed files with 58 additions and 61 deletions

View File

@ -59,14 +59,14 @@ module.exports = function (grunt) {
// Use 'grunt test' for local testing
grunt.registerTask('test', 'Test the HackMyResume application.',
function( config ) {
function() {
grunt.task.run(['clean:test','build','eslint','simplemocha:all']);
}
);
// Use 'grunt build' to build HMR
grunt.registerTask('build', 'Build the HackMyResume application.',
function( config ) {
function() {
grunt.task.run( ['clean:dist','copy','coffee','eslint'] );
}
);

19
dist/cli/error.js vendored
View File

@ -4,18 +4,12 @@
@module cli/error
@license MIT. See LICENSE.md for details.
*/
/** Error handler for HackMyResume. All errors are handled here.
@class ErrorHandler */
var ErrorHandler, FCMD, FS, HMSTATUS, M2C, PATH, PKG, SyntaxErrorEx, WRAP, YAML, _defaultLog, assembleError, chalk, extend, printf;
var FS, HMSTATUS, M2C, PATH, SyntaxErrorEx, WRAP, _defaultLog, assembleError, chalk, extend, printf;
HMSTATUS = require('../core/status-codes');
PKG = require('../../package.json');
FS = require('fs');
FCMD = require('../index');
PATH = require('path');
WRAP = require('word-wrap');
@ -26,15 +20,15 @@
extend = require('extend');
YAML = require('yamljs');
printf = require('printf');
SyntaxErrorEx = require('../utils/syntax-error-ex');
require('string.prototype.startswith');
ErrorHandler = module.exports = {
/** Error handler for HackMyResume. All errors are handled here.
@class ErrorHandler */
module.exports = {
init: function(debug, assert, silent) {
this.debug = debug;
this.assert = assert;
@ -94,7 +88,7 @@
};
_defaultLog = function() {
return console.log.apply(console.log, arguments);
return console.log.apply(console.log, arguments); // eslint-disable-line no-console
};
assembleError = function(ex) {
@ -185,6 +179,7 @@
break;
case HMSTATUS.readError:
if (!ex.quiet) {
// eslint-disable-next-line no-console
console.error(printf(M2C(this.msgs.readError.msg, 'red'), ex.file));
}
msg = ex.inner.toString();
@ -215,6 +210,7 @@
break;
case HMSTATUS.parseError:
if (SyntaxErrorEx.is(ex.inner)) {
// eslint-disable-next-line no-console
console.error(printf(M2C(this.msgs.readError.msg, 'red'), ex.file));
se = new SyntaxErrorEx(ex, ex.raw);
if ((se.line != null) && (se.col != null)) {
@ -243,6 +239,7 @@
case HMSTATUS.invalidOptionsFile:
msg = M2C(this.msgs.invalidOptionsFile.msg[0]);
if (SyntaxErrorEx.is(ex.inner)) {
// eslint-disable-next-line no-console
console.error(printf(M2C(this.msgs.readError.msg, 'red'), ex.file));
se = new SyntaxErrorEx(ex, ex.raw);
if ((se.line != null) && (se.col != null)) {

34
dist/cli/main.js vendored
View File

@ -15,15 +15,8 @@
- Need to accept JSON inputs from the command line.
*/
/* Simple logging placeholder. */
/*
A callable implementation of the HackMyResume CLI. Encapsulates the command
line interface as a single method accepting a parameter array.
@alias module:cli/main.main
@param rawArgs {Array} An array of command-line parameters. Will either be
process.argv (in production) or custom parameters (in test).
*/
/* Split multiple command-line filenames by the 'TO' keyword */
var Command, EXTEND, FS, HME, HMR, HMSTATUS, M2C, OUTPUT, PAD, PATH, PKG, StringUtils, _, _err, _exitCallback, _opts, _out, _title, chalk, execute, executeFail, executeSuccess, initOptions, initialize, loadOptions, logMsg, main, printf, safeLoadJSON, splitSrcDest;
var Command, EXTEND, FS, HMR, HMSTATUS, M2C, OUTPUT, PAD, PATH, PKG, _, _err, _exitCallback, _opts, _out, _title, chalk, execute, executeFail, executeSuccess, initOptions, initialize, loadOptions, logMsg, printf, safeLoadJSON, splitSrcDest;
HMR = require('../index');
@ -39,12 +32,9 @@
HMSTATUS = require('../core/status-codes');
HME = require('../core/event-codes');
safeLoadJSON = require('../utils/safe-json-loader');
StringUtils = require('../utils/string.js');
//StringUtils = require '../utils/string.js'
_ = require('underscore');
OUTPUT = require('./out');
@ -67,7 +57,14 @@
_exitCallback = null;
main = module.exports = function(rawArgs, exitCallback) {
/*
A callable implementation of the HackMyResume CLI. Encapsulates the command
line interface as a single method accepting a parameter array.
@alias module:cli/main.main
@param rawArgs {Array} An array of command-line parameters. Will either be
process.argv (in production) or custom parameters (in test).
*/
module.exports = function(rawArgs, exitCallback) {
var args, initInfo, program;
initInfo = initialize(rawArgs, exitCallback);
if (initInfo === null) {
@ -96,13 +93,15 @@
execute.call(this, sources, [], this.opts(), logMsg);
});
// Create the PEEK command
program.command('peek').arguments('<sources...>').description('Peek at a resume field or section').action(function(sources, sectionOrField) {
//.action(( sources, sectionOrField ) ->
program.command('peek').arguments('<sources...>').description('Peek at a resume field or section').action(function(sources) {
var dst;
dst = (sources && sources.length > 1) ? [sources.pop()] : [];
execute.call(this, sources, dst, this.opts(), logMsg);
});
// Create the BUILD command
program.command('build').alias('generate').option('-t --theme <theme>', 'Theme name or path').option('-n --no-prettify', 'Disable HTML prettification', true).option('-c --css <option>', 'CSS linking / embedding').option('-p --pdf <engine>', 'PDF generation engine').option('--no-sort', 'Sort resume sections by date', false).option('--tips', 'Display theme tips and warnings.', false).option('--private', 'Include resume fields marked as private', false).option('--no-escape', "Turn off encoding in Handlebars themes.", false).description('Generate resume to multiple formats').action(function(sources, targets, options) {
//.action(( sources, targets, options ) ->
program.command('build').alias('generate').option('-t --theme <theme>', 'Theme name or path').option('-n --no-prettify', 'Disable HTML prettification', true).option('-c --css <option>', 'CSS linking / embedding').option('-p --pdf <engine>', 'PDF generation engine').option('--no-sort', 'Sort resume sections by date', false).option('--tips', 'Display theme tips and warnings.', false).option('--private', 'Include resume fields marked as private', false).option('--no-escape', 'Turn off encoding in Handlebars themes.', false).description('Generate resume to multiple formats').action(function() {
var x;
x = splitSrcDest.call(this);
execute.call(this, x.src, x.dst, this.opts(), logMsg);
@ -166,7 +165,7 @@
}, true);
}
// Override the .missingArgument behavior
Command.prototype.missingArgument = function(name) {
Command.prototype.missingArgument = function(/* unused */) {
if (this.name() !== 'help') {
_err.err({
verb: this.name(),
@ -277,7 +276,7 @@
prom.then(executeSuccess, executeFail);
};
executeSuccess = function(obj) {};
executeSuccess = function(/*obj*/) {};
// Can't call _exitCallback here (process.exit) when PDF is running in BK
//_exitCallback 0; return
@ -363,6 +362,7 @@
};
logMsg = function() {
// eslint-disable-next-line no-console
return _opts.silent || console.log.apply(console.log, arguments);
};

19
dist/cli/out.js vendored
View File

@ -4,7 +4,7 @@
@license MIT. See LICENSE.md for details.
@module cli/out
*/
var EXTEND, FS, HANDLEBARS, HME, LO, M2C, OutputHandler, PATH, YAML, _, chalk, dbgStyle, pad, printf;
var EXTEND, FS, HANDLEBARS, HME, M2C, OutputHandler, PATH, YAML, _, chalk, dbgStyle, pad, printf;
chalk = require('chalk');
@ -16,8 +16,6 @@
PATH = require('path');
LO = require('lodash');
FS = require('fs');
EXTEND = require('extend');
@ -32,7 +30,7 @@
dbgStyle = 'cyan';
module.exports = OutputHandler = class OutputHandler {
OutputHandler = class OutputHandler {
constructor(opts) {
this.init(opts);
return;
@ -43,16 +41,15 @@
this.msgs = YAML.load(PATH.join(__dirname, 'msg.yml')).events;
}
log(msg) {
log() {
var finished;
msg = msg || '';
printf = require('printf');
finished = printf.apply(printf, arguments);
return this.opts.silent || console.log(finished);
return this.opts.silent || console.log(finished); // eslint-disable-line no-console
}
do(evt) {
var L, WRAP, adj, info, msg, msgs, numFormats, output, rawTpl, sty, style, suffix, template, that, themeName, tot;
var L, adj, info, msg, msgs, numFormats, output, rawTpl, sty, style, suffix, template, that, themeName, tot;
that = this;
L = function() {
return that.log.apply(that, arguments);
@ -84,7 +81,6 @@
if (evt.cmd === 'build') {
themeName = this.theme.name.toUpperCase();
if (this.opts.tips && (this.theme.message || this.theme.render)) {
WRAP = require('word-wrap');
if (this.theme.message) {
L(M2C(this.msgs.afterBuild.msg[0], 'cyan'), themeName);
return L(M2C(this.theme.message, 'white'));
@ -157,7 +153,7 @@
evt.schema = evt.schema.replace('jars', 'JSON Resume').toUpperCase();
L(M2C(msgs[0], 'white') + chalk[style].bold(adj), evt.file, evt.schema);
if (evt.violations) {
_.each(evt.violations, function(err, idx) {
_.each(evt.violations, function(err) {
L(chalk.yellow.bold('--> ') + chalk.yellow(err.field.replace('data.', 'resume.').toUpperCase() + ' ' + err.message));
}, this);
}
@ -172,6 +168,7 @@
}
// If the key was present, print it
if (evt.target !== void 0 && !evt.error) {
// eslint-disable-next-line no-console
return console.dir(evt.target, {
depth: null,
colors: true
@ -186,6 +183,8 @@
};
module.exports = OutputHandler;
}).call(this);
//# sourceMappingURL=out.js.map

View File

@ -7,15 +7,12 @@ Error-handling routines for HackMyResume.
HMSTATUS = require '../core/status-codes'
PKG = require '../../package.json'
FS = require 'fs'
FCMD = require '../index'
PATH = require 'path'
WRAP = require 'word-wrap'
M2C = require '../utils/md2chalk'
chalk = require 'chalk'
extend = require 'extend'
YAML = require 'yamljs'
printf = require 'printf'
SyntaxErrorEx = require '../utils/syntax-error-ex'
require 'string.prototype.startswith'
@ -24,7 +21,7 @@ require 'string.prototype.startswith'
###* Error handler for HackMyResume. All errors are handled here.
@class ErrorHandler ###
ErrorHandler = module.exports =
module.exports =
init: ( debug, assert, silent ) ->
@debug = debug
@ -86,8 +83,7 @@ ErrorHandler = module.exports =
format_custom: ( msg ) -> msg
_defaultLog = () -> console.log.apply console.log, arguments
_defaultLog = () -> console.log.apply console.log, arguments # eslint-disable-line no-console
@ -180,6 +176,7 @@ assembleError = ( ex ) ->
when HMSTATUS.readError
if !ex.quiet
# eslint-disable-next-line no-console
console.error(printf( M2C(this.msgs.readError.msg, 'red'), ex.file))
msg = ex.inner.toString()
etype = 'error'
@ -205,6 +202,7 @@ assembleError = ( ex ) ->
when HMSTATUS.parseError
if SyntaxErrorEx.is ex.inner
# eslint-disable-next-line no-console
console.error printf( M2C(this.msgs.readError.msg, 'red'), ex.file )
se = new SyntaxErrorEx ex, ex.raw
if se.line? and se.col?
@ -231,6 +229,7 @@ assembleError = ( ex ) ->
when HMSTATUS.invalidOptionsFile
msg = M2C @msgs.invalidOptionsFile.msg[0]
if SyntaxErrorEx.is ex.inner
# eslint-disable-next-line no-console
console.error printf( M2C(this.msgs.readError.msg, 'red'), ex.file )
se = new SyntaxErrorEx ex, ex.raw
if se.line? and se.col?

View File

@ -13,9 +13,8 @@ EXTEND = require 'extend'
chalk = require 'chalk'
PATH = require 'path'
HMSTATUS = require '../core/status-codes'
HME = require '../core/event-codes'
safeLoadJSON = require '../utils/safe-json-loader'
StringUtils = require '../utils/string.js'
#StringUtils = require '../utils/string.js'
_ = require 'underscore'
OUTPUT = require './out'
PAD = require 'string-padding'
@ -37,7 +36,7 @@ line interface as a single method accepting a parameter array.
@param rawArgs {Array} An array of command-line parameters. Will either be
process.argv (in production) or custom parameters (in test).
###
main = module.exports = ( rawArgs, exitCallback ) ->
module.exports = ( rawArgs, exitCallback ) ->
initInfo = initialize( rawArgs, exitCallback )
if initInfo is null
@ -107,7 +106,8 @@ main = module.exports = ( rawArgs, exitCallback ) ->
.command('peek')
.arguments('<sources...>')
.description('Peek at a resume field or section')
.action(( sources, sectionOrField ) ->
#.action(( sources, sectionOrField ) ->
.action(( sources ) ->
dst = if (sources && sources.length > 1) then [sources.pop()] else []
execute.call( this, sources, dst, this.opts(), logMsg)
return
@ -124,9 +124,10 @@ main = module.exports = ( rawArgs, exitCallback ) ->
.option('--no-sort', 'Sort resume sections by date', false)
.option('--tips', 'Display theme tips and warnings.', false)
.option('--private', 'Include resume fields marked as private', false)
.option('--no-escape', "Turn off encoding in Handlebars themes.", false)
.option('--no-escape', 'Turn off encoding in Handlebars themes.', false)
.description('Generate resume to multiple formats')
.action(( sources, targets, options ) ->
#.action(( sources, targets, options ) ->
.action(->
x = splitSrcDest.call( this );
execute.call( this, x.src, x.dst, this.opts(), logMsg)
return
@ -188,7 +189,7 @@ initialize = ( ar, exitCallback ) ->
_err.err fluenterror: HMSTATUS.invalidCommand, quit: true, attempted: o.orgVerb, true
# Override the .missingArgument behavior
Command.prototype.missingArgument = (name) ->
Command.prototype.missingArgument = (### unused ###) ->
if this.name() != 'help'
_err.err
verb: @name()
@ -293,7 +294,7 @@ execute = ( src, dst, opts, log ) ->
### Success handler for verb invocations. Calls process.exit by default ###
executeSuccess = (obj) ->
executeSuccess = (###obj###) ->
# Can't call _exitCallback here (process.exit) when PDF is running in BK
#_exitCallback 0; return
@ -385,4 +386,5 @@ splitSrcDest = () ->
### Simple logging placeholder. ###
logMsg = () ->
# eslint-disable-next-line no-console
_opts.silent || console.log.apply( console.log, arguments )

View File

@ -11,7 +11,6 @@ HME = require('../core/event-codes')
_ = require('underscore')
M2C = require('../utils/md2chalk.js')
PATH = require('path')
LO = require('lodash')
FS = require('fs')
EXTEND = require('extend')
HANDLEBARS = require('handlebars')
@ -23,7 +22,7 @@ dbgStyle = 'cyan';
###* A stateful output module. All HMR console output handled here. ###
module.exports = class OutputHandler
class OutputHandler
@ -40,11 +39,10 @@ module.exports = class OutputHandler
log: ( msg ) ->
msg = msg || ''
log: ->
printf = require('printf')
finished = printf.apply( printf, arguments )
@opts.silent || console.log( finished )
@opts.silent || console.log( finished ) # eslint-disable-line no-console
@ -94,7 +92,6 @@ module.exports = class OutputHandler
if evt.cmd == 'build'
themeName = this.theme.name.toUpperCase()
if this.opts.tips && (this.theme.message || this.theme.render)
WRAP = require('word-wrap')
if this.theme.message
L( M2C( this.msgs.afterBuild.msg[0], 'cyan' ), themeName )
L( M2C( this.theme.message, 'white' ))
@ -153,7 +150,7 @@ module.exports = class OutputHandler
L(M2C( msgs[0], 'white' ) + chalk[style].bold(adj), evt.file, evt.schema)
if evt.violations
_.each evt.violations, (err,idx) ->
_.each evt.violations, (err) ->
L( chalk.yellow.bold('--> ') +
chalk.yellow(err.field.replace('data.','resume.').toUpperCase() +
' ' + err.message))
@ -172,6 +169,7 @@ module.exports = class OutputHandler
# If the key was present, print it
if evt.target != undefined and !evt.error
# eslint-disable-next-line no-console
console.dir( evt.target, { depth: null, colors: true } )
# If the key was not present, but no error occurred, print it
@ -180,3 +178,5 @@ module.exports = class OutputHandler
else if evt.error
L chalk.red( evt.error.inner.inner )
module.exports = OutputHandler