coffeelint/lib/coffeelint.js in coffeelint-0.2.6 vs coffeelint/lib/coffeelint.js in coffeelint-0.2.7
- old
+ new
@@ -1,10 +1,10 @@
!function(e){if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.coffeelint=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
module.exports={
"name": "coffeelint",
"description": "Lint your CoffeeScript",
- "version": "1.2.0",
+ "version": "1.3.0",
"homepage": "http://www.coffeelint.org",
"keywords": [
"lint",
"coffeescript",
"coffee-script"
@@ -458,10 +458,12 @@
coffeelint.registerRule(_dereq_('./rules/no_debugger.coffee'));
coffeelint.registerRule(_dereq_('./rules/no_interpolation_in_single_quotes.coffee'));
+coffeelint.registerRule(_dereq_('./rules/no_empty_functions.coffee'));
+
hasSyntaxError = function(source) {
try {
CoffeeScript.tokens(source);
return false;
} catch (_error) {}
@@ -554,11 +556,11 @@
}
return errors;
};
-},{"./../package.json":1,"./ast_linter.coffee":2,"./lexical_linter.coffee":5,"./line_linter.coffee":6,"./rules.coffee":7,"./rules/arrow_spacing.coffee":8,"./rules/camel_case_classes.coffee":9,"./rules/colon_assignment_spacing.coffee":10,"./rules/cyclomatic_complexity.coffee":11,"./rules/duplicate_key.coffee":12,"./rules/empty_constructor_needs_parens.coffee":13,"./rules/indentation.coffee":14,"./rules/line_endings.coffee":15,"./rules/max_line_length.coffee":16,"./rules/missing_fat_arrows.coffee":17,"./rules/newlines_after_classes.coffee":18,"./rules/no_backticks.coffee":19,"./rules/no_debugger.coffee":20,"./rules/no_empty_param_list.coffee":21,"./rules/no_implicit_braces.coffee":22,"./rules/no_implicit_parens.coffee":23,"./rules/no_interpolation_in_single_quotes.coffee":24,"./rules/no_plusplus.coffee":25,"./rules/no_stand_alone_at.coffee":26,"./rules/no_tabs.coffee":27,"./rules/no_throwing_strings.coffee":28,"./rules/no_trailing_semicolons.coffee":29,"./rules/no_trailing_whitespace.coffee":30,"./rules/no_unnecessary_double_quotes.coffee":31,"./rules/no_unnecessary_fat_arrows.coffee":32,"./rules/non_empty_constructor_needs_parens.coffee":33,"./rules/space_operators.coffee":34}],5:[function(_dereq_,module,exports){
+},{"./../package.json":1,"./ast_linter.coffee":2,"./lexical_linter.coffee":5,"./line_linter.coffee":6,"./rules.coffee":7,"./rules/arrow_spacing.coffee":8,"./rules/camel_case_classes.coffee":9,"./rules/colon_assignment_spacing.coffee":10,"./rules/cyclomatic_complexity.coffee":11,"./rules/duplicate_key.coffee":12,"./rules/empty_constructor_needs_parens.coffee":13,"./rules/indentation.coffee":14,"./rules/line_endings.coffee":15,"./rules/max_line_length.coffee":16,"./rules/missing_fat_arrows.coffee":17,"./rules/newlines_after_classes.coffee":18,"./rules/no_backticks.coffee":19,"./rules/no_debugger.coffee":20,"./rules/no_empty_functions.coffee":21,"./rules/no_empty_param_list.coffee":22,"./rules/no_implicit_braces.coffee":23,"./rules/no_implicit_parens.coffee":24,"./rules/no_interpolation_in_single_quotes.coffee":25,"./rules/no_plusplus.coffee":26,"./rules/no_stand_alone_at.coffee":27,"./rules/no_tabs.coffee":28,"./rules/no_throwing_strings.coffee":29,"./rules/no_trailing_semicolons.coffee":30,"./rules/no_trailing_whitespace.coffee":31,"./rules/no_unnecessary_double_quotes.coffee":32,"./rules/no_unnecessary_fat_arrows.coffee":33,"./rules/non_empty_constructor_needs_parens.coffee":34,"./rules/space_operators.coffee":35}],5:[function(_dereq_,module,exports){
var BaseLinter, LexicalLinter, TokenApi,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
@@ -1351,11 +1353,11 @@
MaxLineLength.prototype.lintLine = function(line, lineApi) {
var limitComments, lineLength, max, _ref, _ref1;
max = (_ref = lineApi.config[this.rule.name]) != null ? _ref.value : void 0;
limitComments = (_ref1 = lineApi.config[this.rule.name]) != null ? _ref1.limitComments : void 0;
- lineLength = line.length;
+ lineLength = line.trimRight().length;
if (lineApi.isLiterate() && regexes.literateComment.test(line)) {
lineLength -= 2;
}
if (max && max < lineLength && !regexes.longUrlComment.test(line)) {
if (!limitComments) {
@@ -1569,10 +1571,54 @@
})();
},{}],21:[function(_dereq_,module,exports){
+var NoEmptyFunctions, isEmptyCode;
+
+isEmptyCode = function(node, astApi) {
+ var nodeName;
+ nodeName = astApi.getNodeName(node);
+ return nodeName === 'Code' && node.body.isEmpty();
+};
+
+module.exports = NoEmptyFunctions = (function() {
+ function NoEmptyFunctions() {}
+
+ NoEmptyFunctions.prototype.rule = {
+ name: 'no_empty_functions',
+ level: 'ignore',
+ message: 'Empty function',
+ description: "Disallows declaring empty functions. The goal of this rule is that\nunintentional empty callbacks can be detected:\n<pre>\n<code>someFunctionWithCallback ->\ndoSomethingSignificant()\n</code>\n</pre>\nThe problem is that the call to\n<tt>doSomethingSignificant</tt> will be made regardless\nof <tt>someFunctionWithCallback</tt>'s execution. It can\nbe because you did not indent the call to\n<tt>doSomethingSignificant</tt> properly.\n\nIf you really meant that <tt>someFunctionWithCallback</tt>\nshould call a callback that does nothing, you can write your code\nthis way:\n<pre>\n<code>someFunctionWithCallback ->\n undefined\ndoSomethingSignificant()\n</code>\n</pre>"
+ };
+
+ NoEmptyFunctions.prototype.lintAST = function(node, astApi) {
+ this.lintNode(node, astApi);
+ return void 0;
+ };
+
+ NoEmptyFunctions.prototype.lintNode = function(node, astApi) {
+ var error;
+ if (isEmptyCode(node, astApi)) {
+ error = astApi.createError({
+ lineNumber: node.locationData.first_line + 1
+ });
+ this.errors.push(error);
+ }
+ return node.eachChild((function(_this) {
+ return function(child) {
+ return _this.lintNode(child, astApi);
+ };
+ })(this));
+ };
+
+ return NoEmptyFunctions;
+
+})();
+
+
+},{}],22:[function(_dereq_,module,exports){
var NoEmptyParamList;
module.exports = NoEmptyParamList = (function() {
function NoEmptyParamList() {}
@@ -1594,11 +1640,11 @@
return NoEmptyParamList;
})();
-},{}],22:[function(_dereq_,module,exports){
+},{}],23:[function(_dereq_,module,exports){
var NoImplicitBraces;
module.exports = NoImplicitBraces = (function() {
function NoImplicitBraces() {}
@@ -1643,11 +1689,11 @@
return NoImplicitBraces;
})();
-},{}],23:[function(_dereq_,module,exports){
+},{}],24:[function(_dereq_,module,exports){
var NoImplicitParens;
module.exports = NoImplicitParens = (function() {
function NoImplicitParens() {}
@@ -1685,11 +1731,11 @@
return NoImplicitParens;
})();
-},{}],24:[function(_dereq_,module,exports){
+},{}],25:[function(_dereq_,module,exports){
var NoInterpolationInSingleQuotes;
module.exports = NoInterpolationInSingleQuotes = (function() {
function NoInterpolationInSingleQuotes() {}
@@ -1712,11 +1758,11 @@
return NoInterpolationInSingleQuotes;
})();
-},{}],25:[function(_dereq_,module,exports){
+},{}],26:[function(_dereq_,module,exports){
var NoPlusPlus;
module.exports = NoPlusPlus = (function() {
function NoPlusPlus() {}
@@ -1738,11 +1784,11 @@
return NoPlusPlus;
})();
-},{}],26:[function(_dereq_,module,exports){
+},{}],27:[function(_dereq_,module,exports){
var NoStandAloneAt;
module.exports = NoStandAloneAt = (function() {
function NoStandAloneAt() {}
@@ -1774,11 +1820,11 @@
return NoStandAloneAt;
})();
-},{}],27:[function(_dereq_,module,exports){
+},{}],28:[function(_dereq_,module,exports){
var NoTabs, indentationRegex,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
indentationRegex = /\S/;
@@ -1805,11 +1851,11 @@
return NoTabs;
})();
-},{}],28:[function(_dereq_,module,exports){
+},{}],29:[function(_dereq_,module,exports){
var NoThrowingStrings;
module.exports = NoThrowingStrings = (function() {
function NoThrowingStrings() {}
@@ -1832,11 +1878,11 @@
return NoThrowingStrings;
})();
-},{}],29:[function(_dereq_,module,exports){
+},{}],30:[function(_dereq_,module,exports){
var NoTrailingSemicolons, regexes,
__slice = [].slice;
regexes = {
trailingSemicolon: /;\r?$/
@@ -1881,11 +1927,11 @@
return NoTrailingSemicolons;
})();
-},{}],30:[function(_dereq_,module,exports){
+},{}],31:[function(_dereq_,module,exports){
var NoTrailingWhitespace, regexes;
regexes = {
trailingWhitespace: /[^\s]+[\t ]+\r?$/,
onlySpaces: /^[\t ]+\r?$/,
@@ -1944,11 +1990,11 @@
return NoTrailingWhitespace;
})();
-},{}],31:[function(_dereq_,module,exports){
+},{}],32:[function(_dereq_,module,exports){
var NoUnnecessaryDoubleQuotes;
module.exports = NoUnnecessaryDoubleQuotes = (function() {
function NoUnnecessaryDoubleQuotes() {}
@@ -1997,11 +2043,11 @@
return NoUnnecessaryDoubleQuotes;
})();
-},{}],32:[function(_dereq_,module,exports){
+},{}],33:[function(_dereq_,module,exports){
var NoUnnecessaryFatArrows, any,
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
any = function(arr, test) {
return arr.reduce((function(res, elt) {
@@ -2074,11 +2120,11 @@
return NoUnnecessaryFatArrows;
})();
-},{}],33:[function(_dereq_,module,exports){
+},{}],34:[function(_dereq_,module,exports){
var NonEmptyConstructorNeedsParens, ParentClass,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
ParentClass = _dereq_('./empty_constructor_needs_parens.coffee');
@@ -2106,10 +2152,10 @@
return NonEmptyConstructorNeedsParens;
})(ParentClass);
-},{"./empty_constructor_needs_parens.coffee":13}],34:[function(_dereq_,module,exports){
+},{"./empty_constructor_needs_parens.coffee":13}],35:[function(_dereq_,module,exports){
var SpaceOperators,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
module.exports = SpaceOperators = (function() {
SpaceOperators.prototype.rule = {
\ No newline at end of file