coffeelint
Advanced tools
Comparing version 1.16.0 to 2.0.0
@@ -12,40 +12,40 @@ (function() { | ||
csVer = ((typeof window !== "undefined" && window !== null ? window.CoffeeScript : void 0) || require('coffee-script')).VERSION; | ||
csVer = ((typeof window !== "undefined" && window !== null ? window.CoffeeScript : void 0) || require('coffeescript')).VERSION; | ||
module.exports = Cache = (function() { | ||
function Cache(basepath) { | ||
module.exports = Cache = class Cache { | ||
constructor(basepath) { | ||
this.basepath = basepath; | ||
if (!fs.existsSync(this.basepath)) { | ||
fs.mkdirSync(this.basepath, 0x1ed); | ||
fs.mkdirSync(this.basepath, 0o755); | ||
} | ||
} | ||
Cache.prototype.path = function(source) { | ||
return path.join(this.basepath, csVer + "-" + ltVer + "-" + this.prefix + "-" + (this.hash(source))); | ||
}; | ||
path(source) { | ||
return path.join(this.basepath, `${csVer}-${ltVer}-${this.prefix}-${this.hash(source)}`); | ||
} | ||
Cache.prototype.get = function(source) { | ||
get(source) { | ||
return JSON.parse(fs.readFileSync(this.path(source), 'utf8')); | ||
}; | ||
} | ||
Cache.prototype.set = function(source, result) { | ||
set(source, result) { | ||
return fs.writeFileSync(this.path(source), JSON.stringify(result)); | ||
}; | ||
} | ||
Cache.prototype.has = function(source) { | ||
has(source) { | ||
return fs.existsSync(this.path(source)); | ||
}; | ||
} | ||
Cache.prototype.hash = function(data) { | ||
hash(data) { | ||
return crypto.createHash('md5').update('' + data).digest('hex').substring(0, 8); | ||
}; | ||
} | ||
Cache.prototype.setConfig = function(config) { | ||
// Use user config as a "namespace" so that | ||
// when he/she changes it the cache becomes invalid | ||
setConfig(config) { | ||
return this.prefix = this.hash(JSON.stringify(config)); | ||
}; | ||
} | ||
return Cache; | ||
}; | ||
})(); | ||
}).call(this); |
@@ -0,10 +1,8 @@ | ||
(function() { | ||
/* | ||
CoffeeLint | ||
/* | ||
CoffeeLint | ||
Copyright (c) 2011 Matthew Perpick. | ||
CoffeeLint is freely distributable under the MIT license. | ||
*/ | ||
(function() { | ||
Copyright (c) 2011 Matthew Perpick. | ||
CoffeeLint is freely distributable under the MIT license. | ||
*/ | ||
var Cache, CoffeeScript, coffeelint, config, configfinder, coreReporters, data, deprecatedReporter, errorReport, findCoffeeScripts, fs, getAllExtention, getFallbackConfig, glob, ignore, jsonIndentation, lintFiles, lintSource, loadConfig, log, logConfig, optimist, options, os, path, paths, read, readConfigFile, ref, reportAndExit, resolve, ruleLoader, scripts, stdin, stripComments, thisdir, userConfig; | ||
@@ -38,3 +36,3 @@ | ||
CoffeeScript = require('coffee-script'); | ||
CoffeeScript = require('coffeescript'); | ||
@@ -44,5 +42,7 @@ CoffeeScript.register(); | ||
log = function() { | ||
return console.log.apply(console, arguments); | ||
// coffeelint: disable=no_debugger | ||
return console.log(...arguments); | ||
}; | ||
// coffeelint: enable=no_debugger | ||
jsonIndentation = 2; | ||
@@ -60,2 +60,3 @@ | ||
// Return the contents of the given file synchronously. | ||
read = function(path) { | ||
@@ -67,6 +68,7 @@ var realPath; | ||
// build all extentions to search | ||
getAllExtention = function(extension) { | ||
if (extension != null) { | ||
extension = ['coffee'].concat(extension != null ? extension.split(',') : void 0); | ||
return "@(" + (extension.join('|')) + ")"; | ||
return `@(${extension.join('|')})`; | ||
} else { | ||
@@ -77,2 +79,3 @@ return 'coffee'; | ||
// Return a list of CoffeeScript's in the given paths. | ||
findCoffeeScripts = function(paths, extension) { | ||
@@ -85,3 +88,4 @@ var allExtention, files, i, len, p; | ||
if (fs.statSync(p).isDirectory()) { | ||
files = files.concat(glob.sync(p + "/**/*." + allExtention)); | ||
// The glob library only uses forward slashes. | ||
files = files.concat(glob.sync(`${p}/**/*.${allExtention}`)); | ||
} else { | ||
@@ -91,2 +95,7 @@ files.push(p); | ||
} | ||
// Normalize paths, converting './test/fixtures' to 'test/fixtures'. | ||
// Ignore pattern 'test/fixtures' does NOT match './test/fixtures', | ||
// because if there is a slash(/) in the pattern, the pattern will not | ||
// act as a glob pattern. | ||
// Use `path.join()` instead of `path.normalize()` for better compatibility. | ||
return files.map(function(p) { | ||
@@ -97,2 +106,3 @@ return path.join(p); | ||
// Return an error report from linting the given paths. | ||
lintFiles = function(files, config) { | ||
@@ -111,7 +121,5 @@ var errorReport, file, fileConfig, i, len, literate, source; | ||
lintSource = function(source, config, literate) { | ||
// Return an error report from linting the given coffeescript source. | ||
lintSource = function(source, config, literate = false) { | ||
var errorReport; | ||
if (literate == null) { | ||
literate = false; | ||
} | ||
errorReport = new coffeelint.getErrorReport(); | ||
@@ -123,2 +131,3 @@ config || (config = getFallbackConfig()); | ||
// Load a config file given a path/filename | ||
readConfigFile = function(path) { | ||
@@ -139,2 +148,3 @@ var text; | ||
config = readConfigFile(options.argv.f); | ||
// If -f was specifying a package.json, extract the config | ||
if (config.coffeelintConfig) { | ||
@@ -148,6 +158,6 @@ config = config.coffeelintConfig; | ||
getFallbackConfig = function(filename) { | ||
if (filename == null) { | ||
filename = null; | ||
} | ||
// Get fallback configuration. With the -F flag found configs in standard places | ||
// will be used for each file being linted. Standard places are package.json or | ||
// coffeelint.json in a project's root folder or the user's home folder. | ||
getFallbackConfig = function(filename = null) { | ||
if (!options.argv.noconfig) { | ||
@@ -158,2 +168,4 @@ return configfinder.getConfig(filename); | ||
// These reporters are usually parsed by other software, so I can't just echo a | ||
// warning. Creating a fake file is my best attempt. | ||
deprecatedReporter = function(errorReport, reporter) { | ||
@@ -167,3 +179,3 @@ var base; | ||
'rule': 'commandline', | ||
'message': "parameter --" + reporter + " is deprecated. Use --reporter " + reporter + " instead", | ||
'message': `parameter --${reporter} is deprecated. Use --reporter ${reporter} instead`, | ||
'lineNumber': 0 | ||
@@ -175,3 +187,3 @@ }); | ||
coreReporters = { | ||
"default": require(path.join(thisdir, 'reporters', 'default')), | ||
default: require(path.join(thisdir, 'reporters', 'default')), | ||
csv: require(path.join(thisdir, 'reporters', 'csv')), | ||
@@ -183,2 +195,3 @@ jslint: require(path.join(thisdir, 'reporters', 'jslint')), | ||
// Publish the error report and exit with the appropriate status. | ||
reportAndExit = function(errorReport, options) { | ||
@@ -225,2 +238,3 @@ var SelectedReporter, base, colorize, ref, reporter, strReporter; | ||
// Declare command line options. | ||
options = optimist.usage('Usage: coffeelint [options] source [...]').alias('f', 'file').alias('h', 'help').alias('v', 'version').alias('s', 'stdin').alias('q', 'quiet').alias('c', 'cache').describe('f', 'Specify a custom configuration file.').describe('rules', 'Specify a custom rule or directory of rules.').describe('makeconfig', 'Prints a default config file').describe('trimconfig', 'Compares your config with the default and prints a minimal configuration').describe('noconfig', 'Ignores any config file.').describe('h', 'Print help information.').describe('v', 'Print current version number.').describe('r', '(not used, but left for backward compatibility)').describe('reporter', 'built in reporter (default, csv, jslint, checkstyle, raw), or module, or path to reporter file.').describe('csv', '[deprecated] use --reporter csv').describe('jslint', '[deprecated] use --reporter jslint').describe('nocolor', '[deprecated] use --color=never').describe('checkstyle', '[deprecated] use --reporter checkstyle').describe('color=<when>', 'When to colorize the output. <when> can be one of always, never , or auto.').describe('s', 'Lint the source from stdin').describe('q', 'Only print errors.').describe('literate', 'Used with --stdin to process as Literate CoffeeScript').describe('c', 'Cache linting results').describe('ext', 'Specify an additional file extension, separated by comma.').boolean('csv').boolean('jslint').boolean('checkstyle').boolean('nocolor').boolean('noconfig').boolean('makeconfig').boolean('trimconfig').boolean('literate').boolean('r').boolean('s').boolean('q', 'Print errors only.').boolean('c'); | ||
@@ -243,5 +257,7 @@ | ||
} else { | ||
// Initialize cache, if enabled | ||
if (options.argv.cache) { | ||
coffeelint.setCache(new Cache(path.join(os.tmpdir(), 'coffeelint'))); | ||
} | ||
// Load configuration. | ||
config = loadConfig(options); | ||
@@ -252,2 +268,3 @@ if (options.argv.rules) { | ||
if (options.argv.s) { | ||
// Lint from stdin | ||
data = ''; | ||
@@ -266,2 +283,3 @@ stdin = process.openStdin(); | ||
} else { | ||
// Find scripts to lint. | ||
paths = options.argv._; | ||
@@ -272,2 +290,3 @@ scripts = findCoffeeScripts(paths, options.argv.ext); | ||
} | ||
// Lint the code. | ||
errorReport = lintFiles(scripts, config, options.argv.literate); | ||
@@ -274,0 +293,0 @@ reportAndExit(errorReport, options); |
@@ -1,8 +0,6 @@ | ||
/* | ||
Helpers for finding CoffeeLint config in standard locations, similar to how | ||
JSHint does. | ||
*/ | ||
(function() { | ||
/* | ||
Helpers for finding CoffeeLint config in standard locations, similar to how | ||
JSHint does. | ||
*/ | ||
var expandModuleNames, extendConfig, findFile, findFileResults, fs, getConfig, loadJSON, loadNpmConfig, path, resolve, stripComments; | ||
@@ -18,4 +16,7 @@ | ||
// Cache for findFile | ||
findFileResults = {}; | ||
// Searches for a file with a specified name starting with 'dir' and going all | ||
// the way up either until it finds the file or hits the root. | ||
findFile = function(name, dir) { | ||
@@ -38,2 +39,3 @@ var filename, parent; | ||
// Possibly find CoffeeLint configuration within a package.json file. | ||
loadNpmConfig = function(dir) { | ||
@@ -47,2 +49,3 @@ var fp, ref; | ||
// Parse a JSON file gracefully. | ||
loadJSON = function(filename) { | ||
@@ -54,3 +57,3 @@ var e; | ||
e = error; | ||
process.stderr.write("Could not load JSON file '" + filename + "': " + e); | ||
process.stderr.write(`Could not load JSON file '${filename}': ${e}`); | ||
return null; | ||
@@ -60,2 +63,6 @@ } | ||
// Tries to find a configuration file in either project directory (if file is | ||
// given), as either the package.json's 'coffeelintConfig' property, or a project | ||
// specific 'coffeelint.json' or a global 'coffeelint.json' in the home | ||
// directory. | ||
getConfig = function(dir) { | ||
@@ -81,2 +88,6 @@ var envs, home, npmConfig, projConfig; | ||
// configfinder is the only part of coffeelint that actually has the full | ||
// filename and can accurately resolve module names. This will find all of the | ||
// modules and expand them into full paths so that they can be found when the | ||
// source and config are passed to `coffeelint.lint` | ||
expandModuleNames = function(dir, config) { | ||
@@ -117,6 +128,6 @@ var coffeelint, data, ruleName; | ||
var extendedConfig, parentConfig, rule, ruleName; | ||
if (!config["extends"]) { | ||
if (!config.extends) { | ||
return config; | ||
} | ||
parentConfig = require(config["extends"]); | ||
parentConfig = require(config.extends); | ||
extendedConfig = {}; | ||
@@ -134,7 +145,4 @@ for (ruleName in config) { | ||
exports.getConfig = function(filename) { | ||
exports.getConfig = function(filename = null) { | ||
var config, dir; | ||
if (filename == null) { | ||
filename = null; | ||
} | ||
if (filename) { | ||
@@ -141,0 +149,0 @@ dir = path.dirname(path.resolve(filename)); |
@@ -7,43 +7,47 @@ (function() { | ||
module.exports = CheckstyleReporter = (function() { | ||
function CheckstyleReporter(errorReport, options) { | ||
this.errorReport = errorReport; | ||
if (options == null) { | ||
options = {}; | ||
class CheckstyleReporter { | ||
constructor(errorReport, options = {}) { | ||
this.errorReport = errorReport; | ||
({quiet: this.quiet} = options); | ||
} | ||
this.quiet = options.quiet; | ||
} | ||
CheckstyleReporter.prototype.print = function(message) { | ||
return console.log(message); | ||
}; | ||
print(message) { | ||
// coffeelint: disable=no_debugger | ||
return console.log(message); | ||
} | ||
CheckstyleReporter.prototype.escape = JsLintReporter.prototype.escape; | ||
CheckstyleReporter.prototype.publish = function() { | ||
var context, e, errors, i, len, level, path, ref, ref1; | ||
this.print('<?xml version="1.0" encoding="utf-8"?>'); | ||
this.print('<checkstyle version="4.3">'); | ||
ref = this.errorReport.paths; | ||
for (path in ref) { | ||
errors = ref[path]; | ||
if (errors.length) { | ||
this.print("<file name=\"" + path + "\">"); | ||
for (i = 0, len = errors.length; i < len; i++) { | ||
e = errors[i]; | ||
if (!(!this.quiet || e.level === 'error')) { | ||
continue; | ||
publish() { | ||
var context, e, errors, i, len, level, path, ref, ref1; | ||
this.print('<?xml version="1.0" encoding="utf-8"?>'); | ||
this.print('<checkstyle version="4.3">'); | ||
ref = this.errorReport.paths; | ||
for (path in ref) { | ||
errors = ref[path]; | ||
if (errors.length) { | ||
this.print(`<file name="${path}">`); | ||
for (i = 0, len = errors.length; i < len; i++) { | ||
e = errors[i]; | ||
if (!(!this.quiet || e.level === 'error')) { | ||
continue; | ||
} | ||
level = e.level; | ||
if (level === 'warn') { | ||
level = 'warning'; | ||
} | ||
// context is optional, this avoids generating the string | ||
// "context: undefined" | ||
context = (ref1 = e.context) != null ? ref1 : ''; | ||
this.print(`<error line="${e.lineNumber}"\n severity="${this.escape(level)}"\n message="${this.escape(e.message + '; context: ' + context)}"\n source="coffeelint"/>`); | ||
} | ||
level = e.level; | ||
if (level === 'warn') { | ||
level = 'warning'; | ||
} | ||
context = (ref1 = e.context) != null ? ref1 : ''; | ||
this.print("<error line=\"" + e.lineNumber + "\"\n severity=\"" + (this.escape(level)) + "\"\n message=\"" + (this.escape(e.message + '; context: ' + context)) + "\"\n source=\"coffeelint\"/>"); | ||
this.print('</file>'); | ||
} | ||
this.print('</file>'); | ||
} | ||
return this.print('</checkstyle>'); | ||
} | ||
return this.print('</checkstyle>'); | ||
}; | ||
// coffeelint: enable=no_debugger | ||
CheckstyleReporter.prototype.escape = JsLintReporter.prototype.escape; | ||
return CheckstyleReporter; | ||
@@ -50,0 +54,0 @@ |
(function() { | ||
var CSVReporter; | ||
module.exports = CSVReporter = (function() { | ||
function CSVReporter(errorReport, options) { | ||
module.exports = CSVReporter = class CSVReporter { | ||
constructor(errorReport, options = {}) { | ||
this.errorReport = errorReport; | ||
if (options == null) { | ||
options = {}; | ||
} | ||
this.quiet = options.quiet; | ||
({quiet: this.quiet} = options); | ||
} | ||
CSVReporter.prototype.print = function(message) { | ||
print(message) { | ||
// coffeelint: disable=no_debugger | ||
return console.log(message); | ||
}; | ||
} | ||
CSVReporter.prototype.publish = function() { | ||
// coffeelint: enable=no_debugger | ||
publish() { | ||
var e, errors, f, header, path, ref, results; | ||
@@ -34,3 +33,5 @@ header = ['path', 'lineNumber', 'lineNumberEnd', 'level', 'message']; | ||
if (e.context) { | ||
e.message += " " + e.context + "."; | ||
// Having the context is useful for the cyclomatic_complexity | ||
// rule and critical for the undefined_variables rule. | ||
e.message += ` ${e.context}.`; | ||
} | ||
@@ -44,8 +45,6 @@ f = [path, e.lineNumber, (ref1 = e.lineNumberEnd) != null ? ref1 : e.lineNumberEnd, e.level, e.message]; | ||
return results; | ||
}; | ||
} | ||
return CSVReporter; | ||
}; | ||
})(); | ||
}).call(this); |
(function() { | ||
var Reporter, | ||
slice = [].slice; | ||
// Reports errors to the command line. | ||
var Reporter; | ||
module.exports = Reporter = (function() { | ||
function Reporter(errorReport, options) { | ||
module.exports = Reporter = class Reporter { | ||
constructor(errorReport, options = {}) { | ||
this.errorReport = errorReport; | ||
if (options == null) { | ||
options = {}; | ||
} | ||
this.colorize = options.colorize, this.quiet = options.quiet; | ||
({colorize: this.colorize, quiet: this.quiet} = options); | ||
this.ok = '✓'; | ||
@@ -17,5 +14,4 @@ this.warn = '⚡'; | ||
Reporter.prototype.stylize = function() { | ||
var map, message, styles; | ||
message = arguments[0], styles = 2 <= arguments.length ? slice.call(arguments, 1) : []; | ||
stylize(message, ...styles) { | ||
var map; | ||
if (!this.colorize) { | ||
@@ -33,5 +29,5 @@ return message; | ||
}, message); | ||
}; | ||
} | ||
Reporter.prototype.publish = function() { | ||
publish() { | ||
var errors, path, paths, report; | ||
@@ -50,7 +46,7 @@ paths = this.errorReport.paths; | ||
return this; | ||
}; | ||
} | ||
Reporter.prototype.reportSummary = function(s) { | ||
reportSummary(s) { | ||
var e, err, file, msg, p, start, w, warn; | ||
start = s.errorCount > 0 ? this.err + " " + (this.stylize('Lint!', 'red', 'bold')) : s.warningCount > 0 ? this.warn + " " + (this.stylize('Warning!', 'yellow', 'bold')) : this.ok + " " + (this.stylize('Ok!', 'green', 'bold')); | ||
start = s.errorCount > 0 ? `${this.err} ${this.stylize('Lint!', 'red', 'bold')}` : s.warningCount > 0 ? `${this.warn} ${this.stylize('Warning!', 'yellow', 'bold')}` : `${this.ok} ${this.stylize('Ok!', 'green', 'bold')}`; | ||
e = s.errorCount; | ||
@@ -62,12 +58,12 @@ w = s.warningCount; | ||
file = this.plural('file', p); | ||
msg = start + " » " + e + " " + err + " and " + w + " " + warn + " in " + p + " " + file; | ||
msg = `${start} » ${e} ${err} and ${w} ${warn} in ${p} ${file}`; | ||
return '\n' + this.stylize(msg) + '\n'; | ||
}; | ||
} | ||
Reporter.prototype.reportPath = function(path, errors) { | ||
var color, e, hasError, hasWarning, i, len, lineEnd, o, output, overall, pathReport, ref; | ||
ref = (hasError = this.errorReport.pathHasError(path)) ? [this.err, 'red'] : (hasWarning = this.errorReport.pathHasWarning(path)) ? [this.warn, 'yellow'] : [this.ok, 'green'], overall = ref[0], color = ref[1]; | ||
reportPath(path, errors) { | ||
var color, e, hasError, hasWarning, i, len, lineEnd, o, output, overall, pathReport; | ||
[overall, color] = (hasError = this.errorReport.pathHasError(path)) ? [this.err, 'red'] : (hasWarning = this.errorReport.pathHasWarning(path)) ? [this.warn, 'yellow'] : [this.ok, 'green']; | ||
pathReport = ''; | ||
if (!this.quiet || hasError) { | ||
pathReport += " " + overall + " " + (this.stylize(path, color, 'bold')) + "\n"; | ||
pathReport += ` ${overall} ${this.stylize(path, color, 'bold')}\n`; | ||
} | ||
@@ -82,8 +78,8 @@ for (i = 0, len = errors.length; i < len; i++) { | ||
if (e.lineNumberEnd != null) { | ||
lineEnd = "-" + e.lineNumberEnd; | ||
lineEnd = `-${e.lineNumberEnd}`; | ||
} | ||
output = '#' + e.lineNumber + lineEnd; | ||
pathReport += ' ' + (o + " " + (this.stylize(output, color)) + ": " + e.message + "."); | ||
pathReport += ' ' + `${o} ${this.stylize(output, color)}: ${e.message}.`; | ||
if (e.context) { | ||
pathReport += " " + e.context + "."; | ||
pathReport += ` ${e.context}.`; | ||
} | ||
@@ -93,20 +89,20 @@ pathReport += '\n'; | ||
return pathReport; | ||
}; | ||
} | ||
Reporter.prototype.print = function(message) { | ||
print(message) { | ||
// coffeelint: disable=no_debugger | ||
return console.log(message); | ||
}; | ||
} | ||
Reporter.prototype.plural = function(str, count) { | ||
// coffeelint: enable=no_debugger | ||
plural(str, count) { | ||
if (count === 1) { | ||
return str; | ||
} else { | ||
return str + "s"; | ||
return `${str}s`; | ||
} | ||
}; | ||
} | ||
return Reporter; | ||
}; | ||
})(); | ||
}).call(this); |
(function() { | ||
var JSLintReporter; | ||
module.exports = JSLintReporter = (function() { | ||
function JSLintReporter(errorReport, options) { | ||
module.exports = JSLintReporter = class JSLintReporter { | ||
constructor(errorReport, options = {}) { | ||
this.errorReport = errorReport; | ||
if (options == null) { | ||
options = {}; | ||
} | ||
this.quiet = options.quiet; | ||
({quiet: this.quiet} = options); | ||
} | ||
JSLintReporter.prototype.print = function(message) { | ||
print(message) { | ||
// coffeelint: disable=no_debugger | ||
return console.log(message); | ||
}; | ||
} | ||
JSLintReporter.prototype.publish = function() { | ||
// coffeelint: enable=no_debugger | ||
publish() { | ||
var e, errors, i, len, path, ref, ref1; | ||
@@ -24,7 +23,8 @@ this.print('<?xml version="1.0" encoding="utf-8"?><jslint>'); | ||
if (errors.length) { | ||
this.print("<file name=\"" + path + "\">"); | ||
this.print(`<file name="${path}">`); | ||
for (i = 0, len = errors.length; i < len; i++) { | ||
e = errors[i]; | ||
if (!this.quiet || e.level === 'error') { | ||
this.print("<issue line=\"" + e.lineNumber + "\"\n lineEnd=\"" + ((ref1 = e.lineNumberEnd) != null ? ref1 : e.lineNumber) + "\"\n reason=\"[" + (this.escape(e.level)) + "] " + (this.escape(e.message)) + "\"\n evidence=\"" + (this.escape(e.context)) + "\"/>"); | ||
// continue if @quiet and e.level isnt 'error' | ||
this.print(`<issue line="${e.lineNumber}"\n lineEnd="${(ref1 = e.lineNumberEnd) != null ? ref1 : e.lineNumber}"\n reason="[${this.escape(e.level)}] ${this.escape(e.message)}"\n evidence="${this.escape(e.context)}"/>`); | ||
} | ||
@@ -36,6 +36,7 @@ } | ||
return this.print('</jslint>'); | ||
}; | ||
} | ||
JSLintReporter.prototype.escape = function(msg) { | ||
escape(msg) { | ||
var i, len, r, replacements; | ||
// Force msg to be a String | ||
msg = '' + msg; | ||
@@ -45,2 +46,4 @@ if (!msg) { | ||
} | ||
// Perhaps some other HTML Special Chars should be added here | ||
// But this are the XML Special Chars listed in Wikipedia | ||
replacements = [[/&/g, '&'], [/"/g, '"'], [/</g, '<'], [/>/g, '>'], [/'/g, ''']]; | ||
@@ -52,8 +55,6 @@ for (i = 0, len = replacements.length; i < len; i++) { | ||
return msg; | ||
}; | ||
} | ||
return JSLintReporter; | ||
}; | ||
})(); | ||
}).call(this); |
(function() { | ||
var RawReporter; | ||
module.exports = RawReporter = (function() { | ||
function RawReporter(errorReport, options) { | ||
module.exports = RawReporter = class RawReporter { | ||
constructor(errorReport, options = {}) { | ||
this.errorReport = errorReport; | ||
if (options == null) { | ||
options = {}; | ||
} | ||
this.quiet = options.quiet; | ||
({quiet: this.quiet} = options); | ||
} | ||
RawReporter.prototype.print = function(message) { | ||
print(message) { | ||
// coffeelint: disable=no_debugger | ||
return console.log(message); | ||
}; | ||
} | ||
RawReporter.prototype.publish = function() { | ||
// coffeelint: enable=no_debugger | ||
publish() { | ||
var e, er, errors, path, ref; | ||
@@ -36,8 +35,6 @@ er = {}; | ||
return this.print(JSON.stringify(er, void 0, 2)); | ||
}; | ||
} | ||
return RawReporter; | ||
}; | ||
})(); | ||
}).call(this); |
@@ -8,2 +8,3 @@ (function() { | ||
// moduleName is a NodeJS module, or a path to a module NodeJS can load. | ||
module.exports = { | ||
@@ -13,2 +14,3 @@ require: function(moduleName) { | ||
try { | ||
// Try to find the project-level rule first. | ||
rulePath = resolve(moduleName, { | ||
@@ -21,7 +23,17 @@ basedir: process.cwd(), | ||
try { | ||
// Globally installed rule | ||
return require(moduleName); | ||
} catch (error) {} | ||
try { | ||
// Maybe the user used a relative path from the command line. This | ||
// doesn't make much sense from a config file, but seems natural | ||
// with the --rules option. | ||
// No try around this one, an exception here should abort the rest of | ||
// this function. | ||
return require(path.resolve(process.cwd(), moduleName)); | ||
} catch (error) {} | ||
// This was already tried once. It will definitely fail, but it will | ||
// fail with a more sensible error message than the last require() | ||
// above. | ||
return require(moduleName); | ||
@@ -40,9 +52,8 @@ }, | ||
}, | ||
loadRule: function(coffeelint, moduleName, ruleName) { | ||
// moduleName is a NodeJS module, or a path to a module NodeJS can load. | ||
loadRule: function(coffeelint, moduleName, ruleName = void 0) { | ||
var e, i, len, results, rule, ruleModule; | ||
if (ruleName == null) { | ||
ruleName = void 0; | ||
} | ||
try { | ||
ruleModule = this.require(moduleName); | ||
// Most rules can export as a single constructor function | ||
if (typeof ruleModule === 'function') { | ||
@@ -52,2 +63,3 @@ return coffeelint.registerRule(ruleModule, ruleName); | ||
results = []; | ||
// Or it can export an array of rules to load. | ||
for (i = 0, len = ruleModule.length; i < len; i++) { | ||
@@ -61,3 +73,4 @@ rule = ruleModule[i]; | ||
e = error; | ||
console.error("Error loading " + moduleName); | ||
// coffeelint: disable=no_debugger | ||
console.error(`Error loading ${moduleName}`); | ||
throw e; | ||
@@ -68,2 +81,4 @@ } | ||
// coffeelint: enable=no_debugger | ||
}).call(this); |
{ | ||
"name": "coffeelint", | ||
"description": "Lint your CoffeeScript", | ||
"version": "1.16.0", | ||
"version": "2.0.0", | ||
"homepage": "http://www.coffeelint.org", | ||
@@ -15,3 +15,3 @@ "keywords": [ | ||
"npm": ">=1.3.7", | ||
"node": ">=0.8.0" | ||
"node": ">=6.9.1" | ||
}, | ||
@@ -26,3 +26,3 @@ "repository": { | ||
"dependencies": { | ||
"coffee-script": "~1.11.0", | ||
"coffeescript": "2.0.0", | ||
"glob": "^7.0.6", | ||
@@ -29,0 +29,0 @@ "ignore": "^3.0.9", |
@@ -21,3 +21,3 @@ CoffeeLint | ||
- [Asa Ayers](https://github.com/AsaAyers) | ||
- [Asa Ayers](https://github.com/AsaAyers) - [You Don't Need CoffeeScript](https://gist.github.com/AsaAyers/d09e4de118b8d6b5e2d8fa3e38e496e0) | ||
- [Matt Perpick](https://github.com/clutchski) | ||
@@ -24,0 +24,0 @@ |
#!/usr/bin/env node | ||
require('coffee-script/register') | ||
require('coffeescript/register') | ||
require('./node_modules/vows/bin/vows') | ||
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
156981
26
3689
+ Addedcoffeescript@2.0.0
+ Addedansi-regex@2.1.1(transitive)
+ Addedansi-styles@2.2.1(transitive)
+ Addedbabel-code-frame@6.26.0(transitive)
+ Addedbabel-core@6.26.3(transitive)
+ Addedbabel-generator@6.26.1(transitive)
+ Addedbabel-helpers@6.24.1(transitive)
+ Addedbabel-messages@6.23.0(transitive)
+ Addedbabel-register@6.26.0(transitive)
+ Addedbabel-runtime@6.26.0(transitive)
+ Addedbabel-template@6.26.0(transitive)
+ Addedbabel-traverse@6.26.0(transitive)
+ Addedbabel-types@6.26.0(transitive)
+ Addedbabylon@6.18.0(transitive)
+ Addedchalk@1.1.3(transitive)
+ Addedcoffeescript@2.0.0(transitive)
+ Addedconvert-source-map@1.9.0(transitive)
+ Addedcore-js@2.6.12(transitive)
+ Addeddebug@2.6.9(transitive)
+ Addeddetect-indent@4.0.0(transitive)
+ Addedescape-string-regexp@1.0.5(transitive)
+ Addedesutils@2.0.3(transitive)
+ Addedglobals@9.18.0(transitive)
+ Addedhas-ansi@2.0.0(transitive)
+ Addedhome-or-tmp@2.0.0(transitive)
+ Addedinvariant@2.2.4(transitive)
+ Addedis-finite@1.1.0(transitive)
+ Addedjs-tokens@3.0.2(transitive)
+ Addedjsesc@1.3.0(transitive)
+ Addedjson5@0.5.1(transitive)
+ Addedlodash@4.17.21(transitive)
+ Addedloose-envify@1.4.0(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedmkdirp@0.5.6(transitive)
+ Addedms@2.0.0(transitive)
+ Addedos-homedir@1.0.2(transitive)
+ Addedos-tmpdir@1.0.2(transitive)
+ Addedprivate@0.1.8(transitive)
+ Addedregenerator-runtime@0.11.1(transitive)
+ Addedrepeating@2.0.1(transitive)
+ Addedslash@1.0.0(transitive)
+ Addedsource-map@0.5.7(transitive)
+ Addedsource-map-support@0.4.18(transitive)
+ Addedstrip-ansi@3.0.1(transitive)
+ Addedsupports-color@2.0.0(transitive)
+ Addedto-fast-properties@1.0.3(transitive)
+ Addedtrim-right@1.0.1(transitive)
- Removedcoffee-script@~1.11.0
- Removedcoffee-script@1.11.1(transitive)