semistandard
Advanced tools
Comparing version 3.3.0 to 4.0.0
#!/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) |
130
index.js
@@ -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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Git dependency
Supply chain riskContains a dependency which resolves to a remote git URL. Dependencies fetched from git URLs are not immutable can be used to inject untrusted code or reduce the likelihood of a reproducible install.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
1
0
0
10158
7
194
+ Addedstandard-engine@^1.0.1
+ Addedansi-regex@1.1.12.1.1(transitive)
+ Addedansi-styles@2.2.1(transitive)
+ Addedargparse@1.0.10(transitive)
+ Addedbuffer-from@1.1.2(transitive)
+ Addedchalk@1.1.3(transitive)
+ Addedcli-width@1.1.1(transitive)
+ Addedclone@1.0.4(transitive)
+ Addedconcat-stream@1.6.2(transitive)
+ Addedcore-util-is@1.0.3(transitive)
+ Addedd@1.0.2(transitive)
+ Addeddebug@2.6.9(transitive)
+ Addeddebug-log@1.0.1(transitive)
+ Addeddeep-is@0.1.4(transitive)
+ Addeddefaults@1.0.4(transitive)
+ Addeddeglob@1.1.2(transitive)
+ Addeddoctrine@0.6.4(transitive)
+ Addedes5-ext@0.10.64(transitive)
+ Addedes6-iterator@2.0.3(transitive)
+ Addedes6-map@0.1.5(transitive)
+ Addedes6-set@0.1.6(transitive)
+ Addedes6-symbol@3.1.4(transitive)
+ Addedes6-weak-map@2.0.3(transitive)
+ Addedescape-string-regexp@1.0.5(transitive)
+ Addedescope@3.6.0(transitive)
+ Addedeslint@0.24.1(transitive)
+ Addedesniff@2.0.1(transitive)
+ Addedespree@2.2.5(transitive)
+ Addedesprima@4.0.1(transitive)
+ Addedesrecurse@4.3.0(transitive)
+ Addedestraverse@4.3.05.3.0(transitive)
+ Addedestraverse-fb@1.3.2(transitive)
+ Addedesutils@1.1.6(transitive)
+ Addedevent-emitter@0.3.5(transitive)
+ Addedext@1.7.0(transitive)
+ Addedfast-levenshtein@1.0.7(transitive)
+ Addedfigures@1.7.0(transitive)
+ Addedfind-root@1.1.0(transitive)
+ Addedfs.realpath@1.0.0(transitive)
+ Addedgenerate-function@2.3.1(transitive)
+ Addedgenerate-object-property@1.2.0(transitive)
+ Addedglob@7.2.3(transitive)
+ Addedglobals@8.18.0(transitive)
+ Addedhas-ansi@2.0.0(transitive)
+ Addedignore@3.3.10(transitive)
+ Addedinquirer@0.8.5(transitive)
+ Addedis-my-ip-valid@1.0.1(transitive)
+ Addedis-my-json-valid@2.20.6(transitive)
+ Addedis-property@1.0.2(transitive)
+ Addedisarray@0.0.11.0.0(transitive)
+ Addedjs-yaml@3.14.1(transitive)
+ Addedjsonpointer@5.0.1(transitive)
+ Addedlevn@0.2.5(transitive)
+ Addedlodash@3.10.1(transitive)
+ Addedminimatch@3.1.2(transitive)
+ Addedmkdirp@0.5.6(transitive)
+ Addedms@2.0.0(transitive)
+ Addedmute-stream@0.0.4(transitive)
+ Addednext-tick@1.1.0(transitive)
+ Addedobject-assign@2.1.14.1.1(transitive)
+ Addedoptionator@0.5.0(transitive)
+ Addedpath-is-absolute@1.0.1(transitive)
+ Addedpkg-config@1.1.1(transitive)
+ Addedprelude-ls@1.1.2(transitive)
+ Addedprocess-nextick-args@2.0.1(transitive)
+ Addedreadable-stream@2.3.8(transitive)
+ Addedreadline2@0.1.1(transitive)
+ Addedrx@2.5.3(transitive)
+ Addedsafe-buffer@5.1.2(transitive)
+ Addedsprintf-js@1.0.3(transitive)
+ Addedstandard-engine@1.11.1(transitive)
+ Addedstring_decoder@1.1.1(transitive)
+ Addedstrip-ansi@2.0.13.0.1(transitive)
+ Addedstrip-json-comments@1.0.4(transitive)
+ Addedsupports-color@2.0.0(transitive)
+ Addedtext-table@0.2.0(transitive)
+ Addedthrough@2.3.8(transitive)
+ Addedtype@2.7.3(transitive)
+ Addedtype-check@0.3.2(transitive)
+ Addedtypedarray@0.0.6(transitive)
+ Addeduser-home@1.1.1(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
+ Addedwordwrap@0.0.3(transitive)
+ Addedxml-escape@1.0.0(transitive)
+ Addedxtend@4.0.2(transitive)
- Removeddezalgo@^1.0.1
- Removedeslint@git://github.com/eslint/eslint.git#06927eeacba776c29a40bc0a191f9d9fc9575ba6
- Removedeslint-plugin-react@^1.5.0
- Removedfind-root@^0.1.1
- Removedget-stdin@^4.0.1
- Removedglob@^4.3.5
- Removedminimist@^1.1.0
- Removedrun-parallel@^1.0.0
- Removeduniq@^1.0.1
- Removedwhich@^1.0.8
- Removedeslint-plugin-react@1.6.1(transitive)
- Removedglob@4.5.3(transitive)
- Removedisexe@2.0.0(transitive)
- Removedwhich@1.3.1(transitive)