Socket
Socket
Sign inDemoInstall

standard

Package Overview
Dependencies
Maintainers
1
Versions
185
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

standard - npm Package Compare versions

Comparing version 1.5.0 to 2.0.0

lib/eslint-reporter-verbose.js

11

bin/test.js

@@ -20,5 +20,6 @@ #!/usr/bin/env node

var URLS = [
'git@github.com:feross/webtorrent.git',
'git@github.com:feross/bittorrent-tracker.git',
'git@github.com:feross/bittorrent-dht.git'
'https://github.com/feross/webtorrent.git',
'https://github.com/feross/bittorrent-tracker.git',
'https://github.com/feross/bittorrent-dht.git',
'https://github.com/mafintosh/level-temp.git'
]

@@ -31,3 +32,3 @@

return function (cb) {
var name = /\/([^.]+)\.git$/.exec(url)[1]
var name = /\/([^.\/]+)\.git$/.exec(url)[1]
var args = [ 'clone', url, path.join(TMP, name) ]

@@ -39,3 +40,3 @@ // TODO: Start `git` in a way that works on Windows – PR welcome!

if (err) return error(err)
spawn(STANDARD, [], function (err) {
spawn(STANDARD, ['--verbose'], function (err) {
if (err) return error(err)

@@ -42,0 +43,0 @@ console.log('ok')

@@ -9,9 +9,15 @@ var cp = require('child_process')

var JSHINT = path.join(__dirname, 'node_modules', '.bin', 'jshint')
var JSHINTRC = path.join(__dirname, 'rc', '.jshintrc')
var JSHINT_RC = path.join(__dirname, 'rc', '.jshintrc')
var JSHINT_REPORTER = path.join(__dirname, 'lib', 'jshint-reporter.js')
var JSCS = path.join(__dirname, 'node_modules', '.bin', 'jscs')
var JSCSRC = path.join(__dirname, 'rc', '.jscsrc')
var JSCS_RC = path.join(__dirname, 'rc', '.jscsrc')
var JSCS_REPORTER = path.join(__dirname, 'lib', 'jscs-reporter.js')
var JSCS_REPORTER_VERBOSE = path.join(__dirname, 'lib', 'jscs-reporter-verbose.js')
var ESLINT = path.join(__dirname, 'node_modules', '.bin', 'eslint')
var ESLINT_RC = path.join(__dirname, 'rc', '.eslintrc')
var ESLINT_REPORTER = path.join(__dirname, 'lib', 'eslint-reporter.js')
var ESLINT_REPORTER_VERBOSE = path.join(__dirname, 'lib', 'eslint-reporter-verbose.js')
if (/^win/.test(process.platform)) {

@@ -65,6 +71,7 @@ JSHINT += '.cmd'

var jshintArgs = ['--config', JSHINTRC, '--reporter', 'unix']
var jshintArgs = ['--config', JSHINT_RC, '--reporter', JSHINT_REPORTER]
var jscsReporter = opts.verbose ? JSCS_REPORTER_VERBOSE : JSCS_REPORTER
var jscsArgs = ['--config', JSCSRC, '--reporter', jscsReporter, '--esnext']
var jscsArgs = ['--config', JSCS_RC, '--reporter', jscsReporter]
var eslintReporter = opts.verbose ? ESLINT_REPORTER_VERBOSE : ESLINT_REPORTER
var eslintArgs = ['--config', ESLINT_RC, '--format', eslintReporter]

@@ -78,51 +85,25 @@ if (opts.verbose) {

jscsArgs = jscsArgs.concat(files)
eslintArgs = eslintArgs.concat(files)
var jshint = spawn(JSHINT, jshintArgs, function (jshintErr) {
var jscs = spawn(JSCS, jscsArgs, function (jscsErr) {
if (jshintErr || jscsErr) {
if (opts.bare) {
errors.forEach(function (str) {
console.error(str)
})
return
}
console.error('Error: Code style check failed:')
var errMap = {}
errors
.filter(function (str) { // de-duplicate errors
if (errMap[str]) return false
errMap[str] = true
return true
})
.sort(function (a, b) {
// sort by line number (merges jshint and jscs output)
var fileA = FILE_RE.exec(a)[1]
var fileB = FILE_RE.exec(b)[1]
var lineA = Number(LINE_RE.exec(a)[1])
var lineB = Number(LINE_RE.exec(b)[1])
var colA = Number(COL_RE.exec(a)[1])
var colB = Number(COL_RE.exec(b)[1])
if (fileA !== fileB) return fileA < fileB ? -1 : 1
if (lineA !== lineB) return lineA - lineB
return colA - colB
})
.forEach(function (str) {
console.error(' ' + str) // indent
})
process.exit(1)
}
spawn(JSHINT, jshintArgs, function (err1) {
spawn(JSCS, jscsArgs, function (err2) {
spawn(ESLINT, eslintArgs, function (err3) {
done(err1 || err2 || err3)
})
})
})
})
stderrPipe(jscs.stdout)
stderrPipe(jscs.stderr)
function spawn (command, args, cb) {
var child = cp.spawn(command, args)
child.on('error', error)
child.on('close', function (code) {
if (code !== 0) cb(new Error('non-zero exit code: ' + code))
else cb(null)
})
stderrPipe(child.stdout)
stderrPipe(child.stderr)
return child
}
stderrPipe(jshint.stdout)
stderrPipe(jshint.stderr)
})
function stderrPipe (readable) {

@@ -133,16 +114,43 @@ readable

if (line === '') return
if (/^\d+ errors?/.test(line)) return
errors.push(line)
})
}
}
function spawn (command, args, cb) {
var child = cp.spawn(command, args)
child.on('error', error)
child.on('close', function (code) {
if (code !== 0) cb(new Error('non-zero exit code: ' + code))
else cb(null)
})
return child
function done (err) {
if (!err) return
if (opts.bare) {
errors.forEach(function (str) {
console.error(str)
})
return
}
console.error('Error: Code style check failed:')
var errMap = {}
errors
.filter(function (str) { // de-duplicate errors
if (errMap[str]) return false
errMap[str] = true
return true
})
.sort(function (a, b) {
// sort by line number (merges jshint and jscs output)
var fileA = FILE_RE.exec(a)[1]
var fileB = FILE_RE.exec(b)[1]
var lineA = Number(LINE_RE.exec(a)[1])
var lineB = Number(LINE_RE.exec(b)[1])
var colA = Number(COL_RE.exec(a)[1])
var colB = Number(COL_RE.exec(b)[1])
if (fileA !== fileB) return fileA < fileB ? -1 : 1
if (lineA !== lineB) return lineA - lineB
return colA - colB
})
.forEach(function (str) {
console.error(' ' + str) // indent
})
process.exit(1)
}
}

@@ -149,0 +157,0 @@

var util = require('util')
module.exports = function (errorsCollection) {
var errorCount = 0
errorsCollection.forEach(function (errors) {
var file = errors.getFilename()
if (!errors.isEmpty()) {
errors.getErrorList().forEach(function (error) {
errorCount++
var message = error.message.substring(error.rule.length + 2)
console.log(util.format(
'%s:%d:%d: %s (%s)', file, error.line, error.column, message, error.rule
))
})
}
if (errors.isEmpty()) return
errors.getErrorList().forEach(function (error) {
var message = error.message.substring(error.rule.length + 2)
console.log(util.format(
'%s:%d:%d: %s (%s)', file, error.line, error.column, message, error.rule
))
})
})
}
var util = require('util')
module.exports = function (errorsCollection) {
var errorCount = 0
errorsCollection.forEach(function (errors) {
var file = errors.getFilename()
if (!errors.isEmpty()) {
errors.getErrorList().forEach(function (error) {
errorCount++
console.log(util.format(
'%s:%d:%d: %s', file, error.line, error.column, error.message
))
})
}
if (errors.isEmpty()) return
errors.getErrorList().forEach(function (error) {
console.log(util.format(
'%s:%d:%d: %s', file, error.line, error.column, error.message
))
})
})
}
{
"name": "standard",
"description": "JavaScript Standard Style",
"version": "1.5.0",
"version": "2.0.0",
"author": {

@@ -17,2 +17,3 @@ "name": "Feross Aboukhadijeh",

"dependencies": {
"eslint": "^0.13.0",
"find-root": "^0.1.1",

@@ -19,0 +20,0 @@ "glob": "^4.3.5",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc