Socket
Socket
Sign inDemoInstall

semistandard

Package Overview
Dependencies
Maintainers
1
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

semistandard - npm Package Compare versions

Comparing version 3.3.0 to 4.0.0

eslintrc.json

98

bin/cmd.js
#!/usr/bin/env node
var minimist = require('minimist')
var standard = require('../')
var stdin = require('get-stdin')
var argv = minimist(process.argv.slice(2), {
alias: {
help: 'h',
verbose: 'v'
},
boolean: [
'help',
'stdin',
'verbose',
'version'
]
})
// running `standard -` is equivalent to `standard --stdin`
if (argv._[0] === '-') {
argv.stdin = true
argv._.shift()
}
if (argv.help) {
console.log(function () {
/*
semistandard - JavaScript Standard Style With Semicolons
Usage:
semistandard <flags> [FILES...]
If FILES is omitted, then all JavaScript source files (*.js, *.jsx) in the current
working directory are checked, recursively.
Certain paths (node_modules/, .git/, coverage/, *.min.js, bundle.js) are
automatically excluded.
Flags:
-v, --verbose Show error codes. (so you can ignore specific rules)
--stdin Read file text from stdin.
--version Show current version.
-h, --help Show usage information.
Readme: https://github.com/flet/semistandard
Report bugs: https://github.com/flet/semistandard/issues
*/
}.toString().split(/\n/).slice(2, -2).join('\n'))
process.exit(0)
}
if (argv.version) {
console.log(require('../package.json').version)
process.exit(0)
}
if (argv.stdin) {
stdin(function (text) {
standard.lintText(text, onResult)
})
} else {
var lintOpts = {}
standard.lintFiles(argv._, lintOpts, onResult)
}
function onResult (err, result) {
if (err) return error(err)
if (result.errorCount === 0) process.exit(0)
console.error(
'Error: Use JavaScript Standard Style With Semicolons' +
'(https://github.com/flet/semistandard)'
)
result.results.forEach(function (result) {
result.messages.forEach(function (message) {
console.error(
' %s:%d:%d: %s%s',
result.filePath, message.line || 0, message.column || 0, message.message,
argv.verbose ? ' (' + message.ruleId + ')' : ''
)
})
})
process.exit(1)
}
function error (err) {
console.error('Unexpected Linter Output:\n')
console.error(err.stack || err.message || err)
console.error(
'\nIf you think this is a bug in `semistandard`, open an issue: ' +
'https://github.com/flet/semistandard'
)
process.exit(1)
}
var opts = require('../options.js')
require('standard-engine').cli(opts)

@@ -1,128 +0,4 @@

module.exports.lintText = lintText
module.exports.lintFiles = lintFiles
// programmatic usage
var opts = require('./options.js')
var dezalgo = require('dezalgo')
var eslint = require('eslint')
var findRoot = require('find-root')
var glob = require('glob')
var parallel = require('run-parallel')
var path = require('path')
var uniq = require('uniq')
var DEFAULT_PATTERNS = [
'**/*.js',
'**/*.jsx'
]
var DEFAULT_IGNORE_PATTERNS = [
'**/node_modules/**',
'.git/**',
'coverage/**',
'**/*.min.js',
'**/bundle.js'
]
var ESLINT_CONFIG = {
configFile: path.join(__dirname, 'rc', '.eslintrc'),
useEslintrc: false
}
/**
* Lint text to enforce JavaScript Standard Style With Semicolons.
*
* @param {string} text file text to lint
* @param {Object} opts options object
* @param {Array.<String>} opts.ignore file globs to ignore (has sane defaults)
* @param {string} opts.cwd current working directory (default: process.cwd())
* @param {function(Error, Object)} cb callback
*/
function lintText (text, opts, cb) {
if (typeof opts === 'function') {
cb = opts
opts = {}
}
opts = parseOpts(opts)
cb = dezalgo(cb)
var result
try {
result = new eslint.CLIEngine(ESLINT_CONFIG).executeOnText(text)
} catch (err) {
return cb(err)
}
return cb(null, result)
}
/**
* Lint files to enforce JavaScript Standard Style With Semicolons.
*
* @param {Array.<string>} files file globs to lint
* @param {Object} opts options object
* @param {Array.<String>} opts.ignore file globs to ignore (has sane defaults)
* @param {string} opts.cwd current working directory (default: process.cwd())
* @param {function(Error, Object)} cb callback
*/
function lintFiles (files, opts, cb) {
if (typeof opts === 'function') {
cb = opts
opts = {}
}
opts = parseOpts(opts)
cb = dezalgo(cb)
if (typeof files === 'string') files = [ files ]
if (files.length === 0) files = DEFAULT_PATTERNS
// traverse filesystem
parallel(files.map(function (pattern) {
return function (cb) {
glob(pattern, {
cwd: opts.cwd,
ignore: opts.ignore,
nodir: true
}, cb)
}
}), function (err, results) {
if (err) return cb(err)
// flatten nested arrays
var files = results.reduce(function (files, result) {
result.forEach(function (file) {
files.push(file)
})
return files
}, [])
// de-dupe
files = uniq(files)
// undocumented – do not use (used by bin/cmd.js)
if (opts._onFiles) opts._onFiles(files)
var result
try {
result = new eslint.CLIEngine(ESLINT_CONFIG).executeOnFiles(files)
} catch (err) {
return cb(err)
}
return cb(null, result)
})
}
function parseOpts (opts) {
if (!opts) opts = {}
if (!opts.cwd) opts.cwd = process.cwd()
// Add user ignore patterns to default ignore patterns
opts.ignore = (opts.ignore || []).concat(DEFAULT_IGNORE_PATTERNS)
// Add additional ignore patterns from the closest `package.json`
try {
var root = findRoot(opts.cwd)
var packageOpts = require(path.join(root, 'package.json')).semistandard
if (packageOpts) opts.ignore = opts.ignore.concat(packageOpts.ignore)
} catch (e) {}
return opts
}
module.exports = require('standard-engine')(opts)
{
"name": "semistandard",
"description": "All the goodness of `feross/standard` with semicolons sprinkled on top.",
"version": "3.3.0",
"version": "4.0.0",
"author": {

@@ -17,12 +17,3 @@ "name": "Dan Flettre",

"dependencies": {
"dezalgo": "^1.0.1",
"eslint": "git://github.com/eslint/eslint.git#06927eeacba776c29a40bc0a191f9d9fc9575ba6",
"eslint-plugin-react": "^1.5.0",
"find-root": "^0.1.1",
"get-stdin": "^4.0.1",
"glob": "^4.3.5",
"minimist": "^1.1.0",
"run-parallel": "^1.0.0",
"uniq": "^1.0.1",
"which": "^1.0.8"
"standard-engine": "^1.0.1"
},

@@ -75,6 +66,3 @@ "devDependencies": {

"scripts": {
"sync": "npm install && cd syncscript && ./syncstandard && cd .. && npm prune && npm install && fixpack && npm test",
"test": "standard && node ./test.js",
"which-eslint": "which eslint",
"which-jscs": "which jscs"
"test": "standard && node ./test.js"
},

@@ -81,0 +69,0 @@ "standard": {

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