Skip to content
Browse files

Switch to the bleeding edge version of Esprima.

We need a few Esprima features that are not in the stable version
yet so I've decided to use -dev version until Esprima 1.0 arrives.

Esprima changed how its output data a bit so I need to update some
code to make sure all tests pass (they do now). But this means
that JSHint Next is not compatible with current stable version of
Esprima anymore.
  • Loading branch information...
1 parent 22a3aeb commit 98f1727930587d80b06462e059f306bc805cbf38 @valueof valueof committed
Showing with 269 additions and 49 deletions.
  1. +1 −1 package.json
  2. +1 −1 src/reason.js
  3. +265 −45 test/fixtures/parser/tokens.json
  4. +1 −1 test/unit/parser.js
  5. +1 −1 test/unit/utils.js
View
2 package.json
@@ -9,7 +9,7 @@
},
"dependencies": {
- "esprima": "*",
+ "esprima": "https://github.com/ariya/esprima/tarball/master",
"underscore": "*",
"peakle": "*"
},
View
2 src/reason.js
@@ -12,7 +12,7 @@ exports.register = function (linter) {
// Check for trailing commas in arrays and objects.
linter.on("ArrayExpression ObjectExpression", function (expr) {
- var token = tokens.move(tokens.find(expr.range[1] - 2));
+ var token = tokens.move(tokens.find(expr.range[1] - 3));
if (token.isPunctuator(","))
report.addError("E001", token.range);
View
310 test/fixtures/parser/tokens.json
@@ -4,175 +4,395 @@
"value": "var",
"range": [
16,
- 18
- ]
+ 19
+ ],
+ "loc": {
+ "start": {
+ "line": 3,
+ "column": 0
+ },
+ "end": {
+ "line": 3,
+ "column": 3
+ }
+ }
},
{
"type": "Identifier",
"value": "number",
"range": [
20,
- 25
- ]
+ 26
+ ],
+ "loc": {
+ "start": {
+ "line": 3,
+ "column": 4
+ },
+ "end": {
+ "line": 3,
+ "column": 10
+ }
+ }
},
{
"type": "Punctuator",
"value": "=",
"range": [
27,
- 27
- ]
+ 28
+ ],
+ "loc": {
+ "start": {
+ "line": 3,
+ "column": 11
+ },
+ "end": {
+ "line": 3,
+ "column": 12
+ }
+ }
},
{
"type": "Numeric",
"value": "1",
"range": [
29,
- 29
- ]
+ 30
+ ],
+ "loc": {
+ "start": {
+ "line": 3,
+ "column": 13
+ },
+ "end": {
+ "line": 3,
+ "column": 14
+ }
+ }
},
{
"type": "Punctuator",
"value": ";",
"range": [
30,
- 30
- ]
+ 31
+ ],
+ "loc": {
+ "start": {
+ "line": 3,
+ "column": 14
+ },
+ "end": {
+ "line": 3,
+ "column": 15
+ }
+ }
},
{
"type": "Keyword",
"value": "function",
"range": [
33,
- 40
- ]
+ 41
+ ],
+ "loc": {
+ "start": {
+ "line": 5,
+ "column": 0
+ },
+ "end": {
+ "line": 5,
+ "column": 8
+ }
+ }
},
{
"type": "Identifier",
"value": "add",
"range": [
42,
- 44
- ]
+ 45
+ ],
+ "loc": {
+ "start": {
+ "line": 5,
+ "column": 9
+ },
+ "end": {
+ "line": 5,
+ "column": 12
+ }
+ }
},
{
"type": "Punctuator",
"value": "(",
"range": [
45,
- 45
- ]
+ 46
+ ],
+ "loc": {
+ "start": {
+ "line": 5,
+ "column": 12
+ },
+ "end": {
+ "line": 5,
+ "column": 13
+ }
+ }
},
{
"type": "Identifier",
"value": "num",
"range": [
46,
- 48
- ]
+ 49
+ ],
+ "loc": {
+ "start": {
+ "line": 5,
+ "column": 13
+ },
+ "end": {
+ "line": 5,
+ "column": 16
+ }
+ }
},
{
"type": "Punctuator",
"value": ")",
"range": [
49,
- 49
- ]
+ 50
+ ],
+ "loc": {
+ "start": {
+ "line": 5,
+ "column": 16
+ },
+ "end": {
+ "line": 5,
+ "column": 17
+ }
+ }
},
{
"type": "Punctuator",
"value": "{",
"range": [
51,
- 51
- ]
+ 52
+ ],
+ "loc": {
+ "start": {
+ "line": 5,
+ "column": 18
+ },
+ "end": {
+ "line": 5,
+ "column": 19
+ }
+ }
},
{
"type": "Keyword",
"value": "return",
"range": [
55,
- 60
- ]
+ 61
+ ],
+ "loc": {
+ "start": {
+ "line": 6,
+ "column": 2
+ },
+ "end": {
+ "line": 6,
+ "column": 8
+ }
+ }
},
{
"type": "Identifier",
"value": "number",
"range": [
62,
- 67
- ]
+ 68
+ ],
+ "loc": {
+ "start": {
+ "line": 6,
+ "column": 9
+ },
+ "end": {
+ "line": 6,
+ "column": 15
+ }
+ }
},
{
"type": "Punctuator",
"value": "+",
"range": [
69,
- 69
- ]
+ 70
+ ],
+ "loc": {
+ "start": {
+ "line": 6,
+ "column": 16
+ },
+ "end": {
+ "line": 6,
+ "column": 17
+ }
+ }
},
{
"type": "Identifier",
"value": "num",
"range": [
71,
- 73
- ]
+ 74
+ ],
+ "loc": {
+ "start": {
+ "line": 6,
+ "column": 18
+ },
+ "end": {
+ "line": 6,
+ "column": 21
+ }
+ }
},
{
"type": "Punctuator",
"value": ";",
"range": [
74,
- 74
- ]
+ 75
+ ],
+ "loc": {
+ "start": {
+ "line": 6,
+ "column": 21
+ },
+ "end": {
+ "line": 6,
+ "column": 22
+ }
+ }
},
{
"type": "Punctuator",
"value": "}",
"range": [
76,
- 76
- ]
+ 77
+ ],
+ "loc": {
+ "start": {
+ "line": 7,
+ "column": 0
+ },
+ "end": {
+ "line": 7,
+ "column": 1
+ }
+ }
},
{
"type": "Identifier",
"value": "add",
"range": [
79,
- 81
- ]
+ 82
+ ],
+ "loc": {
+ "start": {
+ "line": 9,
+ "column": 0
+ },
+ "end": {
+ "line": 9,
+ "column": 3
+ }
+ }
},
{
"type": "Punctuator",
"value": "(",
"range": [
82,
- 82
- ]
+ 83
+ ],
+ "loc": {
+ "start": {
+ "line": 9,
+ "column": 3
+ },
+ "end": {
+ "line": 9,
+ "column": 4
+ }
+ }
},
{
"type": "Numeric",
"value": "1",
"range": [
83,
- 83
- ]
+ 84
+ ],
+ "loc": {
+ "start": {
+ "line": 9,
+ "column": 4
+ },
+ "end": {
+ "line": 9,
+ "column": 5
+ }
+ }
},
{
"type": "Punctuator",
"value": ")",
"range": [
84,
- 84
- ]
+ 85
+ ],
+ "loc": {
+ "start": {
+ "line": 9,
+ "column": 5
+ },
+ "end": {
+ "line": 9,
+ "column": 6
+ }
+ }
},
{
"type": "Punctuator",
"value": ";",
"range": [
85,
- 85
- ]
+ 86
+ ],
+ "loc": {
+ "start": {
+ "line": 9,
+ "column": 6
+ },
+ "end": {
+ "line": 9,
+ "column": 7
+ }
+ }
}
-]
+]
View
2 test/unit/parser.js
@@ -23,7 +23,7 @@ exports.testTree = function (test) {
test.equal(tree.body[2].expression.callee.name, "add");
test.equal(tree.comments[0].type, "Block");
test.equal(tree.comments[0].value, " [linter] ");
- test.deepEqual(tree.comments[0].range, [ 0, 13 ]);
+ test.deepEqual(tree.comments[0].range, [ 0, 14 ]);
test.done();
};
View
2 test/unit/utils.js
@@ -42,7 +42,7 @@ exports.testReport = function (test) {
exports.testTokens = function (test) {
var code = fixtures.get("simple_file.js");
var tokens = new utils.Tokens(linter.lint({ code: code }).tree.tokens);
- var slice = tokens.getRange([ 0, 27 ]);
+ var slice = tokens.getRange([ 0, 28 ]);
test.equal(slice.length, 3);
test.equal(slice.current.value, "var");

0 comments on commit 98f1727

Please sign in to comment.
Something went wrong with that request. Please try again.