rapydscript-ng 0.7.23 → 0.7.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ version 0.7.24
2
+ =======================
3
+
4
+ * Fix linter warning about end of line semi colons inside multiline string literals
5
+
1
6
  version 0.7.23
2
7
  =======================
3
8
 
package/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "start": "node bin/rapydscript",
15
15
  "build-self": "node bin/rapydscript self --complete"
16
16
  },
17
- "version": "0.7.23",
17
+ "version": "0.7.24",
18
18
  "license": "BSD-2-Clause",
19
19
  "engines": {
20
20
  "node": ">=0.12.0"
package/test/lint.pyj CHANGED
@@ -83,6 +83,8 @@ err_test('def f():\n a = 1\n for a in "":\n a', 'loop-shadowed', 3, 'a', 2)
83
83
  # Semi-colons
84
84
  err_test('a=1;;a', 'extra-semicolon', 1, ';')
85
85
  err_test('a=1;', 'eol-semicolon', 1, ';')
86
+ ok_test('a = """\nhello;\n"""')
87
+ ok_test("a = '''\nhello;\n'''")
86
88
 
87
89
  # Builtins
88
90
  for k in 'String Symbol this self window Map arguments print len range dir undefined'.split(' '):
package/tools/lint.js CHANGED
@@ -498,11 +498,39 @@ function Linter(toplevel, filename, code, options) {
498
498
  this.resolve = function() {
499
499
  var messages = this.messages;
500
500
  var line_filters = {};
501
+ var in_multiline_str = false;
502
+ var ml_quote = null;
501
503
 
502
504
  code.split('\n').forEach(function(line, num) {
503
505
  line = line.trimRight();
504
506
  num++;
505
- if (line[line.length - 1] === ';') {
507
+
508
+ // Track triple-quoted multiline string state so we can skip
509
+ // eol-semicolon checks for lines that are inside string literals.
510
+ var line_starts_in_multiline = in_multiline_str;
511
+ var pos = 0, close_pos;
512
+ while (pos < line.length) {
513
+ if (!in_multiline_str) {
514
+ var dq = line.indexOf('"""', pos);
515
+ var sq = line.indexOf("'''", pos);
516
+ var first, quote;
517
+ if (dq !== -1 && (sq === -1 || dq < sq)) { first = dq; quote = '"""'; }
518
+ else if (sq !== -1) { first = sq; quote = "'''"; }
519
+ else break;
520
+ in_multiline_str = true;
521
+ ml_quote = quote;
522
+ pos = first + 3;
523
+ close_pos = line.indexOf(ml_quote, pos);
524
+ if (close_pos !== -1) { in_multiline_str = false; ml_quote = null; pos = close_pos + 3; }
525
+ else break;
526
+ } else {
527
+ close_pos = line.indexOf(ml_quote, pos);
528
+ if (close_pos !== -1) { in_multiline_str = false; ml_quote = null; pos = close_pos + 3; }
529
+ else break;
530
+ }
531
+ }
532
+
533
+ if (!line_starts_in_multiline && !in_multiline_str && line[line.length - 1] === ';') {
506
534
  var ident = 'eol-semicolon';
507
535
  messages.push({filename:filename, ident:ident, message:MESSAGES[ident],
508
536
  level:WARN, name:';', start_line:num, start_col:line.lastIndexOf(';')});