mirror of
https://github.com/JuanCanham/HackMyResume.git
synced 2025-05-10 07:47:07 +01:00
style: fix eslint violations
This commit is contained in:
@ -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?
|
||||
|
@ -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 )
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user