diff --git a/README.md b/README.md index d0768723..1741faa5 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,28 @@ For example: } ``` +You can also specify an object and change the parser separately for `" + } + ], + "comments": [], + "templateBody": { + "type": "VElement", + "range": [ + 0, + 38 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "name": "template", + "rawName": "template", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 0, + 10 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 10, + 13 + ], + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 2, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "VExpressionContainer", + "range": [ + 13, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "expression": { + "type": "CallExpression", + "callee": { + "type": "Identifier", + "name": "a", + "range": [ + 15, + 16 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 5 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "d", + "range": [ + 22, + 23 + ], + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 12 + } + } + } + ], + "optional": false, + "range": [ + 15, + 24 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "typeParameters": { + "type": "TSTypeParameterInstantiation", + "range": [ + 16, + 21 + ], + "params": [ + { + "type": "TSUnionType", + "types": [ + { + "type": "TSTypeReference", + "typeName": { + "type": "Identifier", + "name": "b", + "range": [ + 17, + 18 + ], + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 7 + } + } + }, + "range": [ + 17, + 18 + ], + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 7 + } + } + }, + { + "type": "TSTypeReference", + "typeName": { + "type": "Identifier", + "name": "c", + "range": [ + 19, + 20 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 + } + } + }, + "range": [ + 19, + 20 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 + } + } + } + ], + "range": [ + 17, + 20 + ], + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 9 + } + } + } + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 10 + } + } + } + }, + "references": [ + { + "id": { + "type": "Identifier", + "name": "a", + "range": [ + 15, + 16 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 5 + } + } + }, + "mode": "r" + }, + { + "id": { + "type": "Identifier", + "name": "d", + "range": [ + 22, + 23 + ], + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 12 + } + } + }, + "mode": "r" + } + ] + }, + { + "type": "VText", + "range": [ + 26, + 27 + ], + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 27, + 38 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 11 + } + } + }, + "variables": [], + "tokens": [ + { + "type": "HTMLTagOpen", + "range": [ + 0, + 9 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 9, + 10 + ], + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 10, + 13 + ], + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 2, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "VExpressionStart", + "range": [ + 13, + 15 + ], + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 4 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "value": "a", + "range": [ + 15, + 16 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 5 + } + } + }, + { + "type": "Punctuator", + "value": "<", + "range": [ + 16, + 17 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 6 + } + } + }, + { + "type": "Identifier", + "value": "b", + "range": [ + 17, + 18 + ], + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 7 + } + } + }, + { + "type": "Punctuator", + "value": "|", + "range": [ + 18, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 8 + } + } + }, + { + "type": "Identifier", + "value": "c", + "range": [ + 19, + 20 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 20, + 21 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 10 + } + } + }, + { + "type": "Punctuator", + "value": "(", + "range": [ + 21, + 22 + ], + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + } + } + }, + { + "type": "Identifier", + "value": "d", + "range": [ + 22, + 23 + ], + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 12 + } + } + }, + { + "type": "Punctuator", + "value": ")", + "range": [ + 23, + 24 + ], + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 13 + } + } + }, + { + "type": "VExpressionEnd", + "range": [ + 24, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "value": "}}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 26, + 27 + ], + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 27, + 37 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 37, + 38 + ], + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 38, + 39 + ], + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 39, + 46 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLIdentifier", + "range": [ + 47, + 51 + ], + "loc": { + "start": { + "line": 4, + "column": 8 + }, + "end": { + "line": 4, + "column": 12 + } + }, + "value": "lang" + }, + { + "type": "HTMLAssociation", + "range": [ + 51, + 52 + ], + "loc": { + "start": { + "line": 4, + "column": 12 + }, + "end": { + "line": 4, + "column": 13 + } + }, + "value": "" + }, + { + "type": "HTMLLiteral", + "range": [ + 52, + 56 + ], + "loc": { + "start": { + "line": 4, + "column": 13 + }, + "end": { + "line": 4, + "column": 17 + } + }, + "value": "ts" + }, + { + "type": "HTMLTagClose", + "range": [ + 56, + 57 + ], + "loc": { + "start": { + "line": 4, + "column": 17 + }, + "end": { + "line": 4, + "column": 18 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 57, + 60 + ], + "loc": { + "start": { + "line": 4, + "column": 18 + }, + "end": { + "line": 5, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "HTMLRawText", + "range": [ + 60, + 69 + ], + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 5, + "column": 11 + } + }, + "value": "a(d)" + }, + { + "type": "HTMLWhitespace", + "range": [ + 69, + 70 + ], + "loc": { + "start": { + "line": 5, + "column": 11 + }, + "end": { + "line": 6, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 70, + 78 + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 78, + 79 + ], + "loc": { + "start": { + "line": 6, + "column": 8 + }, + "end": { + "line": 6, + "column": 9 + } + }, + "value": "" + } + ], + "comments": [], + "errors": [] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/parser-option-multiple-parsers-1/parser-options.json b/test/fixtures/ast/parser-option-multiple-parsers-1/parser-options.json new file mode 100644 index 00000000..b6e8a4d5 --- /dev/null +++ b/test/fixtures/ast/parser-option-multiple-parsers-1/parser-options.json @@ -0,0 +1,8 @@ +{ + "sourceType": "module", + "parser": { "ts": "@typescript-eslint/parser" }, + "vueFeatures": { + "interpolationAsNonHTML": true, + "filter": false + } +} diff --git a/test/fixtures/ast/parser-option-multiple-parsers-1/source.vue b/test/fixtures/ast/parser-option-multiple-parsers-1/source.vue new file mode 100644 index 00000000..7430708f --- /dev/null +++ b/test/fixtures/ast/parser-option-multiple-parsers-1/source.vue @@ -0,0 +1,6 @@ + + \ No newline at end of file diff --git a/test/fixtures/ast/parser-option-multiple-parsers-1/token-ranges.json b/test/fixtures/ast/parser-option-multiple-parsers-1/token-ranges.json new file mode 100644 index 00000000..65a1a862 --- /dev/null +++ b/test/fixtures/ast/parser-option-multiple-parsers-1/token-ranges.json @@ -0,0 +1,41 @@ +[ + "", + "", + "\n ", + "{{", + "a", + "<", + "b", + "|", + "c", + ">", + "(", + "d", + ")", + "}}", + "\n", + "", + "\n", + "", + "\n ", + "a(d)", + "\n", + "" +] \ No newline at end of file diff --git a/test/fixtures/ast/parser-option-multiple-parsers-1/tree.json b/test/fixtures/ast/parser-option-multiple-parsers-1/tree.json new file mode 100644 index 00000000..c456ad64 --- /dev/null +++ b/test/fixtures/ast/parser-option-multiple-parsers-1/tree.json @@ -0,0 +1,50 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/ast/parser-option-multiple-parsers-2/ast.json b/test/fixtures/ast/parser-option-multiple-parsers-2/ast.json new file mode 100644 index 00000000..2bd46a34 --- /dev/null +++ b/test/fixtures/ast/parser-option-multiple-parsers-2/ast.json @@ -0,0 +1,1218 @@ +{ + "type": "Program", + "start": 47, + "end": 60, + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 5, + "column": 11 + } + }, + "range": [ + 50, + 59 + ], + "body": [ + { + "type": "ExpressionStatement", + "start": 50, + "end": 59, + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 5, + "column": 11 + } + }, + "range": [ + 50, + 59 + ], + "expression": { + "type": "BinaryExpression", + "start": 50, + "end": 59, + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 5, + "column": 11 + } + }, + "range": [ + 50, + 59 + ], + "left": { + "type": "BinaryExpression", + "start": 50, + "end": 53, + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 5, + "column": 5 + } + }, + "range": [ + 50, + 53 + ], + "left": { + "type": "Identifier", + "start": 50, + "end": 51, + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 5, + "column": 3 + } + }, + "range": [ + 50, + 51 + ], + "name": "a" + }, + "operator": "<", + "right": { + "type": "Identifier", + "start": 52, + "end": 53, + "loc": { + "start": { + "line": 5, + "column": 4 + }, + "end": { + "line": 5, + "column": 5 + } + }, + "range": [ + 52, + 53 + ], + "name": "b" + } + }, + "operator": "|", + "right": { + "type": "BinaryExpression", + "start": 54, + "end": 59, + "loc": { + "start": { + "line": 5, + "column": 6 + }, + "end": { + "line": 5, + "column": 11 + } + }, + "range": [ + 54, + 59 + ], + "left": { + "type": "Identifier", + "start": 54, + "end": 55, + "loc": { + "start": { + "line": 5, + "column": 6 + }, + "end": { + "line": 5, + "column": 7 + } + }, + "range": [ + 54, + 55 + ], + "name": "c" + }, + "operator": ">", + "right": { + "type": "Identifier", + "start": 57, + "end": 58, + "loc": { + "start": { + "line": 5, + "column": 9 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "range": [ + 57, + 58 + ], + "name": "d" + } + } + } + } + ], + "sourceType": "module", + "comments": [], + "tokens": [ + { + "type": "Punctuator", + "range": [ + 39, + 47 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 8 + } + }, + "value": "" + } + ], + "templateBody": { + "type": "VElement", + "range": [ + 0, + 38 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "name": "template", + "rawName": "template", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 0, + 10 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 10, + 13 + ], + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 2, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "VExpressionContainer", + "range": [ + 13, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "expression": { + "type": "BinaryExpression", + "start": 15, + "end": 24, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "range": [ + 15, + 24 + ], + "left": { + "type": "BinaryExpression", + "start": 15, + "end": 18, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "range": [ + 15, + 18 + ], + "left": { + "type": "Identifier", + "start": 15, + "end": 16, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 5 + } + }, + "range": [ + 15, + 16 + ], + "name": "a" + }, + "operator": "<", + "right": { + "type": "Identifier", + "start": 17, + "end": 18, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "range": [ + 17, + 18 + ], + "name": "b" + } + }, + "operator": "|", + "right": { + "type": "BinaryExpression", + "start": 19, + "end": 24, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "range": [ + 19, + 24 + ], + "left": { + "type": "Identifier", + "start": 19, + "end": 20, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "range": [ + 19, + 20 + ], + "name": "c" + }, + "operator": ">", + "right": { + "type": "Identifier", + "start": 22, + "end": 23, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "range": [ + 22, + 23 + ], + "name": "d" + } + } + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 15, + "end": 16, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 5 + } + }, + "range": [ + 15, + 16 + ], + "name": "a" + }, + "mode": "r" + }, + { + "id": { + "type": "Identifier", + "start": 17, + "end": 18, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "range": [ + 17, + 18 + ], + "name": "b" + }, + "mode": "r" + }, + { + "id": { + "type": "Identifier", + "start": 19, + "end": 20, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "range": [ + 19, + 20 + ], + "name": "c" + }, + "mode": "r" + }, + { + "id": { + "type": "Identifier", + "start": 22, + "end": 23, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "range": [ + 22, + 23 + ], + "name": "d" + }, + "mode": "r" + } + ] + }, + { + "type": "VText", + "range": [ + 26, + 27 + ], + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 27, + 38 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 11 + } + } + }, + "variables": [], + "tokens": [ + { + "type": "HTMLTagOpen", + "range": [ + 0, + 9 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 9, + 10 + ], + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 10, + 13 + ], + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 2, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "VExpressionStart", + "range": [ + 13, + 15 + ], + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 4 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "value": "a", + "start": 15, + "end": 16, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 5 + } + }, + "range": [ + 15, + 16 + ] + }, + { + "type": "Punctuator", + "value": "<", + "start": 16, + "end": 17, + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 6 + } + }, + "range": [ + 16, + 17 + ] + }, + { + "type": "Identifier", + "value": "b", + "start": 17, + "end": 18, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "range": [ + 17, + 18 + ] + }, + { + "type": "Punctuator", + "value": "|", + "start": 18, + "end": 19, + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "range": [ + 18, + 19 + ] + }, + { + "type": "Identifier", + "value": "c", + "start": 19, + "end": 20, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "range": [ + 19, + 20 + ] + }, + { + "type": "Punctuator", + "value": ">", + "start": 20, + "end": 21, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "range": [ + 20, + 21 + ] + }, + { + "type": "Punctuator", + "value": "(", + "start": 21, + "end": 22, + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "range": [ + 21, + 22 + ] + }, + { + "type": "Identifier", + "value": "d", + "start": 22, + "end": 23, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "range": [ + 22, + 23 + ] + }, + { + "type": "Punctuator", + "value": ")", + "start": 23, + "end": 24, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "range": [ + 23, + 24 + ] + }, + { + "type": "VExpressionEnd", + "range": [ + 24, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "value": "}}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 26, + 27 + ], + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 27, + 37 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 37, + 38 + ], + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 38, + 39 + ], + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 39, + 46 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 46, + 47 + ], + "loc": { + "start": { + "line": 4, + "column": 7 + }, + "end": { + "line": 4, + "column": 8 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 47, + 50 + ], + "loc": { + "start": { + "line": 4, + "column": 8 + }, + "end": { + "line": 5, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "HTMLRawText", + "range": [ + 50, + 59 + ], + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 5, + "column": 11 + } + }, + "value": "a(d)" + }, + { + "type": "HTMLWhitespace", + "range": [ + 59, + 60 + ], + "loc": { + "start": { + "line": 5, + "column": 11 + }, + "end": { + "line": 6, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 60, + 68 + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 68, + 69 + ], + "loc": { + "start": { + "line": 6, + "column": 8 + }, + "end": { + "line": 6, + "column": 9 + } + }, + "value": "" + } + ], + "comments": [], + "errors": [] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/parser-option-multiple-parsers-2/parser-options.json b/test/fixtures/ast/parser-option-multiple-parsers-2/parser-options.json new file mode 100644 index 00000000..b6e8a4d5 --- /dev/null +++ b/test/fixtures/ast/parser-option-multiple-parsers-2/parser-options.json @@ -0,0 +1,8 @@ +{ + "sourceType": "module", + "parser": { "ts": "@typescript-eslint/parser" }, + "vueFeatures": { + "interpolationAsNonHTML": true, + "filter": false + } +} diff --git a/test/fixtures/ast/parser-option-multiple-parsers-2/source.vue b/test/fixtures/ast/parser-option-multiple-parsers-2/source.vue new file mode 100644 index 00000000..9f441f2b --- /dev/null +++ b/test/fixtures/ast/parser-option-multiple-parsers-2/source.vue @@ -0,0 +1,6 @@ + + \ No newline at end of file diff --git a/test/fixtures/ast/parser-option-multiple-parsers-2/token-ranges.json b/test/fixtures/ast/parser-option-multiple-parsers-2/token-ranges.json new file mode 100644 index 00000000..5d0595ea --- /dev/null +++ b/test/fixtures/ast/parser-option-multiple-parsers-2/token-ranges.json @@ -0,0 +1,38 @@ +[ + "", + "", + "\n ", + "{{", + "a", + "<", + "b", + "|", + "c", + ">", + "(", + "d", + ")", + "}}", + "\n", + "", + "\n", + "", + "\n ", + "a(d)", + "\n", + "" +] \ No newline at end of file diff --git a/test/fixtures/ast/parser-option-multiple-parsers-2/tree.json b/test/fixtures/ast/parser-option-multiple-parsers-2/tree.json new file mode 100644 index 00000000..76f18841 --- /dev/null +++ b/test/fixtures/ast/parser-option-multiple-parsers-2/tree.json @@ -0,0 +1,72 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/ast/parser-option-multiple-parsers-3/ast.json b/test/fixtures/ast/parser-option-multiple-parsers-3/ast.json new file mode 100644 index 00000000..b3dadbb8 --- /dev/null +++ b/test/fixtures/ast/parser-option-multiple-parsers-3/ast.json @@ -0,0 +1,1274 @@ +{ + "type": "Program", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "Identifier", + "name": "a", + "range": [ + 60, + 61 + ], + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 5, + "column": 3 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "d", + "range": [ + 67, + 68 + ], + "loc": { + "start": { + "line": 5, + "column": 9 + }, + "end": { + "line": 5, + "column": 10 + } + } + } + ], + "optional": false, + "range": [ + 60, + 69 + ], + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 5, + "column": 11 + } + }, + "typeParameters": { + "type": "TSTypeParameterInstantiation", + "range": [ + 61, + 66 + ], + "params": [ + { + "type": "TSUnionType", + "types": [ + { + "type": "TSTypeReference", + "typeName": { + "type": "Identifier", + "name": "b", + "range": [ + 62, + 63 + ], + "loc": { + "start": { + "line": 5, + "column": 4 + }, + "end": { + "line": 5, + "column": 5 + } + } + }, + "range": [ + 62, + 63 + ], + "loc": { + "start": { + "line": 5, + "column": 4 + }, + "end": { + "line": 5, + "column": 5 + } + } + }, + { + "type": "TSTypeReference", + "typeName": { + "type": "Identifier", + "name": "c", + "range": [ + 64, + 65 + ], + "loc": { + "start": { + "line": 5, + "column": 6 + }, + "end": { + "line": 5, + "column": 7 + } + } + }, + "range": [ + 64, + 65 + ], + "loc": { + "start": { + "line": 5, + "column": 6 + }, + "end": { + "line": 5, + "column": 7 + } + } + } + ], + "range": [ + 62, + 65 + ], + "loc": { + "start": { + "line": 5, + "column": 4 + }, + "end": { + "line": 5, + "column": 7 + } + } + } + ], + "loc": { + "start": { + "line": 5, + "column": 3 + }, + "end": { + "line": 5, + "column": 8 + } + } + } + }, + "range": [ + 60, + 69 + ], + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 5, + "column": 11 + } + } + } + ], + "sourceType": "module", + "range": [ + 60, + 70 + ], + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 6, + "column": 0 + } + }, + "tokens": [ + { + "type": "Punctuator", + "range": [ + 39, + 57 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 18 + } + }, + "value": "" + } + ], + "comments": [], + "templateBody": { + "type": "VElement", + "range": [ + 0, + 38 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "name": "template", + "rawName": "template", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 0, + 10 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 10, + 13 + ], + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 2, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "VExpressionContainer", + "range": [ + 13, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "expression": { + "type": "BinaryExpression", + "start": 15, + "end": 24, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "range": [ + 15, + 24 + ], + "left": { + "type": "BinaryExpression", + "start": 15, + "end": 18, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "range": [ + 15, + 18 + ], + "left": { + "type": "Identifier", + "start": 15, + "end": 16, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 5 + } + }, + "range": [ + 15, + 16 + ], + "name": "a" + }, + "operator": "<", + "right": { + "type": "Identifier", + "start": 17, + "end": 18, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "range": [ + 17, + 18 + ], + "name": "b" + } + }, + "operator": "|", + "right": { + "type": "BinaryExpression", + "start": 19, + "end": 24, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "range": [ + 19, + 24 + ], + "left": { + "type": "Identifier", + "start": 19, + "end": 20, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "range": [ + 19, + 20 + ], + "name": "c" + }, + "operator": ">", + "right": { + "type": "Identifier", + "start": 22, + "end": 23, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "range": [ + 22, + 23 + ], + "name": "d" + } + } + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 15, + "end": 16, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 5 + } + }, + "range": [ + 15, + 16 + ], + "name": "a" + }, + "mode": "r" + }, + { + "id": { + "type": "Identifier", + "start": 17, + "end": 18, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "range": [ + 17, + 18 + ], + "name": "b" + }, + "mode": "r" + }, + { + "id": { + "type": "Identifier", + "start": 19, + "end": 20, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "range": [ + 19, + 20 + ], + "name": "c" + }, + "mode": "r" + }, + { + "id": { + "type": "Identifier", + "start": 22, + "end": 23, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "range": [ + 22, + 23 + ], + "name": "d" + }, + "mode": "r" + } + ] + }, + { + "type": "VText", + "range": [ + 26, + 27 + ], + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 27, + 38 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 11 + } + } + }, + "variables": [], + "tokens": [ + { + "type": "HTMLTagOpen", + "range": [ + 0, + 9 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 9, + 10 + ], + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 10, + 13 + ], + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 2, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "VExpressionStart", + "range": [ + 13, + 15 + ], + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 4 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "value": "a", + "start": 15, + "end": 16, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 5 + } + }, + "range": [ + 15, + 16 + ] + }, + { + "type": "Punctuator", + "value": "<", + "start": 16, + "end": 17, + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 6 + } + }, + "range": [ + 16, + 17 + ] + }, + { + "type": "Identifier", + "value": "b", + "start": 17, + "end": 18, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "range": [ + 17, + 18 + ] + }, + { + "type": "Punctuator", + "value": "|", + "start": 18, + "end": 19, + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "range": [ + 18, + 19 + ] + }, + { + "type": "Identifier", + "value": "c", + "start": 19, + "end": 20, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "range": [ + 19, + 20 + ] + }, + { + "type": "Punctuator", + "value": ">", + "start": 20, + "end": 21, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "range": [ + 20, + 21 + ] + }, + { + "type": "Punctuator", + "value": "(", + "start": 21, + "end": 22, + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "range": [ + 21, + 22 + ] + }, + { + "type": "Identifier", + "value": "d", + "start": 22, + "end": 23, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "range": [ + 22, + 23 + ] + }, + { + "type": "Punctuator", + "value": ")", + "start": 23, + "end": 24, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "range": [ + 23, + 24 + ] + }, + { + "type": "VExpressionEnd", + "range": [ + 24, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "value": "}}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 26, + 27 + ], + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 27, + 37 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 37, + 38 + ], + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 38, + 39 + ], + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 39, + 46 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLIdentifier", + "range": [ + 47, + 51 + ], + "loc": { + "start": { + "line": 4, + "column": 8 + }, + "end": { + "line": 4, + "column": 12 + } + }, + "value": "lang" + }, + { + "type": "HTMLAssociation", + "range": [ + 51, + 52 + ], + "loc": { + "start": { + "line": 4, + "column": 12 + }, + "end": { + "line": 4, + "column": 13 + } + }, + "value": "" + }, + { + "type": "HTMLLiteral", + "range": [ + 52, + 56 + ], + "loc": { + "start": { + "line": 4, + "column": 13 + }, + "end": { + "line": 4, + "column": 17 + } + }, + "value": "ts" + }, + { + "type": "HTMLTagClose", + "range": [ + 56, + 57 + ], + "loc": { + "start": { + "line": 4, + "column": 17 + }, + "end": { + "line": 4, + "column": 18 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 57, + 60 + ], + "loc": { + "start": { + "line": 4, + "column": 18 + }, + "end": { + "line": 5, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "HTMLRawText", + "range": [ + 60, + 69 + ], + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 5, + "column": 11 + } + }, + "value": "a(d)" + }, + { + "type": "HTMLWhitespace", + "range": [ + 69, + 70 + ], + "loc": { + "start": { + "line": 5, + "column": 11 + }, + "end": { + "line": 6, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 70, + 78 + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 78, + 79 + ], + "loc": { + "start": { + "line": 6, + "column": 8 + }, + "end": { + "line": 6, + "column": 9 + } + }, + "value": "" + } + ], + "comments": [], + "errors": [] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/parser-option-multiple-parsers-3/parser-options.json b/test/fixtures/ast/parser-option-multiple-parsers-3/parser-options.json new file mode 100644 index 00000000..08c6e052 --- /dev/null +++ b/test/fixtures/ast/parser-option-multiple-parsers-3/parser-options.json @@ -0,0 +1,11 @@ +{ + "sourceType": "module", + "parser": { + "ts": "@typescript-eslint/parser", + "