coffeelint 1.14.0 → 1.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +1 -1
- data/coffeelint.gemspec +1 -1
- data/coffeelint/lib/coffeelint.js +599 -571
- data/lib/coffeelint/version.rb +1 -1
- metadata +24 -36
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 532d82c2d2fe20d9f07bff65000dbc91ed408336
|
4
|
+
data.tar.gz: 0cc1a24400c1af0eae57410387d7701d6919f06d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c3e602fc00f1c43c67697aa734fff50bb353d2a894114139e533876724cf50338a8e43767a149e852c51adebf2bdd53dcf102d9326696142a77126b6de552866
|
7
|
+
data.tar.gz: 4734c6006186eaef06a21ec1d9fcb0d050657526ab0f05af472a551924f4a0bebf356962a29e2d0bc9f9ef4500da5805c354b540fa30783e8a0ea2baed0119f2
|
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.16.0
|
4
4
|
|
5
5
|
Coffeelint is a set of simple ruby bindings for [coffeelint](https://github.com/clutchski/coffeelint).
|
6
6
|
|
data/coffeelint.gemspec
CHANGED
@@ -1,48 +1,191 @@
|
|
1
|
-
|
1
|
+
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.coffeelint = f()}})(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){
|
2
|
+
module.exports={
|
3
|
+
"name": "coffeelint",
|
4
|
+
"description": "Lint your CoffeeScript",
|
5
|
+
"version": "1.16.0",
|
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": "^13.1.0",
|
27
|
+
"coffee-script": "~1.11.0",
|
28
|
+
"coffeeify": "~1.0.0",
|
29
|
+
"glob": "^7.0.6",
|
30
|
+
"ignore": "^3.0.9",
|
31
|
+
"optimist": "^0.6.1",
|
32
|
+
"resolve": "^0.6.3",
|
33
|
+
"strip-json-comments": "^1.0.2"
|
34
|
+
},
|
35
|
+
"devDependencies": {
|
36
|
+
"vows": ">=0.8.1",
|
37
|
+
"underscore": ">=1.4.4"
|
38
|
+
},
|
39
|
+
"license": "MIT",
|
40
|
+
"scripts": {
|
41
|
+
"pretest": "cake compile",
|
42
|
+
"test": "./vowsrunner.js --spec test/*.coffee test/*.litcoffee",
|
43
|
+
"testrule": "npm run compile && ./vowsrunner.js --spec",
|
44
|
+
"posttest": "npm run lint",
|
45
|
+
"prepublish": "cake prepublish",
|
46
|
+
"postpublish": "cake postpublish",
|
47
|
+
"publish": "cake publish",
|
48
|
+
"install": "cake install",
|
49
|
+
"lint": "cake compile && ./bin/coffeelint .",
|
50
|
+
"lint-csv": "cake compile && ./bin/coffeelint --csv .",
|
51
|
+
"lint-jslint": "cake compile && ./bin/coffeelint --jslint .",
|
52
|
+
"compile": "cake compile"
|
53
|
+
}
|
54
|
+
}
|
2
55
|
|
3
|
-
|
4
|
-
|
56
|
+
},{}],2:[function(require,module,exports){
|
57
|
+
var ASTApi, ASTLinter, BaseLinter, hasChildren, node_children,
|
58
|
+
hasProp = {}.hasOwnProperty,
|
59
|
+
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; };
|
5
60
|
|
6
|
-
|
7
|
-
CoffeeLint is freely distributable under the MIT license.
|
8
|
-
*/
|
9
|
-
var ASTLinter, CoffeeScript, ERROR, ErrorReport, IGNORE, LexicalLinter, LineLinter, RULES, WARN, _rules, cache, coffeelint, defaults, difference, extend, hasSyntaxError, mergeDefaultConfig, nodeRequire, packageJSON, sameJSON,
|
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; };
|
61
|
+
BaseLinter = require('./base_linter.coffee');
|
12
62
|
|
13
|
-
|
63
|
+
node_children = {
|
64
|
+
Class: ['variable', 'parent', 'body'],
|
65
|
+
Code: ['params', 'body'],
|
66
|
+
For: ['body', 'source', 'guard', 'step'],
|
67
|
+
If: ['condition', 'body', 'elseBody'],
|
68
|
+
Obj: ['properties'],
|
69
|
+
Op: ['first', 'second'],
|
70
|
+
Switch: ['subject', 'cases', 'otherwise'],
|
71
|
+
Try: ['attempt', 'recovery', 'ensure'],
|
72
|
+
Value: ['base', 'properties'],
|
73
|
+
While: ['condition', 'guard', 'body']
|
74
|
+
};
|
14
75
|
|
15
|
-
|
76
|
+
hasChildren = function(node, children) {
|
77
|
+
var ref;
|
78
|
+
return (node != null ? (ref = node.children) != null ? ref.length : void 0 : void 0) === children.length && (node != null ? node.children.every(function(elem, i) {
|
79
|
+
return elem === children[i];
|
80
|
+
}) : void 0);
|
81
|
+
};
|
16
82
|
|
17
|
-
|
18
|
-
|
19
|
-
|
83
|
+
ASTApi = (function() {
|
84
|
+
function ASTApi(config1) {
|
85
|
+
this.config = config1;
|
86
|
+
}
|
20
87
|
|
21
|
-
|
22
|
-
|
23
|
-
|
88
|
+
ASTApi.prototype.getNodeName = function(node) {
|
89
|
+
var children, name, ref;
|
90
|
+
name = node != null ? (ref = node.constructor) != null ? ref.name : void 0 : void 0;
|
91
|
+
if (node_children[name]) {
|
92
|
+
return name;
|
93
|
+
} else {
|
94
|
+
for (name in node_children) {
|
95
|
+
if (!hasProp.call(node_children, name)) continue;
|
96
|
+
children = node_children[name];
|
97
|
+
if (hasChildren(node, children)) {
|
98
|
+
return name;
|
99
|
+
}
|
100
|
+
}
|
101
|
+
}
|
102
|
+
};
|
24
103
|
|
25
|
-
|
26
|
-
throw new Error('Unable to find CoffeeScript');
|
27
|
-
}
|
104
|
+
return ASTApi;
|
28
105
|
|
29
|
-
|
106
|
+
})();
|
30
107
|
|
31
|
-
|
108
|
+
module.exports = ASTLinter = (function(superClass) {
|
109
|
+
extend(ASTLinter, superClass);
|
32
110
|
|
33
|
-
|
111
|
+
function ASTLinter(source, config, rules, CoffeeScript) {
|
112
|
+
this.CoffeeScript = CoffeeScript;
|
113
|
+
ASTLinter.__super__.constructor.call(this, source, config, rules);
|
114
|
+
this.astApi = new ASTApi(this.config);
|
115
|
+
}
|
34
116
|
|
35
|
-
|
117
|
+
ASTLinter.prototype.acceptRule = function(rule) {
|
118
|
+
return typeof rule.lintAST === 'function';
|
119
|
+
};
|
36
120
|
|
37
|
-
|
121
|
+
ASTLinter.prototype.lint = function() {
|
122
|
+
var coffeeError, err, errors, j, len, ref, rule, v;
|
123
|
+
errors = [];
|
124
|
+
try {
|
125
|
+
this.node = this.CoffeeScript.nodes(this.source);
|
126
|
+
} catch (error) {
|
127
|
+
coffeeError = error;
|
128
|
+
err = this._parseCoffeeScriptError(coffeeError);
|
129
|
+
if (err != null) {
|
130
|
+
errors.push(err);
|
131
|
+
}
|
132
|
+
return errors;
|
133
|
+
}
|
134
|
+
ref = this.rules;
|
135
|
+
for (j = 0, len = ref.length; j < len; j++) {
|
136
|
+
rule = ref[j];
|
137
|
+
this.astApi.createError = (function(_this) {
|
138
|
+
return function(attrs) {
|
139
|
+
if (attrs == null) {
|
140
|
+
attrs = {};
|
141
|
+
}
|
142
|
+
return _this.createError(rule.rule.name, attrs);
|
143
|
+
};
|
144
|
+
})(this);
|
145
|
+
rule.errors = errors;
|
146
|
+
v = this.normalizeResult(rule, rule.lintAST(this.node, this.astApi));
|
147
|
+
if (v != null) {
|
148
|
+
return v;
|
149
|
+
}
|
150
|
+
}
|
151
|
+
return errors;
|
152
|
+
};
|
153
|
+
|
154
|
+
ASTLinter.prototype._parseCoffeeScriptError = function(coffeeError) {
|
155
|
+
var attrs, lineNumber, match, message, rule;
|
156
|
+
rule = this.config['coffeescript_error'];
|
157
|
+
message = coffeeError.toString();
|
158
|
+
lineNumber = -1;
|
159
|
+
if (coffeeError.location != null) {
|
160
|
+
lineNumber = coffeeError.location.first_line + 1;
|
161
|
+
} else {
|
162
|
+
match = /line (\d+)/.exec(message);
|
163
|
+
if ((match != null ? match.length : void 0) > 1) {
|
164
|
+
lineNumber = parseInt(match[1], 10);
|
165
|
+
}
|
166
|
+
}
|
167
|
+
attrs = {
|
168
|
+
message: message,
|
169
|
+
level: rule.level,
|
170
|
+
lineNumber: lineNumber
|
171
|
+
};
|
172
|
+
return this.createError('coffeescript_error', attrs);
|
173
|
+
};
|
174
|
+
|
175
|
+
return ASTLinter;
|
176
|
+
|
177
|
+
})(BaseLinter);
|
38
178
|
|
39
|
-
|
179
|
+
|
180
|
+
},{"./base_linter.coffee":3}],3:[function(require,module,exports){
|
181
|
+
var BaseLinter, defaults, extend,
|
182
|
+
slice = [].slice;
|
40
183
|
|
41
184
|
extend = function() {
|
42
|
-
var destination, k, len,
|
185
|
+
var destination, i, k, len, source, sources, v;
|
43
186
|
destination = arguments[0], sources = 2 <= arguments.length ? slice.call(arguments, 1) : [];
|
44
|
-
for (
|
45
|
-
source = sources[
|
187
|
+
for (i = 0, len = sources.length; i < len; i++) {
|
188
|
+
source = sources[i];
|
46
189
|
for (k in source) {
|
47
190
|
v = source[k];
|
48
191
|
destination[k] = v;
|
@@ -55,37 +198,182 @@ defaults = function(source, defaults) {
|
|
55
198
|
return extend({}, defaults, source);
|
56
199
|
};
|
57
200
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
if (ref = a[j], indexOf.call(b, ref) >= 0) {
|
64
|
-
results.push(a.splice(j, 1));
|
65
|
-
} else {
|
66
|
-
results.push(j++);
|
67
|
-
}
|
201
|
+
module.exports = BaseLinter = (function() {
|
202
|
+
function BaseLinter(source1, config, rules) {
|
203
|
+
this.source = source1;
|
204
|
+
this.config = config;
|
205
|
+
this.setupRules(rules);
|
68
206
|
}
|
69
|
-
return results;
|
70
|
-
};
|
71
207
|
|
72
|
-
|
208
|
+
BaseLinter.prototype.isObject = function(obj) {
|
209
|
+
return obj === Object(obj);
|
210
|
+
};
|
73
211
|
|
74
|
-
|
212
|
+
BaseLinter.prototype.createError = function(ruleName, attrs) {
|
213
|
+
var level;
|
214
|
+
if (attrs == null) {
|
215
|
+
attrs = {};
|
216
|
+
}
|
217
|
+
if (attrs.level == null) {
|
218
|
+
attrs.level = this.config[ruleName].level;
|
219
|
+
}
|
220
|
+
level = attrs.level;
|
221
|
+
if (level !== 'ignore' && level !== 'warn' && level !== 'error') {
|
222
|
+
throw new Error("unknown level " + level + " for rule: " + ruleName);
|
223
|
+
}
|
224
|
+
if (level === 'error' || level === 'warn') {
|
225
|
+
attrs.rule = ruleName;
|
226
|
+
return defaults(attrs, this.config[ruleName]);
|
227
|
+
} else {
|
228
|
+
return null;
|
229
|
+
}
|
230
|
+
};
|
75
231
|
|
76
|
-
|
232
|
+
BaseLinter.prototype.acceptRule = function(rule) {
|
233
|
+
throw new Error('acceptRule needs to be overridden in the subclass');
|
234
|
+
};
|
77
235
|
|
78
|
-
|
236
|
+
BaseLinter.prototype.setupRules = function(rules) {
|
237
|
+
var RuleConstructor, level, name, results, rule;
|
238
|
+
this.rules = [];
|
239
|
+
results = [];
|
240
|
+
for (name in rules) {
|
241
|
+
RuleConstructor = rules[name];
|
242
|
+
level = this.config[name].level;
|
243
|
+
if (level === 'error' || level === 'warn') {
|
244
|
+
rule = new RuleConstructor(this, this.config);
|
245
|
+
if (this.acceptRule(rule)) {
|
246
|
+
results.push(this.rules.push(rule));
|
247
|
+
} else {
|
248
|
+
results.push(void 0);
|
249
|
+
}
|
250
|
+
} else if (level !== 'ignore') {
|
251
|
+
throw new Error("unknown level " + level + " for rule: " + rule);
|
252
|
+
} else {
|
253
|
+
results.push(void 0);
|
254
|
+
}
|
255
|
+
}
|
256
|
+
return results;
|
257
|
+
};
|
79
258
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
259
|
+
BaseLinter.prototype.normalizeResult = function(p, result) {
|
260
|
+
if (result === true) {
|
261
|
+
return this.createError(p.rule.name);
|
262
|
+
}
|
263
|
+
if (this.isObject(result)) {
|
264
|
+
return this.createError(p.rule.name, result);
|
265
|
+
}
|
266
|
+
};
|
267
|
+
|
268
|
+
return BaseLinter;
|
269
|
+
|
270
|
+
})();
|
271
|
+
|
272
|
+
|
273
|
+
},{}],4:[function(require,module,exports){
|
274
|
+
|
275
|
+
/*
|
276
|
+
CoffeeLint
|
277
|
+
|
278
|
+
Copyright (c) 2011 Matthew Perpick.
|
279
|
+
CoffeeLint is freely distributable under the MIT license.
|
280
|
+
*/
|
281
|
+
var ASTLinter, CoffeeScript, ERROR, ErrorReport, IGNORE, LexicalLinter, LineLinter, RULES, WARN, _rules, cache, coffeelint, defaults, difference, extend, hasSyntaxError, mergeDefaultConfig, nodeRequire, packageJSON, sameJSON, union,
|
282
|
+
slice = [].slice,
|
283
|
+
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; };
|
284
|
+
|
285
|
+
coffeelint = exports;
|
286
|
+
|
287
|
+
nodeRequire = require;
|
288
|
+
|
289
|
+
if (typeof window !== "undefined" && window !== null) {
|
290
|
+
CoffeeScript = window.CoffeeScript;
|
291
|
+
}
|
292
|
+
|
293
|
+
if (CoffeeScript == null) {
|
294
|
+
CoffeeScript = nodeRequire('coffee-script');
|
295
|
+
}
|
296
|
+
|
297
|
+
if (CoffeeScript == null) {
|
298
|
+
throw new Error('Unable to find CoffeeScript');
|
299
|
+
}
|
300
|
+
|
301
|
+
packageJSON = require('./../package.json');
|
302
|
+
|
303
|
+
coffeelint.VERSION = packageJSON.version;
|
304
|
+
|
305
|
+
ERROR = 'error';
|
306
|
+
|
307
|
+
WARN = 'warn';
|
308
|
+
|
309
|
+
IGNORE = 'ignore';
|
310
|
+
|
311
|
+
coffeelint.RULES = RULES = require('./rules.coffee');
|
312
|
+
|
313
|
+
extend = function() {
|
314
|
+
var destination, j, k, len, source, sources, v;
|
315
|
+
destination = arguments[0], sources = 2 <= arguments.length ? slice.call(arguments, 1) : [];
|
316
|
+
for (j = 0, len = sources.length; j < len; j++) {
|
317
|
+
source = sources[j];
|
318
|
+
for (k in source) {
|
319
|
+
v = source[k];
|
320
|
+
destination[k] = v;
|
321
|
+
}
|
322
|
+
}
|
323
|
+
return destination;
|
324
|
+
};
|
325
|
+
|
326
|
+
defaults = function(source, defaults) {
|
327
|
+
return extend({}, defaults, source);
|
328
|
+
};
|
329
|
+
|
330
|
+
union = function(a, b) {
|
331
|
+
var c, j, len, len1, n, results, x;
|
332
|
+
c = {};
|
333
|
+
for (j = 0, len = a.length; j < len; j++) {
|
334
|
+
x = a[j];
|
335
|
+
c[x] = true;
|
336
|
+
}
|
337
|
+
for (n = 0, len1 = b.length; n < len1; n++) {
|
338
|
+
x = b[n];
|
339
|
+
c[x] = true;
|
340
|
+
}
|
341
|
+
results = [];
|
342
|
+
for (x in c) {
|
343
|
+
results.push(x);
|
344
|
+
}
|
345
|
+
return results;
|
346
|
+
};
|
347
|
+
|
348
|
+
difference = function(a, b) {
|
349
|
+
var j, len, results, x;
|
350
|
+
results = [];
|
351
|
+
for (j = 0, len = a.length; j < len; j++) {
|
352
|
+
x = a[j];
|
353
|
+
if (indexOf.call(b, x) < 0) {
|
354
|
+
results.push(x);
|
355
|
+
}
|
356
|
+
}
|
357
|
+
return results;
|
358
|
+
};
|
359
|
+
|
360
|
+
LineLinter = require('./line_linter.coffee');
|
361
|
+
|
362
|
+
LexicalLinter = require('./lexical_linter.coffee');
|
363
|
+
|
364
|
+
ASTLinter = require('./ast_linter.coffee');
|
365
|
+
|
366
|
+
cache = null;
|
367
|
+
|
368
|
+
mergeDefaultConfig = function(userConfig) {
|
369
|
+
var config, rule, ruleConfig, ruleLoader;
|
370
|
+
try {
|
371
|
+
ruleLoader = nodeRequire('./ruleLoader');
|
372
|
+
ruleLoader.loadFromConfig(coffeelint, userConfig);
|
373
|
+
} catch (error) {}
|
374
|
+
config = {};
|
375
|
+
if (userConfig.coffeelint) {
|
376
|
+
config.coffeelint = userConfig.coffeelint;
|
89
377
|
}
|
90
378
|
for (rule in RULES) {
|
91
379
|
ruleConfig = RULES[rule];
|
@@ -139,16 +427,16 @@ coffeelint.trimConfig = function(userConfig) {
|
|
139
427
|
};
|
140
428
|
|
141
429
|
coffeelint.invertLiterate = function(source) {
|
142
|
-
var len, line,
|
430
|
+
var j, len, line, newSource, ref;
|
143
431
|
source = CoffeeScript.helpers.invertLiterate(source);
|
144
432
|
newSource = '';
|
145
433
|
ref = source.split('\n');
|
146
|
-
for (
|
147
|
-
line = ref[
|
434
|
+
for (j = 0, len = ref.length; j < len; j++) {
|
435
|
+
line = ref[j];
|
148
436
|
if (line.match(/^#/)) {
|
149
437
|
line = line.replace(/\s*$/, '');
|
150
438
|
}
|
151
|
-
line = line.replace(
|
439
|
+
line = line.replace(/^[ ]{4}|^\t/g, '');
|
152
440
|
newSource += line + "\n";
|
153
441
|
}
|
154
442
|
return newSource;
|
@@ -196,11 +484,11 @@ coffeelint.registerRule = function(RuleConstructor, ruleName) {
|
|
196
484
|
};
|
197
485
|
|
198
486
|
coffeelint.getRules = function() {
|
199
|
-
var key, len,
|
487
|
+
var j, key, len, output, ref;
|
200
488
|
output = {};
|
201
489
|
ref = Object.keys(RULES).sort();
|
202
|
-
for (
|
203
|
-
key = ref[
|
490
|
+
for (j = 0, len = ref.length; j < len; j++) {
|
491
|
+
key = ref[j];
|
204
492
|
output[key] = RULES[key];
|
205
493
|
}
|
206
494
|
return output;
|
@@ -266,440 +554,193 @@ coffeelint.registerRule(require('./rules/no_interpolation_in_single_quotes.coffe
|
|
266
554
|
|
267
555
|
coffeelint.registerRule(require('./rules/no_empty_functions.coffee'));
|
268
556
|
|
269
|
-
coffeelint.registerRule(require('./rules/prefer_english_operator.coffee'));
|
270
|
-
|
271
|
-
coffeelint.registerRule(require('./rules/spacing_after_comma.coffee'));
|
272
|
-
|
273
|
-
coffeelint.registerRule(require('./rules/transform_messes_up_line_numbers.coffee'));
|
274
|
-
|
275
|
-
coffeelint.registerRule(require('./rules/ensure_comprehensions.coffee'));
|
276
|
-
|
277
|
-
coffeelint.registerRule(require('./rules/no_this.coffee'));
|
278
|
-
|
279
|
-
coffeelint.registerRule(require('./rules/eol_last.coffee'));
|
280
|
-
|
281
|
-
coffeelint.registerRule(require('./rules/no_private_function_fat_arrows.coffee'));
|
282
|
-
|
283
|
-
hasSyntaxError = function(source) {
|
284
|
-
try {
|
285
|
-
CoffeeScript.tokens(source);
|
286
|
-
return false;
|
287
|
-
} catch (undefined) {}
|
288
|
-
return true;
|
289
|
-
};
|
290
|
-
|
291
|
-
ErrorReport = require('./error_report.coffee');
|
292
|
-
|
293
|
-
coffeelint.getErrorReport = function() {
|
294
|
-
return new ErrorReport(coffeelint);
|
295
|
-
};
|
296
|
-
|
297
|
-
coffeelint.lint = function(source, userConfig, literate) {
|
298
|
-
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;
|
299
|
-
if (userConfig == null) {
|
300
|
-
userConfig = {};
|
301
|
-
}
|
302
|
-
if (literate == null) {
|
303
|
-
literate = false;
|
304
|
-
}
|
305
|
-
errors = [];
|
306
|
-
if (cache != null) {
|
307
|
-
cache.setConfig(userConfig);
|
308
|
-
}
|
309
|
-
if (cache != null ? cache.has(source) : void 0) {
|
310
|
-
return cache != null ? cache.get(source) : void 0;
|
311
|
-
}
|
312
|
-
config = mergeDefaultConfig(userConfig);
|
313
|
-
if (literate) {
|
314
|
-
source = this.invertLiterate(source);
|
315
|
-
}
|
316
|
-
if ((userConfig != null ? (ref = userConfig.coffeelint) != null ? ref.transforms : void 0 : void 0) != null) {
|
317
|
-
sourceLength = source.split('\n').length;
|
318
|
-
ref2 = userConfig != null ? (ref1 = userConfig.coffeelint) != null ? ref1.transforms : void 0 : void 0;
|
319
|
-
for (n = 0, len = ref2.length; n < len; n++) {
|
320
|
-
m = ref2[n];
|
321
|
-
try {
|
322
|
-
ruleLoader = nodeRequire('./ruleLoader');
|
323
|
-
transform = ruleLoader.require(m);
|
324
|
-
source = transform(source);
|
325
|
-
} catch (undefined) {}
|
326
|
-
}
|
327
|
-
if (sourceLength !== source.split('\n').length && config.transform_messes_up_line_numbers.level !== 'ignore') {
|
328
|
-
errors.push(extend({
|
329
|
-
lineNumber: 1,
|
330
|
-
context: "File was transformed from " + sourceLength + " lines to " + (source.split("\n").length) + " lines"
|
331
|
-
}, config.transform_messes_up_line_numbers));
|
332
|
-
}
|
333
|
-
}
|
334
|
-
if ((userConfig != null ? (ref3 = userConfig.coffeelint) != null ? ref3.coffeescript : void 0 : void 0) != null) {
|
335
|
-
CoffeeScript = ruleLoader.require(userConfig.coffeelint.coffeescript);
|
336
|
-
}
|
337
|
-
for (name in userConfig) {
|
338
|
-
if (name !== 'coffeescript_error' && name !== '_comment') {
|
339
|
-
if (_rules[name] == null) {
|
340
|
-
void 0;
|
341
|
-
}
|
342
|
-
}
|
343
|
-
}
|
344
|
-
disabled_initially = [];
|
345
|
-
ref4 = source.split('\n');
|
346
|
-
for (o = 0, len1 = ref4.length; o < len1; o++) {
|
347
|
-
l = ref4[o];
|
348
|
-
s = LineLinter.configStatement.exec(l);
|
349
|
-
if ((s != null ? s.length : void 0) > 2 && indexOf.call(s, 'enable') >= 0) {
|
350
|
-
ref5 = s.slice(1);
|
351
|
-
for (q = 0, len2 = ref5.length; q < len2; q++) {
|
352
|
-
r = ref5[q];
|
353
|
-
if (r !== 'enable' && r !== 'disable') {
|
354
|
-
if (!(r in config && ((ref6 = config[r].level) === 'warn' || ref6 === 'error'))) {
|
355
|
-
disabled_initially.push(r);
|
356
|
-
config[r] = {
|
357
|
-
level: 'error'
|
358
|
-
};
|
359
|
-
}
|
360
|
-
}
|
361
|
-
}
|
362
|
-
}
|
363
|
-
}
|
364
|
-
astErrors = new ASTLinter(source, config, _rules, CoffeeScript).lint();
|
365
|
-
errors = errors.concat(astErrors);
|
366
|
-
if (!hasSyntaxError(source)) {
|
367
|
-
lexicalLinter = new LexicalLinter(source, config, _rules, CoffeeScript);
|
368
|
-
lexErrors = lexicalLinter.lint();
|
369
|
-
errors = errors.concat(lexErrors);
|
370
|
-
tokensByLine = lexicalLinter.tokensByLine;
|
371
|
-
lineLinter = new LineLinter(source, config, _rules, tokensByLine, literate);
|
372
|
-
lineErrors = lineLinter.lint();
|
373
|
-
errors = errors.concat(lineErrors);
|
374
|
-
block_config = lineLinter.block_config;
|
375
|
-
} else {
|
376
|
-
block_config = {
|
377
|
-
enable: {},
|
378
|
-
disable: {}
|
379
|
-
};
|
380
|
-
}
|
381
|
-
errors.sort(function(a, b) {
|
382
|
-
return a.lineNumber - b.lineNumber;
|
383
|
-
});
|
384
|
-
all_errors = errors;
|
385
|
-
errors = [];
|
386
|
-
disabled = disabled_initially;
|
387
|
-
next_line = 0;
|
388
|
-
for (i = t = 0, ref7 = source.split('\n').length; 0 <= ref7 ? t < ref7 : t > ref7; i = 0 <= ref7 ? ++t : --t) {
|
389
|
-
for (cmd in block_config) {
|
390
|
-
rules = block_config[cmd][i];
|
391
|
-
if (rules != null) {
|
392
|
-
({
|
393
|
-
'disable': function() {
|
394
|
-
return disabled = disabled.concat(rules);
|
395
|
-
},
|
396
|
-
'enable': function() {
|
397
|
-
difference(disabled, rules);
|
398
|
-
if (rules.length === 0) {
|
399
|
-
return disabled = disabled_initially;
|
400
|
-
}
|
401
|
-
}
|
402
|
-
})[cmd]();
|
403
|
-
}
|
404
|
-
}
|
405
|
-
while (next_line === i && all_errors.length > 0) {
|
406
|
-
next_line = all_errors[0].lineNumber - 1;
|
407
|
-
e = all_errors[0];
|
408
|
-
if (e.lineNumber === i + 1 || (e.lineNumber == null)) {
|
409
|
-
e = all_errors.shift();
|
410
|
-
if (ref8 = e.rule, indexOf.call(disabled, ref8) < 0) {
|
411
|
-
errors.push(e);
|
412
|
-
}
|
413
|
-
}
|
414
|
-
}
|
415
|
-
}
|
416
|
-
if (cache != null) {
|
417
|
-
cache.set(source, errors);
|
418
|
-
}
|
419
|
-
return errors;
|
420
|
-
};
|
421
|
-
|
422
|
-
coffeelint.setCache = function(obj) {
|
423
|
-
return cache = obj;
|
424
|
-
};
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
},{"./../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/eol_last.coffee":17,"./rules/indentation.coffee":18,"./rules/line_endings.coffee":19,"./rules/max_line_length.coffee":20,"./rules/missing_fat_arrows.coffee":21,"./rules/newlines_after_classes.coffee":22,"./rules/no_backticks.coffee":23,"./rules/no_debugger.coffee":24,"./rules/no_empty_functions.coffee":25,"./rules/no_empty_param_list.coffee":26,"./rules/no_implicit_braces.coffee":27,"./rules/no_implicit_parens.coffee":28,"./rules/no_interpolation_in_single_quotes.coffee":29,"./rules/no_nested_string_interpolation.coffee":30,"./rules/no_plusplus.coffee":31,"./rules/no_private_function_fat_arrows.coffee":32,"./rules/no_stand_alone_at.coffee":33,"./rules/no_tabs.coffee":34,"./rules/no_this.coffee":35,"./rules/no_throwing_strings.coffee":36,"./rules/no_trailing_semicolons.coffee":37,"./rules/no_trailing_whitespace.coffee":38,"./rules/no_unnecessary_double_quotes.coffee":39,"./rules/no_unnecessary_fat_arrows.coffee":40,"./rules/non_empty_constructor_needs_parens.coffee":41,"./rules/prefer_english_operator.coffee":42,"./rules/space_operators.coffee":43,"./rules/spacing_after_comma.coffee":44,"./rules/transform_messes_up_line_numbers.coffee":45}],2:[function(require,module,exports){
|
429
|
-
module.exports={
|
430
|
-
"name": "coffeelint",
|
431
|
-
"description": "Lint your CoffeeScript",
|
432
|
-
"version": "1.14.0",
|
433
|
-
"homepage": "http://www.coffeelint.org",
|
434
|
-
"keywords": [
|
435
|
-
"lint",
|
436
|
-
"coffeescript",
|
437
|
-
"coffee-script"
|
438
|
-
],
|
439
|
-
"author": "Matthew Perpick <clutchski@gmail.com>",
|
440
|
-
"main": "./lib/coffeelint.js",
|
441
|
-
"engines": {
|
442
|
-
"npm": ">=1.3.7",
|
443
|
-
"node": ">=0.8.0"
|
444
|
-
},
|
445
|
-
"repository": {
|
446
|
-
"type": "git",
|
447
|
-
"url": "git://github.com/clutchski/coffeelint.git"
|
448
|
-
},
|
449
|
-
"bin": {
|
450
|
-
"coffeelint": "./bin/coffeelint"
|
451
|
-
},
|
452
|
-
"dependencies": {
|
453
|
-
"browserify": "~8.1.0",
|
454
|
-
"coffee-script": "^1.9.1",
|
455
|
-
"coffeeify": "~1.0.0",
|
456
|
-
"glob": "^4.0.0",
|
457
|
-
"ignore": "^2.2.15",
|
458
|
-
"optimist": "^0.6.1",
|
459
|
-
"resolve": "^0.6.3",
|
460
|
-
"strip-json-comments": "^1.0.2"
|
461
|
-
},
|
462
|
-
"devDependencies": {
|
463
|
-
"vows": ">=0.6.0",
|
464
|
-
"underscore": ">=1.4.4"
|
465
|
-
},
|
466
|
-
"license": "MIT",
|
467
|
-
"scripts": {
|
468
|
-
"pretest": "cake compile",
|
469
|
-
"test": "./vowsrunner.js --spec test/*.coffee test/*.litcoffee",
|
470
|
-
"testrule": "npm run compile && ./vowsrunner.js --spec",
|
471
|
-
"posttest": "npm run lint",
|
472
|
-
"prepublish": "cake prepublish",
|
473
|
-
"postpublish": "cake postpublish",
|
474
|
-
"publish": "cake publish",
|
475
|
-
"install": "cake install",
|
476
|
-
"lint": "cake compile && ./bin/coffeelint .",
|
477
|
-
"lint-csv": "cake compile && ./bin/coffeelint --csv .",
|
478
|
-
"lint-jslint": "cake compile && ./bin/coffeelint --jslint .",
|
479
|
-
"compile": "cake compile"
|
480
|
-
}
|
481
|
-
}
|
482
|
-
|
483
|
-
},{}],3:[function(require,module,exports){
|
484
|
-
var ASTApi, ASTLinter, BaseLinter, hasChildren, node_children,
|
485
|
-
hasProp = {}.hasOwnProperty,
|
486
|
-
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; };
|
487
|
-
|
488
|
-
BaseLinter = require('./base_linter.coffee');
|
489
|
-
|
490
|
-
node_children = {
|
491
|
-
Class: ['variable', 'parent', 'body'],
|
492
|
-
Code: ['params', 'body'],
|
493
|
-
For: ['body', 'source', 'guard', 'step'],
|
494
|
-
If: ['condition', 'body', 'elseBody'],
|
495
|
-
Obj: ['properties'],
|
496
|
-
Op: ['first', 'second'],
|
497
|
-
Switch: ['subject', 'cases', 'otherwise'],
|
498
|
-
Try: ['attempt', 'recovery', 'ensure'],
|
499
|
-
Value: ['base', 'properties'],
|
500
|
-
While: ['condition', 'guard', 'body']
|
501
|
-
};
|
502
|
-
|
503
|
-
hasChildren = function(node, children) {
|
504
|
-
var ref;
|
505
|
-
return (node != null ? (ref = node.children) != null ? ref.length : void 0 : void 0) === children.length && (node != null ? node.children.every(function(elem, i) {
|
506
|
-
return elem === children[i];
|
507
|
-
}) : void 0);
|
508
|
-
};
|
509
|
-
|
510
|
-
ASTApi = (function() {
|
511
|
-
function ASTApi(config1) {
|
512
|
-
this.config = config1;
|
513
|
-
}
|
514
|
-
|
515
|
-
ASTApi.prototype.getNodeName = function(node) {
|
516
|
-
var children, name, ref;
|
517
|
-
name = node != null ? (ref = node.constructor) != null ? ref.name : void 0 : void 0;
|
518
|
-
if (node_children[name]) {
|
519
|
-
return name;
|
520
|
-
} else {
|
521
|
-
for (name in node_children) {
|
522
|
-
if (!hasProp.call(node_children, name)) continue;
|
523
|
-
children = node_children[name];
|
524
|
-
if (hasChildren(node, children)) {
|
525
|
-
return name;
|
526
|
-
}
|
527
|
-
}
|
528
|
-
}
|
529
|
-
};
|
530
|
-
|
531
|
-
return ASTApi;
|
532
|
-
|
533
|
-
})();
|
534
|
-
|
535
|
-
module.exports = ASTLinter = (function(superClass) {
|
536
|
-
extend(ASTLinter, superClass);
|
537
|
-
|
538
|
-
function ASTLinter(source, config, rules, CoffeeScript) {
|
539
|
-
this.CoffeeScript = CoffeeScript;
|
540
|
-
ASTLinter.__super__.constructor.call(this, source, config, rules);
|
541
|
-
this.astApi = new ASTApi(this.config);
|
542
|
-
}
|
543
|
-
|
544
|
-
ASTLinter.prototype.acceptRule = function(rule) {
|
545
|
-
return typeof rule.lintAST === 'function';
|
546
|
-
};
|
547
|
-
|
548
|
-
ASTLinter.prototype.lint = function() {
|
549
|
-
var coffeeError, err, error, errors, j, len, ref, rule, v;
|
550
|
-
errors = [];
|
551
|
-
try {
|
552
|
-
this.node = this.CoffeeScript.nodes(this.source);
|
553
|
-
} catch (error) {
|
554
|
-
coffeeError = error;
|
555
|
-
err = this._parseCoffeeScriptError(coffeeError);
|
556
|
-
if (err != null) {
|
557
|
-
errors.push(err);
|
558
|
-
}
|
559
|
-
return errors;
|
560
|
-
}
|
561
|
-
ref = this.rules;
|
562
|
-
for (j = 0, len = ref.length; j < len; j++) {
|
563
|
-
rule = ref[j];
|
564
|
-
this.astApi.createError = (function(_this) {
|
565
|
-
return function(attrs) {
|
566
|
-
if (attrs == null) {
|
567
|
-
attrs = {};
|
568
|
-
}
|
569
|
-
return _this.createError(rule.rule.name, attrs);
|
570
|
-
};
|
571
|
-
})(this);
|
572
|
-
rule.errors = errors;
|
573
|
-
v = this.normalizeResult(rule, rule.lintAST(this.node, this.astApi));
|
574
|
-
if (v != null) {
|
575
|
-
return v;
|
576
|
-
}
|
577
|
-
}
|
578
|
-
return errors;
|
579
|
-
};
|
557
|
+
coffeelint.registerRule(require('./rules/prefer_english_operator.coffee'));
|
580
558
|
|
581
|
-
|
582
|
-
var attrs, lineNumber, match, message, rule;
|
583
|
-
rule = this.config['coffeescript_error'];
|
584
|
-
message = coffeeError.toString();
|
585
|
-
lineNumber = -1;
|
586
|
-
if (coffeeError.location != null) {
|
587
|
-
lineNumber = coffeeError.location.first_line + 1;
|
588
|
-
} else {
|
589
|
-
match = /line (\d+)/.exec(message);
|
590
|
-
if ((match != null ? match.length : void 0) > 1) {
|
591
|
-
lineNumber = parseInt(match[1], 10);
|
592
|
-
}
|
593
|
-
}
|
594
|
-
attrs = {
|
595
|
-
message: message,
|
596
|
-
level: rule.level,
|
597
|
-
lineNumber: lineNumber
|
598
|
-
};
|
599
|
-
return this.createError('coffeescript_error', attrs);
|
600
|
-
};
|
559
|
+
coffeelint.registerRule(require('./rules/spacing_after_comma.coffee'));
|
601
560
|
|
602
|
-
|
561
|
+
coffeelint.registerRule(require('./rules/transform_messes_up_line_numbers.coffee'));
|
603
562
|
|
604
|
-
|
563
|
+
coffeelint.registerRule(require('./rules/ensure_comprehensions.coffee'));
|
605
564
|
|
565
|
+
coffeelint.registerRule(require('./rules/no_this.coffee'));
|
606
566
|
|
567
|
+
coffeelint.registerRule(require('./rules/eol_last.coffee'));
|
607
568
|
|
608
|
-
|
609
|
-
var BaseLinter, defaults, extend,
|
610
|
-
slice = [].slice;
|
569
|
+
coffeelint.registerRule(require('./rules/no_private_function_fat_arrows.coffee'));
|
611
570
|
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
v = source[k];
|
619
|
-
destination[k] = v;
|
620
|
-
}
|
621
|
-
}
|
622
|
-
return destination;
|
571
|
+
hasSyntaxError = function(source) {
|
572
|
+
try {
|
573
|
+
CoffeeScript.tokens(source);
|
574
|
+
return false;
|
575
|
+
} catch (error) {}
|
576
|
+
return true;
|
623
577
|
};
|
624
578
|
|
625
|
-
|
626
|
-
|
579
|
+
ErrorReport = require('./error_report.coffee');
|
580
|
+
|
581
|
+
coffeelint.getErrorReport = function() {
|
582
|
+
return new ErrorReport(coffeelint);
|
627
583
|
};
|
628
584
|
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
this.setupRules(rules);
|
585
|
+
coffeelint.lint = function(source, userConfig, literate) {
|
586
|
+
var allErrors, astErrors, cmd, config, disabled, disabledEntirely, disabledInitially, disabledLine, e, errors, i, inlineConfig, j, l, len, len1, lexErrors, lexicalLinter, lineErrors, lineLinter, m, n, name, nextLine, o, ref, ref1, ref2, ref3, ref4, ref5, ref6, ref7, ref8, regex, rule, ruleLoader, rules, set, sourceLength, tokensByLine, transform;
|
587
|
+
if (userConfig == null) {
|
588
|
+
userConfig = {};
|
634
589
|
}
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
590
|
+
if (literate == null) {
|
591
|
+
literate = false;
|
592
|
+
}
|
593
|
+
errors = [];
|
594
|
+
if (cache != null) {
|
595
|
+
cache.setConfig(userConfig);
|
596
|
+
}
|
597
|
+
if (cache != null ? cache.has(source) : void 0) {
|
598
|
+
return cache != null ? cache.get(source) : void 0;
|
599
|
+
}
|
600
|
+
config = mergeDefaultConfig(userConfig);
|
601
|
+
if (literate) {
|
602
|
+
source = this.invertLiterate(source);
|
603
|
+
}
|
604
|
+
if ((userConfig != null ? (ref = userConfig.coffeelint) != null ? ref.transforms : void 0 : void 0) != null) {
|
605
|
+
sourceLength = source.split('\n').length;
|
606
|
+
ref2 = userConfig != null ? (ref1 = userConfig.coffeelint) != null ? ref1.transforms : void 0 : void 0;
|
607
|
+
for (j = 0, len = ref2.length; j < len; j++) {
|
608
|
+
m = ref2[j];
|
609
|
+
try {
|
610
|
+
ruleLoader = nodeRequire('./ruleLoader');
|
611
|
+
transform = ruleLoader.require(m);
|
612
|
+
source = transform(source);
|
613
|
+
} catch (error) {}
|
644
614
|
}
|
645
|
-
if (
|
646
|
-
|
615
|
+
if (sourceLength !== source.split('\n').length && config.transform_messes_up_line_numbers.level !== 'ignore') {
|
616
|
+
errors.push(extend({
|
617
|
+
lineNumber: 1,
|
618
|
+
context: "File was transformed from " + sourceLength + " lines to " + (source.split("\n").length) + " lines"
|
619
|
+
}, config.transform_messes_up_line_numbers));
|
647
620
|
}
|
648
|
-
|
649
|
-
|
650
|
-
|
621
|
+
}
|
622
|
+
if ((userConfig != null ? (ref3 = userConfig.coffeelint) != null ? ref3.coffeescript : void 0 : void 0) != null) {
|
623
|
+
CoffeeScript = ruleLoader.require(userConfig.coffeelint.coffeescript);
|
624
|
+
}
|
625
|
+
for (name in userConfig) {
|
626
|
+
if (name !== 'coffeescript_error' && name !== '_comment') {
|
627
|
+
if (_rules[name] == null) {
|
628
|
+
void 0;
|
629
|
+
}
|
651
630
|
}
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
631
|
+
}
|
632
|
+
disabledInitially = [];
|
633
|
+
ref4 = source.split('\n');
|
634
|
+
for (n = 0, len1 = ref4.length; n < len1; n++) {
|
635
|
+
l = ref4[n];
|
636
|
+
ref5 = LineLinter.getDirective(l) || [], regex = ref5[0], set = ref5[1], rule = ref5[ref5.length - 1];
|
637
|
+
if ((set === 'enable' || set === 'enable-line') && ((ref6 = config[rule]) != null ? ref6.level : void 0) === 'ignore') {
|
638
|
+
disabledInitially.push(rule);
|
639
|
+
config[rule].level = 'error';
|
657
640
|
}
|
658
|
-
}
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
641
|
+
}
|
642
|
+
astErrors = new ASTLinter(source, config, _rules, CoffeeScript).lint();
|
643
|
+
errors = errors.concat(astErrors);
|
644
|
+
if (!hasSyntaxError(source)) {
|
645
|
+
lexicalLinter = new LexicalLinter(source, config, _rules, CoffeeScript);
|
646
|
+
lexErrors = lexicalLinter.lint();
|
647
|
+
errors = errors.concat(lexErrors);
|
648
|
+
tokensByLine = lexicalLinter.tokensByLine;
|
649
|
+
lineLinter = new LineLinter(source, config, _rules, tokensByLine, literate);
|
650
|
+
lineErrors = lineLinter.lint();
|
651
|
+
errors = errors.concat(lineErrors);
|
652
|
+
inlineConfig = lineLinter.inlineConfig;
|
653
|
+
} else {
|
654
|
+
inlineConfig = {
|
655
|
+
enable: {},
|
656
|
+
disable: {},
|
657
|
+
'enable-line': {},
|
658
|
+
'disable-line': {}
|
659
|
+
};
|
660
|
+
}
|
661
|
+
errors.sort(function(a, b) {
|
662
|
+
return a.lineNumber - b.lineNumber;
|
663
|
+
});
|
664
|
+
disabledEntirely = (function() {
|
665
|
+
var len2, map, o, ref7, result;
|
666
|
+
result = [];
|
667
|
+
map = {};
|
668
|
+
ref7 = errors || [];
|
669
|
+
for (o = 0, len2 = ref7.length; o < len2; o++) {
|
670
|
+
name = ref7[o].name;
|
671
|
+
if (!map[name]) {
|
672
|
+
result.push(name);
|
673
|
+
map[name] = true;
|
674
|
+
}
|
675
|
+
}
|
676
|
+
return result;
|
677
|
+
})();
|
678
|
+
allErrors = errors;
|
679
|
+
errors = [];
|
680
|
+
disabled = disabledInitially;
|
681
|
+
nextLine = 0;
|
682
|
+
for (i = o = 0, ref7 = source.split('\n').length; 0 <= ref7 ? o < ref7 : o > ref7; i = 0 <= ref7 ? ++o : --o) {
|
683
|
+
disabledLine = disabled;
|
684
|
+
for (cmd in inlineConfig) {
|
685
|
+
rules = inlineConfig[cmd][i];
|
686
|
+
if (rules != null) {
|
687
|
+
({
|
688
|
+
'disable': function() {
|
689
|
+
if (rules.length) {
|
690
|
+
disabled = union(disabled, rules);
|
691
|
+
return disabledLine = union(disabledLine, rules);
|
692
|
+
} else {
|
693
|
+
return disabled = disabledLine = disabledEntirely;
|
694
|
+
}
|
695
|
+
},
|
696
|
+
'disable-line': function() {
|
697
|
+
if (rules.length) {
|
698
|
+
return disabledLine = union(disabledLine, rules);
|
699
|
+
} else {
|
700
|
+
return disabledLine = disabledEntirely;
|
701
|
+
}
|
702
|
+
},
|
703
|
+
'enable': function() {
|
704
|
+
if (rules.length) {
|
705
|
+
disabled = difference(disabled, rules);
|
706
|
+
return disabledLine = difference(disabledLine, rules);
|
707
|
+
} else {
|
708
|
+
return disabled = disabledLine = disabledInitially;
|
709
|
+
}
|
710
|
+
},
|
711
|
+
'enable-line': function() {
|
712
|
+
if (rules.length) {
|
713
|
+
return disabledLine = difference(disabledLine, rules);
|
714
|
+
} else {
|
715
|
+
return disabledLine = disabledInitially;
|
716
|
+
}
|
717
|
+
}
|
718
|
+
})[cmd]();
|
682
719
|
}
|
683
720
|
}
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
721
|
+
while (nextLine === i && allErrors.length > 0) {
|
722
|
+
nextLine = allErrors[0].lineNumber - 1;
|
723
|
+
e = allErrors[0];
|
724
|
+
if (e.lineNumber === i + 1 || (e.lineNumber == null)) {
|
725
|
+
e = allErrors.shift();
|
726
|
+
if (ref8 = e.rule, indexOf.call(disabledLine, ref8) < 0) {
|
727
|
+
errors.push(e);
|
728
|
+
}
|
729
|
+
}
|
693
730
|
}
|
694
|
-
}
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
731
|
+
}
|
732
|
+
if (cache != null) {
|
733
|
+
cache.set(source, errors);
|
734
|
+
}
|
735
|
+
return errors;
|
736
|
+
};
|
699
737
|
|
738
|
+
coffeelint.setCache = function(obj) {
|
739
|
+
return cache = obj;
|
740
|
+
};
|
700
741
|
|
701
742
|
|
702
|
-
},{}],5:[function(require,module,exports){
|
743
|
+
},{"./../package.json":1,"./ast_linter.coffee":2,"./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/eol_last.coffee":17,"./rules/indentation.coffee":18,"./rules/line_endings.coffee":19,"./rules/max_line_length.coffee":20,"./rules/missing_fat_arrows.coffee":21,"./rules/newlines_after_classes.coffee":22,"./rules/no_backticks.coffee":23,"./rules/no_debugger.coffee":24,"./rules/no_empty_functions.coffee":25,"./rules/no_empty_param_list.coffee":26,"./rules/no_implicit_braces.coffee":27,"./rules/no_implicit_parens.coffee":28,"./rules/no_interpolation_in_single_quotes.coffee":29,"./rules/no_nested_string_interpolation.coffee":30,"./rules/no_plusplus.coffee":31,"./rules/no_private_function_fat_arrows.coffee":32,"./rules/no_stand_alone_at.coffee":33,"./rules/no_tabs.coffee":34,"./rules/no_this.coffee":35,"./rules/no_throwing_strings.coffee":36,"./rules/no_trailing_semicolons.coffee":37,"./rules/no_trailing_whitespace.coffee":38,"./rules/no_unnecessary_double_quotes.coffee":39,"./rules/no_unnecessary_fat_arrows.coffee":40,"./rules/non_empty_constructor_needs_parens.coffee":41,"./rules/prefer_english_operator.coffee":42,"./rules/space_operators.coffee":43,"./rules/spacing_after_comma.coffee":44,"./rules/transform_messes_up_line_numbers.coffee":45}],5:[function(require,module,exports){
|
703
744
|
var ErrorReport;
|
704
745
|
|
705
746
|
module.exports = ErrorReport = (function() {
|
@@ -791,7 +832,6 @@ module.exports = ErrorReport = (function() {
|
|
791
832
|
})();
|
792
833
|
|
793
834
|
|
794
|
-
|
795
835
|
},{}],6:[function(require,module,exports){
|
796
836
|
var BaseLinter, LexicalLinter, TokenApi,
|
797
837
|
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; },
|
@@ -892,9 +932,8 @@ module.exports = LexicalLinter = (function(superClass) {
|
|
892
932
|
})(BaseLinter);
|
893
933
|
|
894
934
|
|
895
|
-
|
896
|
-
|
897
|
-
var BaseLinter, LineApi, LineLinter, configStatement,
|
935
|
+
},{"./base_linter.coffee":3}],7:[function(require,module,exports){
|
936
|
+
var BaseLinter, LineApi, LineLinter, configShortcuts, configStatement,
|
898
937
|
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; },
|
899
938
|
hasProp = {}.hasOwnProperty;
|
900
939
|
|
@@ -988,12 +1027,23 @@ LineApi = (function() {
|
|
988
1027
|
|
989
1028
|
BaseLinter = require('./base_linter.coffee');
|
990
1029
|
|
991
|
-
configStatement = /coffeelint:\s*(disable|enable)(?:=([\w\s,]*))?/;
|
1030
|
+
configStatement = /coffeelint:\s*((disable|enable)(-line)?)(?:=([\w\s,]*))?/;
|
1031
|
+
|
1032
|
+
configShortcuts = [[/\#.*noqa/, 'coffeelint: disable-line']];
|
992
1033
|
|
993
1034
|
module.exports = LineLinter = (function(superClass) {
|
994
1035
|
extend(LineLinter, superClass);
|
995
1036
|
|
996
|
-
LineLinter.
|
1037
|
+
LineLinter.getDirective = function(line) {
|
1038
|
+
var i, len, ref, replacement, shortcut;
|
1039
|
+
for (i = 0, len = configShortcuts.length; i < len; i++) {
|
1040
|
+
ref = configShortcuts[i], shortcut = ref[0], replacement = ref[1];
|
1041
|
+
if (line.match(shortcut)) {
|
1042
|
+
return configStatement.exec(replacement);
|
1043
|
+
}
|
1044
|
+
}
|
1045
|
+
return configStatement.exec(line);
|
1046
|
+
};
|
997
1047
|
|
998
1048
|
function LineLinter(source, config, rules, tokensByLine, literate) {
|
999
1049
|
if (literate == null) {
|
@@ -1001,9 +1051,11 @@ module.exports = LineLinter = (function(superClass) {
|
|
1001
1051
|
}
|
1002
1052
|
LineLinter.__super__.constructor.call(this, source, config, rules);
|
1003
1053
|
this.lineApi = new LineApi(source, config, tokensByLine, literate);
|
1004
|
-
this.
|
1054
|
+
this.inlineConfig = {
|
1005
1055
|
enable: {},
|
1006
|
-
disable: {}
|
1056
|
+
disable: {},
|
1057
|
+
'enable-line': {},
|
1058
|
+
'disable-line': {}
|
1007
1059
|
};
|
1008
1060
|
}
|
1009
1061
|
|
@@ -1046,18 +1098,18 @@ module.exports = LineLinter = (function(superClass) {
|
|
1046
1098
|
|
1047
1099
|
LineLinter.prototype.collectInlineConfig = function(line) {
|
1048
1100
|
var cmd, i, len, r, ref, result, rules;
|
1049
|
-
result =
|
1101
|
+
result = this.constructor.getDirective(line);
|
1050
1102
|
if (result != null) {
|
1051
1103
|
cmd = result[1];
|
1052
1104
|
rules = [];
|
1053
|
-
if (result[
|
1054
|
-
ref = result[
|
1105
|
+
if (result[4] != null) {
|
1106
|
+
ref = result[4].split(',');
|
1055
1107
|
for (i = 0, len = ref.length; i < len; i++) {
|
1056
1108
|
r = ref[i];
|
1057
1109
|
rules.push(r.replace(/^\s+|\s+$/g, ''));
|
1058
1110
|
}
|
1059
1111
|
}
|
1060
|
-
this.
|
1112
|
+
this.inlineConfig[cmd][this.lineNumber] = rules;
|
1061
1113
|
}
|
1062
1114
|
return null;
|
1063
1115
|
};
|
@@ -1077,8 +1129,7 @@ module.exports = LineLinter = (function(superClass) {
|
|
1077
1129
|
})(BaseLinter);
|
1078
1130
|
|
1079
1131
|
|
1080
|
-
|
1081
|
-
},{"./base_linter.coffee":4}],8:[function(require,module,exports){
|
1132
|
+
},{"./base_linter.coffee":3}],8:[function(require,module,exports){
|
1082
1133
|
var ERROR, IGNORE, WARN;
|
1083
1134
|
|
1084
1135
|
ERROR = 'error';
|
@@ -1095,7 +1146,6 @@ module.exports = {
|
|
1095
1146
|
};
|
1096
1147
|
|
1097
1148
|
|
1098
|
-
|
1099
1149
|
},{}],9:[function(require,module,exports){
|
1100
1150
|
var ArrowSpacing;
|
1101
1151
|
|
@@ -1131,7 +1181,6 @@ module.exports = ArrowSpacing = (function() {
|
|
1131
1181
|
})();
|
1132
1182
|
|
1133
1183
|
|
1134
|
-
|
1135
1184
|
},{}],10:[function(require,module,exports){
|
1136
1185
|
var BracesSpacing;
|
1137
1186
|
|
@@ -1210,7 +1259,6 @@ module.exports = BracesSpacing = (function() {
|
|
1210
1259
|
})();
|
1211
1260
|
|
1212
1261
|
|
1213
|
-
|
1214
1262
|
},{}],11:[function(require,module,exports){
|
1215
1263
|
var CamelCaseClasses, regexes;
|
1216
1264
|
|
@@ -1258,7 +1306,6 @@ module.exports = CamelCaseClasses = (function() {
|
|
1258
1306
|
})();
|
1259
1307
|
|
1260
1308
|
|
1261
|
-
|
1262
1309
|
},{}],12:[function(require,module,exports){
|
1263
1310
|
var ColonAssignmentSpacing;
|
1264
1311
|
|
@@ -1313,7 +1360,6 @@ module.exports = ColonAssignmentSpacing = (function() {
|
|
1313
1360
|
})();
|
1314
1361
|
|
1315
1362
|
|
1316
|
-
|
1317
1363
|
},{}],13:[function(require,module,exports){
|
1318
1364
|
var CyclomaticComplexity;
|
1319
1365
|
|
@@ -1373,7 +1419,6 @@ module.exports = CyclomaticComplexity = (function() {
|
|
1373
1419
|
})();
|
1374
1420
|
|
1375
1421
|
|
1376
|
-
|
1377
1422
|
},{}],14:[function(require,module,exports){
|
1378
1423
|
var DuplicateKey;
|
1379
1424
|
|
@@ -1385,7 +1430,7 @@ module.exports = DuplicateKey = (function() {
|
|
1385
1430
|
description: 'Prevents defining duplicate keys in object literals and classes'
|
1386
1431
|
};
|
1387
1432
|
|
1388
|
-
DuplicateKey.prototype.tokens = ['IDENTIFIER', '{', '}'];
|
1433
|
+
DuplicateKey.prototype.tokens = ['IDENTIFIER', 'PROPERTY', '{', '}'];
|
1389
1434
|
|
1390
1435
|
function DuplicateKey() {
|
1391
1436
|
this.braceScopes = [];
|
@@ -1398,7 +1443,7 @@ module.exports = DuplicateKey = (function() {
|
|
1398
1443
|
this.lintBrace.apply(this, arguments);
|
1399
1444
|
return void 0;
|
1400
1445
|
}
|
1401
|
-
if (type === 'IDENTIFIER') {
|
1446
|
+
if (type === 'IDENTIFIER' || type === 'PROPERTY') {
|
1402
1447
|
return this.lintIdentifier.apply(this, arguments);
|
1403
1448
|
}
|
1404
1449
|
};
|
@@ -1443,7 +1488,6 @@ module.exports = DuplicateKey = (function() {
|
|
1443
1488
|
})();
|
1444
1489
|
|
1445
1490
|
|
1446
|
-
|
1447
1491
|
},{}],15:[function(require,module,exports){
|
1448
1492
|
var EmptyConstructorNeedsParens;
|
1449
1493
|
|
@@ -1460,35 +1504,35 @@ module.exports = EmptyConstructorNeedsParens = (function() {
|
|
1460
1504
|
EmptyConstructorNeedsParens.prototype.tokens = ['UNARY'];
|
1461
1505
|
|
1462
1506
|
EmptyConstructorNeedsParens.prototype.lintToken = function(token, tokenApi) {
|
1463
|
-
var
|
1507
|
+
var identIndex, isIdent, nextToken, peek, ref, ref1, ref2;
|
1464
1508
|
if (token[1] === 'new') {
|
1465
1509
|
peek = tokenApi.peek.bind(tokenApi);
|
1466
|
-
|
1510
|
+
identIndex = 1;
|
1467
1511
|
while (true) {
|
1468
|
-
|
1469
|
-
|
1470
|
-
if (
|
1471
|
-
if ((
|
1472
|
-
|
1512
|
+
isIdent = (ref = (ref1 = peek(identIndex)) != null ? ref1[0] : void 0) === 'IDENTIFIER' || ref === 'PROPERTY';
|
1513
|
+
nextToken = peek(identIndex + 1);
|
1514
|
+
if (isIdent) {
|
1515
|
+
if ((nextToken != null ? nextToken[0] : void 0) === '.') {
|
1516
|
+
identIndex += 2;
|
1473
1517
|
continue;
|
1474
1518
|
}
|
1475
|
-
if ((
|
1476
|
-
while (((
|
1477
|
-
|
1519
|
+
if ((nextToken != null ? nextToken[0] : void 0) === 'INDEX_START') {
|
1520
|
+
while (((ref2 = peek(identIndex)) != null ? ref2[0] : void 0) !== 'INDEX_END') {
|
1521
|
+
identIndex++;
|
1478
1522
|
}
|
1479
1523
|
continue;
|
1480
1524
|
}
|
1481
1525
|
}
|
1482
1526
|
break;
|
1483
1527
|
}
|
1484
|
-
if (
|
1485
|
-
return this.handleExpectedCallStart(
|
1528
|
+
if (isIdent && (nextToken != null)) {
|
1529
|
+
return this.handleExpectedCallStart(nextToken);
|
1486
1530
|
}
|
1487
1531
|
}
|
1488
1532
|
};
|
1489
1533
|
|
1490
|
-
EmptyConstructorNeedsParens.prototype.handleExpectedCallStart = function(
|
1491
|
-
if (
|
1534
|
+
EmptyConstructorNeedsParens.prototype.handleExpectedCallStart = function(isCallStart) {
|
1535
|
+
if (isCallStart[0] !== 'CALL_START') {
|
1492
1536
|
return true;
|
1493
1537
|
}
|
1494
1538
|
};
|
@@ -1498,7 +1542,6 @@ module.exports = EmptyConstructorNeedsParens = (function() {
|
|
1498
1542
|
})();
|
1499
1543
|
|
1500
1544
|
|
1501
|
-
|
1502
1545
|
},{}],16:[function(require,module,exports){
|
1503
1546
|
var EnsureComprehensions,
|
1504
1547
|
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; };
|
@@ -1597,7 +1640,6 @@ module.exports = EnsureComprehensions = (function() {
|
|
1597
1640
|
})();
|
1598
1641
|
|
1599
1642
|
|
1600
|
-
|
1601
1643
|
},{}],17:[function(require,module,exports){
|
1602
1644
|
var EOLLast;
|
1603
1645
|
|
@@ -1628,7 +1670,6 @@ module.exports = EOLLast = (function() {
|
|
1628
1670
|
})();
|
1629
1671
|
|
1630
1672
|
|
1631
|
-
|
1632
1673
|
},{}],18:[function(require,module,exports){
|
1633
1674
|
var Indentation,
|
1634
1675
|
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; };
|
@@ -1814,7 +1855,6 @@ module.exports = Indentation = (function() {
|
|
1814
1855
|
})();
|
1815
1856
|
|
1816
1857
|
|
1817
|
-
|
1818
1858
|
},{}],19:[function(require,module,exports){
|
1819
1859
|
var LineEndings;
|
1820
1860
|
|
@@ -1859,7 +1899,6 @@ module.exports = LineEndings = (function() {
|
|
1859
1899
|
})();
|
1860
1900
|
|
1861
1901
|
|
1862
|
-
|
1863
1902
|
},{}],20:[function(require,module,exports){
|
1864
1903
|
var MaxLineLength, regexes;
|
1865
1904
|
|
@@ -1905,7 +1944,6 @@ module.exports = MaxLineLength = (function() {
|
|
1905
1944
|
})();
|
1906
1945
|
|
1907
1946
|
|
1908
|
-
|
1909
1947
|
},{}],21:[function(require,module,exports){
|
1910
1948
|
var MissingFatArrows, any, containsButIsnt,
|
1911
1949
|
bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
|
@@ -2057,7 +2095,6 @@ module.exports = MissingFatArrows = (function() {
|
|
2057
2095
|
})();
|
2058
2096
|
|
2059
2097
|
|
2060
|
-
|
2061
2098
|
},{}],22:[function(require,module,exports){
|
2062
2099
|
var NewlinesAfterClasses;
|
2063
2100
|
|
@@ -2099,7 +2136,7 @@ module.exports = NewlinesAfterClasses = (function() {
|
|
2099
2136
|
comment = 0;
|
2100
2137
|
outdent = token.origin[2].first_line;
|
2101
2138
|
start = Math.min(lineNumber, outdent);
|
2102
|
-
trueLine =
|
2139
|
+
trueLine = 2e308;
|
2103
2140
|
while (/^\s*(#|$)/.test(lines[start + afters])) {
|
2104
2141
|
if (/^\s*#/.test(lines[start + afters])) {
|
2105
2142
|
comment += 1;
|
@@ -2133,7 +2170,6 @@ module.exports = NewlinesAfterClasses = (function() {
|
|
2133
2170
|
})();
|
2134
2171
|
|
2135
2172
|
|
2136
|
-
|
2137
2173
|
},{}],23:[function(require,module,exports){
|
2138
2174
|
var NoBackticks;
|
2139
2175
|
|
@@ -2158,7 +2194,6 @@ module.exports = NoBackticks = (function() {
|
|
2158
2194
|
})();
|
2159
2195
|
|
2160
2196
|
|
2161
|
-
|
2162
2197
|
},{}],24:[function(require,module,exports){
|
2163
2198
|
var NoDebugger;
|
2164
2199
|
|
@@ -2173,17 +2208,17 @@ module.exports = NoDebugger = (function() {
|
|
2173
2208
|
description: 'This rule detects `debugger` and optionally `console` calls\nThis rule is `warn` by default.'
|
2174
2209
|
};
|
2175
2210
|
|
2176
|
-
NoDebugger.prototype.tokens = ['DEBUGGER', 'IDENTIFIER'];
|
2211
|
+
NoDebugger.prototype.tokens = ['STATEMENT', 'DEBUGGER', 'IDENTIFIER'];
|
2177
2212
|
|
2178
2213
|
NoDebugger.prototype.lintToken = function(token, tokenApi) {
|
2179
|
-
var method, ref, ref1;
|
2180
|
-
if (token[0] === 'DEBUGGER') {
|
2214
|
+
var method, ref, ref1, ref2;
|
2215
|
+
if (((ref = token[0]) === 'DEBUGGER' || ref === 'STATEMENT') && token[1] === 'debugger') {
|
2181
2216
|
return {
|
2182
2217
|
context: "found '" + token[0] + "'"
|
2183
2218
|
};
|
2184
2219
|
}
|
2185
|
-
if ((
|
2186
|
-
if (token[1] === 'console' && ((
|
2220
|
+
if ((ref1 = tokenApi.config[this.rule.name]) != null ? ref1.console : void 0) {
|
2221
|
+
if (token[1] === 'console' && ((ref2 = tokenApi.peek(1)) != null ? ref2[0] : void 0) === '.') {
|
2187
2222
|
method = tokenApi.peek(2);
|
2188
2223
|
return {
|
2189
2224
|
context: "found 'console." + method[1] + "'"
|
@@ -2197,7 +2232,6 @@ module.exports = NoDebugger = (function() {
|
|
2197
2232
|
})();
|
2198
2233
|
|
2199
2234
|
|
2200
|
-
|
2201
2235
|
},{}],25:[function(require,module,exports){
|
2202
2236
|
var NoEmptyFunctions, isEmptyCode;
|
2203
2237
|
|
@@ -2242,7 +2276,6 @@ module.exports = NoEmptyFunctions = (function() {
|
|
2242
2276
|
})();
|
2243
2277
|
|
2244
2278
|
|
2245
|
-
|
2246
2279
|
},{}],26:[function(require,module,exports){
|
2247
2280
|
var NoEmptyParamList;
|
2248
2281
|
|
@@ -2269,7 +2302,6 @@ module.exports = NoEmptyParamList = (function() {
|
|
2269
2302
|
})();
|
2270
2303
|
|
2271
2304
|
|
2272
|
-
|
2273
2305
|
},{}],27:[function(require,module,exports){
|
2274
2306
|
var NoImplicitBraces;
|
2275
2307
|
|
@@ -2282,21 +2314,29 @@ module.exports = NoImplicitBraces = (function() {
|
|
2282
2314
|
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.'
|
2283
2315
|
};
|
2284
2316
|
|
2285
|
-
NoImplicitBraces.prototype.tokens = ['{', 'OUTDENT', 'CLASS', 'IDENTIFIER'];
|
2317
|
+
NoImplicitBraces.prototype.tokens = ['{', 'OUTDENT', 'CLASS', 'IDENTIFIER', 'EXTENDS'];
|
2286
2318
|
|
2287
2319
|
function NoImplicitBraces() {
|
2288
2320
|
this.isClass = false;
|
2289
|
-
this.className =
|
2321
|
+
this.className = '';
|
2290
2322
|
}
|
2291
2323
|
|
2292
2324
|
NoImplicitBraces.prototype.lintToken = function(token, tokenApi) {
|
2293
|
-
var lineNum,
|
2325
|
+
var _type, _val, c, lineNum, peekIdent, prevToken, ref, ref1, type, val;
|
2294
2326
|
type = token[0], val = token[1], lineNum = token[2];
|
2295
2327
|
if (type === 'OUTDENT' || type === 'CLASS') {
|
2296
2328
|
return this.trackClass.apply(this, arguments);
|
2297
2329
|
}
|
2298
|
-
if (type === '
|
2299
|
-
this.className =
|
2330
|
+
if (type === 'EXTENDS') {
|
2331
|
+
this.className = '';
|
2332
|
+
return;
|
2333
|
+
}
|
2334
|
+
if (type === 'IDENTIFIER' && this.isClass && this.className === '') {
|
2335
|
+
c = 0;
|
2336
|
+
while ((ref = tokenApi.peek(c)[0]) === 'IDENTIFIER' || ref === 'PROPERTY' || ref === '.') {
|
2337
|
+
this.className += tokenApi.peek(c)[1];
|
2338
|
+
c++;
|
2339
|
+
}
|
2300
2340
|
}
|
2301
2341
|
if (token.generated && type === '{') {
|
2302
2342
|
if (!tokenApi.config[this.rule.name].strict) {
|
@@ -2310,8 +2350,16 @@ module.exports = NoImplicitBraces = (function() {
|
|
2310
2350
|
if (prevToken === 'TERMINATOR') {
|
2311
2351
|
return;
|
2312
2352
|
}
|
2313
|
-
|
2314
|
-
|
2353
|
+
peekIdent = '';
|
2354
|
+
c = -2;
|
2355
|
+
while ((ref1 = tokenApi.peek(c), _type = ref1[0], _val = ref1[1], ref1)) {
|
2356
|
+
if (_type !== 'IDENTIFIER' && _type !== 'PROPERTY' && _type !== '.') {
|
2357
|
+
break;
|
2358
|
+
}
|
2359
|
+
peekIdent = _val + peekIdent;
|
2360
|
+
c--;
|
2361
|
+
}
|
2362
|
+
if (peekIdent === this.className) {
|
2315
2363
|
return;
|
2316
2364
|
}
|
2317
2365
|
}
|
@@ -2327,7 +2375,7 @@ module.exports = NoImplicitBraces = (function() {
|
|
2327
2375
|
}
|
2328
2376
|
if (n0 === 'CLASS') {
|
2329
2377
|
this.isClass = true;
|
2330
|
-
this.className =
|
2378
|
+
this.className = '';
|
2331
2379
|
}
|
2332
2380
|
return null;
|
2333
2381
|
};
|
@@ -2337,7 +2385,6 @@ module.exports = NoImplicitBraces = (function() {
|
|
2337
2385
|
})();
|
2338
2386
|
|
2339
2387
|
|
2340
|
-
|
2341
2388
|
},{}],28:[function(require,module,exports){
|
2342
2389
|
var NoImplicitParens;
|
2343
2390
|
|
@@ -2380,7 +2427,6 @@ module.exports = NoImplicitParens = (function() {
|
|
2380
2427
|
})();
|
2381
2428
|
|
2382
2429
|
|
2383
|
-
|
2384
2430
|
},{}],29:[function(require,module,exports){
|
2385
2431
|
var NoInterpolationInSingleQuotes;
|
2386
2432
|
|
@@ -2408,7 +2454,6 @@ module.exports = NoInterpolationInSingleQuotes = (function() {
|
|
2408
2454
|
})();
|
2409
2455
|
|
2410
2456
|
|
2411
|
-
|
2412
2457
|
},{}],30:[function(require,module,exports){
|
2413
2458
|
var NoNestedStringInterpolation;
|
2414
2459
|
|
@@ -2458,7 +2503,6 @@ module.exports = NoNestedStringInterpolation = (function() {
|
|
2458
2503
|
})();
|
2459
2504
|
|
2460
2505
|
|
2461
|
-
|
2462
2506
|
},{}],31:[function(require,module,exports){
|
2463
2507
|
var NoPlusPlus;
|
2464
2508
|
|
@@ -2485,7 +2529,6 @@ module.exports = NoPlusPlus = (function() {
|
|
2485
2529
|
})();
|
2486
2530
|
|
2487
2531
|
|
2488
|
-
|
2489
2532
|
},{}],32:[function(require,module,exports){
|
2490
2533
|
var NoPrivateFunctionFatArrows,
|
2491
2534
|
bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
|
@@ -2583,7 +2626,6 @@ module.exports = NoPrivateFunctionFatArrows = (function() {
|
|
2583
2626
|
})();
|
2584
2627
|
|
2585
2628
|
|
2586
|
-
|
2587
2629
|
},{}],33:[function(require,module,exports){
|
2588
2630
|
var NoStandAloneAt;
|
2589
2631
|
|
@@ -2600,17 +2642,14 @@ module.exports = NoStandAloneAt = (function() {
|
|
2600
2642
|
NoStandAloneAt.prototype.tokens = ['@'];
|
2601
2643
|
|
2602
2644
|
NoStandAloneAt.prototype.lintToken = function(token, tokenApi) {
|
2603
|
-
var
|
2604
|
-
nextToken = tokenApi.peek();
|
2605
|
-
|
2606
|
-
|
2607
|
-
|
2608
|
-
isDot = nextToken
|
2609
|
-
|
2610
|
-
|
2611
|
-
isValidProtoProperty = protoProperty[0] === 'IDENTIFIER';
|
2612
|
-
}
|
2613
|
-
if (spaced || (!isIdentifier && !isIndexStart && !isDot && !isValidProtoProperty)) {
|
2645
|
+
var isAStart, isDot, isProp, isProtoProp, nextToken, noSpace, ref, ref1;
|
2646
|
+
nextToken = tokenApi.peek()[0];
|
2647
|
+
noSpace = !token.spaced;
|
2648
|
+
isProp = nextToken === 'IDENTIFIER' || nextToken === 'PROPERTY';
|
2649
|
+
isAStart = nextToken === 'INDEX_START' || nextToken === 'CALL_START';
|
2650
|
+
isDot = nextToken === '.';
|
2651
|
+
isProtoProp = nextToken === '::' && ((ref = (ref1 = tokenApi.peek(2)) != null ? ref1[0] : void 0) === 'IDENTIFIER' || ref === 'PROPERTY');
|
2652
|
+
if (!(isDot || (noSpace && (isProp || isAStart || isProtoProp)))) {
|
2614
2653
|
return true;
|
2615
2654
|
}
|
2616
2655
|
};
|
@@ -2620,7 +2659,6 @@ module.exports = NoStandAloneAt = (function() {
|
|
2620
2659
|
})();
|
2621
2660
|
|
2622
2661
|
|
2623
|
-
|
2624
2662
|
},{}],34:[function(require,module,exports){
|
2625
2663
|
var NoTabs, indentationRegex,
|
2626
2664
|
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; };
|
@@ -2652,7 +2690,6 @@ module.exports = NoTabs = (function() {
|
|
2652
2690
|
})();
|
2653
2691
|
|
2654
2692
|
|
2655
|
-
|
2656
2693
|
},{}],35:[function(require,module,exports){
|
2657
2694
|
var NoThis;
|
2658
2695
|
|
@@ -2682,7 +2719,6 @@ module.exports = NoThis = (function() {
|
|
2682
2719
|
})();
|
2683
2720
|
|
2684
2721
|
|
2685
|
-
|
2686
2722
|
},{}],36:[function(require,module,exports){
|
2687
2723
|
var NoThrowingStrings;
|
2688
2724
|
|
@@ -2710,7 +2746,6 @@ module.exports = NoThrowingStrings = (function() {
|
|
2710
2746
|
})();
|
2711
2747
|
|
2712
2748
|
|
2713
|
-
|
2714
2749
|
},{}],37:[function(require,module,exports){
|
2715
2750
|
var NoTrailingSemicolons, regexes,
|
2716
2751
|
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; },
|
@@ -2763,7 +2798,6 @@ module.exports = NoTrailingSemicolons = (function() {
|
|
2763
2798
|
})();
|
2764
2799
|
|
2765
2800
|
|
2766
|
-
|
2767
2801
|
},{}],38:[function(require,module,exports){
|
2768
2802
|
var NoTrailingWhitespace, regexes;
|
2769
2803
|
|
@@ -2827,7 +2861,6 @@ module.exports = NoTrailingWhitespace = (function() {
|
|
2827
2861
|
})();
|
2828
2862
|
|
2829
2863
|
|
2830
|
-
|
2831
2864
|
},{}],39:[function(require,module,exports){
|
2832
2865
|
var NoUnnecessaryDoubleQuotes;
|
2833
2866
|
|
@@ -2885,7 +2918,6 @@ module.exports = NoUnnecessaryDoubleQuotes = (function() {
|
|
2885
2918
|
})();
|
2886
2919
|
|
2887
2920
|
|
2888
|
-
|
2889
2921
|
},{}],40:[function(require,module,exports){
|
2890
2922
|
var NoUnnecessaryFatArrows, any,
|
2891
2923
|
bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
@@ -2943,7 +2975,8 @@ module.exports = NoUnnecessaryFatArrows = (function() {
|
|
2943
2975
|
};
|
2944
2976
|
|
2945
2977
|
NoUnnecessaryFatArrows.prototype.isThis = function(node) {
|
2946
|
-
|
2978
|
+
var ref;
|
2979
|
+
return ((ref = node.constructor) != null ? ref.name : void 0) === 'ThisLiteral' || this.isValue(node) && node.base.value === 'this';
|
2947
2980
|
};
|
2948
2981
|
|
2949
2982
|
NoUnnecessaryFatArrows.prototype.needsFatArrow = function(node) {
|
@@ -2953,8 +2986,9 @@ module.exports = NoUnnecessaryFatArrows = (function() {
|
|
2953
2986
|
};
|
2954
2987
|
})(this)) || (node.body.contains(this.isThis) != null) || (node.body.contains((function(_this) {
|
2955
2988
|
return function(child) {
|
2989
|
+
var ref;
|
2956
2990
|
if (!_this.astApi.getNodeName(child)) {
|
2957
|
-
return (child.isSuper != null) && child.isSuper;
|
2991
|
+
return ((ref = child.constructor) != null ? ref.name : void 0) === 'SuperCall' || ((child.isSuper != null) && child.isSuper);
|
2958
2992
|
} else {
|
2959
2993
|
return _this.isFatArrowCode(child) && _this.needsFatArrow(child);
|
2960
2994
|
}
|
@@ -2967,7 +3001,6 @@ module.exports = NoUnnecessaryFatArrows = (function() {
|
|
2967
3001
|
})();
|
2968
3002
|
|
2969
3003
|
|
2970
|
-
|
2971
3004
|
},{}],41:[function(require,module,exports){
|
2972
3005
|
var NonEmptyConstructorNeedsParens, ParentClass,
|
2973
3006
|
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; },
|
@@ -2989,8 +3022,8 @@ module.exports = NonEmptyConstructorNeedsParens = (function(superClass) {
|
|
2989
3022
|
description: 'Requires constructors with parameters to include the parens'
|
2990
3023
|
};
|
2991
3024
|
|
2992
|
-
NonEmptyConstructorNeedsParens.prototype.handleExpectedCallStart = function(
|
2993
|
-
if (
|
3025
|
+
NonEmptyConstructorNeedsParens.prototype.handleExpectedCallStart = function(isCallStart) {
|
3026
|
+
if (isCallStart[0] === 'CALL_START' && isCallStart.generated) {
|
2994
3027
|
return true;
|
2995
3028
|
}
|
2996
3029
|
};
|
@@ -3000,7 +3033,6 @@ module.exports = NonEmptyConstructorNeedsParens = (function(superClass) {
|
|
3000
3033
|
})(ParentClass);
|
3001
3034
|
|
3002
3035
|
|
3003
|
-
|
3004
3036
|
},{"./empty_constructor_needs_parens.coffee":15}],42:[function(require,module,exports){
|
3005
3037
|
var PreferEnglishOperator;
|
3006
3038
|
|
@@ -3062,7 +3094,6 @@ module.exports = PreferEnglishOperator = (function() {
|
|
3062
3094
|
})();
|
3063
3095
|
|
3064
3096
|
|
3065
|
-
|
3066
3097
|
},{}],43:[function(require,module,exports){
|
3067
3098
|
var SpaceOperators,
|
3068
3099
|
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; };
|
@@ -3171,7 +3202,6 @@ module.exports = SpaceOperators = (function() {
|
|
3171
3202
|
})();
|
3172
3203
|
|
3173
3204
|
|
3174
|
-
|
3175
3205
|
},{}],44:[function(require,module,exports){
|
3176
3206
|
var SpacingAfterComma;
|
3177
3207
|
|
@@ -3219,7 +3249,6 @@ module.exports = SpacingAfterComma = (function() {
|
|
3219
3249
|
})();
|
3220
3250
|
|
3221
3251
|
|
3222
|
-
|
3223
3252
|
},{}],45:[function(require,module,exports){
|
3224
3253
|
var TransformMessesUpLineNumbers;
|
3225
3254
|
|
@@ -3242,6 +3271,5 @@ module.exports = TransformMessesUpLineNumbers = (function() {
|
|
3242
3271
|
})();
|
3243
3272
|
|
3244
3273
|
|
3245
|
-
|
3246
|
-
},{}]},{},[1])(1)
|
3274
|
+
},{}]},{},[4])(4)
|
3247
3275
|
});
|