coffeelint 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -0
- data/README.md +4 -2
- data/Rakefile +26 -0
- data/coffeelint/lib/coffeelint.js +164 -136
- data/lib/coffeelint/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12ea363be234261603c842b9b5d69c2d2faa90d2
|
4
|
+
data.tar.gz: c3ac4cb8d5d2919797bdb4271f35846cecacf74d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d63545a40702411336cb530fc03481df13289e6143fdfb10d52934941da81338ac69486d01dcf43543f35cf05f1f176fb3bd86db42fe8643034d92bb0491f54d
|
7
|
+
data.tar.gz: 56ea3c973f062576f2e416313fcea845f90a726d33b5f35f18122f52096df6701ae8352ffb7fedcb5745e9b83e8cfbb3e21a768ac00bb518915f222be7af6d5c
|
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
-
# Coffeelint [![Gem Version](https://badge.fury.io/rb/coffeelint.png)](http://badge.fury.io/rb/coffeelint)
|
1
|
+
# Coffeelint [![Build Status](https://travis-ci.org/zipcodeman/coffeelint-ruby.png?branch=master)](https://travis-ci.org/zipcodeman/coffeelint-ruby) [![Gem Version](https://badge.fury.io/rb/coffeelint.png)](http://badge.fury.io/rb/coffeelint)
|
2
|
+
|
3
|
+
Using coffeelint version: v1.1.0
|
2
4
|
|
3
5
|
Coffeelint is a set of simple ruby bindings for [coffeelint](https://github.com/clutchski/coffeelint).
|
4
6
|
|
5
|
-
##
|
7
|
+
## Install the [Gem](https://rubygems.org/gems/coffeelint)
|
6
8
|
|
7
9
|
Add this line to your application's Gemfile:
|
8
10
|
|
data/Rakefile
CHANGED
@@ -8,6 +8,16 @@ task :console do
|
|
8
8
|
sh "irb -rubygems -I lib -r coffeelint.rb"
|
9
9
|
end
|
10
10
|
|
11
|
+
task :prepare_coffeelint do
|
12
|
+
sh "git submodule init"
|
13
|
+
sh "git submodule update"
|
14
|
+
|
15
|
+
Dir.chdir('coffeelint') do
|
16
|
+
sh "npm install"
|
17
|
+
sh "npm run compile"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
11
21
|
task :compile => [:prepare, :build]
|
12
22
|
|
13
23
|
task :prepare do
|
@@ -21,3 +31,19 @@ task :prepare do
|
|
21
31
|
|
22
32
|
sh "rake spec"
|
23
33
|
end
|
34
|
+
|
35
|
+
def coffeelint_version
|
36
|
+
Dir.chdir('coffeelint') do
|
37
|
+
retval = `git describe`
|
38
|
+
retval.strip! || retval
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
task :update_readme do
|
43
|
+
readme_name = 'README.md'
|
44
|
+
readme = File.read(readme_name)
|
45
|
+
readme = readme.gsub(/(coffeelint version: )v[0-9.]+/, "\\1#{coffeelint_version}")
|
46
|
+
File.open(readme_name, 'w') do |f|
|
47
|
+
f.write(readme)
|
48
|
+
end
|
49
|
+
end
|
@@ -1,9 +1,8 @@
|
|
1
|
-
|
2
|
-
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(require,module,exports){
|
1
|
+
!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){
|
3
2
|
module.exports={
|
4
3
|
"name": "coffeelint",
|
5
4
|
"description": "Lint your CoffeeScript",
|
6
|
-
"version": "1.0
|
5
|
+
"version": "1.1.0",
|
7
6
|
"homepage": "http://www.coffeelint.org",
|
8
7
|
"keywords": [
|
9
8
|
"lint",
|
@@ -24,10 +23,10 @@ module.exports={
|
|
24
23
|
},
|
25
24
|
"dependencies": {
|
26
25
|
"optimist": ">=0.2.8",
|
27
|
-
"coffee-script": "
|
26
|
+
"coffee-script": "~1.7",
|
28
27
|
"glob": ">=3.1.9",
|
29
|
-
"browserify": "~
|
30
|
-
"coffeeify": "~0.
|
28
|
+
"browserify": "~3.x",
|
29
|
+
"coffeeify": "~0.6.0"
|
31
30
|
},
|
32
31
|
"devDependencies": {
|
33
32
|
"vows": ">=0.6.0",
|
@@ -40,24 +39,25 @@ module.exports={
|
|
40
39
|
}
|
41
40
|
],
|
42
41
|
"scripts": {
|
43
|
-
"pretest": "
|
44
|
-
"test": "
|
42
|
+
"pretest": "cake compile",
|
43
|
+
"test": "coffee vowsrunner.coffee --spec test/*.coffee test/*.litcoffee",
|
45
44
|
"posttest": "npm run lint",
|
46
|
-
"prepublish": "
|
47
|
-
"
|
48
|
-
"
|
49
|
-
"lint
|
50
|
-
"lint-
|
51
|
-
"
|
45
|
+
"prepublish": "cake prepublish",
|
46
|
+
"publish": "cake publish",
|
47
|
+
"install": "cake install",
|
48
|
+
"lint": "cake compile && ./bin/coffeelint -f coffeelint.json src/*.coffee test/*.coffee test/*.litcoffee",
|
49
|
+
"lint-csv": "cake compile && ./bin/coffeelint --csv -f coffeelint.json src/*.coffee test/*.coffee",
|
50
|
+
"lint-jslint": "cake compile && ./bin/coffeelint --jslint -f coffeelint.json src/*.coffee test/*.coffee",
|
51
|
+
"compile": "cake compile"
|
52
52
|
}
|
53
53
|
}
|
54
54
|
|
55
|
-
},{}],2:[function(
|
55
|
+
},{}],2:[function(_dereq_,module,exports){
|
56
56
|
var ASTApi, ASTLinter, BaseLinter,
|
57
57
|
__hasProp = {}.hasOwnProperty,
|
58
58
|
__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; };
|
59
59
|
|
60
|
-
BaseLinter =
|
60
|
+
BaseLinter = _dereq_('./base_linter.coffee');
|
61
61
|
|
62
62
|
ASTApi = (function() {
|
63
63
|
function ASTApi(config) {
|
@@ -82,8 +82,7 @@ module.exports = ASTLinter = (function(_super) {
|
|
82
82
|
};
|
83
83
|
|
84
84
|
ASTLinter.prototype.lint = function() {
|
85
|
-
var coffeeError, err, errors, rule, v, _i, _len, _ref
|
86
|
-
_this = this;
|
85
|
+
var coffeeError, err, errors, rule, v, _i, _len, _ref;
|
87
86
|
errors = [];
|
88
87
|
try {
|
89
88
|
this.node = this.CoffeeScript.nodes(this.source);
|
@@ -98,12 +97,14 @@ module.exports = ASTLinter = (function(_super) {
|
|
98
97
|
_ref = this.rules;
|
99
98
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
100
99
|
rule = _ref[_i];
|
101
|
-
this.astApi.createError = function(
|
102
|
-
|
103
|
-
attrs
|
104
|
-
|
105
|
-
|
106
|
-
|
100
|
+
this.astApi.createError = (function(_this) {
|
101
|
+
return function(attrs) {
|
102
|
+
if (attrs == null) {
|
103
|
+
attrs = {};
|
104
|
+
}
|
105
|
+
return _this.createError(rule.rule.name, attrs);
|
106
|
+
};
|
107
|
+
})(this);
|
107
108
|
rule.errors = errors;
|
108
109
|
v = this.normalizeResult(rule, rule.lintAST(this.node, this.astApi));
|
109
110
|
if (v != null) {
|
@@ -139,7 +140,7 @@ module.exports = ASTLinter = (function(_super) {
|
|
139
140
|
})(BaseLinter);
|
140
141
|
|
141
142
|
|
142
|
-
},{"./base_linter.coffee":3}],3:[function(
|
143
|
+
},{"./base_linter.coffee":3}],3:[function(_dereq_,module,exports){
|
143
144
|
var BaseLinter, defaults, extend,
|
144
145
|
__slice = [].slice;
|
145
146
|
|
@@ -232,14 +233,14 @@ module.exports = BaseLinter = (function() {
|
|
232
233
|
})();
|
233
234
|
|
234
235
|
|
235
|
-
},{}],4:[function(
|
236
|
+
},{}],4:[function(_dereq_,module,exports){
|
237
|
+
|
236
238
|
/*
|
237
239
|
CoffeeLint
|
238
240
|
|
239
241
|
Copyright (c) 2011 Matthew Perpick.
|
240
242
|
CoffeeLint is freely distributable under the MIT license.
|
241
|
-
*/
|
242
|
-
|
243
|
+
*/
|
243
244
|
var ASTLinter, CoffeeScript, ERROR, IGNORE, LexicalLinter, LineLinter, RULES, WARN, coffeelint, cs, defaults, difference, extend, hasSyntaxError, mergeDefaultConfig, packageJSON, _rules,
|
244
245
|
__slice = [].slice,
|
245
246
|
__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; };
|
@@ -250,10 +251,10 @@ if (typeof window !== "undefined" && window !== null) {
|
|
250
251
|
CoffeeScript = window.CoffeeScript;
|
251
252
|
} else {
|
252
253
|
cs = 'coffee-script';
|
253
|
-
CoffeeScript =
|
254
|
+
CoffeeScript = _dereq_(cs);
|
254
255
|
}
|
255
256
|
|
256
|
-
packageJSON =
|
257
|
+
packageJSON = _dereq_('./../package.json');
|
257
258
|
|
258
259
|
coffeelint.VERSION = packageJSON.version;
|
259
260
|
|
@@ -263,7 +264,7 @@ WARN = 'warn';
|
|
263
264
|
|
264
265
|
IGNORE = 'ignore';
|
265
266
|
|
266
|
-
coffeelint.RULES = RULES =
|
267
|
+
coffeelint.RULES = RULES = _dereq_('./rules.coffee');
|
267
268
|
|
268
269
|
extend = function() {
|
269
270
|
var destination, k, source, sources, v, _i, _len;
|
@@ -296,11 +297,11 @@ difference = function(a, b) {
|
|
296
297
|
return _results;
|
297
298
|
};
|
298
299
|
|
299
|
-
LineLinter =
|
300
|
+
LineLinter = _dereq_('./line_linter.coffee');
|
300
301
|
|
301
|
-
LexicalLinter =
|
302
|
+
LexicalLinter = _dereq_('./lexical_linter.coffee');
|
302
303
|
|
303
|
-
ASTLinter =
|
304
|
+
ASTLinter = _dereq_('./ast_linter.coffee');
|
304
305
|
|
305
306
|
mergeDefaultConfig = function(userConfig) {
|
306
307
|
var config, rule, ruleConfig;
|
@@ -369,53 +370,53 @@ coffeelint.registerRule = function(RuleConstructor, ruleName) {
|
|
369
370
|
return _rules[p.rule.name] = RuleConstructor;
|
370
371
|
};
|
371
372
|
|
372
|
-
coffeelint.registerRule(
|
373
|
+
coffeelint.registerRule(_dereq_('./rules/arrow_spacing.coffee'));
|
373
374
|
|
374
|
-
coffeelint.registerRule(
|
375
|
+
coffeelint.registerRule(_dereq_('./rules/no_tabs.coffee'));
|
375
376
|
|
376
|
-
coffeelint.registerRule(
|
377
|
+
coffeelint.registerRule(_dereq_('./rules/no_trailing_whitespace.coffee'));
|
377
378
|
|
378
|
-
coffeelint.registerRule(
|
379
|
+
coffeelint.registerRule(_dereq_('./rules/max_line_length.coffee'));
|
379
380
|
|
380
|
-
coffeelint.registerRule(
|
381
|
+
coffeelint.registerRule(_dereq_('./rules/line_endings.coffee'));
|
381
382
|
|
382
|
-
coffeelint.registerRule(
|
383
|
+
coffeelint.registerRule(_dereq_('./rules/no_trailing_semicolons.coffee'));
|
383
384
|
|
384
|
-
coffeelint.registerRule(
|
385
|
+
coffeelint.registerRule(_dereq_('./rules/indentation.coffee'));
|
385
386
|
|
386
|
-
coffeelint.registerRule(
|
387
|
+
coffeelint.registerRule(_dereq_('./rules/camel_case_classes.coffee'));
|
387
388
|
|
388
|
-
coffeelint.registerRule(
|
389
|
+
coffeelint.registerRule(_dereq_('./rules/colon_assignment_spacing.coffee'));
|
389
390
|
|
390
|
-
coffeelint.registerRule(
|
391
|
+
coffeelint.registerRule(_dereq_('./rules/no_implicit_braces.coffee'));
|
391
392
|
|
392
|
-
coffeelint.registerRule(
|
393
|
+
coffeelint.registerRule(_dereq_('./rules/no_plusplus.coffee'));
|
393
394
|
|
394
|
-
coffeelint.registerRule(
|
395
|
+
coffeelint.registerRule(_dereq_('./rules/no_throwing_strings.coffee'));
|
395
396
|
|
396
|
-
coffeelint.registerRule(
|
397
|
+
coffeelint.registerRule(_dereq_('./rules/no_backticks.coffee'));
|
397
398
|
|
398
|
-
coffeelint.registerRule(
|
399
|
+
coffeelint.registerRule(_dereq_('./rules/no_implicit_parens.coffee'));
|
399
400
|
|
400
|
-
coffeelint.registerRule(
|
401
|
+
coffeelint.registerRule(_dereq_('./rules/no_empty_param_list.coffee'));
|
401
402
|
|
402
|
-
coffeelint.registerRule(
|
403
|
+
coffeelint.registerRule(_dereq_('./rules/no_stand_alone_at.coffee'));
|
403
404
|
|
404
|
-
coffeelint.registerRule(
|
405
|
+
coffeelint.registerRule(_dereq_('./rules/space_operators.coffee'));
|
405
406
|
|
406
|
-
coffeelint.registerRule(
|
407
|
+
coffeelint.registerRule(_dereq_('./rules/duplicate_key.coffee'));
|
407
408
|
|
408
|
-
coffeelint.registerRule(
|
409
|
+
coffeelint.registerRule(_dereq_('./rules/empty_constructor_needs_parens.coffee'));
|
409
410
|
|
410
|
-
coffeelint.registerRule(
|
411
|
+
coffeelint.registerRule(_dereq_('./rules/cyclomatic_complexity.coffee'));
|
411
412
|
|
412
|
-
coffeelint.registerRule(
|
413
|
+
coffeelint.registerRule(_dereq_('./rules/newlines_after_classes.coffee'));
|
413
414
|
|
414
|
-
coffeelint.registerRule(
|
415
|
+
coffeelint.registerRule(_dereq_('./rules/no_unnecessary_fat_arrows.coffee'));
|
415
416
|
|
416
|
-
coffeelint.registerRule(
|
417
|
+
coffeelint.registerRule(_dereq_('./rules/missing_fat_arrows.coffee'));
|
417
418
|
|
418
|
-
coffeelint.registerRule(
|
419
|
+
coffeelint.registerRule(_dereq_('./rules/non_empty_constructor_needs_parens.coffee'));
|
419
420
|
|
420
421
|
hasSyntaxError = function(source) {
|
421
422
|
try {
|
@@ -464,7 +465,7 @@ coffeelint.lint = function(source, userConfig, literate) {
|
|
464
465
|
lexErrors = lexicalLinter.lint();
|
465
466
|
errors = errors.concat(lexErrors);
|
466
467
|
tokensByLine = lexicalLinter.tokensByLine;
|
467
|
-
lineLinter = new LineLinter(source, config, _rules, tokensByLine);
|
468
|
+
lineLinter = new LineLinter(source, config, _rules, tokensByLine, literate);
|
468
469
|
lineErrors = lineLinter.lint();
|
469
470
|
errors = errors.concat(lineErrors);
|
470
471
|
block_config = lineLinter.block_config;
|
@@ -513,7 +514,7 @@ coffeelint.lint = function(source, userConfig, literate) {
|
|
513
514
|
};
|
514
515
|
|
515
516
|
|
516
|
-
},{"./../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_empty_param_list.coffee":20,"./rules/no_implicit_braces.coffee":21,"./rules/no_implicit_parens.coffee":22,"./rules/no_plusplus.coffee":23,"./rules/no_stand_alone_at.coffee":24,"./rules/no_tabs.coffee":25,"./rules/no_throwing_strings.coffee":26,"./rules/no_trailing_semicolons.coffee":27,"./rules/no_trailing_whitespace.coffee":28,"./rules/no_unnecessary_fat_arrows.coffee":29,"./rules/non_empty_constructor_needs_parens.coffee":30,"./rules/space_operators.coffee":31}],5:[function(
|
517
|
+
},{"./../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_empty_param_list.coffee":20,"./rules/no_implicit_braces.coffee":21,"./rules/no_implicit_parens.coffee":22,"./rules/no_plusplus.coffee":23,"./rules/no_stand_alone_at.coffee":24,"./rules/no_tabs.coffee":25,"./rules/no_throwing_strings.coffee":26,"./rules/no_trailing_semicolons.coffee":27,"./rules/no_trailing_whitespace.coffee":28,"./rules/no_unnecessary_fat_arrows.coffee":29,"./rules/non_empty_constructor_needs_parens.coffee":30,"./rules/space_operators.coffee":31}],5:[function(_dereq_,module,exports){
|
517
518
|
var BaseLinter, LexicalLinter, TokenApi,
|
518
519
|
__hasProp = {}.hasOwnProperty,
|
519
520
|
__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; },
|
@@ -541,7 +542,7 @@ TokenApi = (function() {
|
|
541
542
|
|
542
543
|
})();
|
543
544
|
|
544
|
-
BaseLinter =
|
545
|
+
BaseLinter = _dereq_('./base_linter.coffee');
|
545
546
|
|
546
547
|
module.exports = LexicalLinter = (function(_super) {
|
547
548
|
__extends(LexicalLinter, _super);
|
@@ -617,15 +618,16 @@ module.exports = LexicalLinter = (function(_super) {
|
|
617
618
|
})(BaseLinter);
|
618
619
|
|
619
620
|
|
620
|
-
},{"./base_linter.coffee":3}],6:[function(
|
621
|
+
},{"./base_linter.coffee":3}],6:[function(_dereq_,module,exports){
|
621
622
|
var BaseLinter, LineApi, LineLinter, configStatement,
|
622
623
|
__hasProp = {}.hasOwnProperty,
|
623
624
|
__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; };
|
624
625
|
|
625
626
|
LineApi = (function() {
|
626
|
-
function LineApi(source, config, tokensByLine) {
|
627
|
+
function LineApi(source, config, tokensByLine, literate) {
|
627
628
|
this.config = config;
|
628
629
|
this.tokensByLine = tokensByLine;
|
630
|
+
this.literate = literate;
|
629
631
|
this.line = null;
|
630
632
|
this.lines = source.split('\n');
|
631
633
|
this.lineCount = this.lines.length;
|
@@ -640,6 +642,10 @@ LineApi = (function() {
|
|
640
642
|
|
641
643
|
LineApi.prototype.lineNumber = 0;
|
642
644
|
|
645
|
+
LineApi.prototype.isLiterate = function() {
|
646
|
+
return this.literate;
|
647
|
+
};
|
648
|
+
|
643
649
|
LineApi.prototype.maintainClassContext = function(line) {
|
644
650
|
if (this.context["class"].inClass) {
|
645
651
|
if (this.lineHasToken('INDENT')) {
|
@@ -705,7 +711,7 @@ LineApi = (function() {
|
|
705
711
|
|
706
712
|
})();
|
707
713
|
|
708
|
-
BaseLinter =
|
714
|
+
BaseLinter = _dereq_('./base_linter.coffee');
|
709
715
|
|
710
716
|
configStatement = /coffeelint:\s*(disable|enable)(?:=([\w\s,]*))?/;
|
711
717
|
|
@@ -714,9 +720,12 @@ module.exports = LineLinter = (function(_super) {
|
|
714
720
|
|
715
721
|
LineLinter.configStatement = configStatement;
|
716
722
|
|
717
|
-
function LineLinter(source, config, rules, tokensByLine) {
|
723
|
+
function LineLinter(source, config, rules, tokensByLine, literate) {
|
724
|
+
if (literate == null) {
|
725
|
+
literate = false;
|
726
|
+
}
|
718
727
|
LineLinter.__super__.constructor.call(this, source, config, rules);
|
719
|
-
this.lineApi = new LineApi(source, config, tokensByLine);
|
728
|
+
this.lineApi = new LineApi(source, config, tokensByLine, literate);
|
720
729
|
this.block_config = {
|
721
730
|
enable: {},
|
722
731
|
disable: {}
|
@@ -792,7 +801,7 @@ module.exports = LineLinter = (function(_super) {
|
|
792
801
|
})(BaseLinter);
|
793
802
|
|
794
803
|
|
795
|
-
},{"./base_linter.coffee":3}],7:[function(
|
804
|
+
},{"./base_linter.coffee":3}],7:[function(_dereq_,module,exports){
|
796
805
|
var ERROR, IGNORE, WARN;
|
797
806
|
|
798
807
|
ERROR = 'error';
|
@@ -809,7 +818,7 @@ module.exports = {
|
|
809
818
|
};
|
810
819
|
|
811
820
|
|
812
|
-
},{}],8:[function(
|
821
|
+
},{}],8:[function(_dereq_,module,exports){
|
813
822
|
var ArrowSpacing;
|
814
823
|
|
815
824
|
module.exports = ArrowSpacing = (function() {
|
@@ -852,7 +861,7 @@ module.exports = ArrowSpacing = (function() {
|
|
852
861
|
})();
|
853
862
|
|
854
863
|
|
855
|
-
},{}],9:[function(
|
864
|
+
},{}],9:[function(_dereq_,module,exports){
|
856
865
|
var CamelCaseClasses, regexes;
|
857
866
|
|
858
867
|
regexes = {
|
@@ -899,7 +908,7 @@ module.exports = CamelCaseClasses = (function() {
|
|
899
908
|
})();
|
900
909
|
|
901
910
|
|
902
|
-
},{}],10:[function(
|
911
|
+
},{}],10:[function(_dereq_,module,exports){
|
903
912
|
var ColonAssignmentSpacing;
|
904
913
|
|
905
914
|
module.exports = ColonAssignmentSpacing = (function() {
|
@@ -953,7 +962,7 @@ module.exports = ColonAssignmentSpacing = (function() {
|
|
953
962
|
})();
|
954
963
|
|
955
964
|
|
956
|
-
},{}],11:[function(
|
965
|
+
},{}],11:[function(_dereq_,module,exports){
|
957
966
|
var NoTabs;
|
958
967
|
|
959
968
|
module.exports = NoTabs = (function() {
|
@@ -981,17 +990,18 @@ module.exports = NoTabs = (function() {
|
|
981
990
|
};
|
982
991
|
|
983
992
|
NoTabs.prototype.lintNode = function(node, line) {
|
984
|
-
var complexity, error, name, rule
|
985
|
-
_this = this;
|
993
|
+
var complexity, error, name, rule;
|
986
994
|
name = node.constructor.name;
|
987
995
|
complexity = this.getComplexity(node);
|
988
|
-
node.eachChild(function(
|
989
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
996
|
+
node.eachChild((function(_this) {
|
997
|
+
return function(childNode) {
|
998
|
+
var nodeLine;
|
999
|
+
nodeLine = childNode.locationData.first_line;
|
1000
|
+
if (childNode) {
|
1001
|
+
return complexity += _this.lintNode(childNode, nodeLine);
|
1002
|
+
}
|
1003
|
+
};
|
1004
|
+
})(this));
|
995
1005
|
rule = this.astApi.config[this.rule.name];
|
996
1006
|
if (name === 'Code' && complexity >= rule.value) {
|
997
1007
|
error = this.astApi.createError({
|
@@ -1011,7 +1021,7 @@ module.exports = NoTabs = (function() {
|
|
1011
1021
|
})();
|
1012
1022
|
|
1013
1023
|
|
1014
|
-
},{}],12:[function(
|
1024
|
+
},{}],12:[function(_dereq_,module,exports){
|
1015
1025
|
var DuplicateKey;
|
1016
1026
|
|
1017
1027
|
module.exports = DuplicateKey = (function() {
|
@@ -1080,7 +1090,7 @@ module.exports = DuplicateKey = (function() {
|
|
1080
1090
|
})();
|
1081
1091
|
|
1082
1092
|
|
1083
|
-
},{}],13:[function(
|
1093
|
+
},{}],13:[function(_dereq_,module,exports){
|
1084
1094
|
var EmptyConstructorNeedsParens;
|
1085
1095
|
|
1086
1096
|
module.exports = EmptyConstructorNeedsParens = (function() {
|
@@ -1127,7 +1137,7 @@ module.exports = EmptyConstructorNeedsParens = (function() {
|
|
1127
1137
|
})();
|
1128
1138
|
|
1129
1139
|
|
1130
|
-
},{}],14:[function(
|
1140
|
+
},{}],14:[function(_dereq_,module,exports){
|
1131
1141
|
var Indentation;
|
1132
1142
|
|
1133
1143
|
module.exports = Indentation = (function() {
|
@@ -1233,7 +1243,7 @@ module.exports = Indentation = (function() {
|
|
1233
1243
|
})();
|
1234
1244
|
|
1235
1245
|
|
1236
|
-
},{}],15:[function(
|
1246
|
+
},{}],15:[function(_dereq_,module,exports){
|
1237
1247
|
var LineEndings;
|
1238
1248
|
|
1239
1249
|
module.exports = LineEndings = (function() {
|
@@ -1277,10 +1287,11 @@ module.exports = LineEndings = (function() {
|
|
1277
1287
|
})();
|
1278
1288
|
|
1279
1289
|
|
1280
|
-
},{}],16:[function(
|
1290
|
+
},{}],16:[function(_dereq_,module,exports){
|
1281
1291
|
var MaxLineLength, regexes;
|
1282
1292
|
|
1283
1293
|
regexes = {
|
1294
|
+
literateComment: /^\#\s/,
|
1284
1295
|
longUrlComment: /^\s*\#\s*http[^\s]+$/
|
1285
1296
|
};
|
1286
1297
|
|
@@ -1297,17 +1308,21 @@ module.exports = MaxLineLength = (function() {
|
|
1297
1308
|
};
|
1298
1309
|
|
1299
1310
|
MaxLineLength.prototype.lintLine = function(line, lineApi) {
|
1300
|
-
var limitComments, max, _ref, _ref1;
|
1311
|
+
var limitComments, lineLength, max, _ref, _ref1;
|
1301
1312
|
max = (_ref = lineApi.config[this.rule.name]) != null ? _ref.value : void 0;
|
1302
1313
|
limitComments = (_ref1 = lineApi.config[this.rule.name]) != null ? _ref1.limitComments : void 0;
|
1303
|
-
|
1314
|
+
lineLength = line.length;
|
1315
|
+
if (lineApi.isLiterate() && regexes.literateComment.test(line)) {
|
1316
|
+
lineLength -= 2;
|
1317
|
+
}
|
1318
|
+
if (max && max < lineLength && !regexes.longUrlComment.test(line)) {
|
1304
1319
|
if (!limitComments) {
|
1305
1320
|
if (lineApi.getLineTokens().length === 0) {
|
1306
1321
|
return;
|
1307
1322
|
}
|
1308
1323
|
}
|
1309
1324
|
return {
|
1310
|
-
context: "Length is " +
|
1325
|
+
context: "Length is " + lineLength + ", max is " + max
|
1311
1326
|
};
|
1312
1327
|
}
|
1313
1328
|
};
|
@@ -1317,7 +1332,7 @@ module.exports = MaxLineLength = (function() {
|
|
1317
1332
|
})();
|
1318
1333
|
|
1319
1334
|
|
1320
|
-
},{}],17:[function(
|
1335
|
+
},{}],17:[function(_dereq_,module,exports){
|
1321
1336
|
var MissingFatArrows, any, isClass, isCode, isFatArrowCode, isObject, isThis, isValue, methodsOfClass, needsFatArrow,
|
1322
1337
|
__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; };
|
1323
1338
|
|
@@ -1386,8 +1401,7 @@ module.exports = MissingFatArrows = (function() {
|
|
1386
1401
|
};
|
1387
1402
|
|
1388
1403
|
MissingFatArrows.prototype.lintNode = function(node, astApi, methods) {
|
1389
|
-
var error
|
1390
|
-
_this = this;
|
1404
|
+
var error;
|
1391
1405
|
if (methods == null) {
|
1392
1406
|
methods = [];
|
1393
1407
|
}
|
@@ -1397,18 +1411,20 @@ module.exports = MissingFatArrows = (function() {
|
|
1397
1411
|
});
|
1398
1412
|
this.errors.push(error);
|
1399
1413
|
}
|
1400
|
-
return node.eachChild(function(
|
1401
|
-
return
|
1402
|
-
|
1403
|
-
|
1404
|
-
|
1405
|
-
|
1406
|
-
|
1407
|
-
|
1408
|
-
|
1409
|
-
|
1410
|
-
|
1411
|
-
|
1414
|
+
return node.eachChild((function(_this) {
|
1415
|
+
return function(child) {
|
1416
|
+
return _this.lintNode(child, astApi, (function() {
|
1417
|
+
switch (false) {
|
1418
|
+
case !isClass(node):
|
1419
|
+
return methodsOfClass(node);
|
1420
|
+
case !isCode(node):
|
1421
|
+
return [];
|
1422
|
+
default:
|
1423
|
+
return methods;
|
1424
|
+
}
|
1425
|
+
})());
|
1426
|
+
};
|
1427
|
+
})(this));
|
1412
1428
|
};
|
1413
1429
|
|
1414
1430
|
return MissingFatArrows;
|
@@ -1416,7 +1432,7 @@ module.exports = MissingFatArrows = (function() {
|
|
1416
1432
|
})();
|
1417
1433
|
|
1418
1434
|
|
1419
|
-
},{}],18:[function(
|
1435
|
+
},{}],18:[function(_dereq_,module,exports){
|
1420
1436
|
var NewlinesAfterClasses;
|
1421
1437
|
|
1422
1438
|
module.exports = NewlinesAfterClasses = (function() {
|
@@ -1427,7 +1443,7 @@ module.exports = NewlinesAfterClasses = (function() {
|
|
1427
1443
|
value: 3,
|
1428
1444
|
level: 'ignore',
|
1429
1445
|
message: 'Wrong count of newlines between a class and other code',
|
1430
|
-
description: "Checks the number of newlines between classes and other
|
1446
|
+
description: "Checks the number of newlines between classes and other code"
|
1431
1447
|
};
|
1432
1448
|
|
1433
1449
|
NewlinesAfterClasses.prototype.lintLine = function(line, lineApi) {
|
@@ -1451,7 +1467,7 @@ module.exports = NewlinesAfterClasses = (function() {
|
|
1451
1467
|
})();
|
1452
1468
|
|
1453
1469
|
|
1454
|
-
},{}],19:[function(
|
1470
|
+
},{}],19:[function(_dereq_,module,exports){
|
1455
1471
|
var NoBackticks;
|
1456
1472
|
|
1457
1473
|
module.exports = NoBackticks = (function() {
|
@@ -1475,7 +1491,7 @@ module.exports = NoBackticks = (function() {
|
|
1475
1491
|
})();
|
1476
1492
|
|
1477
1493
|
|
1478
|
-
},{}],20:[function(
|
1494
|
+
},{}],20:[function(_dereq_,module,exports){
|
1479
1495
|
var NoEmptyParamList;
|
1480
1496
|
|
1481
1497
|
module.exports = NoEmptyParamList = (function() {
|
@@ -1501,7 +1517,7 @@ module.exports = NoEmptyParamList = (function() {
|
|
1501
1517
|
})();
|
1502
1518
|
|
1503
1519
|
|
1504
|
-
},{}],21:[function(
|
1520
|
+
},{}],21:[function(_dereq_,module,exports){
|
1505
1521
|
var NoImplicitBraces;
|
1506
1522
|
|
1507
1523
|
module.exports = NoImplicitBraces = (function() {
|
@@ -1550,7 +1566,7 @@ module.exports = NoImplicitBraces = (function() {
|
|
1550
1566
|
})();
|
1551
1567
|
|
1552
1568
|
|
1553
|
-
},{}],22:[function(
|
1569
|
+
},{}],22:[function(_dereq_,module,exports){
|
1554
1570
|
var NoImplicitParens;
|
1555
1571
|
|
1556
1572
|
module.exports = NoImplicitParens = (function() {
|
@@ -1574,7 +1590,7 @@ module.exports = NoImplicitParens = (function() {
|
|
1574
1590
|
})();
|
1575
1591
|
|
1576
1592
|
|
1577
|
-
},{}],23:[function(
|
1593
|
+
},{}],23:[function(_dereq_,module,exports){
|
1578
1594
|
var NoPlusPlus;
|
1579
1595
|
|
1580
1596
|
module.exports = NoPlusPlus = (function() {
|
@@ -1600,7 +1616,7 @@ module.exports = NoPlusPlus = (function() {
|
|
1600
1616
|
})();
|
1601
1617
|
|
1602
1618
|
|
1603
|
-
},{}],24:[function(
|
1619
|
+
},{}],24:[function(_dereq_,module,exports){
|
1604
1620
|
var NoStandAloneAt;
|
1605
1621
|
|
1606
1622
|
module.exports = NoStandAloneAt = (function() {
|
@@ -1636,7 +1652,7 @@ module.exports = NoStandAloneAt = (function() {
|
|
1636
1652
|
})();
|
1637
1653
|
|
1638
1654
|
|
1639
|
-
},{}],25:[function(
|
1655
|
+
},{}],25:[function(_dereq_,module,exports){
|
1640
1656
|
var NoTabs, indentationRegex,
|
1641
1657
|
__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; };
|
1642
1658
|
|
@@ -1667,7 +1683,7 @@ module.exports = NoTabs = (function() {
|
|
1667
1683
|
})();
|
1668
1684
|
|
1669
1685
|
|
1670
|
-
},{}],26:[function(
|
1686
|
+
},{}],26:[function(_dereq_,module,exports){
|
1671
1687
|
var NoThrowingStrings;
|
1672
1688
|
|
1673
1689
|
module.exports = NoThrowingStrings = (function() {
|
@@ -1694,7 +1710,7 @@ module.exports = NoThrowingStrings = (function() {
|
|
1694
1710
|
})();
|
1695
1711
|
|
1696
1712
|
|
1697
|
-
},{}],27:[function(
|
1713
|
+
},{}],27:[function(_dereq_,module,exports){
|
1698
1714
|
var NoTrailingSemicolons, regexes,
|
1699
1715
|
__slice = [].slice;
|
1700
1716
|
|
@@ -1713,13 +1729,25 @@ module.exports = NoTrailingSemicolons = (function() {
|
|
1713
1729
|
};
|
1714
1730
|
|
1715
1731
|
NoTrailingSemicolons.prototype.lintLine = function(line, lineApi) {
|
1716
|
-
var first, hasNewLine, hasSemicolon, last, lineTokens, _i, _ref;
|
1732
|
+
var endPos, first, hasNewLine, hasSemicolon, last, lineTokens, newLine, startCounter, startPos, _i, _ref;
|
1717
1733
|
lineTokens = lineApi.getLineTokens();
|
1718
|
-
if (lineTokens.length === 1 && lineTokens[0][0] === 'TERMINATOR') {
|
1734
|
+
if (lineTokens.length === 1 && ((_ref = lineTokens[0][0]) === 'TERMINATOR' || _ref === 'HERECOMMENT')) {
|
1719
1735
|
return;
|
1720
1736
|
}
|
1721
|
-
|
1722
|
-
|
1737
|
+
newLine = line;
|
1738
|
+
if (lineTokens.length > 1 && lineTokens[lineTokens.length - 1][0] === 'TERMINATOR') {
|
1739
|
+
startPos = lineTokens[lineTokens.length - 2][2].last_column + 1;
|
1740
|
+
endPos = lineTokens[lineTokens.length - 1][2].first_column;
|
1741
|
+
if (startPos !== endPos) {
|
1742
|
+
startCounter = startPos;
|
1743
|
+
while (line[startCounter] !== "#" && startCounter < line.length) {
|
1744
|
+
startCounter++;
|
1745
|
+
}
|
1746
|
+
newLine = line.substring(0, startCounter).replace(/\s*$/, '');
|
1747
|
+
}
|
1748
|
+
}
|
1749
|
+
hasSemicolon = regexes.trailingSemicolon.test(newLine);
|
1750
|
+
first = 2 <= lineTokens.length ? __slice.call(lineTokens, 0, _i = lineTokens.length - 1) : (_i = 0, []), last = lineTokens[_i++];
|
1723
1751
|
hasNewLine = last && (last.newLine != null);
|
1724
1752
|
if (hasSemicolon && !hasNewLine && lineApi.lineHasToken() && last[0] !== 'STRING') {
|
1725
1753
|
return true;
|
@@ -1731,12 +1759,12 @@ module.exports = NoTrailingSemicolons = (function() {
|
|
1731
1759
|
})();
|
1732
1760
|
|
1733
1761
|
|
1734
|
-
},{}],28:[function(
|
1762
|
+
},{}],28:[function(_dereq_,module,exports){
|
1735
1763
|
var NoTrailingWhitespace, regexes;
|
1736
1764
|
|
1737
1765
|
regexes = {
|
1738
1766
|
trailingWhitespace: /[^\s]+[\t ]+\r?$/,
|
1739
|
-
onlySpaces: /^[\t
|
1767
|
+
onlySpaces: /^[\t ]+\r?$/,
|
1740
1768
|
lineHasComment: /^\s*[^\#]*\#/
|
1741
1769
|
};
|
1742
1770
|
|
@@ -1794,7 +1822,7 @@ module.exports = NoTrailingWhitespace = (function() {
|
|
1794
1822
|
})();
|
1795
1823
|
|
1796
1824
|
|
1797
|
-
},{}],29:[function(
|
1825
|
+
},{}],29:[function(_dereq_,module,exports){
|
1798
1826
|
var NoUnnecessaryFatArrows, any, isCode, isFatArrowCode, isThis, needsFatArrow;
|
1799
1827
|
|
1800
1828
|
isCode = function(node) {
|
@@ -1839,17 +1867,18 @@ module.exports = NoUnnecessaryFatArrows = (function() {
|
|
1839
1867
|
};
|
1840
1868
|
|
1841
1869
|
NoUnnecessaryFatArrows.prototype.lintNode = function(node, astApi) {
|
1842
|
-
var error
|
1843
|
-
_this = this;
|
1870
|
+
var error;
|
1844
1871
|
if ((isFatArrowCode(node)) && (!needsFatArrow(node))) {
|
1845
1872
|
error = astApi.createError({
|
1846
1873
|
lineNumber: node.locationData.first_line + 1
|
1847
1874
|
});
|
1848
1875
|
this.errors.push(error);
|
1849
1876
|
}
|
1850
|
-
return node.eachChild(function(
|
1851
|
-
return
|
1852
|
-
|
1877
|
+
return node.eachChild((function(_this) {
|
1878
|
+
return function(child) {
|
1879
|
+
return _this.lintNode(child, astApi);
|
1880
|
+
};
|
1881
|
+
})(this));
|
1853
1882
|
};
|
1854
1883
|
|
1855
1884
|
return NoUnnecessaryFatArrows;
|
@@ -1857,19 +1886,18 @@ module.exports = NoUnnecessaryFatArrows = (function() {
|
|
1857
1886
|
})();
|
1858
1887
|
|
1859
1888
|
|
1860
|
-
},{}],30:[function(
|
1861
|
-
var NonEmptyConstructorNeedsParens, ParentClass,
|
1889
|
+
},{}],30:[function(_dereq_,module,exports){
|
1890
|
+
var NonEmptyConstructorNeedsParens, ParentClass,
|
1862
1891
|
__hasProp = {}.hasOwnProperty,
|
1863
1892
|
__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; };
|
1864
1893
|
|
1865
|
-
ParentClass =
|
1894
|
+
ParentClass = _dereq_('./empty_constructor_needs_parens.coffee');
|
1866
1895
|
|
1867
1896
|
module.exports = NonEmptyConstructorNeedsParens = (function(_super) {
|
1868
1897
|
__extends(NonEmptyConstructorNeedsParens, _super);
|
1869
1898
|
|
1870
1899
|
function NonEmptyConstructorNeedsParens() {
|
1871
|
-
|
1872
|
-
return _ref;
|
1900
|
+
return NonEmptyConstructorNeedsParens.__super__.constructor.apply(this, arguments);
|
1873
1901
|
}
|
1874
1902
|
|
1875
1903
|
NonEmptyConstructorNeedsParens.prototype.rule = {
|
@@ -1890,7 +1918,7 @@ module.exports = NonEmptyConstructorNeedsParens = (function(_super) {
|
|
1890
1918
|
})(ParentClass);
|
1891
1919
|
|
1892
1920
|
|
1893
|
-
},{"./empty_constructor_needs_parens.coffee":13}],31:[function(
|
1921
|
+
},{"./empty_constructor_needs_parens.coffee":13}],31:[function(_dereq_,module,exports){
|
1894
1922
|
var SpaceOperators,
|
1895
1923
|
__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; };
|
1896
1924
|
|
@@ -1902,7 +1930,7 @@ module.exports = SpaceOperators = (function() {
|
|
1902
1930
|
description: "This rule enforces that operators have space around them."
|
1903
1931
|
};
|
1904
1932
|
|
1905
|
-
SpaceOperators.prototype.tokens = ["+", "-", "=", "MATH", "COMPARE", "LOGIC", "COMPOUND_ASSIGN", "(", ")", "CALL_START", "CALL_END"];
|
1933
|
+
SpaceOperators.prototype.tokens = ["+", "-", "=", "**", "MATH", "COMPARE", "LOGIC", "COMPOUND_ASSIGN", "(", ")", "CALL_START", "CALL_END"];
|
1906
1934
|
|
1907
1935
|
function SpaceOperators() {
|
1908
1936
|
this.callTokens = [];
|
@@ -2010,6 +2038,6 @@ module.exports = SpaceOperators = (function() {
|
|
2010
2038
|
})();
|
2011
2039
|
|
2012
2040
|
|
2013
|
-
},{}]},{},[4])
|
2014
|
-
|
2015
|
-
;
|
2041
|
+
},{}]},{},[4])
|
2042
|
+
(4)
|
2043
|
+
});
|
data/lib/coffeelint/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coffeelint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zachary Bush
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-03-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: coffee-script
|
@@ -76,6 +76,7 @@ extra_rdoc_files: []
|
|
76
76
|
files:
|
77
77
|
- .gitignore
|
78
78
|
- .gitmodules
|
79
|
+
- .travis.yml
|
79
80
|
- Gemfile
|
80
81
|
- LICENSE.txt
|
81
82
|
- README.md
|