coffeelint 1.10.0 → 1.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/coffeelint/lib/coffeelint.js +242 -55
- data/lib/coffeelint.rb +1 -1
- data/lib/coffeelint/version.rb +1 -1
- data/lib/tasks/coffeelint.rake +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e482db9f7267c3b2e3b6a6a39d445a23ed6d2cc
|
4
|
+
data.tar.gz: 16fc6cb55ddc9d88776df33a882d2e1cf374d91c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 440d9e0c1106684bfbd074359e06b0b2a88ef2c30be6e9c58bf0dd3c8e9ad6d7a668d64f78ee0aa543a08572a6f8722a2a3be3e19408ee3df688b588a7fe402b
|
7
|
+
data.tar.gz: a15b9a7d6e6af6646b715996d1c98781a5c7820d4bdcc99be5dcfc672d3447ec44d8da5a8ded34bbeeaa4f3e4f21a2f7136c506c7cba070bc5c48cfbf8c5b2fb
|
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.11.0
|
4
4
|
|
5
5
|
Coffeelint is a set of simple ruby bindings for [coffeelint](https://github.com/clutchski/coffeelint).
|
6
6
|
|
@@ -228,6 +228,8 @@ coffeelint.registerRule(require('./rules/colon_assignment_spacing.coffee'));
|
|
228
228
|
|
229
229
|
coffeelint.registerRule(require('./rules/no_implicit_braces.coffee'));
|
230
230
|
|
231
|
+
coffeelint.registerRule(require('./rules/no_nested_string_interpolation.coffee'));
|
232
|
+
|
231
233
|
coffeelint.registerRule(require('./rules/no_plusplus.coffee'));
|
232
234
|
|
233
235
|
coffeelint.registerRule(require('./rules/no_throwing_strings.coffee'));
|
@@ -276,6 +278,8 @@ coffeelint.registerRule(require('./rules/no_this.coffee'));
|
|
276
278
|
|
277
279
|
coffeelint.registerRule(require('./rules/eol_last.coffee'));
|
278
280
|
|
281
|
+
coffeelint.registerRule(require('./rules/no_private_function_fat_arrows.coffee'));
|
282
|
+
|
279
283
|
hasSyntaxError = function(source) {
|
280
284
|
try {
|
281
285
|
CoffeeScript.tokens(source);
|
@@ -421,11 +425,11 @@ coffeelint.setCache = function(obj) {
|
|
421
425
|
|
422
426
|
|
423
427
|
|
424
|
-
},{"./../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/
|
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){
|
425
429
|
module.exports={
|
426
430
|
"name": "coffeelint",
|
427
431
|
"description": "Lint your CoffeeScript",
|
428
|
-
"version": "1.
|
432
|
+
"version": "1.11.0",
|
429
433
|
"homepage": "http://www.coffeelint.org",
|
430
434
|
"keywords": [
|
431
435
|
"lint",
|
@@ -1112,6 +1116,9 @@ module.exports = ArrowSpacing = (function() {
|
|
1112
1116
|
ArrowSpacing.prototype.lintToken = function(token, tokenApi) {
|
1113
1117
|
var pp;
|
1114
1118
|
pp = tokenApi.peek(-1);
|
1119
|
+
if (!pp) {
|
1120
|
+
return;
|
1121
|
+
}
|
1115
1122
|
if (!token.spaced && (pp[1] === "(" && (pp.generated == null)) && tokenApi.peek(1)[0] === 'INDENT' && tokenApi.peek(2)[0] === 'OUTDENT') {
|
1116
1123
|
return null;
|
1117
1124
|
} else if (!(((token.spaced != null) || (token.newLine != null) || this.atEof(tokenApi)) && (((pp.spaced != null) || pp[0] === 'TERMINATOR') || (pp.generated != null) || pp[0] === "INDENT" || (pp[1] === "(" && (pp.generated == null))))) {
|
@@ -1323,12 +1330,12 @@ module.exports = ColonAssignmentSpacing = (function() {
|
|
1323
1330
|
|
1324
1331
|
|
1325
1332
|
},{}],13:[function(require,module,exports){
|
1326
|
-
var
|
1333
|
+
var CyclomaticComplexity;
|
1327
1334
|
|
1328
|
-
module.exports =
|
1329
|
-
function
|
1335
|
+
module.exports = CyclomaticComplexity = (function() {
|
1336
|
+
function CyclomaticComplexity() {}
|
1330
1337
|
|
1331
|
-
|
1338
|
+
CyclomaticComplexity.prototype.rule = {
|
1332
1339
|
name: 'cyclomatic_complexity',
|
1333
1340
|
value: 10,
|
1334
1341
|
level: 'ignore',
|
@@ -1336,20 +1343,20 @@ module.exports = NoTabs = (function() {
|
|
1336
1343
|
description: 'Examine the complexity of your application.'
|
1337
1344
|
};
|
1338
1345
|
|
1339
|
-
|
1346
|
+
CyclomaticComplexity.prototype.getComplexity = function(node) {
|
1340
1347
|
var complexity, name, ref;
|
1341
1348
|
name = this.astApi.getNodeName(node);
|
1342
1349
|
complexity = name === 'If' || name === 'While' || name === 'For' || name === 'Try' ? 1 : name === 'Op' && ((ref = node.operator) === '&&' || ref === '||') ? 1 : name === 'Switch' ? node.cases.length : 0;
|
1343
1350
|
return complexity;
|
1344
1351
|
};
|
1345
1352
|
|
1346
|
-
|
1353
|
+
CyclomaticComplexity.prototype.lintAST = function(node, astApi) {
|
1347
1354
|
this.astApi = astApi;
|
1348
1355
|
this.lintNode(node);
|
1349
1356
|
return void 0;
|
1350
1357
|
};
|
1351
1358
|
|
1352
|
-
|
1359
|
+
CyclomaticComplexity.prototype.lintNode = function(node, line) {
|
1353
1360
|
var complexity, error, name, ref, rule;
|
1354
1361
|
name = (ref = this.astApi) != null ? ref.getNodeName(node) : void 0;
|
1355
1362
|
complexity = this.getComplexity(node);
|
@@ -1376,7 +1383,7 @@ module.exports = NoTabs = (function() {
|
|
1376
1383
|
return complexity;
|
1377
1384
|
};
|
1378
1385
|
|
1379
|
-
return
|
1386
|
+
return CyclomaticComplexity;
|
1380
1387
|
|
1381
1388
|
})();
|
1382
1389
|
|
@@ -1523,13 +1530,27 @@ module.exports = EnsureComprehensions = (function() {
|
|
1523
1530
|
|
1524
1531
|
EnsureComprehensions.prototype.tokens = ['FOR'];
|
1525
1532
|
|
1533
|
+
EnsureComprehensions.prototype.forBlock = false;
|
1534
|
+
|
1526
1535
|
EnsureComprehensions.prototype.lintToken = function(token, tokenApi) {
|
1527
|
-
var atEqual, idents, peeker, prevIdents, prevToken, ref, ref1;
|
1536
|
+
var atEqual, idents, numCallEnds, numCallStarts, peeker, prevIdents, prevToken, ref, ref1;
|
1528
1537
|
idents = this.findIdents(tokenApi);
|
1538
|
+
if (this.forBlock) {
|
1539
|
+
this.forBlock = false;
|
1540
|
+
return;
|
1541
|
+
}
|
1529
1542
|
peeker = -1;
|
1530
1543
|
atEqual = false;
|
1544
|
+
numCallEnds = 0;
|
1545
|
+
numCallStarts = 0;
|
1531
1546
|
prevIdents = [];
|
1532
1547
|
while ((prevToken = tokenApi.peek(peeker))) {
|
1548
|
+
if (prevToken[0] === 'CALL_END') {
|
1549
|
+
numCallEnds++;
|
1550
|
+
}
|
1551
|
+
if (prevToken[0] === 'CALL_START') {
|
1552
|
+
numCallStarts++;
|
1553
|
+
}
|
1533
1554
|
if (prevToken[0] === 'IDENTIFIER') {
|
1534
1555
|
if (!atEqual) {
|
1535
1556
|
prevIdents.push(prevToken[1]);
|
@@ -1545,7 +1566,7 @@ module.exports = EnsureComprehensions = (function() {
|
|
1545
1566
|
}
|
1546
1567
|
peeker--;
|
1547
1568
|
}
|
1548
|
-
if (atEqual && prevIdents.length > 0) {
|
1569
|
+
if (atEqual && prevIdents.length > 0 && numCallStarts === numCallEnds) {
|
1549
1570
|
return {
|
1550
1571
|
context: ''
|
1551
1572
|
};
|
@@ -1565,6 +1586,16 @@ module.exports = EnsureComprehensions = (function() {
|
|
1565
1586
|
}
|
1566
1587
|
peeker++;
|
1567
1588
|
}
|
1589
|
+
while ((nextToken = tokenApi.peek(peeker))) {
|
1590
|
+
if (nextToken[0] === 'TERMINATOR') {
|
1591
|
+
break;
|
1592
|
+
}
|
1593
|
+
if (nextToken[0] === 'INDENT') {
|
1594
|
+
this.forBlock = true;
|
1595
|
+
break;
|
1596
|
+
}
|
1597
|
+
peeker++;
|
1598
|
+
}
|
1568
1599
|
return idents;
|
1569
1600
|
};
|
1570
1601
|
|
@@ -2259,6 +2290,56 @@ module.exports = NoInterpolationInSingleQuotes = (function() {
|
|
2259
2290
|
|
2260
2291
|
|
2261
2292
|
},{}],30:[function(require,module,exports){
|
2293
|
+
var NoNestedStringInterpolation;
|
2294
|
+
|
2295
|
+
module.exports = NoNestedStringInterpolation = (function() {
|
2296
|
+
NoNestedStringInterpolation.prototype.rule = {
|
2297
|
+
name: 'no_nested_string_interpolation',
|
2298
|
+
level: 'warn',
|
2299
|
+
message: 'Nested string interpolation is forbidden',
|
2300
|
+
description: 'This rule warns about nested string interpolation,\nas it tends to make code harder to read and understand.\n<pre>\n<code># Good!\nstr = "Book by #{firstName.toUpperCase()} #{lastName.toUpperCase()}"\n\n# Bad!\nstr = "Book by #{"#{firstName} #{lastName}".toUpperCase()}"\n</code>\n</pre>'
|
2301
|
+
};
|
2302
|
+
|
2303
|
+
NoNestedStringInterpolation.prototype.tokens = ['STRING_START', 'STRING_END'];
|
2304
|
+
|
2305
|
+
function NoNestedStringInterpolation() {
|
2306
|
+
this.startedStrings = 0;
|
2307
|
+
this.generatedError = false;
|
2308
|
+
}
|
2309
|
+
|
2310
|
+
NoNestedStringInterpolation.prototype.lintToken = function(arg, tokenApi) {
|
2311
|
+
var type;
|
2312
|
+
type = arg[0];
|
2313
|
+
if (type === 'STRING_START') {
|
2314
|
+
return this.trackStringStart();
|
2315
|
+
} else {
|
2316
|
+
return this.trackStringEnd();
|
2317
|
+
}
|
2318
|
+
};
|
2319
|
+
|
2320
|
+
NoNestedStringInterpolation.prototype.trackStringStart = function() {
|
2321
|
+
this.startedStrings += 1;
|
2322
|
+
if (this.startedStrings <= 1 || this.generatedError) {
|
2323
|
+
return;
|
2324
|
+
}
|
2325
|
+
this.generatedError = true;
|
2326
|
+
return true;
|
2327
|
+
};
|
2328
|
+
|
2329
|
+
NoNestedStringInterpolation.prototype.trackStringEnd = function() {
|
2330
|
+
this.startedStrings -= 1;
|
2331
|
+
if (this.startedStrings === 1) {
|
2332
|
+
return this.generatedError = false;
|
2333
|
+
}
|
2334
|
+
};
|
2335
|
+
|
2336
|
+
return NoNestedStringInterpolation;
|
2337
|
+
|
2338
|
+
})();
|
2339
|
+
|
2340
|
+
|
2341
|
+
|
2342
|
+
},{}],31:[function(require,module,exports){
|
2262
2343
|
var NoPlusPlus;
|
2263
2344
|
|
2264
2345
|
module.exports = NoPlusPlus = (function() {
|
@@ -2285,7 +2366,105 @@ module.exports = NoPlusPlus = (function() {
|
|
2285
2366
|
|
2286
2367
|
|
2287
2368
|
|
2288
|
-
},{}],
|
2369
|
+
},{}],32:[function(require,module,exports){
|
2370
|
+
var NoPrivateFunctionFatArrows,
|
2371
|
+
bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
|
2372
|
+
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; };
|
2373
|
+
|
2374
|
+
module.exports = NoPrivateFunctionFatArrows = (function() {
|
2375
|
+
function NoPrivateFunctionFatArrows() {
|
2376
|
+
this.isFatArrowCode = bind(this.isFatArrowCode, this);
|
2377
|
+
this.isObject = bind(this.isObject, this);
|
2378
|
+
this.isValue = bind(this.isValue, this);
|
2379
|
+
this.isClass = bind(this.isClass, this);
|
2380
|
+
this.isCode = bind(this.isCode, this);
|
2381
|
+
}
|
2382
|
+
|
2383
|
+
NoPrivateFunctionFatArrows.prototype.rule = {
|
2384
|
+
name: 'no_private_function_fat_arrows',
|
2385
|
+
level: 'warn',
|
2386
|
+
message: 'Used the fat arrow for a private function',
|
2387
|
+
description: "Warns when you use the fat arrow for a private function\ninside a class defintion scope. It is not necessary and\nit does not do anything."
|
2388
|
+
};
|
2389
|
+
|
2390
|
+
NoPrivateFunctionFatArrows.prototype.lintAST = function(node, astApi) {
|
2391
|
+
this.astApi = astApi;
|
2392
|
+
this.lintNode(node);
|
2393
|
+
return void 0;
|
2394
|
+
};
|
2395
|
+
|
2396
|
+
NoPrivateFunctionFatArrows.prototype.lintNode = function(node, functions) {
|
2397
|
+
var error;
|
2398
|
+
if (functions == null) {
|
2399
|
+
functions = [];
|
2400
|
+
}
|
2401
|
+
if (this.isFatArrowCode(node) && indexOf.call(functions, node) >= 0) {
|
2402
|
+
error = this.astApi.createError({
|
2403
|
+
lineNumber: node.locationData.first_line + 1
|
2404
|
+
});
|
2405
|
+
this.errors.push(error);
|
2406
|
+
}
|
2407
|
+
return node.eachChild((function(_this) {
|
2408
|
+
return function(child) {
|
2409
|
+
return _this.lintNode(child, (function() {
|
2410
|
+
switch (false) {
|
2411
|
+
case !this.isClass(node):
|
2412
|
+
return this.functionsOfClass(node);
|
2413
|
+
case !this.isCode(node):
|
2414
|
+
return [];
|
2415
|
+
default:
|
2416
|
+
return functions;
|
2417
|
+
}
|
2418
|
+
}).call(_this));
|
2419
|
+
};
|
2420
|
+
})(this));
|
2421
|
+
};
|
2422
|
+
|
2423
|
+
NoPrivateFunctionFatArrows.prototype.isCode = function(node) {
|
2424
|
+
return this.astApi.getNodeName(node) === 'Code';
|
2425
|
+
};
|
2426
|
+
|
2427
|
+
NoPrivateFunctionFatArrows.prototype.isClass = function(node) {
|
2428
|
+
return this.astApi.getNodeName(node) === 'Class';
|
2429
|
+
};
|
2430
|
+
|
2431
|
+
NoPrivateFunctionFatArrows.prototype.isValue = function(node) {
|
2432
|
+
return this.astApi.getNodeName(node) === 'Value';
|
2433
|
+
};
|
2434
|
+
|
2435
|
+
NoPrivateFunctionFatArrows.prototype.isObject = function(node) {
|
2436
|
+
return this.astApi.getNodeName(node) === 'Obj';
|
2437
|
+
};
|
2438
|
+
|
2439
|
+
NoPrivateFunctionFatArrows.prototype.isFatArrowCode = function(node) {
|
2440
|
+
return this.isCode(node) && node.bound;
|
2441
|
+
};
|
2442
|
+
|
2443
|
+
NoPrivateFunctionFatArrows.prototype.functionsOfClass = function(classNode) {
|
2444
|
+
var bodyNode, bodyValues;
|
2445
|
+
bodyValues = (function() {
|
2446
|
+
var i, len, ref, results;
|
2447
|
+
ref = classNode.body.expressions;
|
2448
|
+
results = [];
|
2449
|
+
for (i = 0, len = ref.length; i < len; i++) {
|
2450
|
+
bodyNode = ref[i];
|
2451
|
+
if (this.isValue(bodyNode) && this.isObject(bodyNode.base)) {
|
2452
|
+
continue;
|
2453
|
+
}
|
2454
|
+
results.push(bodyNode.value);
|
2455
|
+
}
|
2456
|
+
return results;
|
2457
|
+
}).call(this);
|
2458
|
+
return bodyValues.filter(this.isCode);
|
2459
|
+
};
|
2460
|
+
|
2461
|
+
return NoPrivateFunctionFatArrows;
|
2462
|
+
|
2463
|
+
})();
|
2464
|
+
|
2465
|
+
|
2466
|
+
|
2467
|
+
},{}],33:[function(require,module,exports){
|
2289
2468
|
var NoStandAloneAt;
|
2290
2469
|
|
2291
2470
|
module.exports = NoStandAloneAt = (function() {
|
@@ -2322,7 +2501,7 @@ module.exports = NoStandAloneAt = (function() {
|
|
2322
2501
|
|
2323
2502
|
|
2324
2503
|
|
2325
|
-
},{}],
|
2504
|
+
},{}],34:[function(require,module,exports){
|
2326
2505
|
var NoTabs, indentationRegex,
|
2327
2506
|
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; };
|
2328
2507
|
|
@@ -2354,7 +2533,7 @@ module.exports = NoTabs = (function() {
|
|
2354
2533
|
|
2355
2534
|
|
2356
2535
|
|
2357
|
-
},{}],
|
2536
|
+
},{}],35:[function(require,module,exports){
|
2358
2537
|
var NoThis;
|
2359
2538
|
|
2360
2539
|
module.exports = NoThis = (function() {
|
@@ -2379,7 +2558,7 @@ module.exports = NoThis = (function() {
|
|
2379
2558
|
|
2380
2559
|
|
2381
2560
|
|
2382
|
-
},{}],
|
2561
|
+
},{}],36:[function(require,module,exports){
|
2383
2562
|
var NoThrowingStrings;
|
2384
2563
|
|
2385
2564
|
module.exports = NoThrowingStrings = (function() {
|
@@ -2407,7 +2586,7 @@ module.exports = NoThrowingStrings = (function() {
|
|
2407
2586
|
|
2408
2587
|
|
2409
2588
|
|
2410
|
-
},{}],
|
2589
|
+
},{}],37:[function(require,module,exports){
|
2411
2590
|
var NoTrailingSemicolons, regexes,
|
2412
2591
|
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; },
|
2413
2592
|
slice = [].slice;
|
@@ -2460,7 +2639,7 @@ module.exports = NoTrailingSemicolons = (function() {
|
|
2460
2639
|
|
2461
2640
|
|
2462
2641
|
|
2463
|
-
},{}],
|
2642
|
+
},{}],38:[function(require,module,exports){
|
2464
2643
|
var NoTrailingWhitespace, regexes;
|
2465
2644
|
|
2466
2645
|
regexes = {
|
@@ -2524,7 +2703,7 @@ module.exports = NoTrailingWhitespace = (function() {
|
|
2524
2703
|
|
2525
2704
|
|
2526
2705
|
|
2527
|
-
},{}],
|
2706
|
+
},{}],39:[function(require,module,exports){
|
2528
2707
|
var NoUnnecessaryDoubleQuotes;
|
2529
2708
|
|
2530
2709
|
module.exports = NoUnnecessaryDoubleQuotes = (function() {
|
@@ -2537,7 +2716,7 @@ module.exports = NoUnnecessaryDoubleQuotes = (function() {
|
|
2537
2716
|
|
2538
2717
|
function NoUnnecessaryDoubleQuotes() {
|
2539
2718
|
this.regexps = [];
|
2540
|
-
this.
|
2719
|
+
this.interpolationLevel = 0;
|
2541
2720
|
}
|
2542
2721
|
|
2543
2722
|
NoUnnecessaryDoubleQuotes.prototype.tokens = ['STRING', 'STRING_START', 'STRING_END'];
|
@@ -2555,15 +2734,19 @@ module.exports = NoUnnecessaryDoubleQuotes = (function() {
|
|
2555
2734
|
if (((ref = tokenApi.peek(2)) != null ? ref[0] : void 0) === 'REGEX_END') {
|
2556
2735
|
return false;
|
2557
2736
|
}
|
2558
|
-
hasLegalConstructs = this.
|
2737
|
+
hasLegalConstructs = this.isInInterpolation() || this.hasSingleQuote(tokenValue);
|
2559
2738
|
return !hasLegalConstructs;
|
2560
2739
|
};
|
2561
2740
|
|
2741
|
+
NoUnnecessaryDoubleQuotes.prototype.isInInterpolation = function() {
|
2742
|
+
return this.interpolationLevel > 0;
|
2743
|
+
};
|
2744
|
+
|
2562
2745
|
NoUnnecessaryDoubleQuotes.prototype.trackParens = function(token, tokenApi) {
|
2563
2746
|
if (token[0] === 'STRING_START') {
|
2564
|
-
this.
|
2747
|
+
this.interpolationLevel += 1;
|
2565
2748
|
} else if (token[0] === 'STRING_END') {
|
2566
|
-
this.
|
2749
|
+
this.interpolationLevel -= 1;
|
2567
2750
|
}
|
2568
2751
|
return null;
|
2569
2752
|
};
|
@@ -2578,7 +2761,7 @@ module.exports = NoUnnecessaryDoubleQuotes = (function() {
|
|
2578
2761
|
|
2579
2762
|
|
2580
2763
|
|
2581
|
-
},{}],
|
2764
|
+
},{}],40:[function(require,module,exports){
|
2582
2765
|
var NoUnnecessaryFatArrows, any,
|
2583
2766
|
bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
2584
2767
|
|
@@ -2660,7 +2843,7 @@ module.exports = NoUnnecessaryFatArrows = (function() {
|
|
2660
2843
|
|
2661
2844
|
|
2662
2845
|
|
2663
|
-
},{}],
|
2846
|
+
},{}],41:[function(require,module,exports){
|
2664
2847
|
var NonEmptyConstructorNeedsParens, ParentClass,
|
2665
2848
|
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; },
|
2666
2849
|
hasProp = {}.hasOwnProperty;
|
@@ -2693,13 +2876,13 @@ module.exports = NonEmptyConstructorNeedsParens = (function(superClass) {
|
|
2693
2876
|
|
2694
2877
|
|
2695
2878
|
|
2696
|
-
},{"./empty_constructor_needs_parens.coffee":15}],
|
2697
|
-
var
|
2879
|
+
},{"./empty_constructor_needs_parens.coffee":15}],42:[function(require,module,exports){
|
2880
|
+
var PreferEnglishOperator;
|
2698
2881
|
|
2699
|
-
module.exports =
|
2700
|
-
function
|
2882
|
+
module.exports = PreferEnglishOperator = (function() {
|
2883
|
+
function PreferEnglishOperator() {}
|
2701
2884
|
|
2702
|
-
|
2885
|
+
PreferEnglishOperator.prototype.rule = {
|
2703
2886
|
name: 'prefer_english_operator',
|
2704
2887
|
description: 'This rule prohibits &&, ||, ==, != and !.\nUse and, or, is, isnt, and not instead.\n!! for converting to a boolean is ignored.',
|
2705
2888
|
level: 'ignore',
|
@@ -2707,9 +2890,9 @@ module.exports = RuleProcessor = (function() {
|
|
2707
2890
|
message: 'Don\'t use &&, ||, ==, !=, or !'
|
2708
2891
|
};
|
2709
2892
|
|
2710
|
-
|
2893
|
+
PreferEnglishOperator.prototype.tokens = ['COMPARE', 'UNARY_MATH', 'LOGIC'];
|
2711
2894
|
|
2712
|
-
|
2895
|
+
PreferEnglishOperator.prototype.lintToken = function(token, tokenApi) {
|
2713
2896
|
var actual_token, config, context, first_column, last_column, level, line, ref;
|
2714
2897
|
config = tokenApi.config[this.rule.name];
|
2715
2898
|
level = config.level;
|
@@ -2749,13 +2932,13 @@ module.exports = RuleProcessor = (function() {
|
|
2749
2932
|
}
|
2750
2933
|
};
|
2751
2934
|
|
2752
|
-
return
|
2935
|
+
return PreferEnglishOperator;
|
2753
2936
|
|
2754
2937
|
})();
|
2755
2938
|
|
2756
2939
|
|
2757
2940
|
|
2758
|
-
},{}],
|
2941
|
+
},{}],43:[function(require,module,exports){
|
2759
2942
|
var SpaceOperators,
|
2760
2943
|
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; };
|
2761
2944
|
|
@@ -2772,7 +2955,7 @@ module.exports = SpaceOperators = (function() {
|
|
2772
2955
|
function SpaceOperators() {
|
2773
2956
|
this.callTokens = [];
|
2774
2957
|
this.parenTokens = [];
|
2775
|
-
this.
|
2958
|
+
this.interpolationLevel = 0;
|
2776
2959
|
}
|
2777
2960
|
|
2778
2961
|
SpaceOperators.prototype.lintToken = function(arg, tokenApi) {
|
@@ -2794,7 +2977,7 @@ module.exports = SpaceOperators = (function() {
|
|
2794
2977
|
|
2795
2978
|
SpaceOperators.prototype.lintPlus = function(token, tokenApi) {
|
2796
2979
|
var isUnary, p, ref, unaries;
|
2797
|
-
if (this.
|
2980
|
+
if (this.isInInterpolation() || this.isInExtendedRegex()) {
|
2798
2981
|
return null;
|
2799
2982
|
}
|
2800
2983
|
p = tokenApi.peek(-1);
|
@@ -2833,6 +3016,10 @@ module.exports = SpaceOperators = (function() {
|
|
2833
3016
|
return false;
|
2834
3017
|
};
|
2835
3018
|
|
3019
|
+
SpaceOperators.prototype.isInInterpolation = function() {
|
3020
|
+
return this.interpolationLevel > 0;
|
3021
|
+
};
|
3022
|
+
|
2836
3023
|
SpaceOperators.prototype.trackCall = function(token, tokenApi) {
|
2837
3024
|
var p;
|
2838
3025
|
if (token[0] === 'CALL_START') {
|
@@ -2847,9 +3034,9 @@ module.exports = SpaceOperators = (function() {
|
|
2847
3034
|
|
2848
3035
|
SpaceOperators.prototype.trackParens = function(token, tokenApi) {
|
2849
3036
|
if (token[0] === 'STRING_START') {
|
2850
|
-
this.
|
3037
|
+
this.interpolationLevel += 1;
|
2851
3038
|
} else if (token[0] === 'STRING_END') {
|
2852
|
-
this.
|
3039
|
+
this.interpolationLevel -= 1;
|
2853
3040
|
}
|
2854
3041
|
return null;
|
2855
3042
|
};
|
@@ -2860,24 +3047,24 @@ module.exports = SpaceOperators = (function() {
|
|
2860
3047
|
|
2861
3048
|
|
2862
3049
|
|
2863
|
-
},{}],
|
2864
|
-
var
|
3050
|
+
},{}],44:[function(require,module,exports){
|
3051
|
+
var SpacingAfterComma;
|
2865
3052
|
|
2866
|
-
module.exports =
|
2867
|
-
|
3053
|
+
module.exports = SpacingAfterComma = (function() {
|
3054
|
+
SpacingAfterComma.prototype.rule = {
|
2868
3055
|
name: 'spacing_after_comma',
|
2869
3056
|
description: 'This rule requires a space after commas.',
|
2870
3057
|
level: 'ignore',
|
2871
3058
|
message: 'Spaces are required after commas'
|
2872
3059
|
};
|
2873
3060
|
|
2874
|
-
|
3061
|
+
SpacingAfterComma.prototype.tokens = [',', 'REGEX_START', 'REGEX_END'];
|
2875
3062
|
|
2876
|
-
function
|
3063
|
+
function SpacingAfterComma() {
|
2877
3064
|
this.inRegex = false;
|
2878
3065
|
}
|
2879
3066
|
|
2880
|
-
|
3067
|
+
SpacingAfterComma.prototype.lintToken = function(token, tokenApi) {
|
2881
3068
|
var type;
|
2882
3069
|
type = token[0];
|
2883
3070
|
if (type === 'REGEX_START') {
|
@@ -2895,7 +3082,7 @@ module.exports = RuleProcessor = (function() {
|
|
2895
3082
|
}
|
2896
3083
|
};
|
2897
3084
|
|
2898
|
-
|
3085
|
+
SpacingAfterComma.prototype.isRegexFlag = function(token, tokenApi) {
|
2899
3086
|
var maybeEnd;
|
2900
3087
|
if (!this.inRegex) {
|
2901
3088
|
return false;
|
@@ -2904,30 +3091,30 @@ module.exports = RuleProcessor = (function() {
|
|
2904
3091
|
return (maybeEnd != null ? maybeEnd[0] : void 0) === 'REGEX_END';
|
2905
3092
|
};
|
2906
3093
|
|
2907
|
-
return
|
3094
|
+
return SpacingAfterComma;
|
2908
3095
|
|
2909
3096
|
})();
|
2910
3097
|
|
2911
3098
|
|
2912
3099
|
|
2913
|
-
},{}],
|
2914
|
-
var
|
3100
|
+
},{}],45:[function(require,module,exports){
|
3101
|
+
var TransformMessesUpLineNumbers;
|
2915
3102
|
|
2916
|
-
module.exports =
|
2917
|
-
function
|
3103
|
+
module.exports = TransformMessesUpLineNumbers = (function() {
|
3104
|
+
function TransformMessesUpLineNumbers() {}
|
2918
3105
|
|
2919
|
-
|
3106
|
+
TransformMessesUpLineNumbers.prototype.rule = {
|
2920
3107
|
name: 'transform_messes_up_line_numbers',
|
2921
3108
|
level: 'warn',
|
2922
3109
|
message: 'Transforming source messes up line numbers',
|
2923
3110
|
description: "This rule detects when changes are made by transform function,\nand warns that line numbers are probably incorrect."
|
2924
3111
|
};
|
2925
3112
|
|
2926
|
-
|
3113
|
+
TransformMessesUpLineNumbers.prototype.tokens = [];
|
2927
3114
|
|
2928
|
-
|
3115
|
+
TransformMessesUpLineNumbers.prototype.lintToken = function(token, tokenApi) {};
|
2929
3116
|
|
2930
|
-
return
|
3117
|
+
return TransformMessesUpLineNumbers;
|
2931
3118
|
|
2932
3119
|
})();
|
2933
3120
|
|
data/lib/coffeelint.rb
CHANGED
data/lib/coffeelint/version.rb
CHANGED
data/lib/tasks/coffeelint.rake
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
desc "lint application javascript"
|
2
2
|
task :coffeelint do
|
3
|
-
|
4
|
-
fail "Lint!" unless
|
3
|
+
failures = Coffeelint.run_test_suite('app') + Coffeelint.run_test_suite('spec')
|
4
|
+
fail "Lint!" unless failures == 0
|
5
5
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coffeelint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zachary Bush
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: coffee-script
|