Comparing version 0.2.0 to 0.2.1
@@ -22,3 +22,4 @@ #!/usr/bin/env node | ||
'maxlen' : Number, | ||
'predef' : [String, Array] | ||
'predef' : [String, Array], | ||
'edition' : String | ||
}; | ||
@@ -64,3 +65,5 @@ | ||
// This was the last file. | ||
process.exit(ok ? 0 : 1); | ||
process.stdout.on('drain', function () { | ||
process.exit(ok ? 0 : 1); | ||
}); | ||
} | ||
@@ -67,0 +70,0 @@ }; |
@@ -0,0 +0,0 @@ function color(code, string) { |
@@ -1,5 +0,60 @@ | ||
var JSLINT = require("../lib/nodelint"); | ||
/*jslint stupid: true*/ | ||
var JSLINT, | ||
path = require('path'), | ||
fs = require('fs'); | ||
function addDefaults(options) { | ||
function loadAndParseConfig(filePath) { | ||
'use strict'; | ||
return fs.existsSync(filePath) ? | ||
JSON.parse(fs.readFileSync(filePath, "utf-8")) : {}; | ||
} | ||
function merge(source, add) { | ||
'use strict'; | ||
var result = source, | ||
prop; | ||
for (prop in add) { | ||
if (add.hasOwnProperty(prop)) { | ||
if (!result.hasOwnProperty(prop)) { | ||
result[prop] = add[prop]; | ||
} | ||
} | ||
} | ||
return result; | ||
} | ||
exports.merge = merge; | ||
function mergeConfigs(homerc) { | ||
'use strict'; | ||
var homeConfig = loadAndParseConfig(homerc), | ||
args = [].concat(arguments), | ||
cwdrcs = args.slice(1), | ||
cwdConfig = loadAndParseConfig(cwdrcs[0]) || loadAndParseConfig(cwdrcs[1]), | ||
config; | ||
config = merge(cwdConfig, homeConfig); | ||
return config; | ||
} | ||
function loadConfig() { | ||
'use strict'; | ||
var home = process.env.HOME || '', | ||
defaultConfig = path.join(home, '.jslintrc'), | ||
projectConfig = path.join(process.cwd(), 'jslintrc'), | ||
projectConfigDot = path.join(process.cwd(), '.jslintrc'), | ||
config = mergeConfigs(defaultConfig, projectConfig, projectConfigDot); | ||
return config; | ||
} | ||
function addDefaults(options, config) { | ||
'use strict'; | ||
options = merge(options, config); | ||
['node', 'es5'].forEach(function (opt) { | ||
@@ -12,6 +67,30 @@ if (!options.hasOwnProperty(opt)) { | ||
} | ||
exports.addDefaults = addDefaults; | ||
function splitPredefs(options) { | ||
'use strict'; | ||
if (options.predef && !Array.isArray(options.predef)) { | ||
options.predef = options.predef.split(',') | ||
.filter(function (n) { return !!n; }); | ||
} | ||
return options; | ||
} | ||
exports.splitPredefs = splitPredefs; | ||
function loadJSLint(options) { | ||
'use strict'; | ||
return require("../lib/nodelint")(options.edition); | ||
} | ||
exports.lint = function (script, options) { | ||
'use strict'; | ||
var config = loadConfig(), | ||
ok, | ||
result; | ||
JSLINT = JSLINT || loadJSLint(options); | ||
// Fix UTF8 with BOM | ||
@@ -25,13 +104,17 @@ if (script.charCodeAt(0) === 0xFEFF) { | ||
script = script.replace(/^\#\!.*/, ""); | ||
/*jslint regexp: false*/ | ||
options = options || {}; | ||
delete options.argv; | ||
options = addDefaults(options); | ||
var ok = JSLINT(script, options), | ||
result = { | ||
ok: true, | ||
errors: [] | ||
}; | ||
options = addDefaults(options, config); | ||
options = splitPredefs(options); | ||
ok = JSLINT(script, options); | ||
result = { | ||
ok: true, | ||
errors: [] | ||
}; | ||
if (!ok) { | ||
@@ -38,0 +121,0 @@ result = JSLINT.data(); |
/*jslint | ||
nomen: true | ||
*/ | ||
var vm = require("vm"); | ||
var fs = require("fs"); | ||
nomen: true, stupid: true | ||
*/ | ||
var ctx = vm.createContext(); | ||
module.exports = function (edition) { | ||
'use strict'; | ||
vm.runInContext(fs.readFileSync(__dirname + "/jslint.js"), ctx); | ||
var vm = require("vm"), | ||
fs = require("fs"), | ||
ctx = vm.createContext(), | ||
f; | ||
module.exports = ctx.JSLINT; | ||
function read(name) { | ||
return fs.readFileSync(__dirname + "/" + name + ".js"); | ||
} | ||
if (edition) { | ||
try { | ||
f = read("jslint-" + edition); | ||
} catch (err) { | ||
console.warn("Unable to load edition " + edition + ", reverting to default. " + err); | ||
} | ||
} | ||
if (!f) { | ||
f = read("jslint"); | ||
} | ||
vm.runInContext(f, ctx); | ||
return ctx.JSLINT; | ||
}; |
@@ -47,3 +47,7 @@ /*jslint forin: true */ | ||
} else { | ||
log(fileMessage + " is " + (colorize ? color.green('OK') : 'OK') + "."); | ||
if (terse) { | ||
process.stderr.write("."); | ||
} else { | ||
log(fileMessage + " is " + (colorize ? color.green('OK') : 'OK') + "."); | ||
} | ||
} | ||
@@ -50,0 +54,0 @@ |
@@ -8,3 +8,3 @@ { | ||
], | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"author" : "Reid Burke <me@reidburke.com>", | ||
@@ -16,3 +16,8 @@ "contributors": [ | ||
"Luke Smith <lsmith@yahoo-inc.com>", | ||
"Anders Conbere <aconbere@gmail.com>" | ||
"Anders Conbere <aconbere@gmail.com>", | ||
"Ryuichi OKUMURA <okuryu@okuryu.com>", | ||
"Sam Mikes <smikes@cubane.com>", | ||
"Dylan Lloyd", | ||
"Andreas Hindborg", | ||
"Andrew Pennebaker" | ||
], | ||
@@ -26,2 +31,5 @@ "bin": { | ||
}, | ||
"devDependencies": { | ||
"ronn": "0.4.0" | ||
}, | ||
"engines": { | ||
@@ -31,3 +39,4 @@ "node": ">=0.4.12" | ||
"directories": { | ||
"lib": "./lib" | ||
"lib": "./lib", | ||
"man": "./man" | ||
}, | ||
@@ -46,3 +55,6 @@ "repository": { | ||
} | ||
] | ||
], | ||
"scripts": { | ||
"test": "make test" | ||
} | ||
} |
@@ -5,4 +5,23 @@ ## node-jslint | ||
jslint app.js | ||
jslint bin/jslint.js | ||
## What's New | ||
Version 0.2.1 of node-jslint provides multiple editions of jslint to | ||
address backwards and forwards compatibility. | ||
### Use the default jslint | ||
jslint lib/color.js | ||
### Always use the latest jslint | ||
jslint --edition=latest lib/color.js | ||
### Use a specific edition | ||
For example, edition 2013-02-03 which shipped with node-jslint 0.1.9: | ||
jslint --edition=2013-02-03 lib/color.js | ||
## Install | ||
@@ -20,20 +39,23 @@ | ||
jslint lib/worker.js lib/server.js | ||
jslint lib/color.js lib/reporter.js | ||
All JSLint options supported | ||
jslint --white --vars --regexp app.js | ||
jslint --white --vars --regexp lib/color.js | ||
Defaults to true, but you can specify false | ||
jslint --bitwise false app.js | ||
jslint --bitwise false lib/color.js | ||
Pass arrays | ||
jslint --predef $ --predef Backbone app.js | ||
jslint --predef $ --predef Backbone lib/color.js | ||
JSLint your entire project | ||
find . -name "*.js" -print0 | xargs -0 jslint | ||
find . -name "*.js" -print0 | xargs -0 jslint | ||
Using JSLint with a config file | ||
Start with the included jslintrc.example file and customize your options | ||
per project or copy it to $HOME/.jslintrc to apply your setting globally | ||
@@ -40,0 +62,0 @@ ## License |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
964368
20
25888
65
1
1
5
2