diff --git a/src/convert-comments.ts b/src/convert-comments.ts
index 25d4287..dda9ceb 100644
--- a/src/convert-comments.ts
+++ b/src/convert-comments.ts
@@ -107,7 +107,12 @@ export function convertComments(
* Create a TypeScript Scanner, with skipTrivia set to false so that
* we can parse the comments
*/
- const triviaScanner = ts.createScanner(ast.languageVersion, false, 0, code);
+ const triviaScanner = ts.createScanner(
+ ast.languageVersion,
+ false,
+ ast.languageVariant,
+ code
+ );
let kind = triviaScanner.scan();
while (kind !== ts.SyntaxKind.EndOfFileToken) {
@@ -123,8 +128,21 @@ export function convertComments(
comments.push(comment);
break;
}
+ case ts.SyntaxKind.GreaterThanToken:
+ container = nodeUtils.getNodeContainer(ast, start, end);
+ if (
+ container &&
+ container.parent &&
+ container.parent.kind === ts.SyntaxKind.JsxOpeningElement &&
+ container.parent.parent &&
+ container.parent.parent.kind === ts.SyntaxKind.JsxElement
+ ) {
+ kind = triviaScanner.reScanJsxToken();
+ continue;
+ }
+ break;
case ts.SyntaxKind.CloseBraceToken:
- container = nodeUtils.getNodeContainer(ast, start, end) as ts.Node;
+ container = nodeUtils.getNodeContainer(ast, start, end);
if (
container.kind === ts.SyntaxKind.TemplateMiddle ||
diff --git a/tests/fixtures/comments/jsx-comment-after-jsx.src.js b/tests/fixtures/comments/jsx-comment-after-jsx.src.js
new file mode 100644
index 0000000..32c4c53
--- /dev/null
+++ b/tests/fixtures/comments/jsx-comment-after-jsx.src.js
@@ -0,0 +1,5 @@
+const pure = () => {
+ return (
+ // Foo
+ );
+}
diff --git a/tests/fixtures/comments/jsx-comment-after-self-closing-jsx.src.js b/tests/fixtures/comments/jsx-comment-after-self-closing-jsx.src.js
new file mode 100644
index 0000000..ef446a5
--- /dev/null
+++ b/tests/fixtures/comments/jsx-comment-after-self-closing-jsx.src.js
@@ -0,0 +1,5 @@
+const pure = () => {
+ return (
+ // Foo
+ );
+}
diff --git a/tests/fixtures/comments/jsx-text-with-multiline-non-comment.src.js b/tests/fixtures/comments/jsx-text-with-multiline-non-comment.src.js
new file mode 100644
index 0000000..c14b0ae
--- /dev/null
+++ b/tests/fixtures/comments/jsx-text-with-multiline-non-comment.src.js
@@ -0,0 +1,9 @@
+const pure = () => {
+ return (
+
+ /**
+ * test
+ */
+
+ );
+}
diff --git a/tests/fixtures/comments/jsx-text-with-url.src.js b/tests/fixtures/comments/jsx-text-with-url.src.js
new file mode 100644
index 0000000..ab57e8d
--- /dev/null
+++ b/tests/fixtures/comments/jsx-text-with-url.src.js
@@ -0,0 +1 @@
+const link = (http://example.com);
diff --git a/tests/fixtures/comments/jsx-with-greather-than.src.js b/tests/fixtures/comments/jsx-with-greather-than.src.js
new file mode 100644
index 0000000..6294ad6
--- /dev/null
+++ b/tests/fixtures/comments/jsx-with-greather-than.src.js
@@ -0,0 +1,4 @@
+if (1 >/* Test */2) {
+ test( 2 >> 3);
+ const foo = //
+}
diff --git a/tests/fixtures/comments/jsx-with-operators.src.js b/tests/fixtures/comments/jsx-with-operators.src.js
new file mode 100644
index 0000000..f14ac69
--- /dev/null
+++ b/tests/fixtures/comments/jsx-with-operators.src.js
@@ -0,0 +1,4 @@
+if (1 * Test */2) {
+ test( 2 >> 3);
+ const foo = //
+}
diff --git a/tests/fixtures/comments/type-assertion-regression-test.src.ts b/tests/fixtures/comments/type-assertion-regression-test.src.ts
new file mode 100644
index 0000000..5b14e97
--- /dev/null
+++ b/tests/fixtures/comments/type-assertion-regression-test.src.ts
@@ -0,0 +1,2 @@
+const foo = // test
+ bar;
diff --git a/tests/lib/__snapshots__/comments.ts.snap b/tests/lib/__snapshots__/comments.ts.snap
index 41309c3..7c05def 100644
--- a/tests/lib/__snapshots__/comments.ts.snap
+++ b/tests/lib/__snapshots__/comments.ts.snap
@@ -1912,7 +1912,7 @@ Object {
}
`;
-exports[`Comments fixtures/jsx-tag-comments.src 1`] = `
+exports[`Comments fixtures/jsx-comment-after-jsx.src 1`] = `
Object {
"body": Array [
Object {
@@ -1942,68 +1942,46 @@ Object {
"body": Array [
Object {
"argument": Object {
- "children": Array [
- Object {
- "loc": Object {
- "end": Object {
- "column": 8,
- "line": 7,
- },
- "start": Object {
- "column": 9,
- "line": 6,
- },
- },
- "range": Array [
- 103,
- 112,
- ],
- "raw": "
- ",
- "type": "Literal",
- "value": "
- ",
- },
- ],
+ "children": Array [],
"closingElement": Object {
"loc": Object {
"end": Object {
- "column": 14,
- "line": 7,
+ "column": 19,
+ "line": 3,
},
"start": Object {
- "column": 8,
- "line": 7,
+ "column": 13,
+ "line": 3,
},
},
"name": Object {
"loc": Object {
"end": Object {
- "column": 13,
- "line": 7,
+ "column": 18,
+ "line": 3,
},
"start": Object {
- "column": 10,
- "line": 7,
+ "column": 15,
+ "line": 3,
},
},
"name": "Foo",
"range": Array [
- 114,
- 117,
+ 49,
+ 52,
],
"type": "JSXIdentifier",
},
"range": Array [
- 112,
- 118,
+ 47,
+ 53,
],
"type": "JSXClosingElement",
},
"loc": Object {
"end": Object {
- "column": 14,
- "line": 7,
+ "column": 19,
+ "line": 3,
},
"start": Object {
"column": 8,
@@ -2014,8 +1992,8 @@ Object {
"attributes": Array [],
"loc": Object {
"end": Object {
- "column": 9,
- "line": 6,
+ "column": 13,
+ "line": 3,
},
"start": Object {
"column": 8,
@@ -2042,21 +2020,21 @@ Object {
},
"range": Array [
42,
- 103,
+ 47,
],
"selfClosing": false,
"type": "JSXOpeningElement",
},
"range": Array [
42,
- 118,
+ 53,
],
"type": "JSXElement",
},
"loc": Object {
"end": Object {
"column": 6,
- "line": 8,
+ "line": 4,
},
"start": Object {
"column": 4,
@@ -2065,7 +2043,7 @@ Object {
},
"range": Array [
25,
- 125,
+ 67,
],
"type": "ReturnStatement",
},
@@ -2073,7 +2051,7 @@ Object {
"loc": Object {
"end": Object {
"column": 1,
- "line": 9,
+ "line": 5,
},
"start": Object {
"column": 19,
@@ -2082,7 +2060,7 @@ Object {
},
"range": Array [
19,
- 127,
+ 69,
],
"type": "BlockStatement",
},
@@ -2092,7 +2070,7 @@ Object {
"loc": Object {
"end": Object {
"column": 1,
- "line": 9,
+ "line": 5,
},
"start": Object {
"column": 13,
@@ -2102,14 +2080,14 @@ Object {
"params": Array [],
"range": Array [
13,
- 127,
+ 69,
],
"type": "ArrowFunctionExpression",
},
"loc": Object {
"end": Object {
"column": 1,
- "line": 9,
+ "line": 5,
},
"start": Object {
"column": 6,
@@ -2118,7 +2096,7 @@ Object {
},
"range": Array [
6,
- 127,
+ 69,
],
"type": "VariableDeclarator",
},
@@ -2127,7 +2105,7 @@ Object {
"loc": Object {
"end": Object {
"column": 1,
- "line": 9,
+ "line": 5,
},
"start": Object {
"column": 0,
@@ -2136,7 +2114,7 @@ Object {
},
"range": Array [
0,
- 127,
+ 69,
],
"type": "VariableDeclaration",
},
@@ -2145,44 +2123,26 @@ Object {
Object {
"loc": Object {
"end": Object {
- "column": 21,
- "line": 4,
+ "column": 26,
+ "line": 3,
},
"start": Object {
- "column": 12,
- "line": 4,
+ "column": 20,
+ "line": 3,
},
},
"range": Array [
- 59,
- 68,
+ 54,
+ 60,
],
"type": "Line",
- "value": " single",
- },
- Object {
- "loc": Object {
- "end": Object {
- "column": 23,
- "line": 5,
- },
- "start": Object {
- "column": 12,
- "line": 5,
- },
- },
- "range": Array [
- 81,
- 92,
- ],
- "type": "Block",
- "value": " block ",
+ "value": " Foo",
},
],
"loc": Object {
"end": Object {
"column": 0,
- "line": 11,
+ "line": 6,
},
"start": Object {
"column": 0,
@@ -2191,7 +2151,7 @@ Object {
},
"range": Array [
0,
- 129,
+ 70,
],
"sourceType": "script",
"tokens": Array [
@@ -2396,17 +2356,17 @@ Object {
Object {
"loc": Object {
"end": Object {
- "column": 9,
- "line": 6,
+ "column": 13,
+ "line": 3,
},
"start": Object {
- "column": 8,
- "line": 6,
+ "column": 12,
+ "line": 3,
},
},
"range": Array [
- 102,
- 103,
+ 46,
+ 47,
],
"type": "Punctuator",
"value": ">",
@@ -2414,36 +2374,17 @@ Object {
Object {
"loc": Object {
"end": Object {
- "column": 8,
- "line": 7,
- },
- "start": Object {
- "column": 9,
- "line": 6,
- },
- },
- "range": Array [
- 103,
- 112,
- ],
- "type": "JSXText",
- "value": "
- ",
- },
- Object {
- "loc": Object {
- "end": Object {
- "column": 9,
- "line": 7,
+ "column": 14,
+ "line": 3,
},
"start": Object {
- "column": 8,
- "line": 7,
+ "column": 13,
+ "line": 3,
},
},
"range": Array [
- 112,
- 113,
+ 47,
+ 48,
],
"type": "Punctuator",
"value": "<",
@@ -2451,17 +2392,17 @@ Object {
Object {
"loc": Object {
"end": Object {
- "column": 10,
- "line": 7,
+ "column": 15,
+ "line": 3,
},
"start": Object {
- "column": 9,
- "line": 7,
+ "column": 14,
+ "line": 3,
},
},
"range": Array [
- 113,
- 114,
+ 48,
+ 49,
],
"type": "Punctuator",
"value": "/",
@@ -2469,17 +2410,17 @@ Object {
Object {
"loc": Object {
"end": Object {
- "column": 13,
- "line": 7,
+ "column": 18,
+ "line": 3,
},
"start": Object {
- "column": 10,
- "line": 7,
+ "column": 15,
+ "line": 3,
},
},
"range": Array [
- 114,
- 117,
+ 49,
+ 52,
],
"type": "JSXIdentifier",
"value": "Foo",
@@ -2487,17 +2428,17 @@ Object {
Object {
"loc": Object {
"end": Object {
- "column": 14,
- "line": 7,
+ "column": 19,
+ "line": 3,
},
"start": Object {
- "column": 13,
- "line": 7,
+ "column": 18,
+ "line": 3,
},
},
"range": Array [
- 117,
- 118,
+ 52,
+ 53,
],
"type": "Punctuator",
"value": ">",
@@ -2506,16 +2447,16 @@ Object {
"loc": Object {
"end": Object {
"column": 5,
- "line": 8,
+ "line": 4,
},
"start": Object {
"column": 4,
- "line": 8,
+ "line": 4,
},
},
"range": Array [
- 123,
- 124,
+ 65,
+ 66,
],
"type": "Punctuator",
"value": ")",
@@ -2524,16 +2465,16 @@ Object {
"loc": Object {
"end": Object {
"column": 6,
- "line": 8,
+ "line": 4,
},
"start": Object {
"column": 5,
- "line": 8,
+ "line": 4,
},
},
"range": Array [
- 124,
- 125,
+ 66,
+ 67,
],
"type": "Punctuator",
"value": ";",
@@ -2542,16 +2483,16 @@ Object {
"loc": Object {
"end": Object {
"column": 1,
- "line": 9,
+ "line": 5,
},
"start": Object {
"column": 0,
- "line": 9,
+ "line": 5,
},
},
"range": Array [
- 126,
- 127,
+ 68,
+ 69,
],
"type": "Punctuator",
"value": "}",
@@ -2561,50 +2502,7 @@ Object {
}
`;
-exports[`Comments fixtures/line-comment-with-block-syntax.src 1`] = `
-Object {
- "body": Array [],
- "comments": Array [
- Object {
- "loc": Object {
- "end": Object {
- "column": 11,
- "line": 1,
- },
- "start": Object {
- "column": 0,
- "line": 1,
- },
- },
- "range": Array [
- 0,
- 11,
- ],
- "type": "Line",
- "value": " /*test*/",
- },
- ],
- "loc": Object {
- "end": Object {
- "column": 0,
- "line": 2,
- },
- "start": Object {
- "column": 0,
- "line": 2,
- },
- },
- "range": Array [
- 12,
- 12,
- ],
- "sourceType": "script",
- "tokens": Array [],
- "type": "Program",
-}
-`;
-
-exports[`Comments fixtures/mix-line-and-block-comments.src 1`] = `
+exports[`Comments fixtures/jsx-comment-after-self-closing-jsx.src 1`] = `
Object {
"body": Array [
Object {
@@ -2613,71 +2511,166 @@ Object {
"id": Object {
"loc": Object {
"end": Object {
- "column": 7,
- "line": 2,
+ "column": 10,
+ "line": 1,
},
"start": Object {
- "column": 4,
- "line": 2,
- },
+ "column": 6,
+ "line": 1,
+ },
},
- "name": "zzz",
+ "name": "pure",
"range": Array [
+ 6,
10,
- 13,
],
"type": "Identifier",
},
"init": Object {
+ "async": false,
+ "body": Object {
+ "body": Array [
+ Object {
+ "argument": Object {
+ "children": Array [],
+ "closingElement": null,
+ "loc": Object {
+ "end": Object {
+ "column": 15,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 8,
+ "line": 3,
+ },
+ },
+ "openingElement": Object {
+ "attributes": Array [],
+ "loc": Object {
+ "end": Object {
+ "column": 15,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 8,
+ "line": 3,
+ },
+ },
+ "name": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 12,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 9,
+ "line": 3,
+ },
+ },
+ "name": "Foo",
+ "range": Array [
+ 43,
+ 46,
+ ],
+ "type": "JSXIdentifier",
+ },
+ "range": Array [
+ 42,
+ 49,
+ ],
+ "selfClosing": true,
+ "type": "JSXOpeningElement",
+ },
+ "range": Array [
+ 42,
+ 49,
+ ],
+ "type": "JSXElement",
+ },
+ "loc": Object {
+ "end": Object {
+ "column": 6,
+ "line": 4,
+ },
+ "start": Object {
+ "column": 4,
+ "line": 2,
+ },
+ },
+ "range": Array [
+ 25,
+ 63,
+ ],
+ "type": "ReturnStatement",
+ },
+ ],
+ "loc": Object {
+ "end": Object {
+ "column": 1,
+ "line": 5,
+ },
+ "start": Object {
+ "column": 19,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 19,
+ 65,
+ ],
+ "type": "BlockStatement",
+ },
+ "expression": false,
+ "generator": false,
+ "id": null,
"loc": Object {
"end": Object {
- "column": 21,
- "line": 2,
+ "column": 1,
+ "line": 5,
},
"start": Object {
- "column": 18,
- "line": 2,
+ "column": 13,
+ "line": 1,
},
},
+ "params": Array [],
"range": Array [
- 24,
- 27,
+ 13,
+ 65,
],
- "raw": "777",
- "type": "Literal",
- "value": 777,
+ "type": "ArrowFunctionExpression",
},
"loc": Object {
"end": Object {
- "column": 21,
- "line": 2,
+ "column": 1,
+ "line": 5,
},
"start": Object {
- "column": 4,
- "line": 2,
+ "column": 6,
+ "line": 1,
},
},
"range": Array [
- 10,
- 27,
+ 6,
+ 65,
],
"type": "VariableDeclarator",
},
],
- "kind": "var",
+ "kind": "const",
"loc": Object {
"end": Object {
- "column": 22,
- "line": 2,
+ "column": 1,
+ "line": 5,
},
"start": Object {
"column": 0,
- "line": 2,
+ "line": 1,
},
},
"range": Array [
- 6,
- 28,
+ 0,
+ 65,
],
"type": "VariableDeclaration",
},
@@ -2686,124 +2679,88 @@ Object {
Object {
"loc": Object {
"end": Object {
- "column": 5,
- "line": 1,
- },
- "start": Object {
- "column": 0,
- "line": 1,
- },
- },
- "range": Array [
- 0,
- 5,
- ],
- "type": "Line",
- "value": "foo",
- },
- Object {
- "loc": Object {
- "end": Object {
- "column": 15,
- "line": 2,
- },
- "start": Object {
- "column": 8,
- "line": 2,
- },
- },
- "range": Array [
- 14,
- 21,
- ],
- "type": "Block",
- "value": "aaa",
- },
- Object {
- "loc": Object {
- "end": Object {
- "column": 5,
+ "column": 22,
"line": 3,
},
"start": Object {
- "column": 0,
+ "column": 16,
"line": 3,
},
},
"range": Array [
- 29,
- 34,
+ 50,
+ 56,
],
"type": "Line",
- "value": "bar",
+ "value": " Foo",
},
],
"loc": Object {
"end": Object {
"column": 0,
- "line": 4,
+ "line": 6,
},
"start": Object {
"column": 0,
- "line": 2,
+ "line": 1,
},
},
"range": Array [
- 6,
- 35,
+ 0,
+ 66,
],
"sourceType": "script",
"tokens": Array [
Object {
"loc": Object {
"end": Object {
- "column": 3,
- "line": 2,
+ "column": 5,
+ "line": 1,
},
"start": Object {
"column": 0,
- "line": 2,
+ "line": 1,
},
},
"range": Array [
- 6,
- 9,
+ 0,
+ 5,
],
"type": "Keyword",
- "value": "var",
+ "value": "const",
},
Object {
"loc": Object {
"end": Object {
- "column": 7,
- "line": 2,
+ "column": 10,
+ "line": 1,
},
"start": Object {
- "column": 4,
- "line": 2,
+ "column": 6,
+ "line": 1,
},
},
"range": Array [
+ 6,
10,
- 13,
],
"type": "Identifier",
- "value": "zzz",
+ "value": "pure",
},
Object {
"loc": Object {
"end": Object {
- "column": 17,
- "line": 2,
+ "column": 12,
+ "line": 1,
},
"start": Object {
- "column": 16,
- "line": 2,
+ "column": 11,
+ "line": 1,
},
},
"range": Array [
- 22,
- 23,
+ 11,
+ 12,
],
"type": "Punctuator",
"value": "=",
@@ -2811,243 +2768,243 @@ Object {
Object {
"loc": Object {
"end": Object {
- "column": 21,
- "line": 2,
+ "column": 14,
+ "line": 1,
},
"start": Object {
- "column": 18,
- "line": 2,
+ "column": 13,
+ "line": 1,
},
},
"range": Array [
- 24,
- 27,
+ 13,
+ 14,
],
- "type": "Numeric",
- "value": "777",
+ "type": "Punctuator",
+ "value": "(",
},
Object {
"loc": Object {
"end": Object {
- "column": 22,
- "line": 2,
+ "column": 15,
+ "line": 1,
},
"start": Object {
- "column": 21,
- "line": 2,
+ "column": 14,
+ "line": 1,
},
},
"range": Array [
- 27,
- 28,
+ 14,
+ 15,
],
"type": "Punctuator",
- "value": ";",
+ "value": ")",
},
- ],
- "type": "Program",
-}
-`;
-
-exports[`Comments fixtures/no-comment-regex.src 1`] = `
-Object {
- "body": Array [
Object {
- "declarations": Array [
- Object {
- "id": Object {
- "loc": Object {
- "end": Object {
- "column": 11,
- "line": 1,
- },
- "start": Object {
- "column": 6,
- "line": 1,
- },
- },
- "name": "regex",
- "range": Array [
- 6,
- 11,
- ],
- "type": "Identifier",
- },
- "init": Object {
- "loc": Object {
- "end": Object {
- "column": 33,
- "line": 1,
- },
- "start": Object {
- "column": 14,
- "line": 1,
- },
- },
- "range": Array [
- 14,
- 33,
- ],
- "raw": "/no comment\\\\/**foo/",
- "regex": Object {
- "flags": "",
- "pattern": "no comment\\\\/**foo",
- },
- "type": "Literal",
- "value": null,
- },
- "loc": Object {
- "end": Object {
- "column": 33,
- "line": 1,
- },
- "start": Object {
- "column": 6,
- "line": 1,
- },
- },
- "range": Array [
- 6,
- 33,
- ],
- "type": "VariableDeclarator",
- },
- ],
- "kind": "const",
"loc": Object {
"end": Object {
- "column": 34,
+ "column": 18,
"line": 1,
},
"start": Object {
- "column": 0,
+ "column": 16,
"line": 1,
},
},
"range": Array [
- 0,
- 34,
+ 16,
+ 18,
],
- "type": "VariableDeclaration",
- },
- ],
- "comments": Array [],
- "loc": Object {
- "end": Object {
- "column": 0,
- "line": 2,
- },
- "start": Object {
- "column": 0,
- "line": 1,
+ "type": "Punctuator",
+ "value": "=>",
},
- },
- "range": Array [
- 0,
- 35,
- ],
- "sourceType": "script",
- "tokens": Array [
Object {
"loc": Object {
"end": Object {
- "column": 5,
+ "column": 20,
"line": 1,
},
"start": Object {
- "column": 0,
+ "column": 19,
"line": 1,
},
},
"range": Array [
- 0,
- 5,
+ 19,
+ 20,
+ ],
+ "type": "Punctuator",
+ "value": "{",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 10,
+ "line": 2,
+ },
+ "start": Object {
+ "column": 4,
+ "line": 2,
+ },
+ },
+ "range": Array [
+ 25,
+ 31,
],
"type": "Keyword",
- "value": "const",
+ "value": "return",
},
Object {
"loc": Object {
"end": Object {
- "column": 11,
- "line": 1,
+ "column": 12,
+ "line": 2,
},
"start": Object {
- "column": 6,
- "line": 1,
+ "column": 11,
+ "line": 2,
},
},
"range": Array [
- 6,
- 11,
+ 32,
+ 33,
],
- "type": "Identifier",
- "value": "regex",
+ "type": "Punctuator",
+ "value": "(",
},
Object {
"loc": Object {
"end": Object {
- "column": 13,
- "line": 1,
+ "column": 9,
+ "line": 3,
},
"start": Object {
+ "column": 8,
+ "line": 3,
+ },
+ },
+ "range": Array [
+ 42,
+ 43,
+ ],
+ "type": "Punctuator",
+ "value": "<",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
"column": 12,
- "line": 1,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 9,
+ "line": 3,
},
},
"range": Array [
- 12,
- 13,
+ 43,
+ 46,
+ ],
+ "type": "JSXIdentifier",
+ "value": "Foo",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 14,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 13,
+ "line": 3,
+ },
+ },
+ "range": Array [
+ 47,
+ 48,
],
"type": "Punctuator",
- "value": "=",
+ "value": "/",
},
Object {
"loc": Object {
"end": Object {
- "column": 33,
- "line": 1,
+ "column": 15,
+ "line": 3,
},
"start": Object {
"column": 14,
- "line": 1,
+ "line": 3,
},
},
"range": Array [
- 14,
- 33,
+ 48,
+ 49,
],
- "regex": Object {
- "flags": "",
- "pattern": "no comment\\\\/**foo",
+ "type": "Punctuator",
+ "value": ">",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 5,
+ "line": 4,
+ },
+ "start": Object {
+ "column": 4,
+ "line": 4,
+ },
},
- "type": "RegularExpression",
- "value": "/no comment\\\\/**foo/",
+ "range": Array [
+ 61,
+ 62,
+ ],
+ "type": "Punctuator",
+ "value": ")",
},
Object {
"loc": Object {
"end": Object {
- "column": 34,
- "line": 1,
+ "column": 6,
+ "line": 4,
},
"start": Object {
- "column": 33,
- "line": 1,
+ "column": 5,
+ "line": 4,
},
},
"range": Array [
- 33,
- 34,
+ 62,
+ 63,
],
"type": "Punctuator",
"value": ";",
},
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 1,
+ "line": 5,
+ },
+ "start": Object {
+ "column": 0,
+ "line": 5,
+ },
+ },
+ "range": Array [
+ 64,
+ 65,
+ ],
+ "type": "Punctuator",
+ "value": "}",
+ },
],
"type": "Program",
}
`;
-exports[`Comments fixtures/no-comment-template.src 1`] = `
+exports[`Comments fixtures/jsx-tag-comments.src 1`] = `
Object {
"body": Array [
Object {
@@ -3056,7 +3013,7 @@ Object {
"id": Object {
"loc": Object {
"end": Object {
- "column": 9,
+ "column": 10,
"line": 1,
},
"start": Object {
@@ -3064,10 +3021,4080 @@ Object {
"line": 1,
},
},
- "name": "str",
+ "name": "pure",
"range": Array [
6,
- 9,
+ 10,
+ ],
+ "type": "Identifier",
+ },
+ "init": Object {
+ "async": false,
+ "body": Object {
+ "body": Array [
+ Object {
+ "argument": Object {
+ "children": Array [
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 8,
+ "line": 7,
+ },
+ "start": Object {
+ "column": 9,
+ "line": 6,
+ },
+ },
+ "range": Array [
+ 103,
+ 112,
+ ],
+ "raw": "
+ ",
+ "type": "Literal",
+ "value": "
+ ",
+ },
+ ],
+ "closingElement": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 14,
+ "line": 7,
+ },
+ "start": Object {
+ "column": 8,
+ "line": 7,
+ },
+ },
+ "name": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 13,
+ "line": 7,
+ },
+ "start": Object {
+ "column": 10,
+ "line": 7,
+ },
+ },
+ "name": "Foo",
+ "range": Array [
+ 114,
+ 117,
+ ],
+ "type": "JSXIdentifier",
+ },
+ "range": Array [
+ 112,
+ 118,
+ ],
+ "type": "JSXClosingElement",
+ },
+ "loc": Object {
+ "end": Object {
+ "column": 14,
+ "line": 7,
+ },
+ "start": Object {
+ "column": 8,
+ "line": 3,
+ },
+ },
+ "openingElement": Object {
+ "attributes": Array [],
+ "loc": Object {
+ "end": Object {
+ "column": 9,
+ "line": 6,
+ },
+ "start": Object {
+ "column": 8,
+ "line": 3,
+ },
+ },
+ "name": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 12,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 9,
+ "line": 3,
+ },
+ },
+ "name": "Foo",
+ "range": Array [
+ 43,
+ 46,
+ ],
+ "type": "JSXIdentifier",
+ },
+ "range": Array [
+ 42,
+ 103,
+ ],
+ "selfClosing": false,
+ "type": "JSXOpeningElement",
+ },
+ "range": Array [
+ 42,
+ 118,
+ ],
+ "type": "JSXElement",
+ },
+ "loc": Object {
+ "end": Object {
+ "column": 6,
+ "line": 8,
+ },
+ "start": Object {
+ "column": 4,
+ "line": 2,
+ },
+ },
+ "range": Array [
+ 25,
+ 125,
+ ],
+ "type": "ReturnStatement",
+ },
+ ],
+ "loc": Object {
+ "end": Object {
+ "column": 1,
+ "line": 9,
+ },
+ "start": Object {
+ "column": 19,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 19,
+ 127,
+ ],
+ "type": "BlockStatement",
+ },
+ "expression": false,
+ "generator": false,
+ "id": null,
+ "loc": Object {
+ "end": Object {
+ "column": 1,
+ "line": 9,
+ },
+ "start": Object {
+ "column": 13,
+ "line": 1,
+ },
+ },
+ "params": Array [],
+ "range": Array [
+ 13,
+ 127,
+ ],
+ "type": "ArrowFunctionExpression",
+ },
+ "loc": Object {
+ "end": Object {
+ "column": 1,
+ "line": 9,
+ },
+ "start": Object {
+ "column": 6,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 6,
+ 127,
+ ],
+ "type": "VariableDeclarator",
+ },
+ ],
+ "kind": "const",
+ "loc": Object {
+ "end": Object {
+ "column": 1,
+ "line": 9,
+ },
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 0,
+ 127,
+ ],
+ "type": "VariableDeclaration",
+ },
+ ],
+ "comments": Array [
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 21,
+ "line": 4,
+ },
+ "start": Object {
+ "column": 12,
+ "line": 4,
+ },
+ },
+ "range": Array [
+ 59,
+ 68,
+ ],
+ "type": "Line",
+ "value": " single",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 23,
+ "line": 5,
+ },
+ "start": Object {
+ "column": 12,
+ "line": 5,
+ },
+ },
+ "range": Array [
+ 81,
+ 92,
+ ],
+ "type": "Block",
+ "value": " block ",
+ },
+ ],
+ "loc": Object {
+ "end": Object {
+ "column": 0,
+ "line": 11,
+ },
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 0,
+ 129,
+ ],
+ "sourceType": "script",
+ "tokens": Array [
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 5,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 0,
+ 5,
+ ],
+ "type": "Keyword",
+ "value": "const",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 10,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 6,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 6,
+ 10,
+ ],
+ "type": "Identifier",
+ "value": "pure",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 12,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 11,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 11,
+ 12,
+ ],
+ "type": "Punctuator",
+ "value": "=",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 14,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 13,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 13,
+ 14,
+ ],
+ "type": "Punctuator",
+ "value": "(",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 15,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 14,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 14,
+ 15,
+ ],
+ "type": "Punctuator",
+ "value": ")",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 18,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 16,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 16,
+ 18,
+ ],
+ "type": "Punctuator",
+ "value": "=>",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 20,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 19,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 19,
+ 20,
+ ],
+ "type": "Punctuator",
+ "value": "{",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 10,
+ "line": 2,
+ },
+ "start": Object {
+ "column": 4,
+ "line": 2,
+ },
+ },
+ "range": Array [
+ 25,
+ 31,
+ ],
+ "type": "Keyword",
+ "value": "return",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 12,
+ "line": 2,
+ },
+ "start": Object {
+ "column": 11,
+ "line": 2,
+ },
+ },
+ "range": Array [
+ 32,
+ 33,
+ ],
+ "type": "Punctuator",
+ "value": "(",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 9,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 8,
+ "line": 3,
+ },
+ },
+ "range": Array [
+ 42,
+ 43,
+ ],
+ "type": "Punctuator",
+ "value": "<",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 12,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 9,
+ "line": 3,
+ },
+ },
+ "range": Array [
+ 43,
+ 46,
+ ],
+ "type": "JSXIdentifier",
+ "value": "Foo",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 9,
+ "line": 6,
+ },
+ "start": Object {
+ "column": 8,
+ "line": 6,
+ },
+ },
+ "range": Array [
+ 102,
+ 103,
+ ],
+ "type": "Punctuator",
+ "value": ">",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 8,
+ "line": 7,
+ },
+ "start": Object {
+ "column": 9,
+ "line": 6,
+ },
+ },
+ "range": Array [
+ 103,
+ 112,
+ ],
+ "type": "JSXText",
+ "value": "
+ ",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 9,
+ "line": 7,
+ },
+ "start": Object {
+ "column": 8,
+ "line": 7,
+ },
+ },
+ "range": Array [
+ 112,
+ 113,
+ ],
+ "type": "Punctuator",
+ "value": "<",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 10,
+ "line": 7,
+ },
+ "start": Object {
+ "column": 9,
+ "line": 7,
+ },
+ },
+ "range": Array [
+ 113,
+ 114,
+ ],
+ "type": "Punctuator",
+ "value": "/",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 13,
+ "line": 7,
+ },
+ "start": Object {
+ "column": 10,
+ "line": 7,
+ },
+ },
+ "range": Array [
+ 114,
+ 117,
+ ],
+ "type": "JSXIdentifier",
+ "value": "Foo",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 14,
+ "line": 7,
+ },
+ "start": Object {
+ "column": 13,
+ "line": 7,
+ },
+ },
+ "range": Array [
+ 117,
+ 118,
+ ],
+ "type": "Punctuator",
+ "value": ">",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 5,
+ "line": 8,
+ },
+ "start": Object {
+ "column": 4,
+ "line": 8,
+ },
+ },
+ "range": Array [
+ 123,
+ 124,
+ ],
+ "type": "Punctuator",
+ "value": ")",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 6,
+ "line": 8,
+ },
+ "start": Object {
+ "column": 5,
+ "line": 8,
+ },
+ },
+ "range": Array [
+ 124,
+ 125,
+ ],
+ "type": "Punctuator",
+ "value": ";",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 1,
+ "line": 9,
+ },
+ "start": Object {
+ "column": 0,
+ "line": 9,
+ },
+ },
+ "range": Array [
+ 126,
+ 127,
+ ],
+ "type": "Punctuator",
+ "value": "}",
+ },
+ ],
+ "type": "Program",
+}
+`;
+
+exports[`Comments fixtures/jsx-text-with-multiline-non-comment.src 1`] = `
+Object {
+ "body": Array [
+ Object {
+ "declarations": Array [
+ Object {
+ "id": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 10,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 6,
+ "line": 1,
+ },
+ },
+ "name": "pure",
+ "range": Array [
+ 6,
+ 10,
+ ],
+ "type": "Identifier",
+ },
+ "init": Object {
+ "async": false,
+ "body": Object {
+ "body": Array [
+ Object {
+ "argument": Object {
+ "children": Array [
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 4,
+ "line": 7,
+ },
+ "start": Object {
+ "column": 9,
+ "line": 3,
+ },
+ },
+ "range": Array [
+ 41,
+ 80,
+ ],
+ "raw": "
+ /**
+ * test
+ */
+ ",
+ "type": "Literal",
+ "value": "
+ /**
+ * test
+ */
+ ",
+ },
+ ],
+ "closingElement": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 10,
+ "line": 7,
+ },
+ "start": Object {
+ "column": 4,
+ "line": 7,
+ },
+ },
+ "name": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 9,
+ "line": 7,
+ },
+ "start": Object {
+ "column": 6,
+ "line": 7,
+ },
+ },
+ "name": "Foo",
+ "range": Array [
+ 82,
+ 85,
+ ],
+ "type": "JSXIdentifier",
+ },
+ "range": Array [
+ 80,
+ 86,
+ ],
+ "type": "JSXClosingElement",
+ },
+ "loc": Object {
+ "end": Object {
+ "column": 10,
+ "line": 7,
+ },
+ "start": Object {
+ "column": 4,
+ "line": 3,
+ },
+ },
+ "openingElement": Object {
+ "attributes": Array [],
+ "loc": Object {
+ "end": Object {
+ "column": 9,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 4,
+ "line": 3,
+ },
+ },
+ "name": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 8,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 5,
+ "line": 3,
+ },
+ },
+ "name": "Foo",
+ "range": Array [
+ 37,
+ 40,
+ ],
+ "type": "JSXIdentifier",
+ },
+ "range": Array [
+ 36,
+ 41,
+ ],
+ "selfClosing": false,
+ "type": "JSXOpeningElement",
+ },
+ "range": Array [
+ 36,
+ 86,
+ ],
+ "type": "JSXElement",
+ },
+ "loc": Object {
+ "end": Object {
+ "column": 4,
+ "line": 8,
+ },
+ "start": Object {
+ "column": 2,
+ "line": 2,
+ },
+ },
+ "range": Array [
+ 23,
+ 91,
+ ],
+ "type": "ReturnStatement",
+ },
+ ],
+ "loc": Object {
+ "end": Object {
+ "column": 1,
+ "line": 9,
+ },
+ "start": Object {
+ "column": 19,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 19,
+ 93,
+ ],
+ "type": "BlockStatement",
+ },
+ "expression": false,
+ "generator": false,
+ "id": null,
+ "loc": Object {
+ "end": Object {
+ "column": 1,
+ "line": 9,
+ },
+ "start": Object {
+ "column": 13,
+ "line": 1,
+ },
+ },
+ "params": Array [],
+ "range": Array [
+ 13,
+ 93,
+ ],
+ "type": "ArrowFunctionExpression",
+ },
+ "loc": Object {
+ "end": Object {
+ "column": 1,
+ "line": 9,
+ },
+ "start": Object {
+ "column": 6,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 6,
+ 93,
+ ],
+ "type": "VariableDeclarator",
+ },
+ ],
+ "kind": "const",
+ "loc": Object {
+ "end": Object {
+ "column": 1,
+ "line": 9,
+ },
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 0,
+ 93,
+ ],
+ "type": "VariableDeclaration",
+ },
+ ],
+ "comments": Array [],
+ "loc": Object {
+ "end": Object {
+ "column": 0,
+ "line": 10,
+ },
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 0,
+ 94,
+ ],
+ "sourceType": "script",
+ "tokens": Array [
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 5,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 0,
+ 5,
+ ],
+ "type": "Keyword",
+ "value": "const",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 10,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 6,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 6,
+ 10,
+ ],
+ "type": "Identifier",
+ "value": "pure",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 12,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 11,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 11,
+ 12,
+ ],
+ "type": "Punctuator",
+ "value": "=",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 14,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 13,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 13,
+ 14,
+ ],
+ "type": "Punctuator",
+ "value": "(",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 15,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 14,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 14,
+ 15,
+ ],
+ "type": "Punctuator",
+ "value": ")",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 18,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 16,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 16,
+ 18,
+ ],
+ "type": "Punctuator",
+ "value": "=>",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 20,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 19,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 19,
+ 20,
+ ],
+ "type": "Punctuator",
+ "value": "{",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 8,
+ "line": 2,
+ },
+ "start": Object {
+ "column": 2,
+ "line": 2,
+ },
+ },
+ "range": Array [
+ 23,
+ 29,
+ ],
+ "type": "Keyword",
+ "value": "return",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 10,
+ "line": 2,
+ },
+ "start": Object {
+ "column": 9,
+ "line": 2,
+ },
+ },
+ "range": Array [
+ 30,
+ 31,
+ ],
+ "type": "Punctuator",
+ "value": "(",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 5,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 4,
+ "line": 3,
+ },
+ },
+ "range": Array [
+ 36,
+ 37,
+ ],
+ "type": "Punctuator",
+ "value": "<",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 8,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 5,
+ "line": 3,
+ },
+ },
+ "range": Array [
+ 37,
+ 40,
+ ],
+ "type": "JSXIdentifier",
+ "value": "Foo",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 9,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 8,
+ "line": 3,
+ },
+ },
+ "range": Array [
+ 40,
+ 41,
+ ],
+ "type": "Punctuator",
+ "value": ">",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 4,
+ "line": 7,
+ },
+ "start": Object {
+ "column": 9,
+ "line": 3,
+ },
+ },
+ "range": Array [
+ 41,
+ 80,
+ ],
+ "type": "JSXText",
+ "value": "
+ /**
+ * test
+ */
+ ",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 5,
+ "line": 7,
+ },
+ "start": Object {
+ "column": 4,
+ "line": 7,
+ },
+ },
+ "range": Array [
+ 80,
+ 81,
+ ],
+ "type": "Punctuator",
+ "value": "<",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 6,
+ "line": 7,
+ },
+ "start": Object {
+ "column": 5,
+ "line": 7,
+ },
+ },
+ "range": Array [
+ 81,
+ 82,
+ ],
+ "type": "Punctuator",
+ "value": "/",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 9,
+ "line": 7,
+ },
+ "start": Object {
+ "column": 6,
+ "line": 7,
+ },
+ },
+ "range": Array [
+ 82,
+ 85,
+ ],
+ "type": "JSXIdentifier",
+ "value": "Foo",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 10,
+ "line": 7,
+ },
+ "start": Object {
+ "column": 9,
+ "line": 7,
+ },
+ },
+ "range": Array [
+ 85,
+ 86,
+ ],
+ "type": "Punctuator",
+ "value": ">",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 3,
+ "line": 8,
+ },
+ "start": Object {
+ "column": 2,
+ "line": 8,
+ },
+ },
+ "range": Array [
+ 89,
+ 90,
+ ],
+ "type": "Punctuator",
+ "value": ")",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 4,
+ "line": 8,
+ },
+ "start": Object {
+ "column": 3,
+ "line": 8,
+ },
+ },
+ "range": Array [
+ 90,
+ 91,
+ ],
+ "type": "Punctuator",
+ "value": ";",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 1,
+ "line": 9,
+ },
+ "start": Object {
+ "column": 0,
+ "line": 9,
+ },
+ },
+ "range": Array [
+ 92,
+ 93,
+ ],
+ "type": "Punctuator",
+ "value": "}",
+ },
+ ],
+ "type": "Program",
+}
+`;
+
+exports[`Comments fixtures/jsx-text-with-url.src 1`] = `
+Object {
+ "body": Array [
+ Object {
+ "declarations": Array [
+ Object {
+ "id": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 10,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 6,
+ "line": 1,
+ },
+ },
+ "name": "link",
+ "range": Array [
+ 6,
+ 10,
+ ],
+ "type": "Identifier",
+ },
+ "init": Object {
+ "children": Array [
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 61,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 43,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 43,
+ 61,
+ ],
+ "raw": "http://example.com",
+ "type": "Literal",
+ "value": "http://example.com",
+ },
+ ],
+ "closingElement": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 65,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 61,
+ "line": 1,
+ },
+ },
+ "name": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 64,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 63,
+ "line": 1,
+ },
+ },
+ "name": "a",
+ "range": Array [
+ 63,
+ 64,
+ ],
+ "type": "JSXIdentifier",
+ },
+ "range": Array [
+ 61,
+ 65,
+ ],
+ "type": "JSXClosingElement",
+ },
+ "loc": Object {
+ "end": Object {
+ "column": 65,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 14,
+ "line": 1,
+ },
+ },
+ "openingElement": Object {
+ "attributes": Array [
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 42,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 17,
+ "line": 1,
+ },
+ },
+ "name": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 21,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 17,
+ "line": 1,
+ },
+ },
+ "name": "href",
+ "range": Array [
+ 17,
+ 21,
+ ],
+ "type": "JSXIdentifier",
+ },
+ "range": Array [
+ 17,
+ 42,
+ ],
+ "type": "JSXAttribute",
+ "value": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 42,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 22,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 22,
+ 42,
+ ],
+ "raw": "\\"http://example.com\\"",
+ "type": "Literal",
+ "value": "http://example.com",
+ },
+ },
+ ],
+ "loc": Object {
+ "end": Object {
+ "column": 43,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 14,
+ "line": 1,
+ },
+ },
+ "name": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 16,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 15,
+ "line": 1,
+ },
+ },
+ "name": "a",
+ "range": Array [
+ 15,
+ 16,
+ ],
+ "type": "JSXIdentifier",
+ },
+ "range": Array [
+ 14,
+ 43,
+ ],
+ "selfClosing": false,
+ "type": "JSXOpeningElement",
+ },
+ "range": Array [
+ 14,
+ 65,
+ ],
+ "type": "JSXElement",
+ },
+ "loc": Object {
+ "end": Object {
+ "column": 66,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 6,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 6,
+ 66,
+ ],
+ "type": "VariableDeclarator",
+ },
+ ],
+ "kind": "const",
+ "loc": Object {
+ "end": Object {
+ "column": 67,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 0,
+ 67,
+ ],
+ "type": "VariableDeclaration",
+ },
+ ],
+ "comments": Array [],
+ "loc": Object {
+ "end": Object {
+ "column": 0,
+ "line": 2,
+ },
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 0,
+ 68,
+ ],
+ "sourceType": "script",
+ "tokens": Array [
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 5,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 0,
+ 5,
+ ],
+ "type": "Keyword",
+ "value": "const",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 10,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 6,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 6,
+ 10,
+ ],
+ "type": "Identifier",
+ "value": "link",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 12,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 11,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 11,
+ 12,
+ ],
+ "type": "Punctuator",
+ "value": "=",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 14,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 13,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 13,
+ 14,
+ ],
+ "type": "Punctuator",
+ "value": "(",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 15,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 14,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 14,
+ 15,
+ ],
+ "type": "Punctuator",
+ "value": "<",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 16,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 15,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 15,
+ 16,
+ ],
+ "type": "JSXIdentifier",
+ "value": "a",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 21,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 17,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 17,
+ 21,
+ ],
+ "type": "JSXIdentifier",
+ "value": "href",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 22,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 21,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 21,
+ 22,
+ ],
+ "type": "Punctuator",
+ "value": "=",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 42,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 22,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 22,
+ 42,
+ ],
+ "type": "JSXText",
+ "value": "\\"http://example.com\\"",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 43,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 42,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 42,
+ 43,
+ ],
+ "type": "Punctuator",
+ "value": ">",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 61,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 43,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 43,
+ 61,
+ ],
+ "type": "JSXText",
+ "value": "http://example.com",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 62,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 61,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 61,
+ 62,
+ ],
+ "type": "Punctuator",
+ "value": "<",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 63,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 62,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 62,
+ 63,
+ ],
+ "type": "Punctuator",
+ "value": "/",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 64,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 63,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 63,
+ 64,
+ ],
+ "type": "JSXIdentifier",
+ "value": "a",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 65,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 64,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 64,
+ 65,
+ ],
+ "type": "Punctuator",
+ "value": ">",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 66,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 65,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 65,
+ 66,
+ ],
+ "type": "Punctuator",
+ "value": ")",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 67,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 66,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 66,
+ 67,
+ ],
+ "type": "Punctuator",
+ "value": ";",
+ },
+ ],
+ "type": "Program",
+}
+`;
+
+exports[`Comments fixtures/jsx-with-greather-than.src 1`] = `
+Object {
+ "body": Array [
+ Object {
+ "alternate": null,
+ "consequent": Object {
+ "body": Array [
+ Object {
+ "expression": Object {
+ "arguments": Array [
+ Object {
+ "left": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 9,
+ "line": 2,
+ },
+ "start": Object {
+ "column": 8,
+ "line": 2,
+ },
+ },
+ "range": Array [
+ 30,
+ 31,
+ ],
+ "raw": "2",
+ "type": "Literal",
+ "value": 2,
+ },
+ "loc": Object {
+ "end": Object {
+ "column": 14,
+ "line": 2,
+ },
+ "start": Object {
+ "column": 8,
+ "line": 2,
+ },
+ },
+ "operator": ">>",
+ "range": Array [
+ 30,
+ 36,
+ ],
+ "right": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 14,
+ "line": 2,
+ },
+ "start": Object {
+ "column": 13,
+ "line": 2,
+ },
+ },
+ "range": Array [
+ 35,
+ 36,
+ ],
+ "raw": "3",
+ "type": "Literal",
+ "value": 3,
+ },
+ "type": "BinaryExpression",
+ },
+ ],
+ "callee": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 6,
+ "line": 2,
+ },
+ "start": Object {
+ "column": 2,
+ "line": 2,
+ },
+ },
+ "name": "test",
+ "range": Array [
+ 24,
+ 28,
+ ],
+ "type": "Identifier",
+ },
+ "loc": Object {
+ "end": Object {
+ "column": 15,
+ "line": 2,
+ },
+ "start": Object {
+ "column": 2,
+ "line": 2,
+ },
+ },
+ "range": Array [
+ 24,
+ 37,
+ ],
+ "type": "CallExpression",
+ },
+ "loc": Object {
+ "end": Object {
+ "column": 16,
+ "line": 2,
+ },
+ "start": Object {
+ "column": 2,
+ "line": 2,
+ },
+ },
+ "range": Array [
+ 24,
+ 38,
+ ],
+ "type": "ExpressionStatement",
+ },
+ Object {
+ "declarations": Array [
+ Object {
+ "id": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 11,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 8,
+ "line": 3,
+ },
+ },
+ "name": "foo",
+ "range": Array [
+ 47,
+ 50,
+ ],
+ "type": "Identifier",
+ },
+ "init": Object {
+ "children": Array [
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 22,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 20,
+ "line": 3,
+ },
+ },
+ "range": Array [
+ 59,
+ 61,
+ ],
+ "raw": "//",
+ "type": "Literal",
+ "value": "//",
+ },
+ ],
+ "closingElement": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 29,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 22,
+ "line": 3,
+ },
+ },
+ "name": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 28,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 24,
+ "line": 3,
+ },
+ },
+ "name": "test",
+ "range": Array [
+ 63,
+ 67,
+ ],
+ "type": "JSXIdentifier",
+ },
+ "range": Array [
+ 61,
+ 68,
+ ],
+ "type": "JSXClosingElement",
+ },
+ "loc": Object {
+ "end": Object {
+ "column": 29,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 14,
+ "line": 3,
+ },
+ },
+ "openingElement": Object {
+ "attributes": Array [],
+ "loc": Object {
+ "end": Object {
+ "column": 20,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 14,
+ "line": 3,
+ },
+ },
+ "name": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 19,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 15,
+ "line": 3,
+ },
+ },
+ "name": "test",
+ "range": Array [
+ 54,
+ 58,
+ ],
+ "type": "JSXIdentifier",
+ },
+ "range": Array [
+ 53,
+ 59,
+ ],
+ "selfClosing": false,
+ "type": "JSXOpeningElement",
+ },
+ "range": Array [
+ 53,
+ 68,
+ ],
+ "type": "JSXElement",
+ },
+ "loc": Object {
+ "end": Object {
+ "column": 29,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 8,
+ "line": 3,
+ },
+ },
+ "range": Array [
+ 47,
+ 68,
+ ],
+ "type": "VariableDeclarator",
+ },
+ ],
+ "kind": "const",
+ "loc": Object {
+ "end": Object {
+ "column": 29,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 2,
+ "line": 3,
+ },
+ },
+ "range": Array [
+ 41,
+ 68,
+ ],
+ "type": "VariableDeclaration",
+ },
+ ],
+ "loc": Object {
+ "end": Object {
+ "column": 1,
+ "line": 4,
+ },
+ "start": Object {
+ "column": 20,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 20,
+ 70,
+ ],
+ "type": "BlockStatement",
+ },
+ "loc": Object {
+ "end": Object {
+ "column": 1,
+ "line": 4,
+ },
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 0,
+ 70,
+ ],
+ "test": Object {
+ "left": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 5,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 4,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 4,
+ 5,
+ ],
+ "raw": "1",
+ "type": "Literal",
+ "value": 1,
+ },
+ "loc": Object {
+ "end": Object {
+ "column": 18,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 4,
+ "line": 1,
+ },
+ },
+ "operator": ">",
+ "range": Array [
+ 4,
+ 18,
+ ],
+ "right": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 18,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 17,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 17,
+ 18,
+ ],
+ "raw": "2",
+ "type": "Literal",
+ "value": 2,
+ },
+ "type": "BinaryExpression",
+ },
+ "type": "IfStatement",
+ },
+ ],
+ "comments": Array [
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 17,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 7,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 7,
+ 17,
+ ],
+ "type": "Block",
+ "value": " Test ",
+ },
+ ],
+ "loc": Object {
+ "end": Object {
+ "column": 0,
+ "line": 5,
+ },
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 0,
+ 71,
+ ],
+ "sourceType": "script",
+ "tokens": Array [
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 2,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 0,
+ 2,
+ ],
+ "type": "Keyword",
+ "value": "if",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 4,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 3,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 3,
+ 4,
+ ],
+ "type": "Punctuator",
+ "value": "(",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 5,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 4,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 4,
+ 5,
+ ],
+ "type": "Numeric",
+ "value": "1",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 7,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 6,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 6,
+ 7,
+ ],
+ "type": "Punctuator",
+ "value": ">",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 18,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 17,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 17,
+ 18,
+ ],
+ "type": "Numeric",
+ "value": "2",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 19,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 18,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 18,
+ 19,
+ ],
+ "type": "Punctuator",
+ "value": ")",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 21,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 20,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 20,
+ 21,
+ ],
+ "type": "Punctuator",
+ "value": "{",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 6,
+ "line": 2,
+ },
+ "start": Object {
+ "column": 2,
+ "line": 2,
+ },
+ },
+ "range": Array [
+ 24,
+ 28,
+ ],
+ "type": "Identifier",
+ "value": "test",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 7,
+ "line": 2,
+ },
+ "start": Object {
+ "column": 6,
+ "line": 2,
+ },
+ },
+ "range": Array [
+ 28,
+ 29,
+ ],
+ "type": "Punctuator",
+ "value": "(",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 9,
+ "line": 2,
+ },
+ "start": Object {
+ "column": 8,
+ "line": 2,
+ },
+ },
+ "range": Array [
+ 30,
+ 31,
+ ],
+ "type": "Numeric",
+ "value": "2",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 12,
+ "line": 2,
+ },
+ "start": Object {
+ "column": 10,
+ "line": 2,
+ },
+ },
+ "range": Array [
+ 32,
+ 34,
+ ],
+ "type": "Punctuator",
+ "value": ">>",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 14,
+ "line": 2,
+ },
+ "start": Object {
+ "column": 13,
+ "line": 2,
+ },
+ },
+ "range": Array [
+ 35,
+ 36,
+ ],
+ "type": "Numeric",
+ "value": "3",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 15,
+ "line": 2,
+ },
+ "start": Object {
+ "column": 14,
+ "line": 2,
+ },
+ },
+ "range": Array [
+ 36,
+ 37,
+ ],
+ "type": "Punctuator",
+ "value": ")",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 16,
+ "line": 2,
+ },
+ "start": Object {
+ "column": 15,
+ "line": 2,
+ },
+ },
+ "range": Array [
+ 37,
+ 38,
+ ],
+ "type": "Punctuator",
+ "value": ";",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 7,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 2,
+ "line": 3,
+ },
+ },
+ "range": Array [
+ 41,
+ 46,
+ ],
+ "type": "Keyword",
+ "value": "const",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 11,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 8,
+ "line": 3,
+ },
+ },
+ "range": Array [
+ 47,
+ 50,
+ ],
+ "type": "Identifier",
+ "value": "foo",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 13,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 12,
+ "line": 3,
+ },
+ },
+ "range": Array [
+ 51,
+ 52,
+ ],
+ "type": "Punctuator",
+ "value": "=",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 15,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 14,
+ "line": 3,
+ },
+ },
+ "range": Array [
+ 53,
+ 54,
+ ],
+ "type": "Punctuator",
+ "value": "<",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 19,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 15,
+ "line": 3,
+ },
+ },
+ "range": Array [
+ 54,
+ 58,
+ ],
+ "type": "JSXIdentifier",
+ "value": "test",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 20,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 19,
+ "line": 3,
+ },
+ },
+ "range": Array [
+ 58,
+ 59,
+ ],
+ "type": "Punctuator",
+ "value": ">",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 22,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 20,
+ "line": 3,
+ },
+ },
+ "range": Array [
+ 59,
+ 61,
+ ],
+ "type": "JSXText",
+ "value": "//",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 23,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 22,
+ "line": 3,
+ },
+ },
+ "range": Array [
+ 61,
+ 62,
+ ],
+ "type": "Punctuator",
+ "value": "<",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 24,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 23,
+ "line": 3,
+ },
+ },
+ "range": Array [
+ 62,
+ 63,
+ ],
+ "type": "Punctuator",
+ "value": "/",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 28,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 24,
+ "line": 3,
+ },
+ },
+ "range": Array [
+ 63,
+ 67,
+ ],
+ "type": "JSXIdentifier",
+ "value": "test",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 29,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 28,
+ "line": 3,
+ },
+ },
+ "range": Array [
+ 67,
+ 68,
+ ],
+ "type": "Punctuator",
+ "value": ">",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 1,
+ "line": 4,
+ },
+ "start": Object {
+ "column": 0,
+ "line": 4,
+ },
+ },
+ "range": Array [
+ 69,
+ 70,
+ ],
+ "type": "Punctuator",
+ "value": "}",
+ },
+ ],
+ "type": "Program",
+}
+`;
+
+exports[`Comments fixtures/jsx-with-operators.src 1`] = `
+Object {
+ "body": Array [
+ Object {
+ "alternate": null,
+ "consequent": Object {
+ "body": Array [
+ Object {
+ "expression": Object {
+ "arguments": Array [
+ Object {
+ "left": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 9,
+ "line": 2,
+ },
+ "start": Object {
+ "column": 8,
+ "line": 2,
+ },
+ },
+ "range": Array [
+ 30,
+ 31,
+ ],
+ "raw": "2",
+ "type": "Literal",
+ "value": 2,
+ },
+ "loc": Object {
+ "end": Object {
+ "column": 14,
+ "line": 2,
+ },
+ "start": Object {
+ "column": 8,
+ "line": 2,
+ },
+ },
+ "operator": ">>",
+ "range": Array [
+ 30,
+ 36,
+ ],
+ "right": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 14,
+ "line": 2,
+ },
+ "start": Object {
+ "column": 13,
+ "line": 2,
+ },
+ },
+ "range": Array [
+ 35,
+ 36,
+ ],
+ "raw": "3",
+ "type": "Literal",
+ "value": 3,
+ },
+ "type": "BinaryExpression",
+ },
+ ],
+ "callee": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 6,
+ "line": 2,
+ },
+ "start": Object {
+ "column": 2,
+ "line": 2,
+ },
+ },
+ "name": "test",
+ "range": Array [
+ 24,
+ 28,
+ ],
+ "type": "Identifier",
+ },
+ "loc": Object {
+ "end": Object {
+ "column": 15,
+ "line": 2,
+ },
+ "start": Object {
+ "column": 2,
+ "line": 2,
+ },
+ },
+ "range": Array [
+ 24,
+ 37,
+ ],
+ "type": "CallExpression",
+ },
+ "loc": Object {
+ "end": Object {
+ "column": 16,
+ "line": 2,
+ },
+ "start": Object {
+ "column": 2,
+ "line": 2,
+ },
+ },
+ "range": Array [
+ 24,
+ 38,
+ ],
+ "type": "ExpressionStatement",
+ },
+ Object {
+ "declarations": Array [
+ Object {
+ "id": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 11,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 8,
+ "line": 3,
+ },
+ },
+ "name": "foo",
+ "range": Array [
+ 47,
+ 50,
+ ],
+ "type": "Identifier",
+ },
+ "init": Object {
+ "children": Array [
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 22,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 20,
+ "line": 3,
+ },
+ },
+ "range": Array [
+ 59,
+ 61,
+ ],
+ "raw": "//",
+ "type": "Literal",
+ "value": "//",
+ },
+ ],
+ "closingElement": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 29,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 22,
+ "line": 3,
+ },
+ },
+ "name": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 28,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 24,
+ "line": 3,
+ },
+ },
+ "name": "test",
+ "range": Array [
+ 63,
+ 67,
+ ],
+ "type": "JSXIdentifier",
+ },
+ "range": Array [
+ 61,
+ 68,
+ ],
+ "type": "JSXClosingElement",
+ },
+ "loc": Object {
+ "end": Object {
+ "column": 29,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 14,
+ "line": 3,
+ },
+ },
+ "openingElement": Object {
+ "attributes": Array [],
+ "loc": Object {
+ "end": Object {
+ "column": 20,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 14,
+ "line": 3,
+ },
+ },
+ "name": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 19,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 15,
+ "line": 3,
+ },
+ },
+ "name": "test",
+ "range": Array [
+ 54,
+ 58,
+ ],
+ "type": "JSXIdentifier",
+ },
+ "range": Array [
+ 53,
+ 59,
+ ],
+ "selfClosing": false,
+ "type": "JSXOpeningElement",
+ },
+ "range": Array [
+ 53,
+ 68,
+ ],
+ "type": "JSXElement",
+ },
+ "loc": Object {
+ "end": Object {
+ "column": 29,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 8,
+ "line": 3,
+ },
+ },
+ "range": Array [
+ 47,
+ 68,
+ ],
+ "type": "VariableDeclarator",
+ },
+ ],
+ "kind": "const",
+ "loc": Object {
+ "end": Object {
+ "column": 29,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 2,
+ "line": 3,
+ },
+ },
+ "range": Array [
+ 41,
+ 68,
+ ],
+ "type": "VariableDeclaration",
+ },
+ ],
+ "loc": Object {
+ "end": Object {
+ "column": 1,
+ "line": 4,
+ },
+ "start": Object {
+ "column": 20,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 20,
+ 70,
+ ],
+ "type": "BlockStatement",
+ },
+ "loc": Object {
+ "end": Object {
+ "column": 1,
+ "line": 4,
+ },
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 0,
+ 70,
+ ],
+ "test": Object {
+ "left": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 5,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 4,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 4,
+ 5,
+ ],
+ "raw": "1",
+ "type": "Literal",
+ "value": 1,
+ },
+ "loc": Object {
+ "end": Object {
+ "column": 18,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 4,
+ "line": 1,
+ },
+ },
+ "operator": "<",
+ "range": Array [
+ 4,
+ 18,
+ ],
+ "right": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 18,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 17,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 17,
+ 18,
+ ],
+ "raw": "2",
+ "type": "Literal",
+ "value": 2,
+ },
+ "type": "BinaryExpression",
+ },
+ "type": "IfStatement",
+ },
+ ],
+ "comments": Array [
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 17,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 7,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 7,
+ 17,
+ ],
+ "type": "Block",
+ "value": " Test ",
+ },
+ ],
+ "loc": Object {
+ "end": Object {
+ "column": 0,
+ "line": 5,
+ },
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 0,
+ 71,
+ ],
+ "sourceType": "script",
+ "tokens": Array [
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 2,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 0,
+ 2,
+ ],
+ "type": "Keyword",
+ "value": "if",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 4,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 3,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 3,
+ 4,
+ ],
+ "type": "Punctuator",
+ "value": "(",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 5,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 4,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 4,
+ 5,
+ ],
+ "type": "Numeric",
+ "value": "1",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 7,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 6,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 6,
+ 7,
+ ],
+ "type": "Punctuator",
+ "value": "<",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 18,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 17,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 17,
+ 18,
+ ],
+ "type": "Numeric",
+ "value": "2",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 19,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 18,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 18,
+ 19,
+ ],
+ "type": "Punctuator",
+ "value": ")",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 21,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 20,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 20,
+ 21,
+ ],
+ "type": "Punctuator",
+ "value": "{",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 6,
+ "line": 2,
+ },
+ "start": Object {
+ "column": 2,
+ "line": 2,
+ },
+ },
+ "range": Array [
+ 24,
+ 28,
+ ],
+ "type": "Identifier",
+ "value": "test",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 7,
+ "line": 2,
+ },
+ "start": Object {
+ "column": 6,
+ "line": 2,
+ },
+ },
+ "range": Array [
+ 28,
+ 29,
+ ],
+ "type": "Punctuator",
+ "value": "(",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 9,
+ "line": 2,
+ },
+ "start": Object {
+ "column": 8,
+ "line": 2,
+ },
+ },
+ "range": Array [
+ 30,
+ 31,
+ ],
+ "type": "Numeric",
+ "value": "2",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 12,
+ "line": 2,
+ },
+ "start": Object {
+ "column": 10,
+ "line": 2,
+ },
+ },
+ "range": Array [
+ 32,
+ 34,
+ ],
+ "type": "Punctuator",
+ "value": ">>",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 14,
+ "line": 2,
+ },
+ "start": Object {
+ "column": 13,
+ "line": 2,
+ },
+ },
+ "range": Array [
+ 35,
+ 36,
+ ],
+ "type": "Numeric",
+ "value": "3",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 15,
+ "line": 2,
+ },
+ "start": Object {
+ "column": 14,
+ "line": 2,
+ },
+ },
+ "range": Array [
+ 36,
+ 37,
+ ],
+ "type": "Punctuator",
+ "value": ")",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 16,
+ "line": 2,
+ },
+ "start": Object {
+ "column": 15,
+ "line": 2,
+ },
+ },
+ "range": Array [
+ 37,
+ 38,
+ ],
+ "type": "Punctuator",
+ "value": ";",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 7,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 2,
+ "line": 3,
+ },
+ },
+ "range": Array [
+ 41,
+ 46,
+ ],
+ "type": "Keyword",
+ "value": "const",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 11,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 8,
+ "line": 3,
+ },
+ },
+ "range": Array [
+ 47,
+ 50,
+ ],
+ "type": "Identifier",
+ "value": "foo",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 13,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 12,
+ "line": 3,
+ },
+ },
+ "range": Array [
+ 51,
+ 52,
+ ],
+ "type": "Punctuator",
+ "value": "=",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 15,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 14,
+ "line": 3,
+ },
+ },
+ "range": Array [
+ 53,
+ 54,
+ ],
+ "type": "Punctuator",
+ "value": "<",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 19,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 15,
+ "line": 3,
+ },
+ },
+ "range": Array [
+ 54,
+ 58,
+ ],
+ "type": "JSXIdentifier",
+ "value": "test",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 20,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 19,
+ "line": 3,
+ },
+ },
+ "range": Array [
+ 58,
+ 59,
+ ],
+ "type": "Punctuator",
+ "value": ">",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 22,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 20,
+ "line": 3,
+ },
+ },
+ "range": Array [
+ 59,
+ 61,
+ ],
+ "type": "JSXText",
+ "value": "//",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 23,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 22,
+ "line": 3,
+ },
+ },
+ "range": Array [
+ 61,
+ 62,
+ ],
+ "type": "Punctuator",
+ "value": "<",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 24,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 23,
+ "line": 3,
+ },
+ },
+ "range": Array [
+ 62,
+ 63,
+ ],
+ "type": "Punctuator",
+ "value": "/",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 28,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 24,
+ "line": 3,
+ },
+ },
+ "range": Array [
+ 63,
+ 67,
+ ],
+ "type": "JSXIdentifier",
+ "value": "test",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 29,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 28,
+ "line": 3,
+ },
+ },
+ "range": Array [
+ 67,
+ 68,
+ ],
+ "type": "Punctuator",
+ "value": ">",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 1,
+ "line": 4,
+ },
+ "start": Object {
+ "column": 0,
+ "line": 4,
+ },
+ },
+ "range": Array [
+ 69,
+ 70,
+ ],
+ "type": "Punctuator",
+ "value": "}",
+ },
+ ],
+ "type": "Program",
+}
+`;
+
+exports[`Comments fixtures/line-comment-with-block-syntax.src 1`] = `
+Object {
+ "body": Array [],
+ "comments": Array [
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 11,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 0,
+ 11,
+ ],
+ "type": "Line",
+ "value": " /*test*/",
+ },
+ ],
+ "loc": Object {
+ "end": Object {
+ "column": 0,
+ "line": 2,
+ },
+ "start": Object {
+ "column": 0,
+ "line": 2,
+ },
+ },
+ "range": Array [
+ 12,
+ 12,
+ ],
+ "sourceType": "script",
+ "tokens": Array [],
+ "type": "Program",
+}
+`;
+
+exports[`Comments fixtures/mix-line-and-block-comments.src 1`] = `
+Object {
+ "body": Array [
+ Object {
+ "declarations": Array [
+ Object {
+ "id": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 7,
+ "line": 2,
+ },
+ "start": Object {
+ "column": 4,
+ "line": 2,
+ },
+ },
+ "name": "zzz",
+ "range": Array [
+ 10,
+ 13,
+ ],
+ "type": "Identifier",
+ },
+ "init": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 21,
+ "line": 2,
+ },
+ "start": Object {
+ "column": 18,
+ "line": 2,
+ },
+ },
+ "range": Array [
+ 24,
+ 27,
+ ],
+ "raw": "777",
+ "type": "Literal",
+ "value": 777,
+ },
+ "loc": Object {
+ "end": Object {
+ "column": 21,
+ "line": 2,
+ },
+ "start": Object {
+ "column": 4,
+ "line": 2,
+ },
+ },
+ "range": Array [
+ 10,
+ 27,
+ ],
+ "type": "VariableDeclarator",
+ },
+ ],
+ "kind": "var",
+ "loc": Object {
+ "end": Object {
+ "column": 22,
+ "line": 2,
+ },
+ "start": Object {
+ "column": 0,
+ "line": 2,
+ },
+ },
+ "range": Array [
+ 6,
+ 28,
+ ],
+ "type": "VariableDeclaration",
+ },
+ ],
+ "comments": Array [
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 5,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 0,
+ 5,
+ ],
+ "type": "Line",
+ "value": "foo",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 15,
+ "line": 2,
+ },
+ "start": Object {
+ "column": 8,
+ "line": 2,
+ },
+ },
+ "range": Array [
+ 14,
+ 21,
+ ],
+ "type": "Block",
+ "value": "aaa",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 5,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 0,
+ "line": 3,
+ },
+ },
+ "range": Array [
+ 29,
+ 34,
+ ],
+ "type": "Line",
+ "value": "bar",
+ },
+ ],
+ "loc": Object {
+ "end": Object {
+ "column": 0,
+ "line": 4,
+ },
+ "start": Object {
+ "column": 0,
+ "line": 2,
+ },
+ },
+ "range": Array [
+ 6,
+ 35,
+ ],
+ "sourceType": "script",
+ "tokens": Array [
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 3,
+ "line": 2,
+ },
+ "start": Object {
+ "column": 0,
+ "line": 2,
+ },
+ },
+ "range": Array [
+ 6,
+ 9,
+ ],
+ "type": "Keyword",
+ "value": "var",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 7,
+ "line": 2,
+ },
+ "start": Object {
+ "column": 4,
+ "line": 2,
+ },
+ },
+ "range": Array [
+ 10,
+ 13,
+ ],
+ "type": "Identifier",
+ "value": "zzz",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 17,
+ "line": 2,
+ },
+ "start": Object {
+ "column": 16,
+ "line": 2,
+ },
+ },
+ "range": Array [
+ 22,
+ 23,
+ ],
+ "type": "Punctuator",
+ "value": "=",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 21,
+ "line": 2,
+ },
+ "start": Object {
+ "column": 18,
+ "line": 2,
+ },
+ },
+ "range": Array [
+ 24,
+ 27,
+ ],
+ "type": "Numeric",
+ "value": "777",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 22,
+ "line": 2,
+ },
+ "start": Object {
+ "column": 21,
+ "line": 2,
+ },
+ },
+ "range": Array [
+ 27,
+ 28,
+ ],
+ "type": "Punctuator",
+ "value": ";",
+ },
+ ],
+ "type": "Program",
+}
+`;
+
+exports[`Comments fixtures/no-comment-regex.src 1`] = `
+Object {
+ "body": Array [
+ Object {
+ "declarations": Array [
+ Object {
+ "id": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 11,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 6,
+ "line": 1,
+ },
+ },
+ "name": "regex",
+ "range": Array [
+ 6,
+ 11,
+ ],
+ "type": "Identifier",
+ },
+ "init": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 33,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 14,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 14,
+ 33,
+ ],
+ "raw": "/no comment\\\\/**foo/",
+ "regex": Object {
+ "flags": "",
+ "pattern": "no comment\\\\/**foo",
+ },
+ "type": "Literal",
+ "value": null,
+ },
+ "loc": Object {
+ "end": Object {
+ "column": 33,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 6,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 6,
+ 33,
+ ],
+ "type": "VariableDeclarator",
+ },
+ ],
+ "kind": "const",
+ "loc": Object {
+ "end": Object {
+ "column": 34,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 0,
+ 34,
+ ],
+ "type": "VariableDeclaration",
+ },
+ ],
+ "comments": Array [],
+ "loc": Object {
+ "end": Object {
+ "column": 0,
+ "line": 2,
+ },
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 0,
+ 35,
+ ],
+ "sourceType": "script",
+ "tokens": Array [
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 5,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 0,
+ 5,
+ ],
+ "type": "Keyword",
+ "value": "const",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 11,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 6,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 6,
+ 11,
+ ],
+ "type": "Identifier",
+ "value": "regex",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 13,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 12,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 12,
+ 13,
+ ],
+ "type": "Punctuator",
+ "value": "=",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 33,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 14,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 14,
+ 33,
+ ],
+ "regex": Object {
+ "flags": "",
+ "pattern": "no comment\\\\/**foo",
+ },
+ "type": "RegularExpression",
+ "value": "/no comment\\\\/**foo/",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 34,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 33,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 33,
+ 34,
+ ],
+ "type": "Punctuator",
+ "value": ";",
+ },
+ ],
+ "type": "Program",
+}
+`;
+
+exports[`Comments fixtures/no-comment-template.src 1`] = `
+Object {
+ "body": Array [
+ Object {
+ "declarations": Array [
+ Object {
+ "id": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 9,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 6,
+ "line": 1,
+ },
+ },
+ "name": "str",
+ "range": Array [
+ 6,
+ 9,
],
"type": "Identifier",
},
@@ -8617,494 +12644,844 @@ Object {
"line": 6,
},
"start": Object {
- "column": 56,
- "line": 6,
+ "column": 56,
+ "line": 6,
+ },
+ },
+ "range": Array [
+ 194,
+ 205,
+ ],
+ "type": "Identifier",
+ "value": "expressions",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 68,
+ "line": 6,
+ },
+ "start": Object {
+ "column": 67,
+ "line": 6,
+ },
+ },
+ "range": Array [
+ 205,
+ 206,
+ ],
+ "type": "Punctuator",
+ "value": ".",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 74,
+ "line": 6,
+ },
+ "start": Object {
+ "column": 68,
+ "line": 6,
+ },
+ },
+ "range": Array [
+ 206,
+ 212,
+ ],
+ "type": "Identifier",
+ "value": "length",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 76,
+ "line": 6,
+ },
+ "start": Object {
+ "column": 75,
+ "line": 6,
+ },
+ },
+ "range": Array [
+ 213,
+ 214,
+ ],
+ "type": "Punctuator",
+ "value": "-",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 78,
+ "line": 6,
+ },
+ "start": Object {
+ "column": 77,
+ "line": 6,
+ },
+ },
+ "range": Array [
+ 215,
+ 216,
+ ],
+ "type": "Numeric",
+ "value": "1",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 79,
+ "line": 6,
+ },
+ "start": Object {
+ "column": 78,
+ "line": 6,
+ },
+ },
+ "range": Array [
+ 216,
+ 217,
+ ],
+ "type": "Punctuator",
+ "value": "]",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 80,
+ "line": 6,
+ },
+ "start": Object {
+ "column": 79,
+ "line": 6,
+ },
+ },
+ "range": Array [
+ 217,
+ 218,
+ ],
+ "type": "Punctuator",
+ "value": ")",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 81,
+ "line": 6,
+ },
+ "start": Object {
+ "column": 80,
+ "line": 6,
+ },
+ },
+ "range": Array [
+ 218,
+ 219,
+ ],
+ "type": "Punctuator",
+ "value": ";",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 9,
+ "line": 8,
+ },
+ "start": Object {
+ "column": 8,
+ "line": 8,
+ },
+ },
+ "range": Array [
+ 254,
+ 255,
+ ],
+ "type": "Punctuator",
+ "value": "}",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 14,
+ "line": 9,
+ },
+ "start": Object {
+ "column": 8,
+ "line": 9,
+ },
+ },
+ "range": Array [
+ 264,
+ 270,
+ ],
+ "type": "Keyword",
+ "value": "return",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 20,
+ "line": 9,
+ },
+ "start": Object {
+ "column": 15,
+ "line": 9,
+ },
+ },
+ "range": Array [
+ 271,
+ 276,
+ ],
+ "type": "Boolean",
+ "value": "false",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 21,
+ "line": 9,
+ },
+ "start": Object {
+ "column": 20,
+ "line": 9,
+ },
+ },
+ "range": Array [
+ 276,
+ 277,
+ ],
+ "type": "Punctuator",
+ "value": ";",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 5,
+ "line": 10,
+ },
+ "start": Object {
+ "column": 4,
+ "line": 10,
},
},
"range": Array [
- 194,
- 205,
+ 282,
+ 283,
],
- "type": "Identifier",
- "value": "expressions",
+ "type": "Punctuator",
+ "value": "}",
},
Object {
"loc": Object {
"end": Object {
- "column": 68,
- "line": 6,
+ "column": 1,
+ "line": 12,
},
"start": Object {
- "column": 67,
- "line": 6,
+ "column": 0,
+ "line": 12,
},
},
"range": Array [
- 205,
- 206,
+ 285,
+ 286,
],
"type": "Punctuator",
- "value": ".",
+ "value": "}",
},
Object {
"loc": Object {
"end": Object {
- "column": 74,
- "line": 6,
+ "column": 2,
+ "line": 12,
},
"start": Object {
- "column": 68,
- "line": 6,
+ "column": 1,
+ "line": 12,
},
},
"range": Array [
- 206,
- 212,
+ 286,
+ 287,
],
- "type": "Identifier",
- "value": "length",
+ "type": "Punctuator",
+ "value": ";",
},
+ ],
+ "type": "Program",
+}
+`;
+
+exports[`Comments fixtures/template-string-block.src 1`] = `
+Object {
+ "body": Array [
Object {
+ "expression": Object {
+ "expressions": Array [
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 7,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 3,
+ "line": 1,
+ },
+ },
+ "name": "name",
+ "range": Array [
+ 3,
+ 7,
+ ],
+ "type": "Identifier",
+ },
+ ],
+ "loc": Object {
+ "end": Object {
+ "column": 9,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ },
+ },
+ "quasis": Array [
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 3,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 0,
+ 3,
+ ],
+ "tail": false,
+ "type": "TemplateElement",
+ "value": Object {
+ "cooked": "",
+ "raw": "",
+ },
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 9,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 7,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 7,
+ 9,
+ ],
+ "tail": true,
+ "type": "TemplateElement",
+ "value": Object {
+ "cooked": "",
+ "raw": "",
+ },
+ },
+ ],
+ "range": Array [
+ 0,
+ 9,
+ ],
+ "type": "TemplateLiteral",
+ },
"loc": Object {
"end": Object {
- "column": 76,
- "line": 6,
+ "column": 10,
+ "line": 1,
},
"start": Object {
- "column": 75,
- "line": 6,
+ "column": 0,
+ "line": 1,
},
},
"range": Array [
- 213,
- 214,
+ 0,
+ 10,
],
- "type": "Punctuator",
- "value": "-",
+ "type": "ExpressionStatement",
},
Object {
+ "body": Array [
+ Object {
+ "expression": Object {
+ "left": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 5,
+ "line": 4,
+ },
+ "start": Object {
+ "column": 4,
+ "line": 4,
+ },
+ },
+ "range": Array [
+ 56,
+ 57,
+ ],
+ "raw": "1",
+ "type": "Literal",
+ "value": 1,
+ },
+ "loc": Object {
+ "end": Object {
+ "column": 9,
+ "line": 4,
+ },
+ "start": Object {
+ "column": 4,
+ "line": 4,
+ },
+ },
+ "operator": "+",
+ "range": Array [
+ 56,
+ 61,
+ ],
+ "right": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 9,
+ "line": 4,
+ },
+ "start": Object {
+ "column": 8,
+ "line": 4,
+ },
+ },
+ "range": Array [
+ 60,
+ 61,
+ ],
+ "raw": "1",
+ "type": "Literal",
+ "value": 1,
+ },
+ "type": "BinaryExpression",
+ },
+ "loc": Object {
+ "end": Object {
+ "column": 10,
+ "line": 4,
+ },
+ "start": Object {
+ "column": 4,
+ "line": 4,
+ },
+ },
+ "range": Array [
+ 56,
+ 62,
+ ],
+ "type": "ExpressionStatement",
+ },
+ ],
"loc": Object {
"end": Object {
- "column": 78,
- "line": 6,
+ "column": 1,
+ "line": 5,
},
"start": Object {
- "column": 77,
- "line": 6,
+ "column": 0,
+ "line": 2,
},
},
"range": Array [
- 215,
- 216,
+ 11,
+ 64,
],
- "type": "Numeric",
- "value": "1",
+ "type": "BlockStatement",
},
+ ],
+ "comments": Array [
Object {
"loc": Object {
"end": Object {
- "column": 79,
- "line": 6,
+ "column": 38,
+ "line": 3,
},
"start": Object {
- "column": 78,
- "line": 6,
+ "column": 4,
+ "line": 3,
},
},
"range": Array [
- 216,
- 217,
+ 17,
+ 51,
],
- "type": "Punctuator",
- "value": "]",
+ "type": "Block",
+ "value": " TODO comment comment comment ",
+ },
+ ],
+ "loc": Object {
+ "end": Object {
+ "column": 0,
+ "line": 6,
+ },
+ "start": Object {
+ "column": 0,
+ "line": 1,
},
+ },
+ "range": Array [
+ 0,
+ 65,
+ ],
+ "sourceType": "script",
+ "tokens": Array [
Object {
"loc": Object {
"end": Object {
- "column": 80,
- "line": 6,
+ "column": 3,
+ "line": 1,
},
"start": Object {
- "column": 79,
- "line": 6,
+ "column": 0,
+ "line": 1,
},
},
"range": Array [
- 217,
- 218,
+ 0,
+ 3,
],
- "type": "Punctuator",
- "value": ")",
+ "type": "Template",
+ "value": "\`\${",
},
Object {
"loc": Object {
"end": Object {
- "column": 81,
- "line": 6,
+ "column": 7,
+ "line": 1,
},
"start": Object {
- "column": 80,
- "line": 6,
+ "column": 3,
+ "line": 1,
},
},
"range": Array [
- 218,
- 219,
+ 3,
+ 7,
],
- "type": "Punctuator",
- "value": ";",
+ "type": "Identifier",
+ "value": "name",
},
Object {
"loc": Object {
"end": Object {
"column": 9,
- "line": 8,
+ "line": 1,
},
"start": Object {
- "column": 8,
- "line": 8,
+ "column": 7,
+ "line": 1,
},
},
"range": Array [
- 254,
- 255,
+ 7,
+ 9,
],
- "type": "Punctuator",
- "value": "}",
+ "type": "Template",
+ "value": "}\`",
},
Object {
"loc": Object {
"end": Object {
- "column": 14,
- "line": 9,
+ "column": 10,
+ "line": 1,
},
"start": Object {
- "column": 8,
- "line": 9,
+ "column": 9,
+ "line": 1,
},
},
"range": Array [
- 264,
- 270,
+ 9,
+ 10,
],
- "type": "Keyword",
- "value": "return",
+ "type": "Punctuator",
+ "value": ";",
},
Object {
"loc": Object {
"end": Object {
- "column": 20,
- "line": 9,
+ "column": 1,
+ "line": 2,
},
"start": Object {
- "column": 15,
- "line": 9,
+ "column": 0,
+ "line": 2,
},
},
"range": Array [
- 271,
- 276,
+ 11,
+ 12,
],
- "type": "Boolean",
- "value": "false",
+ "type": "Punctuator",
+ "value": "{",
},
Object {
"loc": Object {
"end": Object {
- "column": 21,
- "line": 9,
+ "column": 5,
+ "line": 4,
},
"start": Object {
- "column": 20,
- "line": 9,
+ "column": 4,
+ "line": 4,
},
},
"range": Array [
- 276,
- 277,
+ 56,
+ 57,
],
- "type": "Punctuator",
- "value": ";",
+ "type": "Numeric",
+ "value": "1",
},
Object {
"loc": Object {
"end": Object {
- "column": 5,
- "line": 10,
+ "column": 7,
+ "line": 4,
},
"start": Object {
- "column": 4,
- "line": 10,
+ "column": 6,
+ "line": 4,
},
},
"range": Array [
- 282,
- 283,
+ 58,
+ 59,
],
"type": "Punctuator",
- "value": "}",
+ "value": "+",
},
Object {
"loc": Object {
"end": Object {
- "column": 1,
- "line": 12,
+ "column": 9,
+ "line": 4,
},
"start": Object {
- "column": 0,
- "line": 12,
+ "column": 8,
+ "line": 4,
},
},
"range": Array [
- 285,
- 286,
+ 60,
+ 61,
],
- "type": "Punctuator",
- "value": "}",
+ "type": "Numeric",
+ "value": "1",
},
Object {
"loc": Object {
"end": Object {
- "column": 2,
- "line": 12,
+ "column": 10,
+ "line": 4,
},
"start": Object {
- "column": 1,
- "line": 12,
+ "column": 9,
+ "line": 4,
},
},
"range": Array [
- 286,
- 287,
+ 61,
+ 62,
],
"type": "Punctuator",
"value": ";",
},
- ],
- "type": "Program",
-}
-`;
-
-exports[`Comments fixtures/template-string-block.src 1`] = `
-Object {
- "body": Array [
Object {
- "expression": Object {
- "expressions": Array [
- Object {
- "loc": Object {
- "end": Object {
- "column": 7,
- "line": 1,
- },
- "start": Object {
- "column": 3,
- "line": 1,
- },
- },
- "name": "name",
- "range": Array [
- 3,
- 7,
- ],
- "type": "Identifier",
- },
- ],
- "loc": Object {
- "end": Object {
- "column": 9,
- "line": 1,
- },
- "start": Object {
- "column": 0,
- "line": 1,
- },
- },
- "quasis": Array [
- Object {
- "loc": Object {
- "end": Object {
- "column": 3,
- "line": 1,
- },
- "start": Object {
- "column": 0,
- "line": 1,
- },
- },
- "range": Array [
- 0,
- 3,
- ],
- "tail": false,
- "type": "TemplateElement",
- "value": Object {
- "cooked": "",
- "raw": "",
- },
- },
- Object {
- "loc": Object {
- "end": Object {
- "column": 9,
- "line": 1,
- },
- "start": Object {
- "column": 7,
- "line": 1,
- },
- },
- "range": Array [
- 7,
- 9,
- ],
- "tail": true,
- "type": "TemplateElement",
- "value": Object {
- "cooked": "",
- "raw": "",
- },
- },
- ],
- "range": Array [
- 0,
- 9,
- ],
- "type": "TemplateLiteral",
- },
"loc": Object {
"end": Object {
- "column": 10,
- "line": 1,
+ "column": 1,
+ "line": 5,
},
"start": Object {
"column": 0,
- "line": 1,
+ "line": 5,
},
},
"range": Array [
- 0,
- 10,
+ 63,
+ 64,
],
- "type": "ExpressionStatement",
+ "type": "Punctuator",
+ "value": "}",
},
+ ],
+ "type": "Program",
+}
+`;
+
+exports[`Comments fixtures/type-assertion-regression-test.src 1`] = `
+Object {
+ "body": Array [
Object {
- "body": Array [
+ "declarations": Array [
Object {
- "expression": Object {
- "left": Object {
+ "id": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 9,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 6,
+ "line": 1,
+ },
+ },
+ "name": "foo",
+ "range": Array [
+ 6,
+ 9,
+ ],
+ "type": "Identifier",
+ },
+ "init": Object {
+ "expression": Object {
"loc": Object {
"end": Object {
"column": 5,
- "line": 4,
+ "line": 2,
},
"start": Object {
- "column": 4,
- "line": 4,
+ "column": 2,
+ "line": 2,
},
},
+ "name": "bar",
"range": Array [
- 56,
- 57,
+ 28,
+ 31,
],
- "raw": "1",
- "type": "Literal",
- "value": 1,
+ "type": "Identifier",
},
"loc": Object {
"end": Object {
- "column": 9,
- "line": 4,
+ "column": 5,
+ "line": 2,
},
"start": Object {
- "column": 4,
- "line": 4,
+ "column": 12,
+ "line": 1,
},
},
- "operator": "+",
"range": Array [
- 56,
- 61,
+ 12,
+ 31,
],
- "right": Object {
+ "type": "TSTypeAssertion",
+ "typeAnnotation": Object {
"loc": Object {
"end": Object {
- "column": 9,
- "line": 4,
+ "column": 16,
+ "line": 1,
},
"start": Object {
- "column": 8,
- "line": 4,
+ "column": 13,
+ "line": 1,
},
},
"range": Array [
- 60,
- 61,
+ 13,
+ 16,
],
- "raw": "1",
- "type": "Literal",
- "value": 1,
+ "type": "TSTypeReference",
+ "typeName": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 16,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 13,
+ "line": 1,
+ },
+ },
+ "name": "Foo",
+ "range": Array [
+ 13,
+ 16,
+ ],
+ "type": "Identifier",
+ },
},
- "type": "BinaryExpression",
},
"loc": Object {
"end": Object {
- "column": 10,
- "line": 4,
+ "column": 5,
+ "line": 2,
},
"start": Object {
- "column": 4,
- "line": 4,
+ "column": 6,
+ "line": 1,
},
},
"range": Array [
- 56,
- 62,
+ 6,
+ 31,
],
- "type": "ExpressionStatement",
+ "type": "VariableDeclarator",
},
],
+ "kind": "const",
"loc": Object {
"end": Object {
- "column": 1,
- "line": 5,
+ "column": 6,
+ "line": 2,
},
"start": Object {
"column": 0,
- "line": 2,
+ "line": 1,
},
},
"range": Array [
- 11,
- 64,
+ 0,
+ 32,
],
- "type": "BlockStatement",
+ "type": "VariableDeclaration",
},
],
"comments": Array [
Object {
"loc": Object {
"end": Object {
- "column": 38,
- "line": 3,
+ "column": 25,
+ "line": 1,
},
"start": Object {
- "column": 4,
- "line": 3,
+ "column": 18,
+ "line": 1,
},
},
"range": Array [
- 17,
- 51,
+ 18,
+ 25,
],
- "type": "Block",
- "value": " TODO comment comment comment ",
+ "type": "Line",
+ "value": " test",
},
],
"loc": Object {
"end": Object {
"column": 0,
- "line": 6,
+ "line": 3,
},
"start": Object {
"column": 0,
@@ -9113,14 +13490,14 @@ Object {
},
"range": Array [
0,
- 65,
+ 33,
],
"sourceType": "script",
"tokens": Array [
Object {
"loc": Object {
"end": Object {
- "column": 3,
+ "column": 5,
"line": 1,
},
"start": Object {
@@ -9130,28 +13507,10 @@ Object {
},
"range": Array [
0,
- 3,
- ],
- "type": "Template",
- "value": "\`\${",
- },
- Object {
- "loc": Object {
- "end": Object {
- "column": 7,
- "line": 1,
- },
- "start": Object {
- "column": 3,
- "line": 1,
- },
- },
- "range": Array [
- 3,
- 7,
+ 5,
],
- "type": "Identifier",
- "value": "name",
+ "type": "Keyword",
+ "value": "const",
},
Object {
"loc": Object {
@@ -9160,143 +13519,125 @@ Object {
"line": 1,
},
"start": Object {
- "column": 7,
+ "column": 6,
"line": 1,
},
},
"range": Array [
- 7,
+ 6,
9,
],
- "type": "Template",
- "value": "}\`",
+ "type": "Identifier",
+ "value": "foo",
},
Object {
"loc": Object {
"end": Object {
- "column": 10,
+ "column": 11,
"line": 1,
},
"start": Object {
- "column": 9,
+ "column": 10,
"line": 1,
},
},
"range": Array [
- 9,
10,
+ 11,
],
"type": "Punctuator",
- "value": ";",
+ "value": "=",
},
Object {
"loc": Object {
"end": Object {
- "column": 1,
- "line": 2,
+ "column": 13,
+ "line": 1,
},
"start": Object {
- "column": 0,
- "line": 2,
+ "column": 12,
+ "line": 1,
},
},
"range": Array [
- 11,
12,
+ 13,
],
"type": "Punctuator",
- "value": "{",
+ "value": "<",
},
Object {
"loc": Object {
"end": Object {
- "column": 5,
- "line": 4,
+ "column": 16,
+ "line": 1,
},
"start": Object {
- "column": 4,
- "line": 4,
+ "column": 13,
+ "line": 1,
},
},
"range": Array [
- 56,
- 57,
+ 13,
+ 16,
],
- "type": "Numeric",
- "value": "1",
+ "type": "Identifier",
+ "value": "Foo",
},
Object {
"loc": Object {
"end": Object {
- "column": 7,
- "line": 4,
+ "column": 17,
+ "line": 1,
},
"start": Object {
- "column": 6,
- "line": 4,
+ "column": 16,
+ "line": 1,
},
},
"range": Array [
- 58,
- 59,
+ 16,
+ 17,
],
"type": "Punctuator",
- "value": "+",
+ "value": ">",
},
Object {
"loc": Object {
"end": Object {
- "column": 9,
- "line": 4,
+ "column": 5,
+ "line": 2,
},
"start": Object {
- "column": 8,
- "line": 4,
+ "column": 2,
+ "line": 2,
},
},
"range": Array [
- 60,
- 61,
+ 28,
+ 31,
],
- "type": "Numeric",
- "value": "1",
+ "type": "Identifier",
+ "value": "bar",
},
Object {
"loc": Object {
"end": Object {
- "column": 10,
- "line": 4,
+ "column": 6,
+ "line": 2,
},
"start": Object {
- "column": 9,
- "line": 4,
+ "column": 5,
+ "line": 2,
},
},
"range": Array [
- 61,
- 62,
+ 31,
+ 32,
],
"type": "Punctuator",
"value": ";",
},
- Object {
- "loc": Object {
- "end": Object {
- "column": 1,
- "line": 5,
- },
- "start": Object {
- "column": 0,
- "line": 5,
- },
- },
- "range": Array [
- 63,
- 64,
- ],
- "type": "Punctuator",
- "value": "}",
- },
],
"type": "Program",
}
diff --git a/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap b/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap
index 504efbb..f54e6aa 100644
--- a/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap
+++ b/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap
@@ -17,6 +17,24 @@ Object {
}
`;
+exports[`Parse all fixtures with "errorOnTypeScriptSyntaticAndSemanticIssues" enabled fixtures/comments/jsx-comment-after-jsx.src.js.src 1`] = `
+Object {
+ "column": 14,
+ "index": 48,
+ "lineNumber": 3,
+ "message": "Type expected.",
+}
+`;
+
+exports[`Parse all fixtures with "errorOnTypeScriptSyntaticAndSemanticIssues" enabled fixtures/comments/jsx-comment-after-self-closing-jsx.src.js.src 1`] = `
+Object {
+ "column": 13,
+ "index": 47,
+ "lineNumber": 3,
+ "message": "'>' expected.",
+}
+`;
+
exports[`Parse all fixtures with "errorOnTypeScriptSyntaticAndSemanticIssues" enabled fixtures/comments/jsx-tag-comments.src.js.src 1`] = `
Object {
"column": 9,
@@ -26,6 +44,42 @@ Object {
}
`;
+exports[`Parse all fixtures with "errorOnTypeScriptSyntaticAndSemanticIssues" enabled fixtures/comments/jsx-text-with-multiline-non-comment.src.js.src 1`] = `
+Object {
+ "column": 5,
+ "index": 81,
+ "lineNumber": 7,
+ "message": "Type expected.",
+}
+`;
+
+exports[`Parse all fixtures with "errorOnTypeScriptSyntaticAndSemanticIssues" enabled fixtures/comments/jsx-text-with-url.src.js.src 1`] = `
+Object {
+ "column": 17,
+ "index": 17,
+ "lineNumber": 1,
+ "message": "'>' expected.",
+}
+`;
+
+exports[`Parse all fixtures with "errorOnTypeScriptSyntaticAndSemanticIssues" enabled fixtures/comments/jsx-with-greather-than.src.js.src 1`] = `
+Object {
+ "column": 0,
+ "index": 69,
+ "lineNumber": 4,
+ "message": "Expression expected.",
+}
+`;
+
+exports[`Parse all fixtures with "errorOnTypeScriptSyntaticAndSemanticIssues" enabled fixtures/comments/jsx-with-operators.src.js.src 1`] = `
+Object {
+ "column": 0,
+ "index": 69,
+ "lineNumber": 4,
+ "message": "Expression expected.",
+}
+`;
+
exports[`Parse all fixtures with "errorOnTypeScriptSyntaticAndSemanticIssues" enabled fixtures/comments/line-comment-with-block-syntax.src.js.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;
exports[`Parse all fixtures with "errorOnTypeScriptSyntaticAndSemanticIssues" enabled fixtures/comments/mix-line-and-block-comments.src.js.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;
@@ -56,6 +110,8 @@ exports[`Parse all fixtures with "errorOnTypeScriptSyntaticAndSemanticIssues" en
exports[`Parse all fixtures with "errorOnTypeScriptSyntaticAndSemanticIssues" enabled fixtures/comments/template-string-block.src.js.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;
+exports[`Parse all fixtures with "errorOnTypeScriptSyntaticAndSemanticIssues" enabled fixtures/comments/type-assertion-regression-test.src.ts.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;
+
exports[`Parse all fixtures with "errorOnTypeScriptSyntaticAndSemanticIssues" enabled fixtures/javascript/arrayLiteral/array-literal-in-lhs.src.js.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;
exports[`Parse all fixtures with "errorOnTypeScriptSyntaticAndSemanticIssues" enabled fixtures/javascript/arrayLiteral/array-literals-in-binary-expr.src.js.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;
diff --git a/tests/lib/comments.ts b/tests/lib/comments.ts
index 936b7a2..7ad9695 100644
--- a/tests/lib/comments.ts
+++ b/tests/lib/comments.ts
@@ -18,10 +18,9 @@ const FIXTURES_DIR = './tests/fixtures/comments';
const testFiles = shelljs
.find(FIXTURES_DIR)
- .filter(filename => filename.indexOf('.src.js') > -1)
- // strip off ".src.js"
- .map(filename =>
- filename.substring(FIXTURES_DIR.length - 1, filename.length - 7)
+ .filter(
+ filename =>
+ filename.indexOf('.src.js') > -1 || filename.indexOf('.src.ts') > -1
);
//------------------------------------------------------------------------------
@@ -30,17 +29,19 @@ const testFiles = shelljs
describe('Comments', () => {
testFiles.forEach(filename => {
- const code = shelljs.cat(`${path.resolve(FIXTURES_DIR, filename)}.src.js`);
- const config = {
+ const code = shelljs.cat(path.resolve(filename));
+ const config: ParserOptions = {
loc: true,
range: true,
tokens: true,
comment: true,
- jsx: true
+ jsx: path.extname(filename) === '.js'
};
- it(
- `fixtures/${filename}.src`,
- createSnapshotTestBlock(code, config as ParserOptions)
+ // strip off ".src.js" and ".src.ts"
+ const name = filename.substring(
+ FIXTURES_DIR.length - 1,
+ filename.length - 7
);
+ it(`fixtures/${name}.src`, createSnapshotTestBlock(code, config));
});
});