coffeelint 1.8.1 → 1.9.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +8 -1
- data/coffeelint.gemspec +1 -3
- data/coffeelint/lib/coffeelint.js +793 -742
- data/lib/coffeelint.rb +3 -5
- data/lib/coffeelint/config.rb +42 -0
- data/lib/coffeelint/version.rb +1 -1
- data/lib/tasks/coffeelint.rake +1 -13
- data/spec/assets/.coffeelint.json +5 -0
- data/spec/config_spec.rb +64 -0
- metadata +7 -2
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Coffeelint [![Build Status](https://travis-ci.org/zmbush/coffeelint-ruby.svg?branch=master)](https://travis-ci.org/zmbush/coffeelint-ruby) [![Gem Version](https://badge.fury.io/rb/coffeelint.png)](http://badge.fury.io/rb/coffeelint)
|
2
2
|
|
3
|
-
Using coffeelint version: v1.
|
3
|
+
Using coffeelint version: v1.9.1
|
4
4
|
|
5
5
|
Coffeelint is a set of simple ruby bindings for [coffeelint](https://github.com/clutchski/coffeelint).
|
6
6
|
|
@@ -50,6 +50,13 @@ Coffeelint.run_test_suite(directory, :config_file => 'coffeelint_config.json')
|
|
50
50
|
|
51
51
|
Then it will load the config options from that file.
|
52
52
|
|
53
|
+
Alternatively you can create a config file in your project, coffeelint will load these by default:
|
54
|
+
|
55
|
+
* coffeelint.json
|
56
|
+
* .coffeelint.json
|
57
|
+
* config/coffeelint.json
|
58
|
+
* config/.coffeelint.json
|
59
|
+
|
53
60
|
To use a local version of coffeelint instead of the one bundled with the gem, You can set the path with `Coffeelint.set_path(/path/to/coffeelint.js)`
|
54
61
|
|
55
62
|
Additionally, if you are using rails you also get the rake task:
|
data/coffeelint.gemspec
CHANGED
@@ -13,9 +13,7 @@ Gem::Specification.new do |gem|
|
|
13
13
|
gem.homepage = "https://github.com/zipcodeman/coffeelint-ruby"
|
14
14
|
gem.licenses = ["MIT"]
|
15
15
|
|
16
|
-
gem.files = `git ls-files`.split($/)
|
17
|
-
gem.files -= ['bin/coffeelint']
|
18
|
-
gem.files << 'coffeelint/lib/coffeelint.js'
|
16
|
+
gem.files = `git ls-files`.split($/) + %w(coffeelint/lib/coffeelint.js) - %w(bin/coffeelint)
|
19
17
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
20
18
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
21
19
|
gem.require_paths = ["lib"]
|
@@ -1,278 +1,4 @@
|
|
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);
|
2
|
-
module.exports={
|
3
|
-
"name": "coffeelint",
|
4
|
-
"description": "Lint your CoffeeScript",
|
5
|
-
"version": "1.8.1",
|
6
|
-
"homepage": "http://www.coffeelint.org",
|
7
|
-
"keywords": [
|
8
|
-
"lint",
|
9
|
-
"coffeescript",
|
10
|
-
"coffee-script"
|
11
|
-
],
|
12
|
-
"author": "Matthew Perpick <clutchski@gmail.com>",
|
13
|
-
"main": "./lib/coffeelint.js",
|
14
|
-
"engines": {
|
15
|
-
"npm": ">=1.3.7",
|
16
|
-
"node": ">=0.8.0"
|
17
|
-
},
|
18
|
-
"repository": {
|
19
|
-
"type": "git",
|
20
|
-
"url": "git://github.com/clutchski/coffeelint.git"
|
21
|
-
},
|
22
|
-
"bin": {
|
23
|
-
"coffeelint": "./bin/coffeelint"
|
24
|
-
},
|
25
|
-
"dependencies": {
|
26
|
-
"browserify": "~3.37",
|
27
|
-
"coffee-script": "~1.7",
|
28
|
-
"coffeeify": "~0.6.0",
|
29
|
-
"glob": "^4.0.0",
|
30
|
-
"ignore": "^2.2.15",
|
31
|
-
"optimist": "^0.6.1",
|
32
|
-
"resolve": "^0.6.3"
|
33
|
-
},
|
34
|
-
"devDependencies": {
|
35
|
-
"vows": ">=0.6.0",
|
36
|
-
"underscore": ">=1.4.4"
|
37
|
-
},
|
38
|
-
"licenses": [
|
39
|
-
{
|
40
|
-
"type": "MIT",
|
41
|
-
"url": "http://github.com/clutchski/coffeelint/raw/master/LICENSE"
|
42
|
-
}
|
43
|
-
],
|
44
|
-
"scripts": {
|
45
|
-
"pretest": "cake compile",
|
46
|
-
"test": "./vowsrunner.js --spec test/*.coffee test/*.litcoffee",
|
47
|
-
"posttest": "npm run lint",
|
48
|
-
"prepublish": "cake prepublish",
|
49
|
-
"publish": "cake publish",
|
50
|
-
"install": "cake install",
|
51
|
-
"lint": "cake compile && ./bin/coffeelint .",
|
52
|
-
"lint-csv": "cake compile && ./bin/coffeelint --csv .",
|
53
|
-
"lint-jslint": "cake compile && ./bin/coffeelint --jslint .",
|
54
|
-
"compile": "cake compile"
|
55
|
-
}
|
56
|
-
}
|
57
|
-
|
58
|
-
},{}],2:[function(_dereq_,module,exports){
|
59
|
-
var ASTApi, ASTLinter, BaseLinter, hasChildren, node_children,
|
60
|
-
__hasProp = {}.hasOwnProperty,
|
61
|
-
__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; };
|
62
|
-
|
63
|
-
BaseLinter = _dereq_('./base_linter.coffee');
|
64
|
-
|
65
|
-
node_children = {
|
66
|
-
Class: ['variable', 'parent', 'body'],
|
67
|
-
Code: ['params', 'body'],
|
68
|
-
For: ['body', 'source', 'guard', 'step'],
|
69
|
-
If: ['condition', 'body', 'elseBody'],
|
70
|
-
Obj: ['properties'],
|
71
|
-
Op: ['first', 'second'],
|
72
|
-
Switch: ['subject', 'cases', 'otherwise'],
|
73
|
-
Try: ['attempt', 'recovery', 'ensure'],
|
74
|
-
Value: ['base', 'properties'],
|
75
|
-
While: ['condition', 'guard', 'body']
|
76
|
-
};
|
77
|
-
|
78
|
-
hasChildren = function(node, children) {
|
79
|
-
var _ref;
|
80
|
-
return (node != null ? (_ref = node.children) != null ? _ref.length : void 0 : void 0) === children.length && (node != null ? node.children.every(function(elem, i) {
|
81
|
-
return elem === children[i];
|
82
|
-
}) : void 0);
|
83
|
-
};
|
84
|
-
|
85
|
-
ASTApi = (function() {
|
86
|
-
function ASTApi(config) {
|
87
|
-
this.config = config;
|
88
|
-
}
|
89
|
-
|
90
|
-
ASTApi.prototype.getNodeName = function(node) {
|
91
|
-
var children, name, _ref;
|
92
|
-
name = node != null ? (_ref = node.constructor) != null ? _ref.name : void 0 : void 0;
|
93
|
-
if (node_children[name]) {
|
94
|
-
return name;
|
95
|
-
} else {
|
96
|
-
for (name in node_children) {
|
97
|
-
if (!__hasProp.call(node_children, name)) continue;
|
98
|
-
children = node_children[name];
|
99
|
-
if (hasChildren(node, children)) {
|
100
|
-
return name;
|
101
|
-
}
|
102
|
-
}
|
103
|
-
}
|
104
|
-
};
|
105
|
-
|
106
|
-
return ASTApi;
|
107
|
-
|
108
|
-
})();
|
109
|
-
|
110
|
-
module.exports = ASTLinter = (function(_super) {
|
111
|
-
__extends(ASTLinter, _super);
|
112
|
-
|
113
|
-
function ASTLinter(source, config, rules, CoffeeScript) {
|
114
|
-
this.CoffeeScript = CoffeeScript;
|
115
|
-
ASTLinter.__super__.constructor.call(this, source, config, rules);
|
116
|
-
this.astApi = new ASTApi(this.config);
|
117
|
-
}
|
118
|
-
|
119
|
-
ASTLinter.prototype.acceptRule = function(rule) {
|
120
|
-
return typeof rule.lintAST === 'function';
|
121
|
-
};
|
122
|
-
|
123
|
-
ASTLinter.prototype.lint = function() {
|
124
|
-
var coffeeError, err, errors, rule, v, _i, _len, _ref;
|
125
|
-
errors = [];
|
126
|
-
try {
|
127
|
-
this.node = this.CoffeeScript.nodes(this.source);
|
128
|
-
} catch (_error) {
|
129
|
-
coffeeError = _error;
|
130
|
-
err = this._parseCoffeeScriptError(coffeeError);
|
131
|
-
if (err != null) {
|
132
|
-
errors.push(err);
|
133
|
-
}
|
134
|
-
return errors;
|
135
|
-
}
|
136
|
-
_ref = this.rules;
|
137
|
-
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
138
|
-
rule = _ref[_i];
|
139
|
-
this.astApi.createError = (function(_this) {
|
140
|
-
return function(attrs) {
|
141
|
-
if (attrs == null) {
|
142
|
-
attrs = {};
|
143
|
-
}
|
144
|
-
return _this.createError(rule.rule.name, attrs);
|
145
|
-
};
|
146
|
-
})(this);
|
147
|
-
rule.errors = errors;
|
148
|
-
v = this.normalizeResult(rule, rule.lintAST(this.node, this.astApi));
|
149
|
-
if (v != null) {
|
150
|
-
return v;
|
151
|
-
}
|
152
|
-
}
|
153
|
-
return errors;
|
154
|
-
};
|
155
|
-
|
156
|
-
ASTLinter.prototype._parseCoffeeScriptError = function(coffeeError) {
|
157
|
-
var attrs, lineNumber, match, message, rule;
|
158
|
-
rule = this.config['coffeescript_error'];
|
159
|
-
message = coffeeError.toString();
|
160
|
-
lineNumber = -1;
|
161
|
-
if (coffeeError.location != null) {
|
162
|
-
lineNumber = coffeeError.location.first_line + 1;
|
163
|
-
} else {
|
164
|
-
match = /line (\d+)/.exec(message);
|
165
|
-
if ((match != null ? match.length : void 0) > 1) {
|
166
|
-
lineNumber = parseInt(match[1], 10);
|
167
|
-
}
|
168
|
-
}
|
169
|
-
attrs = {
|
170
|
-
message: message,
|
171
|
-
level: rule.level,
|
172
|
-
lineNumber: lineNumber
|
173
|
-
};
|
174
|
-
return this.createError('coffeescript_error', attrs);
|
175
|
-
};
|
176
|
-
|
177
|
-
return ASTLinter;
|
178
|
-
|
179
|
-
})(BaseLinter);
|
180
|
-
|
181
|
-
|
182
|
-
},{"./base_linter.coffee":3}],3:[function(_dereq_,module,exports){
|
183
|
-
var BaseLinter, defaults, extend,
|
184
|
-
__slice = [].slice;
|
185
|
-
|
186
|
-
extend = function() {
|
187
|
-
var destination, k, source, sources, v, _i, _len;
|
188
|
-
destination = arguments[0], sources = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
|
189
|
-
for (_i = 0, _len = sources.length; _i < _len; _i++) {
|
190
|
-
source = sources[_i];
|
191
|
-
for (k in source) {
|
192
|
-
v = source[k];
|
193
|
-
destination[k] = v;
|
194
|
-
}
|
195
|
-
}
|
196
|
-
return destination;
|
197
|
-
};
|
198
|
-
|
199
|
-
defaults = function(source, defaults) {
|
200
|
-
return extend({}, defaults, source);
|
201
|
-
};
|
202
|
-
|
203
|
-
module.exports = BaseLinter = (function() {
|
204
|
-
function BaseLinter(source, config, rules) {
|
205
|
-
this.source = source;
|
206
|
-
this.config = config;
|
207
|
-
this.setupRules(rules);
|
208
|
-
}
|
209
|
-
|
210
|
-
BaseLinter.prototype.isObject = function(obj) {
|
211
|
-
return obj === Object(obj);
|
212
|
-
};
|
213
|
-
|
214
|
-
BaseLinter.prototype.createError = function(ruleName, attrs) {
|
215
|
-
var level;
|
216
|
-
if (attrs == null) {
|
217
|
-
attrs = {};
|
218
|
-
}
|
219
|
-
if (attrs.level == null) {
|
220
|
-
attrs.level = this.config[ruleName].level;
|
221
|
-
}
|
222
|
-
level = attrs.level;
|
223
|
-
if (level !== 'ignore' && level !== 'warn' && level !== 'error') {
|
224
|
-
throw new Error("unknown level " + level);
|
225
|
-
}
|
226
|
-
if (level === 'error' || level === 'warn') {
|
227
|
-
attrs.rule = ruleName;
|
228
|
-
return defaults(attrs, this.config[ruleName]);
|
229
|
-
} else {
|
230
|
-
return null;
|
231
|
-
}
|
232
|
-
};
|
233
|
-
|
234
|
-
BaseLinter.prototype.acceptRule = function(rule) {
|
235
|
-
throw new Error("acceptRule needs to be overridden in the subclass");
|
236
|
-
};
|
237
|
-
|
238
|
-
BaseLinter.prototype.setupRules = function(rules) {
|
239
|
-
var RuleConstructor, level, name, rule, _results;
|
240
|
-
this.rules = [];
|
241
|
-
_results = [];
|
242
|
-
for (name in rules) {
|
243
|
-
RuleConstructor = rules[name];
|
244
|
-
level = this.config[name].level;
|
245
|
-
if (level === 'error' || level === 'warn') {
|
246
|
-
rule = new RuleConstructor(this, this.config);
|
247
|
-
if (this.acceptRule(rule)) {
|
248
|
-
_results.push(this.rules.push(rule));
|
249
|
-
} else {
|
250
|
-
_results.push(void 0);
|
251
|
-
}
|
252
|
-
} else if (level !== 'ignore') {
|
253
|
-
throw new Error("unknown level " + level);
|
254
|
-
} else {
|
255
|
-
_results.push(void 0);
|
256
|
-
}
|
257
|
-
}
|
258
|
-
return _results;
|
259
|
-
};
|
260
|
-
|
261
|
-
BaseLinter.prototype.normalizeResult = function(p, result) {
|
262
|
-
if (result === true) {
|
263
|
-
return this.createError(p.rule.name);
|
264
|
-
}
|
265
|
-
if (this.isObject(result)) {
|
266
|
-
return this.createError(p.rule.name, result);
|
267
|
-
}
|
268
|
-
};
|
269
|
-
|
270
|
-
return BaseLinter;
|
271
|
-
|
272
|
-
})();
|
273
|
-
|
274
|
-
|
275
|
-
},{}],4:[function(_dereq_,module,exports){
|
1
|
+
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)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);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.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){
|
276
2
|
|
277
3
|
/*
|
278
4
|
CoffeeLint
|
@@ -280,21 +6,27 @@ CoffeeLint
|
|
280
6
|
Copyright (c) 2011 Matthew Perpick.
|
281
7
|
CoffeeLint is freely distributable under the MIT license.
|
282
8
|
*/
|
283
|
-
var ASTLinter, CoffeeScript, ERROR, ErrorReport, IGNORE, LexicalLinter, LineLinter, RULES, WARN, cache, coffeelint, defaults, difference, extend, hasSyntaxError, mergeDefaultConfig, nodeRequire, packageJSON,
|
284
|
-
|
285
|
-
|
9
|
+
var ASTLinter, CoffeeScript, ERROR, ErrorReport, IGNORE, LexicalLinter, LineLinter, RULES, WARN, _rules, cache, coffeelint, defaults, difference, extend, hasSyntaxError, mergeDefaultConfig, nodeRequire, packageJSON,
|
10
|
+
slice = [].slice,
|
11
|
+
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; };
|
286
12
|
|
287
13
|
coffeelint = exports;
|
288
14
|
|
289
|
-
nodeRequire =
|
15
|
+
nodeRequire = require;
|
290
16
|
|
291
17
|
if (typeof window !== "undefined" && window !== null) {
|
292
18
|
CoffeeScript = window.CoffeeScript;
|
293
|
-
}
|
19
|
+
}
|
20
|
+
|
21
|
+
if (CoffeeScript == null) {
|
294
22
|
CoffeeScript = nodeRequire('coffee-script');
|
295
23
|
}
|
296
24
|
|
297
|
-
|
25
|
+
if (CoffeeScript == null) {
|
26
|
+
throw new Error('Unable to find CoffeeScript');
|
27
|
+
}
|
28
|
+
|
29
|
+
packageJSON = require('./../package.json');
|
298
30
|
|
299
31
|
coffeelint.VERSION = packageJSON.version;
|
300
32
|
|
@@ -304,13 +36,13 @@ WARN = 'warn';
|
|
304
36
|
|
305
37
|
IGNORE = 'ignore';
|
306
38
|
|
307
|
-
coffeelint.RULES = RULES =
|
39
|
+
coffeelint.RULES = RULES = require('./rules.coffee');
|
308
40
|
|
309
41
|
extend = function() {
|
310
|
-
var destination, k,
|
311
|
-
destination = arguments[0], sources = 2 <= arguments.length ?
|
312
|
-
for (
|
313
|
-
source = sources[
|
42
|
+
var destination, k, len, n, source, sources, v;
|
43
|
+
destination = arguments[0], sources = 2 <= arguments.length ? slice.call(arguments, 1) : [];
|
44
|
+
for (n = 0, len = sources.length; n < len; n++) {
|
45
|
+
source = sources[n];
|
314
46
|
for (k in source) {
|
315
47
|
v = source[k];
|
316
48
|
destination[k] = v;
|
@@ -324,24 +56,24 @@ defaults = function(source, defaults) {
|
|
324
56
|
};
|
325
57
|
|
326
58
|
difference = function(a, b) {
|
327
|
-
var j,
|
59
|
+
var j, ref, results;
|
328
60
|
j = 0;
|
329
|
-
|
61
|
+
results = [];
|
330
62
|
while (j < a.length) {
|
331
|
-
if (
|
332
|
-
|
63
|
+
if (ref = a[j], indexOf.call(b, ref) >= 0) {
|
64
|
+
results.push(a.splice(j, 1));
|
333
65
|
} else {
|
334
|
-
|
66
|
+
results.push(j++);
|
335
67
|
}
|
336
68
|
}
|
337
|
-
return
|
69
|
+
return results;
|
338
70
|
};
|
339
71
|
|
340
|
-
LineLinter =
|
72
|
+
LineLinter = require('./line_linter.coffee');
|
341
73
|
|
342
|
-
LexicalLinter =
|
74
|
+
LexicalLinter = require('./lexical_linter.coffee');
|
343
75
|
|
344
|
-
ASTLinter =
|
76
|
+
ASTLinter = require('./ast_linter.coffee');
|
345
77
|
|
346
78
|
cache = null;
|
347
79
|
|
@@ -356,17 +88,17 @@ mergeDefaultConfig = function(userConfig) {
|
|
356
88
|
};
|
357
89
|
|
358
90
|
coffeelint.invertLiterate = function(source) {
|
359
|
-
var
|
91
|
+
var len, line, n, newSource, ref;
|
360
92
|
source = CoffeeScript.helpers.invertLiterate(source);
|
361
93
|
newSource = "";
|
362
|
-
|
363
|
-
for (
|
364
|
-
line =
|
94
|
+
ref = source.split("\n");
|
95
|
+
for (n = 0, len = ref.length; n < len; n++) {
|
96
|
+
line = ref[n];
|
365
97
|
if (line.match(/^#/)) {
|
366
98
|
line = line.replace(/\s*$/, '');
|
367
99
|
}
|
368
100
|
line = line.replace(/^\s{4}/g, '');
|
369
|
-
newSource +=
|
101
|
+
newSource += line + "\n";
|
370
102
|
}
|
371
103
|
return newSource;
|
372
104
|
};
|
@@ -374,12 +106,12 @@ coffeelint.invertLiterate = function(source) {
|
|
374
106
|
_rules = {};
|
375
107
|
|
376
108
|
coffeelint.registerRule = function(RuleConstructor, ruleName) {
|
377
|
-
var e, name, p,
|
109
|
+
var e, name, p, ref, ref1;
|
378
110
|
if (ruleName == null) {
|
379
111
|
ruleName = void 0;
|
380
112
|
}
|
381
113
|
p = new RuleConstructor;
|
382
|
-
name = (p != null ? (
|
114
|
+
name = (p != null ? (ref = p.rule) != null ? ref.name : void 0 : void 0) || "(unknown)";
|
383
115
|
e = function(msg) {
|
384
116
|
throw new Error("Invalid rule: " + name + " " + msg);
|
385
117
|
};
|
@@ -398,7 +130,7 @@ coffeelint.registerRule = function(RuleConstructor, ruleName) {
|
|
398
130
|
if (p.rule.description == null) {
|
399
131
|
e("Rule defaults require a description");
|
400
132
|
}
|
401
|
-
if ((
|
133
|
+
if ((ref1 = p.rule.level) !== 'ignore' && ref1 !== 'warn' && ref1 !== 'error') {
|
402
134
|
e("Default level must be 'ignore', 'warn', or 'error'");
|
403
135
|
}
|
404
136
|
if (typeof p.lintToken === 'function') {
|
@@ -413,79 +145,81 @@ coffeelint.registerRule = function(RuleConstructor, ruleName) {
|
|
413
145
|
};
|
414
146
|
|
415
147
|
coffeelint.getRules = function() {
|
416
|
-
var key,
|
148
|
+
var key, len, n, output, ref;
|
417
149
|
output = {};
|
418
|
-
|
419
|
-
for (
|
420
|
-
key =
|
150
|
+
ref = Object.keys(RULES).sort();
|
151
|
+
for (n = 0, len = ref.length; n < len; n++) {
|
152
|
+
key = ref[n];
|
421
153
|
output[key] = RULES[key];
|
422
154
|
}
|
423
155
|
return output;
|
424
156
|
};
|
425
157
|
|
426
|
-
coffeelint.registerRule(
|
158
|
+
coffeelint.registerRule(require('./rules/arrow_spacing.coffee'));
|
159
|
+
|
160
|
+
coffeelint.registerRule(require('./rules/braces_spacing.coffee'));
|
427
161
|
|
428
|
-
coffeelint.registerRule(
|
162
|
+
coffeelint.registerRule(require('./rules/no_tabs.coffee'));
|
429
163
|
|
430
|
-
coffeelint.registerRule(
|
164
|
+
coffeelint.registerRule(require('./rules/no_trailing_whitespace.coffee'));
|
431
165
|
|
432
|
-
coffeelint.registerRule(
|
166
|
+
coffeelint.registerRule(require('./rules/max_line_length.coffee'));
|
433
167
|
|
434
|
-
coffeelint.registerRule(
|
168
|
+
coffeelint.registerRule(require('./rules/line_endings.coffee'));
|
435
169
|
|
436
|
-
coffeelint.registerRule(
|
170
|
+
coffeelint.registerRule(require('./rules/no_trailing_semicolons.coffee'));
|
437
171
|
|
438
|
-
coffeelint.registerRule(
|
172
|
+
coffeelint.registerRule(require('./rules/indentation.coffee'));
|
439
173
|
|
440
|
-
coffeelint.registerRule(
|
174
|
+
coffeelint.registerRule(require('./rules/camel_case_classes.coffee'));
|
441
175
|
|
442
|
-
coffeelint.registerRule(
|
176
|
+
coffeelint.registerRule(require('./rules/colon_assignment_spacing.coffee'));
|
443
177
|
|
444
|
-
coffeelint.registerRule(
|
178
|
+
coffeelint.registerRule(require('./rules/no_implicit_braces.coffee'));
|
445
179
|
|
446
|
-
coffeelint.registerRule(
|
180
|
+
coffeelint.registerRule(require('./rules/no_plusplus.coffee'));
|
447
181
|
|
448
|
-
coffeelint.registerRule(
|
182
|
+
coffeelint.registerRule(require('./rules/no_throwing_strings.coffee'));
|
449
183
|
|
450
|
-
coffeelint.registerRule(
|
184
|
+
coffeelint.registerRule(require('./rules/no_backticks.coffee'));
|
451
185
|
|
452
|
-
coffeelint.registerRule(
|
186
|
+
coffeelint.registerRule(require('./rules/no_implicit_parens.coffee'));
|
453
187
|
|
454
|
-
coffeelint.registerRule(
|
188
|
+
coffeelint.registerRule(require('./rules/no_empty_param_list.coffee'));
|
455
189
|
|
456
|
-
coffeelint.registerRule(
|
190
|
+
coffeelint.registerRule(require('./rules/no_stand_alone_at.coffee'));
|
457
191
|
|
458
|
-
coffeelint.registerRule(
|
192
|
+
coffeelint.registerRule(require('./rules/space_operators.coffee'));
|
459
193
|
|
460
|
-
coffeelint.registerRule(
|
194
|
+
coffeelint.registerRule(require('./rules/duplicate_key.coffee'));
|
461
195
|
|
462
|
-
coffeelint.registerRule(
|
196
|
+
coffeelint.registerRule(require('./rules/empty_constructor_needs_parens.coffee'));
|
463
197
|
|
464
|
-
coffeelint.registerRule(
|
198
|
+
coffeelint.registerRule(require('./rules/cyclomatic_complexity.coffee'));
|
465
199
|
|
466
|
-
coffeelint.registerRule(
|
200
|
+
coffeelint.registerRule(require('./rules/newlines_after_classes.coffee'));
|
467
201
|
|
468
|
-
coffeelint.registerRule(
|
202
|
+
coffeelint.registerRule(require('./rules/no_unnecessary_fat_arrows.coffee'));
|
469
203
|
|
470
|
-
coffeelint.registerRule(
|
204
|
+
coffeelint.registerRule(require('./rules/missing_fat_arrows.coffee'));
|
471
205
|
|
472
|
-
coffeelint.registerRule(
|
206
|
+
coffeelint.registerRule(require('./rules/non_empty_constructor_needs_parens.coffee'));
|
473
207
|
|
474
|
-
coffeelint.registerRule(
|
208
|
+
coffeelint.registerRule(require('./rules/no_unnecessary_double_quotes.coffee'));
|
475
209
|
|
476
|
-
coffeelint.registerRule(
|
210
|
+
coffeelint.registerRule(require('./rules/no_debugger.coffee'));
|
477
211
|
|
478
|
-
coffeelint.registerRule(
|
212
|
+
coffeelint.registerRule(require('./rules/no_interpolation_in_single_quotes.coffee'));
|
479
213
|
|
480
|
-
coffeelint.registerRule(
|
214
|
+
coffeelint.registerRule(require('./rules/no_empty_functions.coffee'));
|
481
215
|
|
482
|
-
coffeelint.registerRule(
|
216
|
+
coffeelint.registerRule(require('./rules/prefer_english_operator.coffee'));
|
483
217
|
|
484
|
-
coffeelint.registerRule(
|
218
|
+
coffeelint.registerRule(require('./rules/spacing_after_comma.coffee'));
|
485
219
|
|
486
|
-
coffeelint.registerRule(
|
220
|
+
coffeelint.registerRule(require('./rules/transform_messes_up_line_numbers.coffee'));
|
487
221
|
|
488
|
-
coffeelint.registerRule(
|
222
|
+
coffeelint.registerRule(require('./rules/ensure_comprehensions.coffee'));
|
489
223
|
|
490
224
|
hasSyntaxError = function(source) {
|
491
225
|
try {
|
@@ -495,14 +229,14 @@ hasSyntaxError = function(source) {
|
|
495
229
|
return true;
|
496
230
|
};
|
497
231
|
|
498
|
-
ErrorReport =
|
232
|
+
ErrorReport = require('./error_report.coffee');
|
499
233
|
|
500
234
|
coffeelint.getErrorReport = function() {
|
501
235
|
return new ErrorReport(coffeelint);
|
502
236
|
};
|
503
237
|
|
504
238
|
coffeelint.lint = function(source, userConfig, literate) {
|
505
|
-
var all_errors, astErrors, block_config, cmd, config, disabled, disabled_initially, e, errors, i, l,
|
239
|
+
var all_errors, astErrors, block_config, cmd, config, disabled, disabled_initially, e, errors, i, l, len, len1, len2, lexErrors, lexicalLinter, lineErrors, lineLinter, m, n, name, next_line, o, q, r, ref, ref1, ref2, ref3, ref4, ref5, ref6, ref7, ref8, ruleLoader, rules, s, sourceLength, t, tokensByLine, transform;
|
506
240
|
if (userConfig == null) {
|
507
241
|
userConfig = {};
|
508
242
|
}
|
@@ -524,11 +258,11 @@ coffeelint.lint = function(source, userConfig, literate) {
|
|
524
258
|
if (literate) {
|
525
259
|
source = this.invertLiterate(source);
|
526
260
|
}
|
527
|
-
if ((userConfig != null ? (
|
261
|
+
if ((userConfig != null ? (ref = userConfig.coffeelint) != null ? ref.transforms : void 0 : void 0) != null) {
|
528
262
|
sourceLength = source.split("\n").length;
|
529
|
-
|
530
|
-
for (
|
531
|
-
m =
|
263
|
+
ref2 = userConfig != null ? (ref1 = userConfig.coffeelint) != null ? ref1.transforms : void 0 : void 0;
|
264
|
+
for (n = 0, len = ref2.length; n < len; n++) {
|
265
|
+
m = ref2[n];
|
532
266
|
transform = ruleLoader.require(m);
|
533
267
|
source = transform(source);
|
534
268
|
}
|
@@ -540,100 +274,377 @@ coffeelint.lint = function(source, userConfig, literate) {
|
|
540
274
|
console.log(errors);
|
541
275
|
}
|
542
276
|
}
|
543
|
-
if ((userConfig != null ? (
|
544
|
-
CoffeeScript = ruleLoader.require(userConfig.coffeelint.coffeescript);
|
277
|
+
if ((userConfig != null ? (ref3 = userConfig.coffeelint) != null ? ref3.coffeescript : void 0 : void 0) != null) {
|
278
|
+
CoffeeScript = ruleLoader.require(userConfig.coffeelint.coffeescript);
|
279
|
+
}
|
280
|
+
for (name in userConfig) {
|
281
|
+
if (name !== 'coffeescript_error' && name !== '_comment') {
|
282
|
+
if (_rules[name] == null) {
|
283
|
+
void 0;
|
284
|
+
}
|
285
|
+
}
|
286
|
+
}
|
287
|
+
disabled_initially = [];
|
288
|
+
ref4 = source.split('\n');
|
289
|
+
for (o = 0, len1 = ref4.length; o < len1; o++) {
|
290
|
+
l = ref4[o];
|
291
|
+
s = LineLinter.configStatement.exec(l);
|
292
|
+
if ((s != null ? s.length : void 0) > 2 && indexOf.call(s, 'enable') >= 0) {
|
293
|
+
ref5 = s.slice(1);
|
294
|
+
for (q = 0, len2 = ref5.length; q < len2; q++) {
|
295
|
+
r = ref5[q];
|
296
|
+
if (r !== 'enable' && r !== 'disable') {
|
297
|
+
if (!(r in config && ((ref6 = config[r].level) === 'warn' || ref6 === 'error'))) {
|
298
|
+
disabled_initially.push(r);
|
299
|
+
config[r] = {
|
300
|
+
level: 'error'
|
301
|
+
};
|
302
|
+
}
|
303
|
+
}
|
304
|
+
}
|
305
|
+
}
|
306
|
+
}
|
307
|
+
astErrors = new ASTLinter(source, config, _rules, CoffeeScript).lint();
|
308
|
+
errors = errors.concat(astErrors);
|
309
|
+
if (!hasSyntaxError(source)) {
|
310
|
+
lexicalLinter = new LexicalLinter(source, config, _rules, CoffeeScript);
|
311
|
+
lexErrors = lexicalLinter.lint();
|
312
|
+
errors = errors.concat(lexErrors);
|
313
|
+
tokensByLine = lexicalLinter.tokensByLine;
|
314
|
+
lineLinter = new LineLinter(source, config, _rules, tokensByLine, literate);
|
315
|
+
lineErrors = lineLinter.lint();
|
316
|
+
errors = errors.concat(lineErrors);
|
317
|
+
block_config = lineLinter.block_config;
|
318
|
+
} else {
|
319
|
+
block_config = {
|
320
|
+
enable: {},
|
321
|
+
disable: {}
|
322
|
+
};
|
323
|
+
}
|
324
|
+
errors.sort(function(a, b) {
|
325
|
+
return a.lineNumber - b.lineNumber;
|
326
|
+
});
|
327
|
+
all_errors = errors;
|
328
|
+
errors = [];
|
329
|
+
disabled = disabled_initially;
|
330
|
+
next_line = 0;
|
331
|
+
for (i = t = 0, ref7 = source.split('\n').length; 0 <= ref7 ? t < ref7 : t > ref7; i = 0 <= ref7 ? ++t : --t) {
|
332
|
+
for (cmd in block_config) {
|
333
|
+
rules = block_config[cmd][i];
|
334
|
+
if (rules != null) {
|
335
|
+
({
|
336
|
+
'disable': function() {
|
337
|
+
return disabled = disabled.concat(rules);
|
338
|
+
},
|
339
|
+
'enable': function() {
|
340
|
+
difference(disabled, rules);
|
341
|
+
if (rules.length === 0) {
|
342
|
+
return disabled = disabled_initially;
|
343
|
+
}
|
344
|
+
}
|
345
|
+
})[cmd]();
|
346
|
+
}
|
347
|
+
}
|
348
|
+
while (next_line === i && all_errors.length > 0) {
|
349
|
+
next_line = all_errors[0].lineNumber - 1;
|
350
|
+
e = all_errors[0];
|
351
|
+
if (e.lineNumber === i + 1 || (e.lineNumber == null)) {
|
352
|
+
e = all_errors.shift();
|
353
|
+
if (ref8 = e.rule, indexOf.call(disabled, ref8) < 0) {
|
354
|
+
errors.push(e);
|
355
|
+
}
|
356
|
+
}
|
357
|
+
}
|
358
|
+
}
|
359
|
+
if (cache != null) {
|
360
|
+
cache.set(source, errors);
|
361
|
+
}
|
362
|
+
return errors;
|
363
|
+
};
|
364
|
+
|
365
|
+
coffeelint.setCache = function(obj) {
|
366
|
+
return cache = obj;
|
367
|
+
};
|
368
|
+
|
369
|
+
|
370
|
+
|
371
|
+
},{"./../package.json":2,"./ast_linter.coffee":3,"./error_report.coffee":5,"./lexical_linter.coffee":6,"./line_linter.coffee":7,"./rules.coffee":8,"./rules/arrow_spacing.coffee":9,"./rules/braces_spacing.coffee":10,"./rules/camel_case_classes.coffee":11,"./rules/colon_assignment_spacing.coffee":12,"./rules/cyclomatic_complexity.coffee":13,"./rules/duplicate_key.coffee":14,"./rules/empty_constructor_needs_parens.coffee":15,"./rules/ensure_comprehensions.coffee":16,"./rules/indentation.coffee":17,"./rules/line_endings.coffee":18,"./rules/max_line_length.coffee":19,"./rules/missing_fat_arrows.coffee":20,"./rules/newlines_after_classes.coffee":21,"./rules/no_backticks.coffee":22,"./rules/no_debugger.coffee":23,"./rules/no_empty_functions.coffee":24,"./rules/no_empty_param_list.coffee":25,"./rules/no_implicit_braces.coffee":26,"./rules/no_implicit_parens.coffee":27,"./rules/no_interpolation_in_single_quotes.coffee":28,"./rules/no_plusplus.coffee":29,"./rules/no_stand_alone_at.coffee":30,"./rules/no_tabs.coffee":31,"./rules/no_throwing_strings.coffee":32,"./rules/no_trailing_semicolons.coffee":33,"./rules/no_trailing_whitespace.coffee":34,"./rules/no_unnecessary_double_quotes.coffee":35,"./rules/no_unnecessary_fat_arrows.coffee":36,"./rules/non_empty_constructor_needs_parens.coffee":37,"./rules/prefer_english_operator.coffee":38,"./rules/space_operators.coffee":39,"./rules/spacing_after_comma.coffee":40,"./rules/transform_messes_up_line_numbers.coffee":41}],2:[function(require,module,exports){
|
372
|
+
module.exports={
|
373
|
+
"name": "coffeelint",
|
374
|
+
"description": "Lint your CoffeeScript",
|
375
|
+
"version": "1.9.1",
|
376
|
+
"homepage": "http://www.coffeelint.org",
|
377
|
+
"keywords": [
|
378
|
+
"lint",
|
379
|
+
"coffeescript",
|
380
|
+
"coffee-script"
|
381
|
+
],
|
382
|
+
"author": "Matthew Perpick <clutchski@gmail.com>",
|
383
|
+
"main": "./lib/coffeelint.js",
|
384
|
+
"engines": {
|
385
|
+
"npm": ">=1.3.7",
|
386
|
+
"node": ">=0.8.0"
|
387
|
+
},
|
388
|
+
"repository": {
|
389
|
+
"type": "git",
|
390
|
+
"url": "git://github.com/clutchski/coffeelint.git"
|
391
|
+
},
|
392
|
+
"bin": {
|
393
|
+
"coffeelint": "./bin/coffeelint"
|
394
|
+
},
|
395
|
+
"dependencies": {
|
396
|
+
"browserify": "~8.1.0",
|
397
|
+
"coffee-script": "^1.9.1",
|
398
|
+
"coffeeify": "~1.0.0",
|
399
|
+
"glob": "^4.0.0",
|
400
|
+
"ignore": "^2.2.15",
|
401
|
+
"optimist": "^0.6.1",
|
402
|
+
"resolve": "^0.6.3"
|
403
|
+
},
|
404
|
+
"devDependencies": {
|
405
|
+
"vows": ">=0.6.0",
|
406
|
+
"underscore": ">=1.4.4"
|
407
|
+
},
|
408
|
+
"licenses": [
|
409
|
+
{
|
410
|
+
"type": "MIT",
|
411
|
+
"url": "http://github.com/clutchski/coffeelint/raw/master/LICENSE"
|
412
|
+
}
|
413
|
+
],
|
414
|
+
"scripts": {
|
415
|
+
"pretest": "cake compile",
|
416
|
+
"test": "./vowsrunner.js --spec test/*.coffee test/*.litcoffee",
|
417
|
+
"posttest": "npm run lint",
|
418
|
+
"prepublish": "cake prepublish",
|
419
|
+
"publish": "cake publish",
|
420
|
+
"install": "cake install",
|
421
|
+
"lint": "cake compile && ./bin/coffeelint .",
|
422
|
+
"lint-csv": "cake compile && ./bin/coffeelint --csv .",
|
423
|
+
"lint-jslint": "cake compile && ./bin/coffeelint --jslint .",
|
424
|
+
"compile": "cake compile"
|
425
|
+
}
|
426
|
+
}
|
427
|
+
|
428
|
+
},{}],3:[function(require,module,exports){
|
429
|
+
var ASTApi, ASTLinter, BaseLinter, hasChildren, node_children,
|
430
|
+
hasProp = {}.hasOwnProperty,
|
431
|
+
extend = 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; };
|
432
|
+
|
433
|
+
BaseLinter = require('./base_linter.coffee');
|
434
|
+
|
435
|
+
node_children = {
|
436
|
+
Class: ['variable', 'parent', 'body'],
|
437
|
+
Code: ['params', 'body'],
|
438
|
+
For: ['body', 'source', 'guard', 'step'],
|
439
|
+
If: ['condition', 'body', 'elseBody'],
|
440
|
+
Obj: ['properties'],
|
441
|
+
Op: ['first', 'second'],
|
442
|
+
Switch: ['subject', 'cases', 'otherwise'],
|
443
|
+
Try: ['attempt', 'recovery', 'ensure'],
|
444
|
+
Value: ['base', 'properties'],
|
445
|
+
While: ['condition', 'guard', 'body']
|
446
|
+
};
|
447
|
+
|
448
|
+
hasChildren = function(node, children) {
|
449
|
+
var ref;
|
450
|
+
return (node != null ? (ref = node.children) != null ? ref.length : void 0 : void 0) === children.length && (node != null ? node.children.every(function(elem, i) {
|
451
|
+
return elem === children[i];
|
452
|
+
}) : void 0);
|
453
|
+
};
|
454
|
+
|
455
|
+
ASTApi = (function() {
|
456
|
+
function ASTApi(config1) {
|
457
|
+
this.config = config1;
|
458
|
+
}
|
459
|
+
|
460
|
+
ASTApi.prototype.getNodeName = function(node) {
|
461
|
+
var children, name, ref;
|
462
|
+
name = node != null ? (ref = node.constructor) != null ? ref.name : void 0 : void 0;
|
463
|
+
if (node_children[name]) {
|
464
|
+
return name;
|
465
|
+
} else {
|
466
|
+
for (name in node_children) {
|
467
|
+
if (!hasProp.call(node_children, name)) continue;
|
468
|
+
children = node_children[name];
|
469
|
+
if (hasChildren(node, children)) {
|
470
|
+
return name;
|
471
|
+
}
|
472
|
+
}
|
473
|
+
}
|
474
|
+
};
|
475
|
+
|
476
|
+
return ASTApi;
|
477
|
+
|
478
|
+
})();
|
479
|
+
|
480
|
+
module.exports = ASTLinter = (function(superClass) {
|
481
|
+
extend(ASTLinter, superClass);
|
482
|
+
|
483
|
+
function ASTLinter(source, config, rules, CoffeeScript) {
|
484
|
+
this.CoffeeScript = CoffeeScript;
|
485
|
+
ASTLinter.__super__.constructor.call(this, source, config, rules);
|
486
|
+
this.astApi = new ASTApi(this.config);
|
487
|
+
}
|
488
|
+
|
489
|
+
ASTLinter.prototype.acceptRule = function(rule) {
|
490
|
+
return typeof rule.lintAST === 'function';
|
491
|
+
};
|
492
|
+
|
493
|
+
ASTLinter.prototype.lint = function() {
|
494
|
+
var coffeeError, err, errors, j, len, ref, rule, v;
|
495
|
+
errors = [];
|
496
|
+
try {
|
497
|
+
this.node = this.CoffeeScript.nodes(this.source);
|
498
|
+
} catch (_error) {
|
499
|
+
coffeeError = _error;
|
500
|
+
err = this._parseCoffeeScriptError(coffeeError);
|
501
|
+
if (err != null) {
|
502
|
+
errors.push(err);
|
503
|
+
}
|
504
|
+
return errors;
|
505
|
+
}
|
506
|
+
ref = this.rules;
|
507
|
+
for (j = 0, len = ref.length; j < len; j++) {
|
508
|
+
rule = ref[j];
|
509
|
+
this.astApi.createError = (function(_this) {
|
510
|
+
return function(attrs) {
|
511
|
+
if (attrs == null) {
|
512
|
+
attrs = {};
|
513
|
+
}
|
514
|
+
return _this.createError(rule.rule.name, attrs);
|
515
|
+
};
|
516
|
+
})(this);
|
517
|
+
rule.errors = errors;
|
518
|
+
v = this.normalizeResult(rule, rule.lintAST(this.node, this.astApi));
|
519
|
+
if (v != null) {
|
520
|
+
return v;
|
521
|
+
}
|
522
|
+
}
|
523
|
+
return errors;
|
524
|
+
};
|
525
|
+
|
526
|
+
ASTLinter.prototype._parseCoffeeScriptError = function(coffeeError) {
|
527
|
+
var attrs, lineNumber, match, message, rule;
|
528
|
+
rule = this.config['coffeescript_error'];
|
529
|
+
message = coffeeError.toString();
|
530
|
+
lineNumber = -1;
|
531
|
+
if (coffeeError.location != null) {
|
532
|
+
lineNumber = coffeeError.location.first_line + 1;
|
533
|
+
} else {
|
534
|
+
match = /line (\d+)/.exec(message);
|
535
|
+
if ((match != null ? match.length : void 0) > 1) {
|
536
|
+
lineNumber = parseInt(match[1], 10);
|
537
|
+
}
|
538
|
+
}
|
539
|
+
attrs = {
|
540
|
+
message: message,
|
541
|
+
level: rule.level,
|
542
|
+
lineNumber: lineNumber
|
543
|
+
};
|
544
|
+
return this.createError('coffeescript_error', attrs);
|
545
|
+
};
|
546
|
+
|
547
|
+
return ASTLinter;
|
548
|
+
|
549
|
+
})(BaseLinter);
|
550
|
+
|
551
|
+
|
552
|
+
|
553
|
+
},{"./base_linter.coffee":4}],4:[function(require,module,exports){
|
554
|
+
var BaseLinter, defaults, extend,
|
555
|
+
slice = [].slice;
|
556
|
+
|
557
|
+
extend = function() {
|
558
|
+
var destination, i, k, len, source, sources, v;
|
559
|
+
destination = arguments[0], sources = 2 <= arguments.length ? slice.call(arguments, 1) : [];
|
560
|
+
for (i = 0, len = sources.length; i < len; i++) {
|
561
|
+
source = sources[i];
|
562
|
+
for (k in source) {
|
563
|
+
v = source[k];
|
564
|
+
destination[k] = v;
|
565
|
+
}
|
566
|
+
}
|
567
|
+
return destination;
|
568
|
+
};
|
569
|
+
|
570
|
+
defaults = function(source, defaults) {
|
571
|
+
return extend({}, defaults, source);
|
572
|
+
};
|
573
|
+
|
574
|
+
module.exports = BaseLinter = (function() {
|
575
|
+
function BaseLinter(source1, config, rules) {
|
576
|
+
this.source = source1;
|
577
|
+
this.config = config;
|
578
|
+
this.setupRules(rules);
|
545
579
|
}
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
580
|
+
|
581
|
+
BaseLinter.prototype.isObject = function(obj) {
|
582
|
+
return obj === Object(obj);
|
583
|
+
};
|
584
|
+
|
585
|
+
BaseLinter.prototype.createError = function(ruleName, attrs) {
|
586
|
+
var level;
|
587
|
+
if (attrs == null) {
|
588
|
+
attrs = {};
|
551
589
|
}
|
552
|
-
|
553
|
-
|
554
|
-
_ref4 = source.split('\n');
|
555
|
-
for (_j = 0, _len1 = _ref4.length; _j < _len1; _j++) {
|
556
|
-
l = _ref4[_j];
|
557
|
-
s = LineLinter.configStatement.exec(l);
|
558
|
-
if ((s != null ? s.length : void 0) > 2 && __indexOf.call(s, 'enable') >= 0) {
|
559
|
-
_ref5 = s.slice(1);
|
560
|
-
for (_k = 0, _len2 = _ref5.length; _k < _len2; _k++) {
|
561
|
-
r = _ref5[_k];
|
562
|
-
if (r !== 'enable' && r !== 'disable') {
|
563
|
-
if (!(r in config && ((_ref6 = config[r].level) === 'warn' || _ref6 === 'error'))) {
|
564
|
-
disabled_initially.push(r);
|
565
|
-
config[r] = {
|
566
|
-
level: 'error'
|
567
|
-
};
|
568
|
-
}
|
569
|
-
}
|
570
|
-
}
|
590
|
+
if (attrs.level == null) {
|
591
|
+
attrs.level = this.config[ruleName].level;
|
571
592
|
}
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
if (!hasSyntaxError(source)) {
|
576
|
-
lexicalLinter = new LexicalLinter(source, config, _rules, CoffeeScript);
|
577
|
-
lexErrors = lexicalLinter.lint();
|
578
|
-
errors = errors.concat(lexErrors);
|
579
|
-
tokensByLine = lexicalLinter.tokensByLine;
|
580
|
-
lineLinter = new LineLinter(source, config, _rules, tokensByLine, literate);
|
581
|
-
lineErrors = lineLinter.lint();
|
582
|
-
errors = errors.concat(lineErrors);
|
583
|
-
block_config = lineLinter.block_config;
|
584
|
-
} else {
|
585
|
-
block_config = {
|
586
|
-
enable: {},
|
587
|
-
disable: {}
|
588
|
-
};
|
589
|
-
}
|
590
|
-
errors.sort(function(a, b) {
|
591
|
-
return a.lineNumber - b.lineNumber;
|
592
|
-
});
|
593
|
-
all_errors = errors;
|
594
|
-
errors = [];
|
595
|
-
disabled = disabled_initially;
|
596
|
-
next_line = 0;
|
597
|
-
for (i = _l = 0, _ref7 = source.split('\n').length; 0 <= _ref7 ? _l < _ref7 : _l > _ref7; i = 0 <= _ref7 ? ++_l : --_l) {
|
598
|
-
for (cmd in block_config) {
|
599
|
-
rules = block_config[cmd][i];
|
600
|
-
if (rules != null) {
|
601
|
-
({
|
602
|
-
'disable': function() {
|
603
|
-
return disabled = disabled.concat(rules);
|
604
|
-
},
|
605
|
-
'enable': function() {
|
606
|
-
difference(disabled, rules);
|
607
|
-
if (rules.length === 0) {
|
608
|
-
return disabled = disabled_initially;
|
609
|
-
}
|
610
|
-
}
|
611
|
-
})[cmd]();
|
612
|
-
}
|
593
|
+
level = attrs.level;
|
594
|
+
if (level !== 'ignore' && level !== 'warn' && level !== 'error') {
|
595
|
+
throw new Error("unknown level " + level);
|
613
596
|
}
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
597
|
+
if (level === 'error' || level === 'warn') {
|
598
|
+
attrs.rule = ruleName;
|
599
|
+
return defaults(attrs, this.config[ruleName]);
|
600
|
+
} else {
|
601
|
+
return null;
|
602
|
+
}
|
603
|
+
};
|
604
|
+
|
605
|
+
BaseLinter.prototype.acceptRule = function(rule) {
|
606
|
+
throw new Error("acceptRule needs to be overridden in the subclass");
|
607
|
+
};
|
608
|
+
|
609
|
+
BaseLinter.prototype.setupRules = function(rules) {
|
610
|
+
var RuleConstructor, level, name, results, rule;
|
611
|
+
this.rules = [];
|
612
|
+
results = [];
|
613
|
+
for (name in rules) {
|
614
|
+
RuleConstructor = rules[name];
|
615
|
+
level = this.config[name].level;
|
616
|
+
if (level === 'error' || level === 'warn') {
|
617
|
+
rule = new RuleConstructor(this, this.config);
|
618
|
+
if (this.acceptRule(rule)) {
|
619
|
+
results.push(this.rules.push(rule));
|
620
|
+
} else {
|
621
|
+
results.push(void 0);
|
621
622
|
}
|
623
|
+
} else if (level !== 'ignore') {
|
624
|
+
throw new Error("unknown level " + level);
|
625
|
+
} else {
|
626
|
+
results.push(void 0);
|
622
627
|
}
|
623
628
|
}
|
624
|
-
|
625
|
-
|
626
|
-
cache.set(source, errors);
|
627
|
-
}
|
628
|
-
return errors;
|
629
|
-
};
|
629
|
+
return results;
|
630
|
+
};
|
630
631
|
|
631
|
-
|
632
|
-
|
633
|
-
|
632
|
+
BaseLinter.prototype.normalizeResult = function(p, result) {
|
633
|
+
if (result === true) {
|
634
|
+
return this.createError(p.rule.name);
|
635
|
+
}
|
636
|
+
if (this.isObject(result)) {
|
637
|
+
return this.createError(p.rule.name, result);
|
638
|
+
}
|
639
|
+
};
|
640
|
+
|
641
|
+
return BaseLinter;
|
642
|
+
|
643
|
+
})();
|
634
644
|
|
635
645
|
|
636
|
-
|
646
|
+
|
647
|
+
},{}],5:[function(require,module,exports){
|
637
648
|
var ErrorReport;
|
638
649
|
|
639
650
|
module.exports = ErrorReport = (function() {
|
@@ -663,14 +674,14 @@ module.exports = ErrorReport = (function() {
|
|
663
674
|
};
|
664
675
|
|
665
676
|
ErrorReport.prototype.getSummary = function() {
|
666
|
-
var error, errorCount, errors,
|
677
|
+
var error, errorCount, errors, i, len, path, pathCount, ref, warningCount;
|
667
678
|
pathCount = errorCount = warningCount = 0;
|
668
|
-
|
669
|
-
for (path in
|
670
|
-
errors =
|
679
|
+
ref = this.paths;
|
680
|
+
for (path in ref) {
|
681
|
+
errors = ref[path];
|
671
682
|
pathCount++;
|
672
|
-
for (
|
673
|
-
error = errors[
|
683
|
+
for (i = 0, len = errors.length; i < len; i++) {
|
684
|
+
error = errors[i];
|
674
685
|
if (error.level === 'error') {
|
675
686
|
errorCount++;
|
676
687
|
}
|
@@ -709,10 +720,10 @@ module.exports = ErrorReport = (function() {
|
|
709
720
|
};
|
710
721
|
|
711
722
|
ErrorReport.prototype._hasLevel = function(path, level) {
|
712
|
-
var error,
|
713
|
-
|
714
|
-
for (
|
715
|
-
error =
|
723
|
+
var error, i, len, ref;
|
724
|
+
ref = this.paths[path];
|
725
|
+
for (i = 0, len = ref.length; i < len; i++) {
|
726
|
+
error = ref[i];
|
716
727
|
if (error.level === level) {
|
717
728
|
return true;
|
718
729
|
}
|
@@ -725,15 +736,16 @@ module.exports = ErrorReport = (function() {
|
|
725
736
|
})();
|
726
737
|
|
727
738
|
|
728
|
-
|
739
|
+
|
740
|
+
},{}],6:[function(require,module,exports){
|
729
741
|
var BaseLinter, LexicalLinter, TokenApi,
|
730
|
-
|
731
|
-
|
732
|
-
|
742
|
+
extend = 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; },
|
743
|
+
hasProp = {}.hasOwnProperty,
|
744
|
+
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; };
|
733
745
|
|
734
746
|
TokenApi = (function() {
|
735
|
-
function TokenApi(CoffeeScript, source,
|
736
|
-
this.config =
|
747
|
+
function TokenApi(CoffeeScript, source, config1, tokensByLine) {
|
748
|
+
this.config = config1;
|
737
749
|
this.tokensByLine = tokensByLine;
|
738
750
|
this.tokens = CoffeeScript.tokens(source);
|
739
751
|
this.lines = source.split('\n');
|
@@ -753,10 +765,10 @@ TokenApi = (function() {
|
|
753
765
|
|
754
766
|
})();
|
755
767
|
|
756
|
-
BaseLinter =
|
768
|
+
BaseLinter = require('./base_linter.coffee');
|
757
769
|
|
758
|
-
module.exports = LexicalLinter = (function(
|
759
|
-
|
770
|
+
module.exports = LexicalLinter = (function(superClass) {
|
771
|
+
extend(LexicalLinter, superClass);
|
760
772
|
|
761
773
|
function LexicalLinter(source, config, rules, CoffeeScript) {
|
762
774
|
LexicalLinter.__super__.constructor.call(this, source, config, rules);
|
@@ -769,15 +781,15 @@ module.exports = LexicalLinter = (function(_super) {
|
|
769
781
|
};
|
770
782
|
|
771
783
|
LexicalLinter.prototype.lint = function() {
|
772
|
-
var error, errors, i,
|
784
|
+
var error, errors, i, j, k, len, len1, ref, ref1, token;
|
773
785
|
errors = [];
|
774
|
-
|
775
|
-
for (i =
|
776
|
-
token =
|
786
|
+
ref = this.tokenApi.tokens;
|
787
|
+
for (i = j = 0, len = ref.length; j < len; i = ++j) {
|
788
|
+
token = ref[i];
|
777
789
|
this.tokenApi.i = i;
|
778
|
-
|
779
|
-
for (
|
780
|
-
error =
|
790
|
+
ref1 = this.lintToken(token);
|
791
|
+
for (k = 0, len1 = ref1.length; k < len1; k++) {
|
792
|
+
error = ref1[k];
|
781
793
|
errors.push(error);
|
782
794
|
}
|
783
795
|
}
|
@@ -785,7 +797,7 @@ module.exports = LexicalLinter = (function(_super) {
|
|
785
797
|
};
|
786
798
|
|
787
799
|
LexicalLinter.prototype.lintToken = function(token) {
|
788
|
-
var
|
800
|
+
var base, errors, j, len, lineNumber, ref, ref1, rule, type, v, value;
|
789
801
|
type = token[0], value = token[1], lineNumber = token[2];
|
790
802
|
if (typeof lineNumber === "object") {
|
791
803
|
if (type === 'OUTDENT' || type === 'INDENT') {
|
@@ -794,17 +806,17 @@ module.exports = LexicalLinter = (function(_super) {
|
|
794
806
|
lineNumber = lineNumber.first_line;
|
795
807
|
}
|
796
808
|
}
|
797
|
-
if ((
|
798
|
-
|
809
|
+
if ((base = this.tokensByLine)[lineNumber] == null) {
|
810
|
+
base[lineNumber] = [];
|
799
811
|
}
|
800
812
|
this.tokensByLine[lineNumber].push(token);
|
801
813
|
this.lineNumber = lineNumber || this.lineNumber || 0;
|
802
814
|
this.tokenApi.lineNumber = this.lineNumber;
|
803
815
|
errors = [];
|
804
|
-
|
805
|
-
for (
|
806
|
-
rule =
|
807
|
-
if (!(
|
816
|
+
ref = this.rules;
|
817
|
+
for (j = 0, len = ref.length; j < len; j++) {
|
818
|
+
rule = ref[j];
|
819
|
+
if (!(ref1 = token[0], indexOf.call(rule.tokens, ref1) >= 0)) {
|
808
820
|
continue;
|
809
821
|
}
|
810
822
|
v = this.normalizeResult(rule, rule.lintToken(token, this.tokenApi));
|
@@ -829,16 +841,17 @@ module.exports = LexicalLinter = (function(_super) {
|
|
829
841
|
})(BaseLinter);
|
830
842
|
|
831
843
|
|
832
|
-
|
844
|
+
|
845
|
+
},{"./base_linter.coffee":4}],7:[function(require,module,exports){
|
833
846
|
var BaseLinter, LineApi, LineLinter, configStatement,
|
834
|
-
|
835
|
-
|
847
|
+
extend = 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; },
|
848
|
+
hasProp = {}.hasOwnProperty;
|
836
849
|
|
837
850
|
LineApi = (function() {
|
838
|
-
function LineApi(source,
|
839
|
-
this.config =
|
840
|
-
this.tokensByLine =
|
841
|
-
this.literate =
|
851
|
+
function LineApi(source, config1, tokensByLine1, literate1) {
|
852
|
+
this.config = config1;
|
853
|
+
this.tokensByLine = tokensByLine1;
|
854
|
+
this.literate = literate1;
|
842
855
|
this.line = null;
|
843
856
|
this.lines = source.split('\n');
|
844
857
|
this.lineCount = this.lines.length;
|
@@ -889,7 +902,7 @@ LineApi = (function() {
|
|
889
902
|
};
|
890
903
|
|
891
904
|
LineApi.prototype.lineHasToken = function(tokenType, lineNumber) {
|
892
|
-
var
|
905
|
+
var i, len, token, tokens;
|
893
906
|
if (tokenType == null) {
|
894
907
|
tokenType = null;
|
895
908
|
}
|
@@ -904,8 +917,8 @@ LineApi = (function() {
|
|
904
917
|
if (tokens == null) {
|
905
918
|
return null;
|
906
919
|
}
|
907
|
-
for (
|
908
|
-
token = tokens[
|
920
|
+
for (i = 0, len = tokens.length; i < len; i++) {
|
921
|
+
token = tokens[i];
|
909
922
|
if (token[0] === tokenType) {
|
910
923
|
return true;
|
911
924
|
}
|
@@ -922,12 +935,12 @@ LineApi = (function() {
|
|
922
935
|
|
923
936
|
})();
|
924
937
|
|
925
|
-
BaseLinter =
|
938
|
+
BaseLinter = require('./base_linter.coffee');
|
926
939
|
|
927
940
|
configStatement = /coffeelint:\s*(disable|enable)(?:=([\w\s,]*))?/;
|
928
941
|
|
929
|
-
module.exports = LineLinter = (function(
|
930
|
-
|
942
|
+
module.exports = LineLinter = (function(superClass) {
|
943
|
+
extend(LineLinter, superClass);
|
931
944
|
|
932
945
|
LineLinter.configStatement = configStatement;
|
933
946
|
|
@@ -948,17 +961,17 @@ module.exports = LineLinter = (function(_super) {
|
|
948
961
|
};
|
949
962
|
|
950
963
|
LineLinter.prototype.lint = function() {
|
951
|
-
var error, errors,
|
964
|
+
var error, errors, i, j, len, len1, line, lineNumber, ref, ref1;
|
952
965
|
errors = [];
|
953
|
-
|
954
|
-
for (lineNumber =
|
955
|
-
line =
|
966
|
+
ref = this.lineApi.lines;
|
967
|
+
for (lineNumber = i = 0, len = ref.length; i < len; lineNumber = ++i) {
|
968
|
+
line = ref[lineNumber];
|
956
969
|
this.lineApi.lineNumber = this.lineNumber = lineNumber;
|
957
970
|
this.lineApi.maintainClassContext(line);
|
958
971
|
this.collectInlineConfig(line);
|
959
|
-
|
960
|
-
for (
|
961
|
-
error =
|
972
|
+
ref1 = this.lintLine(line);
|
973
|
+
for (j = 0, len1 = ref1.length; j < len1; j++) {
|
974
|
+
error = ref1[j];
|
962
975
|
errors.push(error);
|
963
976
|
}
|
964
977
|
}
|
@@ -966,11 +979,11 @@ module.exports = LineLinter = (function(_super) {
|
|
966
979
|
};
|
967
980
|
|
968
981
|
LineLinter.prototype.lintLine = function(line) {
|
969
|
-
var errors,
|
982
|
+
var errors, i, len, ref, rule, v;
|
970
983
|
errors = [];
|
971
|
-
|
972
|
-
for (
|
973
|
-
rule =
|
984
|
+
ref = this.rules;
|
985
|
+
for (i = 0, len = ref.length; i < len; i++) {
|
986
|
+
rule = ref[i];
|
974
987
|
v = this.normalizeResult(rule, rule.lintLine(line, this.lineApi));
|
975
988
|
if (v != null) {
|
976
989
|
errors.push(v);
|
@@ -980,15 +993,15 @@ module.exports = LineLinter = (function(_super) {
|
|
980
993
|
};
|
981
994
|
|
982
995
|
LineLinter.prototype.collectInlineConfig = function(line) {
|
983
|
-
var cmd,
|
996
|
+
var cmd, i, len, r, ref, result, rules;
|
984
997
|
result = configStatement.exec(line);
|
985
998
|
if (result != null) {
|
986
999
|
cmd = result[1];
|
987
1000
|
rules = [];
|
988
1001
|
if (result[2] != null) {
|
989
|
-
|
990
|
-
for (
|
991
|
-
r =
|
1002
|
+
ref = result[2].split(',');
|
1003
|
+
for (i = 0, len = ref.length; i < len; i++) {
|
1004
|
+
r = ref[i];
|
992
1005
|
rules.push(r.replace(/^\s+|\s+$/g, ""));
|
993
1006
|
}
|
994
1007
|
}
|
@@ -998,12 +1011,12 @@ module.exports = LineLinter = (function(_super) {
|
|
998
1011
|
};
|
999
1012
|
|
1000
1013
|
LineLinter.prototype.createError = function(rule, attrs) {
|
1001
|
-
var
|
1014
|
+
var ref;
|
1002
1015
|
if (attrs == null) {
|
1003
1016
|
attrs = {};
|
1004
1017
|
}
|
1005
1018
|
attrs.lineNumber = this.lineNumber + 1;
|
1006
|
-
attrs.level = (
|
1019
|
+
attrs.level = (ref = this.config[rule]) != null ? ref.level : void 0;
|
1007
1020
|
return LineLinter.__super__.createError.call(this, rule, attrs);
|
1008
1021
|
};
|
1009
1022
|
|
@@ -1012,7 +1025,8 @@ module.exports = LineLinter = (function(_super) {
|
|
1012
1025
|
})(BaseLinter);
|
1013
1026
|
|
1014
1027
|
|
1015
|
-
|
1028
|
+
|
1029
|
+
},{"./base_linter.coffee":4}],8:[function(require,module,exports){
|
1016
1030
|
var ERROR, IGNORE, WARN;
|
1017
1031
|
|
1018
1032
|
ERROR = 'error';
|
@@ -1029,7 +1043,8 @@ module.exports = {
|
|
1029
1043
|
};
|
1030
1044
|
|
1031
1045
|
|
1032
|
-
|
1046
|
+
|
1047
|
+
},{}],9:[function(require,module,exports){
|
1033
1048
|
var ArrowSpacing;
|
1034
1049
|
|
1035
1050
|
module.exports = ArrowSpacing = (function() {
|
@@ -1057,12 +1072,12 @@ module.exports = ArrowSpacing = (function() {
|
|
1057
1072
|
};
|
1058
1073
|
|
1059
1074
|
ArrowSpacing.prototype.atEof = function(tokenApi) {
|
1060
|
-
var i,
|
1075
|
+
var i, j, len, ref, ref1, token, tokens;
|
1061
1076
|
tokens = tokenApi.tokens, i = tokenApi.i;
|
1062
|
-
|
1063
|
-
for (
|
1064
|
-
token =
|
1065
|
-
if (!(token.generated || ((
|
1077
|
+
ref = tokens.slice(i + 1);
|
1078
|
+
for (j = 0, len = ref.length; j < len; j++) {
|
1079
|
+
token = ref[j];
|
1080
|
+
if (!(token.generated || ((ref1 = token[0]) === 'OUTDENT' || ref1 === 'TERMINATOR'))) {
|
1066
1081
|
return false;
|
1067
1082
|
}
|
1068
1083
|
}
|
@@ -1074,7 +1089,76 @@ module.exports = ArrowSpacing = (function() {
|
|
1074
1089
|
})();
|
1075
1090
|
|
1076
1091
|
|
1077
|
-
|
1092
|
+
|
1093
|
+
},{}],10:[function(require,module,exports){
|
1094
|
+
var BracesSpacing;
|
1095
|
+
|
1096
|
+
module.exports = BracesSpacing = (function() {
|
1097
|
+
function BracesSpacing() {}
|
1098
|
+
|
1099
|
+
BracesSpacing.prototype.rule = {
|
1100
|
+
name: 'braces_spacing',
|
1101
|
+
level: 'ignore',
|
1102
|
+
spaces: 0,
|
1103
|
+
message: 'Curly braces must have the proper spacing',
|
1104
|
+
description: 'This rule checks to see that there is the proper spacing inside\ncurly braces. The spacing amount is specified by "spaces".\n\n<pre><code>\n# Spaces is 0\n{a: b} # Good\n{a: b } # Bad\n{ a: b} # Bad\n{ a: b } # Bad\n\n# Spaces is 1\n{a: b} # Bad\n{a: b } # Bad\n{ a: b} # Bad\n{ a: b } # Good\n{ a: b } # Bad\n{ a: b } # Bad\n{ a: b } # Bad\n</code></pre>\n\nThis rule is disabled by default.'
|
1105
|
+
};
|
1106
|
+
|
1107
|
+
BracesSpacing.prototype.tokens = ['{', '}'];
|
1108
|
+
|
1109
|
+
BracesSpacing.prototype.distanceBetweenTokens = function(firstToken, secondToken) {
|
1110
|
+
return secondToken[2].first_column - firstToken[2].last_column - 1;
|
1111
|
+
};
|
1112
|
+
|
1113
|
+
BracesSpacing.prototype.findNearestToken = function(token, tokenApi, difference) {
|
1114
|
+
var nearestToken, totalDifference;
|
1115
|
+
totalDifference = 0;
|
1116
|
+
while (true) {
|
1117
|
+
totalDifference += difference;
|
1118
|
+
nearestToken = tokenApi.peek(totalDifference);
|
1119
|
+
if (nearestToken[0] === 'OUTDENT') {
|
1120
|
+
continue;
|
1121
|
+
}
|
1122
|
+
return nearestToken;
|
1123
|
+
}
|
1124
|
+
};
|
1125
|
+
|
1126
|
+
BracesSpacing.prototype.tokensOnSameLine = function(firstToken, secondToken) {
|
1127
|
+
return firstToken[2].first_line === secondToken[2].first_line;
|
1128
|
+
};
|
1129
|
+
|
1130
|
+
BracesSpacing.prototype.lintToken = function(token, tokenApi) {
|
1131
|
+
var actual, expected, firstToken, msg, ref, secondToken;
|
1132
|
+
if (token.generated) {
|
1133
|
+
return null;
|
1134
|
+
}
|
1135
|
+
ref = token[0] === '{' ? [token, this.findNearestToken(token, tokenApi, 1)] : [this.findNearestToken(token, tokenApi, -1), token], firstToken = ref[0], secondToken = ref[1];
|
1136
|
+
if (!this.tokensOnSameLine(firstToken, secondToken)) {
|
1137
|
+
return null;
|
1138
|
+
}
|
1139
|
+
expected = tokenApi.config[this.rule.name].spaces;
|
1140
|
+
actual = this.distanceBetweenTokens(firstToken, secondToken);
|
1141
|
+
if (actual === expected) {
|
1142
|
+
return null;
|
1143
|
+
} else {
|
1144
|
+
msg = "There should be " + expected + " space";
|
1145
|
+
if (expected !== 1) {
|
1146
|
+
msg += 's';
|
1147
|
+
}
|
1148
|
+
msg += " inside \"" + token[0] + "\"";
|
1149
|
+
return {
|
1150
|
+
context: msg
|
1151
|
+
};
|
1152
|
+
}
|
1153
|
+
};
|
1154
|
+
|
1155
|
+
return BracesSpacing;
|
1156
|
+
|
1157
|
+
})();
|
1158
|
+
|
1159
|
+
|
1160
|
+
|
1161
|
+
},{}],11:[function(require,module,exports){
|
1078
1162
|
var CamelCaseClasses, regexes;
|
1079
1163
|
|
1080
1164
|
regexes = {
|
@@ -1094,16 +1178,16 @@ module.exports = CamelCaseClasses = (function() {
|
|
1094
1178
|
CamelCaseClasses.prototype.tokens = ['CLASS'];
|
1095
1179
|
|
1096
1180
|
CamelCaseClasses.prototype.lintToken = function(token, tokenApi) {
|
1097
|
-
var className, offset,
|
1098
|
-
if ((token.newLine != null) || ((
|
1181
|
+
var className, offset, ref, ref1, ref2;
|
1182
|
+
if ((token.newLine != null) || ((ref = tokenApi.peek()[0]) === 'INDENT' || ref === 'EXTENDS')) {
|
1099
1183
|
return null;
|
1100
1184
|
}
|
1101
1185
|
className = null;
|
1102
1186
|
offset = 1;
|
1103
1187
|
while (!className) {
|
1104
|
-
if (((
|
1188
|
+
if (((ref1 = tokenApi.peek(offset + 1)) != null ? ref1[0] : void 0) === '.') {
|
1105
1189
|
offset += 2;
|
1106
|
-
} else if (((
|
1190
|
+
} else if (((ref2 = tokenApi.peek(offset)) != null ? ref2[0] : void 0) === '@') {
|
1107
1191
|
offset += 1;
|
1108
1192
|
} else {
|
1109
1193
|
className = tokenApi.peek(offset)[1];
|
@@ -1121,7 +1205,8 @@ module.exports = CamelCaseClasses = (function() {
|
|
1121
1205
|
})();
|
1122
1206
|
|
1123
1207
|
|
1124
|
-
|
1208
|
+
|
1209
|
+
},{}],12:[function(require,module,exports){
|
1125
1210
|
var ColonAssignmentSpacing;
|
1126
1211
|
|
1127
1212
|
module.exports = ColonAssignmentSpacing = (function() {
|
@@ -1141,7 +1226,7 @@ module.exports = ColonAssignmentSpacing = (function() {
|
|
1141
1226
|
ColonAssignmentSpacing.prototype.tokens = [':'];
|
1142
1227
|
|
1143
1228
|
ColonAssignmentSpacing.prototype.lintToken = function(token, tokenApi) {
|
1144
|
-
var checkSpacing, getSpaceFromToken, isLeftSpaced, isRightSpaced, leftSpacing, nextToken, previousToken,
|
1229
|
+
var checkSpacing, getSpaceFromToken, isLeftSpaced, isRightSpaced, leftSpacing, nextToken, previousToken, ref, ref1, rightSpacing, spaceRules;
|
1145
1230
|
spaceRules = tokenApi.config[this.rule.name].spacing;
|
1146
1231
|
previousToken = tokenApi.peek(-1);
|
1147
1232
|
nextToken = tokenApi.peek(1);
|
@@ -1159,8 +1244,8 @@ module.exports = ColonAssignmentSpacing = (function() {
|
|
1159
1244
|
isSpaced = spacing < 0 ? true : spacing === parseInt(spaceRules[direction]);
|
1160
1245
|
return [isSpaced, spacing];
|
1161
1246
|
};
|
1162
|
-
|
1163
|
-
|
1247
|
+
ref = checkSpacing('left'), isLeftSpaced = ref[0], leftSpacing = ref[1];
|
1248
|
+
ref1 = checkSpacing('right'), isRightSpaced = ref1[0], rightSpacing = ref1[1];
|
1164
1249
|
if (isLeftSpaced && isRightSpaced) {
|
1165
1250
|
return null;
|
1166
1251
|
} else {
|
@@ -1175,7 +1260,8 @@ module.exports = ColonAssignmentSpacing = (function() {
|
|
1175
1260
|
})();
|
1176
1261
|
|
1177
1262
|
|
1178
|
-
|
1263
|
+
|
1264
|
+
},{}],13:[function(require,module,exports){
|
1179
1265
|
var NoTabs;
|
1180
1266
|
|
1181
1267
|
module.exports = NoTabs = (function() {
|
@@ -1190,9 +1276,9 @@ module.exports = NoTabs = (function() {
|
|
1190
1276
|
};
|
1191
1277
|
|
1192
1278
|
NoTabs.prototype.getComplexity = function(node) {
|
1193
|
-
var complexity, name,
|
1279
|
+
var complexity, name, ref;
|
1194
1280
|
name = this.astApi.getNodeName(node);
|
1195
|
-
complexity = name === 'If' || name === 'While' || name === 'For' || name === 'Try' ? 1 : name === 'Op' && ((
|
1281
|
+
complexity = name === 'If' || name === 'While' || name === 'For' || name === 'Try' ? 1 : name === 'Op' && ((ref = node.operator) === '&&' || ref === '||') ? 1 : name === 'Switch' ? node.cases.length : 0;
|
1196
1282
|
return complexity;
|
1197
1283
|
};
|
1198
1284
|
|
@@ -1203,8 +1289,8 @@ module.exports = NoTabs = (function() {
|
|
1203
1289
|
};
|
1204
1290
|
|
1205
1291
|
NoTabs.prototype.lintNode = function(node, line) {
|
1206
|
-
var complexity, error, name,
|
1207
|
-
name = (
|
1292
|
+
var complexity, error, name, ref, rule;
|
1293
|
+
name = (ref = this.astApi) != null ? ref.getNodeName(node) : void 0;
|
1208
1294
|
complexity = this.getComplexity(node);
|
1209
1295
|
node.eachChild((function(_this) {
|
1210
1296
|
return function(childNode) {
|
@@ -1234,7 +1320,8 @@ module.exports = NoTabs = (function() {
|
|
1234
1320
|
})();
|
1235
1321
|
|
1236
1322
|
|
1237
|
-
|
1323
|
+
|
1324
|
+
},{}],14:[function(require,module,exports){
|
1238
1325
|
var DuplicateKey;
|
1239
1326
|
|
1240
1327
|
module.exports = DuplicateKey = (function() {
|
@@ -1251,9 +1338,9 @@ module.exports = DuplicateKey = (function() {
|
|
1251
1338
|
this.braceScopes = [];
|
1252
1339
|
}
|
1253
1340
|
|
1254
|
-
DuplicateKey.prototype.lintToken = function(
|
1341
|
+
DuplicateKey.prototype.lintToken = function(arg, tokenApi) {
|
1255
1342
|
var type;
|
1256
|
-
type =
|
1343
|
+
type = arg[0];
|
1257
1344
|
if (type === '{' || type === '}') {
|
1258
1345
|
this.lintBrace.apply(this, arguments);
|
1259
1346
|
return void 0;
|
@@ -1303,7 +1390,8 @@ module.exports = DuplicateKey = (function() {
|
|
1303
1390
|
})();
|
1304
1391
|
|
1305
1392
|
|
1306
|
-
|
1393
|
+
|
1394
|
+
},{}],15:[function(require,module,exports){
|
1307
1395
|
var EmptyConstructorNeedsParens;
|
1308
1396
|
|
1309
1397
|
module.exports = EmptyConstructorNeedsParens = (function() {
|
@@ -1350,9 +1438,10 @@ module.exports = EmptyConstructorNeedsParens = (function() {
|
|
1350
1438
|
})();
|
1351
1439
|
|
1352
1440
|
|
1353
|
-
|
1441
|
+
|
1442
|
+
},{}],16:[function(require,module,exports){
|
1354
1443
|
var EnsureComprehensions,
|
1355
|
-
|
1444
|
+
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; };
|
1356
1445
|
|
1357
1446
|
module.exports = EnsureComprehensions = (function() {
|
1358
1447
|
function EnsureComprehensions() {}
|
@@ -1367,7 +1456,7 @@ module.exports = EnsureComprehensions = (function() {
|
|
1367
1456
|
EnsureComprehensions.prototype.tokens = ['FOR'];
|
1368
1457
|
|
1369
1458
|
EnsureComprehensions.prototype.lintToken = function(token, tokenApi) {
|
1370
|
-
var atEqual, idents, peeker, prevIdents, prevToken,
|
1459
|
+
var atEqual, idents, peeker, prevIdents, prevToken, ref, ref1;
|
1371
1460
|
idents = this.findIdents(tokenApi);
|
1372
1461
|
peeker = -1;
|
1373
1462
|
atEqual = false;
|
@@ -1376,11 +1465,11 @@ module.exports = EnsureComprehensions = (function() {
|
|
1376
1465
|
if (prevToken[0] === 'IDENTIFIER') {
|
1377
1466
|
if (!atEqual) {
|
1378
1467
|
prevIdents.push(prevToken[1]);
|
1379
|
-
} else if (
|
1468
|
+
} else if (ref = prevToken[1], indexOf.call(idents, ref) >= 0) {
|
1380
1469
|
return;
|
1381
1470
|
}
|
1382
1471
|
}
|
1383
|
-
if (((
|
1472
|
+
if (((ref1 = prevToken[0]) === '(' || ref1 === '->' || ref1 === 'TERMINATOR') || (prevToken.newLine != null)) {
|
1384
1473
|
break;
|
1385
1474
|
}
|
1386
1475
|
if (prevToken[0] === '=') {
|
@@ -1396,14 +1485,14 @@ module.exports = EnsureComprehensions = (function() {
|
|
1396
1485
|
};
|
1397
1486
|
|
1398
1487
|
EnsureComprehensions.prototype.findIdents = function(tokenApi) {
|
1399
|
-
var idents, nextToken, peeker,
|
1488
|
+
var idents, nextToken, peeker, ref;
|
1400
1489
|
peeker = 1;
|
1401
1490
|
idents = [];
|
1402
1491
|
while ((nextToken = tokenApi.peek(peeker))) {
|
1403
1492
|
if (nextToken[0] === 'IDENTIFIER') {
|
1404
1493
|
idents.push(nextToken[1]);
|
1405
1494
|
}
|
1406
|
-
if ((
|
1495
|
+
if ((ref = nextToken[0]) === 'FORIN' || ref === 'FOROF') {
|
1407
1496
|
break;
|
1408
1497
|
}
|
1409
1498
|
peeker++;
|
@@ -1416,7 +1505,8 @@ module.exports = EnsureComprehensions = (function() {
|
|
1416
1505
|
})();
|
1417
1506
|
|
1418
1507
|
|
1419
|
-
|
1508
|
+
|
1509
|
+
},{}],17:[function(require,module,exports){
|
1420
1510
|
var Indentation;
|
1421
1511
|
|
1422
1512
|
module.exports = Indentation = (function() {
|
@@ -1435,13 +1525,13 @@ module.exports = Indentation = (function() {
|
|
1435
1525
|
}
|
1436
1526
|
|
1437
1527
|
Indentation.prototype.lintToken = function(token, tokenApi) {
|
1438
|
-
var currentLine, expected, ignoreIndent, isArrayIndent, isInterpIndent, isMultiline, lineNumber, lines, numIndents, previous, previousSymbol,
|
1439
|
-
type = token[0], numIndents = token[1], (
|
1528
|
+
var currentLine, expected, ignoreIndent, isArrayIndent, isInterpIndent, isMultiline, lineNumber, lines, numIndents, previous, previousSymbol, ref, ref1, ref2, type;
|
1529
|
+
type = token[0], numIndents = token[1], (ref = token[2], lineNumber = ref.first_line);
|
1440
1530
|
lines = tokenApi.lines, lineNumber = tokenApi.lineNumber;
|
1441
1531
|
expected = tokenApi.config[this.rule.name].value;
|
1442
1532
|
if (type === '.') {
|
1443
1533
|
currentLine = lines[lineNumber];
|
1444
|
-
if (((
|
1534
|
+
if (((ref1 = currentLine.match(/\S/i)) != null ? ref1[0] : void 0) === '.') {
|
1445
1535
|
return this.handleChain(tokenApi, expected);
|
1446
1536
|
}
|
1447
1537
|
return void 0;
|
@@ -1457,7 +1547,7 @@ module.exports = Indentation = (function() {
|
|
1457
1547
|
isInterpIndent = previous && previous[0] === '+';
|
1458
1548
|
previous = tokenApi.peek(-1);
|
1459
1549
|
isArrayIndent = this.inArray() && (previous != null ? previous.newLine : void 0);
|
1460
|
-
previousSymbol = (
|
1550
|
+
previousSymbol = (ref2 = tokenApi.peek(-1)) != null ? ref2[0] : void 0;
|
1461
1551
|
isMultiline = previousSymbol === '=' || previousSymbol === ',';
|
1462
1552
|
ignoreIndent = isInterpIndent || isArrayIndent || isMultiline;
|
1463
1553
|
numIndents = this.getCorrectIndent(tokenApi);
|
@@ -1482,7 +1572,7 @@ module.exports = Indentation = (function() {
|
|
1482
1572
|
};
|
1483
1573
|
|
1484
1574
|
Indentation.prototype.handleChain = function(tokenApi, expected) {
|
1485
|
-
var callStart, checkNum, currIsIndent, currentLine, currentSpaces, findCallStart, lastCheck, lineNumber, lines, numIndents, prevIsIndent, prevLine, prevNum, prevSpaces,
|
1575
|
+
var callStart, checkNum, currIsIndent, currentLine, currentSpaces, findCallStart, lastCheck, lineNumber, lines, numIndents, prevIsIndent, prevLine, prevNum, prevSpaces, ref, ref1;
|
1486
1576
|
lastCheck = 1;
|
1487
1577
|
callStart = 1;
|
1488
1578
|
prevNum = 1;
|
@@ -1501,8 +1591,8 @@ module.exports = Indentation = (function() {
|
|
1501
1591
|
if (checkNum >= 0) {
|
1502
1592
|
prevLine = lines[checkNum];
|
1503
1593
|
if (prevLine.match(/\S/i)[0] === '.' || checkNum === lastCheck) {
|
1504
|
-
currentSpaces = (
|
1505
|
-
prevSpaces = (
|
1594
|
+
currentSpaces = (ref = currentLine.match(/\S/i)) != null ? ref.index : void 0;
|
1595
|
+
prevSpaces = (ref1 = prevLine.match(/\S/i)) != null ? ref1.index : void 0;
|
1506
1596
|
numIndents = currentSpaces - prevSpaces;
|
1507
1597
|
prevIsIndent = prevSpaces % expected !== 0;
|
1508
1598
|
currIsIndent = currentSpaces % expected !== 0;
|
@@ -1519,17 +1609,17 @@ module.exports = Indentation = (function() {
|
|
1519
1609
|
};
|
1520
1610
|
|
1521
1611
|
Indentation.prototype.getCorrectIndent = function(tokenApi) {
|
1522
|
-
var curIndent, i, lineNumber, lines, prevIndent, prevLine, prevNum,
|
1612
|
+
var curIndent, i, lineNumber, lines, prevIndent, prevLine, prevNum, ref, ref1, ref2, tokens;
|
1523
1613
|
lineNumber = tokenApi.lineNumber, lines = tokenApi.lines, tokens = tokenApi.tokens, i = tokenApi.i;
|
1524
|
-
curIndent = (
|
1614
|
+
curIndent = (ref = lines[lineNumber].match(/\S/)) != null ? ref.index : void 0;
|
1525
1615
|
prevNum = 1;
|
1526
1616
|
while (/^\s*(#|$)/.test(lines[lineNumber - prevNum])) {
|
1527
1617
|
prevNum += 1;
|
1528
1618
|
}
|
1529
1619
|
prevLine = lines[lineNumber - prevNum];
|
1530
|
-
prevIndent = (
|
1620
|
+
prevIndent = (ref1 = prevLine.match(/^(\s*)\./)) != null ? ref1[1].length : void 0;
|
1531
1621
|
if (prevIndent > 0) {
|
1532
|
-
return curIndent - ((
|
1622
|
+
return curIndent - ((ref2 = prevLine.match(/\S/)) != null ? ref2.index : void 0);
|
1533
1623
|
} else {
|
1534
1624
|
return tokens[i][1];
|
1535
1625
|
}
|
@@ -1540,7 +1630,8 @@ module.exports = Indentation = (function() {
|
|
1540
1630
|
})();
|
1541
1631
|
|
1542
1632
|
|
1543
|
-
|
1633
|
+
|
1634
|
+
},{}],18:[function(require,module,exports){
|
1544
1635
|
var LineEndings;
|
1545
1636
|
|
1546
1637
|
module.exports = LineEndings = (function() {
|
@@ -1555,8 +1646,8 @@ module.exports = LineEndings = (function() {
|
|
1555
1646
|
};
|
1556
1647
|
|
1557
1648
|
LineEndings.prototype.lintLine = function(line, lineApi) {
|
1558
|
-
var ending, lastChar,
|
1559
|
-
ending = (
|
1649
|
+
var ending, lastChar, ref, valid;
|
1650
|
+
ending = (ref = lineApi.config[this.rule.name]) != null ? ref.value : void 0;
|
1560
1651
|
if (!ending || lineApi.isLastLine() || !line) {
|
1561
1652
|
return null;
|
1562
1653
|
}
|
@@ -1584,7 +1675,8 @@ module.exports = LineEndings = (function() {
|
|
1584
1675
|
})();
|
1585
1676
|
|
1586
1677
|
|
1587
|
-
|
1678
|
+
|
1679
|
+
},{}],19:[function(require,module,exports){
|
1588
1680
|
var MaxLineLength, regexes;
|
1589
1681
|
|
1590
1682
|
regexes = {
|
@@ -1605,9 +1697,9 @@ module.exports = MaxLineLength = (function() {
|
|
1605
1697
|
};
|
1606
1698
|
|
1607
1699
|
MaxLineLength.prototype.lintLine = function(line, lineApi) {
|
1608
|
-
var limitComments, lineLength, max,
|
1609
|
-
max = (
|
1610
|
-
limitComments = (
|
1700
|
+
var limitComments, lineLength, max, ref, ref1;
|
1701
|
+
max = (ref = lineApi.config[this.rule.name]) != null ? ref.value : void 0;
|
1702
|
+
limitComments = (ref1 = lineApi.config[this.rule.name]) != null ? ref1.limitComments : void 0;
|
1611
1703
|
lineLength = line.trimRight().length;
|
1612
1704
|
if (lineApi.isLiterate() && regexes.literateComment.test(line)) {
|
1613
1705
|
lineLength -= 2;
|
@@ -1629,10 +1721,11 @@ module.exports = MaxLineLength = (function() {
|
|
1629
1721
|
})();
|
1630
1722
|
|
1631
1723
|
|
1632
|
-
|
1724
|
+
|
1725
|
+
},{}],20:[function(require,module,exports){
|
1633
1726
|
var MissingFatArrows, any, containsButIsnt,
|
1634
|
-
|
1635
|
-
|
1727
|
+
bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
|
1728
|
+
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; };
|
1636
1729
|
|
1637
1730
|
any = function(arr, test) {
|
1638
1731
|
return arr.reduce((function(res, elt) {
|
@@ -1657,12 +1750,12 @@ containsButIsnt = function(node, nIsThis, nIsClass) {
|
|
1657
1750
|
|
1658
1751
|
module.exports = MissingFatArrows = (function() {
|
1659
1752
|
function MissingFatArrows() {
|
1660
|
-
this.isFatArrowCode =
|
1661
|
-
this.isThis =
|
1662
|
-
this.isObject =
|
1663
|
-
this.isValue =
|
1664
|
-
this.isClass =
|
1665
|
-
this.isCode =
|
1753
|
+
this.isFatArrowCode = bind(this.isFatArrowCode, this);
|
1754
|
+
this.isThis = bind(this.isThis, this);
|
1755
|
+
this.isObject = bind(this.isObject, this);
|
1756
|
+
this.isValue = bind(this.isValue, this);
|
1757
|
+
this.isClass = bind(this.isClass, this);
|
1758
|
+
this.isCode = bind(this.isCode, this);
|
1666
1759
|
}
|
1667
1760
|
|
1668
1761
|
MissingFatArrows.prototype.rule = {
|
@@ -1683,7 +1776,7 @@ module.exports = MissingFatArrows = (function() {
|
|
1683
1776
|
if (methods == null) {
|
1684
1777
|
methods = [];
|
1685
1778
|
}
|
1686
|
-
if ((!this.isFatArrowCode(node)) && (
|
1779
|
+
if ((!this.isFatArrowCode(node)) && (indexOf.call(methods, node) < 0) && (this.needsFatArrow(node))) {
|
1687
1780
|
error = this.astApi.createError({
|
1688
1781
|
lineNumber: node.locationData.first_line + 1
|
1689
1782
|
});
|
@@ -1755,7 +1848,8 @@ module.exports = MissingFatArrows = (function() {
|
|
1755
1848
|
})();
|
1756
1849
|
|
1757
1850
|
|
1758
|
-
|
1851
|
+
|
1852
|
+
},{}],21:[function(require,module,exports){
|
1759
1853
|
var NewlinesAfterClasses;
|
1760
1854
|
|
1761
1855
|
module.exports = NewlinesAfterClasses = (function() {
|
@@ -1790,7 +1884,8 @@ module.exports = NewlinesAfterClasses = (function() {
|
|
1790
1884
|
})();
|
1791
1885
|
|
1792
1886
|
|
1793
|
-
|
1887
|
+
|
1888
|
+
},{}],22:[function(require,module,exports){
|
1794
1889
|
var NoBackticks;
|
1795
1890
|
|
1796
1891
|
module.exports = NoBackticks = (function() {
|
@@ -1814,7 +1909,8 @@ module.exports = NoBackticks = (function() {
|
|
1814
1909
|
})();
|
1815
1910
|
|
1816
1911
|
|
1817
|
-
|
1912
|
+
|
1913
|
+
},{}],23:[function(require,module,exports){
|
1818
1914
|
var NoDebugger;
|
1819
1915
|
|
1820
1916
|
module.exports = NoDebugger = (function() {
|
@@ -1840,7 +1936,8 @@ module.exports = NoDebugger = (function() {
|
|
1840
1936
|
})();
|
1841
1937
|
|
1842
1938
|
|
1843
|
-
|
1939
|
+
|
1940
|
+
},{}],24:[function(require,module,exports){
|
1844
1941
|
var NoEmptyFunctions, isEmptyCode;
|
1845
1942
|
|
1846
1943
|
isEmptyCode = function(node, astApi) {
|
@@ -1884,7 +1981,8 @@ module.exports = NoEmptyFunctions = (function() {
|
|
1884
1981
|
})();
|
1885
1982
|
|
1886
1983
|
|
1887
|
-
|
1984
|
+
|
1985
|
+
},{}],25:[function(require,module,exports){
|
1888
1986
|
var NoEmptyParamList;
|
1889
1987
|
|
1890
1988
|
module.exports = NoEmptyParamList = (function() {
|
@@ -1910,48 +2008,59 @@ module.exports = NoEmptyParamList = (function() {
|
|
1910
2008
|
})();
|
1911
2009
|
|
1912
2010
|
|
1913
|
-
|
2011
|
+
|
2012
|
+
},{}],26:[function(require,module,exports){
|
1914
2013
|
var NoImplicitBraces;
|
1915
2014
|
|
1916
2015
|
module.exports = NoImplicitBraces = (function() {
|
1917
|
-
function NoImplicitBraces() {}
|
1918
|
-
|
1919
2016
|
NoImplicitBraces.prototype.rule = {
|
1920
2017
|
name: 'no_implicit_braces',
|
1921
2018
|
level: 'ignore',
|
1922
2019
|
message: 'Implicit braces are forbidden',
|
1923
2020
|
strict: true,
|
1924
|
-
description:
|
2021
|
+
description: 'This rule prohibits implicit braces when declaring object literals.\nImplicit braces can make code more difficult to understand,\nespecially when used in combination with optional parenthesis.\n<pre>\n<code># Do you find this code ambiguous? Is it a\n# function call with three arguments or four?\nmyFunction a, b, 1:2, 3:4\n\n# While the same code written in a more\n# explicit manner has no ambiguity.\nmyFunction(a, b, {1:2, 3:4})\n</code>\n</pre>\nImplicit braces are permitted by default, since their use is\nidiomatic CoffeeScript.'
|
1925
2022
|
};
|
1926
2023
|
|
1927
|
-
NoImplicitBraces.prototype.tokens = [
|
2024
|
+
NoImplicitBraces.prototype.tokens = ['{', 'OUTDENT', 'CLASS'];
|
2025
|
+
|
2026
|
+
function NoImplicitBraces() {
|
2027
|
+
this.isClass = false;
|
2028
|
+
this.classBrace = false;
|
2029
|
+
}
|
1928
2030
|
|
1929
2031
|
NoImplicitBraces.prototype.lintToken = function(token, tokenApi) {
|
1930
|
-
var previousToken;
|
2032
|
+
var lineNum, previousToken, type, val;
|
2033
|
+
type = token[0], val = token[1], lineNum = token[2];
|
2034
|
+
if (type === 'OUTDENT' || type === 'CLASS') {
|
2035
|
+
return this.trackClass.apply(this, arguments);
|
2036
|
+
}
|
1931
2037
|
if (token.generated) {
|
2038
|
+
if (this.classBrace) {
|
2039
|
+
this.classBrace = false;
|
2040
|
+
return;
|
2041
|
+
}
|
1932
2042
|
if (!tokenApi.config[this.rule.name].strict) {
|
1933
2043
|
previousToken = tokenApi.peek(-1)[0];
|
1934
2044
|
if (previousToken === 'INDENT') {
|
1935
2045
|
return;
|
1936
2046
|
}
|
1937
2047
|
}
|
1938
|
-
return
|
2048
|
+
return true;
|
1939
2049
|
}
|
1940
2050
|
};
|
1941
2051
|
|
1942
|
-
NoImplicitBraces.prototype.
|
1943
|
-
var
|
1944
|
-
|
1945
|
-
|
1946
|
-
|
1947
|
-
|
1948
|
-
return true;
|
1949
|
-
}
|
1950
|
-
if (t[0] === 'CLASS') {
|
1951
|
-
return null;
|
1952
|
-
}
|
1953
|
-
i -= 1;
|
2052
|
+
NoImplicitBraces.prototype.trackClass = function(token, tokenApi) {
|
2053
|
+
var ln, n0, n1, ref, ref1, ref2;
|
2054
|
+
ref = [token, tokenApi.peek()], (ref1 = ref[0], n0 = ref1[0], ln = ref1[ref1.length - 1]), (ref2 = ref[1], n1 = ref2[0]);
|
2055
|
+
if (n0 === 'OUTDENT' && n1 === 'TERMINATOR') {
|
2056
|
+
this.isClass = false;
|
2057
|
+
this.classBrace = false;
|
1954
2058
|
}
|
2059
|
+
if (n0 === 'CLASS') {
|
2060
|
+
this.isClass = true;
|
2061
|
+
this.classBrace = true;
|
2062
|
+
}
|
2063
|
+
return null;
|
1955
2064
|
};
|
1956
2065
|
|
1957
2066
|
return NoImplicitBraces;
|
@@ -1959,7 +2068,8 @@ module.exports = NoImplicitBraces = (function() {
|
|
1959
2068
|
})();
|
1960
2069
|
|
1961
2070
|
|
1962
|
-
|
2071
|
+
|
2072
|
+
},{}],27:[function(require,module,exports){
|
1963
2073
|
var NoImplicitParens;
|
1964
2074
|
|
1965
2075
|
module.exports = NoImplicitParens = (function() {
|
@@ -2001,7 +2111,8 @@ module.exports = NoImplicitParens = (function() {
|
|
2001
2111
|
})();
|
2002
2112
|
|
2003
2113
|
|
2004
|
-
|
2114
|
+
|
2115
|
+
},{}],28:[function(require,module,exports){
|
2005
2116
|
var NoInterpolationInSingleQuotes;
|
2006
2117
|
|
2007
2118
|
module.exports = NoInterpolationInSingleQuotes = (function() {
|
@@ -2028,7 +2139,8 @@ module.exports = NoInterpolationInSingleQuotes = (function() {
|
|
2028
2139
|
})();
|
2029
2140
|
|
2030
2141
|
|
2031
|
-
|
2142
|
+
|
2143
|
+
},{}],29:[function(require,module,exports){
|
2032
2144
|
var NoPlusPlus;
|
2033
2145
|
|
2034
2146
|
module.exports = NoPlusPlus = (function() {
|
@@ -2054,7 +2166,8 @@ module.exports = NoPlusPlus = (function() {
|
|
2054
2166
|
})();
|
2055
2167
|
|
2056
2168
|
|
2057
|
-
|
2169
|
+
|
2170
|
+
},{}],30:[function(require,module,exports){
|
2058
2171
|
var NoStandAloneAt;
|
2059
2172
|
|
2060
2173
|
module.exports = NoStandAloneAt = (function() {
|
@@ -2090,9 +2203,10 @@ module.exports = NoStandAloneAt = (function() {
|
|
2090
2203
|
})();
|
2091
2204
|
|
2092
2205
|
|
2093
|
-
|
2206
|
+
|
2207
|
+
},{}],31:[function(require,module,exports){
|
2094
2208
|
var NoTabs, indentationRegex,
|
2095
|
-
|
2209
|
+
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; };
|
2096
2210
|
|
2097
2211
|
indentationRegex = /\S/;
|
2098
2212
|
|
@@ -2109,7 +2223,7 @@ module.exports = NoTabs = (function() {
|
|
2109
2223
|
NoTabs.prototype.lintLine = function(line, lineApi) {
|
2110
2224
|
var indentation;
|
2111
2225
|
indentation = line.split(indentationRegex)[0];
|
2112
|
-
if (lineApi.lineHasToken() &&
|
2226
|
+
if (lineApi.lineHasToken() && indexOf.call(indentation, '\t') >= 0) {
|
2113
2227
|
return true;
|
2114
2228
|
} else {
|
2115
2229
|
return null;
|
@@ -2121,7 +2235,8 @@ module.exports = NoTabs = (function() {
|
|
2121
2235
|
})();
|
2122
2236
|
|
2123
2237
|
|
2124
|
-
|
2238
|
+
|
2239
|
+
},{}],32:[function(require,module,exports){
|
2125
2240
|
var NoThrowingStrings;
|
2126
2241
|
|
2127
2242
|
module.exports = NoThrowingStrings = (function() {
|
@@ -2137,9 +2252,9 @@ module.exports = NoThrowingStrings = (function() {
|
|
2137
2252
|
NoThrowingStrings.prototype.tokens = ['THROW'];
|
2138
2253
|
|
2139
2254
|
NoThrowingStrings.prototype.lintToken = function(token, tokenApi) {
|
2140
|
-
var n1,
|
2141
|
-
|
2142
|
-
nextIsString = n1
|
2255
|
+
var n1, nextIsString, ref;
|
2256
|
+
ref = tokenApi.peek(), n1 = ref[0];
|
2257
|
+
nextIsString = n1 === 'STRING' || n1 === 'STRING_START';
|
2143
2258
|
return nextIsString;
|
2144
2259
|
};
|
2145
2260
|
|
@@ -2148,10 +2263,11 @@ module.exports = NoThrowingStrings = (function() {
|
|
2148
2263
|
})();
|
2149
2264
|
|
2150
2265
|
|
2151
|
-
|
2266
|
+
|
2267
|
+
},{}],33:[function(require,module,exports){
|
2152
2268
|
var NoTrailingSemicolons, regexes,
|
2153
|
-
|
2154
|
-
|
2269
|
+
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; },
|
2270
|
+
slice = [].slice;
|
2155
2271
|
|
2156
2272
|
regexes = {
|
2157
2273
|
trailingSemicolon: /;\r?$/
|
@@ -2168,11 +2284,11 @@ module.exports = NoTrailingSemicolons = (function() {
|
|
2168
2284
|
};
|
2169
2285
|
|
2170
2286
|
NoTrailingSemicolons.prototype.lintLine = function(line, lineApi) {
|
2171
|
-
var endPos, first, hasNewLine, hasSemicolon, last, lineTokens, newLine, startCounter, startPos, stopTokens, tokenLen
|
2287
|
+
var endPos, first, hasNewLine, hasSemicolon, i, last, lineTokens, newLine, ref, ref1, startCounter, startPos, stopTokens, tokenLen;
|
2172
2288
|
lineTokens = lineApi.getLineTokens();
|
2173
2289
|
tokenLen = lineTokens.length;
|
2174
2290
|
stopTokens = ['TERMINATOR', 'HERECOMMENT'];
|
2175
|
-
if (tokenLen === 1 && (
|
2291
|
+
if (tokenLen === 1 && (ref = lineTokens[0][0], indexOf.call(stopTokens, ref) >= 0)) {
|
2176
2292
|
return;
|
2177
2293
|
}
|
2178
2294
|
newLine = line;
|
@@ -2188,9 +2304,9 @@ module.exports = NoTrailingSemicolons = (function() {
|
|
2188
2304
|
}
|
2189
2305
|
}
|
2190
2306
|
hasSemicolon = regexes.trailingSemicolon.test(newLine);
|
2191
|
-
first = 2 <= lineTokens.length ?
|
2307
|
+
first = 2 <= lineTokens.length ? slice.call(lineTokens, 0, i = lineTokens.length - 1) : (i = 0, []), last = lineTokens[i++];
|
2192
2308
|
hasNewLine = last && (last.newLine != null);
|
2193
|
-
if (hasSemicolon && !hasNewLine && lineApi.lineHasToken() && !((
|
2309
|
+
if (hasSemicolon && !hasNewLine && lineApi.lineHasToken() && !((ref1 = last[0]) === 'STRING' || ref1 === 'IDENTIFIER' || ref1 === 'STRING_END')) {
|
2194
2310
|
return true;
|
2195
2311
|
}
|
2196
2312
|
};
|
@@ -2200,7 +2316,8 @@ module.exports = NoTrailingSemicolons = (function() {
|
|
2200
2316
|
})();
|
2201
2317
|
|
2202
2318
|
|
2203
|
-
|
2319
|
+
|
2320
|
+
},{}],34:[function(require,module,exports){
|
2204
2321
|
var NoTrailingWhitespace, regexes;
|
2205
2322
|
|
2206
2323
|
regexes = {
|
@@ -2222,14 +2339,14 @@ module.exports = NoTrailingWhitespace = (function() {
|
|
2222
2339
|
};
|
2223
2340
|
|
2224
2341
|
NoTrailingWhitespace.prototype.lintLine = function(line, lineApi) {
|
2225
|
-
var
|
2226
|
-
if (!((
|
2342
|
+
var i, len, ref, ref1, ref2, str, token, tokens;
|
2343
|
+
if (!((ref = lineApi.config['no_trailing_whitespace']) != null ? ref.allowed_in_empty_lines : void 0)) {
|
2227
2344
|
if (regexes.onlySpaces.test(line)) {
|
2228
2345
|
return true;
|
2229
2346
|
}
|
2230
2347
|
}
|
2231
2348
|
if (regexes.trailingWhitespace.test(line)) {
|
2232
|
-
if (!((
|
2349
|
+
if (!((ref1 = lineApi.config['no_trailing_whitespace']) != null ? ref1.allowed_in_comments : void 0)) {
|
2233
2350
|
return true;
|
2234
2351
|
}
|
2235
2352
|
line = line;
|
@@ -2237,19 +2354,19 @@ module.exports = NoTrailingWhitespace = (function() {
|
|
2237
2354
|
if (!tokens) {
|
2238
2355
|
return null;
|
2239
2356
|
}
|
2240
|
-
|
2241
|
-
var
|
2242
|
-
|
2243
|
-
for (
|
2244
|
-
token = tokens[
|
2357
|
+
ref2 = (function() {
|
2358
|
+
var j, len, results;
|
2359
|
+
results = [];
|
2360
|
+
for (j = 0, len = tokens.length; j < len; j++) {
|
2361
|
+
token = tokens[j];
|
2245
2362
|
if (token[0] === 'STRING') {
|
2246
|
-
|
2363
|
+
results.push(token[1]);
|
2247
2364
|
}
|
2248
2365
|
}
|
2249
|
-
return
|
2366
|
+
return results;
|
2250
2367
|
})();
|
2251
|
-
for (
|
2252
|
-
str =
|
2368
|
+
for (i = 0, len = ref2.length; i < len; i++) {
|
2369
|
+
str = ref2[i];
|
2253
2370
|
line = line.replace(str, 'STRING');
|
2254
2371
|
}
|
2255
2372
|
if (!regexes.lineHasComment.test(line)) {
|
@@ -2263,7 +2380,8 @@ module.exports = NoTrailingWhitespace = (function() {
|
|
2263
2380
|
})();
|
2264
2381
|
|
2265
2382
|
|
2266
|
-
|
2383
|
+
|
2384
|
+
},{}],35:[function(require,module,exports){
|
2267
2385
|
var NoUnnecessaryDoubleQuotes;
|
2268
2386
|
|
2269
2387
|
module.exports = NoUnnecessaryDoubleQuotes = (function() {
|
@@ -2276,90 +2394,35 @@ module.exports = NoUnnecessaryDoubleQuotes = (function() {
|
|
2276
2394
|
|
2277
2395
|
function NoUnnecessaryDoubleQuotes() {
|
2278
2396
|
this.regexps = [];
|
2397
|
+
this.isInterpolation = false;
|
2279
2398
|
}
|
2280
2399
|
|
2281
|
-
NoUnnecessaryDoubleQuotes.prototype.tokens = ['STRING'];
|
2400
|
+
NoUnnecessaryDoubleQuotes.prototype.tokens = ['STRING', 'STRING_START', 'STRING_END'];
|
2282
2401
|
|
2283
2402
|
NoUnnecessaryDoubleQuotes.prototype.lintToken = function(token, tokenApi) {
|
2284
|
-
var
|
2285
|
-
tokenValue = token[1];
|
2286
|
-
|
2403
|
+
var hasLegalConstructs, stringValue, tokenValue, type;
|
2404
|
+
type = token[0], tokenValue = token[1];
|
2405
|
+
if (type === 'STRING_START' || type === 'STRING_END') {
|
2406
|
+
return this.trackParens.apply(this, arguments);
|
2407
|
+
}
|
2287
2408
|
stringValue = tokenValue.match(/^\"(.*)\"$/);
|
2288
|
-
if (
|
2289
|
-
this.regexps = this.getBlockRegExps(tokenApi);
|
2290
|
-
}
|
2291
|
-
notInBlock = ((function() {
|
2292
|
-
var _i, _len, _ref, _ref1, _results;
|
2293
|
-
_ref = this.regexps;
|
2294
|
-
_results = [];
|
2295
|
-
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
2296
|
-
_ref1 = _ref[_i], s = _ref1[0], e = _ref1[1];
|
2297
|
-
if ((s < i && i < e)) {
|
2298
|
-
_results.push(1);
|
2299
|
-
}
|
2300
|
-
}
|
2301
|
-
return _results;
|
2302
|
-
}).call(this)).length === 0;
|
2303
|
-
if (!(stringValue && notInBlock)) {
|
2409
|
+
if (!stringValue) {
|
2304
2410
|
return false;
|
2305
2411
|
}
|
2306
|
-
hasLegalConstructs = this.
|
2412
|
+
hasLegalConstructs = this.isInterpolation || this.hasSingleQuote(tokenValue);
|
2307
2413
|
return !hasLegalConstructs;
|
2308
2414
|
};
|
2309
2415
|
|
2310
|
-
NoUnnecessaryDoubleQuotes.prototype.
|
2311
|
-
|
2312
|
-
|
2313
|
-
|
2314
|
-
|
2315
|
-
t = tokens[i];
|
2316
|
-
if (!(t[0] === 'IDENTIFIER' && t[1] === 'RegExp')) {
|
2317
|
-
continue;
|
2318
|
-
}
|
2319
|
-
_ref = t[2], lin = _ref.first_line, col = _ref.first_column;
|
2320
|
-
if (lines[lin].slice(col, +(col + 2) + 1 || 9e9) === "///") {
|
2321
|
-
regexps.push([i, 0]);
|
2322
|
-
}
|
2323
|
-
}
|
2324
|
-
for (idx = _j = 0, _len1 = regexps.length; _j < _len1; idx = ++_j) {
|
2325
|
-
i = regexps[idx][0];
|
2326
|
-
ii = 2;
|
2327
|
-
callEnds = 1;
|
2328
|
-
while (callEnds > 0 && (curTok = tokens[i + ii][0])) {
|
2329
|
-
if (curTok === 'CALL_END') {
|
2330
|
-
callEnds--;
|
2331
|
-
}
|
2332
|
-
if (curTok === 'CALL_START') {
|
2333
|
-
callEnds++;
|
2334
|
-
}
|
2335
|
-
ii++;
|
2336
|
-
}
|
2337
|
-
regexps[idx][1] = i + ii - 1;
|
2338
|
-
}
|
2339
|
-
return regexps;
|
2340
|
-
};
|
2341
|
-
|
2342
|
-
NoUnnecessaryDoubleQuotes.prototype.isInterpolated = function(tokenApi) {
|
2343
|
-
var i, idx, isInterpolated, token, tokenName, _i, _ref;
|
2344
|
-
idx = tokenApi.i;
|
2345
|
-
isInterpolated = false;
|
2346
|
-
for (i = _i = 1; 1 <= idx ? _i <= idx : _i >= idx; i = 1 <= idx ? ++_i : --_i) {
|
2347
|
-
token = tokenApi.peek(-i);
|
2348
|
-
if (token == null) {
|
2349
|
-
break;
|
2350
|
-
}
|
2351
|
-
tokenName = token[0];
|
2352
|
-
if (tokenName === ')' && token.stringEnd) {
|
2353
|
-
break;
|
2354
|
-
} else if (tokenName === '(' && ((_ref = token.origin) != null ? _ref[1] : void 0) === 'string interpolation') {
|
2355
|
-
isInterpolated = true;
|
2356
|
-
break;
|
2357
|
-
}
|
2416
|
+
NoUnnecessaryDoubleQuotes.prototype.trackParens = function(token, tokenApi) {
|
2417
|
+
if (token[0] === 'STRING_START') {
|
2418
|
+
this.isInterpolation = true;
|
2419
|
+
} else if (token[0] === 'STRING_END') {
|
2420
|
+
this.isInterpolation = false;
|
2358
2421
|
}
|
2359
|
-
return
|
2422
|
+
return null;
|
2360
2423
|
};
|
2361
2424
|
|
2362
|
-
NoUnnecessaryDoubleQuotes.prototype.
|
2425
|
+
NoUnnecessaryDoubleQuotes.prototype.hasSingleQuote = function(tokenValue) {
|
2363
2426
|
return tokenValue.indexOf("'") !== -1;
|
2364
2427
|
};
|
2365
2428
|
|
@@ -2368,9 +2431,10 @@ module.exports = NoUnnecessaryDoubleQuotes = (function() {
|
|
2368
2431
|
})();
|
2369
2432
|
|
2370
2433
|
|
2371
|
-
|
2434
|
+
|
2435
|
+
},{}],36:[function(require,module,exports){
|
2372
2436
|
var NoUnnecessaryFatArrows, any,
|
2373
|
-
|
2437
|
+
bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
2374
2438
|
|
2375
2439
|
any = function(arr, test) {
|
2376
2440
|
return arr.reduce((function(res, elt) {
|
@@ -2380,8 +2444,8 @@ any = function(arr, test) {
|
|
2380
2444
|
|
2381
2445
|
module.exports = NoUnnecessaryFatArrows = (function() {
|
2382
2446
|
function NoUnnecessaryFatArrows() {
|
2383
|
-
this.needsFatArrow =
|
2384
|
-
this.isThis =
|
2447
|
+
this.needsFatArrow = bind(this.needsFatArrow, this);
|
2448
|
+
this.isThis = bind(this.isThis, this);
|
2385
2449
|
}
|
2386
2450
|
|
2387
2451
|
NoUnnecessaryFatArrows.prototype.rule = {
|
@@ -2449,15 +2513,16 @@ module.exports = NoUnnecessaryFatArrows = (function() {
|
|
2449
2513
|
})();
|
2450
2514
|
|
2451
2515
|
|
2452
|
-
|
2516
|
+
|
2517
|
+
},{}],37:[function(require,module,exports){
|
2453
2518
|
var NonEmptyConstructorNeedsParens, ParentClass,
|
2454
|
-
|
2455
|
-
|
2519
|
+
extend = 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; },
|
2520
|
+
hasProp = {}.hasOwnProperty;
|
2456
2521
|
|
2457
|
-
ParentClass =
|
2522
|
+
ParentClass = require('./empty_constructor_needs_parens.coffee');
|
2458
2523
|
|
2459
|
-
module.exports = NonEmptyConstructorNeedsParens = (function(
|
2460
|
-
|
2524
|
+
module.exports = NonEmptyConstructorNeedsParens = (function(superClass) {
|
2525
|
+
extend(NonEmptyConstructorNeedsParens, superClass);
|
2461
2526
|
|
2462
2527
|
function NonEmptyConstructorNeedsParens() {
|
2463
2528
|
return NonEmptyConstructorNeedsParens.__super__.constructor.apply(this, arguments);
|
@@ -2481,7 +2546,8 @@ module.exports = NonEmptyConstructorNeedsParens = (function(_super) {
|
|
2481
2546
|
})(ParentClass);
|
2482
2547
|
|
2483
2548
|
|
2484
|
-
|
2549
|
+
|
2550
|
+
},{"./empty_constructor_needs_parens.coffee":15}],38:[function(require,module,exports){
|
2485
2551
|
var RuleProcessor;
|
2486
2552
|
|
2487
2553
|
module.exports = RuleProcessor = (function() {
|
@@ -2498,14 +2564,14 @@ module.exports = RuleProcessor = (function() {
|
|
2498
2564
|
RuleProcessor.prototype.tokens = ['COMPARE', 'UNARY_MATH', 'LOGIC'];
|
2499
2565
|
|
2500
2566
|
RuleProcessor.prototype.lintToken = function(token, tokenApi) {
|
2501
|
-
var actual_token, config, context, first_column, last_column, level, line,
|
2567
|
+
var actual_token, config, context, first_column, last_column, level, line, ref;
|
2502
2568
|
config = tokenApi.config[this.rule.name];
|
2503
2569
|
level = config.level;
|
2504
|
-
|
2570
|
+
ref = token[2], first_column = ref.first_column, last_column = ref.last_column;
|
2505
2571
|
line = tokenApi.lines[tokenApi.lineNumber];
|
2506
2572
|
actual_token = line.slice(first_column, +last_column + 1 || 9e9);
|
2507
2573
|
context = (function() {
|
2508
|
-
var
|
2574
|
+
var ref1, ref2;
|
2509
2575
|
switch (actual_token) {
|
2510
2576
|
case '==':
|
2511
2577
|
return 'Replace "==" with "is"';
|
@@ -2516,10 +2582,10 @@ module.exports = RuleProcessor = (function() {
|
|
2516
2582
|
case '&&':
|
2517
2583
|
return 'Replace "&&" with "and"';
|
2518
2584
|
case '!':
|
2519
|
-
if (((
|
2585
|
+
if (((ref1 = tokenApi.peek(1)) != null ? ref1[0] : void 0) === 'UNARY_MATH') {
|
2520
2586
|
level = config.doubleNotLevel;
|
2521
2587
|
return '"?" is usually better than "!!"';
|
2522
|
-
} else if (((
|
2588
|
+
} else if (((ref2 = tokenApi.peek(-1)) != null ? ref2[0] : void 0) === 'UNARY_MATH') {
|
2523
2589
|
return void 0;
|
2524
2590
|
} else {
|
2525
2591
|
return 'Replace "!" with "not"';
|
@@ -2542,9 +2608,10 @@ module.exports = RuleProcessor = (function() {
|
|
2542
2608
|
})();
|
2543
2609
|
|
2544
2610
|
|
2545
|
-
|
2611
|
+
|
2612
|
+
},{}],39:[function(require,module,exports){
|
2546
2613
|
var SpaceOperators,
|
2547
|
-
|
2614
|
+
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; };
|
2548
2615
|
|
2549
2616
|
module.exports = SpaceOperators = (function() {
|
2550
2617
|
SpaceOperators.prototype.rule = {
|
@@ -2554,23 +2621,23 @@ module.exports = SpaceOperators = (function() {
|
|
2554
2621
|
description: "This rule enforces that operators have space around them."
|
2555
2622
|
};
|
2556
2623
|
|
2557
|
-
SpaceOperators.prototype.tokens = ['+', '-', '=', '**', 'MATH', 'COMPARE', 'LOGIC', 'COMPOUND_ASSIGN', '
|
2624
|
+
SpaceOperators.prototype.tokens = ['+', '-', '=', '**', 'MATH', 'COMPARE', 'LOGIC', 'COMPOUND_ASSIGN', 'STRING_START', 'STRING_END', 'CALL_START', 'CALL_END'];
|
2558
2625
|
|
2559
2626
|
function SpaceOperators() {
|
2560
2627
|
this.callTokens = [];
|
2561
2628
|
this.parenTokens = [];
|
2629
|
+
this.isInterpolation = false;
|
2562
2630
|
}
|
2563
2631
|
|
2564
|
-
SpaceOperators.prototype.lintToken = function(
|
2632
|
+
SpaceOperators.prototype.lintToken = function(arg, tokenApi) {
|
2565
2633
|
var type;
|
2566
|
-
type =
|
2634
|
+
type = arg[0];
|
2567
2635
|
if (type === 'CALL_START' || type === 'CALL_END') {
|
2568
|
-
this.
|
2569
|
-
return
|
2636
|
+
this.trackCall.apply(this, arguments);
|
2637
|
+
return;
|
2570
2638
|
}
|
2571
|
-
if (type === '
|
2572
|
-
this.
|
2573
|
-
return void 0;
|
2639
|
+
if (type === 'STRING_START' || type === 'STRING_END') {
|
2640
|
+
return this.trackParens.apply(this, arguments);
|
2574
2641
|
}
|
2575
2642
|
if (type === '+' || type === '-') {
|
2576
2643
|
return this.lintPlus.apply(this, arguments);
|
@@ -2580,14 +2647,14 @@ module.exports = SpaceOperators = (function() {
|
|
2580
2647
|
};
|
2581
2648
|
|
2582
2649
|
SpaceOperators.prototype.lintPlus = function(token, tokenApi) {
|
2583
|
-
var isUnary, p,
|
2584
|
-
if (this.
|
2650
|
+
var isUnary, p, ref, unaries;
|
2651
|
+
if (this.isInterpolation || this.isInExtendedRegex()) {
|
2585
2652
|
return null;
|
2586
2653
|
}
|
2587
2654
|
p = tokenApi.peek(-1);
|
2588
2655
|
unaries = ['TERMINATOR', '(', '=', '-', '+', ',', 'CALL_START', 'INDEX_START', '..', '...', 'COMPARE', 'IF', 'THROW', 'LOGIC', 'POST_IF', ':', '[', 'INDENT', 'COMPOUND_ASSIGN', 'RETURN', 'MATH', 'BY', 'LEADING_WHEN'];
|
2589
|
-
isUnary = !p ? false : (
|
2590
|
-
if ((isUnary && token.spaced) || (!isUnary && !token.newLine && (!token.spaced || (p && !p.spaced)))) {
|
2656
|
+
isUnary = !p ? false : (ref = p[0], indexOf.call(unaries, ref) >= 0);
|
2657
|
+
if ((isUnary && (token.spaced != null)) || (!isUnary && !token.newLine && (!token.spaced || (p && !p.spaced)))) {
|
2591
2658
|
return {
|
2592
2659
|
context: token[1]
|
2593
2660
|
};
|
@@ -2609,10 +2676,10 @@ module.exports = SpaceOperators = (function() {
|
|
2609
2676
|
};
|
2610
2677
|
|
2611
2678
|
SpaceOperators.prototype.isInExtendedRegex = function() {
|
2612
|
-
var
|
2613
|
-
|
2614
|
-
for (
|
2615
|
-
t =
|
2679
|
+
var i, len, ref, t;
|
2680
|
+
ref = this.callTokens;
|
2681
|
+
for (i = 0, len = ref.length; i < len; i++) {
|
2682
|
+
t = ref[i];
|
2616
2683
|
if (t.isRegex) {
|
2617
2684
|
return true;
|
2618
2685
|
}
|
@@ -2620,7 +2687,7 @@ module.exports = SpaceOperators = (function() {
|
|
2620
2687
|
return false;
|
2621
2688
|
};
|
2622
2689
|
|
2623
|
-
SpaceOperators.prototype.
|
2690
|
+
SpaceOperators.prototype.trackCall = function(token, tokenApi) {
|
2624
2691
|
var p;
|
2625
2692
|
if (token[0] === 'CALL_START') {
|
2626
2693
|
p = tokenApi.peek(-1);
|
@@ -2632,29 +2699,11 @@ module.exports = SpaceOperators = (function() {
|
|
2632
2699
|
return null;
|
2633
2700
|
};
|
2634
2701
|
|
2635
|
-
SpaceOperators.prototype.
|
2636
|
-
|
2637
|
-
|
2638
|
-
|
2639
|
-
|
2640
|
-
if (t.isInterpolation) {
|
2641
|
-
return true;
|
2642
|
-
}
|
2643
|
-
}
|
2644
|
-
return false;
|
2645
|
-
};
|
2646
|
-
|
2647
|
-
SpaceOperators.prototype.lintParens = function(token, tokenApi) {
|
2648
|
-
var i, n1, n2, p1;
|
2649
|
-
if (token[0] === '(') {
|
2650
|
-
p1 = tokenApi.peek(-1);
|
2651
|
-
n1 = tokenApi.peek(1);
|
2652
|
-
n2 = tokenApi.peek(2);
|
2653
|
-
i = n1 && n2 && n1[0] === 'STRING' && n2[0] === '+';
|
2654
|
-
token.isInterpolation = i;
|
2655
|
-
this.parenTokens.push(token);
|
2656
|
-
} else {
|
2657
|
-
this.parenTokens.pop();
|
2702
|
+
SpaceOperators.prototype.trackParens = function(token, tokenApi) {
|
2703
|
+
if (token[0] === 'STRING_START') {
|
2704
|
+
this.isInterpolation = true;
|
2705
|
+
} else if (token[0] === 'STRING_END') {
|
2706
|
+
this.isInterpolation = false;
|
2658
2707
|
}
|
2659
2708
|
return null;
|
2660
2709
|
};
|
@@ -2664,7 +2713,8 @@ module.exports = SpaceOperators = (function() {
|
|
2664
2713
|
})();
|
2665
2714
|
|
2666
2715
|
|
2667
|
-
|
2716
|
+
|
2717
|
+
},{}],40:[function(require,module,exports){
|
2668
2718
|
var RuleProcessor;
|
2669
2719
|
|
2670
2720
|
module.exports = RuleProcessor = (function() {
|
@@ -2692,7 +2742,8 @@ module.exports = RuleProcessor = (function() {
|
|
2692
2742
|
})();
|
2693
2743
|
|
2694
2744
|
|
2695
|
-
|
2745
|
+
|
2746
|
+
},{}],41:[function(require,module,exports){
|
2696
2747
|
var CamelCaseClasses;
|
2697
2748
|
|
2698
2749
|
module.exports = CamelCaseClasses = (function() {
|
@@ -2714,6 +2765,6 @@ module.exports = CamelCaseClasses = (function() {
|
|
2714
2765
|
})();
|
2715
2766
|
|
2716
2767
|
|
2717
|
-
|
2718
|
-
(
|
2768
|
+
|
2769
|
+
},{}]},{},[1])(1)
|
2719
2770
|
});
|