From debe5cdfe3b4b9fcdbb6ffaaa9d2bf525ff9ce49 Mon Sep 17 00:00:00 2001 From: Zeke Sikelianos Date: Sat, 10 Jun 2017 09:54:45 -0700 Subject: [PATCH 1/2] use ora to show progress --- lib/linter.js | 36 +++++++++++++++++------------------- package.json | 1 + 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/lib/linter.js b/lib/linter.js index a3cdabb..e526bf3 100644 --- a/lib/linter.js +++ b/lib/linter.js @@ -1,17 +1,19 @@ 'use strict' -var fs = require('fs') - -var async = require('async') -var flatten = require('lodash.flatten') -var standard = require('standard') - -var extractCodeBlocks = require('./codeBlockUtils').extractCodeBlocks - -var disabledRules = ['no-undef', 'no-unused-vars', 'no-lone-blocks', 'no-labels'] -var eslintDisable = '/* eslint-disable ' + disabledRules.join(', ') + ' */\n' - -var linter = module.exports = {} +const fs = require('fs') +const async = require('async') +const flatten = require('lodash.flatten') +const standard = require('standard') +const ora = require('ora') +const extractCodeBlocks = require('./codeBlockUtils').extractCodeBlocks +const disabledRules = [ + 'no-undef', + 'no-unused-vars', + 'no-lone-blocks', + 'no-labels' +] +const eslintDisable = '/* eslint-disable ' + disabledRules.join(', ') + ' */\n' +const linter = module.exports = {} function removeParensWrappingOrphanedObject (block) { return block.replace( @@ -65,18 +67,14 @@ linter.lintText = function (text, standardOptions, done) { linter.lintFiles = function (files, standardOptions, done) { var index = 0 + const spinner = (files.length > 3) ? ora().start() : null + if (typeof standardOptions === 'function') { done = standardOptions standardOptions = {} } async.map(files, function (file, callback) { - // Inform the user of progress - if (process.stdout.clearLine && process.stdout.cursorTo) { - process.stdout.clearLine() - process.stdout.cursorTo(0) - } - - process.stdout.write('Linting file ' + (index++ + 1) + ' of ' + files.length) + if (spinner) spinner.text('Linting file ' + (index++ + 1) + ' of ' + files.length) linter.lintText(fs.readFileSync(file, 'utf8'), standardOptions, function (err, errors, outputText) { if (err) return callback(err) diff --git a/package.json b/package.json index c6f7862..77cdfd7 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "globby": "^6.0.0", "lodash.flatten": "^4.2.0", "lodash.range": "^3.1.5", + "ora": "^1.2.0", "standard": "^8.6.0" }, "devDependencies": { From 5ba495e9ca6e68551d10f62a42dbc95d80f36a19 Mon Sep 17 00:00:00 2001 From: Zeke Sikelianos Date: Sat, 10 Jun 2017 09:58:38 -0700 Subject: [PATCH 2/2] update to standard 10 and disable no-unused-expressions rule --- lib/linter.js | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/linter.js b/lib/linter.js index e526bf3..d07140a 100644 --- a/lib/linter.js +++ b/lib/linter.js @@ -9,6 +9,7 @@ const extractCodeBlocks = require('./codeBlockUtils').extractCodeBlocks const disabledRules = [ 'no-undef', 'no-unused-vars', + 'no-unused-expressions', 'no-lone-blocks', 'no-labels' ] diff --git a/package.json b/package.json index 77cdfd7..4a4cce5 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "lodash.flatten": "^4.2.0", "lodash.range": "^3.1.5", "ora": "^1.2.0", - "standard": "^8.6.0" + "standard": "^10.0.2" }, "devDependencies": { "tap-spec": "^4.1.1",