@task
@needs('pavelib.prereqs.install_node_prereqs')
@cmdopts([('limit=', 'l', 'limit for number of acceptable violations')])
@timed
def run_eslint(options):
 eslint_report_dir = (Env.REPORT_DIR / 'eslint')
 eslint_report = (eslint_report_dir / 'eslint.report')
 _prepare_report_dir(eslint_report_dir)
 violations_limit = int(getattr(options, 'limit', (-1)))
 sh('eslint --format=compact . | tee {eslint_report}'.format(eslint_report=eslint_report), ignore_error=True)
 try:
  num_violations = int(_get_count_from_last_line(eslint_report, 'eslint'))
 except TypeError:
  raise BuildFailure('Error. Number of eslint violations could not be found in {eslint_report}'.format(eslint_report=eslint_report))
 _write_metric(num_violations, (Env.METRICS_DIR / 'eslint'))
 if (num_violations > violations_limit > (-1)):
  raise BuildFailure('ESLint Failed. Too many violations ({count}).\nThe limit is {violations_limit}.'.format(count=num_violations, violations_limit=violations_limit))

@ task @ needs ( 'pavelib.prereqs.install_node_prereqs' ) @ cmdopts ( [ ( 'limit=' , 'l' , 'limit for number of acceptable violations' ) ] ) @ timed def run_eslint ( options ) : eslint_report_dir = ( Env . REPORT_DIR / 'eslint' ) eslint_report = ( eslint_report_dir / 'eslint.report' ) _prepare_report_dir ( eslint_report_dir ) violations_limit = int ( getattr ( options , 'limit' , ( - 1 ) ) ) sh ( 'eslint --format=compact . | tee {eslint_report}' . format ( eslint_report = eslint_report ) , ignore_error = True ) try : num_violations = int ( _get_count_from_last_line ( eslint_report , 'eslint' ) ) except TypeError : raise BuildFailure ( 'Error. Number of eslint violations could not be found in {eslint_report}' . format ( eslint_report = eslint_report ) ) _write_metric ( num_violations , ( Env . METRICS_DIR / 'eslint' ) ) if ( num_violations > violations_limit > ( - 1 ) ) : raise BuildFailure ( 'ESLint Failed. Too many violations ({count}).\nThe limit is {violations_limit}.' . format ( count = num_violations , violations_limit = violations_limit ) )
runs eslint on static asset directories .