Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve CLI output and use newest version of standard #18

Merged
merged 2 commits into from
Jun 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 18 additions & 19 deletions lib/linter.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
'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-unused-expressions',
'no-lone-blocks',
'no-labels'
]
const eslintDisable = '/* eslint-disable ' + disabledRules.join(', ') + ' */\n'
const linter = module.exports = {}

function removeParensWrappingOrphanedObject (block) {
return block.replace(
Expand Down Expand Up @@ -65,18 +68,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)
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"globby": "^6.0.0",
"lodash.flatten": "^4.2.0",
"lodash.range": "^3.1.5",
"standard": "^8.6.0"
"ora": "^1.2.0",
"standard": "^10.0.2"
},
"devDependencies": {
"tap-spec": "^4.1.1",
Expand Down