diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index b77b6607..00000000 --- a/.eslintignore +++ /dev/null @@ -1,10 +0,0 @@ -/.nyc_output -/.temp -/coverage -/node_modules -/src/external -/src/html/util -/test/fixtures -/test/temp -/index.d.ts -/index.js diff --git a/.eslintrc.yml b/.eslintrc.yml deleted file mode 100644 index 8f89e2f3..00000000 --- a/.eslintrc.yml +++ /dev/null @@ -1,18 +0,0 @@ -extends: - - plugin:@mysticatea/es2015 - - plugin:@mysticatea/+node - -overrides: - - files: "typings/**" - rules: - node/no-missing-import: - - error - - allowModules: - - estree - -settings: - node: - tryExtensions: - - .ts - - .js - - .json diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index ce763b1f..71f6fe76 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,2 +1,3 @@ github: +- ota-meshi - mysticatea diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 00000000..2c55f6c5 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,84 @@ +name: Bug report +description: Create a report to help us improve. + +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to fill out this bug report! + - type: checkboxes + id: sanity-checks + attributes: + label: Before You File a Bug Report Please Confirm You Have Done The Following... + description: If any of these required steps are not taken, we may not be able to review your issue. Help us to help you! + options: + - label: I'm using [eslint-plugin-vue](https://github.com/vuejs/eslint-plugin-vue). + - label: I'm sure the problem is a parser problem. (If you are not sure, search for the issue in [eslint-plugin-vue](https://github.com/vuejs/eslint-plugin-vue) repo and open the issue in [eslint-plugin-vue](https://github.com/vuejs/eslint-plugin-vue) repo if there is no solution. + required: true + - label: I have tried restarting my IDE and the issue persists. + required: true + - label: I have updated to the latest version of the packages. + required: true + - type: input + id: eslint-version + attributes: + label: What version of ESLint are you using? + placeholder: 0.0.0 + validations: + required: true + - type: textarea + id: eslint-plugin-vue-version + attributes: + label: What version of `eslint-plugin-vue` and `vue-eslint-parser` are you using? + value: | + - vue-eslint-parser@0.0.0 + - eslint-plugin-vue@0.0.0 + validations: + required: true + - type: textarea + attributes: + label: What did you do? + description: | + Please include a *minimal* reproduction case. + value: | +
+ Configuration + + ``` + + ``` +
+ + ```vue + + ``` + validations: + required: true + - type: textarea + attributes: + label: What did you expect to happen? + description: | + You can use Markdown in this field. + validations: + required: true + - type: textarea + attributes: + label: What actually happened? + description: | + Please copy-paste the actual ESLint output. You can use Markdown in this field. + validations: + required: true + - type: textarea + id: bug-reproduction + attributes: + label: Link to Minimal Reproducible Example + description: | + Create a minimal reproduction of the problem. **A minimal reproduction is required** so that others can help debug your issue. **If a report has no reproduction, it will be closed.** + [Why Reproductions are Required](https://antfu.me/posts/why-reproductions-are-required) + placeholder: | + https://github.com/[your]/[repo] + validations: + required: true + - type: textarea + attributes: + label: Additional comments diff --git a/.github/ISSUE_TEMPLATE/other.md b/.github/ISSUE_TEMPLATE/other.md new file mode 100644 index 00000000..565795b2 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/other.md @@ -0,0 +1,7 @@ +--- +name: Other +about: An issue that doesn't fit into the other categories. +title: "" +labels: "" +assignees: "" +--- diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index c9b501be..6bb0a761 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -1,7 +1,7 @@ name: CI on: push: - branches: [master] + branches: [master, try] pull_request: branches: [master] schedule: @@ -13,13 +13,13 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Checkout submodules run: git submodule update --init - name: Install Node.js - uses: actions/setup-node@v1 + uses: actions/setup-node@v4 with: - node-version: 14 + node-version: 'lts/*' - name: Install Packages run: npm install - name: Lint @@ -29,55 +29,55 @@ jobs: name: Test strategy: matrix: - eslint: [7] - node: [14] + eslint: [9] + node: [18, 20, 21, 'lts/*'] os: [ubuntu-latest] include: # On other platforms - - eslint: 7 - node: 14 + - eslint: 9 + node: 'lts/*' os: windows-latest - - eslint: 7 - node: 14 + - eslint: 9 + node: 'lts/*' os: macos-latest - # On old Node.js versions - - eslint: 7 - node: 12 - os: ubuntu-latest - - eslint: 7 - node: 10 - os: ubuntu-latest - # On old ESLint versions - - eslint: 6 - node: 14 - os: ubuntu-latest - - eslint: 5 - node: 14 - os: ubuntu-latest - # On the minimum supported ESLint/Node.js version - - eslint: 5 - node: 8.10.0 - os: ubuntu-latest runs-on: ${{ matrix.os }} steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 + - name: Checkout submodules + run: git submodule update --init + - name: Install Node.js v${{ matrix.node }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node }} + - name: Install Packages + run: npm install -f + - name: Install ESLint v${{ matrix.eslint }} + run: node scripts/ci-install-eslint ${{ matrix.eslint }} + - name: Test + run: npm run -s test + test-for-old-eslint: + name: Test + strategy: + matrix: + eslint: [8] + node: ['lts/*'] + os: [ubuntu-latest] + + runs-on: ${{ matrix.os }} + steps: + - name: Checkout + uses: actions/checkout@v4 - name: Checkout submodules run: git submodule update --init - name: Install Node.js v${{ matrix.node }} - uses: actions/setup-node@v1 + uses: actions/setup-node@v4 with: node-version: ${{ matrix.node }} - name: Install Packages - run: npm install + run: npm install -f - name: Install ESLint v${{ matrix.eslint }} run: node scripts/ci-install-eslint ${{ matrix.eslint }} - - name: Build - run: npm run -s build - name: Test - run: npm run -s test:mocha - - name: Send Coverage - run: npm run -s codecov - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + run: npm run -s test diff --git a/.gitignore b/.gitignore index 80b13514..f17b5538 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,8 @@ -/.nyc_output -/.temp /coverage -/node_modules +node_modules /test/temp -/index.* /npm-debug.log /test.js +/test/fixtures/espree-v8/node_modules +/test/fixtures/integrations/**/_actual.json +/dist diff --git a/.gitmodules b/.gitmodules index 45ed6b45..e69de29b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +0,0 @@ -[submodule "test/fixtures/eslint"] - path = test/fixtures/eslint - url = https://github.com/eslint/eslint.git diff --git a/.nycrc b/.nycrc deleted file mode 100644 index a31275f2..00000000 --- a/.nycrc +++ /dev/null @@ -1,19 +0,0 @@ -{ - "include": [ - "src/**/*.ts" - ], - "exclude": [ - "src/external/**/*.ts" - ], - "extension": [ - ".ts" - ], - "require": [ - "ts-node/register" - ], - "reporter": [ - "lcov", - "text-summary" - ], - "sourceMap": true -} diff --git a/.vscode/settings.json b/.vscode/settings.json index e4ba81f2..7ff99747 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,9 +1,12 @@ { - "eslint.validate": [ - "javascript", - {"language": "html", "autoFix": true}, - {"language": "vue", "autoFix": true}, - {"language": "typescript", "autoFix": true} - ], - "typescript.tsdk": "node_modules/typescript/lib" + "typescript.tsdk": "node_modules/typescript/lib", + "eslint.validate": [ + "javascript", + "javascriptreact", + "typescript", + "typescriptreact", + "vue", + "json", + "jsonc" + ] } diff --git a/README.md b/README.md index 3fd432b1..57a71a6b 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,7 @@ [![npm version](https://img.shields.io/npm/v/vue-eslint-parser.svg)](https://www.npmjs.com/package/vue-eslint-parser) [![Downloads/month](https://img.shields.io/npm/dm/vue-eslint-parser.svg)](http://www.npmtrends.com/vue-eslint-parser) -[![Build Status](https://github.com/mysticatea/vue-eslint-parser/workflows/CI/badge.svg)](https://github.com/mysticatea/vue-eslint-parser/actions) -[![Coverage Status](https://codecov.io/gh/mysticatea/vue-eslint-parser/branch/master/graph/badge.svg)](https://codecov.io/gh/mysticatea/vue-eslint-parser) -[![Dependency Status](https://david-dm.org/mysticatea/vue-eslint-parser.svg)](https://david-dm.org/mysticatea/vue-eslint-parser) +[![Build Status](https://github.com/vuejs/vue-eslint-parser/workflows/CI/badge.svg)](https://github.com/vuejs/vue-eslint-parser/actions) The ESLint custom parser for `.vue` files. @@ -15,89 +13,287 @@ This parser allows us to lint the ` + diff --git a/test/fixtures/ast/end-of-line01/token-ranges.json b/test/fixtures/ast/end-of-line01/token-ranges.json new file mode 100644 index 00000000..6b841cd8 --- /dev/null +++ b/test/fixtures/ast/end-of-line01/token-ranges.json @@ -0,0 +1,80 @@ +[ + "", + "", + "\n ", + "", + "", + "\n ", + "", + "", + "\n ", + "", + "", + "\n ", + "", + "", + "\n", + "", + "\n", + "", + "\n", + "var", + " ", + "a", + " ", + "=", + " ", + "foo", + "\n", + "", + "\n" +] \ No newline at end of file diff --git a/test/fixtures/ast/end-of-line01/tree.json b/test/fixtures/ast/end-of-line01/tree.json new file mode 100644 index 00000000..a68b9b28 --- /dev/null +++ b/test/fixtures/ast/end-of-line01/tree.json @@ -0,0 +1,311 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/ast/end-of-line02/ast.json b/test/fixtures/ast/end-of-line02/ast.json new file mode 100644 index 00000000..392ced18 --- /dev/null +++ b/test/fixtures/ast/end-of-line02/ast.json @@ -0,0 +1,2803 @@ +{ + "type": "Program", + "start": 9, + "end": 20, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "range": [ + 9, + 20 + ], + "body": [ + { + "type": "VariableDeclaration", + "start": 9, + "end": 20, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "range": [ + 9, + 20 + ], + "declarations": [ + { + "type": "VariableDeclarator", + "start": 13, + "end": 20, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "range": [ + 13, + 20 + ], + "id": { + "type": "Identifier", + "start": 13, + "end": 14, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 5 + } + }, + "range": [ + 13, + 14 + ], + "name": "a" + }, + "init": { + "type": "Identifier", + "start": 17, + "end": 20, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "range": [ + 17, + 20 + ], + "name": "foo" + } + } + ], + "kind": "var" + } + ], + "sourceType": "module", + "comments": [], + "tokens": [ + { + "type": "Punctuator", + "range": [ + 0, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "value": "" + } + ], + "templateBody": { + "type": "VElement", + "range": [ + 31, + 213 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 17, + "column": 11 + } + }, + "name": "template", + "rawName": "template", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 31, + 41 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 10 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 41, + 44 + ], + "loc": { + "start": { + "line": 4, + "column": 10 + }, + "end": { + "line": 5, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 44, + 75 + ], + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 7, + "column": 9 + } + }, + "name": "div", + "rawName": "div", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 44, + 69 + ], + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 7, + "column": 3 + } + }, + "selfClosing": false, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 53, + 65 + ], + "loc": { + "start": { + "line": 6, + "column": 4 + }, + "end": { + "line": 6, + "column": 16 + } + }, + "directive": true, + "key": { + "type": "VDirectiveKey", + "range": [ + 53, + 59 + ], + "loc": { + "start": { + "line": 6, + "column": 4 + }, + "end": { + "line": 6, + "column": 10 + } + }, + "name": { + "type": "VIdentifier", + "range": [ + 53, + 54 + ], + "loc": { + "start": { + "column": 4, + "line": 6 + }, + "end": { + "column": 5, + "line": 6 + } + }, + "name": "on", + "rawName": "@" + }, + "argument": { + "type": "VIdentifier", + "range": [ + 54, + 59 + ], + "loc": { + "start": { + "column": 5, + "line": 6 + }, + "end": { + "column": 10, + "line": 6 + } + }, + "name": "click", + "rawName": "click" + }, + "modifiers": [] + }, + "value": { + "type": "VExpressionContainer", + "range": [ + 60, + 65 + ], + "loc": { + "start": { + "line": 6, + "column": 11 + }, + "end": { + "line": 6, + "column": 16 + } + }, + "expression": { + "type": "VOnExpression", + "range": [ + 61, + 64 + ], + "loc": { + "start": { + "line": 6, + "column": 12 + }, + "end": { + "line": 6, + "column": 15 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 61, + "end": 64, + "loc": { + "start": { + "line": 6, + "column": 12 + }, + "end": { + "line": 6, + "column": 15 + } + }, + "range": [ + 61, + 64 + ], + "expression": { + "type": "AssignmentExpression", + "start": 61, + "end": 64, + "loc": { + "start": { + "line": 6, + "column": 12 + }, + "end": { + "line": 6, + "column": 15 + } + }, + "range": [ + 61, + 64 + ], + "operator": "=", + "left": { + "type": "Identifier", + "start": 61, + "end": 62, + "loc": { + "start": { + "line": 6, + "column": 12 + }, + "end": { + "line": 6, + "column": 13 + } + }, + "range": [ + 61, + 62 + ], + "name": "a" + }, + "right": { + "type": "Identifier", + "start": 63, + "end": 64, + "loc": { + "start": { + "line": 6, + "column": 14 + }, + "end": { + "line": 6, + "column": 15 + } + }, + "range": [ + 63, + 64 + ], + "name": "b" + } + } + } + ] + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 61, + "end": 62, + "loc": { + "start": { + "line": 6, + "column": 12 + }, + "end": { + "line": 6, + "column": 13 + } + }, + "range": [ + 61, + 62 + ], + "name": "a" + }, + "mode": "w" + }, + { + "id": { + "type": "Identifier", + "start": 63, + "end": 64, + "loc": { + "start": { + "line": 6, + "column": 14 + }, + "end": { + "line": 6, + "column": 15 + } + }, + "range": [ + 63, + 64 + ], + "name": "b" + }, + "mode": "r" + } + ] + } + } + ] + }, + "children": [], + "endTag": { + "type": "VEndTag", + "range": [ + 69, + 75 + ], + "loc": { + "start": { + "line": 7, + "column": 3 + }, + "end": { + "line": 7, + "column": 9 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 75, + 78 + ], + "loc": { + "start": { + "line": 7, + "column": 9 + }, + "end": { + "line": 8, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 78, + 121 + ], + "loc": { + "start": { + "line": 8, + "column": 2 + }, + "end": { + "line": 10, + "column": 9 + } + }, + "name": "div", + "rawName": "div", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 78, + 115 + ], + "loc": { + "start": { + "line": 8, + "column": 2 + }, + "end": { + "line": 10, + "column": 3 + } + }, + "selfClosing": false, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 87, + 111 + ], + "loc": { + "start": { + "line": 9, + "column": 4 + }, + "end": { + "line": 9, + "column": 28 + } + }, + "directive": true, + "key": { + "type": "VDirectiveKey", + "range": [ + 87, + 96 + ], + "loc": { + "start": { + "line": 9, + "column": 4 + }, + "end": { + "line": 9, + "column": 13 + } + }, + "name": { + "type": "VIdentifier", + "range": [ + 87, + 88 + ], + "loc": { + "start": { + "column": 4, + "line": 9 + }, + "end": { + "column": 5, + "line": 9 + } + }, + "name": "bind", + "rawName": ":" + }, + "argument": { + "type": "VIdentifier", + "range": [ + 88, + 96 + ], + "loc": { + "start": { + "column": 5, + "line": 9 + }, + "end": { + "column": 13, + "line": 9 + } + }, + "name": "data-foo", + "rawName": "data-foo" + }, + "modifiers": [] + }, + "value": { + "type": "VExpressionContainer", + "range": [ + 97, + 111 + ], + "loc": { + "start": { + "line": 9, + "column": 14 + }, + "end": { + "line": 9, + "column": 28 + } + }, + "expression": { + "type": "LogicalExpression", + "start": 98, + "end": 102, + "loc": { + "start": { + "line": 9, + "column": 15 + }, + "end": { + "line": 9, + "column": 27 + } + }, + "range": [ + 98, + 110 + ], + "left": { + "type": "Identifier", + "start": 98, + "end": 99, + "loc": { + "start": { + "line": 9, + "column": 15 + }, + "end": { + "line": 9, + "column": 16 + } + }, + "range": [ + 98, + 99 + ], + "name": "c" + }, + "operator": "&&", + "right": { + "type": "Identifier", + "start": 109, + "end": 110, + "loc": { + "start": { + "line": 9, + "column": 26 + }, + "end": { + "line": 9, + "column": 27 + } + }, + "range": [ + 109, + 110 + ], + "name": "d" + } + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 98, + "end": 99, + "loc": { + "start": { + "line": 9, + "column": 15 + }, + "end": { + "line": 9, + "column": 16 + } + }, + "range": [ + 98, + 99 + ], + "name": "c" + }, + "mode": "r" + }, + { + "id": { + "type": "Identifier", + "start": 109, + "end": 110, + "loc": { + "start": { + "line": 9, + "column": 26 + }, + "end": { + "line": 9, + "column": 27 + } + }, + "range": [ + 109, + 110 + ], + "name": "d" + }, + "mode": "r" + } + ] + } + } + ] + }, + "children": [], + "endTag": { + "type": "VEndTag", + "range": [ + 115, + 121 + ], + "loc": { + "start": { + "line": 10, + "column": 3 + }, + "end": { + "line": 10, + "column": 9 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 121, + 124 + ], + "loc": { + "start": { + "line": 10, + "column": 9 + }, + "end": { + "line": 11, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 124, + 160 + ], + "loc": { + "start": { + "line": 11, + "column": 2 + }, + "end": { + "line": 13, + "column": 9 + } + }, + "name": "div", + "rawName": "div", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 124, + 154 + ], + "loc": { + "start": { + "line": 11, + "column": 2 + }, + "end": { + "line": 13, + "column": 3 + } + }, + "selfClosing": false, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 133, + 150 + ], + "loc": { + "start": { + "line": 12, + "column": 4 + }, + "end": { + "line": 12, + "column": 21 + } + }, + "directive": true, + "key": { + "type": "VDirectiveKey", + "range": [ + 133, + 144 + ], + "loc": { + "start": { + "line": 12, + "column": 4 + }, + "end": { + "line": 12, + "column": 15 + } + }, + "name": { + "type": "VIdentifier", + "range": [ + 133, + 134 + ], + "loc": { + "start": { + "column": 4, + "line": 12 + }, + "end": { + "column": 5, + "line": 12 + } + }, + "name": "bind", + "rawName": ":" + }, + "argument": { + "type": "VIdentifier", + "range": [ + 134, + 144 + ], + "loc": { + "start": { + "column": 5, + "line": 12 + }, + "end": { + "column": 15, + "line": 12 + } + }, + "name": "data-click", + "rawName": "data-click" + }, + "modifiers": [] + }, + "value": { + "type": "VExpressionContainer", + "range": [ + 145, + 150 + ], + "loc": { + "start": { + "line": 12, + "column": 16 + }, + "end": { + "line": 12, + "column": 21 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 146, + "end": 149, + "loc": { + "start": { + "line": 12, + "column": 17 + }, + "end": { + "line": 12, + "column": 20 + } + }, + "range": [ + 146, + 149 + ], + "operator": "=", + "left": { + "type": "Identifier", + "start": 146, + "end": 147, + "loc": { + "start": { + "line": 12, + "column": 17 + }, + "end": { + "line": 12, + "column": 18 + } + }, + "range": [ + 146, + 147 + ], + "name": "a" + }, + "right": { + "type": "Identifier", + "start": 148, + "end": 149, + "loc": { + "start": { + "line": 12, + "column": 19 + }, + "end": { + "line": 12, + "column": 20 + } + }, + "range": [ + 148, + 149 + ], + "name": "b" + } + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 146, + "end": 147, + "loc": { + "start": { + "line": 12, + "column": 17 + }, + "end": { + "line": 12, + "column": 18 + } + }, + "range": [ + 146, + 147 + ], + "name": "a" + }, + "mode": "w" + }, + { + "id": { + "type": "Identifier", + "start": 148, + "end": 149, + "loc": { + "start": { + "line": 12, + "column": 19 + }, + "end": { + "line": 12, + "column": 20 + } + }, + "range": [ + 148, + 149 + ], + "name": "b" + }, + "mode": "r" + } + ] + } + } + ] + }, + "children": [], + "endTag": { + "type": "VEndTag", + "range": [ + 154, + 160 + ], + "loc": { + "start": { + "line": 13, + "column": 3 + }, + "end": { + "line": 13, + "column": 9 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 160, + 163 + ], + "loc": { + "start": { + "line": 13, + "column": 9 + }, + "end": { + "line": 14, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 163, + 201 + ], + "loc": { + "start": { + "line": 14, + "column": 2 + }, + "end": { + "line": 16, + "column": 9 + } + }, + "name": "div", + "rawName": "div", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 163, + 195 + ], + "loc": { + "start": { + "line": 14, + "column": 2 + }, + "end": { + "line": 16, + "column": 3 + } + }, + "selfClosing": false, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 172, + 191 + ], + "loc": { + "start": { + "line": 15, + "column": 4 + }, + "end": { + "line": 15, + "column": 23 + } + }, + "directive": true, + "key": { + "type": "VDirectiveKey", + "range": [ + 172, + 176 + ], + "loc": { + "start": { + "line": 15, + "column": 4 + }, + "end": { + "line": 15, + "column": 8 + } + }, + "name": { + "type": "VIdentifier", + "range": [ + 172, + 173 + ], + "loc": { + "start": { + "column": 4, + "line": 15 + }, + "end": { + "column": 5, + "line": 15 + } + }, + "name": "on", + "rawName": "@" + }, + "argument": { + "type": "VIdentifier", + "range": [ + 173, + 176 + ], + "loc": { + "start": { + "column": 5, + "line": 15 + }, + "end": { + "column": 8, + "line": 15 + } + }, + "name": "foo", + "rawName": "foo" + }, + "modifiers": [] + }, + "value": { + "type": "VExpressionContainer", + "range": [ + 177, + 191 + ], + "loc": { + "start": { + "line": 15, + "column": 9 + }, + "end": { + "line": 15, + "column": 23 + } + }, + "expression": { + "type": "VOnExpression", + "range": [ + 178, + 190 + ], + "loc": { + "start": { + "line": 15, + "column": 10 + }, + "end": { + "line": 15, + "column": 22 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 178, + "end": 182, + "loc": { + "start": { + "line": 15, + "column": 10 + }, + "end": { + "line": 15, + "column": 22 + } + }, + "range": [ + 178, + 190 + ], + "expression": { + "type": "LogicalExpression", + "start": 178, + "end": 182, + "loc": { + "start": { + "line": 15, + "column": 10 + }, + "end": { + "line": 15, + "column": 22 + } + }, + "range": [ + 178, + 190 + ], + "left": { + "type": "Identifier", + "start": 178, + "end": 179, + "loc": { + "start": { + "line": 15, + "column": 10 + }, + "end": { + "line": 15, + "column": 11 + } + }, + "range": [ + 178, + 179 + ], + "name": "c" + }, + "operator": "&&", + "right": { + "type": "Identifier", + "start": 189, + "end": 190, + "loc": { + "start": { + "line": 15, + "column": 21 + }, + "end": { + "line": 15, + "column": 22 + } + }, + "range": [ + 189, + 190 + ], + "name": "d" + } + } + } + ] + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 178, + "end": 179, + "loc": { + "start": { + "line": 15, + "column": 10 + }, + "end": { + "line": 15, + "column": 11 + } + }, + "range": [ + 178, + 179 + ], + "name": "c" + }, + "mode": "r" + }, + { + "id": { + "type": "Identifier", + "start": 189, + "end": 190, + "loc": { + "start": { + "line": 15, + "column": 21 + }, + "end": { + "line": 15, + "column": 22 + } + }, + "range": [ + 189, + 190 + ], + "name": "d" + }, + "mode": "r" + } + ] + } + } + ] + }, + "children": [], + "endTag": { + "type": "VEndTag", + "range": [ + 195, + 201 + ], + "loc": { + "start": { + "line": 16, + "column": 3 + }, + "end": { + "line": 16, + "column": 9 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 201, + 202 + ], + "loc": { + "start": { + "line": 16, + "column": 9 + }, + "end": { + "line": 17, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 202, + 213 + ], + "loc": { + "start": { + "line": 17, + "column": 0 + }, + "end": { + "line": 17, + "column": 11 + } + } + }, + "variables": [], + "tokens": [ + { + "type": "HTMLTagOpen", + "range": [ + 0, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 7, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 8, + 9 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 9, + 12 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 3 + } + }, + "value": "var" + }, + { + "type": "HTMLWhitespace", + "range": [ + 12, + 13 + ], + "loc": { + "start": { + "line": 2, + "column": 3 + }, + "end": { + "line": 2, + "column": 4 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 13, + 14 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 5 + } + }, + "value": "a" + }, + { + "type": "HTMLWhitespace", + "range": [ + 14, + 15 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 15, + 16 + ], + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 16, + 17 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 17, + 20 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "value": "foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 20, + 21 + ], + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 21, + 29 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 29, + 30 + ], + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 30, + 31 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 31, + 40 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 40, + 41 + ], + "loc": { + "start": { + "line": 4, + "column": 9 + }, + "end": { + "line": 4, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 41, + 44 + ], + "loc": { + "start": { + "line": 4, + "column": 10 + }, + "end": { + "line": 5, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 44, + 48 + ], + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 5, + "column": 6 + } + }, + "value": "div" + }, + { + "type": "Punctuator", + "range": [ + 53, + 54 + ], + "loc": { + "start": { + "column": 4, + "line": 6 + }, + "end": { + "column": 5, + "line": 6 + } + }, + "value": "@" + }, + { + "type": "HTMLIdentifier", + "range": [ + 54, + 59 + ], + "loc": { + "start": { + "column": 5, + "line": 6 + }, + "end": { + "column": 10, + "line": 6 + } + }, + "value": "click" + }, + { + "type": "HTMLAssociation", + "range": [ + 59, + 60 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 11 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 60, + 61 + ], + "loc": { + "start": { + "line": 6, + "column": 11 + }, + "end": { + "line": 6, + "column": 12 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "value": "a", + "start": 61, + "end": 62, + "loc": { + "start": { + "line": 6, + "column": 12 + }, + "end": { + "line": 6, + "column": 13 + } + }, + "range": [ + 61, + 62 + ] + }, + { + "type": "Punctuator", + "value": "=", + "start": 62, + "end": 63, + "loc": { + "start": { + "line": 6, + "column": 13 + }, + "end": { + "line": 6, + "column": 14 + } + }, + "range": [ + 62, + 63 + ] + }, + { + "type": "Identifier", + "value": "b", + "start": 63, + "end": 64, + "loc": { + "start": { + "line": 6, + "column": 14 + }, + "end": { + "line": 6, + "column": 15 + } + }, + "range": [ + 63, + 64 + ] + }, + { + "type": "Punctuator", + "range": [ + 64, + 65 + ], + "loc": { + "start": { + "line": 6, + "column": 15 + }, + "end": { + "line": 6, + "column": 16 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 68, + 69 + ], + "loc": { + "start": { + "line": 7, + "column": 2 + }, + "end": { + "line": 7, + "column": 3 + } + }, + "value": "" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 69, + 74 + ], + "loc": { + "start": { + "line": 7, + "column": 3 + }, + "end": { + "line": 7, + "column": 8 + } + }, + "value": "div" + }, + { + "type": "HTMLTagClose", + "range": [ + 74, + 75 + ], + "loc": { + "start": { + "line": 7, + "column": 8 + }, + "end": { + "line": 7, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 75, + 78 + ], + "loc": { + "start": { + "line": 7, + "column": 9 + }, + "end": { + "line": 8, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 78, + 82 + ], + "loc": { + "start": { + "line": 8, + "column": 2 + }, + "end": { + "line": 8, + "column": 6 + } + }, + "value": "div" + }, + { + "type": "Punctuator", + "range": [ + 87, + 88 + ], + "loc": { + "start": { + "column": 4, + "line": 9 + }, + "end": { + "column": 5, + "line": 9 + } + }, + "value": ":" + }, + { + "type": "HTMLIdentifier", + "range": [ + 88, + 96 + ], + "loc": { + "start": { + "column": 5, + "line": 9 + }, + "end": { + "column": 13, + "line": 9 + } + }, + "value": "data-foo" + }, + { + "type": "HTMLAssociation", + "range": [ + 96, + 97 + ], + "loc": { + "start": { + "line": 9, + "column": 13 + }, + "end": { + "line": 9, + "column": 14 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 97, + 98 + ], + "loc": { + "start": { + "line": 9, + "column": 14 + }, + "end": { + "line": 9, + "column": 15 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "value": "c", + "start": 98, + "end": 99, + "loc": { + "start": { + "line": 9, + "column": 15 + }, + "end": { + "line": 9, + "column": 16 + } + }, + "range": [ + 98, + 99 + ] + }, + { + "type": "Punctuator", + "value": "&&", + "start": 99, + "end": 101, + "loc": { + "start": { + "line": 9, + "column": 16 + }, + "end": { + "line": 9, + "column": 26 + } + }, + "range": [ + 99, + 109 + ] + }, + { + "type": "Identifier", + "value": "d", + "start": 109, + "end": 110, + "loc": { + "start": { + "line": 9, + "column": 26 + }, + "end": { + "line": 9, + "column": 27 + } + }, + "range": [ + 109, + 110 + ] + }, + { + "type": "Punctuator", + "range": [ + 110, + 111 + ], + "loc": { + "start": { + "line": 9, + "column": 27 + }, + "end": { + "line": 9, + "column": 28 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 114, + 115 + ], + "loc": { + "start": { + "line": 10, + "column": 2 + }, + "end": { + "line": 10, + "column": 3 + } + }, + "value": "" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 115, + 120 + ], + "loc": { + "start": { + "line": 10, + "column": 3 + }, + "end": { + "line": 10, + "column": 8 + } + }, + "value": "div" + }, + { + "type": "HTMLTagClose", + "range": [ + 120, + 121 + ], + "loc": { + "start": { + "line": 10, + "column": 8 + }, + "end": { + "line": 10, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 121, + 124 + ], + "loc": { + "start": { + "line": 10, + "column": 9 + }, + "end": { + "line": 11, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 124, + 128 + ], + "loc": { + "start": { + "line": 11, + "column": 2 + }, + "end": { + "line": 11, + "column": 6 + } + }, + "value": "div" + }, + { + "type": "Punctuator", + "range": [ + 133, + 134 + ], + "loc": { + "start": { + "column": 4, + "line": 12 + }, + "end": { + "column": 5, + "line": 12 + } + }, + "value": ":" + }, + { + "type": "HTMLIdentifier", + "range": [ + 134, + 144 + ], + "loc": { + "start": { + "column": 5, + "line": 12 + }, + "end": { + "column": 15, + "line": 12 + } + }, + "value": "data-click" + }, + { + "type": "HTMLAssociation", + "range": [ + 144, + 145 + ], + "loc": { + "start": { + "line": 12, + "column": 15 + }, + "end": { + "line": 12, + "column": 16 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 145, + 146 + ], + "loc": { + "start": { + "line": 12, + "column": 16 + }, + "end": { + "line": 12, + "column": 17 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "value": "a", + "start": 146, + "end": 147, + "loc": { + "start": { + "line": 12, + "column": 17 + }, + "end": { + "line": 12, + "column": 18 + } + }, + "range": [ + 146, + 147 + ] + }, + { + "type": "Punctuator", + "value": "=", + "start": 147, + "end": 148, + "loc": { + "start": { + "line": 12, + "column": 18 + }, + "end": { + "line": 12, + "column": 19 + } + }, + "range": [ + 147, + 148 + ] + }, + { + "type": "Identifier", + "value": "b", + "start": 148, + "end": 149, + "loc": { + "start": { + "line": 12, + "column": 19 + }, + "end": { + "line": 12, + "column": 20 + } + }, + "range": [ + 148, + 149 + ] + }, + { + "type": "Punctuator", + "range": [ + 149, + 150 + ], + "loc": { + "start": { + "line": 12, + "column": 20 + }, + "end": { + "line": 12, + "column": 21 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 153, + 154 + ], + "loc": { + "start": { + "line": 13, + "column": 2 + }, + "end": { + "line": 13, + "column": 3 + } + }, + "value": "" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 154, + 159 + ], + "loc": { + "start": { + "line": 13, + "column": 3 + }, + "end": { + "line": 13, + "column": 8 + } + }, + "value": "div" + }, + { + "type": "HTMLTagClose", + "range": [ + 159, + 160 + ], + "loc": { + "start": { + "line": 13, + "column": 8 + }, + "end": { + "line": 13, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 160, + 163 + ], + "loc": { + "start": { + "line": 13, + "column": 9 + }, + "end": { + "line": 14, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 163, + 167 + ], + "loc": { + "start": { + "line": 14, + "column": 2 + }, + "end": { + "line": 14, + "column": 6 + } + }, + "value": "div" + }, + { + "type": "Punctuator", + "range": [ + 172, + 173 + ], + "loc": { + "start": { + "column": 4, + "line": 15 + }, + "end": { + "column": 5, + "line": 15 + } + }, + "value": "@" + }, + { + "type": "HTMLIdentifier", + "range": [ + 173, + 176 + ], + "loc": { + "start": { + "column": 5, + "line": 15 + }, + "end": { + "column": 8, + "line": 15 + } + }, + "value": "foo" + }, + { + "type": "HTMLAssociation", + "range": [ + 176, + 177 + ], + "loc": { + "start": { + "line": 15, + "column": 8 + }, + "end": { + "line": 15, + "column": 9 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 177, + 178 + ], + "loc": { + "start": { + "line": 15, + "column": 9 + }, + "end": { + "line": 15, + "column": 10 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "value": "c", + "start": 178, + "end": 179, + "loc": { + "start": { + "line": 15, + "column": 10 + }, + "end": { + "line": 15, + "column": 11 + } + }, + "range": [ + 178, + 179 + ] + }, + { + "type": "Punctuator", + "value": "&&", + "start": 179, + "end": 181, + "loc": { + "start": { + "line": 15, + "column": 11 + }, + "end": { + "line": 15, + "column": 21 + } + }, + "range": [ + 179, + 189 + ] + }, + { + "type": "Identifier", + "value": "d", + "start": 189, + "end": 190, + "loc": { + "start": { + "line": 15, + "column": 21 + }, + "end": { + "line": 15, + "column": 22 + } + }, + "range": [ + 189, + 190 + ] + }, + { + "type": "Punctuator", + "range": [ + 190, + 191 + ], + "loc": { + "start": { + "line": 15, + "column": 22 + }, + "end": { + "line": 15, + "column": 23 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 194, + 195 + ], + "loc": { + "start": { + "line": 16, + "column": 2 + }, + "end": { + "line": 16, + "column": 3 + } + }, + "value": "" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 195, + 200 + ], + "loc": { + "start": { + "line": 16, + "column": 3 + }, + "end": { + "line": 16, + "column": 8 + } + }, + "value": "div" + }, + { + "type": "HTMLTagClose", + "range": [ + 200, + 201 + ], + "loc": { + "start": { + "line": 16, + "column": 8 + }, + "end": { + "line": 16, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 201, + 202 + ], + "loc": { + "start": { + "line": 16, + "column": 9 + }, + "end": { + "line": 17, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 202, + 212 + ], + "loc": { + "start": { + "line": 17, + "column": 0 + }, + "end": { + "line": 17, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 212, + 213 + ], + "loc": { + "start": { + "line": 17, + "column": 10 + }, + "end": { + "line": 17, + "column": 11 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 213, + 214 + ], + "loc": { + "start": { + "line": 17, + "column": 11 + }, + "end": { + "line": 18, + "column": 0 + } + }, + "value": "\n" + } + ], + "comments": [], + "errors": [] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/end-of-line02/requirements.json b/test/fixtures/ast/end-of-line02/requirements.json new file mode 100644 index 00000000..36659b1f --- /dev/null +++ b/test/fixtures/ast/end-of-line02/requirements.json @@ -0,0 +1,3 @@ +{ + "eslint": ">=8" +} \ No newline at end of file diff --git a/test/fixtures/ast/end-of-line02/source.vue b/test/fixtures/ast/end-of-line02/source.vue new file mode 100644 index 00000000..6c27e7dd --- /dev/null +++ b/test/fixtures/ast/end-of-line02/source.vue @@ -0,0 +1,17 @@ + + diff --git a/test/fixtures/ast/end-of-line02/token-ranges.json b/test/fixtures/ast/end-of-line02/token-ranges.json new file mode 100644 index 00000000..be779652 --- /dev/null +++ b/test/fixtures/ast/end-of-line02/token-ranges.json @@ -0,0 +1,80 @@ +[ + "", + "", + "\n", + "var", + " ", + "a", + " ", + "=", + " ", + "foo", + "\n", + "", + "\n", + "", + "\n ", + "", + "", + "\n ", + "", + "", + "\n ", + "", + "", + "\n ", + "", + "", + "\n", + "", + "\n" +] \ No newline at end of file diff --git a/test/fixtures/ast/end-of-line02/tree.json b/test/fixtures/ast/end-of-line02/tree.json new file mode 100644 index 00000000..d1a52306 --- /dev/null +++ b/test/fixtures/ast/end-of-line02/tree.json @@ -0,0 +1,311 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/ast/error-absence-of-digits-in-numeric-character-reference/ast.json b/test/fixtures/ast/error-absence-of-digits-in-numeric-character-reference/ast.json index e59ed2f9..e69c38ca 100644 --- a/test/fixtures/ast/error-absence-of-digits-in-numeric-character-reference/ast.json +++ b/test/fixtures/ast/error-absence-of-digits-in-numeric-character-reference/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-character-reference-outside-unicode-range/ast.json b/test/fixtures/ast/error-character-reference-outside-unicode-range/ast.json index 33c779c3..fa679dd1 100644 --- a/test/fixtures/ast/error-character-reference-outside-unicode-range/ast.json +++ b/test/fixtures/ast/error-character-reference-outside-unicode-range/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-control-character-reference/ast.json b/test/fixtures/ast/error-control-character-reference/ast.json index c6a2dba7..fdf8c650 100644 --- a/test/fixtures/ast/error-control-character-reference/ast.json +++ b/test/fixtures/ast/error-control-character-reference/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-duplicate-attribute/ast.json b/test/fixtures/ast/error-duplicate-attribute/ast.json index d82cfb06..a9c58684 100644 --- a/test/fixtures/ast/error-duplicate-attribute/ast.json +++ b/test/fixtures/ast/error-duplicate-attribute/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-end-tag-with-attributes/ast.json b/test/fixtures/ast/error-end-tag-with-attributes/ast.json index 696fe712..7322b7cc 100644 --- a/test/fixtures/ast/error-end-tag-with-attributes/ast.json +++ b/test/fixtures/ast/error-end-tag-with-attributes/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-end-tag-with-trailing-solidus/ast.json b/test/fixtures/ast/error-end-tag-with-trailing-solidus/ast.json index 3890be2a..4b466df3 100644 --- a/test/fixtures/ast/error-end-tag-with-trailing-solidus/ast.json +++ b/test/fixtures/ast/error-end-tag-with-trailing-solidus/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-eof-before-tag-name-2/ast.json b/test/fixtures/ast/error-eof-before-tag-name-2/ast.json index 9f8aee7f..15236497 100644 --- a/test/fixtures/ast/error-eof-before-tag-name-2/ast.json +++ b/test/fixtures/ast/error-eof-before-tag-name-2/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-eof-before-tag-name/ast.json b/test/fixtures/ast/error-eof-before-tag-name/ast.json index 06cccbc6..3a40017a 100644 --- a/test/fixtures/ast/error-eof-before-tag-name/ast.json +++ b/test/fixtures/ast/error-eof-before-tag-name/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-eof-in-cdata/ast.json b/test/fixtures/ast/error-eof-in-cdata/ast.json index de55171f..6ee92a11 100644 --- a/test/fixtures/ast/error-eof-in-cdata/ast.json +++ b/test/fixtures/ast/error-eof-in-cdata/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-eof-in-comment-2/ast.json b/test/fixtures/ast/error-eof-in-comment-2/ast.json index 75fabe21..f0b7158a 100644 --- a/test/fixtures/ast/error-eof-in-comment-2/ast.json +++ b/test/fixtures/ast/error-eof-in-comment-2/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-eof-in-comment-3/ast.json b/test/fixtures/ast/error-eof-in-comment-3/ast.json index 3b595b6e..546f7100 100644 --- a/test/fixtures/ast/error-eof-in-comment-3/ast.json +++ b/test/fixtures/ast/error-eof-in-comment-3/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-eof-in-comment-4/ast.json b/test/fixtures/ast/error-eof-in-comment-4/ast.json index 6087bd52..cb1d7145 100644 --- a/test/fixtures/ast/error-eof-in-comment-4/ast.json +++ b/test/fixtures/ast/error-eof-in-comment-4/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-eof-in-comment-5/ast.json b/test/fixtures/ast/error-eof-in-comment-5/ast.json index 80d7ae2c..cebbd6ec 100644 --- a/test/fixtures/ast/error-eof-in-comment-5/ast.json +++ b/test/fixtures/ast/error-eof-in-comment-5/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-eof-in-comment/ast.json b/test/fixtures/ast/error-eof-in-comment/ast.json index d9278c11..c45d5ebe 100644 --- a/test/fixtures/ast/error-eof-in-comment/ast.json +++ b/test/fixtures/ast/error-eof-in-comment/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-eof-in-tag-2/ast.json b/test/fixtures/ast/error-eof-in-tag-2/ast.json index a643133d..b59cdb7f 100644 --- a/test/fixtures/ast/error-eof-in-tag-2/ast.json +++ b/test/fixtures/ast/error-eof-in-tag-2/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-eof-in-tag-3/ast.json b/test/fixtures/ast/error-eof-in-tag-3/ast.json index e87d4b72..3008a1c8 100644 --- a/test/fixtures/ast/error-eof-in-tag-3/ast.json +++ b/test/fixtures/ast/error-eof-in-tag-3/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-eof-in-tag-4/ast.json b/test/fixtures/ast/error-eof-in-tag-4/ast.json index 2ceee212..189f335a 100644 --- a/test/fixtures/ast/error-eof-in-tag-4/ast.json +++ b/test/fixtures/ast/error-eof-in-tag-4/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-eof-in-tag-5/ast.json b/test/fixtures/ast/error-eof-in-tag-5/ast.json index 2ceee212..189f335a 100644 --- a/test/fixtures/ast/error-eof-in-tag-5/ast.json +++ b/test/fixtures/ast/error-eof-in-tag-5/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-eof-in-tag-6/ast.json b/test/fixtures/ast/error-eof-in-tag-6/ast.json index 96aa43e0..637a0766 100644 --- a/test/fixtures/ast/error-eof-in-tag-6/ast.json +++ b/test/fixtures/ast/error-eof-in-tag-6/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-eof-in-tag-7/ast.json b/test/fixtures/ast/error-eof-in-tag-7/ast.json index 95c443ad..ab4d4c67 100644 --- a/test/fixtures/ast/error-eof-in-tag-7/ast.json +++ b/test/fixtures/ast/error-eof-in-tag-7/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-eof-in-tag/ast.json b/test/fixtures/ast/error-eof-in-tag/ast.json index 1f060a42..52f0c380 100644 --- a/test/fixtures/ast/error-eof-in-tag/ast.json +++ b/test/fixtures/ast/error-eof-in-tag/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-invalid-first-character-of-tag-name/ast.json b/test/fixtures/ast/error-invalid-first-character-of-tag-name/ast.json index 853d8334..725d1e82 100644 --- a/test/fixtures/ast/error-invalid-first-character-of-tag-name/ast.json +++ b/test/fixtures/ast/error-invalid-first-character-of-tag-name/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-message-empty/ast.json b/test/fixtures/ast/error-message-empty/ast.json index 6f8a32e2..a2a913e5 100644 --- a/test/fixtures/ast/error-message-empty/ast.json +++ b/test/fixtures/ast/error-message-empty/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-message-outside/ast.json b/test/fixtures/ast/error-message-outside/ast.json index 4d4be9bf..5747314c 100644 --- a/test/fixtures/ast/error-message-outside/ast.json +++ b/test/fixtures/ast/error-message-outside/ast.json @@ -17,14 +17,14 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { "type": "VElement", "range": [ 0, - 132 + 138 ], "loc": { "start": { @@ -118,7 +118,7 @@ "type": "VElement", "range": [ 28, - 51 + 57 ], "loc": { "start": { @@ -127,7 +127,7 @@ }, "end": { "line": 3, - "column": 27 + "column": 33 } }, "name": "div", @@ -137,7 +137,7 @@ "type": "VStartTag", "range": [ 28, - 45 + 51 ], "loc": { "start": { @@ -146,7 +146,7 @@ }, "end": { "line": 3, - "column": 21 + "column": 27 } }, "selfClosing": false, @@ -155,7 +155,7 @@ "type": "VAttribute", "range": [ 33, - 44 + 50 ], "loc": { "start": { @@ -164,7 +164,7 @@ }, "end": { "line": 3, - "column": 20 + "column": 26 } }, "directive": true, @@ -210,7 +210,7 @@ "type": "VExpressionContainer", "range": [ 39, - 44 + 50 ], "loc": { "start": { @@ -219,7 +219,7 @@ }, "end": { "line": 3, - "column": 20 + "column": 26 } }, "expression": null, @@ -232,17 +232,17 @@ "endTag": { "type": "VEndTag", "range": [ - 45, - 51 + 51, + 57 ], "loc": { "start": { "line": 3, - "column": 21 + "column": 27 }, "end": { "line": 3, - "column": 27 + "column": 33 } } }, @@ -251,13 +251,13 @@ { "type": "VText", "range": [ - 51, - 56 + 57, + 62 ], "loc": { "start": { "line": 3, - "column": 27 + "column": 33 }, "end": { "line": 4, @@ -269,8 +269,8 @@ { "type": "VElement", "range": [ - 56, - 83 + 62, + 89 ], "loc": { "start": { @@ -288,8 +288,8 @@ "startTag": { "type": "VStartTag", "range": [ - 56, - 77 + 62, + 83 ], "loc": { "start": { @@ -306,8 +306,8 @@ { "type": "VAttribute", "range": [ - 61, - 76 + 67, + 82 ], "loc": { "start": { @@ -323,8 +323,8 @@ "key": { "type": "VDirectiveKey", "range": [ - 61, - 65 + 67, + 71 ], "loc": { "start": { @@ -339,8 +339,8 @@ "name": { "type": "VIdentifier", "range": [ - 61, - 62 + 67, + 68 ], "loc": { "start": { @@ -358,8 +358,8 @@ "argument": { "type": "VIdentifier", "range": [ - 62, - 65 + 68, + 71 ], "loc": { "start": { @@ -379,8 +379,8 @@ "value": { "type": "VExpressionContainer", "range": [ - 66, - 76 + 72, + 82 ], "loc": { "start": { @@ -402,8 +402,8 @@ "endTag": { "type": "VEndTag", "range": [ - 77, - 83 + 83, + 89 ], "loc": { "start": { @@ -421,8 +421,8 @@ { "type": "VText", "range": [ - 83, - 88 + 89, + 94 ], "loc": { "start": { @@ -439,8 +439,8 @@ { "type": "VElement", "range": [ - 88, - 120 + 94, + 126 ], "loc": { "start": { @@ -458,8 +458,8 @@ "startTag": { "type": "VStartTag", "range": [ - 88, - 114 + 94, + 120 ], "loc": { "start": { @@ -476,8 +476,8 @@ { "type": "VAttribute", "range": [ - 93, - 113 + 99, + 119 ], "loc": { "start": { @@ -493,8 +493,8 @@ "key": { "type": "VDirectiveKey", "range": [ - 93, - 99 + 99, + 105 ], "loc": { "start": { @@ -509,8 +509,8 @@ "name": { "type": "VIdentifier", "range": [ - 93, - 94 + 99, + 100 ], "loc": { "start": { @@ -528,8 +528,8 @@ "argument": { "type": "VIdentifier", "range": [ - 94, - 99 + 100, + 105 ], "loc": { "start": { @@ -549,8 +549,8 @@ "value": { "type": "VExpressionContainer", "range": [ - 100, - 113 + 106, + 119 ], "loc": { "start": { @@ -572,8 +572,8 @@ "endTag": { "type": "VEndTag", "range": [ - 114, - 120 + 120, + 126 ], "loc": { "start": { @@ -591,8 +591,8 @@ { "type": "VText", "range": [ - 120, - 121 + 126, + 127 ], "loc": { "start": { @@ -610,8 +610,8 @@ "endTag": { "type": "VEndTag", "range": [ - 121, - 132 + 127, + 138 ], "loc": { "start": { @@ -864,7 +864,7 @@ "type": "HTMLLiteral", "range": [ 39, - 44 + 50 ], "loc": { "start": { @@ -873,25 +873,25 @@ }, "end": { "line": 3, - "column": 20 + "column": 26 } }, - "value": "abc" + "value": "i in abc." }, { "type": "HTMLTagClose", "range": [ - 44, - 45 + 50, + 51 ], "loc": { "start": { "line": 3, - "column": 20 + "column": 26 }, "end": { "line": 3, - "column": 21 + "column": 27 } }, "value": "" @@ -899,17 +899,17 @@ { "type": "HTMLEndTagOpen", "range": [ - 45, - 50 + 51, + 56 ], "loc": { "start": { "line": 3, - "column": 21 + "column": 27 }, "end": { "line": 3, - "column": 26 + "column": 32 } }, "value": "div" @@ -917,17 +917,17 @@ { "type": "HTMLTagClose", "range": [ - 50, - 51 + 56, + 57 ], "loc": { "start": { "line": 3, - "column": 26 + "column": 32 }, "end": { "line": 3, - "column": 27 + "column": 33 } }, "value": "" @@ -935,13 +935,13 @@ { "type": "HTMLWhitespace", "range": [ - 51, - 56 + 57, + 62 ], "loc": { "start": { "line": 3, - "column": 27 + "column": 33 }, "end": { "line": 4, @@ -953,8 +953,8 @@ { "type": "HTMLTagOpen", "range": [ - 56, - 60 + 62, + 66 ], "loc": { "start": { @@ -971,8 +971,8 @@ { "type": "Punctuator", "range": [ - 61, - 62 + 67, + 68 ], "loc": { "start": { @@ -989,8 +989,8 @@ { "type": "HTMLIdentifier", "range": [ - 62, - 65 + 68, + 71 ], "loc": { "start": { @@ -1007,8 +1007,8 @@ { "type": "HTMLAssociation", "range": [ - 65, - 66 + 71, + 72 ], "loc": { "start": { @@ -1025,8 +1025,8 @@ { "type": "HTMLLiteral", "range": [ - 66, - 76 + 72, + 82 ], "loc": { "start": { @@ -1043,8 +1043,8 @@ { "type": "HTMLTagClose", "range": [ - 76, - 77 + 82, + 83 ], "loc": { "start": { @@ -1061,8 +1061,8 @@ { "type": "HTMLEndTagOpen", "range": [ - 77, - 82 + 83, + 88 ], "loc": { "start": { @@ -1079,8 +1079,8 @@ { "type": "HTMLTagClose", "range": [ - 82, - 83 + 88, + 89 ], "loc": { "start": { @@ -1097,8 +1097,8 @@ { "type": "HTMLWhitespace", "range": [ - 83, - 88 + 89, + 94 ], "loc": { "start": { @@ -1115,8 +1115,8 @@ { "type": "HTMLTagOpen", "range": [ - 88, - 92 + 94, + 98 ], "loc": { "start": { @@ -1133,8 +1133,8 @@ { "type": "Punctuator", "range": [ - 93, - 94 + 99, + 100 ], "loc": { "start": { @@ -1151,8 +1151,8 @@ { "type": "HTMLIdentifier", "range": [ - 94, - 99 + 100, + 105 ], "loc": { "start": { @@ -1169,8 +1169,8 @@ { "type": "HTMLAssociation", "range": [ - 99, - 100 + 105, + 106 ], "loc": { "start": { @@ -1187,8 +1187,8 @@ { "type": "HTMLLiteral", "range": [ - 100, - 113 + 106, + 119 ], "loc": { "start": { @@ -1205,8 +1205,8 @@ { "type": "HTMLTagClose", "range": [ - 113, - 114 + 119, + 120 ], "loc": { "start": { @@ -1223,8 +1223,8 @@ { "type": "HTMLEndTagOpen", "range": [ - 114, - 119 + 120, + 125 ], "loc": { "start": { @@ -1241,8 +1241,8 @@ { "type": "HTMLTagClose", "range": [ - 119, - 120 + 125, + 126 ], "loc": { "start": { @@ -1259,8 +1259,8 @@ { "type": "HTMLWhitespace", "range": [ - 120, - 121 + 126, + 127 ], "loc": { "start": { @@ -1277,8 +1277,8 @@ { "type": "HTMLEndTagOpen", "range": [ - 121, - 131 + 127, + 137 ], "loc": { "start": { @@ -1295,8 +1295,8 @@ { "type": "HTMLTagClose", "range": [ - 131, - 132 + 137, + 138 ], "loc": { "start": { @@ -1313,8 +1313,8 @@ { "type": "HTMLWhitespace", "range": [ - 132, - 133 + 138, + 139 ], "loc": { "start": { @@ -1339,19 +1339,19 @@ }, { "message": "Unexpected end of expression.", - "index": 43, + "index": 49, "lineNumber": 3, - "column": 19 + "column": 25 }, { "message": "Unexpected end of expression.", - "index": 76, + "index": 82, "lineNumber": 4, "column": 24 }, { "message": "Unexpected end of expression.", - "index": 112, + "index": 118, "lineNumber": 5, "column": 28 } diff --git a/test/fixtures/ast/error-message-outside/source.vue b/test/fixtures/ast/error-message-outside/source.vue index d7ced3de..9154164c 100644 --- a/test/fixtures/ast/error-message-outside/source.vue +++ b/test/fixtures/ast/error-message-outside/source.vue @@ -1,6 +1,6 @@ diff --git a/test/fixtures/ast/error-message-outside/token-ranges.json b/test/fixtures/ast/error-message-outside/token-ranges.json index b166ebd1..b7754866 100644 --- a/test/fixtures/ast/error-message-outside/token-ranges.json +++ b/test/fixtures/ast/error-message-outside/token-ranges.json @@ -12,7 +12,7 @@ "", "", diff --git a/test/fixtures/ast/error-message-outside/tree.json b/test/fixtures/ast/error-message-outside/tree.json index 5107ead3..248eea33 100644 --- a/test/fixtures/ast/error-message-outside/tree.json +++ b/test/fixtures/ast/error-message-outside/tree.json @@ -1,7 +1,7 @@ [ { "type": "VElement", - "text": "", + "text": "", "children": [ { "type": "VStartTag", @@ -25,15 +25,15 @@ }, { "type": "VElement", - "text": "
", + "text": "
", "children": [ { "type": "VStartTag", - "text": "
", + "text": "
", "children": [ { "type": "VAttribute", - "text": "v-for=\"abc\"", + "text": "v-for=\"i in abc.\"", "children": [ { "type": "VDirectiveKey", @@ -48,7 +48,7 @@ }, { "type": "VExpressionContainer", - "text": "\"abc\"", + "text": "\"i in abc.\"", "children": [] } ] diff --git a/test/fixtures/ast/error-missing-end-tag-name/ast.json b/test/fixtures/ast/error-missing-end-tag-name/ast.json index 012ad6a7..1eebe291 100644 --- a/test/fixtures/ast/error-missing-end-tag-name/ast.json +++ b/test/fixtures/ast/error-missing-end-tag-name/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-missing-semicolon-after-character-reference/ast.json b/test/fixtures/ast/error-missing-semicolon-after-character-reference/ast.json index bb29108e..8e8d338c 100644 --- a/test/fixtures/ast/error-missing-semicolon-after-character-reference/ast.json +++ b/test/fixtures/ast/error-missing-semicolon-after-character-reference/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-missing-whitespace-between-attributes/ast.json b/test/fixtures/ast/error-missing-whitespace-between-attributes/ast.json index 5b9f11b7..94602436 100644 --- a/test/fixtures/ast/error-missing-whitespace-between-attributes/ast.json +++ b/test/fixtures/ast/error-missing-whitespace-between-attributes/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-noncharacter-character-reference/ast.json b/test/fixtures/ast/error-noncharacter-character-reference/ast.json index 6b57ead0..48a89100 100644 --- a/test/fixtures/ast/error-noncharacter-character-reference/ast.json +++ b/test/fixtures/ast/error-noncharacter-character-reference/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-null-character-reference/ast.json b/test/fixtures/ast/error-null-character-reference/ast.json index ad092a2a..dedb8c73 100644 --- a/test/fixtures/ast/error-null-character-reference/ast.json +++ b/test/fixtures/ast/error-null-character-reference/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-surrogate-character-reference/ast.json b/test/fixtures/ast/error-surrogate-character-reference/ast.json index be1ba501..8e3bb162 100644 --- a/test/fixtures/ast/error-surrogate-character-reference/ast.json +++ b/test/fixtures/ast/error-surrogate-character-reference/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-unexpected-character-in-attribute-name/ast.json b/test/fixtures/ast/error-unexpected-character-in-attribute-name/ast.json index d9917c99..f74d916f 100644 --- a/test/fixtures/ast/error-unexpected-character-in-attribute-name/ast.json +++ b/test/fixtures/ast/error-unexpected-character-in-attribute-name/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-unexpected-character-in-unquoted-attribute-value/ast.json b/test/fixtures/ast/error-unexpected-character-in-unquoted-attribute-value/ast.json index 05610ed2..c96f41f1 100644 --- a/test/fixtures/ast/error-unexpected-character-in-unquoted-attribute-value/ast.json +++ b/test/fixtures/ast/error-unexpected-character-in-unquoted-attribute-value/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-unexpected-equals-sign-before-attribute-name/ast.json b/test/fixtures/ast/error-unexpected-equals-sign-before-attribute-name/ast.json index fac2297c..7cdf016e 100644 --- a/test/fixtures/ast/error-unexpected-equals-sign-before-attribute-name/ast.json +++ b/test/fixtures/ast/error-unexpected-equals-sign-before-attribute-name/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-unexpected-solidus-in-tag/ast.json b/test/fixtures/ast/error-unexpected-solidus-in-tag/ast.json index 1f336ace..22d04c52 100644 --- a/test/fixtures/ast/error-unexpected-solidus-in-tag/ast.json +++ b/test/fixtures/ast/error-unexpected-solidus-in-tag/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-unknown-named-character-reference/ast.json b/test/fixtures/ast/error-unknown-named-character-reference/ast.json index 3b6d9bbf..7ca7ecf6 100644 --- a/test/fixtures/ast/error-unknown-named-character-reference/ast.json +++ b/test/fixtures/ast/error-unknown-named-character-reference/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-v-on-function-expression/ast.json b/test/fixtures/ast/error-v-on-function-expression/ast.json index 0e6de9bd..4b5630aa 100644 --- a/test/fixtures/ast/error-v-on-function-expression/ast.json +++ b/test/fixtures/ast/error-v-on-function-expression/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-x-invalid-end-tag/ast.json b/test/fixtures/ast/error-x-invalid-end-tag/ast.json index 47e735a7..72d49ae8 100644 --- a/test/fixtures/ast/error-x-invalid-end-tag/ast.json +++ b/test/fixtures/ast/error-x-invalid-end-tag/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-x-invalid-namespace/ast.json b/test/fixtures/ast/error-x-invalid-namespace/ast.json index 76d2fd79..876d2520 100644 --- a/test/fixtures/ast/error-x-invalid-namespace/ast.json +++ b/test/fixtures/ast/error-x-invalid-namespace/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/expression-container-only/ast.json b/test/fixtures/ast/expression-container-only/ast.json index 104fd11f..cb659414 100644 --- a/test/fixtures/ast/expression-container-only/ast.json +++ b/test/fixtures/ast/expression-container-only/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/filter-empty/ast.json b/test/fixtures/ast/filter-empty/ast.json index e476fbbb..b7299032 100644 --- a/test/fixtures/ast/filter-empty/ast.json +++ b/test/fixtures/ast/filter-empty/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/filters-2/ast.json b/test/fixtures/ast/filters-2/ast.json index e1a0926b..7de005d1 100644 --- a/test/fixtures/ast/filters-2/ast.json +++ b/test/fixtures/ast/filters-2/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/filters-3/ast.json b/test/fixtures/ast/filters-3/ast.json index 59d0eeaa..24c0fd0d 100644 --- a/test/fixtures/ast/filters-3/ast.json +++ b/test/fixtures/ast/filters-3/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/filters-4/ast.json b/test/fixtures/ast/filters-4/ast.json index 7ed79a2e..4001e0ad 100644 --- a/test/fixtures/ast/filters-4/ast.json +++ b/test/fixtures/ast/filters-4/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/filters-error-2/ast.json b/test/fixtures/ast/filters-error-2/ast.json index 62069a7f..da887d04 100644 --- a/test/fixtures/ast/filters-error-2/ast.json +++ b/test/fixtures/ast/filters-error-2/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/filters-error/ast.json b/test/fixtures/ast/filters-error/ast.json index 83e1718d..a908741d 100644 --- a/test/fixtures/ast/filters-error/ast.json +++ b/test/fixtures/ast/filters-error/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/filters-opt-filter-off-babel/ast.json b/test/fixtures/ast/filters-opt-filter-off-babel/ast.json new file mode 100644 index 00000000..5798c090 --- /dev/null +++ b/test/fixtures/ast/filters-opt-filter-off-babel/ast.json @@ -0,0 +1,600 @@ +{ + "type": "Program", + "start": 0, + "end": 0, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 0 + } + }, + "range": [ + 0, + 0 + ], + "comments": [], + "tokens": [], + "sourceType": "module", + "body": [], + "templateBody": { + "type": "VElement", + "range": [ + 0, + 54 + ], + "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, + 15 + ], + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 2, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 15, + 42 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 31 + } + }, + "name": "div", + "rawName": "div", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 15, + 20 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VExpressionContainer", + "range": [ + 20, + 36 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "expression": { + "type": "BinaryExpression", + "start": 23, + "end": 33, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "range": [ + 23, + 33 + ], + "left": { + "type": "Identifier", + "start": 23, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "range": [ + 23, + 26 + ], + "name": "foo" + }, + "operator": "|>", + "right": { + "type": "Identifier", + "start": 30, + "end": 33, + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "range": [ + 30, + 33 + ], + "name": "bar" + } + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 23, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "range": [ + 23, + 26 + ], + "name": "foo" + }, + "mode": "r" + }, + { + "id": { + "type": "Identifier", + "start": 30, + "end": 33, + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "range": [ + 30, + 33 + ], + "name": "bar" + }, + "mode": "r" + } + ] + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 36, + 42 + ], + "loc": { + "start": { + "line": 2, + "column": 25 + }, + "end": { + "line": 2, + "column": 31 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 42, + 43 + ], + "loc": { + "start": { + "line": 2, + "column": 31 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 43, + 54 + ], + "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, + 15 + ], + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 2, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 15, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "value": "div" + }, + { + "type": "HTMLTagClose", + "range": [ + 19, + 20 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "value": "" + }, + { + "type": "VExpressionStart", + "range": [ + 20, + 22 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "value": "foo", + "start": 23, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "range": [ + 23, + 26 + ] + }, + { + "type": "Punctuator", + "value": "|>", + "start": 27, + "end": 29, + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "range": [ + 27, + 29 + ] + }, + { + "type": "Identifier", + "value": "bar", + "start": 30, + "end": 33, + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "range": [ + 30, + 33 + ] + }, + { + "type": "VExpressionEnd", + "range": [ + 34, + 36 + ], + "loc": { + "start": { + "line": 2, + "column": 23 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "value": "}}" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 36, + 41 + ], + "loc": { + "start": { + "line": 2, + "column": 25 + }, + "end": { + "line": 2, + "column": 30 + } + }, + "value": "div" + }, + { + "type": "HTMLTagClose", + "range": [ + 41, + 42 + ], + "loc": { + "start": { + "line": 2, + "column": 30 + }, + "end": { + "line": 2, + "column": 31 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 42, + 43 + ], + "loc": { + "start": { + "line": 2, + "column": 31 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 43, + 53 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 53, + 54 + ], + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 54, + 55 + ], + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "value": "\n" + } + ], + "comments": [], + "errors": [] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/filters-opt-filter-off-babel/parser-options.json b/test/fixtures/ast/filters-opt-filter-off-babel/parser-options.json new file mode 100644 index 00000000..959a61c7 --- /dev/null +++ b/test/fixtures/ast/filters-opt-filter-off-babel/parser-options.json @@ -0,0 +1,14 @@ +{ + "parser": "@babel/eslint-parser", + "requireConfigFile": false, + "babelOptions": { + "plugins": [ + [ + "@babel/plugin-syntax-pipeline-operator", { "proposal": "minimal" } + ] + ] + }, + "vueFeatures": { + "filter": false + } +} diff --git a/test/fixtures/ast/filters-opt-filter-off-babel/requirements.json b/test/fixtures/ast/filters-opt-filter-off-babel/requirements.json new file mode 100644 index 00000000..599c1280 --- /dev/null +++ b/test/fixtures/ast/filters-opt-filter-off-babel/requirements.json @@ -0,0 +1,3 @@ +{ + "node": ">=12" +} \ No newline at end of file diff --git a/test/fixtures/ast/filters-opt-filter-off-babel/source.vue b/test/fixtures/ast/filters-opt-filter-off-babel/source.vue new file mode 100644 index 00000000..868e8859 --- /dev/null +++ b/test/fixtures/ast/filters-opt-filter-off-babel/source.vue @@ -0,0 +1,3 @@ + diff --git a/test/fixtures/ast/filters-opt-filter-off-babel/token-ranges.json b/test/fixtures/ast/filters-opt-filter-off-babel/token-ranges.json new file mode 100644 index 00000000..68f472a1 --- /dev/null +++ b/test/fixtures/ast/filters-opt-filter-off-babel/token-ranges.json @@ -0,0 +1,18 @@ +[ + "", + "\n ", + "", + "{{", + "foo", + "|>", + "bar", + "}}", + "", + "\n", + "", + "\n" +] \ No newline at end of file diff --git a/test/fixtures/ast/filters-opt-filter-off-babel/tree.json b/test/fixtures/ast/filters-opt-filter-off-babel/tree.json new file mode 100644 index 00000000..7db3a314 --- /dev/null +++ b/test/fixtures/ast/filters-opt-filter-off-babel/tree.json @@ -0,0 +1,66 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/ast/filters-opt-filter-off/ast.json b/test/fixtures/ast/filters-opt-filter-off/ast.json new file mode 100644 index 00000000..5f4f64a3 --- /dev/null +++ b/test/fixtures/ast/filters-opt-filter-off/ast.json @@ -0,0 +1,1874 @@ +{ + "type": "Program", + "start": 0, + "end": 0, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 0 + } + }, + "range": [ + 0, + 0 + ], + "body": [], + "sourceType": "module", + "comments": [], + "tokens": [], + "templateBody": { + "type": "VElement", + "range": [ + 0, + 157 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 6, + "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, + 15 + ], + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 2, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 15, + 45 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 34 + } + }, + "name": "div", + "rawName": "div", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 15, + 20 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VExpressionContainer", + "range": [ + 20, + 39 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 28 + } + }, + "expression": { + "type": "BinaryExpression", + "start": 23, + "end": 36, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "range": [ + 23, + 36 + ], + "left": { + "type": "Identifier", + "start": 23, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "range": [ + 23, + 26 + ], + "name": "foo" + }, + "operator": "|", + "right": { + "type": "BinaryExpression", + "start": 29, + "end": 36, + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "range": [ + 29, + 36 + ], + "left": { + "type": "Identifier", + "start": 29, + "end": 32, + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "range": [ + 29, + 32 + ], + "name": "bar" + }, + "operator": "-", + "right": { + "type": "Identifier", + "start": 33, + "end": 36, + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "range": [ + 33, + 36 + ], + "name": "baz" + } + } + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 23, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "range": [ + 23, + 26 + ], + "name": "foo" + }, + "mode": "r" + }, + { + "id": { + "type": "Identifier", + "start": 29, + "end": 32, + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "range": [ + 29, + 32 + ], + "name": "bar" + }, + "mode": "r" + }, + { + "id": { + "type": "Identifier", + "start": 33, + "end": 36, + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "range": [ + 33, + 36 + ], + "name": "baz" + }, + "mode": "r" + } + ] + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 39, + 45 + ], + "loc": { + "start": { + "line": 2, + "column": 28 + }, + "end": { + "line": 2, + "column": 34 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 45, + 50 + ], + "loc": { + "start": { + "line": 2, + "column": 34 + }, + "end": { + "line": 3, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 50, + 78 + ], + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 32 + } + }, + "name": "div", + "rawName": "div", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 50, + 55 + ], + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VExpressionContainer", + "range": [ + 55, + 72 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 3, + "column": 26 + } + }, + "expression": { + "type": "BinaryExpression", + "start": 58, + "end": 69, + "loc": { + "start": { + "line": 3, + "column": 12 + }, + "end": { + "line": 3, + "column": 23 + } + }, + "range": [ + 58, + 69 + ], + "left": { + "type": "Identifier", + "start": 58, + "end": 61, + "loc": { + "start": { + "line": 3, + "column": 12 + }, + "end": { + "line": 3, + "column": 15 + } + }, + "range": [ + 58, + 61 + ], + "name": "foo" + }, + "operator": "|", + "right": { + "type": "Identifier", + "start": 65, + "end": 68, + "loc": { + "start": { + "line": 3, + "column": 19 + }, + "end": { + "line": 3, + "column": 22 + } + }, + "range": [ + 65, + 68 + ], + "name": "bar" + } + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 58, + "end": 61, + "loc": { + "start": { + "line": 3, + "column": 12 + }, + "end": { + "line": 3, + "column": 15 + } + }, + "range": [ + 58, + 61 + ], + "name": "foo" + }, + "mode": "r" + }, + { + "id": { + "type": "Identifier", + "start": 65, + "end": 68, + "loc": { + "start": { + "line": 3, + "column": 19 + }, + "end": { + "line": 3, + "column": 22 + } + }, + "range": [ + 65, + 68 + ], + "name": "bar" + }, + "mode": "r" + } + ] + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 72, + 78 + ], + "loc": { + "start": { + "line": 3, + "column": 26 + }, + "end": { + "line": 3, + "column": 32 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 78, + 83 + ], + "loc": { + "start": { + "line": 3, + "column": 32 + }, + "end": { + "line": 4, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 83, + 110 + ], + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 31 + } + }, + "name": "div", + "rawName": "div", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 83, + 88 + ], + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 9 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VExpressionContainer", + "range": [ + 88, + 104 + ], + "loc": { + "start": { + "line": 4, + "column": 9 + }, + "end": { + "line": 4, + "column": 25 + } + }, + "expression": { + "type": "LogicalExpression", + "start": 91, + "end": 101, + "loc": { + "start": { + "line": 4, + "column": 12 + }, + "end": { + "line": 4, + "column": 22 + } + }, + "range": [ + 91, + 101 + ], + "left": { + "type": "Identifier", + "start": 91, + "end": 94, + "loc": { + "start": { + "line": 4, + "column": 12 + }, + "end": { + "line": 4, + "column": 15 + } + }, + "range": [ + 91, + 94 + ], + "name": "foo" + }, + "operator": "||", + "right": { + "type": "Identifier", + "start": 98, + "end": 101, + "loc": { + "start": { + "line": 4, + "column": 19 + }, + "end": { + "line": 4, + "column": 22 + } + }, + "range": [ + 98, + 101 + ], + "name": "bar" + } + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 91, + "end": 94, + "loc": { + "start": { + "line": 4, + "column": 12 + }, + "end": { + "line": 4, + "column": 15 + } + }, + "range": [ + 91, + 94 + ], + "name": "foo" + }, + "mode": "r" + }, + { + "id": { + "type": "Identifier", + "start": 98, + "end": 101, + "loc": { + "start": { + "line": 4, + "column": 19 + }, + "end": { + "line": 4, + "column": 22 + } + }, + "range": [ + 98, + 101 + ], + "name": "bar" + }, + "mode": "r" + } + ] + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 104, + 110 + ], + "loc": { + "start": { + "line": 4, + "column": 25 + }, + "end": { + "line": 4, + "column": 31 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 110, + 115 + ], + "loc": { + "start": { + "line": 4, + "column": 31 + }, + "end": { + "line": 5, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 115, + 145 + ], + "loc": { + "start": { + "line": 5, + "column": 4 + }, + "end": { + "line": 5, + "column": 34 + } + }, + "name": "div", + "rawName": "div", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 115, + 120 + ], + "loc": { + "start": { + "line": 5, + "column": 4 + }, + "end": { + "line": 5, + "column": 9 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VExpressionContainer", + "range": [ + 120, + 139 + ], + "loc": { + "start": { + "line": 5, + "column": 9 + }, + "end": { + "line": 5, + "column": 28 + } + }, + "expression": null, + "references": [] + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 139, + 145 + ], + "loc": { + "start": { + "line": 5, + "column": 28 + }, + "end": { + "line": 5, + "column": 34 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 145, + 146 + ], + "loc": { + "start": { + "line": 5, + "column": 34 + }, + "end": { + "line": 6, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 146, + 157 + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "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, + 15 + ], + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 2, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 15, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "value": "div" + }, + { + "type": "HTMLTagClose", + "range": [ + 19, + 20 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "value": "" + }, + { + "type": "VExpressionStart", + "range": [ + 20, + 22 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "value": "foo", + "start": 23, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "range": [ + 23, + 26 + ] + }, + { + "type": "Punctuator", + "value": "|", + "start": 27, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "range": [ + 27, + 28 + ] + }, + { + "type": "Identifier", + "value": "bar", + "start": 29, + "end": 32, + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "range": [ + 29, + 32 + ] + }, + { + "type": "Punctuator", + "value": "-", + "start": 32, + "end": 33, + "loc": { + "start": { + "line": 2, + "column": 21 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "range": [ + 32, + 33 + ] + }, + { + "type": "Identifier", + "value": "baz", + "start": 33, + "end": 36, + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "range": [ + 33, + 36 + ] + }, + { + "type": "VExpressionEnd", + "range": [ + 37, + 39 + ], + "loc": { + "start": { + "line": 2, + "column": 26 + }, + "end": { + "line": 2, + "column": 28 + } + }, + "value": "}}" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 39, + 44 + ], + "loc": { + "start": { + "line": 2, + "column": 28 + }, + "end": { + "line": 2, + "column": 33 + } + }, + "value": "div" + }, + { + "type": "HTMLTagClose", + "range": [ + 44, + 45 + ], + "loc": { + "start": { + "line": 2, + "column": 33 + }, + "end": { + "line": 2, + "column": 34 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 45, + 50 + ], + "loc": { + "start": { + "line": 2, + "column": 34 + }, + "end": { + "line": 3, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 50, + 54 + ], + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "value": "div" + }, + { + "type": "HTMLTagClose", + "range": [ + 54, + 55 + ], + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "value": "" + }, + { + "type": "VExpressionStart", + "range": [ + 55, + 57 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "value": "foo", + "start": 58, + "end": 61, + "loc": { + "start": { + "line": 3, + "column": 12 + }, + "end": { + "line": 3, + "column": 15 + } + }, + "range": [ + 58, + 61 + ] + }, + { + "type": "Punctuator", + "value": "|", + "start": 62, + "end": 63, + "loc": { + "start": { + "line": 3, + "column": 16 + }, + "end": { + "line": 3, + "column": 17 + } + }, + "range": [ + 62, + 63 + ] + }, + { + "type": "Punctuator", + "value": "(", + "start": 64, + "end": 65, + "loc": { + "start": { + "line": 3, + "column": 18 + }, + "end": { + "line": 3, + "column": 19 + } + }, + "range": [ + 64, + 65 + ] + }, + { + "type": "Identifier", + "value": "bar", + "start": 65, + "end": 68, + "loc": { + "start": { + "line": 3, + "column": 19 + }, + "end": { + "line": 3, + "column": 22 + } + }, + "range": [ + 65, + 68 + ] + }, + { + "type": "Punctuator", + "value": ")", + "start": 68, + "end": 69, + "loc": { + "start": { + "line": 3, + "column": 22 + }, + "end": { + "line": 3, + "column": 23 + } + }, + "range": [ + 68, + 69 + ] + }, + { + "type": "VExpressionEnd", + "range": [ + 70, + 72 + ], + "loc": { + "start": { + "line": 3, + "column": 24 + }, + "end": { + "line": 3, + "column": 26 + } + }, + "value": "}}" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 72, + 77 + ], + "loc": { + "start": { + "line": 3, + "column": 26 + }, + "end": { + "line": 3, + "column": 31 + } + }, + "value": "div" + }, + { + "type": "HTMLTagClose", + "range": [ + 77, + 78 + ], + "loc": { + "start": { + "line": 3, + "column": 31 + }, + "end": { + "line": 3, + "column": 32 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 78, + 83 + ], + "loc": { + "start": { + "line": 3, + "column": 32 + }, + "end": { + "line": 4, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 83, + 87 + ], + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 8 + } + }, + "value": "div" + }, + { + "type": "HTMLTagClose", + "range": [ + 87, + 88 + ], + "loc": { + "start": { + "line": 4, + "column": 8 + }, + "end": { + "line": 4, + "column": 9 + } + }, + "value": "" + }, + { + "type": "VExpressionStart", + "range": [ + 88, + 90 + ], + "loc": { + "start": { + "line": 4, + "column": 9 + }, + "end": { + "line": 4, + "column": 11 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "value": "foo", + "start": 91, + "end": 94, + "loc": { + "start": { + "line": 4, + "column": 12 + }, + "end": { + "line": 4, + "column": 15 + } + }, + "range": [ + 91, + 94 + ] + }, + { + "type": "Punctuator", + "value": "||", + "start": 95, + "end": 97, + "loc": { + "start": { + "line": 4, + "column": 16 + }, + "end": { + "line": 4, + "column": 18 + } + }, + "range": [ + 95, + 97 + ] + }, + { + "type": "Identifier", + "value": "bar", + "start": 98, + "end": 101, + "loc": { + "start": { + "line": 4, + "column": 19 + }, + "end": { + "line": 4, + "column": 22 + } + }, + "range": [ + 98, + 101 + ] + }, + { + "type": "VExpressionEnd", + "range": [ + 102, + 104 + ], + "loc": { + "start": { + "line": 4, + "column": 23 + }, + "end": { + "line": 4, + "column": 25 + } + }, + "value": "}}" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 104, + 109 + ], + "loc": { + "start": { + "line": 4, + "column": 25 + }, + "end": { + "line": 4, + "column": 30 + } + }, + "value": "div" + }, + { + "type": "HTMLTagClose", + "range": [ + 109, + 110 + ], + "loc": { + "start": { + "line": 4, + "column": 30 + }, + "end": { + "line": 4, + "column": 31 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 110, + 115 + ], + "loc": { + "start": { + "line": 4, + "column": 31 + }, + "end": { + "line": 5, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 115, + 119 + ], + "loc": { + "start": { + "line": 5, + "column": 4 + }, + "end": { + "line": 5, + "column": 8 + } + }, + "value": "div" + }, + { + "type": "HTMLTagClose", + "range": [ + 119, + 120 + ], + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 9 + } + }, + "value": "" + }, + { + "type": "VExpressionStart", + "range": [ + 120, + 122 + ], + "loc": { + "start": { + "line": 5, + "column": 9 + }, + "end": { + "line": 5, + "column": 11 + } + }, + "value": "{{" + }, + { + "type": "HTMLWhitespace", + "range": [ + 122, + 123 + ], + "loc": { + "start": { + "line": 5, + "column": 11 + }, + "end": { + "line": 5, + "column": 12 + } + }, + "value": " " + }, + { + "type": "HTMLText", + "range": [ + 123, + 126 + ], + "loc": { + "start": { + "line": 5, + "column": 12 + }, + "end": { + "line": 5, + "column": 15 + } + }, + "value": "foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 126, + 127 + ], + "loc": { + "start": { + "line": 5, + "column": 15 + }, + "end": { + "line": 5, + "column": 16 + } + }, + "value": " " + }, + { + "type": "HTMLText", + "range": [ + 127, + 128 + ], + "loc": { + "start": { + "line": 5, + "column": 16 + }, + "end": { + "line": 5, + "column": 17 + } + }, + "value": "|" + }, + { + "type": "HTMLWhitespace", + "range": [ + 128, + 129 + ], + "loc": { + "start": { + "line": 5, + "column": 17 + }, + "end": { + "line": 5, + "column": 18 + } + }, + "value": " " + }, + { + "type": "HTMLText", + "range": [ + 129, + 136 + ], + "loc": { + "start": { + "line": 5, + "column": 18 + }, + "end": { + "line": 5, + "column": 25 + } + }, + "value": "bar:baz" + }, + { + "type": "HTMLWhitespace", + "range": [ + 136, + 137 + ], + "loc": { + "start": { + "line": 5, + "column": 25 + }, + "end": { + "line": 5, + "column": 26 + } + }, + "value": " " + }, + { + "type": "VExpressionEnd", + "range": [ + 137, + 139 + ], + "loc": { + "start": { + "line": 5, + "column": 26 + }, + "end": { + "line": 5, + "column": 28 + } + }, + "value": "}}" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 139, + 144 + ], + "loc": { + "start": { + "line": 5, + "column": 28 + }, + "end": { + "line": 5, + "column": 33 + } + }, + "value": "div" + }, + { + "type": "HTMLTagClose", + "range": [ + 144, + 145 + ], + "loc": { + "start": { + "line": 5, + "column": 33 + }, + "end": { + "line": 5, + "column": 34 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 145, + 146 + ], + "loc": { + "start": { + "line": 5, + "column": 34 + }, + "end": { + "line": 6, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 146, + 156 + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 156, + 157 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 11 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 157, + 158 + ], + "loc": { + "start": { + "line": 6, + "column": 11 + }, + "end": { + "line": 7, + "column": 0 + } + }, + "value": "\n" + } + ], + "comments": [], + "errors": [ + { + "message": "Unexpected token :", + "index": 132, + "lineNumber": 5, + "column": 21 + } + ] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/filters-opt-filter-off/parser-options.json b/test/fixtures/ast/filters-opt-filter-off/parser-options.json new file mode 100644 index 00000000..f84071b8 --- /dev/null +++ b/test/fixtures/ast/filters-opt-filter-off/parser-options.json @@ -0,0 +1,5 @@ +{ + "vueFeatures": { + "filter": false + } +} diff --git a/test/fixtures/ast/filters-opt-filter-off/source.vue b/test/fixtures/ast/filters-opt-filter-off/source.vue new file mode 100644 index 00000000..c39a31b0 --- /dev/null +++ b/test/fixtures/ast/filters-opt-filter-off/source.vue @@ -0,0 +1,6 @@ + diff --git a/test/fixtures/ast/filters-opt-filter-off/token-ranges.json b/test/fixtures/ast/filters-opt-filter-off/token-ranges.json new file mode 100644 index 00000000..6ee9fe12 --- /dev/null +++ b/test/fixtures/ast/filters-opt-filter-off/token-ranges.json @@ -0,0 +1,56 @@ +[ + "", + "\n ", + "", + "{{", + "foo", + "|", + "bar", + "-", + "baz", + "}}", + "", + "\n ", + "", + "{{", + "foo", + "|", + "(", + "bar", + ")", + "}}", + "", + "\n ", + "", + "{{", + "foo", + "||", + "bar", + "}}", + "", + "\n ", + "", + "{{", + " ", + "foo", + " ", + "|", + " ", + "bar:baz", + " ", + "}}", + "", + "\n", + "", + "\n" +] \ No newline at end of file diff --git a/test/fixtures/ast/filters-opt-filter-off/tree.json b/test/fixtures/ast/filters-opt-filter-off/tree.json new file mode 100644 index 00000000..0322573c --- /dev/null +++ b/test/fixtures/ast/filters-opt-filter-off/tree.json @@ -0,0 +1,189 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/ast/filters-opt-filter-on/ast.json b/test/fixtures/ast/filters-opt-filter-on/ast.json new file mode 100644 index 00000000..adc0b05b --- /dev/null +++ b/test/fixtures/ast/filters-opt-filter-on/ast.json @@ -0,0 +1,1707 @@ +{ + "type": "Program", + "start": 0, + "end": 0, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 0 + } + }, + "range": [ + 0, + 0 + ], + "body": [], + "sourceType": "module", + "comments": [], + "tokens": [], + "templateBody": { + "type": "VElement", + "range": [ + 0, + 157 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 6, + "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, + 15 + ], + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 2, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 15, + 45 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 34 + } + }, + "name": "div", + "rawName": "div", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 15, + 20 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VExpressionContainer", + "range": [ + 20, + 39 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 28 + } + }, + "expression": { + "type": "VFilterSequenceExpression", + "expression": { + "type": "Identifier", + "start": 23, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "range": [ + 23, + 26 + ], + "name": "foo" + }, + "filters": [ + { + "type": "VFilter", + "range": [ + 29, + 36 + ], + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "callee": { + "type": "Identifier", + "range": [ + 29, + 36 + ], + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "name": "bar-baz" + }, + "arguments": [] + } + ], + "range": [ + 23, + 36 + ], + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 25 + } + } + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 23, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "range": [ + 23, + 26 + ], + "name": "foo" + }, + "mode": "r" + } + ] + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 39, + 45 + ], + "loc": { + "start": { + "line": 2, + "column": 28 + }, + "end": { + "line": 2, + "column": 34 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 45, + 50 + ], + "loc": { + "start": { + "line": 2, + "column": 34 + }, + "end": { + "line": 3, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 50, + 78 + ], + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 32 + } + }, + "name": "div", + "rawName": "div", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 50, + 55 + ], + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VExpressionContainer", + "range": [ + 55, + 72 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 3, + "column": 26 + } + }, + "expression": null, + "references": [] + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 72, + 78 + ], + "loc": { + "start": { + "line": 3, + "column": 26 + }, + "end": { + "line": 3, + "column": 32 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 78, + 83 + ], + "loc": { + "start": { + "line": 3, + "column": 32 + }, + "end": { + "line": 4, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 83, + 110 + ], + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 31 + } + }, + "name": "div", + "rawName": "div", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 83, + 88 + ], + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 9 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VExpressionContainer", + "range": [ + 88, + 104 + ], + "loc": { + "start": { + "line": 4, + "column": 9 + }, + "end": { + "line": 4, + "column": 25 + } + }, + "expression": { + "type": "LogicalExpression", + "start": 91, + "end": 101, + "loc": { + "start": { + "line": 4, + "column": 12 + }, + "end": { + "line": 4, + "column": 22 + } + }, + "range": [ + 91, + 101 + ], + "left": { + "type": "Identifier", + "start": 91, + "end": 94, + "loc": { + "start": { + "line": 4, + "column": 12 + }, + "end": { + "line": 4, + "column": 15 + } + }, + "range": [ + 91, + 94 + ], + "name": "foo" + }, + "operator": "||", + "right": { + "type": "Identifier", + "start": 98, + "end": 101, + "loc": { + "start": { + "line": 4, + "column": 19 + }, + "end": { + "line": 4, + "column": 22 + } + }, + "range": [ + 98, + 101 + ], + "name": "bar" + } + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 91, + "end": 94, + "loc": { + "start": { + "line": 4, + "column": 12 + }, + "end": { + "line": 4, + "column": 15 + } + }, + "range": [ + 91, + 94 + ], + "name": "foo" + }, + "mode": "r" + }, + { + "id": { + "type": "Identifier", + "start": 98, + "end": 101, + "loc": { + "start": { + "line": 4, + "column": 19 + }, + "end": { + "line": 4, + "column": 22 + } + }, + "range": [ + 98, + 101 + ], + "name": "bar" + }, + "mode": "r" + } + ] + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 104, + 110 + ], + "loc": { + "start": { + "line": 4, + "column": 25 + }, + "end": { + "line": 4, + "column": 31 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 110, + 115 + ], + "loc": { + "start": { + "line": 4, + "column": 31 + }, + "end": { + "line": 5, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 115, + 145 + ], + "loc": { + "start": { + "line": 5, + "column": 4 + }, + "end": { + "line": 5, + "column": 34 + } + }, + "name": "div", + "rawName": "div", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 115, + 120 + ], + "loc": { + "start": { + "line": 5, + "column": 4 + }, + "end": { + "line": 5, + "column": 9 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VExpressionContainer", + "range": [ + 120, + 139 + ], + "loc": { + "start": { + "line": 5, + "column": 9 + }, + "end": { + "line": 5, + "column": 28 + } + }, + "expression": { + "type": "VFilterSequenceExpression", + "expression": { + "type": "Identifier", + "start": 123, + "end": 126, + "loc": { + "start": { + "line": 5, + "column": 12 + }, + "end": { + "line": 5, + "column": 15 + } + }, + "range": [ + 123, + 126 + ], + "name": "foo" + }, + "filters": [ + { + "type": "VFilter", + "range": [ + 129, + 136 + ], + "loc": { + "start": { + "line": 5, + "column": 18 + }, + "end": { + "line": 5, + "column": 25 + } + }, + "callee": { + "type": "Identifier", + "range": [ + 129, + 136 + ], + "loc": { + "start": { + "line": 5, + "column": 18 + }, + "end": { + "line": 5, + "column": 25 + } + }, + "name": "bar:baz" + }, + "arguments": [] + } + ], + "range": [ + 123, + 136 + ], + "loc": { + "start": { + "line": 5, + "column": 12 + }, + "end": { + "line": 5, + "column": 25 + } + } + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 123, + "end": 126, + "loc": { + "start": { + "line": 5, + "column": 12 + }, + "end": { + "line": 5, + "column": 15 + } + }, + "range": [ + 123, + 126 + ], + "name": "foo" + }, + "mode": "r" + } + ] + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 139, + 145 + ], + "loc": { + "start": { + "line": 5, + "column": 28 + }, + "end": { + "line": 5, + "column": 34 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 145, + 146 + ], + "loc": { + "start": { + "line": 5, + "column": 34 + }, + "end": { + "line": 6, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 146, + 157 + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "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, + 15 + ], + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 2, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 15, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "value": "div" + }, + { + "type": "HTMLTagClose", + "range": [ + 19, + 20 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "value": "" + }, + { + "type": "VExpressionStart", + "range": [ + 20, + 22 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "value": "foo", + "start": 23, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "range": [ + 23, + 26 + ] + }, + { + "type": "Punctuator", + "value": "|", + "range": [ + 27, + 28 + ], + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 17 + } + } + }, + { + "type": "Identifier", + "value": "bar-baz", + "range": [ + 29, + 36 + ], + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 25 + } + } + }, + { + "type": "VExpressionEnd", + "range": [ + 37, + 39 + ], + "loc": { + "start": { + "line": 2, + "column": 26 + }, + "end": { + "line": 2, + "column": 28 + } + }, + "value": "}}" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 39, + 44 + ], + "loc": { + "start": { + "line": 2, + "column": 28 + }, + "end": { + "line": 2, + "column": 33 + } + }, + "value": "div" + }, + { + "type": "HTMLTagClose", + "range": [ + 44, + 45 + ], + "loc": { + "start": { + "line": 2, + "column": 33 + }, + "end": { + "line": 2, + "column": 34 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 45, + 50 + ], + "loc": { + "start": { + "line": 2, + "column": 34 + }, + "end": { + "line": 3, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 50, + 54 + ], + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "value": "div" + }, + { + "type": "HTMLTagClose", + "range": [ + 54, + 55 + ], + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "value": "" + }, + { + "type": "VExpressionStart", + "range": [ + 55, + 57 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "value": "{{" + }, + { + "type": "HTMLWhitespace", + "range": [ + 57, + 58 + ], + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 3, + "column": 12 + } + }, + "value": " " + }, + { + "type": "HTMLText", + "range": [ + 58, + 61 + ], + "loc": { + "start": { + "line": 3, + "column": 12 + }, + "end": { + "line": 3, + "column": 15 + } + }, + "value": "foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 61, + 62 + ], + "loc": { + "start": { + "line": 3, + "column": 15 + }, + "end": { + "line": 3, + "column": 16 + } + }, + "value": " " + }, + { + "type": "HTMLText", + "range": [ + 62, + 63 + ], + "loc": { + "start": { + "line": 3, + "column": 16 + }, + "end": { + "line": 3, + "column": 17 + } + }, + "value": "|" + }, + { + "type": "HTMLWhitespace", + "range": [ + 63, + 64 + ], + "loc": { + "start": { + "line": 3, + "column": 17 + }, + "end": { + "line": 3, + "column": 18 + } + }, + "value": " " + }, + { + "type": "HTMLText", + "range": [ + 64, + 69 + ], + "loc": { + "start": { + "line": 3, + "column": 18 + }, + "end": { + "line": 3, + "column": 23 + } + }, + "value": "(bar)" + }, + { + "type": "HTMLWhitespace", + "range": [ + 69, + 70 + ], + "loc": { + "start": { + "line": 3, + "column": 23 + }, + "end": { + "line": 3, + "column": 24 + } + }, + "value": " " + }, + { + "type": "VExpressionEnd", + "range": [ + 70, + 72 + ], + "loc": { + "start": { + "line": 3, + "column": 24 + }, + "end": { + "line": 3, + "column": 26 + } + }, + "value": "}}" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 72, + 77 + ], + "loc": { + "start": { + "line": 3, + "column": 26 + }, + "end": { + "line": 3, + "column": 31 + } + }, + "value": "div" + }, + { + "type": "HTMLTagClose", + "range": [ + 77, + 78 + ], + "loc": { + "start": { + "line": 3, + "column": 31 + }, + "end": { + "line": 3, + "column": 32 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 78, + 83 + ], + "loc": { + "start": { + "line": 3, + "column": 32 + }, + "end": { + "line": 4, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 83, + 87 + ], + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 8 + } + }, + "value": "div" + }, + { + "type": "HTMLTagClose", + "range": [ + 87, + 88 + ], + "loc": { + "start": { + "line": 4, + "column": 8 + }, + "end": { + "line": 4, + "column": 9 + } + }, + "value": "" + }, + { + "type": "VExpressionStart", + "range": [ + 88, + 90 + ], + "loc": { + "start": { + "line": 4, + "column": 9 + }, + "end": { + "line": 4, + "column": 11 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "value": "foo", + "start": 91, + "end": 94, + "loc": { + "start": { + "line": 4, + "column": 12 + }, + "end": { + "line": 4, + "column": 15 + } + }, + "range": [ + 91, + 94 + ] + }, + { + "type": "Punctuator", + "value": "||", + "start": 95, + "end": 97, + "loc": { + "start": { + "line": 4, + "column": 16 + }, + "end": { + "line": 4, + "column": 18 + } + }, + "range": [ + 95, + 97 + ] + }, + { + "type": "Identifier", + "value": "bar", + "start": 98, + "end": 101, + "loc": { + "start": { + "line": 4, + "column": 19 + }, + "end": { + "line": 4, + "column": 22 + } + }, + "range": [ + 98, + 101 + ] + }, + { + "type": "VExpressionEnd", + "range": [ + 102, + 104 + ], + "loc": { + "start": { + "line": 4, + "column": 23 + }, + "end": { + "line": 4, + "column": 25 + } + }, + "value": "}}" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 104, + 109 + ], + "loc": { + "start": { + "line": 4, + "column": 25 + }, + "end": { + "line": 4, + "column": 30 + } + }, + "value": "div" + }, + { + "type": "HTMLTagClose", + "range": [ + 109, + 110 + ], + "loc": { + "start": { + "line": 4, + "column": 30 + }, + "end": { + "line": 4, + "column": 31 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 110, + 115 + ], + "loc": { + "start": { + "line": 4, + "column": 31 + }, + "end": { + "line": 5, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 115, + 119 + ], + "loc": { + "start": { + "line": 5, + "column": 4 + }, + "end": { + "line": 5, + "column": 8 + } + }, + "value": "div" + }, + { + "type": "HTMLTagClose", + "range": [ + 119, + 120 + ], + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 9 + } + }, + "value": "" + }, + { + "type": "VExpressionStart", + "range": [ + 120, + 122 + ], + "loc": { + "start": { + "line": 5, + "column": 9 + }, + "end": { + "line": 5, + "column": 11 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "value": "foo", + "start": 123, + "end": 126, + "loc": { + "start": { + "line": 5, + "column": 12 + }, + "end": { + "line": 5, + "column": 15 + } + }, + "range": [ + 123, + 126 + ] + }, + { + "type": "Punctuator", + "value": "|", + "range": [ + 127, + 128 + ], + "loc": { + "start": { + "line": 5, + "column": 16 + }, + "end": { + "line": 5, + "column": 17 + } + } + }, + { + "type": "Identifier", + "value": "bar:baz", + "range": [ + 129, + 136 + ], + "loc": { + "start": { + "line": 5, + "column": 18 + }, + "end": { + "line": 5, + "column": 25 + } + } + }, + { + "type": "VExpressionEnd", + "range": [ + 137, + 139 + ], + "loc": { + "start": { + "line": 5, + "column": 26 + }, + "end": { + "line": 5, + "column": 28 + } + }, + "value": "}}" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 139, + 144 + ], + "loc": { + "start": { + "line": 5, + "column": 28 + }, + "end": { + "line": 5, + "column": 33 + } + }, + "value": "div" + }, + { + "type": "HTMLTagClose", + "range": [ + 144, + 145 + ], + "loc": { + "start": { + "line": 5, + "column": 33 + }, + "end": { + "line": 5, + "column": 34 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 145, + 146 + ], + "loc": { + "start": { + "line": 5, + "column": 34 + }, + "end": { + "line": 6, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 146, + 156 + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 156, + 157 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 11 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 157, + 158 + ], + "loc": { + "start": { + "line": 6, + "column": 11 + }, + "end": { + "line": 7, + "column": 0 + } + }, + "value": "\n" + } + ], + "comments": [], + "errors": [ + { + "message": "Expected to be a filter name, but got empty.", + "index": 63, + "lineNumber": 3, + "column": 17 + } + ] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/filters-opt-filter-on/parser-options.json b/test/fixtures/ast/filters-opt-filter-on/parser-options.json new file mode 100644 index 00000000..ddd62bf2 --- /dev/null +++ b/test/fixtures/ast/filters-opt-filter-on/parser-options.json @@ -0,0 +1,5 @@ +{ + "vueFeatures": { + "filter": true + } +} diff --git a/test/fixtures/ast/filters-opt-filter-on/source.vue b/test/fixtures/ast/filters-opt-filter-on/source.vue new file mode 100644 index 00000000..c39a31b0 --- /dev/null +++ b/test/fixtures/ast/filters-opt-filter-on/source.vue @@ -0,0 +1,6 @@ + diff --git a/test/fixtures/ast/filters-opt-filter-on/token-ranges.json b/test/fixtures/ast/filters-opt-filter-on/token-ranges.json new file mode 100644 index 00000000..bc7817b9 --- /dev/null +++ b/test/fixtures/ast/filters-opt-filter-on/token-ranges.json @@ -0,0 +1,52 @@ +[ + "", + "\n ", + "", + "{{", + "foo", + "|", + "bar-baz", + "}}", + "", + "\n ", + "", + "{{", + " ", + "foo", + " ", + "|", + " ", + "(bar)", + " ", + "}}", + "", + "\n ", + "", + "{{", + "foo", + "||", + "bar", + "}}", + "", + "\n ", + "", + "{{", + "foo", + "|", + "bar:baz", + "}}", + "", + "\n", + "", + "\n" +] \ No newline at end of file diff --git a/test/fixtures/ast/filters-opt-filter-on/tree.json b/test/fixtures/ast/filters-opt-filter-on/tree.json new file mode 100644 index 00000000..614624fa --- /dev/null +++ b/test/fixtures/ast/filters-opt-filter-on/tree.json @@ -0,0 +1,190 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/ast/filters/ast.json b/test/fixtures/ast/filters/ast.json index ef0c5853..e9964d67 100644 --- a/test/fixtures/ast/filters/ast.json +++ b/test/fixtures/ast/filters/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { @@ -192,7 +192,8 @@ ], "name": "create_time" }, - "computed": false + "computed": false, + "optional": false }, "filters": [ { diff --git a/test/fixtures/ast/foreignobject-lower/ast.json b/test/fixtures/ast/foreignobject-lower/ast.json new file mode 100644 index 00000000..480e572a --- /dev/null +++ b/test/fixtures/ast/foreignobject-lower/ast.json @@ -0,0 +1,618 @@ +{ + "type": "Program", + "start": 0, + "end": 0, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 0 + } + }, + "range": [ + 0, + 0 + ], + "body": [], + "sourceType": "module", + "comments": [], + "tokens": [], + "templateBody": { + "type": "VElement", + "range": [ + 0, + 92 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 6, + "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, + 15 + ], + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 2, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 15, + 80 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "name": "svg", + "rawName": "svg", + "namespace": "http://www.w3.org/2000/svg", + "startTag": { + "type": "VStartTag", + "range": [ + 15, + 20 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 20, + 29 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 29, + 69 + ], + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 4, + "column": 24 + } + }, + "name": "foreignObject", + "rawName": "foreignobject", + "namespace": "http://www.w3.org/2000/svg", + "startTag": { + "type": "VStartTag", + "range": [ + 29, + 44 + ], + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 23 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 44, + 53 + ], + "loc": { + "start": { + "line": 3, + "column": 23 + }, + "end": { + "line": 4, + "column": 8 + } + }, + "value": "\n " + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 53, + 69 + ], + "loc": { + "start": { + "line": 4, + "column": 8 + }, + "end": { + "line": 4, + "column": 24 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 69, + 74 + ], + "loc": { + "start": { + "line": 4, + "column": 24 + }, + "end": { + "line": 5, + "column": 4 + } + }, + "value": "\n " + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 74, + 80 + ], + "loc": { + "start": { + "line": 5, + "column": 4 + }, + "end": { + "line": 5, + "column": 10 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 80, + 81 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 6, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 81, + 92 + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "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, + 15 + ], + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 2, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 15, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "value": "svg" + }, + { + "type": "HTMLTagClose", + "range": [ + 19, + 20 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 20, + 29 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 29, + 43 + ], + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 22 + } + }, + "value": "foreignobject" + }, + { + "type": "HTMLTagClose", + "range": [ + 43, + 44 + ], + "loc": { + "start": { + "line": 3, + "column": 22 + }, + "end": { + "line": 3, + "column": 23 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 44, + 53 + ], + "loc": { + "start": { + "line": 3, + "column": 23 + }, + "end": { + "line": 4, + "column": 8 + } + }, + "value": "\n " + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 53, + 68 + ], + "loc": { + "start": { + "line": 4, + "column": 8 + }, + "end": { + "line": 4, + "column": 23 + } + }, + "value": "foreignobject" + }, + { + "type": "HTMLTagClose", + "range": [ + 68, + 69 + ], + "loc": { + "start": { + "line": 4, + "column": 23 + }, + "end": { + "line": 4, + "column": 24 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 69, + 74 + ], + "loc": { + "start": { + "line": 4, + "column": 24 + }, + "end": { + "line": 5, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 74, + 79 + ], + "loc": { + "start": { + "line": 5, + "column": 4 + }, + "end": { + "line": 5, + "column": 9 + } + }, + "value": "svg" + }, + { + "type": "HTMLTagClose", + "range": [ + 79, + 80 + ], + "loc": { + "start": { + "line": 5, + "column": 9 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 80, + 81 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 6, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 81, + 91 + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 91, + 92 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 11 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 92, + 93 + ], + "loc": { + "start": { + "line": 6, + "column": 11 + }, + "end": { + "line": 7, + "column": 0 + } + }, + "value": "\n" + } + ], + "comments": [], + "errors": [] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/foreignobject-lower/source.vue b/test/fixtures/ast/foreignobject-lower/source.vue new file mode 100644 index 00000000..60c36533 --- /dev/null +++ b/test/fixtures/ast/foreignobject-lower/source.vue @@ -0,0 +1,6 @@ + diff --git a/test/fixtures/ast/foreignobject-lower/token-ranges.json b/test/fixtures/ast/foreignobject-lower/token-ranges.json new file mode 100644 index 00000000..6c369be4 --- /dev/null +++ b/test/fixtures/ast/foreignobject-lower/token-ranges.json @@ -0,0 +1,20 @@ +[ + "", + "\n ", + "", + "\n ", + "", + "\n ", + "", + "\n ", + "", + "\n", + "", + "\n" +] \ No newline at end of file diff --git a/test/fixtures/ast/foreignobject-lower/tree.json b/test/fixtures/ast/foreignobject-lower/tree.json new file mode 100644 index 00000000..991839f9 --- /dev/null +++ b/test/fixtures/ast/foreignobject-lower/tree.json @@ -0,0 +1,75 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/ast/foreignobject/ast.json b/test/fixtures/ast/foreignobject/ast.json index fb4942f8..2d0fc692 100644 --- a/test/fixtures/ast/foreignobject/ast.json +++ b/test/fixtures/ast/foreignobject/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { @@ -267,7 +267,7 @@ } }, "name": "foreignObject", - "rawName": "foreignobject", + "rawName": "foreignObject", "namespace": "http://www.w3.org/2000/svg", "startTag": { "type": "VStartTag", diff --git a/test/fixtures/ast/foreignobject/source.vue b/test/fixtures/ast/foreignobject/source.vue index b8e86b43..5c41fe86 100644 --- a/test/fixtures/ast/foreignobject/source.vue +++ b/test/fixtures/ast/foreignobject/source.vue @@ -1,8 +1,8 @@ diff --git a/test/fixtures/ast/foreignobject/token-ranges.json b/test/fixtures/ast/foreignobject/token-ranges.json index 39743b51..3b3c3eca 100644 --- a/test/fixtures/ast/foreignobject/token-ranges.json +++ b/test/fixtures/ast/foreignobject/token-ranges.json @@ -11,7 +11,7 @@ "\"\"", "/>", "\n ", - "", "\n ", "", "\n ", - "", "\n ", "\n \n \n \n
Hello
\n
\n
\n", + "text": "", "children": [ { "type": "VStartTag", @@ -15,7 +15,7 @@ }, { "type": "VElement", - "text": "\n \n \n
Hello
\n
\n
", + "text": "\n \n \n
Hello
\n
\n
", "children": [ { "type": "VStartTag", @@ -62,11 +62,11 @@ }, { "type": "VElement", - "text": "\n
Hello
\n
", + "text": "\n
Hello
\n
", "children": [ { "type": "VStartTag", - "text": "", + "text": "", "children": [] }, { @@ -102,7 +102,7 @@ }, { "type": "VEndTag", - "text": "", + "text": "", "children": [] } ] diff --git a/test/fixtures/ast/hole-in-array/ast.json b/test/fixtures/ast/hole-in-array/ast.json index 2c8dfa86..f435432e 100644 --- a/test/fixtures/ast/hole-in-array/ast.json +++ b/test/fixtures/ast/hole-in-array/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/html-entities-in-static-places/ast.json b/test/fixtures/ast/html-entities-in-static-places/ast.json index a9c98c69..1959d1b0 100644 --- a/test/fixtures/ast/html-entities-in-static-places/ast.json +++ b/test/fixtures/ast/html-entities-in-static-places/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/html-entities-lone-amp/ast.json b/test/fixtures/ast/html-entities-lone-amp/ast.json new file mode 100644 index 00000000..1714f23d --- /dev/null +++ b/test/fixtures/ast/html-entities-lone-amp/ast.json @@ -0,0 +1,1723 @@ +{ + "type": "Program", + "start": 0, + "end": 0, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 0 + } + }, + "range": [ + 0, + 0 + ], + "body": [], + "sourceType": "module", + "comments": [], + "tokens": [], + "templateBody": { + "type": "VElement", + "range": [ + 0, + 187 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 8, + "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, + 15 + ], + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 2, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 15, + 38 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 27 + } + }, + "name": "mycomponent", + "rawName": "MyComponent", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 15, + 38 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 27 + } + }, + "selfClosing": true, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 28, + 35 + ], + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 24 + } + }, + "directive": false, + "key": { + "type": "VIdentifier", + "range": [ + 28, + 31 + ], + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "name": "foo", + "rawName": "foo" + }, + "value": { + "type": "VLiteral", + "range": [ + 32, + 35 + ], + "loc": { + "start": { + "line": 2, + "column": 21 + }, + "end": { + "line": 2, + "column": 24 + } + }, + "value": "&" + } + } + ] + }, + "children": [], + "endTag": null, + "variables": [] + }, + { + "type": "VText", + "range": [ + 38, + 43 + ], + "loc": { + "start": { + "line": 2, + "column": 27 + }, + "end": { + "line": 3, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 43, + 66 + ], + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 27 + } + }, + "name": "mycomponent", + "rawName": "MyComponent", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 43, + 66 + ], + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 27 + } + }, + "selfClosing": true, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 56, + 63 + ], + "loc": { + "start": { + "line": 3, + "column": 17 + }, + "end": { + "line": 3, + "column": 24 + } + }, + "directive": false, + "key": { + "type": "VIdentifier", + "range": [ + 56, + 59 + ], + "loc": { + "start": { + "line": 3, + "column": 17 + }, + "end": { + "line": 3, + "column": 20 + } + }, + "name": "foo", + "rawName": "foo" + }, + "value": { + "type": "VLiteral", + "range": [ + 60, + 63 + ], + "loc": { + "start": { + "line": 3, + "column": 21 + }, + "end": { + "line": 3, + "column": 24 + } + }, + "value": "&" + } + } + ] + }, + "children": [], + "endTag": null, + "variables": [] + }, + { + "type": "VText", + "range": [ + 66, + 71 + ], + "loc": { + "start": { + "line": 3, + "column": 27 + }, + "end": { + "line": 4, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 71, + 92 + ], + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 25 + } + }, + "name": "mycomponent", + "rawName": "MyComponent", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 71, + 92 + ], + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 25 + } + }, + "selfClosing": true, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 84, + 89 + ], + "loc": { + "start": { + "line": 4, + "column": 17 + }, + "end": { + "line": 4, + "column": 22 + } + }, + "directive": false, + "key": { + "type": "VIdentifier", + "range": [ + 84, + 87 + ], + "loc": { + "start": { + "line": 4, + "column": 17 + }, + "end": { + "line": 4, + "column": 20 + } + }, + "name": "foo", + "rawName": "foo" + }, + "value": { + "type": "VLiteral", + "range": [ + 88, + 89 + ], + "loc": { + "start": { + "line": 4, + "column": 21 + }, + "end": { + "line": 4, + "column": 22 + } + }, + "value": "&" + } + } + ] + }, + "children": [], + "endTag": null, + "variables": [] + }, + { + "type": "VText", + "range": [ + 92, + 97 + ], + "loc": { + "start": { + "line": 4, + "column": 25 + }, + "end": { + "line": 5, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 97, + 122 + ], + "loc": { + "start": { + "line": 5, + "column": 4 + }, + "end": { + "line": 5, + "column": 29 + } + }, + "name": "mycomponent", + "rawName": "MyComponent", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 97, + 122 + ], + "loc": { + "start": { + "line": 5, + "column": 4 + }, + "end": { + "line": 5, + "column": 29 + } + }, + "selfClosing": true, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 110, + 115 + ], + "loc": { + "start": { + "line": 5, + "column": 17 + }, + "end": { + "line": 5, + "column": 22 + } + }, + "directive": false, + "key": { + "type": "VIdentifier", + "range": [ + 110, + 113 + ], + "loc": { + "start": { + "line": 5, + "column": 17 + }, + "end": { + "line": 5, + "column": 20 + } + }, + "name": "foo", + "rawName": "foo" + }, + "value": { + "type": "VLiteral", + "range": [ + 114, + 115 + ], + "loc": { + "start": { + "line": 5, + "column": 21 + }, + "end": { + "line": 5, + "column": 22 + } + }, + "value": "&" + } + }, + { + "type": "VAttribute", + "range": [ + 116, + 119 + ], + "loc": { + "start": { + "line": 5, + "column": 23 + }, + "end": { + "line": 5, + "column": 26 + } + }, + "directive": false, + "key": { + "type": "VIdentifier", + "range": [ + 116, + 119 + ], + "loc": { + "start": { + "line": 5, + "column": 23 + }, + "end": { + "line": 5, + "column": 26 + } + }, + "name": "bar", + "rawName": "bar" + }, + "value": null + } + ] + }, + "children": [], + "endTag": null, + "variables": [] + }, + { + "type": "VText", + "range": [ + 122, + 127 + ], + "loc": { + "start": { + "line": 5, + "column": 29 + }, + "end": { + "line": 6, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 127, + 169 + ], + "loc": { + "start": { + "line": 6, + "column": 4 + }, + "end": { + "line": 6, + "column": 46 + } + }, + "name": "mycomponent", + "rawName": "MyComponent", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 127, + 146 + ], + "loc": { + "start": { + "line": 6, + "column": 4 + }, + "end": { + "line": 6, + "column": 23 + } + }, + "selfClosing": false, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 140, + 145 + ], + "loc": { + "start": { + "line": 6, + "column": 17 + }, + "end": { + "line": 6, + "column": 22 + } + }, + "directive": false, + "key": { + "type": "VIdentifier", + "range": [ + 140, + 143 + ], + "loc": { + "start": { + "line": 6, + "column": 17 + }, + "end": { + "line": 6, + "column": 20 + } + }, + "name": "foo", + "rawName": "foo" + }, + "value": { + "type": "VLiteral", + "range": [ + 144, + 145 + ], + "loc": { + "start": { + "line": 6, + "column": 21 + }, + "end": { + "line": 6, + "column": 22 + } + }, + "value": "&" + } + } + ] + }, + "children": [ + { + "type": "VExpressionContainer", + "range": [ + 146, + 155 + ], + "loc": { + "start": { + "line": 6, + "column": 23 + }, + "end": { + "line": 6, + "column": 32 + } + }, + "expression": { + "type": "BinaryExpression", + "start": 148, + "end": 153, + "loc": { + "start": { + "line": 6, + "column": 25 + }, + "end": { + "line": 6, + "column": 30 + } + }, + "range": [ + 148, + 153 + ], + "left": { + "type": "Identifier", + "start": 148, + "end": 149, + "loc": { + "start": { + "line": 6, + "column": 25 + }, + "end": { + "line": 6, + "column": 26 + } + }, + "range": [ + 148, + 149 + ], + "name": "a" + }, + "operator": "&", + "right": { + "type": "Identifier", + "start": 152, + "end": 153, + "loc": { + "start": { + "line": 6, + "column": 29 + }, + "end": { + "line": 6, + "column": 30 + } + }, + "range": [ + 152, + 153 + ], + "name": "b" + } + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 148, + "end": 149, + "loc": { + "start": { + "line": 6, + "column": 25 + }, + "end": { + "line": 6, + "column": 26 + } + }, + "range": [ + 148, + 149 + ], + "name": "a" + }, + "mode": "r" + }, + { + "id": { + "type": "Identifier", + "start": 152, + "end": 153, + "loc": { + "start": { + "line": 6, + "column": 29 + }, + "end": { + "line": 6, + "column": 30 + } + }, + "range": [ + 152, + 153 + ], + "name": "b" + }, + "mode": "r" + } + ] + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 155, + 169 + ], + "loc": { + "start": { + "line": 6, + "column": 32 + }, + "end": { + "line": 6, + "column": 46 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 169, + 176 + ], + "loc": { + "start": { + "line": 6, + "column": 46 + }, + "end": { + "line": 8, + "column": 0 + } + }, + "value": "\n &\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 176, + 187 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "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, + 15 + ], + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 2, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 15, + 27 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "value": "mycomponent" + }, + { + "type": "HTMLIdentifier", + "range": [ + 28, + 31 + ], + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "value": "foo" + }, + { + "type": "HTMLAssociation", + "range": [ + 31, + 32 + ], + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "value": "" + }, + { + "type": "HTMLLiteral", + "range": [ + 32, + 35 + ], + "loc": { + "start": { + "line": 2, + "column": 21 + }, + "end": { + "line": 2, + "column": 24 + } + }, + "value": "&" + }, + { + "type": "HTMLSelfClosingTagClose", + "range": [ + 36, + 38 + ], + "loc": { + "start": { + "line": 2, + "column": 25 + }, + "end": { + "line": 2, + "column": 27 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 38, + 43 + ], + "loc": { + "start": { + "line": 2, + "column": 27 + }, + "end": { + "line": 3, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 43, + 55 + ], + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 16 + } + }, + "value": "mycomponent" + }, + { + "type": "HTMLIdentifier", + "range": [ + 56, + 59 + ], + "loc": { + "start": { + "line": 3, + "column": 17 + }, + "end": { + "line": 3, + "column": 20 + } + }, + "value": "foo" + }, + { + "type": "HTMLAssociation", + "range": [ + 59, + 60 + ], + "loc": { + "start": { + "line": 3, + "column": 20 + }, + "end": { + "line": 3, + "column": 21 + } + }, + "value": "" + }, + { + "type": "HTMLLiteral", + "range": [ + 60, + 63 + ], + "loc": { + "start": { + "line": 3, + "column": 21 + }, + "end": { + "line": 3, + "column": 24 + } + }, + "value": "&" + }, + { + "type": "HTMLSelfClosingTagClose", + "range": [ + 64, + 66 + ], + "loc": { + "start": { + "line": 3, + "column": 25 + }, + "end": { + "line": 3, + "column": 27 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 66, + 71 + ], + "loc": { + "start": { + "line": 3, + "column": 27 + }, + "end": { + "line": 4, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 71, + 83 + ], + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 16 + } + }, + "value": "mycomponent" + }, + { + "type": "HTMLIdentifier", + "range": [ + 84, + 87 + ], + "loc": { + "start": { + "line": 4, + "column": 17 + }, + "end": { + "line": 4, + "column": 20 + } + }, + "value": "foo" + }, + { + "type": "HTMLAssociation", + "range": [ + 87, + 88 + ], + "loc": { + "start": { + "line": 4, + "column": 20 + }, + "end": { + "line": 4, + "column": 21 + } + }, + "value": "" + }, + { + "type": "HTMLLiteral", + "range": [ + 88, + 89 + ], + "loc": { + "start": { + "line": 4, + "column": 21 + }, + "end": { + "line": 4, + "column": 22 + } + }, + "value": "&" + }, + { + "type": "HTMLSelfClosingTagClose", + "range": [ + 90, + 92 + ], + "loc": { + "start": { + "line": 4, + "column": 23 + }, + "end": { + "line": 4, + "column": 25 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 92, + 97 + ], + "loc": { + "start": { + "line": 4, + "column": 25 + }, + "end": { + "line": 5, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 97, + 109 + ], + "loc": { + "start": { + "line": 5, + "column": 4 + }, + "end": { + "line": 5, + "column": 16 + } + }, + "value": "mycomponent" + }, + { + "type": "HTMLIdentifier", + "range": [ + 110, + 113 + ], + "loc": { + "start": { + "line": 5, + "column": 17 + }, + "end": { + "line": 5, + "column": 20 + } + }, + "value": "foo" + }, + { + "type": "HTMLAssociation", + "range": [ + 113, + 114 + ], + "loc": { + "start": { + "line": 5, + "column": 20 + }, + "end": { + "line": 5, + "column": 21 + } + }, + "value": "" + }, + { + "type": "HTMLLiteral", + "range": [ + 114, + 115 + ], + "loc": { + "start": { + "line": 5, + "column": 21 + }, + "end": { + "line": 5, + "column": 22 + } + }, + "value": "&" + }, + { + "type": "HTMLIdentifier", + "range": [ + 116, + 119 + ], + "loc": { + "start": { + "line": 5, + "column": 23 + }, + "end": { + "line": 5, + "column": 26 + } + }, + "value": "bar" + }, + { + "type": "HTMLSelfClosingTagClose", + "range": [ + 120, + 122 + ], + "loc": { + "start": { + "line": 5, + "column": 27 + }, + "end": { + "line": 5, + "column": 29 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 122, + 127 + ], + "loc": { + "start": { + "line": 5, + "column": 29 + }, + "end": { + "line": 6, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 127, + 139 + ], + "loc": { + "start": { + "line": 6, + "column": 4 + }, + "end": { + "line": 6, + "column": 16 + } + }, + "value": "mycomponent" + }, + { + "type": "HTMLIdentifier", + "range": [ + 140, + 143 + ], + "loc": { + "start": { + "line": 6, + "column": 17 + }, + "end": { + "line": 6, + "column": 20 + } + }, + "value": "foo" + }, + { + "type": "HTMLAssociation", + "range": [ + 143, + 144 + ], + "loc": { + "start": { + "line": 6, + "column": 20 + }, + "end": { + "line": 6, + "column": 21 + } + }, + "value": "" + }, + { + "type": "HTMLLiteral", + "range": [ + 144, + 145 + ], + "loc": { + "start": { + "line": 6, + "column": 21 + }, + "end": { + "line": 6, + "column": 22 + } + }, + "value": "&" + }, + { + "type": "HTMLTagClose", + "range": [ + 145, + 146 + ], + "loc": { + "start": { + "line": 6, + "column": 22 + }, + "end": { + "line": 6, + "column": 23 + } + }, + "value": "" + }, + { + "type": "VExpressionStart", + "range": [ + 146, + 148 + ], + "loc": { + "start": { + "line": 6, + "column": 23 + }, + "end": { + "line": 6, + "column": 25 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "value": "a", + "start": 148, + "end": 149, + "loc": { + "start": { + "line": 6, + "column": 25 + }, + "end": { + "line": 6, + "column": 26 + } + }, + "range": [ + 148, + 149 + ] + }, + { + "type": "Punctuator", + "value": "&", + "start": 150, + "end": 151, + "loc": { + "start": { + "line": 6, + "column": 27 + }, + "end": { + "line": 6, + "column": 28 + } + }, + "range": [ + 150, + 151 + ] + }, + { + "type": "Identifier", + "value": "b", + "start": 152, + "end": 153, + "loc": { + "start": { + "line": 6, + "column": 29 + }, + "end": { + "line": 6, + "column": 30 + } + }, + "range": [ + 152, + 153 + ] + }, + { + "type": "VExpressionEnd", + "range": [ + 153, + 155 + ], + "loc": { + "start": { + "line": 6, + "column": 30 + }, + "end": { + "line": 6, + "column": 32 + } + }, + "value": "}}" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 155, + 168 + ], + "loc": { + "start": { + "line": 6, + "column": 32 + }, + "end": { + "line": 6, + "column": 45 + } + }, + "value": "mycomponent" + }, + { + "type": "HTMLTagClose", + "range": [ + 168, + 169 + ], + "loc": { + "start": { + "line": 6, + "column": 45 + }, + "end": { + "line": 6, + "column": 46 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 169, + 174 + ], + "loc": { + "start": { + "line": 6, + "column": 46 + }, + "end": { + "line": 7, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "HTMLText", + "range": [ + 174, + 175 + ], + "loc": { + "start": { + "line": 7, + "column": 4 + }, + "end": { + "line": 7, + "column": 5 + } + }, + "value": "&" + }, + { + "type": "HTMLWhitespace", + "range": [ + 175, + 176 + ], + "loc": { + "start": { + "line": 7, + "column": 5 + }, + "end": { + "line": 8, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 176, + 186 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 186, + 187 + ], + "loc": { + "start": { + "line": 8, + "column": 10 + }, + "end": { + "line": 8, + "column": 11 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 187, + 188 + ], + "loc": { + "start": { + "line": 8, + "column": 11 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "value": "\n" + } + ], + "comments": [], + "errors": [ + { + "message": "non-void-html-element-start-tag-with-trailing-solidus", + "index": 15, + "lineNumber": 2, + "column": 4 + }, + { + "message": "non-void-html-element-start-tag-with-trailing-solidus", + "index": 43, + "lineNumber": 3, + "column": 4 + }, + { + "message": "non-void-html-element-start-tag-with-trailing-solidus", + "index": 71, + "lineNumber": 4, + "column": 4 + }, + { + "message": "non-void-html-element-start-tag-with-trailing-solidus", + "index": 97, + "lineNumber": 5, + "column": 4 + } + ] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/html-entities-lone-amp/source.vue b/test/fixtures/ast/html-entities-lone-amp/source.vue new file mode 100644 index 00000000..b6bac9ef --- /dev/null +++ b/test/fixtures/ast/html-entities-lone-amp/source.vue @@ -0,0 +1,8 @@ + diff --git a/test/fixtures/ast/html-entities-lone-amp/token-ranges.json b/test/fixtures/ast/html-entities-lone-amp/token-ranges.json new file mode 100644 index 00000000..0f15d840 --- /dev/null +++ b/test/fixtures/ast/html-entities-lone-amp/token-ranges.json @@ -0,0 +1,48 @@ +[ + "", + "\n ", + "", + "\n ", + "", + "\n ", + "", + "\n ", + "", + "\n ", + "", + "{{", + "a", + "&", + "b", + "}}", + "", + "\n ", + "&", + "\n", + "", + "\n" +] \ No newline at end of file diff --git a/test/fixtures/ast/html-entities-lone-amp/tree.json b/test/fixtures/ast/html-entities-lone-amp/tree.json new file mode 100644 index 00000000..68c8ede7 --- /dev/null +++ b/test/fixtures/ast/html-entities-lone-amp/tree.json @@ -0,0 +1,226 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/ast/html-entities-mapping/ast.json b/test/fixtures/ast/html-entities-mapping/ast.json index a4214137..69aab3f9 100644 --- a/test/fixtures/ast/html-entities-mapping/ast.json +++ b/test/fixtures/ast/html-entities-mapping/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/html-entities-numeric/ast.json b/test/fixtures/ast/html-entities-numeric/ast.json index 4c5e77c8..0480cae5 100644 --- a/test/fixtures/ast/html-entities-numeric/ast.json +++ b/test/fixtures/ast/html-entities-numeric/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/html-entities-special-in-attributes/ast.json b/test/fixtures/ast/html-entities-special-in-attributes/ast.json index ef52f027..23c8c433 100644 --- a/test/fixtures/ast/html-entities-special-in-attributes/ast.json +++ b/test/fixtures/ast/html-entities-special-in-attributes/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/html-entities-surrogate-pair-and-expression/ast.json b/test/fixtures/ast/html-entities-surrogate-pair-and-expression/ast.json index 3cf43b01..a499ff27 100644 --- a/test/fixtures/ast/html-entities-surrogate-pair-and-expression/ast.json +++ b/test/fixtures/ast/html-entities-surrogate-pair-and-expression/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/html-entities-with-line-terminators/ast.json b/test/fixtures/ast/html-entities-with-line-terminators/ast.json index ff6d2941..18b3e947 100644 --- a/test/fixtures/ast/html-entities-with-line-terminators/ast.json +++ b/test/fixtures/ast/html-entities-with-line-terminators/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/html-entities/ast.json b/test/fixtures/ast/html-entities/ast.json index 0d9c4201..98faf0df 100644 --- a/test/fixtures/ast/html-entities/ast.json +++ b/test/fixtures/ast/html-entities/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/input-component/ast.json b/test/fixtures/ast/input-component/ast.json new file mode 100644 index 00000000..0e782a38 --- /dev/null +++ b/test/fixtures/ast/input-component/ast.json @@ -0,0 +1,1246 @@ +{ + "type": "Program", + "start": 0, + "end": 0, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 0 + } + }, + "range": [ + 0, + 0 + ], + "body": [], + "sourceType": "module", + "comments": [], + "tokens": [], + "templateBody": { + "type": "VElement", + "range": [ + 0, + 141 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 9, + "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": "VElement", + "range": [ + 13, + 129 + ], + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 8, + "column": 8 + } + }, + "name": "div", + "rawName": "div", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 13, + 18 + ], + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 18, + 23 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 3, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 23, + 120 + ], + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 7, + "column": 12 + } + }, + "name": "input", + "rawName": "Input", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 23, + 30 + ], + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 30, + 37 + ], + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 4, + "column": 6 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 37, + 107 + ], + "loc": { + "start": { + "line": 4, + "column": 6 + }, + "end": { + "line": 6, + "column": 17 + } + }, + "name": "template", + "rawName": "template", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 37, + 55 + ], + "loc": { + "start": { + "line": 4, + "column": 6 + }, + "end": { + "line": 4, + "column": 24 + } + }, + "selfClosing": false, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 47, + 54 + ], + "loc": { + "start": { + "line": 4, + "column": 16 + }, + "end": { + "line": 4, + "column": 23 + } + }, + "directive": true, + "key": { + "type": "VDirectiveKey", + "range": [ + 47, + 54 + ], + "loc": { + "start": { + "line": 4, + "column": 16 + }, + "end": { + "line": 4, + "column": 23 + } + }, + "name": { + "type": "VIdentifier", + "range": [ + 47, + 48 + ], + "loc": { + "start": { + "column": 16, + "line": 4 + }, + "end": { + "column": 17, + "line": 4 + } + }, + "name": "slot", + "rawName": "#" + }, + "argument": { + "type": "VIdentifier", + "range": [ + 48, + 54 + ], + "loc": { + "start": { + "column": 17, + "line": 4 + }, + "end": { + "column": 23, + "line": 4 + } + }, + "name": "suffix", + "rawName": "suffix" + }, + "modifiers": [] + }, + "value": null + } + ] + }, + "children": [ + { + "type": "VText", + "range": [ + 55, + 64 + ], + "loc": { + "start": { + "line": 4, + "column": 24 + }, + "end": { + "line": 5, + "column": 8 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 64, + 89 + ], + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 33 + } + }, + "name": "icon", + "rawName": "Icon", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 64, + 82 + ], + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 26 + } + }, + "selfClosing": false, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 70, + 81 + ], + "loc": { + "start": { + "line": 5, + "column": 14 + }, + "end": { + "line": 5, + "column": 25 + } + }, + "directive": false, + "key": { + "type": "VIdentifier", + "range": [ + 70, + 74 + ], + "loc": { + "start": { + "line": 5, + "column": 14 + }, + "end": { + "line": 5, + "column": 18 + } + }, + "name": "name", + "rawName": "name" + }, + "value": { + "type": "VLiteral", + "range": [ + 75, + 81 + ], + "loc": { + "start": { + "line": 5, + "column": 19 + }, + "end": { + "line": 5, + "column": 25 + } + }, + "value": "user" + } + } + ] + }, + "children": [], + "endTag": { + "type": "VEndTag", + "range": [ + 82, + 89 + ], + "loc": { + "start": { + "line": 5, + "column": 26 + }, + "end": { + "line": 5, + "column": 33 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 89, + 96 + ], + "loc": { + "start": { + "line": 5, + "column": 33 + }, + "end": { + "line": 6, + "column": 6 + } + }, + "value": "\n " + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 96, + 107 + ], + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 17 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 107, + 112 + ], + "loc": { + "start": { + "line": 6, + "column": 17 + }, + "end": { + "line": 7, + "column": 4 + } + }, + "value": "\n " + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 112, + 120 + ], + "loc": { + "start": { + "line": 7, + "column": 4 + }, + "end": { + "line": 7, + "column": 12 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 120, + 123 + ], + "loc": { + "start": { + "line": 7, + "column": 12 + }, + "end": { + "line": 8, + "column": 2 + } + }, + "value": "\n " + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 123, + 129 + ], + "loc": { + "start": { + "line": 8, + "column": 2 + }, + "end": { + "line": 8, + "column": 8 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 129, + 130 + ], + "loc": { + "start": { + "line": 8, + "column": 8 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 130, + 141 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "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": "HTMLTagOpen", + "range": [ + 13, + 17 + ], + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 6 + } + }, + "value": "div" + }, + { + "type": "HTMLTagClose", + "range": [ + 17, + 18 + ], + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 18, + 23 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 3, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 23, + 29 + ], + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 10 + } + }, + "value": "input" + }, + { + "type": "HTMLTagClose", + "range": [ + 29, + 30 + ], + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 30, + 37 + ], + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 4, + "column": 6 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 37, + 46 + ], + "loc": { + "start": { + "line": 4, + "column": 6 + }, + "end": { + "line": 4, + "column": 15 + } + }, + "value": "template" + }, + { + "type": "Punctuator", + "range": [ + 47, + 48 + ], + "loc": { + "start": { + "column": 16, + "line": 4 + }, + "end": { + "column": 17, + "line": 4 + } + }, + "value": "#" + }, + { + "type": "HTMLIdentifier", + "range": [ + 48, + 54 + ], + "loc": { + "start": { + "column": 17, + "line": 4 + }, + "end": { + "column": 23, + "line": 4 + } + }, + "value": "suffix" + }, + { + "type": "HTMLTagClose", + "range": [ + 54, + 55 + ], + "loc": { + "start": { + "line": 4, + "column": 23 + }, + "end": { + "line": 4, + "column": 24 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 55, + 64 + ], + "loc": { + "start": { + "line": 4, + "column": 24 + }, + "end": { + "line": 5, + "column": 8 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 64, + 69 + ], + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 13 + } + }, + "value": "icon" + }, + { + "type": "HTMLIdentifier", + "range": [ + 70, + 74 + ], + "loc": { + "start": { + "line": 5, + "column": 14 + }, + "end": { + "line": 5, + "column": 18 + } + }, + "value": "name" + }, + { + "type": "HTMLAssociation", + "range": [ + 74, + 75 + ], + "loc": { + "start": { + "line": 5, + "column": 18 + }, + "end": { + "line": 5, + "column": 19 + } + }, + "value": "" + }, + { + "type": "HTMLLiteral", + "range": [ + 75, + 81 + ], + "loc": { + "start": { + "line": 5, + "column": 19 + }, + "end": { + "line": 5, + "column": 25 + } + }, + "value": "user" + }, + { + "type": "HTMLTagClose", + "range": [ + 81, + 82 + ], + "loc": { + "start": { + "line": 5, + "column": 25 + }, + "end": { + "line": 5, + "column": 26 + } + }, + "value": "" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 82, + 88 + ], + "loc": { + "start": { + "line": 5, + "column": 26 + }, + "end": { + "line": 5, + "column": 32 + } + }, + "value": "icon" + }, + { + "type": "HTMLTagClose", + "range": [ + 88, + 89 + ], + "loc": { + "start": { + "line": 5, + "column": 32 + }, + "end": { + "line": 5, + "column": 33 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 89, + 96 + ], + "loc": { + "start": { + "line": 5, + "column": 33 + }, + "end": { + "line": 6, + "column": 6 + } + }, + "value": "\n " + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 96, + 106 + ], + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 16 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 106, + 107 + ], + "loc": { + "start": { + "line": 6, + "column": 16 + }, + "end": { + "line": 6, + "column": 17 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 107, + 112 + ], + "loc": { + "start": { + "line": 6, + "column": 17 + }, + "end": { + "line": 7, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 112, + 119 + ], + "loc": { + "start": { + "line": 7, + "column": 4 + }, + "end": { + "line": 7, + "column": 11 + } + }, + "value": "input" + }, + { + "type": "HTMLTagClose", + "range": [ + 119, + 120 + ], + "loc": { + "start": { + "line": 7, + "column": 11 + }, + "end": { + "line": 7, + "column": 12 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 120, + 123 + ], + "loc": { + "start": { + "line": 7, + "column": 12 + }, + "end": { + "line": 8, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 123, + 128 + ], + "loc": { + "start": { + "line": 8, + "column": 2 + }, + "end": { + "line": 8, + "column": 7 + } + }, + "value": "div" + }, + { + "type": "HTMLTagClose", + "range": [ + 128, + 129 + ], + "loc": { + "start": { + "line": 8, + "column": 7 + }, + "end": { + "line": 8, + "column": 8 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 129, + 130 + ], + "loc": { + "start": { + "line": 8, + "column": 8 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 130, + 140 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 140, + 141 + ], + "loc": { + "start": { + "line": 9, + "column": 10 + }, + "end": { + "line": 9, + "column": 11 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 141, + 142 + ], + "loc": { + "start": { + "line": 9, + "column": 11 + }, + "end": { + "line": 10, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLWhitespace", + "range": [ + 210, + 211 + ], + "loc": { + "start": { + "line": 10, + "column": 68 + }, + "end": { + "line": 11, + "column": 0 + } + }, + "value": "\n" + } + ], + "comments": [ + { + "type": "HTMLComment", + "range": [ + 142, + 210 + ], + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 68 + } + }, + "value": " from https://github.com/vuejs/eslint-plugin-vue/issues/1292 " + } + ], + "errors": [] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/input-component/source.vue b/test/fixtures/ast/input-component/source.vue new file mode 100644 index 00000000..be80913a --- /dev/null +++ b/test/fixtures/ast/input-component/source.vue @@ -0,0 +1,10 @@ + + diff --git a/test/fixtures/ast/input-component/token-ranges.json b/test/fixtures/ast/input-component/token-ranges.json new file mode 100644 index 00000000..72ecce42 --- /dev/null +++ b/test/fixtures/ast/input-component/token-ranges.json @@ -0,0 +1,38 @@ +[ + "", + "\n ", + "", + "\n ", + "", + "\n ", + "", + "\n ", + "", + "", + "\n ", + "", + "\n ", + "", + "\n ", + "", + "\n", + "", + "\n", + "\n", + "" +] \ No newline at end of file diff --git a/test/fixtures/ast/input-component/tree.json b/test/fixtures/ast/input-component/tree.json new file mode 100644 index 00000000..859c2908 --- /dev/null +++ b/test/fixtures/ast/input-component/tree.json @@ -0,0 +1,162 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/ast/link-component/ast.json b/test/fixtures/ast/link-component/ast.json new file mode 100644 index 00000000..a0ea7e45 --- /dev/null +++ b/test/fixtures/ast/link-component/ast.json @@ -0,0 +1,2582 @@ +{ + "type": "Program", + "start": 0, + "end": 0, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 0 + } + }, + "range": [ + 0, + 0 + ], + "body": [], + "sourceType": "module", + "comments": [], + "tokens": [], + "templateBody": { + "type": "VElement", + "range": [ + 0, + 277 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 10, + "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": "VElement", + "range": [ + 13, + 265 + ], + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 9, + "column": 9 + } + }, + "name": "link", + "rawName": "Link", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 13, + 54 + ], + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 43 + } + }, + "selfClosing": false, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 19, + 27 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "directive": true, + "key": { + "type": "VDirectiveKey", + "range": [ + 19, + 22 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "name": { + "type": "VIdentifier", + "range": [ + 19, + 20 + ], + "loc": { + "start": { + "column": 8, + "line": 2 + }, + "end": { + "column": 9, + "line": 2 + } + }, + "name": "bind", + "rawName": ":" + }, + "argument": { + "type": "VIdentifier", + "range": [ + 20, + 22 + ], + "loc": { + "start": { + "column": 9, + "line": 2 + }, + "end": { + "column": 11, + "line": 2 + } + }, + "name": "to", + "rawName": "to" + }, + "modifiers": [] + }, + "value": { + "type": "VExpressionContainer", + "range": [ + 23, + 27 + ], + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "expression": { + "type": "Identifier", + "start": 24, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "range": [ + 24, + 26 + ], + "name": "to" + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 24, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "range": [ + 24, + 26 + ], + "name": "to" + }, + "mode": "r" + } + ] + } + }, + { + "type": "VAttribute", + "range": [ + 28, + 53 + ], + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 42 + } + }, + "directive": false, + "key": { + "type": "VIdentifier", + "range": [ + 28, + 33 + ], + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "name": "class", + "rawName": "class" + }, + "value": { + "type": "VLiteral", + "range": [ + 34, + 53 + ], + "loc": { + "start": { + "line": 2, + "column": 23 + }, + "end": { + "line": 2, + "column": 42 + } + }, + "value": "flex items-center" + } + } + ] + }, + "children": [ + { + "type": "VText", + "range": [ + 54, + 59 + ], + "loc": { + "start": { + "line": 2, + "column": 43 + }, + "end": { + "line": 3, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 59, + 242 + ], + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 7, + "column": 11 + } + }, + "name": "span", + "rawName": "span", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 59, + 113 + ], + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 58 + } + }, + "selfClosing": false, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 65, + 99 + ], + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 44 + } + }, + "directive": true, + "key": { + "type": "VDirectiveKey", + "range": [ + 65, + 69 + ], + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 14 + } + }, + "name": { + "type": "VIdentifier", + "range": [ + 65, + 69 + ], + "loc": { + "start": { + "column": 10, + "line": 3 + }, + "end": { + "column": 14, + "line": 3 + } + }, + "name": "if", + "rawName": "if" + }, + "argument": null, + "modifiers": [] + }, + "value": { + "type": "VExpressionContainer", + "range": [ + 70, + 99 + ], + "loc": { + "start": { + "line": 3, + "column": 15 + }, + "end": { + "line": 3, + "column": 44 + } + }, + "expression": { + "type": "LogicalExpression", + "start": 71, + "end": 98, + "loc": { + "start": { + "line": 3, + "column": 16 + }, + "end": { + "line": 3, + "column": 43 + } + }, + "range": [ + 71, + 98 + ], + "left": { + "type": "Identifier", + "start": 71, + "end": 81, + "loc": { + "start": { + "line": 3, + "column": 16 + }, + "end": { + "line": 3, + "column": 26 + } + }, + "range": [ + 71, + 81 + ], + "name": "prefixIcon" + }, + "operator": "||", + "right": { + "type": "MemberExpression", + "start": 85, + "end": 98, + "loc": { + "start": { + "line": 3, + "column": 30 + }, + "end": { + "line": 3, + "column": 43 + } + }, + "range": [ + 85, + 98 + ], + "object": { + "type": "Identifier", + "start": 85, + "end": 91, + "loc": { + "start": { + "line": 3, + "column": 30 + }, + "end": { + "line": 3, + "column": 36 + } + }, + "range": [ + 85, + 91 + ], + "name": "$slots" + }, + "property": { + "type": "Identifier", + "start": 92, + "end": 98, + "loc": { + "start": { + "line": 3, + "column": 37 + }, + "end": { + "line": 3, + "column": 43 + } + }, + "range": [ + 92, + 98 + ], + "name": "prefix" + }, + "computed": false, + "optional": false + } + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 71, + "end": 81, + "loc": { + "start": { + "line": 3, + "column": 16 + }, + "end": { + "line": 3, + "column": 26 + } + }, + "range": [ + 71, + 81 + ], + "name": "prefixIcon" + }, + "mode": "r" + }, + { + "id": { + "type": "Identifier", + "start": 85, + "end": 91, + "loc": { + "start": { + "line": 3, + "column": 30 + }, + "end": { + "line": 3, + "column": 36 + } + }, + "range": [ + 85, + 91 + ], + "name": "$slots" + }, + "mode": "r" + } + ] + } + }, + { + "type": "VAttribute", + "range": [ + 100, + 112 + ], + "loc": { + "start": { + "line": 3, + "column": 45 + }, + "end": { + "line": 3, + "column": 57 + } + }, + "directive": false, + "key": { + "type": "VIdentifier", + "range": [ + 100, + 105 + ], + "loc": { + "start": { + "line": 3, + "column": 45 + }, + "end": { + "line": 3, + "column": 50 + } + }, + "name": "class", + "rawName": "class" + }, + "value": { + "type": "VLiteral", + "range": [ + 106, + 112 + ], + "loc": { + "start": { + "line": 3, + "column": 51 + }, + "end": { + "line": 3, + "column": 57 + } + }, + "value": "mr-1" + } + } + ] + }, + "children": [ + { + "type": "VText", + "range": [ + 113, + 120 + ], + "loc": { + "start": { + "line": 3, + "column": 58 + }, + "end": { + "line": 4, + "column": 6 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 120, + 230 + ], + "loc": { + "start": { + "line": 4, + "column": 6 + }, + "end": { + "line": 6, + "column": 13 + } + }, + "name": "slot", + "rawName": "slot", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 120, + 140 + ], + "loc": { + "start": { + "line": 4, + "column": 6 + }, + "end": { + "line": 4, + "column": 26 + } + }, + "selfClosing": false, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 126, + 139 + ], + "loc": { + "start": { + "line": 4, + "column": 12 + }, + "end": { + "line": 4, + "column": 25 + } + }, + "directive": false, + "key": { + "type": "VIdentifier", + "range": [ + 126, + 130 + ], + "loc": { + "start": { + "line": 4, + "column": 12 + }, + "end": { + "line": 4, + "column": 16 + } + }, + "name": "name", + "rawName": "name" + }, + "value": { + "type": "VLiteral", + "range": [ + 131, + 139 + ], + "loc": { + "start": { + "line": 4, + "column": 17 + }, + "end": { + "line": 4, + "column": 25 + } + }, + "value": "prefix" + } + } + ] + }, + "children": [ + { + "type": "VText", + "range": [ + 140, + 149 + ], + "loc": { + "start": { + "line": 4, + "column": 26 + }, + "end": { + "line": 5, + "column": 8 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 149, + 216 + ], + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 75 + } + }, + "name": "fontawesomeicon", + "rawName": "FontAwesomeIcon", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 149, + 216 + ], + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 75 + } + }, + "selfClosing": true, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 166, + 183 + ], + "loc": { + "start": { + "line": 5, + "column": 25 + }, + "end": { + "line": 5, + "column": 42 + } + }, + "directive": true, + "key": { + "type": "VDirectiveKey", + "range": [ + 166, + 170 + ], + "loc": { + "start": { + "line": 5, + "column": 25 + }, + "end": { + "line": 5, + "column": 29 + } + }, + "name": { + "type": "VIdentifier", + "range": [ + 166, + 170 + ], + "loc": { + "start": { + "column": 25, + "line": 5 + }, + "end": { + "column": 29, + "line": 5 + } + }, + "name": "if", + "rawName": "if" + }, + "argument": null, + "modifiers": [] + }, + "value": { + "type": "VExpressionContainer", + "range": [ + 171, + 183 + ], + "loc": { + "start": { + "line": 5, + "column": 30 + }, + "end": { + "line": 5, + "column": 42 + } + }, + "expression": { + "type": "Identifier", + "start": 172, + "end": 182, + "loc": { + "start": { + "line": 5, + "column": 31 + }, + "end": { + "line": 5, + "column": 41 + } + }, + "range": [ + 172, + 182 + ], + "name": "prefixIcon" + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 172, + "end": 182, + "loc": { + "start": { + "line": 5, + "column": 31 + }, + "end": { + "line": 5, + "column": 41 + } + }, + "range": [ + 172, + 182 + ], + "name": "prefixIcon" + }, + "mode": "r" + } + ] + } + }, + { + "type": "VAttribute", + "range": [ + 184, + 202 + ], + "loc": { + "start": { + "line": 5, + "column": 43 + }, + "end": { + "line": 5, + "column": 61 + } + }, + "directive": true, + "key": { + "type": "VDirectiveKey", + "range": [ + 184, + 189 + ], + "loc": { + "start": { + "line": 5, + "column": 43 + }, + "end": { + "line": 5, + "column": 48 + } + }, + "name": { + "type": "VIdentifier", + "range": [ + 184, + 185 + ], + "loc": { + "start": { + "column": 43, + "line": 5 + }, + "end": { + "column": 44, + "line": 5 + } + }, + "name": "bind", + "rawName": ":" + }, + "argument": { + "type": "VIdentifier", + "range": [ + 185, + 189 + ], + "loc": { + "start": { + "column": 44, + "line": 5 + }, + "end": { + "column": 48, + "line": 5 + } + }, + "name": "icon", + "rawName": "icon" + }, + "modifiers": [] + }, + "value": { + "type": "VExpressionContainer", + "range": [ + 190, + 202 + ], + "loc": { + "start": { + "line": 5, + "column": 49 + }, + "end": { + "line": 5, + "column": 61 + } + }, + "expression": { + "type": "Identifier", + "start": 191, + "end": 201, + "loc": { + "start": { + "line": 5, + "column": 50 + }, + "end": { + "line": 5, + "column": 60 + } + }, + "range": [ + 191, + 201 + ], + "name": "prefixIcon" + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 191, + "end": 201, + "loc": { + "start": { + "line": 5, + "column": 50 + }, + "end": { + "line": 5, + "column": 60 + } + }, + "range": [ + 191, + 201 + ], + "name": "prefixIcon" + }, + "mode": "r" + } + ] + } + }, + { + "type": "VAttribute", + "range": [ + 203, + 213 + ], + "loc": { + "start": { + "line": 5, + "column": 62 + }, + "end": { + "line": 5, + "column": 72 + } + }, + "directive": false, + "key": { + "type": "VIdentifier", + "range": [ + 203, + 213 + ], + "loc": { + "start": { + "line": 5, + "column": 62 + }, + "end": { + "line": 5, + "column": 72 + } + }, + "name": "fixedwidth", + "rawName": "fixedWidth" + }, + "value": null + } + ] + }, + "children": [], + "endTag": null, + "variables": [] + }, + { + "type": "VText", + "range": [ + 216, + 223 + ], + "loc": { + "start": { + "line": 5, + "column": 75 + }, + "end": { + "line": 6, + "column": 6 + } + }, + "value": "\n " + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 223, + 230 + ], + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 13 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 230, + 235 + ], + "loc": { + "start": { + "line": 6, + "column": 13 + }, + "end": { + "line": 7, + "column": 4 + } + }, + "value": "\n " + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 235, + 242 + ], + "loc": { + "start": { + "line": 7, + "column": 4 + }, + "end": { + "line": 7, + "column": 11 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 242, + 247 + ], + "loc": { + "start": { + "line": 7, + "column": 11 + }, + "end": { + "line": 8, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 247, + 255 + ], + "loc": { + "start": { + "line": 8, + "column": 4 + }, + "end": { + "line": 8, + "column": 12 + } + }, + "name": "slot", + "rawName": "slot", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 247, + 255 + ], + "loc": { + "start": { + "line": 8, + "column": 4 + }, + "end": { + "line": 8, + "column": 12 + } + }, + "selfClosing": true, + "attributes": [] + }, + "children": [], + "endTag": null, + "variables": [] + }, + { + "type": "VText", + "range": [ + 255, + 258 + ], + "loc": { + "start": { + "line": 8, + "column": 12 + }, + "end": { + "line": 9, + "column": 2 + } + }, + "value": "\n " + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 258, + 265 + ], + "loc": { + "start": { + "line": 9, + "column": 2 + }, + "end": { + "line": 9, + "column": 9 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 265, + 266 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 10, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 266, + 277 + ], + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "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": "HTMLTagOpen", + "range": [ + 13, + 18 + ], + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "value": "link" + }, + { + "type": "Punctuator", + "range": [ + 19, + 20 + ], + "loc": { + "start": { + "column": 8, + "line": 2 + }, + "end": { + "column": 9, + "line": 2 + } + }, + "value": ":" + }, + { + "type": "HTMLIdentifier", + "range": [ + 20, + 22 + ], + "loc": { + "start": { + "column": 9, + "line": 2 + }, + "end": { + "column": 11, + "line": 2 + } + }, + "value": "to" + }, + { + "type": "HTMLAssociation", + "range": [ + 22, + 23 + ], + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 23, + 24 + ], + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "value": "to", + "start": 24, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "range": [ + 24, + 26 + ] + }, + { + "type": "Punctuator", + "range": [ + 26, + 27 + ], + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "value": "\"" + }, + { + "type": "HTMLIdentifier", + "range": [ + 28, + 33 + ], + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "value": "class" + }, + { + "type": "HTMLAssociation", + "range": [ + 33, + 34 + ], + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 2, + "column": 23 + } + }, + "value": "" + }, + { + "type": "HTMLLiteral", + "range": [ + 34, + 53 + ], + "loc": { + "start": { + "line": 2, + "column": 23 + }, + "end": { + "line": 2, + "column": 42 + } + }, + "value": "flex items-center" + }, + { + "type": "HTMLTagClose", + "range": [ + 53, + 54 + ], + "loc": { + "start": { + "line": 2, + "column": 42 + }, + "end": { + "line": 2, + "column": 43 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 54, + 59 + ], + "loc": { + "start": { + "line": 2, + "column": 43 + }, + "end": { + "line": 3, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 59, + 64 + ], + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "value": "span" + }, + { + "type": "HTMLIdentifier", + "range": [ + 65, + 69 + ], + "loc": { + "start": { + "column": 10, + "line": 3 + }, + "end": { + "column": 14, + "line": 3 + } + }, + "value": "v-if" + }, + { + "type": "HTMLAssociation", + "range": [ + 69, + 70 + ], + "loc": { + "start": { + "line": 3, + "column": 14 + }, + "end": { + "line": 3, + "column": 15 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 70, + 71 + ], + "loc": { + "start": { + "line": 3, + "column": 15 + }, + "end": { + "line": 3, + "column": 16 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "value": "prefixIcon", + "start": 71, + "end": 81, + "loc": { + "start": { + "line": 3, + "column": 16 + }, + "end": { + "line": 3, + "column": 26 + } + }, + "range": [ + 71, + 81 + ] + }, + { + "type": "Punctuator", + "value": "||", + "start": 82, + "end": 84, + "loc": { + "start": { + "line": 3, + "column": 27 + }, + "end": { + "line": 3, + "column": 29 + } + }, + "range": [ + 82, + 84 + ] + }, + { + "type": "Identifier", + "value": "$slots", + "start": 85, + "end": 91, + "loc": { + "start": { + "line": 3, + "column": 30 + }, + "end": { + "line": 3, + "column": 36 + } + }, + "range": [ + 85, + 91 + ] + }, + { + "type": "Punctuator", + "value": ".", + "start": 91, + "end": 92, + "loc": { + "start": { + "line": 3, + "column": 36 + }, + "end": { + "line": 3, + "column": 37 + } + }, + "range": [ + 91, + 92 + ] + }, + { + "type": "Identifier", + "value": "prefix", + "start": 92, + "end": 98, + "loc": { + "start": { + "line": 3, + "column": 37 + }, + "end": { + "line": 3, + "column": 43 + } + }, + "range": [ + 92, + 98 + ] + }, + { + "type": "Punctuator", + "range": [ + 98, + 99 + ], + "loc": { + "start": { + "line": 3, + "column": 43 + }, + "end": { + "line": 3, + "column": 44 + } + }, + "value": "\"" + }, + { + "type": "HTMLIdentifier", + "range": [ + 100, + 105 + ], + "loc": { + "start": { + "line": 3, + "column": 45 + }, + "end": { + "line": 3, + "column": 50 + } + }, + "value": "class" + }, + { + "type": "HTMLAssociation", + "range": [ + 105, + 106 + ], + "loc": { + "start": { + "line": 3, + "column": 50 + }, + "end": { + "line": 3, + "column": 51 + } + }, + "value": "" + }, + { + "type": "HTMLLiteral", + "range": [ + 106, + 112 + ], + "loc": { + "start": { + "line": 3, + "column": 51 + }, + "end": { + "line": 3, + "column": 57 + } + }, + "value": "mr-1" + }, + { + "type": "HTMLTagClose", + "range": [ + 112, + 113 + ], + "loc": { + "start": { + "line": 3, + "column": 57 + }, + "end": { + "line": 3, + "column": 58 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 113, + 120 + ], + "loc": { + "start": { + "line": 3, + "column": 58 + }, + "end": { + "line": 4, + "column": 6 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 120, + 125 + ], + "loc": { + "start": { + "line": 4, + "column": 6 + }, + "end": { + "line": 4, + "column": 11 + } + }, + "value": "slot" + }, + { + "type": "HTMLIdentifier", + "range": [ + 126, + 130 + ], + "loc": { + "start": { + "line": 4, + "column": 12 + }, + "end": { + "line": 4, + "column": 16 + } + }, + "value": "name" + }, + { + "type": "HTMLAssociation", + "range": [ + 130, + 131 + ], + "loc": { + "start": { + "line": 4, + "column": 16 + }, + "end": { + "line": 4, + "column": 17 + } + }, + "value": "" + }, + { + "type": "HTMLLiteral", + "range": [ + 131, + 139 + ], + "loc": { + "start": { + "line": 4, + "column": 17 + }, + "end": { + "line": 4, + "column": 25 + } + }, + "value": "prefix" + }, + { + "type": "HTMLTagClose", + "range": [ + 139, + 140 + ], + "loc": { + "start": { + "line": 4, + "column": 25 + }, + "end": { + "line": 4, + "column": 26 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 140, + 149 + ], + "loc": { + "start": { + "line": 4, + "column": 26 + }, + "end": { + "line": 5, + "column": 8 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 149, + 165 + ], + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 24 + } + }, + "value": "fontawesomeicon" + }, + { + "type": "HTMLIdentifier", + "range": [ + 166, + 170 + ], + "loc": { + "start": { + "column": 25, + "line": 5 + }, + "end": { + "column": 29, + "line": 5 + } + }, + "value": "v-if" + }, + { + "type": "HTMLAssociation", + "range": [ + 170, + 171 + ], + "loc": { + "start": { + "line": 5, + "column": 29 + }, + "end": { + "line": 5, + "column": 30 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 171, + 172 + ], + "loc": { + "start": { + "line": 5, + "column": 30 + }, + "end": { + "line": 5, + "column": 31 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "value": "prefixIcon", + "start": 172, + "end": 182, + "loc": { + "start": { + "line": 5, + "column": 31 + }, + "end": { + "line": 5, + "column": 41 + } + }, + "range": [ + 172, + 182 + ] + }, + { + "type": "Punctuator", + "range": [ + 182, + 183 + ], + "loc": { + "start": { + "line": 5, + "column": 41 + }, + "end": { + "line": 5, + "column": 42 + } + }, + "value": "\"" + }, + { + "type": "Punctuator", + "range": [ + 184, + 185 + ], + "loc": { + "start": { + "column": 43, + "line": 5 + }, + "end": { + "column": 44, + "line": 5 + } + }, + "value": ":" + }, + { + "type": "HTMLIdentifier", + "range": [ + 185, + 189 + ], + "loc": { + "start": { + "column": 44, + "line": 5 + }, + "end": { + "column": 48, + "line": 5 + } + }, + "value": "icon" + }, + { + "type": "HTMLAssociation", + "range": [ + 189, + 190 + ], + "loc": { + "start": { + "line": 5, + "column": 48 + }, + "end": { + "line": 5, + "column": 49 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 190, + 191 + ], + "loc": { + "start": { + "line": 5, + "column": 49 + }, + "end": { + "line": 5, + "column": 50 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "value": "prefixIcon", + "start": 191, + "end": 201, + "loc": { + "start": { + "line": 5, + "column": 50 + }, + "end": { + "line": 5, + "column": 60 + } + }, + "range": [ + 191, + 201 + ] + }, + { + "type": "Punctuator", + "range": [ + 201, + 202 + ], + "loc": { + "start": { + "line": 5, + "column": 60 + }, + "end": { + "line": 5, + "column": 61 + } + }, + "value": "\"" + }, + { + "type": "HTMLIdentifier", + "range": [ + 203, + 213 + ], + "loc": { + "start": { + "line": 5, + "column": 62 + }, + "end": { + "line": 5, + "column": 72 + } + }, + "value": "fixedwidth" + }, + { + "type": "HTMLSelfClosingTagClose", + "range": [ + 214, + 216 + ], + "loc": { + "start": { + "line": 5, + "column": 73 + }, + "end": { + "line": 5, + "column": 75 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 216, + 223 + ], + "loc": { + "start": { + "line": 5, + "column": 75 + }, + "end": { + "line": 6, + "column": 6 + } + }, + "value": "\n " + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 223, + 229 + ], + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 12 + } + }, + "value": "slot" + }, + { + "type": "HTMLTagClose", + "range": [ + 229, + 230 + ], + "loc": { + "start": { + "line": 6, + "column": 12 + }, + "end": { + "line": 6, + "column": 13 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 230, + 235 + ], + "loc": { + "start": { + "line": 6, + "column": 13 + }, + "end": { + "line": 7, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 235, + 241 + ], + "loc": { + "start": { + "line": 7, + "column": 4 + }, + "end": { + "line": 7, + "column": 10 + } + }, + "value": "span" + }, + { + "type": "HTMLTagClose", + "range": [ + 241, + 242 + ], + "loc": { + "start": { + "line": 7, + "column": 10 + }, + "end": { + "line": 7, + "column": 11 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 242, + 247 + ], + "loc": { + "start": { + "line": 7, + "column": 11 + }, + "end": { + "line": 8, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 247, + 252 + ], + "loc": { + "start": { + "line": 8, + "column": 4 + }, + "end": { + "line": 8, + "column": 9 + } + }, + "value": "slot" + }, + { + "type": "HTMLSelfClosingTagClose", + "range": [ + 253, + 255 + ], + "loc": { + "start": { + "line": 8, + "column": 10 + }, + "end": { + "line": 8, + "column": 12 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 255, + 258 + ], + "loc": { + "start": { + "line": 8, + "column": 12 + }, + "end": { + "line": 9, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 258, + 264 + ], + "loc": { + "start": { + "line": 9, + "column": 2 + }, + "end": { + "line": 9, + "column": 8 + } + }, + "value": "link" + }, + { + "type": "HTMLTagClose", + "range": [ + 264, + 265 + ], + "loc": { + "start": { + "line": 9, + "column": 8 + }, + "end": { + "line": 9, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 265, + 266 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 10, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 266, + 276 + ], + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 276, + 277 + ], + "loc": { + "start": { + "line": 10, + "column": 10 + }, + "end": { + "line": 10, + "column": 11 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 277, + 278 + ], + "loc": { + "start": { + "line": 10, + "column": 11 + }, + "end": { + "line": 11, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLWhitespace", + "range": [ + 346, + 347 + ], + "loc": { + "start": { + "line": 11, + "column": 68 + }, + "end": { + "line": 12, + "column": 0 + } + }, + "value": "\n" + } + ], + "comments": [ + { + "type": "HTMLComment", + "range": [ + 278, + 346 + ], + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 68 + } + }, + "value": " from https://github.com/vuejs/eslint-plugin-vue/issues/1439 " + } + ], + "errors": [ + { + "message": "non-void-html-element-start-tag-with-trailing-solidus", + "index": 149, + "lineNumber": 5, + "column": 8 + }, + { + "message": "non-void-html-element-start-tag-with-trailing-solidus", + "index": 247, + "lineNumber": 8, + "column": 4 + } + ] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/link-component/source.vue b/test/fixtures/ast/link-component/source.vue new file mode 100644 index 00000000..5f81ad87 --- /dev/null +++ b/test/fixtures/ast/link-component/source.vue @@ -0,0 +1,11 @@ + + diff --git a/test/fixtures/ast/link-component/token-ranges.json b/test/fixtures/ast/link-component/token-ranges.json new file mode 100644 index 00000000..4a579f82 --- /dev/null +++ b/test/fixtures/ast/link-component/token-ranges.json @@ -0,0 +1,70 @@ +[ + "", + "\n ", + "", + "\n ", + "", + "\n ", + "", + "\n ", + "", + "\n ", + "", + "\n ", + "", + "\n ", + "", + "\n ", + "", + "\n", + "", + "\n", + "\n", + "" +] \ No newline at end of file diff --git a/test/fixtures/ast/link-component/tree.json b/test/fixtures/ast/link-component/tree.json new file mode 100644 index 00000000..640c4961 --- /dev/null +++ b/test/fixtures/ast/link-component/tree.json @@ -0,0 +1,340 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/ast/math/ast.json b/test/fixtures/ast/math/ast.json index dacb9357..eaac83cf 100644 --- a/test/fixtures/ast/math/ast.json +++ b/test/fixtures/ast/math/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/multiple-scripts-10/ast.json b/test/fixtures/ast/multiple-scripts-10/ast.json new file mode 100644 index 00000000..dcf27584 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-10/ast.json @@ -0,0 +1,259 @@ +{ + "type": "Program", + "start": 8, + "end": 48, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "range": [ + 9, + 22 + ], + "body": [ + { + "type": "VariableDeclaration", + "start": 9, + "end": 22, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "range": [ + 9, + 22 + ], + "declarations": [ + { + "type": "VariableDeclarator", + "start": 13, + "end": 22, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "range": [ + 13, + 22 + ], + "id": { + "type": "Identifier", + "start": 13, + "end": 18, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "range": [ + 13, + 18 + ], + "name": "count" + }, + "init": { + "type": "Literal", + "start": 21, + "end": 22, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "range": [ + 21, + 22 + ], + "value": 0, + "raw": "0" + } + } + ], + "kind": "let" + } + ], + "sourceType": "module", + "comments": [], + "tokens": [ + { + "type": "Punctuator", + "range": [ + 0, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 34, + 48 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 14 + } + }, + "value": "" + } + ] +} \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-10/parser-options.json b/test/fixtures/ast/multiple-scripts-10/parser-options.json new file mode 100644 index 00000000..2104ca43 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-10/parser-options.json @@ -0,0 +1,3 @@ +{ + "sourceType": "module" +} diff --git a/test/fixtures/ast/multiple-scripts-10/requirements.json b/test/fixtures/ast/multiple-scripts-10/requirements.json new file mode 100644 index 00000000..36659b1f --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-10/requirements.json @@ -0,0 +1,3 @@ +{ + "eslint": ">=8" +} \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-10/source.vue b/test/fixtures/ast/multiple-scripts-10/source.vue new file mode 100644 index 00000000..9765b0b9 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-10/source.vue @@ -0,0 +1,5 @@ + + + diff --git a/test/fixtures/ast/multiple-scripts-10/token-ranges.json b/test/fixtures/ast/multiple-scripts-10/token-ranges.json new file mode 100644 index 00000000..0ede0b05 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-10/token-ranges.json @@ -0,0 +1,10 @@ +[ + "", + "" +] \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-10/tree.json b/test/fixtures/ast/multiple-scripts-10/tree.json new file mode 100644 index 00000000..0637a088 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-10/tree.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-11/ast.json b/test/fixtures/ast/multiple-scripts-11/ast.json new file mode 100644 index 00000000..0e4de961 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-11/ast.json @@ -0,0 +1,3340 @@ +{ + "type": "Program", + "start": 152, + "end": 383, + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 16, + "column": 1 + } + }, + "range": [ + 153, + 382 + ], + "body": [ + { + "type": "ImportDeclaration", + "start": 153, + "end": 188, + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 35 + } + }, + "range": [ + 153, + 188 + ], + "specifiers": [ + { + "type": "ImportSpecifier", + "start": 162, + "end": 165, + "loc": { + "start": { + "line": 7, + "column": 9 + }, + "end": { + "line": 7, + "column": 12 + } + }, + "range": [ + 162, + 165 + ], + "imported": { + "type": "Identifier", + "start": 162, + "end": 165, + "loc": { + "start": { + "line": 7, + "column": 9 + }, + "end": { + "line": 7, + "column": 12 + } + }, + "range": [ + 162, + 165 + ], + "name": "ref" + }, + "local": { + "type": "Identifier", + "start": 162, + "end": 165, + "loc": { + "start": { + "line": 7, + "column": 9 + }, + "end": { + "line": 7, + "column": 12 + } + }, + "range": [ + 162, + 165 + ], + "name": "ref" + } + }, + { + "type": "ImportSpecifier", + "start": 167, + "end": 175, + "loc": { + "start": { + "line": 7, + "column": 14 + }, + "end": { + "line": 7, + "column": 22 + } + }, + "range": [ + 167, + 175 + ], + "imported": { + "type": "Identifier", + "start": 167, + "end": 175, + "loc": { + "start": { + "line": 7, + "column": 14 + }, + "end": { + "line": 7, + "column": 22 + } + }, + "range": [ + 167, + 175 + ], + "name": "computed" + }, + "local": { + "type": "Identifier", + "start": 167, + "end": 175, + "loc": { + "start": { + "line": 7, + "column": 14 + }, + "end": { + "line": 7, + "column": 22 + } + }, + "range": [ + 167, + 175 + ], + "name": "computed" + } + } + ], + "source": { + "type": "Literal", + "start": 183, + "end": 188, + "loc": { + "start": { + "line": 7, + "column": 30 + }, + "end": { + "line": 7, + "column": 35 + } + }, + "range": [ + 183, + 188 + ], + "value": "vue", + "raw": "'vue'" + }, + "attributes": [] + }, + { + "type": "ImportDeclaration", + "start": 250, + "end": 281, + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 31 + } + }, + "range": [ + 250, + 281 + ], + "specifiers": [ + { + "type": "ImportSpecifier", + "start": 259, + "end": 267, + "loc": { + "start": { + "line": 8, + "column": 9 + }, + "end": { + "line": 8, + "column": 17 + } + }, + "range": [ + 259, + 267 + ], + "imported": { + "type": "Identifier", + "start": 259, + "end": 267, + "loc": { + "start": { + "line": 8, + "column": 9 + }, + "end": { + "line": 8, + "column": 17 + } + }, + "range": [ + 259, + 267 + ], + "name": "useStore" + }, + "local": { + "type": "Identifier", + "start": 259, + "end": 267, + "loc": { + "start": { + "line": 8, + "column": 9 + }, + "end": { + "line": 8, + "column": 17 + } + }, + "range": [ + 259, + 267 + ], + "name": "useStore" + } + } + ], + "source": { + "type": "Literal", + "start": 275, + "end": 281, + "loc": { + "start": { + "line": 8, + "column": 25 + }, + "end": { + "line": 8, + "column": 31 + } + }, + "range": [ + 275, + 281 + ], + "value": "vuex", + "raw": "'vuex'" + }, + "attributes": [] + }, + { + "type": "ExportDefaultDeclaration", + "start": 328, + "end": 382, + "loc": { + "start": { + "line": 12, + "column": 0 + }, + "end": { + "line": 16, + "column": 1 + } + }, + "range": [ + 328, + 382 + ], + "declaration": { + "type": "ObjectExpression", + "start": 343, + "end": 382, + "loc": { + "start": { + "line": 12, + "column": 15 + }, + "end": { + "line": 16, + "column": 1 + } + }, + "range": [ + 343, + 382 + ], + "properties": [ + { + "type": "Property", + "start": 347, + "end": 358, + "loc": { + "start": { + "line": 13, + "column": 2 + }, + "end": { + "line": 13, + "column": 13 + } + }, + "range": [ + 347, + 358 + ], + "method": false, + "shorthand": false, + "computed": false, + "key": { + "type": "Identifier", + "start": 347, + "end": 351, + "loc": { + "start": { + "line": 13, + "column": 2 + }, + "end": { + "line": 13, + "column": 6 + } + }, + "range": [ + 347, + 351 + ], + "name": "name" + }, + "value": { + "type": "Literal", + "start": 353, + "end": 358, + "loc": { + "start": { + "line": 13, + "column": 8 + }, + "end": { + "line": 13, + "column": 13 + } + }, + "range": [ + 353, + 358 + ], + "value": "App", + "raw": "'App'" + }, + "kind": "init" + }, + { + "type": "Property", + "start": 362, + "end": 379, + "loc": { + "start": { + "line": 14, + "column": 2 + }, + "end": { + "line": 15, + "column": 3 + } + }, + "range": [ + 362, + 379 + ], + "method": false, + "shorthand": false, + "computed": false, + "key": { + "type": "Identifier", + "start": 362, + "end": 372, + "loc": { + "start": { + "line": 14, + "column": 2 + }, + "end": { + "line": 14, + "column": 12 + } + }, + "range": [ + 362, + 372 + ], + "name": "components" + }, + "value": { + "type": "ObjectExpression", + "start": 374, + "end": 379, + "loc": { + "start": { + "line": 14, + "column": 14 + }, + "end": { + "line": 15, + "column": 3 + } + }, + "range": [ + 374, + 379 + ], + "properties": [] + }, + "kind": "init" + } + ] + } + } + ], + "sourceType": "module", + "comments": [ + { + "type": "Line", + "value": " each time uncomment error will print. anything from 'vue'", + "start": 189, + "end": 249, + "range": [ + 189, + 249 + ], + "loc": { + "start": { + "line": 7, + "column": 36 + }, + "end": { + "line": 7, + "column": 96 + } + } + }, + { + "type": "Line", + "value": " others like this is ok", + "start": 282, + "end": 307, + "range": [ + 282, + 307 + ], + "loc": { + "start": { + "line": 8, + "column": 32 + }, + "end": { + "line": 8, + "column": 57 + } + } + } + ], + "tokens": [ + { + "type": "Punctuator", + "range": [ + 138, + 152 + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 14 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 319, + 327 + ], + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 8 + } + }, + "value": "" + } + ], + "templateBody": { + "type": "VElement", + "range": [ + 64, + 137 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 5, + "column": 11 + } + }, + "name": "template", + "rawName": "template", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 64, + 74 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 74, + 77 + ], + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 3, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 77, + 125 + ], + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 4, + "column": 8 + } + }, + "name": "div", + "rawName": "div", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 77, + 116 + ], + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 41 + } + }, + "selfClosing": false, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 82, + 93 + ], + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 18 + } + }, + "directive": false, + "key": { + "type": "VIdentifier", + "range": [ + 82, + 87 + ], + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 12 + } + }, + "name": "class", + "rawName": "class" + }, + "value": { + "type": "VLiteral", + "range": [ + 88, + 93 + ], + "loc": { + "start": { + "line": 3, + "column": 13 + }, + "end": { + "line": 3, + "column": 18 + } + }, + "value": "f-c" + } + }, + { + "type": "VAttribute", + "range": [ + 94, + 115 + ], + "loc": { + "start": { + "line": 3, + "column": 19 + }, + "end": { + "line": 3, + "column": 40 + } + }, + "directive": false, + "key": { + "type": "VIdentifier", + "range": [ + 94, + 99 + ], + "loc": { + "start": { + "line": 3, + "column": 19 + }, + "end": { + "line": 3, + "column": 24 + } + }, + "name": "style", + "rawName": "style" + }, + "value": { + "type": "VLiteral", + "range": [ + 100, + 115 + ], + "loc": { + "start": { + "line": 3, + "column": 25 + }, + "end": { + "line": 3, + "column": 40 + } + }, + "value": "height: 100%;" + } + } + ] + }, + "children": [ + { + "type": "VText", + "range": [ + 116, + 119 + ], + "loc": { + "start": { + "line": 3, + "column": 41 + }, + "end": { + "line": 4, + "column": 2 + } + }, + "value": "\n " + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 119, + 125 + ], + "loc": { + "start": { + "line": 4, + "column": 2 + }, + "end": { + "line": 4, + "column": 8 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 125, + 126 + ], + "loc": { + "start": { + "line": 4, + "column": 8 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 126, + 137 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 11 + } + } + }, + "variables": [], + "tokens": [ + { + "type": "HTMLWhitespace", + "range": [ + 63, + 64 + ], + "loc": { + "start": { + "line": 1, + "column": 63 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 64, + 73 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 73, + 74 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 74, + 77 + ], + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 3, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 77, + 81 + ], + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 6 + } + }, + "value": "div" + }, + { + "type": "HTMLIdentifier", + "range": [ + 82, + 87 + ], + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 12 + } + }, + "value": "class" + }, + { + "type": "HTMLAssociation", + "range": [ + 87, + 88 + ], + "loc": { + "start": { + "line": 3, + "column": 12 + }, + "end": { + "line": 3, + "column": 13 + } + }, + "value": "" + }, + { + "type": "HTMLLiteral", + "range": [ + 88, + 93 + ], + "loc": { + "start": { + "line": 3, + "column": 13 + }, + "end": { + "line": 3, + "column": 18 + } + }, + "value": "f-c" + }, + { + "type": "HTMLIdentifier", + "range": [ + 94, + 99 + ], + "loc": { + "start": { + "line": 3, + "column": 19 + }, + "end": { + "line": 3, + "column": 24 + } + }, + "value": "style" + }, + { + "type": "HTMLAssociation", + "range": [ + 99, + 100 + ], + "loc": { + "start": { + "line": 3, + "column": 24 + }, + "end": { + "line": 3, + "column": 25 + } + }, + "value": "" + }, + { + "type": "HTMLLiteral", + "range": [ + 100, + 115 + ], + "loc": { + "start": { + "line": 3, + "column": 25 + }, + "end": { + "line": 3, + "column": 40 + } + }, + "value": "height: 100%;" + }, + { + "type": "HTMLTagClose", + "range": [ + 115, + 116 + ], + "loc": { + "start": { + "line": 3, + "column": 40 + }, + "end": { + "line": 3, + "column": 41 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 116, + 119 + ], + "loc": { + "start": { + "line": 3, + "column": 41 + }, + "end": { + "line": 4, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 119, + 124 + ], + "loc": { + "start": { + "line": 4, + "column": 2 + }, + "end": { + "line": 4, + "column": 7 + } + }, + "value": "div" + }, + { + "type": "HTMLTagClose", + "range": [ + 124, + 125 + ], + "loc": { + "start": { + "line": 4, + "column": 7 + }, + "end": { + "line": 4, + "column": 8 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 125, + 126 + ], + "loc": { + "start": { + "line": 4, + "column": 8 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 126, + 136 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 136, + 137 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 11 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 137, + 138 + ], + "loc": { + "start": { + "line": 5, + "column": 11 + }, + "end": { + "line": 6, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 138, + 145 + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLIdentifier", + "range": [ + 146, + 151 + ], + "loc": { + "start": { + "line": 6, + "column": 8 + }, + "end": { + "line": 6, + "column": 13 + } + }, + "value": "setup" + }, + { + "type": "HTMLTagClose", + "range": [ + 151, + 152 + ], + "loc": { + "start": { + "line": 6, + "column": 13 + }, + "end": { + "line": 6, + "column": 14 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 152, + 153 + ], + "loc": { + "start": { + "line": 6, + "column": 14 + }, + "end": { + "line": 7, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 153, + 159 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 6 + } + }, + "value": "import" + }, + { + "type": "HTMLWhitespace", + "range": [ + 159, + 160 + ], + "loc": { + "start": { + "line": 7, + "column": 6 + }, + "end": { + "line": 7, + "column": 7 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 160, + 161 + ], + "loc": { + "start": { + "line": 7, + "column": 7 + }, + "end": { + "line": 7, + "column": 8 + } + }, + "value": "{" + }, + { + "type": "HTMLWhitespace", + "range": [ + 161, + 162 + ], + "loc": { + "start": { + "line": 7, + "column": 8 + }, + "end": { + "line": 7, + "column": 9 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 162, + 166 + ], + "loc": { + "start": { + "line": 7, + "column": 9 + }, + "end": { + "line": 7, + "column": 13 + } + }, + "value": "ref," + }, + { + "type": "HTMLWhitespace", + "range": [ + 166, + 167 + ], + "loc": { + "start": { + "line": 7, + "column": 13 + }, + "end": { + "line": 7, + "column": 14 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 167, + 175 + ], + "loc": { + "start": { + "line": 7, + "column": 14 + }, + "end": { + "line": 7, + "column": 22 + } + }, + "value": "computed" + }, + { + "type": "HTMLWhitespace", + "range": [ + 175, + 176 + ], + "loc": { + "start": { + "line": 7, + "column": 22 + }, + "end": { + "line": 7, + "column": 23 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 176, + 177 + ], + "loc": { + "start": { + "line": 7, + "column": 23 + }, + "end": { + "line": 7, + "column": 24 + } + }, + "value": "}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 177, + 178 + ], + "loc": { + "start": { + "line": 7, + "column": 24 + }, + "end": { + "line": 7, + "column": 25 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 178, + 182 + ], + "loc": { + "start": { + "line": 7, + "column": 25 + }, + "end": { + "line": 7, + "column": 29 + } + }, + "value": "from" + }, + { + "type": "HTMLWhitespace", + "range": [ + 182, + 183 + ], + "loc": { + "start": { + "line": 7, + "column": 29 + }, + "end": { + "line": 7, + "column": 30 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 183, + 188 + ], + "loc": { + "start": { + "line": 7, + "column": 30 + }, + "end": { + "line": 7, + "column": 35 + } + }, + "value": "'vue'" + }, + { + "type": "HTMLWhitespace", + "range": [ + 188, + 189 + ], + "loc": { + "start": { + "line": 7, + "column": 35 + }, + "end": { + "line": 7, + "column": 36 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 189, + 191 + ], + "loc": { + "start": { + "line": 7, + "column": 36 + }, + "end": { + "line": 7, + "column": 38 + } + }, + "value": "//" + }, + { + "type": "HTMLWhitespace", + "range": [ + 191, + 192 + ], + "loc": { + "start": { + "line": 7, + "column": 38 + }, + "end": { + "line": 7, + "column": 39 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 192, + 196 + ], + "loc": { + "start": { + "line": 7, + "column": 39 + }, + "end": { + "line": 7, + "column": 43 + } + }, + "value": "each" + }, + { + "type": "HTMLWhitespace", + "range": [ + 196, + 197 + ], + "loc": { + "start": { + "line": 7, + "column": 43 + }, + "end": { + "line": 7, + "column": 44 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 197, + 201 + ], + "loc": { + "start": { + "line": 7, + "column": 44 + }, + "end": { + "line": 7, + "column": 48 + } + }, + "value": "time" + }, + { + "type": "HTMLWhitespace", + "range": [ + 201, + 202 + ], + "loc": { + "start": { + "line": 7, + "column": 48 + }, + "end": { + "line": 7, + "column": 49 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 202, + 211 + ], + "loc": { + "start": { + "line": 7, + "column": 49 + }, + "end": { + "line": 7, + "column": 58 + } + }, + "value": "uncomment" + }, + { + "type": "HTMLWhitespace", + "range": [ + 211, + 212 + ], + "loc": { + "start": { + "line": 7, + "column": 58 + }, + "end": { + "line": 7, + "column": 59 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 212, + 217 + ], + "loc": { + "start": { + "line": 7, + "column": 59 + }, + "end": { + "line": 7, + "column": 64 + } + }, + "value": "error" + }, + { + "type": "HTMLWhitespace", + "range": [ + 217, + 218 + ], + "loc": { + "start": { + "line": 7, + "column": 64 + }, + "end": { + "line": 7, + "column": 65 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 218, + 222 + ], + "loc": { + "start": { + "line": 7, + "column": 65 + }, + "end": { + "line": 7, + "column": 69 + } + }, + "value": "will" + }, + { + "type": "HTMLWhitespace", + "range": [ + 222, + 223 + ], + "loc": { + "start": { + "line": 7, + "column": 69 + }, + "end": { + "line": 7, + "column": 70 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 223, + 229 + ], + "loc": { + "start": { + "line": 7, + "column": 70 + }, + "end": { + "line": 7, + "column": 76 + } + }, + "value": "print." + }, + { + "type": "HTMLWhitespace", + "range": [ + 229, + 230 + ], + "loc": { + "start": { + "line": 7, + "column": 76 + }, + "end": { + "line": 7, + "column": 77 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 230, + 238 + ], + "loc": { + "start": { + "line": 7, + "column": 77 + }, + "end": { + "line": 7, + "column": 85 + } + }, + "value": "anything" + }, + { + "type": "HTMLWhitespace", + "range": [ + 238, + 239 + ], + "loc": { + "start": { + "line": 7, + "column": 85 + }, + "end": { + "line": 7, + "column": 86 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 239, + 243 + ], + "loc": { + "start": { + "line": 7, + "column": 86 + }, + "end": { + "line": 7, + "column": 90 + } + }, + "value": "from" + }, + { + "type": "HTMLWhitespace", + "range": [ + 243, + 244 + ], + "loc": { + "start": { + "line": 7, + "column": 90 + }, + "end": { + "line": 7, + "column": 91 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 244, + 249 + ], + "loc": { + "start": { + "line": 7, + "column": 91 + }, + "end": { + "line": 7, + "column": 96 + } + }, + "value": "'vue'" + }, + { + "type": "HTMLWhitespace", + "range": [ + 249, + 250 + ], + "loc": { + "start": { + "line": 7, + "column": 96 + }, + "end": { + "line": 8, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 250, + 256 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 6 + } + }, + "value": "import" + }, + { + "type": "HTMLWhitespace", + "range": [ + 256, + 257 + ], + "loc": { + "start": { + "line": 8, + "column": 6 + }, + "end": { + "line": 8, + "column": 7 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 257, + 258 + ], + "loc": { + "start": { + "line": 8, + "column": 7 + }, + "end": { + "line": 8, + "column": 8 + } + }, + "value": "{" + }, + { + "type": "HTMLWhitespace", + "range": [ + 258, + 259 + ], + "loc": { + "start": { + "line": 8, + "column": 8 + }, + "end": { + "line": 8, + "column": 9 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 259, + 267 + ], + "loc": { + "start": { + "line": 8, + "column": 9 + }, + "end": { + "line": 8, + "column": 17 + } + }, + "value": "useStore" + }, + { + "type": "HTMLWhitespace", + "range": [ + 267, + 268 + ], + "loc": { + "start": { + "line": 8, + "column": 17 + }, + "end": { + "line": 8, + "column": 18 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 268, + 269 + ], + "loc": { + "start": { + "line": 8, + "column": 18 + }, + "end": { + "line": 8, + "column": 19 + } + }, + "value": "}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 269, + 270 + ], + "loc": { + "start": { + "line": 8, + "column": 19 + }, + "end": { + "line": 8, + "column": 20 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 270, + 274 + ], + "loc": { + "start": { + "line": 8, + "column": 20 + }, + "end": { + "line": 8, + "column": 24 + } + }, + "value": "from" + }, + { + "type": "HTMLWhitespace", + "range": [ + 274, + 275 + ], + "loc": { + "start": { + "line": 8, + "column": 24 + }, + "end": { + "line": 8, + "column": 25 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 275, + 281 + ], + "loc": { + "start": { + "line": 8, + "column": 25 + }, + "end": { + "line": 8, + "column": 31 + } + }, + "value": "'vuex'" + }, + { + "type": "HTMLWhitespace", + "range": [ + 281, + 282 + ], + "loc": { + "start": { + "line": 8, + "column": 31 + }, + "end": { + "line": 8, + "column": 32 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 282, + 284 + ], + "loc": { + "start": { + "line": 8, + "column": 32 + }, + "end": { + "line": 8, + "column": 34 + } + }, + "value": "//" + }, + { + "type": "HTMLWhitespace", + "range": [ + 284, + 285 + ], + "loc": { + "start": { + "line": 8, + "column": 34 + }, + "end": { + "line": 8, + "column": 35 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 285, + 291 + ], + "loc": { + "start": { + "line": 8, + "column": 35 + }, + "end": { + "line": 8, + "column": 41 + } + }, + "value": "others" + }, + { + "type": "HTMLWhitespace", + "range": [ + 291, + 292 + ], + "loc": { + "start": { + "line": 8, + "column": 41 + }, + "end": { + "line": 8, + "column": 42 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 292, + 296 + ], + "loc": { + "start": { + "line": 8, + "column": 42 + }, + "end": { + "line": 8, + "column": 46 + } + }, + "value": "like" + }, + { + "type": "HTMLWhitespace", + "range": [ + 296, + 297 + ], + "loc": { + "start": { + "line": 8, + "column": 46 + }, + "end": { + "line": 8, + "column": 47 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 297, + 301 + ], + "loc": { + "start": { + "line": 8, + "column": 47 + }, + "end": { + "line": 8, + "column": 51 + } + }, + "value": "this" + }, + { + "type": "HTMLWhitespace", + "range": [ + 301, + 302 + ], + "loc": { + "start": { + "line": 8, + "column": 51 + }, + "end": { + "line": 8, + "column": 52 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 302, + 304 + ], + "loc": { + "start": { + "line": 8, + "column": 52 + }, + "end": { + "line": 8, + "column": 54 + } + }, + "value": "is" + }, + { + "type": "HTMLWhitespace", + "range": [ + 304, + 305 + ], + "loc": { + "start": { + "line": 8, + "column": 54 + }, + "end": { + "line": 8, + "column": 55 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 305, + 307 + ], + "loc": { + "start": { + "line": 8, + "column": 55 + }, + "end": { + "line": 8, + "column": 57 + } + }, + "value": "ok" + }, + { + "type": "HTMLWhitespace", + "range": [ + 307, + 308 + ], + "loc": { + "start": { + "line": 8, + "column": 57 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 308, + 316 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 316, + 317 + ], + "loc": { + "start": { + "line": 9, + "column": 8 + }, + "end": { + "line": 9, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 317, + 319 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 11, + "column": 0 + } + }, + "value": "\n\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 319, + 326 + ], + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 326, + 327 + ], + "loc": { + "start": { + "line": 11, + "column": 7 + }, + "end": { + "line": 11, + "column": 8 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 327, + 328 + ], + "loc": { + "start": { + "line": 11, + "column": 8 + }, + "end": { + "line": 12, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 328, + 334 + ], + "loc": { + "start": { + "line": 12, + "column": 0 + }, + "end": { + "line": 12, + "column": 6 + } + }, + "value": "export" + }, + { + "type": "HTMLWhitespace", + "range": [ + 334, + 335 + ], + "loc": { + "start": { + "line": 12, + "column": 6 + }, + "end": { + "line": 12, + "column": 7 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 335, + 342 + ], + "loc": { + "start": { + "line": 12, + "column": 7 + }, + "end": { + "line": 12, + "column": 14 + } + }, + "value": "default" + }, + { + "type": "HTMLWhitespace", + "range": [ + 342, + 343 + ], + "loc": { + "start": { + "line": 12, + "column": 14 + }, + "end": { + "line": 12, + "column": 15 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 343, + 344 + ], + "loc": { + "start": { + "line": 12, + "column": 15 + }, + "end": { + "line": 12, + "column": 16 + } + }, + "value": "{" + }, + { + "type": "HTMLWhitespace", + "range": [ + 344, + 347 + ], + "loc": { + "start": { + "line": 12, + "column": 16 + }, + "end": { + "line": 13, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "HTMLRawText", + "range": [ + 347, + 352 + ], + "loc": { + "start": { + "line": 13, + "column": 2 + }, + "end": { + "line": 13, + "column": 7 + } + }, + "value": "name:" + }, + { + "type": "HTMLWhitespace", + "range": [ + 352, + 353 + ], + "loc": { + "start": { + "line": 13, + "column": 7 + }, + "end": { + "line": 13, + "column": 8 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 353, + 359 + ], + "loc": { + "start": { + "line": 13, + "column": 8 + }, + "end": { + "line": 13, + "column": 14 + } + }, + "value": "'App'," + }, + { + "type": "HTMLWhitespace", + "range": [ + 359, + 362 + ], + "loc": { + "start": { + "line": 13, + "column": 14 + }, + "end": { + "line": 14, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "HTMLRawText", + "range": [ + 362, + 373 + ], + "loc": { + "start": { + "line": 14, + "column": 2 + }, + "end": { + "line": 14, + "column": 13 + } + }, + "value": "components:" + }, + { + "type": "HTMLWhitespace", + "range": [ + 373, + 374 + ], + "loc": { + "start": { + "line": 14, + "column": 13 + }, + "end": { + "line": 14, + "column": 14 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 374, + 375 + ], + "loc": { + "start": { + "line": 14, + "column": 14 + }, + "end": { + "line": 14, + "column": 15 + } + }, + "value": "{" + }, + { + "type": "HTMLWhitespace", + "range": [ + 375, + 378 + ], + "loc": { + "start": { + "line": 14, + "column": 15 + }, + "end": { + "line": 15, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "HTMLRawText", + "range": [ + 378, + 380 + ], + "loc": { + "start": { + "line": 15, + "column": 2 + }, + "end": { + "line": 15, + "column": 4 + } + }, + "value": "}," + }, + { + "type": "HTMLWhitespace", + "range": [ + 380, + 381 + ], + "loc": { + "start": { + "line": 15, + "column": 4 + }, + "end": { + "line": 16, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 381, + 382 + ], + "loc": { + "start": { + "line": 16, + "column": 0 + }, + "end": { + "line": 16, + "column": 1 + } + }, + "value": "}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 382, + 383 + ], + "loc": { + "start": { + "line": 16, + "column": 1 + }, + "end": { + "line": 17, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 383, + 391 + ], + "loc": { + "start": { + "line": 17, + "column": 0 + }, + "end": { + "line": 17, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 391, + 392 + ], + "loc": { + "start": { + "line": 17, + "column": 8 + }, + "end": { + "line": 17, + "column": 9 + } + }, + "value": "" + } + ], + "comments": [ + { + "type": "HTMLComment", + "range": [ + 0, + 63 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 63 + } + }, + "value": " https://github.com/vuejs/eslint-plugin-vue/issues/1690 " + } + ], + "errors": [] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-11/parser-options.json b/test/fixtures/ast/multiple-scripts-11/parser-options.json new file mode 100644 index 00000000..2104ca43 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-11/parser-options.json @@ -0,0 +1,3 @@ +{ + "sourceType": "module" +} diff --git a/test/fixtures/ast/multiple-scripts-11/requirements.json b/test/fixtures/ast/multiple-scripts-11/requirements.json new file mode 100644 index 00000000..36659b1f --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-11/requirements.json @@ -0,0 +1,3 @@ +{ + "eslint": ">=8" +} \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-11/scope.json b/test/fixtures/ast/multiple-scripts-11/scope.json new file mode 100644 index 00000000..23e5c0ee --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-11/scope.json @@ -0,0 +1,133 @@ +{ + "type": "global", + "variables": [], + "references": [], + "childScopes": [ + { + "type": "module", + "variables": [ + { + "name": "ref", + "identifiers": [ + { + "type": "Identifier", + "name": "ref", + "loc": { + "start": { + "line": 7, + "column": 9 + }, + "end": { + "line": 7, + "column": 12 + } + } + } + ], + "defs": [ + { + "type": "ImportBinding", + "node": { + "type": "ImportSpecifier", + "loc": { + "start": { + "line": 7, + "column": 9 + }, + "end": { + "line": 7, + "column": 12 + } + } + }, + "name": "ref" + } + ], + "references": [] + }, + { + "name": "computed", + "identifiers": [ + { + "type": "Identifier", + "name": "computed", + "loc": { + "start": { + "line": 7, + "column": 14 + }, + "end": { + "line": 7, + "column": 22 + } + } + } + ], + "defs": [ + { + "type": "ImportBinding", + "node": { + "type": "ImportSpecifier", + "loc": { + "start": { + "line": 7, + "column": 14 + }, + "end": { + "line": 7, + "column": 22 + } + } + }, + "name": "computed" + } + ], + "references": [] + }, + { + "name": "useStore", + "identifiers": [ + { + "type": "Identifier", + "name": "useStore", + "loc": { + "start": { + "line": 8, + "column": 9 + }, + "end": { + "line": 8, + "column": 17 + } + } + } + ], + "defs": [ + { + "type": "ImportBinding", + "node": { + "type": "ImportSpecifier", + "loc": { + "start": { + "line": 8, + "column": 9 + }, + "end": { + "line": 8, + "column": 17 + } + } + }, + "name": "useStore" + } + ], + "references": [] + } + ], + "references": [], + "childScopes": [], + "through": [] + } + ], + "through": [] +} \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-11/source.vue b/test/fixtures/ast/multiple-scripts-11/source.vue new file mode 100644 index 00000000..923d3c47 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-11/source.vue @@ -0,0 +1,17 @@ + + + + + \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-11/token-ranges.json b/test/fixtures/ast/multiple-scripts-11/token-ranges.json new file mode 100644 index 00000000..b02c52a8 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-11/token-ranges.json @@ -0,0 +1,143 @@ +[ + "", + "", + "// each time uncomment error will print. anything from 'vue'", + "// others like this is ok", + "\n", + "", + "\n ", + "", + "\n ", + "", + "\n", + "", + "\n", + "", + "\n", + "import", + " ", + "{", + " ", + "ref,", + " ", + "computed", + " ", + "}", + " ", + "from", + " ", + "'vue'", + " ", + "//", + " ", + "each", + " ", + "time", + " ", + "uncomment", + " ", + "error", + " ", + "will", + " ", + "print.", + " ", + "anything", + " ", + "from", + " ", + "'vue'", + "\n", + "import", + " ", + "{", + " ", + "useStore", + " ", + "}", + " ", + "from", + " ", + "'vuex'", + " ", + "//", + " ", + "others", + " ", + "like", + " ", + "this", + " ", + "is", + " ", + "ok", + "\n", + "", + "\n\n", + "", + "\n", + "export", + " ", + "default", + " ", + "{", + "\n ", + "name:", + " ", + "'App',", + "\n ", + "components:", + " ", + "{", + "\n ", + "},", + "\n", + "}", + "\n", + "", + "" +] \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-11/tree.json b/test/fixtures/ast/multiple-scripts-11/tree.json new file mode 100644 index 00000000..9ef29fd9 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-11/tree.json @@ -0,0 +1,82 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-2/ast.json b/test/fixtures/ast/multiple-scripts-2/ast.json new file mode 100644 index 00000000..345cdacc --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-2/ast.json @@ -0,0 +1,886 @@ +{ + "type": "Program", + "start": 8, + "end": 106, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 8, + "column": 17 + } + }, + "range": [ + 9, + 105 + ], + "body": [ + { + "type": "ImportDeclaration", + "start": 9, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "range": [ + 9, + 28 + ], + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start": 16, + "end": 17, + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "range": [ + 16, + 17 + ], + "local": { + "type": "Identifier", + "start": 16, + "end": 17, + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "range": [ + 16, + 17 + ], + "name": "A" + } + } + ], + "source": { + "type": "Literal", + "start": 23, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "range": [ + 23, + 28 + ], + "value": "./a", + "raw": "'./a'" + }, + "attributes": [] + }, + { + "type": "ImportDeclaration", + "start": 55, + "end": 74, + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 19 + } + }, + "range": [ + 55, + 74 + ], + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start": 62, + "end": 63, + "loc": { + "start": { + "line": 6, + "column": 7 + }, + "end": { + "line": 6, + "column": 8 + } + }, + "range": [ + 62, + 63 + ], + "local": { + "type": "Identifier", + "start": 62, + "end": 63, + "loc": { + "start": { + "line": 6, + "column": 7 + }, + "end": { + "line": 6, + "column": 8 + } + }, + "range": [ + 62, + 63 + ], + "name": "B" + } + } + ], + "source": { + "type": "Literal", + "start": 69, + "end": 74, + "loc": { + "start": { + "line": 6, + "column": 14 + }, + "end": { + "line": 6, + "column": 19 + } + }, + "range": [ + 69, + 74 + ], + "value": "./a", + "raw": "'./a'" + }, + "attributes": [] + }, + { + "type": "VariableDeclaration", + "start": 75, + "end": 87, + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 12 + } + }, + "range": [ + 75, + 87 + ], + "declarations": [ + { + "type": "VariableDeclarator", + "start": 81, + "end": 87, + "loc": { + "start": { + "line": 7, + "column": 6 + }, + "end": { + "line": 7, + "column": 12 + } + }, + "range": [ + 81, + 87 + ], + "id": { + "type": "Identifier", + "start": 81, + "end": 82, + "loc": { + "start": { + "line": 7, + "column": 6 + }, + "end": { + "line": 7, + "column": 7 + } + }, + "range": [ + 81, + 82 + ], + "name": "c" + }, + "init": { + "type": "Literal", + "start": 85, + "end": 87, + "loc": { + "start": { + "line": 7, + "column": 10 + }, + "end": { + "line": 7, + "column": 12 + } + }, + "range": [ + 85, + 87 + ], + "value": 42, + "raw": "42" + } + } + ], + "kind": "const" + }, + { + "type": "VariableDeclaration", + "start": 88, + "end": 105, + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 17 + } + }, + "range": [ + 88, + 105 + ], + "declarations": [ + { + "type": "VariableDeclarator", + "start": 94, + "end": 105, + "loc": { + "start": { + "line": 8, + "column": 6 + }, + "end": { + "line": 8, + "column": 17 + } + }, + "range": [ + 94, + 105 + ], + "id": { + "type": "Identifier", + "start": 94, + "end": 95, + "loc": { + "start": { + "line": 8, + "column": 6 + }, + "end": { + "line": 8, + "column": 7 + } + }, + "range": [ + 94, + 95 + ], + "name": "d" + }, + "init": { + "type": "CallExpression", + "start": 98, + "end": 105, + "loc": { + "start": { + "line": 8, + "column": 10 + }, + "end": { + "line": 8, + "column": 17 + } + }, + "range": [ + 98, + 105 + ], + "callee": { + "type": "MemberExpression", + "start": 98, + "end": 103, + "loc": { + "start": { + "line": 8, + "column": 10 + }, + "end": { + "line": 8, + "column": 15 + } + }, + "range": [ + 98, + 103 + ], + "object": { + "type": "Identifier", + "start": 98, + "end": 99, + "loc": { + "start": { + "line": 8, + "column": 10 + }, + "end": { + "line": 8, + "column": 11 + } + }, + "range": [ + 98, + 99 + ], + "name": "A" + }, + "property": { + "type": "Identifier", + "start": 100, + "end": 103, + "loc": { + "start": { + "line": 8, + "column": 12 + }, + "end": { + "line": 8, + "column": 15 + } + }, + "range": [ + 100, + 103 + ], + "name": "use" + }, + "computed": false, + "optional": false + }, + "arguments": [], + "optional": false + } + } + ], + "kind": "const" + } + ], + "sourceType": "module", + "comments": [], + "tokens": [ + { + "type": "Punctuator", + "range": [ + 0, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 40, + 54 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 14 + } + }, + "value": "" + } + ] +} \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-2/parser-options.json b/test/fixtures/ast/multiple-scripts-2/parser-options.json new file mode 100644 index 00000000..2104ca43 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-2/parser-options.json @@ -0,0 +1,3 @@ +{ + "sourceType": "module" +} diff --git a/test/fixtures/ast/multiple-scripts-2/requirements.json b/test/fixtures/ast/multiple-scripts-2/requirements.json new file mode 100644 index 00000000..36659b1f --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-2/requirements.json @@ -0,0 +1,3 @@ +{ + "eslint": ">=8" +} \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-2/source.vue b/test/fixtures/ast/multiple-scripts-2/source.vue new file mode 100644 index 00000000..c4c3f1e2 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-2/source.vue @@ -0,0 +1,9 @@ + + + diff --git a/test/fixtures/ast/multiple-scripts-2/token-ranges.json b/test/fixtures/ast/multiple-scripts-2/token-ranges.json new file mode 100644 index 00000000..0570d8ea --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-2/token-ranges.json @@ -0,0 +1,26 @@ +[ + "", + "" +] \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-2/tree.json b/test/fixtures/ast/multiple-scripts-2/tree.json new file mode 100644 index 00000000..0637a088 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-2/tree.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-3/ast.json b/test/fixtures/ast/multiple-scripts-3/ast.json new file mode 100644 index 00000000..85552110 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-3/ast.json @@ -0,0 +1,749 @@ +{ + "type": "Program", + "start": 8, + "end": 91, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 8, + "column": 14 + } + }, + "range": [ + 9, + 90 + ], + "body": [ + { + "type": "ExpressionStatement", + "start": 9, + "end": 17, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "range": [ + 9, + 17 + ], + "expression": { + "type": "Literal", + "start": 9, + "end": 17, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "range": [ + 9, + 17 + ], + "value": "script", + "raw": "\"script\"" + }, + "directive": "script" + }, + { + "type": "ExpressionStatement", + "start": 76, + "end": 90, + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 14 + } + }, + "range": [ + 76, + 90 + ], + "expression": { + "type": "Literal", + "start": 76, + "end": 90, + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 14 + } + }, + "range": [ + 76, + 90 + ], + "value": "script setup", + "raw": "\"script setup\"" + } + } + ], + "sourceType": "module", + "comments": [], + "tokens": [ + { + "type": "Punctuator", + "range": [ + 0, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 61, + 75 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 14 + } + }, + "value": "" + } + ], + "templateBody": { + "type": "VElement", + "range": [ + 29, + 59 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 30 + } + }, + "name": "template", + "rawName": "template", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 29, + 39 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 39, + 48 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 19 + } + }, + "value": "Template!" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 48, + 59 + ], + "loc": { + "start": { + "line": 5, + "column": 19 + }, + "end": { + "line": 5, + "column": 30 + } + } + }, + "variables": [], + "tokens": [ + { + "type": "HTMLTagOpen", + "range": [ + 0, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 7, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 8, + 9 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 9, + 17 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "value": "\"script\"" + }, + { + "type": "HTMLWhitespace", + "range": [ + 17, + 18 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 18, + 26 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 26, + 27 + ], + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 27, + 29 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "value": "\n\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 29, + 38 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 38, + 39 + ], + "loc": { + "start": { + "line": 5, + "column": 9 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLText", + "range": [ + 39, + 48 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 19 + } + }, + "value": "Template!" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 48, + 58 + ], + "loc": { + "start": { + "line": 5, + "column": 19 + }, + "end": { + "line": 5, + "column": 29 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 58, + 59 + ], + "loc": { + "start": { + "line": 5, + "column": 29 + }, + "end": { + "line": 5, + "column": 30 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 59, + 61 + ], + "loc": { + "start": { + "line": 5, + "column": 30 + }, + "end": { + "line": 7, + "column": 0 + } + }, + "value": "\n\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 61, + 68 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLIdentifier", + "range": [ + 69, + 74 + ], + "loc": { + "start": { + "line": 7, + "column": 8 + }, + "end": { + "line": 7, + "column": 13 + } + }, + "value": "setup" + }, + { + "type": "HTMLTagClose", + "range": [ + 74, + 75 + ], + "loc": { + "start": { + "line": 7, + "column": 13 + }, + "end": { + "line": 7, + "column": 14 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 75, + 76 + ], + "loc": { + "start": { + "line": 7, + "column": 14 + }, + "end": { + "line": 8, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 76, + 83 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 7 + } + }, + "value": "\"script" + }, + { + "type": "HTMLWhitespace", + "range": [ + 83, + 84 + ], + "loc": { + "start": { + "line": 8, + "column": 7 + }, + "end": { + "line": 8, + "column": 8 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 84, + 90 + ], + "loc": { + "start": { + "line": 8, + "column": 8 + }, + "end": { + "line": 8, + "column": 14 + } + }, + "value": "setup\"" + }, + { + "type": "HTMLWhitespace", + "range": [ + 90, + 91 + ], + "loc": { + "start": { + "line": 8, + "column": 14 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 91, + 99 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 99, + 100 + ], + "loc": { + "start": { + "line": 9, + "column": 8 + }, + "end": { + "line": 9, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 100, + 101 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 10, + "column": 0 + } + }, + "value": "\n" + } + ], + "comments": [], + "errors": [] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-3/parser-options.json b/test/fixtures/ast/multiple-scripts-3/parser-options.json new file mode 100644 index 00000000..2104ca43 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-3/parser-options.json @@ -0,0 +1,3 @@ +{ + "sourceType": "module" +} diff --git a/test/fixtures/ast/multiple-scripts-3/requirements.json b/test/fixtures/ast/multiple-scripts-3/requirements.json new file mode 100644 index 00000000..36659b1f --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-3/requirements.json @@ -0,0 +1,3 @@ +{ + "eslint": ">=8" +} \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-3/source.vue b/test/fixtures/ast/multiple-scripts-3/source.vue new file mode 100644 index 00000000..e136f806 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-3/source.vue @@ -0,0 +1,9 @@ + + + + + diff --git a/test/fixtures/ast/multiple-scripts-3/token-ranges.json b/test/fixtures/ast/multiple-scripts-3/token-ranges.json new file mode 100644 index 00000000..91b6f7d5 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-3/token-ranges.json @@ -0,0 +1,33 @@ +[ + "", + "", + "", + "\n", + "\"script\"", + "\n", + "", + "\n\n", + "", + "Template!", + "", + "\n\n", + "", + "\n", + "\"script", + " ", + "setup\"", + "\n", + "", + "\n" +] \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-3/tree.json b/test/fixtures/ast/multiple-scripts-3/tree.json new file mode 100644 index 00000000..7cedc5f9 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-3/tree.json @@ -0,0 +1,23 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-4/ast.json b/test/fixtures/ast/multiple-scripts-4/ast.json new file mode 100644 index 00000000..03a1f108 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-4/ast.json @@ -0,0 +1,851 @@ +{ + "type": "Program", + "start": 9, + "end": 17, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "range": [ + 9, + 17 + ], + "body": [ + { + "type": "ExpressionStatement", + "start": 9, + "end": 17, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "range": [ + 9, + 17 + ], + "expression": { + "type": "Literal", + "start": 9, + "end": 17, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "range": [ + 9, + 17 + ], + "value": "script", + "raw": "\"script\"" + }, + "directive": "script" + } + ], + "sourceType": "module", + "comments": [], + "tokens": [ + { + "type": "Punctuator", + "range": [ + 0, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "value": "" + } + ], + "templateBody": { + "type": "VElement", + "range": [ + 29, + 59 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 30 + } + }, + "name": "template", + "rawName": "template", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 29, + 39 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 39, + 48 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 19 + } + }, + "value": "Template!" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 48, + 59 + ], + "loc": { + "start": { + "line": 5, + "column": 19 + }, + "end": { + "line": 5, + "column": 30 + } + } + }, + "variables": [], + "tokens": [ + { + "type": "HTMLTagOpen", + "range": [ + 0, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 7, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 8, + 9 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 9, + 17 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "value": "\"script\"" + }, + { + "type": "HTMLWhitespace", + "range": [ + 17, + 18 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 18, + 26 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 26, + 27 + ], + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 27, + 29 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "value": "\n\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 29, + 38 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 38, + 39 + ], + "loc": { + "start": { + "line": 5, + "column": 9 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLText", + "range": [ + 39, + 48 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 19 + } + }, + "value": "Template!" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 48, + 58 + ], + "loc": { + "start": { + "line": 5, + "column": 19 + }, + "end": { + "line": 5, + "column": 29 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 58, + 59 + ], + "loc": { + "start": { + "line": 5, + "column": 29 + }, + "end": { + "line": 5, + "column": 30 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 59, + 61 + ], + "loc": { + "start": { + "line": 5, + "column": 30 + }, + "end": { + "line": 7, + "column": 0 + } + }, + "value": "\n\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 61, + 68 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLIdentifier", + "range": [ + 69, + 74 + ], + "loc": { + "start": { + "line": 7, + "column": 8 + }, + "end": { + "line": 7, + "column": 13 + } + }, + "value": "setup" + }, + { + "type": "HTMLTagClose", + "range": [ + 74, + 75 + ], + "loc": { + "start": { + "line": 7, + "column": 13 + }, + "end": { + "line": 7, + "column": 14 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 75, + 76 + ], + "loc": { + "start": { + "line": 7, + "column": 14 + }, + "end": { + "line": 8, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 76, + 83 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 7 + } + }, + "value": "\"script" + }, + { + "type": "HTMLWhitespace", + "range": [ + 83, + 84 + ], + "loc": { + "start": { + "line": 8, + "column": 7 + }, + "end": { + "line": 8, + "column": 8 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 84, + 90 + ], + "loc": { + "start": { + "line": 8, + "column": 8 + }, + "end": { + "line": 8, + "column": 14 + } + }, + "value": "setup\"" + }, + { + "type": "HTMLWhitespace", + "range": [ + 90, + 91 + ], + "loc": { + "start": { + "line": 8, + "column": 14 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 91, + 99 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 99, + 100 + ], + "loc": { + "start": { + "line": 9, + "column": 8 + }, + "end": { + "line": 9, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 100, + 102 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 11, + "column": 0 + } + }, + "value": "\n\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 102, + 109 + ], + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLIdentifier", + "range": [ + 110, + 117 + ], + "loc": { + "start": { + "line": 11, + "column": 8 + }, + "end": { + "line": 11, + "column": 15 + } + }, + "value": "unknown" + }, + { + "type": "HTMLTagClose", + "range": [ + 117, + 118 + ], + "loc": { + "start": { + "line": 11, + "column": 15 + }, + "end": { + "line": 11, + "column": 16 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 118, + 119 + ], + "loc": { + "start": { + "line": 11, + "column": 16 + }, + "end": { + "line": 12, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 119, + 126 + ], + "loc": { + "start": { + "line": 12, + "column": 0 + }, + "end": { + "line": 12, + "column": 7 + } + }, + "value": "\"script" + }, + { + "type": "HTMLWhitespace", + "range": [ + 126, + 127 + ], + "loc": { + "start": { + "line": 12, + "column": 7 + }, + "end": { + "line": 12, + "column": 8 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 127, + 135 + ], + "loc": { + "start": { + "line": 12, + "column": 8 + }, + "end": { + "line": 12, + "column": 16 + } + }, + "value": "unknown\"" + }, + { + "type": "HTMLWhitespace", + "range": [ + 135, + 136 + ], + "loc": { + "start": { + "line": 12, + "column": 16 + }, + "end": { + "line": 13, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 136, + 144 + ], + "loc": { + "start": { + "line": 13, + "column": 0 + }, + "end": { + "line": 13, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 144, + 145 + ], + "loc": { + "start": { + "line": 13, + "column": 8 + }, + "end": { + "line": 13, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 145, + 146 + ], + "loc": { + "start": { + "line": 13, + "column": 9 + }, + "end": { + "line": 14, + "column": 0 + } + }, + "value": "\n" + } + ], + "comments": [], + "errors": [] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-4/parser-options.json b/test/fixtures/ast/multiple-scripts-4/parser-options.json new file mode 100644 index 00000000..2104ca43 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-4/parser-options.json @@ -0,0 +1,3 @@ +{ + "sourceType": "module" +} diff --git a/test/fixtures/ast/multiple-scripts-4/requirements.json b/test/fixtures/ast/multiple-scripts-4/requirements.json new file mode 100644 index 00000000..36659b1f --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-4/requirements.json @@ -0,0 +1,3 @@ +{ + "eslint": ">=8" +} \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-4/source.vue b/test/fixtures/ast/multiple-scripts-4/source.vue new file mode 100644 index 00000000..7d1a37de --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-4/source.vue @@ -0,0 +1,13 @@ + + + + + + + diff --git a/test/fixtures/ast/multiple-scripts-4/token-ranges.json b/test/fixtures/ast/multiple-scripts-4/token-ranges.json new file mode 100644 index 00000000..002d3fc9 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-4/token-ranges.json @@ -0,0 +1,41 @@ +[ + "", + "", + "\n", + "\"script\"", + "\n", + "", + "\n\n", + "", + "Template!", + "", + "\n\n", + "", + "\n", + "\"script", + " ", + "setup\"", + "\n", + "", + "\n\n", + "", + "\n", + "\"script", + " ", + "unknown\"", + "\n", + "", + "\n" +] \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-4/tree.json b/test/fixtures/ast/multiple-scripts-4/tree.json new file mode 100644 index 00000000..7cedc5f9 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-4/tree.json @@ -0,0 +1,23 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-5/ast.json b/test/fixtures/ast/multiple-scripts-5/ast.json new file mode 100644 index 00000000..fd0cbb7d --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-5/ast.json @@ -0,0 +1,1729 @@ +{ + "type": "Program", + "start": 8, + "end": 145, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 9, + "column": 14 + } + }, + "range": [ + 9, + 144 + ], + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 9, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "range": [ + 9, + 30 + ], + "declaration": { + "type": "VariableDeclaration", + "start": 16, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "range": [ + 16, + 30 + ], + "declarations": [ + { + "type": "VariableDeclarator", + "start": 20, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "range": [ + 20, + 30 + ], + "id": { + "type": "Identifier", + "start": 20, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "range": [ + 20, + 25 + ], + "name": "count" + }, + "init": { + "type": "Literal", + "start": 28, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "range": [ + 28, + 30 + ], + "value": 42, + "raw": "42" + } + } + ], + "kind": "let" + }, + "specifiers": [], + "source": null, + "attributes": [] + }, + { + "type": "ImportDeclaration", + "start": 102, + "end": 129, + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 27 + } + }, + "range": [ + 102, + 129 + ], + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start": 109, + "end": 112, + "loc": { + "start": { + "line": 8, + "column": 7 + }, + "end": { + "line": 8, + "column": 10 + } + }, + "range": [ + 109, + 112 + ], + "local": { + "type": "Identifier", + "start": 109, + "end": 112, + "loc": { + "start": { + "line": 8, + "column": 7 + }, + "end": { + "line": 8, + "column": 10 + } + }, + "range": [ + 109, + 112 + ], + "name": "Foo" + } + } + ], + "source": { + "type": "Literal", + "start": 118, + "end": 129, + "loc": { + "start": { + "line": 8, + "column": 16 + }, + "end": { + "line": 8, + "column": 27 + } + }, + "range": [ + 118, + 129 + ], + "value": "./Foo.vue", + "raw": "'./Foo.vue'" + }, + "attributes": [] + }, + { + "type": "VariableDeclaration", + "start": 130, + "end": 144, + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 14 + } + }, + "range": [ + 130, + 144 + ], + "declarations": [ + { + "type": "VariableDeclarator", + "start": 134, + "end": 144, + "loc": { + "start": { + "line": 9, + "column": 4 + }, + "end": { + "line": 9, + "column": 14 + } + }, + "range": [ + 134, + 144 + ], + "id": { + "type": "Identifier", + "start": 134, + "end": 139, + "loc": { + "start": { + "line": 9, + "column": 4 + }, + "end": { + "line": 9, + "column": 9 + } + }, + "range": [ + 134, + 139 + ], + "name": "count" + }, + "init": { + "type": "Literal", + "start": 142, + "end": 144, + "loc": { + "start": { + "line": 9, + "column": 12 + }, + "end": { + "line": 9, + "column": 14 + } + }, + "range": [ + 142, + 144 + ], + "value": 42, + "raw": "42" + } + } + ], + "kind": "let" + } + ], + "sourceType": "module", + "comments": [], + "tokens": [ + { + "type": "Punctuator", + "range": [ + 0, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 87, + 101 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 14 + } + }, + "value": "" + } + ], + "templateBody": { + "type": "VElement", + "range": [ + 42, + 85 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 43 + } + }, + "name": "template", + "rawName": "template", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 42, + 52 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VElement", + "range": [ + 52, + 74 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 32 + } + }, + "name": "foo", + "rawName": "Foo", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 52, + 57 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 15 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VExpressionContainer", + "range": [ + 57, + 68 + ], + "loc": { + "start": { + "line": 5, + "column": 15 + }, + "end": { + "line": 5, + "column": 26 + } + }, + "expression": { + "type": "Identifier", + "start": 60, + "end": 65, + "loc": { + "start": { + "line": 5, + "column": 18 + }, + "end": { + "line": 5, + "column": 23 + } + }, + "range": [ + 60, + 65 + ], + "name": "count" + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 60, + "end": 65, + "loc": { + "start": { + "line": 5, + "column": 18 + }, + "end": { + "line": 5, + "column": 23 + } + }, + "range": [ + 60, + 65 + ], + "name": "count" + }, + "mode": "r" + } + ] + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 68, + 74 + ], + "loc": { + "start": { + "line": 5, + "column": 26 + }, + "end": { + "line": 5, + "column": 32 + } + } + }, + "variables": [] + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 74, + 85 + ], + "loc": { + "start": { + "line": 5, + "column": 32 + }, + "end": { + "line": 5, + "column": 43 + } + } + }, + "variables": [], + "tokens": [ + { + "type": "HTMLTagOpen", + "range": [ + 0, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 7, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 8, + 9 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 9, + 15 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 6 + } + }, + "value": "export" + }, + { + "type": "HTMLWhitespace", + "range": [ + 15, + 16 + ], + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 16, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "value": "let" + }, + { + "type": "HTMLWhitespace", + "range": [ + 19, + 20 + ], + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 20, + 25 + ], + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "value": "count" + }, + { + "type": "HTMLWhitespace", + "range": [ + 25, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 26, + 27 + ], + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 27, + 28 + ], + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 28, + 30 + ], + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "value": "42" + }, + { + "type": "HTMLWhitespace", + "range": [ + 30, + 31 + ], + "loc": { + "start": { + "line": 2, + "column": 21 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 31, + 39 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 39, + 40 + ], + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 40, + 42 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "value": "\n\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 42, + 51 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 51, + 52 + ], + "loc": { + "start": { + "line": 5, + "column": 9 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLTagOpen", + "range": [ + 52, + 56 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 14 + } + }, + "value": "foo" + }, + { + "type": "HTMLTagClose", + "range": [ + 56, + 57 + ], + "loc": { + "start": { + "line": 5, + "column": 14 + }, + "end": { + "line": 5, + "column": 15 + } + }, + "value": "" + }, + { + "type": "VExpressionStart", + "range": [ + 57, + 59 + ], + "loc": { + "start": { + "line": 5, + "column": 15 + }, + "end": { + "line": 5, + "column": 17 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "value": "count", + "start": 60, + "end": 65, + "loc": { + "start": { + "line": 5, + "column": 18 + }, + "end": { + "line": 5, + "column": 23 + } + }, + "range": [ + 60, + 65 + ] + }, + { + "type": "VExpressionEnd", + "range": [ + 66, + 68 + ], + "loc": { + "start": { + "line": 5, + "column": 24 + }, + "end": { + "line": 5, + "column": 26 + } + }, + "value": "}}" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 68, + 73 + ], + "loc": { + "start": { + "line": 5, + "column": 26 + }, + "end": { + "line": 5, + "column": 31 + } + }, + "value": "foo" + }, + { + "type": "HTMLTagClose", + "range": [ + 73, + 74 + ], + "loc": { + "start": { + "line": 5, + "column": 31 + }, + "end": { + "line": 5, + "column": 32 + } + }, + "value": "" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 74, + 84 + ], + "loc": { + "start": { + "line": 5, + "column": 32 + }, + "end": { + "line": 5, + "column": 42 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 84, + 85 + ], + "loc": { + "start": { + "line": 5, + "column": 42 + }, + "end": { + "line": 5, + "column": 43 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 85, + 87 + ], + "loc": { + "start": { + "line": 5, + "column": 43 + }, + "end": { + "line": 7, + "column": 0 + } + }, + "value": "\n\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 87, + 94 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLIdentifier", + "range": [ + 95, + 100 + ], + "loc": { + "start": { + "line": 7, + "column": 8 + }, + "end": { + "line": 7, + "column": 13 + } + }, + "value": "setup" + }, + { + "type": "HTMLTagClose", + "range": [ + 100, + 101 + ], + "loc": { + "start": { + "line": 7, + "column": 13 + }, + "end": { + "line": 7, + "column": 14 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 101, + 102 + ], + "loc": { + "start": { + "line": 7, + "column": 14 + }, + "end": { + "line": 8, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 102, + 108 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 6 + } + }, + "value": "import" + }, + { + "type": "HTMLWhitespace", + "range": [ + 108, + 109 + ], + "loc": { + "start": { + "line": 8, + "column": 6 + }, + "end": { + "line": 8, + "column": 7 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 109, + 112 + ], + "loc": { + "start": { + "line": 8, + "column": 7 + }, + "end": { + "line": 8, + "column": 10 + } + }, + "value": "Foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 112, + 113 + ], + "loc": { + "start": { + "line": 8, + "column": 10 + }, + "end": { + "line": 8, + "column": 11 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 113, + 117 + ], + "loc": { + "start": { + "line": 8, + "column": 11 + }, + "end": { + "line": 8, + "column": 15 + } + }, + "value": "from" + }, + { + "type": "HTMLWhitespace", + "range": [ + 117, + 118 + ], + "loc": { + "start": { + "line": 8, + "column": 15 + }, + "end": { + "line": 8, + "column": 16 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 118, + 129 + ], + "loc": { + "start": { + "line": 8, + "column": 16 + }, + "end": { + "line": 8, + "column": 27 + } + }, + "value": "'./Foo.vue'" + }, + { + "type": "HTMLWhitespace", + "range": [ + 129, + 130 + ], + "loc": { + "start": { + "line": 8, + "column": 27 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 130, + 133 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 3 + } + }, + "value": "let" + }, + { + "type": "HTMLWhitespace", + "range": [ + 133, + 134 + ], + "loc": { + "start": { + "line": 9, + "column": 3 + }, + "end": { + "line": 9, + "column": 4 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 134, + 139 + ], + "loc": { + "start": { + "line": 9, + "column": 4 + }, + "end": { + "line": 9, + "column": 9 + } + }, + "value": "count" + }, + { + "type": "HTMLWhitespace", + "range": [ + 139, + 140 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 9, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 140, + 141 + ], + "loc": { + "start": { + "line": 9, + "column": 10 + }, + "end": { + "line": 9, + "column": 11 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 141, + 142 + ], + "loc": { + "start": { + "line": 9, + "column": 11 + }, + "end": { + "line": 9, + "column": 12 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 142, + 144 + ], + "loc": { + "start": { + "line": 9, + "column": 12 + }, + "end": { + "line": 9, + "column": 14 + } + }, + "value": "42" + }, + { + "type": "HTMLWhitespace", + "range": [ + 144, + 145 + ], + "loc": { + "start": { + "line": 9, + "column": 14 + }, + "end": { + "line": 10, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 145, + 153 + ], + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 153, + 154 + ], + "loc": { + "start": { + "line": 10, + "column": 8 + }, + "end": { + "line": 10, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 154, + 155 + ], + "loc": { + "start": { + "line": 10, + "column": 9 + }, + "end": { + "line": 11, + "column": 0 + } + }, + "value": "\n" + } + ], + "comments": [], + "errors": [] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-5/parser-options.json b/test/fixtures/ast/multiple-scripts-5/parser-options.json new file mode 100644 index 00000000..2104ca43 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-5/parser-options.json @@ -0,0 +1,3 @@ +{ + "sourceType": "module" +} diff --git a/test/fixtures/ast/multiple-scripts-5/requirements.json b/test/fixtures/ast/multiple-scripts-5/requirements.json new file mode 100644 index 00000000..36659b1f --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-5/requirements.json @@ -0,0 +1,3 @@ +{ + "eslint": ">=8" +} \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-5/source.vue b/test/fixtures/ast/multiple-scripts-5/source.vue new file mode 100644 index 00000000..267b0f65 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-5/source.vue @@ -0,0 +1,10 @@ + + + + + diff --git a/test/fixtures/ast/multiple-scripts-5/token-ranges.json b/test/fixtures/ast/multiple-scripts-5/token-ranges.json new file mode 100644 index 00000000..5da2f7d5 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-5/token-ranges.json @@ -0,0 +1,70 @@ +[ + "", + "", + "", + "\n", + "export", + " ", + "let", + " ", + "count", + " ", + "=", + " ", + "42", + "\n", + "", + "\n\n", + "", + "", + "{{", + "count", + "}}", + "", + "", + "\n\n", + "", + "\n", + "import", + " ", + "Foo", + " ", + "from", + " ", + "'./Foo.vue'", + "\n", + "let", + " ", + "count", + " ", + "=", + " ", + "42", + "\n", + "", + "\n" +] \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-5/tree.json b/test/fixtures/ast/multiple-scripts-5/tree.json new file mode 100644 index 00000000..f84d7918 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-5/tree.json @@ -0,0 +1,45 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-6/ast.json b/test/fixtures/ast/multiple-scripts-6/ast.json new file mode 100644 index 00000000..4d97bdcb --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-6/ast.json @@ -0,0 +1,583 @@ +{ + "type": "Program", + "start": 14, + "end": 98, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 7, + "column": 22 + } + }, + "range": [ + 15, + 97 + ], + "body": [ + { + "type": "VariableDeclaration", + "start": 15, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "range": [ + 15, + 28 + ], + "declarations": [ + { + "type": "VariableDeclarator", + "start": 19, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "range": [ + 19, + 28 + ], + "id": { + "type": "Identifier", + "start": 19, + "end": 24, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "range": [ + 19, + 24 + ], + "name": "count" + }, + "init": { + "type": "Literal", + "start": 27, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "range": [ + 27, + 28 + ], + "value": 0, + "raw": "0" + } + } + ], + "kind": "let" + }, + { + "type": "ExpressionStatement", + "start": 48, + "end": 73, + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 25 + } + }, + "range": [ + 48, + 73 + ], + "expression": { + "type": "CallExpression", + "start": 48, + "end": 73, + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 25 + } + }, + "range": [ + 48, + 73 + ], + "callee": { + "type": "Identifier", + "start": 48, + "end": 71, + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 23 + } + }, + "range": [ + 48, + 71 + ], + "name": "performGlobalSideEffect" + }, + "arguments": [], + "optional": false + } + }, + { + "type": "ExportNamedDeclaration", + "start": 75, + "end": 97, + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 22 + } + }, + "range": [ + 75, + 97 + ], + "declaration": { + "type": "VariableDeclaration", + "start": 82, + "end": 97, + "loc": { + "start": { + "line": 7, + "column": 7 + }, + "end": { + "line": 7, + "column": 22 + } + }, + "range": [ + 82, + 97 + ], + "declarations": [ + { + "type": "VariableDeclarator", + "start": 88, + "end": 97, + "loc": { + "start": { + "line": 7, + "column": 13 + }, + "end": { + "line": 7, + "column": 22 + } + }, + "range": [ + 88, + 97 + ], + "id": { + "type": "Identifier", + "start": 88, + "end": 93, + "loc": { + "start": { + "line": 7, + "column": 13 + }, + "end": { + "line": 7, + "column": 18 + } + }, + "range": [ + 88, + 93 + ], + "name": "named" + }, + "init": { + "type": "Literal", + "start": 96, + "end": 97, + "loc": { + "start": { + "line": 7, + "column": 21 + }, + "end": { + "line": 7, + "column": 22 + } + }, + "range": [ + 96, + 97 + ], + "value": 1, + "raw": "1" + } + } + ], + "kind": "const" + }, + "specifiers": [], + "source": null, + "attributes": [] + } + ], + "sourceType": "module", + "comments": [], + "tokens": [ + { + "type": "Punctuator", + "range": [ + 0, + 14 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 39, + 47 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 8 + } + }, + "value": "" + } + ] +} \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-6/parser-options.json b/test/fixtures/ast/multiple-scripts-6/parser-options.json new file mode 100644 index 00000000..2104ca43 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-6/parser-options.json @@ -0,0 +1,3 @@ +{ + "sourceType": "module" +} diff --git a/test/fixtures/ast/multiple-scripts-6/requirements.json b/test/fixtures/ast/multiple-scripts-6/requirements.json new file mode 100644 index 00000000..36659b1f --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-6/requirements.json @@ -0,0 +1,3 @@ +{ + "eslint": ">=8" +} \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-6/source.vue b/test/fixtures/ast/multiple-scripts-6/source.vue new file mode 100644 index 00000000..ecaf529b --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-6/source.vue @@ -0,0 +1,8 @@ + + diff --git a/test/fixtures/ast/multiple-scripts-6/token-ranges.json b/test/fixtures/ast/multiple-scripts-6/token-ranges.json new file mode 100644 index 00000000..fb1b1bda --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-6/token-ranges.json @@ -0,0 +1,18 @@ +[ + "", + "" +] \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-6/tree.json b/test/fixtures/ast/multiple-scripts-6/tree.json new file mode 100644 index 00000000..0637a088 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-6/tree.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-7/ast.json b/test/fixtures/ast/multiple-scripts-7/ast.json new file mode 100644 index 00000000..ca60f41a --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-7/ast.json @@ -0,0 +1,2685 @@ +{ + "type": "Program", + "start": 8, + "end": 178, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 9, + "column": 13 + } + }, + "range": [ + 9, + 177 + ], + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 9, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "range": [ + 9, + 30 + ], + "declaration": { + "type": "VariableDeclaration", + "start": 16, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "range": [ + 16, + 30 + ], + "declarations": [ + { + "type": "VariableDeclarator", + "start": 20, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "range": [ + 20, + 30 + ], + "id": { + "type": "Identifier", + "start": 20, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "range": [ + 20, + 25 + ], + "name": "count" + }, + "init": { + "type": "Literal", + "start": 28, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "range": [ + 28, + 30 + ], + "value": 42, + "raw": "42" + } + } + ], + "kind": "let" + }, + "specifiers": [], + "source": null, + "attributes": [] + }, + { + "type": "ImportDeclaration", + "start": 57, + "end": 102, + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 45 + } + }, + "range": [ + 57, + 102 + ], + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start": 64, + "end": 76, + "loc": { + "start": { + "line": 6, + "column": 7 + }, + "end": { + "line": 6, + "column": 19 + } + }, + "range": [ + 64, + 76 + ], + "local": { + "type": "Identifier", + "start": 64, + "end": 76, + "loc": { + "start": { + "line": 6, + "column": 7 + }, + "end": { + "line": 6, + "column": 19 + } + }, + "range": [ + 64, + 76 + ], + "name": "MyComponent1" + } + } + ], + "source": { + "type": "Literal", + "start": 82, + "end": 102, + "loc": { + "start": { + "line": 6, + "column": 25 + }, + "end": { + "line": 6, + "column": 45 + } + }, + "range": [ + 82, + 102 + ], + "value": "./MyComponent1.vue", + "raw": "'./MyComponent1.vue'" + }, + "attributes": [] + }, + { + "type": "VariableDeclaration", + "start": 103, + "end": 117, + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 14 + } + }, + "range": [ + 103, + 117 + ], + "declarations": [ + { + "type": "VariableDeclarator", + "start": 107, + "end": 117, + "loc": { + "start": { + "line": 7, + "column": 4 + }, + "end": { + "line": 7, + "column": 14 + } + }, + "range": [ + 107, + 117 + ], + "id": { + "type": "Identifier", + "start": 107, + "end": 112, + "loc": { + "start": { + "line": 7, + "column": 4 + }, + "end": { + "line": 7, + "column": 9 + } + }, + "range": [ + 107, + 112 + ], + "name": "count" + }, + "init": { + "type": "Literal", + "start": 115, + "end": 117, + "loc": { + "start": { + "line": 7, + "column": 12 + }, + "end": { + "line": 7, + "column": 14 + } + }, + "range": [ + 115, + 117 + ], + "value": 42, + "raw": "42" + } + } + ], + "kind": "let" + }, + { + "type": "ImportDeclaration", + "start": 118, + "end": 163, + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 45 + } + }, + "range": [ + 118, + 163 + ], + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start": 125, + "end": 137, + "loc": { + "start": { + "line": 8, + "column": 7 + }, + "end": { + "line": 8, + "column": 19 + } + }, + "range": [ + 125, + 137 + ], + "local": { + "type": "Identifier", + "start": 125, + "end": 137, + "loc": { + "start": { + "line": 8, + "column": 7 + }, + "end": { + "line": 8, + "column": 19 + } + }, + "range": [ + 125, + 137 + ], + "name": "MyComponent2" + } + } + ], + "source": { + "type": "Literal", + "start": 143, + "end": 163, + "loc": { + "start": { + "line": 8, + "column": 25 + }, + "end": { + "line": 8, + "column": 45 + } + }, + "range": [ + 143, + 163 + ], + "value": "./MyComponent2.vue", + "raw": "'./MyComponent2.vue'" + }, + "attributes": [] + }, + { + "type": "VariableDeclaration", + "start": 164, + "end": 177, + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 13 + } + }, + "range": [ + 164, + 177 + ], + "declarations": [ + { + "type": "VariableDeclarator", + "start": 168, + "end": 177, + "loc": { + "start": { + "line": 9, + "column": 4 + }, + "end": { + "line": 9, + "column": 13 + } + }, + "range": [ + 168, + 177 + ], + "id": { + "type": "Identifier", + "start": 168, + "end": 169, + "loc": { + "start": { + "line": 9, + "column": 4 + }, + "end": { + "line": 9, + "column": 5 + } + }, + "range": [ + 168, + 169 + ], + "name": "a" + }, + "init": { + "type": "BinaryExpression", + "start": 172, + "end": 177, + "loc": { + "start": { + "line": 9, + "column": 8 + }, + "end": { + "line": 9, + "column": 13 + } + }, + "range": [ + 172, + 177 + ], + "left": { + "type": "Identifier", + "start": 172, + "end": 173, + "loc": { + "start": { + "line": 9, + "column": 8 + }, + "end": { + "line": 9, + "column": 9 + } + }, + "range": [ + 172, + 173 + ], + "name": "b" + }, + "operator": "+", + "right": { + "type": "Identifier", + "start": 176, + "end": 177, + "loc": { + "start": { + "line": 9, + "column": 12 + }, + "end": { + "line": 9, + "column": 13 + } + }, + "range": [ + 176, + 177 + ], + "name": "c" + } + } + } + ], + "kind": "let" + } + ], + "sourceType": "module", + "comments": [], + "tokens": [ + { + "type": "Punctuator", + "range": [ + 0, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 42, + 56 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 14 + } + }, + "value": "" + } + ], + "templateBody": { + "type": "VElement", + "range": [ + 189, + 276 + ], + "loc": { + "start": { + "line": 12, + "column": 0 + }, + "end": { + "line": 15, + "column": 11 + } + }, + "name": "template", + "rawName": "template", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 189, + 199 + ], + "loc": { + "start": { + "line": 12, + "column": 0 + }, + "end": { + "line": 12, + "column": 10 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 199, + 204 + ], + "loc": { + "start": { + "line": 12, + "column": 10 + }, + "end": { + "line": 13, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 204, + 244 + ], + "loc": { + "start": { + "line": 13, + "column": 4 + }, + "end": { + "line": 13, + "column": 44 + } + }, + "name": "mycomponent1", + "rawName": "MyComponent1", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 204, + 218 + ], + "loc": { + "start": { + "line": 13, + "column": 4 + }, + "end": { + "line": 13, + "column": 18 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VExpressionContainer", + "range": [ + 218, + 229 + ], + "loc": { + "start": { + "line": 13, + "column": 18 + }, + "end": { + "line": 13, + "column": 29 + } + }, + "expression": { + "type": "Identifier", + "start": 221, + "end": 226, + "loc": { + "start": { + "line": 13, + "column": 21 + }, + "end": { + "line": 13, + "column": 26 + } + }, + "range": [ + 221, + 226 + ], + "name": "count" + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 221, + "end": 226, + "loc": { + "start": { + "line": 13, + "column": 21 + }, + "end": { + "line": 13, + "column": 26 + } + }, + "range": [ + 221, + 226 + ], + "name": "count" + }, + "mode": "r" + } + ] + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 229, + 244 + ], + "loc": { + "start": { + "line": 13, + "column": 29 + }, + "end": { + "line": 13, + "column": 44 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 244, + 249 + ], + "loc": { + "start": { + "line": 13, + "column": 44 + }, + "end": { + "line": 14, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 249, + 264 + ], + "loc": { + "start": { + "line": 14, + "column": 4 + }, + "end": { + "line": 14, + "column": 19 + } + }, + "name": "mycomponent2", + "rawName": "MyComponent2", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 249, + 264 + ], + "loc": { + "start": { + "line": 14, + "column": 4 + }, + "end": { + "line": 14, + "column": 19 + } + }, + "selfClosing": true, + "attributes": [] + }, + "children": [], + "endTag": null, + "variables": [] + }, + { + "type": "VText", + "range": [ + 264, + 265 + ], + "loc": { + "start": { + "line": 14, + "column": 19 + }, + "end": { + "line": 15, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 265, + 276 + ], + "loc": { + "start": { + "line": 15, + "column": 0 + }, + "end": { + "line": 15, + "column": 11 + } + } + }, + "variables": [], + "tokens": [ + { + "type": "HTMLTagOpen", + "range": [ + 0, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 7, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 8, + 9 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 9, + 15 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 6 + } + }, + "value": "export" + }, + { + "type": "HTMLWhitespace", + "range": [ + 15, + 16 + ], + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 16, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "value": "let" + }, + { + "type": "HTMLWhitespace", + "range": [ + 19, + 20 + ], + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 20, + 25 + ], + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "value": "count" + }, + { + "type": "HTMLWhitespace", + "range": [ + 25, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 26, + 27 + ], + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 27, + 28 + ], + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 28, + 30 + ], + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "value": "42" + }, + { + "type": "HTMLWhitespace", + "range": [ + 30, + 31 + ], + "loc": { + "start": { + "line": 2, + "column": 21 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 31, + 39 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 39, + 40 + ], + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 40, + 42 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "value": "\n\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 42, + 49 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLIdentifier", + "range": [ + 50, + 55 + ], + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 13 + } + }, + "value": "setup" + }, + { + "type": "HTMLTagClose", + "range": [ + 55, + 56 + ], + "loc": { + "start": { + "line": 5, + "column": 13 + }, + "end": { + "line": 5, + "column": 14 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 56, + 57 + ], + "loc": { + "start": { + "line": 5, + "column": 14 + }, + "end": { + "line": 6, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 57, + 63 + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 6 + } + }, + "value": "import" + }, + { + "type": "HTMLWhitespace", + "range": [ + 63, + 64 + ], + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 7 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 64, + 76 + ], + "loc": { + "start": { + "line": 6, + "column": 7 + }, + "end": { + "line": 6, + "column": 19 + } + }, + "value": "MyComponent1" + }, + { + "type": "HTMLWhitespace", + "range": [ + 76, + 77 + ], + "loc": { + "start": { + "line": 6, + "column": 19 + }, + "end": { + "line": 6, + "column": 20 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 77, + 81 + ], + "loc": { + "start": { + "line": 6, + "column": 20 + }, + "end": { + "line": 6, + "column": 24 + } + }, + "value": "from" + }, + { + "type": "HTMLWhitespace", + "range": [ + 81, + 82 + ], + "loc": { + "start": { + "line": 6, + "column": 24 + }, + "end": { + "line": 6, + "column": 25 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 82, + 102 + ], + "loc": { + "start": { + "line": 6, + "column": 25 + }, + "end": { + "line": 6, + "column": 45 + } + }, + "value": "'./MyComponent1.vue'" + }, + { + "type": "HTMLWhitespace", + "range": [ + 102, + 103 + ], + "loc": { + "start": { + "line": 6, + "column": 45 + }, + "end": { + "line": 7, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 103, + 106 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 3 + } + }, + "value": "let" + }, + { + "type": "HTMLWhitespace", + "range": [ + 106, + 107 + ], + "loc": { + "start": { + "line": 7, + "column": 3 + }, + "end": { + "line": 7, + "column": 4 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 107, + 112 + ], + "loc": { + "start": { + "line": 7, + "column": 4 + }, + "end": { + "line": 7, + "column": 9 + } + }, + "value": "count" + }, + { + "type": "HTMLWhitespace", + "range": [ + 112, + 113 + ], + "loc": { + "start": { + "line": 7, + "column": 9 + }, + "end": { + "line": 7, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 113, + 114 + ], + "loc": { + "start": { + "line": 7, + "column": 10 + }, + "end": { + "line": 7, + "column": 11 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 114, + 115 + ], + "loc": { + "start": { + "line": 7, + "column": 11 + }, + "end": { + "line": 7, + "column": 12 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 115, + 117 + ], + "loc": { + "start": { + "line": 7, + "column": 12 + }, + "end": { + "line": 7, + "column": 14 + } + }, + "value": "42" + }, + { + "type": "HTMLWhitespace", + "range": [ + 117, + 118 + ], + "loc": { + "start": { + "line": 7, + "column": 14 + }, + "end": { + "line": 8, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 118, + 124 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 6 + } + }, + "value": "import" + }, + { + "type": "HTMLWhitespace", + "range": [ + 124, + 125 + ], + "loc": { + "start": { + "line": 8, + "column": 6 + }, + "end": { + "line": 8, + "column": 7 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 125, + 137 + ], + "loc": { + "start": { + "line": 8, + "column": 7 + }, + "end": { + "line": 8, + "column": 19 + } + }, + "value": "MyComponent2" + }, + { + "type": "HTMLWhitespace", + "range": [ + 137, + 138 + ], + "loc": { + "start": { + "line": 8, + "column": 19 + }, + "end": { + "line": 8, + "column": 20 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 138, + 142 + ], + "loc": { + "start": { + "line": 8, + "column": 20 + }, + "end": { + "line": 8, + "column": 24 + } + }, + "value": "from" + }, + { + "type": "HTMLWhitespace", + "range": [ + 142, + 143 + ], + "loc": { + "start": { + "line": 8, + "column": 24 + }, + "end": { + "line": 8, + "column": 25 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 143, + 163 + ], + "loc": { + "start": { + "line": 8, + "column": 25 + }, + "end": { + "line": 8, + "column": 45 + } + }, + "value": "'./MyComponent2.vue'" + }, + { + "type": "HTMLWhitespace", + "range": [ + 163, + 164 + ], + "loc": { + "start": { + "line": 8, + "column": 45 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 164, + 167 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 3 + } + }, + "value": "let" + }, + { + "type": "HTMLWhitespace", + "range": [ + 167, + 168 + ], + "loc": { + "start": { + "line": 9, + "column": 3 + }, + "end": { + "line": 9, + "column": 4 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 168, + 169 + ], + "loc": { + "start": { + "line": 9, + "column": 4 + }, + "end": { + "line": 9, + "column": 5 + } + }, + "value": "a" + }, + { + "type": "HTMLWhitespace", + "range": [ + 169, + 170 + ], + "loc": { + "start": { + "line": 9, + "column": 5 + }, + "end": { + "line": 9, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 170, + 171 + ], + "loc": { + "start": { + "line": 9, + "column": 6 + }, + "end": { + "line": 9, + "column": 7 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 171, + 172 + ], + "loc": { + "start": { + "line": 9, + "column": 7 + }, + "end": { + "line": 9, + "column": 8 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 172, + 173 + ], + "loc": { + "start": { + "line": 9, + "column": 8 + }, + "end": { + "line": 9, + "column": 9 + } + }, + "value": "b" + }, + { + "type": "HTMLWhitespace", + "range": [ + 173, + 174 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 9, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 174, + 175 + ], + "loc": { + "start": { + "line": 9, + "column": 10 + }, + "end": { + "line": 9, + "column": 11 + } + }, + "value": "+" + }, + { + "type": "HTMLWhitespace", + "range": [ + 175, + 176 + ], + "loc": { + "start": { + "line": 9, + "column": 11 + }, + "end": { + "line": 9, + "column": 12 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 176, + 177 + ], + "loc": { + "start": { + "line": 9, + "column": 12 + }, + "end": { + "line": 9, + "column": 13 + } + }, + "value": "c" + }, + { + "type": "HTMLWhitespace", + "range": [ + 177, + 178 + ], + "loc": { + "start": { + "line": 9, + "column": 13 + }, + "end": { + "line": 10, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 178, + 186 + ], + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 186, + 187 + ], + "loc": { + "start": { + "line": 10, + "column": 8 + }, + "end": { + "line": 10, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 187, + 189 + ], + "loc": { + "start": { + "line": 10, + "column": 9 + }, + "end": { + "line": 12, + "column": 0 + } + }, + "value": "\n\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 189, + 198 + ], + "loc": { + "start": { + "line": 12, + "column": 0 + }, + "end": { + "line": 12, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 198, + 199 + ], + "loc": { + "start": { + "line": 12, + "column": 9 + }, + "end": { + "line": 12, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 199, + 204 + ], + "loc": { + "start": { + "line": 12, + "column": 10 + }, + "end": { + "line": 13, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 204, + 217 + ], + "loc": { + "start": { + "line": 13, + "column": 4 + }, + "end": { + "line": 13, + "column": 17 + } + }, + "value": "mycomponent1" + }, + { + "type": "HTMLTagClose", + "range": [ + 217, + 218 + ], + "loc": { + "start": { + "line": 13, + "column": 17 + }, + "end": { + "line": 13, + "column": 18 + } + }, + "value": "" + }, + { + "type": "VExpressionStart", + "range": [ + 218, + 220 + ], + "loc": { + "start": { + "line": 13, + "column": 18 + }, + "end": { + "line": 13, + "column": 20 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "value": "count", + "start": 221, + "end": 226, + "loc": { + "start": { + "line": 13, + "column": 21 + }, + "end": { + "line": 13, + "column": 26 + } + }, + "range": [ + 221, + 226 + ] + }, + { + "type": "VExpressionEnd", + "range": [ + 227, + 229 + ], + "loc": { + "start": { + "line": 13, + "column": 27 + }, + "end": { + "line": 13, + "column": 29 + } + }, + "value": "}}" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 229, + 243 + ], + "loc": { + "start": { + "line": 13, + "column": 29 + }, + "end": { + "line": 13, + "column": 43 + } + }, + "value": "mycomponent1" + }, + { + "type": "HTMLTagClose", + "range": [ + 243, + 244 + ], + "loc": { + "start": { + "line": 13, + "column": 43 + }, + "end": { + "line": 13, + "column": 44 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 244, + 249 + ], + "loc": { + "start": { + "line": 13, + "column": 44 + }, + "end": { + "line": 14, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 249, + 262 + ], + "loc": { + "start": { + "line": 14, + "column": 4 + }, + "end": { + "line": 14, + "column": 17 + } + }, + "value": "mycomponent2" + }, + { + "type": "HTMLSelfClosingTagClose", + "range": [ + 262, + 264 + ], + "loc": { + "start": { + "line": 14, + "column": 17 + }, + "end": { + "line": 14, + "column": 19 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 264, + 265 + ], + "loc": { + "start": { + "line": 14, + "column": 19 + }, + "end": { + "line": 15, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 265, + 275 + ], + "loc": { + "start": { + "line": 15, + "column": 0 + }, + "end": { + "line": 15, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 275, + 276 + ], + "loc": { + "start": { + "line": 15, + "column": 10 + }, + "end": { + "line": 15, + "column": 11 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 276, + 278 + ], + "loc": { + "start": { + "line": 15, + "column": 11 + }, + "end": { + "line": 17, + "column": 0 + } + }, + "value": "\n\n" + } + ], + "comments": [], + "errors": [ + { + "message": "non-void-html-element-start-tag-with-trailing-solidus", + "index": 249, + "lineNumber": 14, + "column": 4 + } + ] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-7/parser-options.json b/test/fixtures/ast/multiple-scripts-7/parser-options.json new file mode 100644 index 00000000..2104ca43 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-7/parser-options.json @@ -0,0 +1,3 @@ +{ + "sourceType": "module" +} diff --git a/test/fixtures/ast/multiple-scripts-7/requirements.json b/test/fixtures/ast/multiple-scripts-7/requirements.json new file mode 100644 index 00000000..36659b1f --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-7/requirements.json @@ -0,0 +1,3 @@ +{ + "eslint": ">=8" +} \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-7/scope.json b/test/fixtures/ast/multiple-scripts-7/scope.json new file mode 100644 index 00000000..18858c17 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-7/scope.json @@ -0,0 +1,615 @@ +{ + "type": "global", + "variables": [], + "references": [], + "childScopes": [ + { + "type": "module", + "variables": [ + { + "name": "count", + "identifiers": [ + { + "type": "Identifier", + "name": "count", + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 16 + } + } + }, + { + "type": "Identifier", + "name": "count", + "loc": { + "start": { + "line": 7, + "column": 4 + }, + "end": { + "line": 7, + "column": 9 + } + } + } + ], + "defs": [ + { + "type": "Variable", + "node": { + "type": "VariableDeclarator", + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 21 + } + } + }, + "name": "count" + }, + { + "type": "Variable", + "node": { + "type": "VariableDeclarator", + "loc": { + "start": { + "line": 7, + "column": 4 + }, + "end": { + "line": 7, + "column": 14 + } + } + }, + "name": "count" + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "count", + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 16 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "count", + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 16 + } + } + }, + "init": true + }, + { + "identifier": { + "type": "Identifier", + "name": "count", + "loc": { + "start": { + "line": 7, + "column": 4 + }, + "end": { + "line": 7, + "column": 9 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "count", + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 16 + } + } + }, + "init": true + }, + { + "identifier": { + "type": "Identifier", + "name": "count", + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 16 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "count", + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 16 + } + } + }, + "init": null, + "vueUsedInTemplate": true + } + ] + }, + { + "name": "MyComponent1", + "identifiers": [ + { + "type": "Identifier", + "name": "MyComponent1", + "loc": { + "start": { + "line": 6, + "column": 7 + }, + "end": { + "line": 6, + "column": 19 + } + } + } + ], + "defs": [ + { + "type": "ImportBinding", + "node": { + "type": "ImportDefaultSpecifier", + "loc": { + "start": { + "line": 6, + "column": 7 + }, + "end": { + "line": 6, + "column": 19 + } + } + }, + "name": "MyComponent1" + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "MyComponent1", + "loc": { + "start": { + "line": 6, + "column": 7 + }, + "end": { + "line": 6, + "column": 19 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "MyComponent1", + "loc": { + "start": { + "line": 6, + "column": 7 + }, + "end": { + "line": 6, + "column": 19 + } + } + }, + "init": null, + "vueUsedInTemplate": true + } + ] + }, + { + "name": "MyComponent2", + "identifiers": [ + { + "type": "Identifier", + "name": "MyComponent2", + "loc": { + "start": { + "line": 8, + "column": 7 + }, + "end": { + "line": 8, + "column": 19 + } + } + } + ], + "defs": [ + { + "type": "ImportBinding", + "node": { + "type": "ImportDefaultSpecifier", + "loc": { + "start": { + "line": 8, + "column": 7 + }, + "end": { + "line": 8, + "column": 19 + } + } + }, + "name": "MyComponent2" + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "MyComponent2", + "loc": { + "start": { + "line": 8, + "column": 7 + }, + "end": { + "line": 8, + "column": 19 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "MyComponent2", + "loc": { + "start": { + "line": 8, + "column": 7 + }, + "end": { + "line": 8, + "column": 19 + } + } + }, + "init": null, + "vueUsedInTemplate": true + } + ] + }, + { + "name": "a", + "identifiers": [ + { + "type": "Identifier", + "name": "a", + "loc": { + "start": { + "line": 9, + "column": 4 + }, + "end": { + "line": 9, + "column": 5 + } + } + } + ], + "defs": [ + { + "type": "Variable", + "node": { + "type": "VariableDeclarator", + "loc": { + "start": { + "line": 9, + "column": 4 + }, + "end": { + "line": 9, + "column": 13 + } + } + }, + "name": "a" + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "a", + "loc": { + "start": { + "line": 9, + "column": 4 + }, + "end": { + "line": 9, + "column": 5 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "a", + "loc": { + "start": { + "line": 9, + "column": 4 + }, + "end": { + "line": 9, + "column": 5 + } + } + }, + "init": true + } + ] + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "count", + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 16 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "count", + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 16 + } + } + }, + "init": true + }, + { + "identifier": { + "type": "Identifier", + "name": "count", + "loc": { + "start": { + "line": 7, + "column": 4 + }, + "end": { + "line": 7, + "column": 9 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "count", + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 16 + } + } + }, + "init": true + }, + { + "identifier": { + "type": "Identifier", + "name": "a", + "loc": { + "start": { + "line": 9, + "column": 4 + }, + "end": { + "line": 9, + "column": 5 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "a", + "loc": { + "start": { + "line": 9, + "column": 4 + }, + "end": { + "line": 9, + "column": 5 + } + } + }, + "init": true + }, + { + "identifier": { + "type": "Identifier", + "name": "b", + "loc": { + "start": { + "line": 9, + "column": 8 + }, + "end": { + "line": 9, + "column": 9 + } + } + }, + "from": "module", + "resolved": null, + "init": null + }, + { + "identifier": { + "type": "Identifier", + "name": "c", + "loc": { + "start": { + "line": 9, + "column": 12 + }, + "end": { + "line": 9, + "column": 13 + } + } + }, + "from": "module", + "resolved": null, + "init": null + } + ], + "childScopes": [], + "through": [ + { + "identifier": { + "type": "Identifier", + "name": "b", + "loc": { + "start": { + "line": 9, + "column": 8 + }, + "end": { + "line": 9, + "column": 9 + } + } + }, + "from": "module", + "resolved": null, + "init": null + }, + { + "identifier": { + "type": "Identifier", + "name": "c", + "loc": { + "start": { + "line": 9, + "column": 12 + }, + "end": { + "line": 9, + "column": 13 + } + } + }, + "from": "module", + "resolved": null, + "init": null + } + ] + } + ], + "through": [ + { + "identifier": { + "type": "Identifier", + "name": "b", + "loc": { + "start": { + "line": 9, + "column": 8 + }, + "end": { + "line": 9, + "column": 9 + } + } + }, + "from": "module", + "resolved": null, + "init": null + }, + { + "identifier": { + "type": "Identifier", + "name": "c", + "loc": { + "start": { + "line": 9, + "column": 12 + }, + "end": { + "line": 9, + "column": 13 + } + } + }, + "from": "module", + "resolved": null, + "init": null + } + ] +} \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-7/source.vue b/test/fixtures/ast/multiple-scripts-7/source.vue new file mode 100644 index 00000000..3bd3b5d1 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-7/source.vue @@ -0,0 +1,16 @@ + + + + + + diff --git a/test/fixtures/ast/multiple-scripts-7/token-ranges.json b/test/fixtures/ast/multiple-scripts-7/token-ranges.json new file mode 100644 index 00000000..acbbc20c --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-7/token-ranges.json @@ -0,0 +1,105 @@ +[ + "", + "", + "", + "\n", + "export", + " ", + "let", + " ", + "count", + " ", + "=", + " ", + "42", + "\n", + "", + "\n\n", + "", + "\n", + "import", + " ", + "MyComponent1", + " ", + "from", + " ", + "'./MyComponent1.vue'", + "\n", + "let", + " ", + "count", + " ", + "=", + " ", + "42", + "\n", + "import", + " ", + "MyComponent2", + " ", + "from", + " ", + "'./MyComponent2.vue'", + "\n", + "let", + " ", + "a", + " ", + "=", + " ", + "b", + " ", + "+", + " ", + "c", + "\n", + "", + "\n\n", + "", + "\n ", + "", + "{{", + "count", + "}}", + "", + "\n ", + "", + "\n", + "", + "\n\n" +] \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-7/tree.json b/test/fixtures/ast/multiple-scripts-7/tree.json new file mode 100644 index 00000000..b3d62709 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-7/tree.json @@ -0,0 +1,71 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-8/ast.json b/test/fixtures/ast/multiple-scripts-8/ast.json new file mode 100644 index 00000000..2055eb94 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-8/ast.json @@ -0,0 +1,3448 @@ +{ + "type": "Program", + "start": 8, + "end": 340, + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 17, + "column": 13 + } + }, + "range": [ + 20, + 316 + ], + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 20, + "end": 41, + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 21 + } + }, + "range": [ + 20, + 41 + ], + "declaration": { + "type": "VariableDeclaration", + "start": 27, + "end": 41, + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 21 + } + }, + "range": [ + 27, + 41 + ], + "declarations": [ + { + "type": "VariableDeclarator", + "start": 31, + "end": 41, + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 3, + "column": 21 + } + }, + "range": [ + 31, + 41 + ], + "id": { + "type": "Identifier", + "start": 31, + "end": 36, + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 3, + "column": 16 + } + }, + "range": [ + 31, + 36 + ], + "name": "count" + }, + "init": { + "type": "Literal", + "start": 39, + "end": 41, + "loc": { + "start": { + "line": 3, + "column": 19 + }, + "end": { + "line": 3, + "column": 21 + } + }, + "range": [ + 39, + 41 + ], + "value": 42, + "raw": "42" + } + } + ], + "kind": "let" + }, + "specifiers": [], + "source": null, + "attributes": [] + }, + { + "type": "VariableDeclaration", + "start": 100, + "end": 108, + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 8 + } + }, + "range": [ + 100, + 108 + ], + "declarations": [ + { + "type": "VariableDeclarator", + "start": 104, + "end": 107, + "loc": { + "start": { + "line": 9, + "column": 4 + }, + "end": { + "line": 9, + "column": 7 + } + }, + "range": [ + 104, + 107 + ], + "id": { + "type": "Identifier", + "start": 104, + "end": 107, + "loc": { + "start": { + "line": 9, + "column": 4 + }, + "end": { + "line": 9, + "column": 7 + } + }, + "range": [ + 104, + 107 + ], + "name": "foo" + }, + "init": null + } + ], + "kind": "let" + }, + { + "type": "ImportDeclaration", + "start": 130, + "end": 175, + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 45 + } + }, + "range": [ + 130, + 175 + ], + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start": 137, + "end": 149, + "loc": { + "start": { + "line": 11, + "column": 7 + }, + "end": { + "line": 11, + "column": 19 + } + }, + "range": [ + 137, + 149 + ], + "local": { + "type": "Identifier", + "start": 137, + "end": 149, + "loc": { + "start": { + "line": 11, + "column": 7 + }, + "end": { + "line": 11, + "column": 19 + } + }, + "range": [ + 137, + 149 + ], + "name": "MyComponent1" + } + } + ], + "source": { + "type": "Literal", + "start": 155, + "end": 175, + "loc": { + "start": { + "line": 11, + "column": 25 + }, + "end": { + "line": 11, + "column": 45 + } + }, + "range": [ + 155, + 175 + ], + "value": "./MyComponent1.vue", + "raw": "'./MyComponent1.vue'" + }, + "attributes": [] + }, + { + "type": "VariableDeclaration", + "start": 197, + "end": 211, + "loc": { + "start": { + "line": 13, + "column": 0 + }, + "end": { + "line": 13, + "column": 14 + } + }, + "range": [ + 197, + 211 + ], + "declarations": [ + { + "type": "VariableDeclarator", + "start": 201, + "end": 211, + "loc": { + "start": { + "line": 13, + "column": 4 + }, + "end": { + "line": 13, + "column": 14 + } + }, + "range": [ + 201, + 211 + ], + "id": { + "type": "Identifier", + "start": 201, + "end": 206, + "loc": { + "start": { + "line": 13, + "column": 4 + }, + "end": { + "line": 13, + "column": 9 + } + }, + "range": [ + 201, + 206 + ], + "name": "count" + }, + "init": { + "type": "Literal", + "start": 209, + "end": 211, + "loc": { + "start": { + "line": 13, + "column": 12 + }, + "end": { + "line": 13, + "column": 14 + } + }, + "range": [ + 209, + 211 + ], + "value": 42, + "raw": "42" + } + } + ], + "kind": "let" + }, + { + "type": "ImportDeclaration", + "start": 234, + "end": 279, + "loc": { + "start": { + "line": 15, + "column": 0 + }, + "end": { + "line": 15, + "column": 45 + } + }, + "range": [ + 234, + 279 + ], + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start": 241, + "end": 253, + "loc": { + "start": { + "line": 15, + "column": 7 + }, + "end": { + "line": 15, + "column": 19 + } + }, + "range": [ + 241, + 253 + ], + "local": { + "type": "Identifier", + "start": 241, + "end": 253, + "loc": { + "start": { + "line": 15, + "column": 7 + }, + "end": { + "line": 15, + "column": 19 + } + }, + "range": [ + 241, + 253 + ], + "name": "MyComponent2" + } + } + ], + "source": { + "type": "Literal", + "start": 259, + "end": 279, + "loc": { + "start": { + "line": 15, + "column": 25 + }, + "end": { + "line": 15, + "column": 45 + } + }, + "range": [ + 259, + 279 + ], + "value": "./MyComponent2.vue", + "raw": "'./MyComponent2.vue'" + }, + "attributes": [] + }, + { + "type": "VariableDeclaration", + "start": 303, + "end": 316, + "loc": { + "start": { + "line": 17, + "column": 0 + }, + "end": { + "line": 17, + "column": 13 + } + }, + "range": [ + 303, + 316 + ], + "declarations": [ + { + "type": "VariableDeclarator", + "start": 307, + "end": 316, + "loc": { + "start": { + "line": 17, + "column": 4 + }, + "end": { + "line": 17, + "column": 13 + } + }, + "range": [ + 307, + 316 + ], + "id": { + "type": "Identifier", + "start": 307, + "end": 308, + "loc": { + "start": { + "line": 17, + "column": 4 + }, + "end": { + "line": 17, + "column": 5 + } + }, + "range": [ + 307, + 308 + ], + "name": "a" + }, + "init": { + "type": "BinaryExpression", + "start": 311, + "end": 316, + "loc": { + "start": { + "line": 17, + "column": 8 + }, + "end": { + "line": 17, + "column": 13 + } + }, + "range": [ + 311, + 316 + ], + "left": { + "type": "Identifier", + "start": 311, + "end": 312, + "loc": { + "start": { + "line": 17, + "column": 8 + }, + "end": { + "line": 17, + "column": 9 + } + }, + "range": [ + 311, + 312 + ], + "name": "b" + }, + "operator": "+", + "right": { + "type": "Identifier", + "start": 315, + "end": 316, + "loc": { + "start": { + "line": 17, + "column": 12 + }, + "end": { + "line": 17, + "column": 13 + } + }, + "range": [ + 315, + 316 + ], + "name": "c" + } + } + } + ], + "kind": "let" + } + ], + "sourceType": "module", + "comments": [ + { + "type": "Line", + "value": "comment1", + "start": 9, + "end": 19, + "range": [ + 9, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 10 + } + } + }, + { + "type": "Line", + "value": "comment2", + "start": 41, + "end": 51, + "range": [ + 41, + 51 + ], + "loc": { + "start": { + "line": 3, + "column": 21 + }, + "end": { + "line": 3, + "column": 31 + } + } + }, + { + "type": "Line", + "value": "comment3", + "start": 52, + "end": 62, + "range": [ + 52, + 62 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 10 + } + } + }, + { + "type": "Line", + "value": "comment4", + "start": 89, + "end": 99, + "range": [ + 89, + 99 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 10 + } + } + }, + { + "type": "Line", + "value": "comment5", + "start": 108, + "end": 118, + "range": [ + 108, + 118 + ], + "loc": { + "start": { + "line": 9, + "column": 8 + }, + "end": { + "line": 9, + "column": 18 + } + } + }, + { + "type": "Line", + "value": "comment6", + "start": 119, + "end": 129, + "range": [ + 119, + 129 + ], + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 10 + } + } + }, + { + "type": "Line", + "value": "comment7", + "start": 175, + "end": 185, + "range": [ + 175, + 185 + ], + "loc": { + "start": { + "line": 11, + "column": 45 + }, + "end": { + "line": 11, + "column": 55 + } + } + }, + { + "type": "Line", + "value": "comment8", + "start": 186, + "end": 196, + "range": [ + 186, + 196 + ], + "loc": { + "start": { + "line": 12, + "column": 0 + }, + "end": { + "line": 12, + "column": 10 + } + } + }, + { + "type": "Line", + "value": "comment9", + "start": 211, + "end": 221, + "range": [ + 211, + 221 + ], + "loc": { + "start": { + "line": 13, + "column": 14 + }, + "end": { + "line": 13, + "column": 24 + } + } + }, + { + "type": "Line", + "value": "comment10", + "start": 222, + "end": 233, + "range": [ + 222, + 233 + ], + "loc": { + "start": { + "line": 14, + "column": 0 + }, + "end": { + "line": 14, + "column": 11 + } + } + }, + { + "type": "Line", + "value": "comment11", + "start": 279, + "end": 290, + "range": [ + 279, + 290 + ], + "loc": { + "start": { + "line": 15, + "column": 45 + }, + "end": { + "line": 15, + "column": 56 + } + } + }, + { + "type": "Line", + "value": "comment12", + "start": 291, + "end": 302, + "range": [ + 291, + 302 + ], + "loc": { + "start": { + "line": 16, + "column": 0 + }, + "end": { + "line": 16, + "column": 11 + } + } + }, + { + "type": "Line", + "value": "comment13", + "start": 316, + "end": 327, + "range": [ + 316, + 327 + ], + "loc": { + "start": { + "line": 17, + "column": 13 + }, + "end": { + "line": 17, + "column": 24 + } + } + }, + { + "type": "Line", + "value": "comment14", + "start": 328, + "end": 339, + "range": [ + 328, + 339 + ], + "loc": { + "start": { + "line": 18, + "column": 0 + }, + "end": { + "line": 18, + "column": 11 + } + } + } + ], + "tokens": [ + { + "type": "Punctuator", + "range": [ + 0, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 74, + 88 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 14 + } + }, + "value": "" + } + ], + "templateBody": { + "type": "VElement", + "range": [ + 351, + 438 + ], + "loc": { + "start": { + "line": 21, + "column": 0 + }, + "end": { + "line": 24, + "column": 11 + } + }, + "name": "template", + "rawName": "template", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 351, + 361 + ], + "loc": { + "start": { + "line": 21, + "column": 0 + }, + "end": { + "line": 21, + "column": 10 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 361, + 366 + ], + "loc": { + "start": { + "line": 21, + "column": 10 + }, + "end": { + "line": 22, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 366, + 406 + ], + "loc": { + "start": { + "line": 22, + "column": 4 + }, + "end": { + "line": 22, + "column": 44 + } + }, + "name": "mycomponent1", + "rawName": "MyComponent1", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 366, + 380 + ], + "loc": { + "start": { + "line": 22, + "column": 4 + }, + "end": { + "line": 22, + "column": 18 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VExpressionContainer", + "range": [ + 380, + 391 + ], + "loc": { + "start": { + "line": 22, + "column": 18 + }, + "end": { + "line": 22, + "column": 29 + } + }, + "expression": { + "type": "Identifier", + "start": 383, + "end": 388, + "loc": { + "start": { + "line": 22, + "column": 21 + }, + "end": { + "line": 22, + "column": 26 + } + }, + "range": [ + 383, + 388 + ], + "name": "count" + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 383, + "end": 388, + "loc": { + "start": { + "line": 22, + "column": 21 + }, + "end": { + "line": 22, + "column": 26 + } + }, + "range": [ + 383, + 388 + ], + "name": "count" + }, + "mode": "r" + } + ] + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 391, + 406 + ], + "loc": { + "start": { + "line": 22, + "column": 29 + }, + "end": { + "line": 22, + "column": 44 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 406, + 411 + ], + "loc": { + "start": { + "line": 22, + "column": 44 + }, + "end": { + "line": 23, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 411, + 426 + ], + "loc": { + "start": { + "line": 23, + "column": 4 + }, + "end": { + "line": 23, + "column": 19 + } + }, + "name": "mycomponent2", + "rawName": "MyComponent2", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 411, + 426 + ], + "loc": { + "start": { + "line": 23, + "column": 4 + }, + "end": { + "line": 23, + "column": 19 + } + }, + "selfClosing": true, + "attributes": [] + }, + "children": [], + "endTag": null, + "variables": [] + }, + { + "type": "VText", + "range": [ + 426, + 427 + ], + "loc": { + "start": { + "line": 23, + "column": 19 + }, + "end": { + "line": 24, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 427, + 438 + ], + "loc": { + "start": { + "line": 24, + "column": 0 + }, + "end": { + "line": 24, + "column": 11 + } + } + }, + "variables": [], + "tokens": [ + { + "type": "HTMLTagOpen", + "range": [ + 0, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 7, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 8, + 9 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 9, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "value": "//comment1" + }, + { + "type": "HTMLWhitespace", + "range": [ + 19, + 20 + ], + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 20, + 26 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 6 + } + }, + "value": "export" + }, + { + "type": "HTMLWhitespace", + "range": [ + 26, + 27 + ], + "loc": { + "start": { + "line": 3, + "column": 6 + }, + "end": { + "line": 3, + "column": 7 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 27, + 30 + ], + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 10 + } + }, + "value": "let" + }, + { + "type": "HTMLWhitespace", + "range": [ + 30, + 31 + ], + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 31, + 36 + ], + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 3, + "column": 16 + } + }, + "value": "count" + }, + { + "type": "HTMLWhitespace", + "range": [ + 36, + 37 + ], + "loc": { + "start": { + "line": 3, + "column": 16 + }, + "end": { + "line": 3, + "column": 17 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 37, + 38 + ], + "loc": { + "start": { + "line": 3, + "column": 17 + }, + "end": { + "line": 3, + "column": 18 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 38, + 39 + ], + "loc": { + "start": { + "line": 3, + "column": 18 + }, + "end": { + "line": 3, + "column": 19 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 39, + 51 + ], + "loc": { + "start": { + "line": 3, + "column": 19 + }, + "end": { + "line": 3, + "column": 31 + } + }, + "value": "42//comment2" + }, + { + "type": "HTMLWhitespace", + "range": [ + 51, + 52 + ], + "loc": { + "start": { + "line": 3, + "column": 31 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 52, + 62 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 10 + } + }, + "value": "//comment3" + }, + { + "type": "HTMLWhitespace", + "range": [ + 62, + 63 + ], + "loc": { + "start": { + "line": 4, + "column": 10 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 63, + 71 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 71, + 72 + ], + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 72, + 74 + ], + "loc": { + "start": { + "line": 5, + "column": 9 + }, + "end": { + "line": 7, + "column": 0 + } + }, + "value": "\n\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 74, + 81 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLIdentifier", + "range": [ + 82, + 87 + ], + "loc": { + "start": { + "line": 7, + "column": 8 + }, + "end": { + "line": 7, + "column": 13 + } + }, + "value": "setup" + }, + { + "type": "HTMLTagClose", + "range": [ + 87, + 88 + ], + "loc": { + "start": { + "line": 7, + "column": 13 + }, + "end": { + "line": 7, + "column": 14 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 88, + 89 + ], + "loc": { + "start": { + "line": 7, + "column": 14 + }, + "end": { + "line": 8, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 89, + 99 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 10 + } + }, + "value": "//comment4" + }, + { + "type": "HTMLWhitespace", + "range": [ + 99, + 100 + ], + "loc": { + "start": { + "line": 8, + "column": 10 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 100, + 103 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 3 + } + }, + "value": "let" + }, + { + "type": "HTMLWhitespace", + "range": [ + 103, + 104 + ], + "loc": { + "start": { + "line": 9, + "column": 3 + }, + "end": { + "line": 9, + "column": 4 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 104, + 118 + ], + "loc": { + "start": { + "line": 9, + "column": 4 + }, + "end": { + "line": 9, + "column": 18 + } + }, + "value": "foo;//comment5" + }, + { + "type": "HTMLWhitespace", + "range": [ + 118, + 119 + ], + "loc": { + "start": { + "line": 9, + "column": 18 + }, + "end": { + "line": 10, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 119, + 129 + ], + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 10 + } + }, + "value": "//comment6" + }, + { + "type": "HTMLWhitespace", + "range": [ + 129, + 130 + ], + "loc": { + "start": { + "line": 10, + "column": 10 + }, + "end": { + "line": 11, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 130, + 136 + ], + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 6 + } + }, + "value": "import" + }, + { + "type": "HTMLWhitespace", + "range": [ + 136, + 137 + ], + "loc": { + "start": { + "line": 11, + "column": 6 + }, + "end": { + "line": 11, + "column": 7 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 137, + 149 + ], + "loc": { + "start": { + "line": 11, + "column": 7 + }, + "end": { + "line": 11, + "column": 19 + } + }, + "value": "MyComponent1" + }, + { + "type": "HTMLWhitespace", + "range": [ + 149, + 150 + ], + "loc": { + "start": { + "line": 11, + "column": 19 + }, + "end": { + "line": 11, + "column": 20 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 150, + 154 + ], + "loc": { + "start": { + "line": 11, + "column": 20 + }, + "end": { + "line": 11, + "column": 24 + } + }, + "value": "from" + }, + { + "type": "HTMLWhitespace", + "range": [ + 154, + 155 + ], + "loc": { + "start": { + "line": 11, + "column": 24 + }, + "end": { + "line": 11, + "column": 25 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 155, + 185 + ], + "loc": { + "start": { + "line": 11, + "column": 25 + }, + "end": { + "line": 11, + "column": 55 + } + }, + "value": "'./MyComponent1.vue'//comment7" + }, + { + "type": "HTMLWhitespace", + "range": [ + 185, + 186 + ], + "loc": { + "start": { + "line": 11, + "column": 55 + }, + "end": { + "line": 12, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 186, + 196 + ], + "loc": { + "start": { + "line": 12, + "column": 0 + }, + "end": { + "line": 12, + "column": 10 + } + }, + "value": "//comment8" + }, + { + "type": "HTMLWhitespace", + "range": [ + 196, + 197 + ], + "loc": { + "start": { + "line": 12, + "column": 10 + }, + "end": { + "line": 13, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 197, + 200 + ], + "loc": { + "start": { + "line": 13, + "column": 0 + }, + "end": { + "line": 13, + "column": 3 + } + }, + "value": "let" + }, + { + "type": "HTMLWhitespace", + "range": [ + 200, + 201 + ], + "loc": { + "start": { + "line": 13, + "column": 3 + }, + "end": { + "line": 13, + "column": 4 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 201, + 206 + ], + "loc": { + "start": { + "line": 13, + "column": 4 + }, + "end": { + "line": 13, + "column": 9 + } + }, + "value": "count" + }, + { + "type": "HTMLWhitespace", + "range": [ + 206, + 207 + ], + "loc": { + "start": { + "line": 13, + "column": 9 + }, + "end": { + "line": 13, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 207, + 208 + ], + "loc": { + "start": { + "line": 13, + "column": 10 + }, + "end": { + "line": 13, + "column": 11 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 208, + 209 + ], + "loc": { + "start": { + "line": 13, + "column": 11 + }, + "end": { + "line": 13, + "column": 12 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 209, + 221 + ], + "loc": { + "start": { + "line": 13, + "column": 12 + }, + "end": { + "line": 13, + "column": 24 + } + }, + "value": "42//comment9" + }, + { + "type": "HTMLWhitespace", + "range": [ + 221, + 222 + ], + "loc": { + "start": { + "line": 13, + "column": 24 + }, + "end": { + "line": 14, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 222, + 233 + ], + "loc": { + "start": { + "line": 14, + "column": 0 + }, + "end": { + "line": 14, + "column": 11 + } + }, + "value": "//comment10" + }, + { + "type": "HTMLWhitespace", + "range": [ + 233, + 234 + ], + "loc": { + "start": { + "line": 14, + "column": 11 + }, + "end": { + "line": 15, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 234, + 240 + ], + "loc": { + "start": { + "line": 15, + "column": 0 + }, + "end": { + "line": 15, + "column": 6 + } + }, + "value": "import" + }, + { + "type": "HTMLWhitespace", + "range": [ + 240, + 241 + ], + "loc": { + "start": { + "line": 15, + "column": 6 + }, + "end": { + "line": 15, + "column": 7 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 241, + 253 + ], + "loc": { + "start": { + "line": 15, + "column": 7 + }, + "end": { + "line": 15, + "column": 19 + } + }, + "value": "MyComponent2" + }, + { + "type": "HTMLWhitespace", + "range": [ + 253, + 254 + ], + "loc": { + "start": { + "line": 15, + "column": 19 + }, + "end": { + "line": 15, + "column": 20 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 254, + 258 + ], + "loc": { + "start": { + "line": 15, + "column": 20 + }, + "end": { + "line": 15, + "column": 24 + } + }, + "value": "from" + }, + { + "type": "HTMLWhitespace", + "range": [ + 258, + 259 + ], + "loc": { + "start": { + "line": 15, + "column": 24 + }, + "end": { + "line": 15, + "column": 25 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 259, + 290 + ], + "loc": { + "start": { + "line": 15, + "column": 25 + }, + "end": { + "line": 15, + "column": 56 + } + }, + "value": "'./MyComponent2.vue'//comment11" + }, + { + "type": "HTMLWhitespace", + "range": [ + 290, + 291 + ], + "loc": { + "start": { + "line": 15, + "column": 56 + }, + "end": { + "line": 16, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 291, + 302 + ], + "loc": { + "start": { + "line": 16, + "column": 0 + }, + "end": { + "line": 16, + "column": 11 + } + }, + "value": "//comment12" + }, + { + "type": "HTMLWhitespace", + "range": [ + 302, + 303 + ], + "loc": { + "start": { + "line": 16, + "column": 11 + }, + "end": { + "line": 17, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 303, + 306 + ], + "loc": { + "start": { + "line": 17, + "column": 0 + }, + "end": { + "line": 17, + "column": 3 + } + }, + "value": "let" + }, + { + "type": "HTMLWhitespace", + "range": [ + 306, + 307 + ], + "loc": { + "start": { + "line": 17, + "column": 3 + }, + "end": { + "line": 17, + "column": 4 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 307, + 308 + ], + "loc": { + "start": { + "line": 17, + "column": 4 + }, + "end": { + "line": 17, + "column": 5 + } + }, + "value": "a" + }, + { + "type": "HTMLWhitespace", + "range": [ + 308, + 309 + ], + "loc": { + "start": { + "line": 17, + "column": 5 + }, + "end": { + "line": 17, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 309, + 310 + ], + "loc": { + "start": { + "line": 17, + "column": 6 + }, + "end": { + "line": 17, + "column": 7 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 310, + 311 + ], + "loc": { + "start": { + "line": 17, + "column": 7 + }, + "end": { + "line": 17, + "column": 8 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 311, + 312 + ], + "loc": { + "start": { + "line": 17, + "column": 8 + }, + "end": { + "line": 17, + "column": 9 + } + }, + "value": "b" + }, + { + "type": "HTMLWhitespace", + "range": [ + 312, + 313 + ], + "loc": { + "start": { + "line": 17, + "column": 9 + }, + "end": { + "line": 17, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 313, + 314 + ], + "loc": { + "start": { + "line": 17, + "column": 10 + }, + "end": { + "line": 17, + "column": 11 + } + }, + "value": "+" + }, + { + "type": "HTMLWhitespace", + "range": [ + 314, + 315 + ], + "loc": { + "start": { + "line": 17, + "column": 11 + }, + "end": { + "line": 17, + "column": 12 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 315, + 327 + ], + "loc": { + "start": { + "line": 17, + "column": 12 + }, + "end": { + "line": 17, + "column": 24 + } + }, + "value": "c//comment13" + }, + { + "type": "HTMLWhitespace", + "range": [ + 327, + 328 + ], + "loc": { + "start": { + "line": 17, + "column": 24 + }, + "end": { + "line": 18, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 328, + 339 + ], + "loc": { + "start": { + "line": 18, + "column": 0 + }, + "end": { + "line": 18, + "column": 11 + } + }, + "value": "//comment14" + }, + { + "type": "HTMLWhitespace", + "range": [ + 339, + 340 + ], + "loc": { + "start": { + "line": 18, + "column": 11 + }, + "end": { + "line": 19, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 340, + 348 + ], + "loc": { + "start": { + "line": 19, + "column": 0 + }, + "end": { + "line": 19, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 348, + 349 + ], + "loc": { + "start": { + "line": 19, + "column": 8 + }, + "end": { + "line": 19, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 349, + 351 + ], + "loc": { + "start": { + "line": 19, + "column": 9 + }, + "end": { + "line": 21, + "column": 0 + } + }, + "value": "\n\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 351, + 360 + ], + "loc": { + "start": { + "line": 21, + "column": 0 + }, + "end": { + "line": 21, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 360, + 361 + ], + "loc": { + "start": { + "line": 21, + "column": 9 + }, + "end": { + "line": 21, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 361, + 366 + ], + "loc": { + "start": { + "line": 21, + "column": 10 + }, + "end": { + "line": 22, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 366, + 379 + ], + "loc": { + "start": { + "line": 22, + "column": 4 + }, + "end": { + "line": 22, + "column": 17 + } + }, + "value": "mycomponent1" + }, + { + "type": "HTMLTagClose", + "range": [ + 379, + 380 + ], + "loc": { + "start": { + "line": 22, + "column": 17 + }, + "end": { + "line": 22, + "column": 18 + } + }, + "value": "" + }, + { + "type": "VExpressionStart", + "range": [ + 380, + 382 + ], + "loc": { + "start": { + "line": 22, + "column": 18 + }, + "end": { + "line": 22, + "column": 20 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "value": "count", + "start": 383, + "end": 388, + "loc": { + "start": { + "line": 22, + "column": 21 + }, + "end": { + "line": 22, + "column": 26 + } + }, + "range": [ + 383, + 388 + ] + }, + { + "type": "VExpressionEnd", + "range": [ + 389, + 391 + ], + "loc": { + "start": { + "line": 22, + "column": 27 + }, + "end": { + "line": 22, + "column": 29 + } + }, + "value": "}}" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 391, + 405 + ], + "loc": { + "start": { + "line": 22, + "column": 29 + }, + "end": { + "line": 22, + "column": 43 + } + }, + "value": "mycomponent1" + }, + { + "type": "HTMLTagClose", + "range": [ + 405, + 406 + ], + "loc": { + "start": { + "line": 22, + "column": 43 + }, + "end": { + "line": 22, + "column": 44 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 406, + 411 + ], + "loc": { + "start": { + "line": 22, + "column": 44 + }, + "end": { + "line": 23, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 411, + 424 + ], + "loc": { + "start": { + "line": 23, + "column": 4 + }, + "end": { + "line": 23, + "column": 17 + } + }, + "value": "mycomponent2" + }, + { + "type": "HTMLSelfClosingTagClose", + "range": [ + 424, + 426 + ], + "loc": { + "start": { + "line": 23, + "column": 17 + }, + "end": { + "line": 23, + "column": 19 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 426, + 427 + ], + "loc": { + "start": { + "line": 23, + "column": 19 + }, + "end": { + "line": 24, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 427, + 437 + ], + "loc": { + "start": { + "line": 24, + "column": 0 + }, + "end": { + "line": 24, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 437, + 438 + ], + "loc": { + "start": { + "line": 24, + "column": 10 + }, + "end": { + "line": 24, + "column": 11 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 438, + 440 + ], + "loc": { + "start": { + "line": 24, + "column": 11 + }, + "end": { + "line": 26, + "column": 0 + } + }, + "value": "\n\n" + } + ], + "comments": [], + "errors": [ + { + "message": "non-void-html-element-start-tag-with-trailing-solidus", + "index": 411, + "lineNumber": 23, + "column": 4 + } + ] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-8/parser-options.json b/test/fixtures/ast/multiple-scripts-8/parser-options.json new file mode 100644 index 00000000..2104ca43 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-8/parser-options.json @@ -0,0 +1,3 @@ +{ + "sourceType": "module" +} diff --git a/test/fixtures/ast/multiple-scripts-8/requirements.json b/test/fixtures/ast/multiple-scripts-8/requirements.json new file mode 100644 index 00000000..36659b1f --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-8/requirements.json @@ -0,0 +1,3 @@ +{ + "eslint": ">=8" +} \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-8/source.vue b/test/fixtures/ast/multiple-scripts-8/source.vue new file mode 100644 index 00000000..64663ded --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-8/source.vue @@ -0,0 +1,25 @@ + + + + + + diff --git a/test/fixtures/ast/multiple-scripts-8/token-ranges.json b/test/fixtures/ast/multiple-scripts-8/token-ranges.json new file mode 100644 index 00000000..69888352 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-8/token-ranges.json @@ -0,0 +1,142 @@ +[ + "", + "", + "//comment1", + "//comment2", + "//comment3", + "//comment4", + "//comment5", + "//comment6", + "//comment7", + "//comment8", + "//comment9", + "//comment10", + "//comment11", + "//comment12", + "//comment13", + "//comment14", + "", + "\n", + "//comment1", + "\n", + "export", + " ", + "let", + " ", + "count", + " ", + "=", + " ", + "42//comment2", + "\n", + "//comment3", + "\n", + "", + "\n\n", + "", + "\n", + "//comment4", + "\n", + "let", + " ", + "foo;//comment5", + "\n", + "//comment6", + "\n", + "import", + " ", + "MyComponent1", + " ", + "from", + " ", + "'./MyComponent1.vue'//comment7", + "\n", + "//comment8", + "\n", + "let", + " ", + "count", + " ", + "=", + " ", + "42//comment9", + "\n", + "//comment10", + "\n", + "import", + " ", + "MyComponent2", + " ", + "from", + " ", + "'./MyComponent2.vue'//comment11", + "\n", + "//comment12", + "\n", + "let", + " ", + "a", + " ", + "=", + " ", + "b", + " ", + "+", + " ", + "c//comment13", + "\n", + "//comment14", + "\n", + "", + "\n\n", + "", + "\n ", + "", + "{{", + "count", + "}}", + "", + "\n ", + "", + "\n", + "", + "\n\n" +] \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-8/tree.json b/test/fixtures/ast/multiple-scripts-8/tree.json new file mode 100644 index 00000000..b3d62709 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-8/tree.json @@ -0,0 +1,71 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-9/ast.json b/test/fixtures/ast/multiple-scripts-9/ast.json new file mode 100644 index 00000000..00d1ffaf --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-9/ast.json @@ -0,0 +1,259 @@ +{ + "type": "Program", + "start": 2, + "end": 48, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 4, + "column": 13 + } + }, + "range": [ + 2, + 47 + ], + "body": [ + { + "type": "VariableDeclaration", + "start": 34, + "end": 47, + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 13 + } + }, + "range": [ + 34, + 47 + ], + "declarations": [ + { + "type": "VariableDeclarator", + "start": 38, + "end": 47, + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 13 + } + }, + "range": [ + 38, + 47 + ], + "id": { + "type": "Identifier", + "start": 38, + "end": 43, + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 9 + } + }, + "range": [ + 38, + 43 + ], + "name": "count" + }, + "init": { + "type": "Literal", + "start": 46, + "end": 47, + "loc": { + "start": { + "line": 4, + "column": 12 + }, + "end": { + "line": 4, + "column": 13 + } + }, + "range": [ + 46, + 47 + ], + "value": 0, + "raw": "0" + } + } + ], + "kind": "let" + } + ], + "sourceType": "module", + "comments": [], + "tokens": [ + { + "type": "Punctuator", + "range": [ + 0, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 19, + 33 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 14 + } + }, + "value": "" + } + ] +} \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-9/parser-options.json b/test/fixtures/ast/multiple-scripts-9/parser-options.json new file mode 100644 index 00000000..2104ca43 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-9/parser-options.json @@ -0,0 +1,3 @@ +{ + "sourceType": "module" +} diff --git a/test/fixtures/ast/multiple-scripts-9/requirements.json b/test/fixtures/ast/multiple-scripts-9/requirements.json new file mode 100644 index 00000000..36659b1f --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-9/requirements.json @@ -0,0 +1,3 @@ +{ + "eslint": ">=8" +} \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-9/source.vue b/test/fixtures/ast/multiple-scripts-9/source.vue new file mode 100644 index 00000000..90521f52 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-9/source.vue @@ -0,0 +1,5 @@ + + + diff --git a/test/fixtures/ast/multiple-scripts-9/token-ranges.json b/test/fixtures/ast/multiple-scripts-9/token-ranges.json new file mode 100644 index 00000000..1530a12e --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-9/token-ranges.json @@ -0,0 +1,10 @@ +[ + "", + "" +] \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-9/tree.json b/test/fixtures/ast/multiple-scripts-9/tree.json new file mode 100644 index 00000000..0637a088 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-9/tree.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-with-export01/ast.json b/test/fixtures/ast/multiple-scripts-with-export01/ast.json new file mode 100644 index 00000000..9b0ae9fb --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-export01/ast.json @@ -0,0 +1,463 @@ +{ + "type": "Program", + "start": 8, + "end": 75, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 6, + "column": 25 + } + }, + "range": [ + 9, + 74 + ], + "body": [ + { + "type": "VariableDeclaration", + "start": 9, + "end": 22, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "range": [ + 9, + 22 + ], + "declarations": [ + { + "type": "VariableDeclarator", + "start": 13, + "end": 22, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "range": [ + 13, + 22 + ], + "id": { + "type": "Identifier", + "start": 13, + "end": 18, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "range": [ + 13, + 18 + ], + "name": "count" + }, + "init": { + "type": "Literal", + "start": 21, + "end": 22, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "range": [ + 21, + 22 + ], + "value": 0, + "raw": "0" + } + } + ], + "kind": "let" + }, + { + "type": "ExportNamedDeclaration", + "start": 49, + "end": 74, + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 25 + } + }, + "range": [ + 49, + 74 + ], + "declaration": { + "type": "VariableDeclaration", + "start": 56, + "end": 74, + "loc": { + "start": { + "line": 6, + "column": 7 + }, + "end": { + "line": 6, + "column": 25 + } + }, + "range": [ + 56, + 74 + ], + "declarations": [ + { + "type": "VariableDeclarator", + "start": 60, + "end": 74, + "loc": { + "start": { + "line": 6, + "column": 11 + }, + "end": { + "line": 6, + "column": 25 + } + }, + "range": [ + 60, + 74 + ], + "id": { + "type": "Identifier", + "start": 60, + "end": 63, + "loc": { + "start": { + "line": 6, + "column": 11 + }, + "end": { + "line": 6, + "column": 14 + } + }, + "range": [ + 60, + 63 + ], + "name": "msg" + }, + "init": { + "type": "Literal", + "start": 66, + "end": 74, + "loc": { + "start": { + "line": 6, + "column": 17 + }, + "end": { + "line": 6, + "column": 25 + } + }, + "range": [ + 66, + 74 + ], + "value": "Hello!", + "raw": "'Hello!'" + } + } + ], + "kind": "let" + }, + "specifiers": [], + "source": null, + "attributes": [] + } + ], + "sourceType": "module", + "comments": [], + "tokens": [ + { + "type": "Punctuator", + "range": [ + 0, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 34, + 48 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 14 + } + }, + "value": "" + } + ] +} \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-with-export01/parser-options.json b/test/fixtures/ast/multiple-scripts-with-export01/parser-options.json new file mode 100644 index 00000000..2104ca43 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-export01/parser-options.json @@ -0,0 +1,3 @@ +{ + "sourceType": "module" +} diff --git a/test/fixtures/ast/multiple-scripts-with-export01/requirements.json b/test/fixtures/ast/multiple-scripts-with-export01/requirements.json new file mode 100644 index 00000000..36659b1f --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-export01/requirements.json @@ -0,0 +1,3 @@ +{ + "eslint": ">=8" +} \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-with-export01/source.vue b/test/fixtures/ast/multiple-scripts-with-export01/source.vue new file mode 100644 index 00000000..ae0413c9 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-export01/source.vue @@ -0,0 +1,7 @@ + + + diff --git a/test/fixtures/ast/multiple-scripts-with-export01/token-ranges.json b/test/fixtures/ast/multiple-scripts-with-export01/token-ranges.json new file mode 100644 index 00000000..c1a94ddf --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-export01/token-ranges.json @@ -0,0 +1,15 @@ +[ + "", + "" +] \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-with-export01/tree.json b/test/fixtures/ast/multiple-scripts-with-export01/tree.json new file mode 100644 index 00000000..0637a088 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-export01/tree.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-with-export02/ast.json b/test/fixtures/ast/multiple-scripts-with-export02/ast.json new file mode 100644 index 00000000..cf673aae --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-export02/ast.json @@ -0,0 +1,2525 @@ +{ + "type": "Program", + "start": 8, + "end": 262, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 18, + "column": 12 + } + }, + "range": [ + 9, + 261 + ], + "body": [ + { + "type": "VariableDeclaration", + "start": 9, + "end": 22, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "range": [ + 9, + 22 + ], + "declarations": [ + { + "type": "VariableDeclarator", + "start": 13, + "end": 22, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "range": [ + 13, + 22 + ], + "id": { + "type": "Identifier", + "start": 13, + "end": 18, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "range": [ + 13, + 18 + ], + "name": "count" + }, + "init": { + "type": "Literal", + "start": 21, + "end": 22, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "range": [ + 21, + 22 + ], + "value": 0, + "raw": "0" + } + } + ], + "kind": "let" + }, + { + "type": "ImportDeclaration", + "start": 49, + "end": 66, + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 17 + } + }, + "range": [ + 49, + 66 + ], + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start": 56, + "end": 57, + "loc": { + "start": { + "line": 6, + "column": 7 + }, + "end": { + "line": 6, + "column": 8 + } + }, + "range": [ + 56, + 57 + ], + "local": { + "type": "Identifier", + "start": 56, + "end": 57, + "loc": { + "start": { + "line": 6, + "column": 7 + }, + "end": { + "line": 6, + "column": 8 + } + }, + "range": [ + 56, + 57 + ], + "name": "A" + } + } + ], + "source": { + "type": "Literal", + "start": 63, + "end": 66, + "loc": { + "start": { + "line": 6, + "column": 14 + }, + "end": { + "line": 6, + "column": 17 + } + }, + "range": [ + 63, + 66 + ], + "value": "a", + "raw": "'a'" + }, + "attributes": [] + }, + { + "type": "VariableDeclaration", + "start": 67, + "end": 79, + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 12 + } + }, + "range": [ + 67, + 79 + ], + "declarations": [ + { + "type": "VariableDeclarator", + "start": 73, + "end": 79, + "loc": { + "start": { + "line": 7, + "column": 6 + }, + "end": { + "line": 7, + "column": 12 + } + }, + "range": [ + 73, + 79 + ], + "id": { + "type": "Identifier", + "start": 73, + "end": 74, + "loc": { + "start": { + "line": 7, + "column": 6 + }, + "end": { + "line": 7, + "column": 7 + } + }, + "range": [ + 73, + 74 + ], + "name": "a" + }, + "init": { + "type": "Literal", + "start": 77, + "end": 79, + "loc": { + "start": { + "line": 7, + "column": 10 + }, + "end": { + "line": 7, + "column": 12 + } + }, + "range": [ + 77, + 79 + ], + "value": 42, + "raw": "42" + } + } + ], + "kind": "const" + }, + { + "type": "ExportNamedDeclaration", + "start": 80, + "end": 105, + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 25 + } + }, + "range": [ + 80, + 105 + ], + "declaration": { + "type": "VariableDeclaration", + "start": 87, + "end": 105, + "loc": { + "start": { + "line": 8, + "column": 7 + }, + "end": { + "line": 8, + "column": 25 + } + }, + "range": [ + 87, + 105 + ], + "declarations": [ + { + "type": "VariableDeclarator", + "start": 91, + "end": 105, + "loc": { + "start": { + "line": 8, + "column": 11 + }, + "end": { + "line": 8, + "column": 25 + } + }, + "range": [ + 91, + 105 + ], + "id": { + "type": "Identifier", + "start": 91, + "end": 94, + "loc": { + "start": { + "line": 8, + "column": 11 + }, + "end": { + "line": 8, + "column": 14 + } + }, + "range": [ + 91, + 94 + ], + "name": "msg" + }, + "init": { + "type": "Literal", + "start": 97, + "end": 105, + "loc": { + "start": { + "line": 8, + "column": 17 + }, + "end": { + "line": 8, + "column": 25 + } + }, + "range": [ + 97, + 105 + ], + "value": "Hello!", + "raw": "'Hello!'" + } + } + ], + "kind": "let" + }, + "specifiers": [], + "source": null, + "attributes": [] + }, + { + "type": "ImportDeclaration", + "start": 106, + "end": 123, + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 17 + } + }, + "range": [ + 106, + 123 + ], + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start": 113, + "end": 114, + "loc": { + "start": { + "line": 9, + "column": 7 + }, + "end": { + "line": 9, + "column": 8 + } + }, + "range": [ + 113, + 114 + ], + "local": { + "type": "Identifier", + "start": 113, + "end": 114, + "loc": { + "start": { + "line": 9, + "column": 7 + }, + "end": { + "line": 9, + "column": 8 + } + }, + "range": [ + 113, + 114 + ], + "name": "B" + } + } + ], + "source": { + "type": "Literal", + "start": 120, + "end": 123, + "loc": { + "start": { + "line": 9, + "column": 14 + }, + "end": { + "line": 9, + "column": 17 + } + }, + "range": [ + 120, + 123 + ], + "value": "a", + "raw": "'a'" + }, + "attributes": [] + }, + { + "type": "VariableDeclaration", + "start": 124, + "end": 136, + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 12 + } + }, + "range": [ + 124, + 136 + ], + "declarations": [ + { + "type": "VariableDeclarator", + "start": 130, + "end": 136, + "loc": { + "start": { + "line": 10, + "column": 6 + }, + "end": { + "line": 10, + "column": 12 + } + }, + "range": [ + 130, + 136 + ], + "id": { + "type": "Identifier", + "start": 130, + "end": 131, + "loc": { + "start": { + "line": 10, + "column": 6 + }, + "end": { + "line": 10, + "column": 7 + } + }, + "range": [ + 130, + 131 + ], + "name": "b" + }, + "init": { + "type": "Literal", + "start": 134, + "end": 136, + "loc": { + "start": { + "line": 10, + "column": 10 + }, + "end": { + "line": 10, + "column": 12 + } + }, + "range": [ + 134, + 136 + ], + "value": 42, + "raw": "42" + } + } + ], + "kind": "const" + }, + { + "type": "ExportAllDeclaration", + "start": 137, + "end": 156, + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 19 + } + }, + "range": [ + 137, + 156 + ], + "exported": null, + "source": { + "type": "Literal", + "start": 151, + "end": 156, + "loc": { + "start": { + "line": 11, + "column": 14 + }, + "end": { + "line": 11, + "column": 19 + } + }, + "range": [ + 151, + 156 + ], + "value": "foo", + "raw": "'foo'" + }, + "attributes": [] + }, + { + "type": "VariableDeclaration", + "start": 157, + "end": 169, + "loc": { + "start": { + "line": 12, + "column": 0 + }, + "end": { + "line": 12, + "column": 12 + } + }, + "range": [ + 157, + 169 + ], + "declarations": [ + { + "type": "VariableDeclarator", + "start": 163, + "end": 169, + "loc": { + "start": { + "line": 12, + "column": 6 + }, + "end": { + "line": 12, + "column": 12 + } + }, + "range": [ + 163, + 169 + ], + "id": { + "type": "Identifier", + "start": 163, + "end": 164, + "loc": { + "start": { + "line": 12, + "column": 6 + }, + "end": { + "line": 12, + "column": 7 + } + }, + "range": [ + 163, + 164 + ], + "name": "c" + }, + "init": { + "type": "Literal", + "start": 167, + "end": 169, + "loc": { + "start": { + "line": 12, + "column": 10 + }, + "end": { + "line": 12, + "column": 12 + } + }, + "range": [ + 167, + 169 + ], + "value": 42, + "raw": "42" + } + } + ], + "kind": "const" + }, + { + "type": "ExportDefaultDeclaration", + "start": 170, + "end": 187, + "loc": { + "start": { + "line": 13, + "column": 0 + }, + "end": { + "line": 13, + "column": 17 + } + }, + "range": [ + 170, + 187 + ], + "declaration": { + "type": "ObjectExpression", + "start": 185, + "end": 187, + "loc": { + "start": { + "line": 13, + "column": 15 + }, + "end": { + "line": 13, + "column": 17 + } + }, + "range": [ + 185, + 187 + ], + "properties": [] + } + }, + { + "type": "VariableDeclaration", + "start": 188, + "end": 200, + "loc": { + "start": { + "line": 14, + "column": 0 + }, + "end": { + "line": 14, + "column": 12 + } + }, + "range": [ + 188, + 200 + ], + "declarations": [ + { + "type": "VariableDeclarator", + "start": 194, + "end": 200, + "loc": { + "start": { + "line": 14, + "column": 6 + }, + "end": { + "line": 14, + "column": 12 + } + }, + "range": [ + 194, + 200 + ], + "id": { + "type": "Identifier", + "start": 194, + "end": 195, + "loc": { + "start": { + "line": 14, + "column": 6 + }, + "end": { + "line": 14, + "column": 7 + } + }, + "range": [ + 194, + 195 + ], + "name": "d" + }, + "init": { + "type": "Literal", + "start": 198, + "end": 200, + "loc": { + "start": { + "line": 14, + "column": 10 + }, + "end": { + "line": 14, + "column": 12 + } + }, + "range": [ + 198, + 200 + ], + "value": 42, + "raw": "42" + } + } + ], + "kind": "const" + }, + { + "type": "ExportNamedDeclaration", + "start": 201, + "end": 213, + "loc": { + "start": { + "line": 15, + "column": 0 + }, + "end": { + "line": 15, + "column": 12 + } + }, + "range": [ + 201, + 213 + ], + "declaration": null, + "specifiers": [ + { + "type": "ExportSpecifier", + "start": 209, + "end": 210, + "loc": { + "start": { + "line": 15, + "column": 8 + }, + "end": { + "line": 15, + "column": 9 + } + }, + "range": [ + 209, + 210 + ], + "local": { + "type": "Identifier", + "start": 209, + "end": 210, + "loc": { + "start": { + "line": 15, + "column": 8 + }, + "end": { + "line": 15, + "column": 9 + } + }, + "range": [ + 209, + 210 + ], + "name": "b" + }, + "exported": { + "type": "Identifier", + "start": 209, + "end": 210, + "loc": { + "start": { + "line": 15, + "column": 8 + }, + "end": { + "line": 15, + "column": 9 + } + }, + "range": [ + 209, + 210 + ], + "name": "b" + } + }, + { + "type": "ExportSpecifier", + "start": 211, + "end": 212, + "loc": { + "start": { + "line": 15, + "column": 10 + }, + "end": { + "line": 15, + "column": 11 + } + }, + "range": [ + 211, + 212 + ], + "local": { + "type": "Identifier", + "start": 211, + "end": 212, + "loc": { + "start": { + "line": 15, + "column": 10 + }, + "end": { + "line": 15, + "column": 11 + } + }, + "range": [ + 211, + 212 + ], + "name": "c" + }, + "exported": { + "type": "Identifier", + "start": 211, + "end": 212, + "loc": { + "start": { + "line": 15, + "column": 10 + }, + "end": { + "line": 15, + "column": 11 + } + }, + "range": [ + 211, + 212 + ], + "name": "c" + } + } + ], + "source": null, + "attributes": [] + }, + { + "type": "ExportNamedDeclaration", + "start": 214, + "end": 238, + "loc": { + "start": { + "line": 16, + "column": 0 + }, + "end": { + "line": 16, + "column": 24 + } + }, + "range": [ + 214, + 238 + ], + "declaration": null, + "specifiers": [ + { + "type": "ExportSpecifier", + "start": 222, + "end": 229, + "loc": { + "start": { + "line": 16, + "column": 8 + }, + "end": { + "line": 16, + "column": 15 + } + }, + "range": [ + 222, + 229 + ], + "local": { + "type": "Identifier", + "start": 222, + "end": 223, + "loc": { + "start": { + "line": 16, + "column": 8 + }, + "end": { + "line": 16, + "column": 9 + } + }, + "range": [ + 222, + 223 + ], + "name": "b" + }, + "exported": { + "type": "Identifier", + "start": 227, + "end": 229, + "loc": { + "start": { + "line": 16, + "column": 13 + }, + "end": { + "line": 16, + "column": 15 + } + }, + "range": [ + 227, + 229 + ], + "name": "b2" + } + }, + { + "type": "ExportSpecifier", + "start": 230, + "end": 237, + "loc": { + "start": { + "line": 16, + "column": 16 + }, + "end": { + "line": 16, + "column": 23 + } + }, + "range": [ + 230, + 237 + ], + "local": { + "type": "Identifier", + "start": 230, + "end": 231, + "loc": { + "start": { + "line": 16, + "column": 16 + }, + "end": { + "line": 16, + "column": 17 + } + }, + "range": [ + 230, + 231 + ], + "name": "c" + }, + "exported": { + "type": "Identifier", + "start": 235, + "end": 237, + "loc": { + "start": { + "line": 16, + "column": 21 + }, + "end": { + "line": 16, + "column": 23 + } + }, + "range": [ + 235, + 237 + ], + "name": "c2" + } + } + ], + "source": null, + "attributes": [] + }, + { + "type": "ExportNamedDeclaration", + "start": 239, + "end": 248, + "loc": { + "start": { + "line": 17, + "column": 0 + }, + "end": { + "line": 17, + "column": 9 + } + }, + "range": [ + 239, + 248 + ], + "declaration": null, + "specifiers": [], + "source": null, + "attributes": [] + }, + { + "type": "VariableDeclaration", + "start": 249, + "end": 261, + "loc": { + "start": { + "line": 18, + "column": 0 + }, + "end": { + "line": 18, + "column": 12 + } + }, + "range": [ + 249, + 261 + ], + "declarations": [ + { + "type": "VariableDeclarator", + "start": 255, + "end": 261, + "loc": { + "start": { + "line": 18, + "column": 6 + }, + "end": { + "line": 18, + "column": 12 + } + }, + "range": [ + 255, + 261 + ], + "id": { + "type": "Identifier", + "start": 255, + "end": 256, + "loc": { + "start": { + "line": 18, + "column": 6 + }, + "end": { + "line": 18, + "column": 7 + } + }, + "range": [ + 255, + 256 + ], + "name": "e" + }, + "init": { + "type": "Literal", + "start": 259, + "end": 261, + "loc": { + "start": { + "line": 18, + "column": 10 + }, + "end": { + "line": 18, + "column": 12 + } + }, + "range": [ + 259, + 261 + ], + "value": 42, + "raw": "42" + } + } + ], + "kind": "const" + } + ], + "sourceType": "module", + "comments": [], + "tokens": [ + { + "type": "Punctuator", + "range": [ + 0, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 34, + 48 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 14 + } + }, + "value": "" + } + ] +} \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-with-export02/parser-options.json b/test/fixtures/ast/multiple-scripts-with-export02/parser-options.json new file mode 100644 index 00000000..2104ca43 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-export02/parser-options.json @@ -0,0 +1,3 @@ +{ + "sourceType": "module" +} diff --git a/test/fixtures/ast/multiple-scripts-with-export02/requirements.json b/test/fixtures/ast/multiple-scripts-with-export02/requirements.json new file mode 100644 index 00000000..36659b1f --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-export02/requirements.json @@ -0,0 +1,3 @@ +{ + "eslint": ">=8" +} \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-with-export02/source.vue b/test/fixtures/ast/multiple-scripts-with-export02/source.vue new file mode 100644 index 00000000..67210d80 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-export02/source.vue @@ -0,0 +1,19 @@ + + + diff --git a/test/fixtures/ast/multiple-scripts-with-export02/token-ranges.json b/test/fixtures/ast/multiple-scripts-with-export02/token-ranges.json new file mode 100644 index 00000000..b5d9365b --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-export02/token-ranges.json @@ -0,0 +1,70 @@ +[ + "", + "" +] \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-with-export02/tree.json b/test/fixtures/ast/multiple-scripts-with-export02/tree.json new file mode 100644 index 00000000..0637a088 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-export02/tree.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-with-export03/ast.json b/test/fixtures/ast/multiple-scripts-with-export03/ast.json new file mode 100644 index 00000000..fff01a7e --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-export03/ast.json @@ -0,0 +1,2060 @@ +{ + "type": "Program", + "start": 8, + "end": 241, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 15, + "column": 12 + } + }, + "range": [ + 9, + 240 + ], + "body": [ + { + "type": "VariableDeclaration", + "start": 9, + "end": 22, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "range": [ + 9, + 22 + ], + "declarations": [ + { + "type": "VariableDeclarator", + "start": 13, + "end": 22, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "range": [ + 13, + 22 + ], + "id": { + "type": "Identifier", + "start": 13, + "end": 18, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "range": [ + 13, + 18 + ], + "name": "count" + }, + "init": { + "type": "Literal", + "start": 21, + "end": 22, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "range": [ + 21, + 22 + ], + "value": 0, + "raw": "0" + } + } + ], + "kind": "let" + }, + { + "type": "VariableDeclaration", + "start": 49, + "end": 61, + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 12 + } + }, + "range": [ + 49, + 61 + ], + "declarations": [ + { + "type": "VariableDeclarator", + "start": 55, + "end": 61, + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 12 + } + }, + "range": [ + 55, + 61 + ], + "id": { + "type": "Identifier", + "start": 55, + "end": 56, + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 7 + } + }, + "range": [ + 55, + 56 + ], + "name": "a" + }, + "init": { + "type": "Literal", + "start": 59, + "end": 61, + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 12 + } + }, + "range": [ + 59, + 61 + ], + "value": 42, + "raw": "42" + } + } + ], + "kind": "const" + }, + { + "type": "ImportDeclaration", + "start": 62, + "end": 81, + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 19 + } + }, + "range": [ + 62, + 81 + ], + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start": 69, + "end": 70, + "loc": { + "start": { + "line": 7, + "column": 7 + }, + "end": { + "line": 7, + "column": 8 + } + }, + "range": [ + 69, + 70 + ], + "local": { + "type": "Identifier", + "start": 69, + "end": 70, + "loc": { + "start": { + "line": 7, + "column": 7 + }, + "end": { + "line": 7, + "column": 8 + } + }, + "range": [ + 69, + 70 + ], + "name": "A" + } + } + ], + "source": { + "type": "Literal", + "start": 76, + "end": 81, + "loc": { + "start": { + "line": 7, + "column": 14 + }, + "end": { + "line": 7, + "column": 19 + } + }, + "range": [ + 76, + 81 + ], + "value": "foo", + "raw": "'foo'" + }, + "attributes": [] + }, + { + "type": "ExportAllDeclaration", + "start": 82, + "end": 107, + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 25 + } + }, + "range": [ + 82, + 107 + ], + "exported": { + "type": "Identifier", + "start": 94, + "end": 96, + "loc": { + "start": { + "line": 8, + "column": 12 + }, + "end": { + "line": 8, + "column": 14 + } + }, + "range": [ + 94, + 96 + ], + "name": "ns" + }, + "source": { + "type": "Literal", + "start": 102, + "end": 107, + "loc": { + "start": { + "line": 8, + "column": 20 + }, + "end": { + "line": 8, + "column": 25 + } + }, + "range": [ + 102, + 107 + ], + "value": "foo", + "raw": "'foo'" + }, + "attributes": [] + }, + { + "type": "ImportDeclaration", + "start": 108, + "end": 127, + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 19 + } + }, + "range": [ + 108, + 127 + ], + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start": 115, + "end": 116, + "loc": { + "start": { + "line": 9, + "column": 7 + }, + "end": { + "line": 9, + "column": 8 + } + }, + "range": [ + 115, + 116 + ], + "local": { + "type": "Identifier", + "start": 115, + "end": 116, + "loc": { + "start": { + "line": 9, + "column": 7 + }, + "end": { + "line": 9, + "column": 8 + } + }, + "range": [ + 115, + 116 + ], + "name": "B" + } + } + ], + "source": { + "type": "Literal", + "start": 122, + "end": 127, + "loc": { + "start": { + "line": 9, + "column": 14 + }, + "end": { + "line": 9, + "column": 19 + } + }, + "range": [ + 122, + 127 + ], + "value": "foo", + "raw": "'foo'" + }, + "attributes": [] + }, + { + "type": "VariableDeclaration", + "start": 128, + "end": 140, + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 12 + } + }, + "range": [ + 128, + 140 + ], + "declarations": [ + { + "type": "VariableDeclarator", + "start": 134, + "end": 140, + "loc": { + "start": { + "line": 10, + "column": 6 + }, + "end": { + "line": 10, + "column": 12 + } + }, + "range": [ + 134, + 140 + ], + "id": { + "type": "Identifier", + "start": 134, + "end": 135, + "loc": { + "start": { + "line": 10, + "column": 6 + }, + "end": { + "line": 10, + "column": 7 + } + }, + "range": [ + 134, + 135 + ], + "name": "b" + }, + "init": { + "type": "Literal", + "start": 138, + "end": 140, + "loc": { + "start": { + "line": 10, + "column": 10 + }, + "end": { + "line": 10, + "column": 12 + } + }, + "range": [ + 138, + 140 + ], + "value": 42, + "raw": "42" + } + } + ], + "kind": "const" + }, + { + "type": "ExportNamedDeclaration", + "start": 141, + "end": 164, + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 23 + } + }, + "range": [ + 141, + 164 + ], + "declaration": null, + "specifiers": [ + { + "type": "ExportSpecifier", + "start": 149, + "end": 152, + "loc": { + "start": { + "line": 11, + "column": 8 + }, + "end": { + "line": 11, + "column": 11 + } + }, + "range": [ + 149, + 152 + ], + "local": { + "type": "Identifier", + "start": 149, + "end": 152, + "loc": { + "start": { + "line": 11, + "column": 8 + }, + "end": { + "line": 11, + "column": 11 + } + }, + "range": [ + 149, + 152 + ], + "name": "ns2" + }, + "exported": { + "type": "Identifier", + "start": 149, + "end": 152, + "loc": { + "start": { + "line": 11, + "column": 8 + }, + "end": { + "line": 11, + "column": 11 + } + }, + "range": [ + 149, + 152 + ], + "name": "ns2" + } + } + ], + "source": { + "type": "Literal", + "start": 159, + "end": 164, + "loc": { + "start": { + "line": 11, + "column": 18 + }, + "end": { + "line": 11, + "column": 23 + } + }, + "range": [ + 159, + 164 + ], + "value": "foo", + "raw": "'foo'" + }, + "attributes": [] + }, + { + "type": "VariableDeclaration", + "start": 165, + "end": 177, + "loc": { + "start": { + "line": 12, + "column": 0 + }, + "end": { + "line": 12, + "column": 12 + } + }, + "range": [ + 165, + 177 + ], + "declarations": [ + { + "type": "VariableDeclarator", + "start": 171, + "end": 177, + "loc": { + "start": { + "line": 12, + "column": 6 + }, + "end": { + "line": 12, + "column": 12 + } + }, + "range": [ + 171, + 177 + ], + "id": { + "type": "Identifier", + "start": 171, + "end": 172, + "loc": { + "start": { + "line": 12, + "column": 6 + }, + "end": { + "line": 12, + "column": 7 + } + }, + "range": [ + 171, + 172 + ], + "name": "c" + }, + "init": { + "type": "Literal", + "start": 175, + "end": 177, + "loc": { + "start": { + "line": 12, + "column": 10 + }, + "end": { + "line": 12, + "column": 12 + } + }, + "range": [ + 175, + 177 + ], + "value": 42, + "raw": "42" + } + } + ], + "kind": "const" + }, + { + "type": "ImportDeclaration", + "start": 178, + "end": 197, + "loc": { + "start": { + "line": 13, + "column": 0 + }, + "end": { + "line": 13, + "column": 19 + } + }, + "range": [ + 178, + 197 + ], + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start": 185, + "end": 186, + "loc": { + "start": { + "line": 13, + "column": 7 + }, + "end": { + "line": 13, + "column": 8 + } + }, + "range": [ + 185, + 186 + ], + "local": { + "type": "Identifier", + "start": 185, + "end": 186, + "loc": { + "start": { + "line": 13, + "column": 7 + }, + "end": { + "line": 13, + "column": 8 + } + }, + "range": [ + 185, + 186 + ], + "name": "C" + } + } + ], + "source": { + "type": "Literal", + "start": 192, + "end": 197, + "loc": { + "start": { + "line": 13, + "column": 14 + }, + "end": { + "line": 13, + "column": 19 + } + }, + "range": [ + 192, + 197 + ], + "value": "foo", + "raw": "'foo'" + }, + "attributes": [] + }, + { + "type": "ExportNamedDeclaration", + "start": 198, + "end": 227, + "loc": { + "start": { + "line": 14, + "column": 0 + }, + "end": { + "line": 14, + "column": 29 + } + }, + "range": [ + 198, + 227 + ], + "declaration": null, + "specifiers": [ + { + "type": "ExportSpecifier", + "start": 206, + "end": 215, + "loc": { + "start": { + "line": 14, + "column": 8 + }, + "end": { + "line": 14, + "column": 17 + } + }, + "range": [ + 206, + 215 + ], + "local": { + "type": "Identifier", + "start": 206, + "end": 208, + "loc": { + "start": { + "line": 14, + "column": 8 + }, + "end": { + "line": 14, + "column": 10 + } + }, + "range": [ + 206, + 208 + ], + "name": "ns" + }, + "exported": { + "type": "Identifier", + "start": 212, + "end": 215, + "loc": { + "start": { + "line": 14, + "column": 14 + }, + "end": { + "line": 14, + "column": 17 + } + }, + "range": [ + 212, + 215 + ], + "name": "ns3" + } + } + ], + "source": { + "type": "Literal", + "start": 222, + "end": 227, + "loc": { + "start": { + "line": 14, + "column": 24 + }, + "end": { + "line": 14, + "column": 29 + } + }, + "range": [ + 222, + 227 + ], + "value": "foo", + "raw": "'foo'" + }, + "attributes": [] + }, + { + "type": "VariableDeclaration", + "start": 228, + "end": 240, + "loc": { + "start": { + "line": 15, + "column": 0 + }, + "end": { + "line": 15, + "column": 12 + } + }, + "range": [ + 228, + 240 + ], + "declarations": [ + { + "type": "VariableDeclarator", + "start": 234, + "end": 240, + "loc": { + "start": { + "line": 15, + "column": 6 + }, + "end": { + "line": 15, + "column": 12 + } + }, + "range": [ + 234, + 240 + ], + "id": { + "type": "Identifier", + "start": 234, + "end": 235, + "loc": { + "start": { + "line": 15, + "column": 6 + }, + "end": { + "line": 15, + "column": 7 + } + }, + "range": [ + 234, + 235 + ], + "name": "d" + }, + "init": { + "type": "Literal", + "start": 238, + "end": 240, + "loc": { + "start": { + "line": 15, + "column": 10 + }, + "end": { + "line": 15, + "column": 12 + } + }, + "range": [ + 238, + 240 + ], + "value": 42, + "raw": "42" + } + } + ], + "kind": "const" + } + ], + "sourceType": "module", + "comments": [], + "tokens": [ + { + "type": "Punctuator", + "range": [ + 0, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 34, + 48 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 14 + } + }, + "value": "" + } + ] +} \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-with-export03/parser-options.json b/test/fixtures/ast/multiple-scripts-with-export03/parser-options.json new file mode 100644 index 00000000..2104ca43 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-export03/parser-options.json @@ -0,0 +1,3 @@ +{ + "sourceType": "module" +} diff --git a/test/fixtures/ast/multiple-scripts-with-export03/requirements.json b/test/fixtures/ast/multiple-scripts-with-export03/requirements.json new file mode 100644 index 00000000..36659b1f --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-export03/requirements.json @@ -0,0 +1,3 @@ +{ + "eslint": ">=8" +} \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-with-export03/source.vue b/test/fixtures/ast/multiple-scripts-with-export03/source.vue new file mode 100644 index 00000000..c1b579c6 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-export03/source.vue @@ -0,0 +1,16 @@ + + + diff --git a/test/fixtures/ast/multiple-scripts-with-export03/token-ranges.json b/test/fixtures/ast/multiple-scripts-with-export03/token-ranges.json new file mode 100644 index 00000000..fc1ab24d --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-export03/token-ranges.json @@ -0,0 +1,58 @@ +[ + "", + "" +] \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-with-export03/tree.json b/test/fixtures/ast/multiple-scripts-with-export03/tree.json new file mode 100644 index 00000000..0637a088 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-export03/tree.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-with-export04/ast.json b/test/fixtures/ast/multiple-scripts-with-export04/ast.json new file mode 100644 index 00000000..cfbba14f --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-export04/ast.json @@ -0,0 +1,1196 @@ +{ + "type": "Program", + "start": 8, + "end": 178, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 9, + "column": 22 + } + }, + "range": [ + 9, + 177 + ], + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 9, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "range": [ + 9, + 30 + ], + "declaration": { + "type": "VariableDeclaration", + "start": 16, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "range": [ + 16, + 30 + ], + "declarations": [ + { + "type": "VariableDeclarator", + "start": 20, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "range": [ + 20, + 30 + ], + "id": { + "type": "Identifier", + "start": 20, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "range": [ + 20, + 25 + ], + "name": "count" + }, + "init": { + "type": "Literal", + "start": 28, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "range": [ + 28, + 30 + ], + "value": 42, + "raw": "42" + } + } + ], + "kind": "let" + }, + "specifiers": [], + "source": null, + "attributes": [] + }, + { + "type": "ExportNamedDeclaration", + "start": 31, + "end": 53, + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 22 + } + }, + "range": [ + 31, + 53 + ], + "declaration": { + "type": "VariableDeclaration", + "start": 38, + "end": 53, + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 22 + } + }, + "range": [ + 38, + 53 + ], + "declarations": [ + { + "type": "VariableDeclarator", + "start": 42, + "end": 53, + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 3, + "column": 22 + } + }, + "range": [ + 42, + 53 + ], + "id": { + "type": "Identifier", + "start": 42, + "end": 48, + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 3, + "column": 17 + } + }, + "range": [ + 42, + 48 + ], + "name": "count2" + }, + "init": { + "type": "Literal", + "start": 51, + "end": 53, + "loc": { + "start": { + "line": 3, + "column": 20 + }, + "end": { + "line": 3, + "column": 22 + } + }, + "range": [ + 51, + 53 + ], + "value": 42, + "raw": "42" + } + } + ], + "kind": "let" + }, + "specifiers": [], + "source": null, + "attributes": [] + }, + { + "type": "ImportDeclaration", + "start": 79, + "end": 124, + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 45 + } + }, + "range": [ + 79, + 124 + ], + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start": 86, + "end": 98, + "loc": { + "start": { + "line": 6, + "column": 7 + }, + "end": { + "line": 6, + "column": 19 + } + }, + "range": [ + 86, + 98 + ], + "local": { + "type": "Identifier", + "start": 86, + "end": 98, + "loc": { + "start": { + "line": 6, + "column": 7 + }, + "end": { + "line": 6, + "column": 19 + } + }, + "range": [ + 86, + 98 + ], + "name": "MyComponent1" + } + } + ], + "source": { + "type": "Literal", + "start": 104, + "end": 124, + "loc": { + "start": { + "line": 6, + "column": 25 + }, + "end": { + "line": 6, + "column": 45 + } + }, + "range": [ + 104, + 124 + ], + "value": "./MyComponent1.vue", + "raw": "'./MyComponent1.vue'" + }, + "attributes": [] + }, + { + "type": "VariableDeclaration", + "start": 125, + "end": 139, + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 14 + } + }, + "range": [ + 125, + 139 + ], + "declarations": [ + { + "type": "VariableDeclarator", + "start": 129, + "end": 139, + "loc": { + "start": { + "line": 7, + "column": 4 + }, + "end": { + "line": 7, + "column": 14 + } + }, + "range": [ + 129, + 139 + ], + "id": { + "type": "Identifier", + "start": 129, + "end": 134, + "loc": { + "start": { + "line": 7, + "column": 4 + }, + "end": { + "line": 7, + "column": 9 + } + }, + "range": [ + 129, + 134 + ], + "name": "count" + }, + "init": { + "type": "Literal", + "start": 137, + "end": 139, + "loc": { + "start": { + "line": 7, + "column": 12 + }, + "end": { + "line": 7, + "column": 14 + } + }, + "range": [ + 137, + 139 + ], + "value": 42, + "raw": "42" + } + } + ], + "kind": "let" + }, + { + "type": "ExportNamedDeclaration", + "start": 140, + "end": 154, + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 14 + } + }, + "range": [ + 140, + 154 + ], + "declaration": null, + "specifiers": [ + { + "type": "ExportSpecifier", + "start": 148, + "end": 153, + "loc": { + "start": { + "line": 8, + "column": 8 + }, + "end": { + "line": 8, + "column": 13 + } + }, + "range": [ + 148, + 153 + ], + "local": { + "type": "Identifier", + "start": 148, + "end": 153, + "loc": { + "start": { + "line": 8, + "column": 8 + }, + "end": { + "line": 8, + "column": 13 + } + }, + "range": [ + 148, + 153 + ], + "name": "count" + }, + "exported": { + "type": "Identifier", + "start": 148, + "end": 153, + "loc": { + "start": { + "line": 8, + "column": 8 + }, + "end": { + "line": 8, + "column": 13 + } + }, + "range": [ + 148, + 153 + ], + "name": "count" + } + } + ], + "source": null, + "attributes": [] + }, + { + "type": "ExportNamedDeclaration", + "start": 155, + "end": 177, + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 22 + } + }, + "range": [ + 155, + 177 + ], + "declaration": { + "type": "VariableDeclaration", + "start": 162, + "end": 177, + "loc": { + "start": { + "line": 9, + "column": 7 + }, + "end": { + "line": 9, + "column": 22 + } + }, + "range": [ + 162, + 177 + ], + "declarations": [ + { + "type": "VariableDeclarator", + "start": 166, + "end": 177, + "loc": { + "start": { + "line": 9, + "column": 11 + }, + "end": { + "line": 9, + "column": 22 + } + }, + "range": [ + 166, + 177 + ], + "id": { + "type": "Identifier", + "start": 166, + "end": 172, + "loc": { + "start": { + "line": 9, + "column": 11 + }, + "end": { + "line": 9, + "column": 17 + } + }, + "range": [ + 166, + 172 + ], + "name": "count2" + }, + "init": { + "type": "Literal", + "start": 175, + "end": 177, + "loc": { + "start": { + "line": 9, + "column": 20 + }, + "end": { + "line": 9, + "column": 22 + } + }, + "range": [ + 175, + 177 + ], + "value": 42, + "raw": "42" + } + } + ], + "kind": "let" + }, + "specifiers": [], + "source": null, + "attributes": [] + } + ], + "sourceType": "module", + "comments": [], + "tokens": [ + { + "type": "Punctuator", + "range": [ + 0, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 64, + 78 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 14 + } + }, + "value": "" + } + ] +} \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-with-export04/parser-options.json b/test/fixtures/ast/multiple-scripts-with-export04/parser-options.json new file mode 100644 index 00000000..2104ca43 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-export04/parser-options.json @@ -0,0 +1,3 @@ +{ + "sourceType": "module" +} diff --git a/test/fixtures/ast/multiple-scripts-with-export04/requirements.json b/test/fixtures/ast/multiple-scripts-with-export04/requirements.json new file mode 100644 index 00000000..36659b1f --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-export04/requirements.json @@ -0,0 +1,3 @@ +{ + "eslint": ">=8" +} \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-with-export04/source.vue b/test/fixtures/ast/multiple-scripts-with-export04/source.vue new file mode 100644 index 00000000..188597dc --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-export04/source.vue @@ -0,0 +1,10 @@ + + diff --git a/test/fixtures/ast/multiple-scripts-with-export04/token-ranges.json b/test/fixtures/ast/multiple-scripts-with-export04/token-ranges.json new file mode 100644 index 00000000..bfab1925 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-export04/token-ranges.json @@ -0,0 +1,33 @@ +[ + "", + "" +] \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-with-export04/tree.json b/test/fixtures/ast/multiple-scripts-with-export04/tree.json new file mode 100644 index 00000000..0637a088 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-export04/tree.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-with-export05/ast.json b/test/fixtures/ast/multiple-scripts-with-export05/ast.json new file mode 100644 index 00000000..6fa01d70 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-export05/ast.json @@ -0,0 +1,1070 @@ +{ + "type": "Program", + "start": 8, + "end": 151, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 8, + "column": 23 + } + }, + "range": [ + 9, + 150 + ], + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 9, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "range": [ + 9, + 30 + ], + "declaration": { + "type": "VariableDeclaration", + "start": 16, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "range": [ + 16, + 30 + ], + "declarations": [ + { + "type": "VariableDeclarator", + "start": 20, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "range": [ + 20, + 30 + ], + "id": { + "type": "Identifier", + "start": 20, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "range": [ + 20, + 25 + ], + "name": "count" + }, + "init": { + "type": "Literal", + "start": 28, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "range": [ + 28, + 30 + ], + "value": 42, + "raw": "42" + } + } + ], + "kind": "let" + }, + "specifiers": [], + "source": null + }, + { + "type": "ExportNamedDeclaration", + "start": 31, + "end": 58, + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 27 + } + }, + "range": [ + 31, + 58 + ], + "declaration": null, + "specifiers": [ + { + "type": "ExportSpecifier", + "start": 39, + "end": 57, + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 26 + } + }, + "range": [ + 39, + 57 + ], + "local": { + "type": "Identifier", + "start": 39, + "end": 44, + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 13 + } + }, + "range": [ + 39, + 44 + ], + "name": "count" + }, + "exported": { + "type": "Literal", + "start": 48, + "end": 57, + "loc": { + "start": { + "line": 3, + "column": 17 + }, + "end": { + "line": 3, + "column": 26 + } + }, + "range": [ + 48, + 57 + ], + "value": "foo-bar", + "raw": "\"foo-bar\"" + } + } + ], + "source": null + }, + { + "type": "VariableDeclaration", + "start": 84, + "end": 98, + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 14 + } + }, + "range": [ + 84, + 98 + ], + "declarations": [ + { + "type": "VariableDeclarator", + "start": 88, + "end": 98, + "loc": { + "start": { + "line": 6, + "column": 4 + }, + "end": { + "line": 6, + "column": 14 + } + }, + "range": [ + 88, + 98 + ], + "id": { + "type": "Identifier", + "start": 88, + "end": 93, + "loc": { + "start": { + "line": 6, + "column": 4 + }, + "end": { + "line": 6, + "column": 9 + } + }, + "range": [ + 88, + 93 + ], + "name": "count" + }, + "init": { + "type": "Literal", + "start": 96, + "end": 98, + "loc": { + "start": { + "line": 6, + "column": 12 + }, + "end": { + "line": 6, + "column": 14 + } + }, + "range": [ + 96, + 98 + ], + "value": 42, + "raw": "42" + } + } + ], + "kind": "let" + }, + { + "type": "ExportNamedDeclaration", + "start": 99, + "end": 126, + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 27 + } + }, + "range": [ + 99, + 126 + ], + "declaration": null, + "specifiers": [ + { + "type": "ExportSpecifier", + "start": 107, + "end": 125, + "loc": { + "start": { + "line": 7, + "column": 8 + }, + "end": { + "line": 7, + "column": 26 + } + }, + "range": [ + 107, + 125 + ], + "local": { + "type": "Identifier", + "start": 107, + "end": 112, + "loc": { + "start": { + "line": 7, + "column": 8 + }, + "end": { + "line": 7, + "column": 13 + } + }, + "range": [ + 107, + 112 + ], + "name": "count" + }, + "exported": { + "type": "Literal", + "start": 116, + "end": 125, + "loc": { + "start": { + "line": 7, + "column": 17 + }, + "end": { + "line": 7, + "column": 26 + } + }, + "range": [ + 116, + 125 + ], + "value": "foo-bar", + "raw": "\"foo-bar\"" + } + } + ], + "source": null + }, + { + "type": "ExportNamedDeclaration", + "start": 127, + "end": 150, + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 23 + } + }, + "range": [ + 127, + 150 + ], + "declaration": null, + "specifiers": [ + { + "type": "ExportSpecifier", + "start": 135, + "end": 149, + "loc": { + "start": { + "line": 8, + "column": 8 + }, + "end": { + "line": 8, + "column": 22 + } + }, + "range": [ + 135, + 149 + ], + "local": { + "type": "Identifier", + "start": 135, + "end": 140, + "loc": { + "start": { + "line": 8, + "column": 8 + }, + "end": { + "line": 8, + "column": 13 + } + }, + "range": [ + 135, + 140 + ], + "name": "count" + }, + "exported": { + "type": "Identifier", + "start": 144, + "end": 149, + "loc": { + "start": { + "line": 8, + "column": 17 + }, + "end": { + "line": 8, + "column": 22 + } + }, + "range": [ + 144, + 149 + ], + "name": "count" + } + } + ], + "source": null + } + ], + "sourceType": "module", + "comments": [], + "tokens": [ + { + "type": "Punctuator", + "range": [ + 0, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 69, + 83 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 14 + } + }, + "value": "" + } + ] +} \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-with-export05/parser-options.json b/test/fixtures/ast/multiple-scripts-with-export05/parser-options.json new file mode 100644 index 00000000..9f047d2c --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-export05/parser-options.json @@ -0,0 +1,4 @@ +{ + "sourceType": "module", + "ecmaVersion": 2022 +} diff --git a/test/fixtures/ast/multiple-scripts-with-export05/requirements.json b/test/fixtures/ast/multiple-scripts-with-export05/requirements.json new file mode 100644 index 00000000..afdd18ef --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-export05/requirements.json @@ -0,0 +1,3 @@ +{ + "eslint": ">=8.7" +} \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-with-export05/source.vue b/test/fixtures/ast/multiple-scripts-with-export05/source.vue new file mode 100644 index 00000000..f848b252 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-export05/source.vue @@ -0,0 +1,9 @@ + + diff --git a/test/fixtures/ast/multiple-scripts-with-export05/token-ranges.json b/test/fixtures/ast/multiple-scripts-with-export05/token-ranges.json new file mode 100644 index 00000000..2a9e6963 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-export05/token-ranges.json @@ -0,0 +1,33 @@ +[ + "", + "" +] \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-with-export05/tree.json b/test/fixtures/ast/multiple-scripts-with-export05/tree.json new file mode 100644 index 00000000..0637a088 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-export05/tree.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-with-ts-2/ast.json b/test/fixtures/ast/multiple-scripts-with-ts-2/ast.json new file mode 100644 index 00000000..f9931353 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-ts-2/ast.json @@ -0,0 +1,806 @@ +{ + "type": "Program", + "body": [ + { + "type": "ImportDeclaration", + "source": { + "type": "Literal", + "value": "./a", + "raw": "'./a'", + "range": [ + 23, + 28 + ], + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 19 + } + } + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "local": { + "type": "Identifier", + "name": "A", + "range": [ + 16, + 17 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 8 + } + } + }, + "range": [ + 16, + 17 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 8 + } + } + } + ], + "importKind": "value", + "range": [ + 9, + 28 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 19 + } + } + }, + { + "type": "ImportDeclaration", + "source": { + "type": "Literal", + "value": "./a", + "raw": "'./a'", + "range": [ + 69, + 74 + ], + "loc": { + "start": { + "line": 6, + "column": 14 + }, + "end": { + "line": 6, + "column": 19 + } + } + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "local": { + "type": "Identifier", + "name": "B", + "range": [ + 62, + 63 + ], + "loc": { + "start": { + "line": 6, + "column": 7 + }, + "end": { + "line": 6, + "column": 8 + } + } + }, + "range": [ + 62, + 63 + ], + "loc": { + "start": { + "line": 6, + "column": 7 + }, + "end": { + "line": 6, + "column": 8 + } + } + } + ], + "importKind": "value", + "range": [ + 55, + 74 + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 19 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "c", + "range": [ + 81, + 82 + ], + "loc": { + "start": { + "line": 7, + "column": 6 + }, + "end": { + "line": 7, + "column": 7 + } + } + }, + "init": { + "type": "Literal", + "value": 42, + "raw": "42", + "range": [ + 85, + 87 + ], + "loc": { + "start": { + "line": 7, + "column": 10 + }, + "end": { + "line": 7, + "column": 12 + } + } + }, + "range": [ + 81, + 87 + ], + "loc": { + "start": { + "line": 7, + "column": 6 + }, + "end": { + "line": 7, + "column": 12 + } + } + } + ], + "kind": "const", + "range": [ + 75, + 87 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 12 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "d", + "range": [ + 94, + 95 + ], + "loc": { + "start": { + "line": 8, + "column": 6 + }, + "end": { + "line": 8, + "column": 7 + } + } + }, + "init": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "A", + "range": [ + 98, + 99 + ], + "loc": { + "start": { + "line": 8, + "column": 10 + }, + "end": { + "line": 8, + "column": 11 + } + } + }, + "property": { + "type": "Identifier", + "name": "use", + "range": [ + 100, + 103 + ], + "loc": { + "start": { + "line": 8, + "column": 12 + }, + "end": { + "line": 8, + "column": 15 + } + } + }, + "computed": false, + "optional": false, + "range": [ + 98, + 103 + ], + "loc": { + "start": { + "line": 8, + "column": 10 + }, + "end": { + "line": 8, + "column": 15 + } + } + }, + "arguments": [], + "optional": false, + "range": [ + 98, + 105 + ], + "loc": { + "start": { + "line": 8, + "column": 10 + }, + "end": { + "line": 8, + "column": 17 + } + } + }, + "range": [ + 94, + 105 + ], + "loc": { + "start": { + "line": 8, + "column": 6 + }, + "end": { + "line": 8, + "column": 17 + } + } + } + ], + "kind": "const", + "range": [ + 88, + 105 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 17 + } + } + } + ], + "sourceType": "module", + "range": [ + 9, + 105 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 8, + "column": 17 + } + }, + "tokens": [ + { + "type": "Punctuator", + "range": [ + 0, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 40, + 54 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 14 + } + }, + "value": "" + } + ], + "comments": [] +} \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-with-ts-2/parser-options.json b/test/fixtures/ast/multiple-scripts-with-ts-2/parser-options.json new file mode 100644 index 00000000..6e1a0ab4 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-ts-2/parser-options.json @@ -0,0 +1,4 @@ +{ + "sourceType": "module", + "parser": "@typescript-eslint/parser" +} diff --git a/test/fixtures/ast/multiple-scripts-with-ts-2/requirements.json b/test/fixtures/ast/multiple-scripts-with-ts-2/requirements.json new file mode 100644 index 00000000..945cf775 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-ts-2/requirements.json @@ -0,0 +1,3 @@ +{ + "@typescript-eslint/parser": "^4.0.0" +} \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-with-ts-2/source.vue b/test/fixtures/ast/multiple-scripts-with-ts-2/source.vue new file mode 100644 index 00000000..c4c3f1e2 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-ts-2/source.vue @@ -0,0 +1,9 @@ + + + diff --git a/test/fixtures/ast/multiple-scripts-with-ts-2/token-ranges.json b/test/fixtures/ast/multiple-scripts-with-ts-2/token-ranges.json new file mode 100644 index 00000000..0570d8ea --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-ts-2/token-ranges.json @@ -0,0 +1,26 @@ +[ + "", + "" +] \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-with-ts-2/tree.json b/test/fixtures/ast/multiple-scripts-with-ts-2/tree.json new file mode 100644 index 00000000..0637a088 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-ts-2/tree.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-with-ts-3/ast.json b/test/fixtures/ast/multiple-scripts-with-ts-3/ast.json new file mode 100644 index 00000000..32b118ed --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-ts-3/ast.json @@ -0,0 +1,735 @@ +{ + "type": "Program", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "Literal", + "value": "script", + "raw": "\"script\"", + "range": [ + 9, + 17 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 8 + } + } + }, + "range": [ + 9, + 17 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "directive": "script" + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "Literal", + "value": "script setup", + "raw": "\"script setup\"", + "range": [ + 76, + 90 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 14 + } + } + }, + "range": [ + 76, + 90 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 14 + } + } + } + ], + "sourceType": "module", + "range": [ + 9, + 90 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 8, + "column": 14 + } + }, + "tokens": [ + { + "type": "Punctuator", + "range": [ + 0, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 61, + 75 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 14 + } + }, + "value": "" + } + ], + "comments": [], + "templateBody": { + "type": "VElement", + "range": [ + 29, + 59 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 30 + } + }, + "name": "template", + "rawName": "template", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 29, + 39 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 39, + 48 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 19 + } + }, + "value": "Template!" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 48, + 59 + ], + "loc": { + "start": { + "line": 5, + "column": 19 + }, + "end": { + "line": 5, + "column": 30 + } + } + }, + "variables": [], + "tokens": [ + { + "type": "HTMLTagOpen", + "range": [ + 0, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 7, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 8, + 9 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 9, + 17 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "value": "\"script\"" + }, + { + "type": "HTMLWhitespace", + "range": [ + 17, + 18 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 18, + 26 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 26, + 27 + ], + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 27, + 29 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "value": "\n\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 29, + 38 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 38, + 39 + ], + "loc": { + "start": { + "line": 5, + "column": 9 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLText", + "range": [ + 39, + 48 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 19 + } + }, + "value": "Template!" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 48, + 58 + ], + "loc": { + "start": { + "line": 5, + "column": 19 + }, + "end": { + "line": 5, + "column": 29 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 58, + 59 + ], + "loc": { + "start": { + "line": 5, + "column": 29 + }, + "end": { + "line": 5, + "column": 30 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 59, + 61 + ], + "loc": { + "start": { + "line": 5, + "column": 30 + }, + "end": { + "line": 7, + "column": 0 + } + }, + "value": "\n\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 61, + 68 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLIdentifier", + "range": [ + 69, + 74 + ], + "loc": { + "start": { + "line": 7, + "column": 8 + }, + "end": { + "line": 7, + "column": 13 + } + }, + "value": "setup" + }, + { + "type": "HTMLTagClose", + "range": [ + 74, + 75 + ], + "loc": { + "start": { + "line": 7, + "column": 13 + }, + "end": { + "line": 7, + "column": 14 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 75, + 76 + ], + "loc": { + "start": { + "line": 7, + "column": 14 + }, + "end": { + "line": 8, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 76, + 83 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 7 + } + }, + "value": "\"script" + }, + { + "type": "HTMLWhitespace", + "range": [ + 83, + 84 + ], + "loc": { + "start": { + "line": 8, + "column": 7 + }, + "end": { + "line": 8, + "column": 8 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 84, + 90 + ], + "loc": { + "start": { + "line": 8, + "column": 8 + }, + "end": { + "line": 8, + "column": 14 + } + }, + "value": "setup\"" + }, + { + "type": "HTMLWhitespace", + "range": [ + 90, + 91 + ], + "loc": { + "start": { + "line": 8, + "column": 14 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 91, + 99 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 99, + 100 + ], + "loc": { + "start": { + "line": 9, + "column": 8 + }, + "end": { + "line": 9, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 100, + 101 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 10, + "column": 0 + } + }, + "value": "\n" + } + ], + "comments": [], + "errors": [] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-with-ts-3/parser-options.json b/test/fixtures/ast/multiple-scripts-with-ts-3/parser-options.json new file mode 100644 index 00000000..6e1a0ab4 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-ts-3/parser-options.json @@ -0,0 +1,4 @@ +{ + "sourceType": "module", + "parser": "@typescript-eslint/parser" +} diff --git a/test/fixtures/ast/multiple-scripts-with-ts-3/requirements.json b/test/fixtures/ast/multiple-scripts-with-ts-3/requirements.json new file mode 100644 index 00000000..945cf775 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-ts-3/requirements.json @@ -0,0 +1,3 @@ +{ + "@typescript-eslint/parser": "^4.0.0" +} \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-with-ts-3/source.vue b/test/fixtures/ast/multiple-scripts-with-ts-3/source.vue new file mode 100644 index 00000000..e136f806 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-ts-3/source.vue @@ -0,0 +1,9 @@ + + + + + diff --git a/test/fixtures/ast/multiple-scripts-with-ts-3/token-ranges.json b/test/fixtures/ast/multiple-scripts-with-ts-3/token-ranges.json new file mode 100644 index 00000000..91b6f7d5 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-ts-3/token-ranges.json @@ -0,0 +1,33 @@ +[ + "", + "", + "", + "\n", + "\"script\"", + "\n", + "", + "\n\n", + "", + "Template!", + "", + "\n\n", + "", + "\n", + "\"script", + " ", + "setup\"", + "\n", + "", + "\n" +] \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-with-ts-3/tree.json b/test/fixtures/ast/multiple-scripts-with-ts-3/tree.json new file mode 100644 index 00000000..7cedc5f9 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-ts-3/tree.json @@ -0,0 +1,23 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-with-ts-4/ast.json b/test/fixtures/ast/multiple-scripts-with-ts-4/ast.json new file mode 100644 index 00000000..ad815425 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-ts-4/ast.json @@ -0,0 +1,843 @@ +{ + "type": "Program", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "Literal", + "value": "script", + "raw": "\"script\"", + "range": [ + 9, + 17 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 8 + } + } + }, + "range": [ + 9, + 17 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "directive": "script" + } + ], + "sourceType": "module", + "range": [ + 9, + 18 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "tokens": [ + { + "type": "Punctuator", + "range": [ + 0, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "value": "" + } + ], + "comments": [], + "templateBody": { + "type": "VElement", + "range": [ + 29, + 59 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 30 + } + }, + "name": "template", + "rawName": "template", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 29, + 39 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 39, + 48 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 19 + } + }, + "value": "Template!" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 48, + 59 + ], + "loc": { + "start": { + "line": 5, + "column": 19 + }, + "end": { + "line": 5, + "column": 30 + } + } + }, + "variables": [], + "tokens": [ + { + "type": "HTMLTagOpen", + "range": [ + 0, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 7, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 8, + 9 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 9, + 17 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "value": "\"script\"" + }, + { + "type": "HTMLWhitespace", + "range": [ + 17, + 18 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 18, + 26 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 26, + 27 + ], + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 27, + 29 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "value": "\n\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 29, + 38 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 38, + 39 + ], + "loc": { + "start": { + "line": 5, + "column": 9 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLText", + "range": [ + 39, + 48 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 19 + } + }, + "value": "Template!" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 48, + 58 + ], + "loc": { + "start": { + "line": 5, + "column": 19 + }, + "end": { + "line": 5, + "column": 29 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 58, + 59 + ], + "loc": { + "start": { + "line": 5, + "column": 29 + }, + "end": { + "line": 5, + "column": 30 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 59, + 61 + ], + "loc": { + "start": { + "line": 5, + "column": 30 + }, + "end": { + "line": 7, + "column": 0 + } + }, + "value": "\n\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 61, + 68 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLIdentifier", + "range": [ + 69, + 74 + ], + "loc": { + "start": { + "line": 7, + "column": 8 + }, + "end": { + "line": 7, + "column": 13 + } + }, + "value": "setup" + }, + { + "type": "HTMLTagClose", + "range": [ + 74, + 75 + ], + "loc": { + "start": { + "line": 7, + "column": 13 + }, + "end": { + "line": 7, + "column": 14 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 75, + 76 + ], + "loc": { + "start": { + "line": 7, + "column": 14 + }, + "end": { + "line": 8, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 76, + 83 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 7 + } + }, + "value": "\"script" + }, + { + "type": "HTMLWhitespace", + "range": [ + 83, + 84 + ], + "loc": { + "start": { + "line": 8, + "column": 7 + }, + "end": { + "line": 8, + "column": 8 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 84, + 90 + ], + "loc": { + "start": { + "line": 8, + "column": 8 + }, + "end": { + "line": 8, + "column": 14 + } + }, + "value": "setup\"" + }, + { + "type": "HTMLWhitespace", + "range": [ + 90, + 91 + ], + "loc": { + "start": { + "line": 8, + "column": 14 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 91, + 99 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 99, + 100 + ], + "loc": { + "start": { + "line": 9, + "column": 8 + }, + "end": { + "line": 9, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 100, + 102 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 11, + "column": 0 + } + }, + "value": "\n\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 102, + 109 + ], + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLIdentifier", + "range": [ + 110, + 117 + ], + "loc": { + "start": { + "line": 11, + "column": 8 + }, + "end": { + "line": 11, + "column": 15 + } + }, + "value": "unknown" + }, + { + "type": "HTMLTagClose", + "range": [ + 117, + 118 + ], + "loc": { + "start": { + "line": 11, + "column": 15 + }, + "end": { + "line": 11, + "column": 16 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 118, + 119 + ], + "loc": { + "start": { + "line": 11, + "column": 16 + }, + "end": { + "line": 12, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 119, + 126 + ], + "loc": { + "start": { + "line": 12, + "column": 0 + }, + "end": { + "line": 12, + "column": 7 + } + }, + "value": "\"script" + }, + { + "type": "HTMLWhitespace", + "range": [ + 126, + 127 + ], + "loc": { + "start": { + "line": 12, + "column": 7 + }, + "end": { + "line": 12, + "column": 8 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 127, + 135 + ], + "loc": { + "start": { + "line": 12, + "column": 8 + }, + "end": { + "line": 12, + "column": 16 + } + }, + "value": "unknown\"" + }, + { + "type": "HTMLWhitespace", + "range": [ + 135, + 136 + ], + "loc": { + "start": { + "line": 12, + "column": 16 + }, + "end": { + "line": 13, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 136, + 144 + ], + "loc": { + "start": { + "line": 13, + "column": 0 + }, + "end": { + "line": 13, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 144, + 145 + ], + "loc": { + "start": { + "line": 13, + "column": 8 + }, + "end": { + "line": 13, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 145, + 146 + ], + "loc": { + "start": { + "line": 13, + "column": 9 + }, + "end": { + "line": 14, + "column": 0 + } + }, + "value": "\n" + } + ], + "comments": [], + "errors": [] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-with-ts-4/parser-options.json b/test/fixtures/ast/multiple-scripts-with-ts-4/parser-options.json new file mode 100644 index 00000000..6e1a0ab4 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-ts-4/parser-options.json @@ -0,0 +1,4 @@ +{ + "sourceType": "module", + "parser": "@typescript-eslint/parser" +} diff --git a/test/fixtures/ast/multiple-scripts-with-ts-4/requirements.json b/test/fixtures/ast/multiple-scripts-with-ts-4/requirements.json new file mode 100644 index 00000000..945cf775 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-ts-4/requirements.json @@ -0,0 +1,3 @@ +{ + "@typescript-eslint/parser": "^4.0.0" +} \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-with-ts-4/source.vue b/test/fixtures/ast/multiple-scripts-with-ts-4/source.vue new file mode 100644 index 00000000..7d1a37de --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-ts-4/source.vue @@ -0,0 +1,13 @@ + + + + + + + diff --git a/test/fixtures/ast/multiple-scripts-with-ts-4/token-ranges.json b/test/fixtures/ast/multiple-scripts-with-ts-4/token-ranges.json new file mode 100644 index 00000000..002d3fc9 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-ts-4/token-ranges.json @@ -0,0 +1,41 @@ +[ + "", + "", + "\n", + "\"script\"", + "\n", + "", + "\n\n", + "", + "Template!", + "", + "\n\n", + "", + "\n", + "\"script", + " ", + "setup\"", + "\n", + "", + "\n\n", + "", + "\n", + "\"script", + " ", + "unknown\"", + "\n", + "", + "\n" +] \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-with-ts-4/tree.json b/test/fixtures/ast/multiple-scripts-with-ts-4/tree.json new file mode 100644 index 00000000..7cedc5f9 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-ts-4/tree.json @@ -0,0 +1,23 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-with-ts-5/ast.json b/test/fixtures/ast/multiple-scripts-with-ts-5/ast.json new file mode 100644 index 00000000..edd413d0 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-ts-5/ast.json @@ -0,0 +1,1669 @@ +{ + "type": "Program", + "body": [ + { + "type": "ExportNamedDeclaration", + "declaration": { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "count", + "range": [ + 20, + 25 + ], + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 16 + } + } + }, + "init": { + "type": "Literal", + "value": 42, + "raw": "42", + "range": [ + 28, + 30 + ], + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 21 + } + } + }, + "range": [ + 20, + 30 + ], + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 21 + } + } + } + ], + "kind": "let", + "range": [ + 16, + 30 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 21 + } + } + }, + "specifiers": [], + "source": null, + "exportKind": "value", + "range": [ + 9, + 30 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 21 + } + } + }, + { + "type": "ImportDeclaration", + "source": { + "type": "Literal", + "value": "./Foo.vue", + "raw": "'./Foo.vue'", + "range": [ + 118, + 129 + ], + "loc": { + "start": { + "line": 8, + "column": 16 + }, + "end": { + "line": 8, + "column": 27 + } + } + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "local": { + "type": "Identifier", + "name": "Foo", + "range": [ + 109, + 112 + ], + "loc": { + "start": { + "line": 8, + "column": 7 + }, + "end": { + "line": 8, + "column": 10 + } + } + }, + "range": [ + 109, + 112 + ], + "loc": { + "start": { + "line": 8, + "column": 7 + }, + "end": { + "line": 8, + "column": 10 + } + } + } + ], + "importKind": "value", + "range": [ + 102, + 129 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 27 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "count", + "range": [ + 134, + 139 + ], + "loc": { + "start": { + "line": 9, + "column": 4 + }, + "end": { + "line": 9, + "column": 9 + } + } + }, + "init": { + "type": "Literal", + "value": 42, + "raw": "42", + "range": [ + 142, + 144 + ], + "loc": { + "start": { + "line": 9, + "column": 12 + }, + "end": { + "line": 9, + "column": 14 + } + } + }, + "range": [ + 134, + 144 + ], + "loc": { + "start": { + "line": 9, + "column": 4 + }, + "end": { + "line": 9, + "column": 14 + } + } + } + ], + "kind": "let", + "range": [ + 130, + 144 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 14 + } + } + } + ], + "sourceType": "module", + "range": [ + 9, + 144 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 9, + "column": 14 + } + }, + "tokens": [ + { + "type": "Punctuator", + "range": [ + 0, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 87, + 101 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 14 + } + }, + "value": "" + } + ], + "comments": [], + "templateBody": { + "type": "VElement", + "range": [ + 42, + 85 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 43 + } + }, + "name": "template", + "rawName": "template", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 42, + 52 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VElement", + "range": [ + 52, + 74 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 32 + } + }, + "name": "foo", + "rawName": "Foo", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 52, + 57 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 15 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VExpressionContainer", + "range": [ + 57, + 68 + ], + "loc": { + "start": { + "line": 5, + "column": 15 + }, + "end": { + "line": 5, + "column": 26 + } + }, + "expression": { + "type": "Identifier", + "name": "count", + "range": [ + 60, + 65 + ], + "loc": { + "start": { + "line": 5, + "column": 18 + }, + "end": { + "line": 5, + "column": 23 + } + } + }, + "references": [ + { + "id": { + "type": "Identifier", + "name": "count", + "range": [ + 60, + 65 + ], + "loc": { + "start": { + "line": 5, + "column": 18 + }, + "end": { + "line": 5, + "column": 23 + } + } + }, + "mode": "r" + } + ] + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 68, + 74 + ], + "loc": { + "start": { + "line": 5, + "column": 26 + }, + "end": { + "line": 5, + "column": 32 + } + } + }, + "variables": [] + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 74, + 85 + ], + "loc": { + "start": { + "line": 5, + "column": 32 + }, + "end": { + "line": 5, + "column": 43 + } + } + }, + "variables": [], + "tokens": [ + { + "type": "HTMLTagOpen", + "range": [ + 0, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 7, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 8, + 9 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 9, + 15 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 6 + } + }, + "value": "export" + }, + { + "type": "HTMLWhitespace", + "range": [ + 15, + 16 + ], + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 16, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "value": "let" + }, + { + "type": "HTMLWhitespace", + "range": [ + 19, + 20 + ], + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 20, + 25 + ], + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "value": "count" + }, + { + "type": "HTMLWhitespace", + "range": [ + 25, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 26, + 27 + ], + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 27, + 28 + ], + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 28, + 30 + ], + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "value": "42" + }, + { + "type": "HTMLWhitespace", + "range": [ + 30, + 31 + ], + "loc": { + "start": { + "line": 2, + "column": 21 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 31, + 39 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 39, + 40 + ], + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 40, + 42 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "value": "\n\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 42, + 51 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 51, + 52 + ], + "loc": { + "start": { + "line": 5, + "column": 9 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLTagOpen", + "range": [ + 52, + 56 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 14 + } + }, + "value": "foo" + }, + { + "type": "HTMLTagClose", + "range": [ + 56, + 57 + ], + "loc": { + "start": { + "line": 5, + "column": 14 + }, + "end": { + "line": 5, + "column": 15 + } + }, + "value": "" + }, + { + "type": "VExpressionStart", + "range": [ + 57, + 59 + ], + "loc": { + "start": { + "line": 5, + "column": 15 + }, + "end": { + "line": 5, + "column": 17 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "value": "count", + "range": [ + 60, + 65 + ], + "loc": { + "start": { + "line": 5, + "column": 18 + }, + "end": { + "line": 5, + "column": 23 + } + } + }, + { + "type": "VExpressionEnd", + "range": [ + 66, + 68 + ], + "loc": { + "start": { + "line": 5, + "column": 24 + }, + "end": { + "line": 5, + "column": 26 + } + }, + "value": "}}" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 68, + 73 + ], + "loc": { + "start": { + "line": 5, + "column": 26 + }, + "end": { + "line": 5, + "column": 31 + } + }, + "value": "foo" + }, + { + "type": "HTMLTagClose", + "range": [ + 73, + 74 + ], + "loc": { + "start": { + "line": 5, + "column": 31 + }, + "end": { + "line": 5, + "column": 32 + } + }, + "value": "" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 74, + 84 + ], + "loc": { + "start": { + "line": 5, + "column": 32 + }, + "end": { + "line": 5, + "column": 42 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 84, + 85 + ], + "loc": { + "start": { + "line": 5, + "column": 42 + }, + "end": { + "line": 5, + "column": 43 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 85, + 87 + ], + "loc": { + "start": { + "line": 5, + "column": 43 + }, + "end": { + "line": 7, + "column": 0 + } + }, + "value": "\n\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 87, + 94 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLIdentifier", + "range": [ + 95, + 100 + ], + "loc": { + "start": { + "line": 7, + "column": 8 + }, + "end": { + "line": 7, + "column": 13 + } + }, + "value": "setup" + }, + { + "type": "HTMLTagClose", + "range": [ + 100, + 101 + ], + "loc": { + "start": { + "line": 7, + "column": 13 + }, + "end": { + "line": 7, + "column": 14 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 101, + 102 + ], + "loc": { + "start": { + "line": 7, + "column": 14 + }, + "end": { + "line": 8, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 102, + 108 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 6 + } + }, + "value": "import" + }, + { + "type": "HTMLWhitespace", + "range": [ + 108, + 109 + ], + "loc": { + "start": { + "line": 8, + "column": 6 + }, + "end": { + "line": 8, + "column": 7 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 109, + 112 + ], + "loc": { + "start": { + "line": 8, + "column": 7 + }, + "end": { + "line": 8, + "column": 10 + } + }, + "value": "Foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 112, + 113 + ], + "loc": { + "start": { + "line": 8, + "column": 10 + }, + "end": { + "line": 8, + "column": 11 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 113, + 117 + ], + "loc": { + "start": { + "line": 8, + "column": 11 + }, + "end": { + "line": 8, + "column": 15 + } + }, + "value": "from" + }, + { + "type": "HTMLWhitespace", + "range": [ + 117, + 118 + ], + "loc": { + "start": { + "line": 8, + "column": 15 + }, + "end": { + "line": 8, + "column": 16 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 118, + 129 + ], + "loc": { + "start": { + "line": 8, + "column": 16 + }, + "end": { + "line": 8, + "column": 27 + } + }, + "value": "'./Foo.vue'" + }, + { + "type": "HTMLWhitespace", + "range": [ + 129, + 130 + ], + "loc": { + "start": { + "line": 8, + "column": 27 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 130, + 133 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 3 + } + }, + "value": "let" + }, + { + "type": "HTMLWhitespace", + "range": [ + 133, + 134 + ], + "loc": { + "start": { + "line": 9, + "column": 3 + }, + "end": { + "line": 9, + "column": 4 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 134, + 139 + ], + "loc": { + "start": { + "line": 9, + "column": 4 + }, + "end": { + "line": 9, + "column": 9 + } + }, + "value": "count" + }, + { + "type": "HTMLWhitespace", + "range": [ + 139, + 140 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 9, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 140, + 141 + ], + "loc": { + "start": { + "line": 9, + "column": 10 + }, + "end": { + "line": 9, + "column": 11 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 141, + 142 + ], + "loc": { + "start": { + "line": 9, + "column": 11 + }, + "end": { + "line": 9, + "column": 12 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 142, + 144 + ], + "loc": { + "start": { + "line": 9, + "column": 12 + }, + "end": { + "line": 9, + "column": 14 + } + }, + "value": "42" + }, + { + "type": "HTMLWhitespace", + "range": [ + 144, + 145 + ], + "loc": { + "start": { + "line": 9, + "column": 14 + }, + "end": { + "line": 10, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 145, + 153 + ], + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 153, + 154 + ], + "loc": { + "start": { + "line": 10, + "column": 8 + }, + "end": { + "line": 10, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 154, + 155 + ], + "loc": { + "start": { + "line": 10, + "column": 9 + }, + "end": { + "line": 11, + "column": 0 + } + }, + "value": "\n" + } + ], + "comments": [], + "errors": [] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-with-ts-5/parser-options.json b/test/fixtures/ast/multiple-scripts-with-ts-5/parser-options.json new file mode 100644 index 00000000..6e1a0ab4 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-ts-5/parser-options.json @@ -0,0 +1,4 @@ +{ + "sourceType": "module", + "parser": "@typescript-eslint/parser" +} diff --git a/test/fixtures/ast/multiple-scripts-with-ts-5/requirements.json b/test/fixtures/ast/multiple-scripts-with-ts-5/requirements.json new file mode 100644 index 00000000..945cf775 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-ts-5/requirements.json @@ -0,0 +1,3 @@ +{ + "@typescript-eslint/parser": "^4.0.0" +} \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-with-ts-5/source.vue b/test/fixtures/ast/multiple-scripts-with-ts-5/source.vue new file mode 100644 index 00000000..267b0f65 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-ts-5/source.vue @@ -0,0 +1,10 @@ + + + + + diff --git a/test/fixtures/ast/multiple-scripts-with-ts-5/token-ranges.json b/test/fixtures/ast/multiple-scripts-with-ts-5/token-ranges.json new file mode 100644 index 00000000..5da2f7d5 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-ts-5/token-ranges.json @@ -0,0 +1,70 @@ +[ + "", + "", + "", + "\n", + "export", + " ", + "let", + " ", + "count", + " ", + "=", + " ", + "42", + "\n", + "", + "\n\n", + "", + "", + "{{", + "count", + "}}", + "", + "", + "\n\n", + "", + "\n", + "import", + " ", + "Foo", + " ", + "from", + " ", + "'./Foo.vue'", + "\n", + "let", + " ", + "count", + " ", + "=", + " ", + "42", + "\n", + "", + "\n" +] \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-with-ts-5/tree.json b/test/fixtures/ast/multiple-scripts-with-ts-5/tree.json new file mode 100644 index 00000000..f84d7918 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-ts-5/tree.json @@ -0,0 +1,45 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-with-ts-7/ast.json b/test/fixtures/ast/multiple-scripts-with-ts-7/ast.json new file mode 100644 index 00000000..f860e330 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-ts-7/ast.json @@ -0,0 +1,2585 @@ +{ + "type": "Program", + "body": [ + { + "type": "ExportNamedDeclaration", + "declaration": { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "count", + "range": [ + 20, + 25 + ], + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 16 + } + } + }, + "init": { + "type": "Literal", + "value": 42, + "raw": "42", + "range": [ + 28, + 30 + ], + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 21 + } + } + }, + "range": [ + 20, + 30 + ], + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 21 + } + } + } + ], + "kind": "let", + "range": [ + 16, + 30 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 21 + } + } + }, + "specifiers": [], + "source": null, + "exportKind": "value", + "range": [ + 9, + 30 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 21 + } + } + }, + { + "type": "ImportDeclaration", + "source": { + "type": "Literal", + "value": "./MyComponent1.vue", + "raw": "'./MyComponent1.vue'", + "range": [ + 82, + 102 + ], + "loc": { + "start": { + "line": 6, + "column": 25 + }, + "end": { + "line": 6, + "column": 45 + } + } + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "local": { + "type": "Identifier", + "name": "MyComponent1", + "range": [ + 64, + 76 + ], + "loc": { + "start": { + "line": 6, + "column": 7 + }, + "end": { + "line": 6, + "column": 19 + } + } + }, + "range": [ + 64, + 76 + ], + "loc": { + "start": { + "line": 6, + "column": 7 + }, + "end": { + "line": 6, + "column": 19 + } + } + } + ], + "importKind": "value", + "range": [ + 57, + 102 + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 45 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "count", + "range": [ + 107, + 112 + ], + "loc": { + "start": { + "line": 7, + "column": 4 + }, + "end": { + "line": 7, + "column": 9 + } + } + }, + "init": { + "type": "Literal", + "value": 42, + "raw": "42", + "range": [ + 115, + 117 + ], + "loc": { + "start": { + "line": 7, + "column": 12 + }, + "end": { + "line": 7, + "column": 14 + } + } + }, + "range": [ + 107, + 117 + ], + "loc": { + "start": { + "line": 7, + "column": 4 + }, + "end": { + "line": 7, + "column": 14 + } + } + } + ], + "kind": "let", + "range": [ + 103, + 117 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 14 + } + } + }, + { + "type": "ImportDeclaration", + "source": { + "type": "Literal", + "value": "./MyComponent2.vue", + "raw": "'./MyComponent2.vue'", + "range": [ + 143, + 163 + ], + "loc": { + "start": { + "line": 8, + "column": 25 + }, + "end": { + "line": 8, + "column": 45 + } + } + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "local": { + "type": "Identifier", + "name": "MyComponent2", + "range": [ + 125, + 137 + ], + "loc": { + "start": { + "line": 8, + "column": 7 + }, + "end": { + "line": 8, + "column": 19 + } + } + }, + "range": [ + 125, + 137 + ], + "loc": { + "start": { + "line": 8, + "column": 7 + }, + "end": { + "line": 8, + "column": 19 + } + } + } + ], + "importKind": "value", + "range": [ + 118, + 163 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 45 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "a", + "range": [ + 168, + 169 + ], + "loc": { + "start": { + "line": 9, + "column": 4 + }, + "end": { + "line": 9, + "column": 5 + } + } + }, + "init": { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "Identifier", + "name": "b", + "range": [ + 172, + 173 + ], + "loc": { + "start": { + "line": 9, + "column": 8 + }, + "end": { + "line": 9, + "column": 9 + } + } + }, + "right": { + "type": "Identifier", + "name": "c", + "range": [ + 176, + 177 + ], + "loc": { + "start": { + "line": 9, + "column": 12 + }, + "end": { + "line": 9, + "column": 13 + } + } + }, + "range": [ + 172, + 177 + ], + "loc": { + "start": { + "line": 9, + "column": 8 + }, + "end": { + "line": 9, + "column": 13 + } + } + }, + "range": [ + 168, + 177 + ], + "loc": { + "start": { + "line": 9, + "column": 4 + }, + "end": { + "line": 9, + "column": 13 + } + } + } + ], + "kind": "let", + "range": [ + 164, + 177 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 13 + } + } + } + ], + "sourceType": "module", + "range": [ + 9, + 177 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 9, + "column": 13 + } + }, + "tokens": [ + { + "type": "Punctuator", + "range": [ + 0, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 42, + 56 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 14 + } + }, + "value": "" + } + ], + "comments": [], + "templateBody": { + "type": "VElement", + "range": [ + 189, + 276 + ], + "loc": { + "start": { + "line": 12, + "column": 0 + }, + "end": { + "line": 15, + "column": 11 + } + }, + "name": "template", + "rawName": "template", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 189, + 199 + ], + "loc": { + "start": { + "line": 12, + "column": 0 + }, + "end": { + "line": 12, + "column": 10 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 199, + 204 + ], + "loc": { + "start": { + "line": 12, + "column": 10 + }, + "end": { + "line": 13, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 204, + 244 + ], + "loc": { + "start": { + "line": 13, + "column": 4 + }, + "end": { + "line": 13, + "column": 44 + } + }, + "name": "mycomponent1", + "rawName": "MyComponent1", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 204, + 218 + ], + "loc": { + "start": { + "line": 13, + "column": 4 + }, + "end": { + "line": 13, + "column": 18 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VExpressionContainer", + "range": [ + 218, + 229 + ], + "loc": { + "start": { + "line": 13, + "column": 18 + }, + "end": { + "line": 13, + "column": 29 + } + }, + "expression": { + "type": "Identifier", + "name": "count", + "range": [ + 221, + 226 + ], + "loc": { + "start": { + "line": 13, + "column": 21 + }, + "end": { + "line": 13, + "column": 26 + } + } + }, + "references": [ + { + "id": { + "type": "Identifier", + "name": "count", + "range": [ + 221, + 226 + ], + "loc": { + "start": { + "line": 13, + "column": 21 + }, + "end": { + "line": 13, + "column": 26 + } + } + }, + "mode": "r" + } + ] + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 229, + 244 + ], + "loc": { + "start": { + "line": 13, + "column": 29 + }, + "end": { + "line": 13, + "column": 44 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 244, + 249 + ], + "loc": { + "start": { + "line": 13, + "column": 44 + }, + "end": { + "line": 14, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 249, + 264 + ], + "loc": { + "start": { + "line": 14, + "column": 4 + }, + "end": { + "line": 14, + "column": 19 + } + }, + "name": "mycomponent2", + "rawName": "MyComponent2", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 249, + 264 + ], + "loc": { + "start": { + "line": 14, + "column": 4 + }, + "end": { + "line": 14, + "column": 19 + } + }, + "selfClosing": true, + "attributes": [] + }, + "children": [], + "endTag": null, + "variables": [] + }, + { + "type": "VText", + "range": [ + 264, + 265 + ], + "loc": { + "start": { + "line": 14, + "column": 19 + }, + "end": { + "line": 15, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 265, + 276 + ], + "loc": { + "start": { + "line": 15, + "column": 0 + }, + "end": { + "line": 15, + "column": 11 + } + } + }, + "variables": [], + "tokens": [ + { + "type": "HTMLTagOpen", + "range": [ + 0, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 7, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 8, + 9 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 9, + 15 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 6 + } + }, + "value": "export" + }, + { + "type": "HTMLWhitespace", + "range": [ + 15, + 16 + ], + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 16, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "value": "let" + }, + { + "type": "HTMLWhitespace", + "range": [ + 19, + 20 + ], + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 20, + 25 + ], + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "value": "count" + }, + { + "type": "HTMLWhitespace", + "range": [ + 25, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 26, + 27 + ], + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 27, + 28 + ], + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 28, + 30 + ], + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "value": "42" + }, + { + "type": "HTMLWhitespace", + "range": [ + 30, + 31 + ], + "loc": { + "start": { + "line": 2, + "column": 21 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 31, + 39 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 39, + 40 + ], + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 40, + 42 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "value": "\n\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 42, + 49 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLIdentifier", + "range": [ + 50, + 55 + ], + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 13 + } + }, + "value": "setup" + }, + { + "type": "HTMLTagClose", + "range": [ + 55, + 56 + ], + "loc": { + "start": { + "line": 5, + "column": 13 + }, + "end": { + "line": 5, + "column": 14 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 56, + 57 + ], + "loc": { + "start": { + "line": 5, + "column": 14 + }, + "end": { + "line": 6, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 57, + 63 + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 6 + } + }, + "value": "import" + }, + { + "type": "HTMLWhitespace", + "range": [ + 63, + 64 + ], + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 7 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 64, + 76 + ], + "loc": { + "start": { + "line": 6, + "column": 7 + }, + "end": { + "line": 6, + "column": 19 + } + }, + "value": "MyComponent1" + }, + { + "type": "HTMLWhitespace", + "range": [ + 76, + 77 + ], + "loc": { + "start": { + "line": 6, + "column": 19 + }, + "end": { + "line": 6, + "column": 20 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 77, + 81 + ], + "loc": { + "start": { + "line": 6, + "column": 20 + }, + "end": { + "line": 6, + "column": 24 + } + }, + "value": "from" + }, + { + "type": "HTMLWhitespace", + "range": [ + 81, + 82 + ], + "loc": { + "start": { + "line": 6, + "column": 24 + }, + "end": { + "line": 6, + "column": 25 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 82, + 102 + ], + "loc": { + "start": { + "line": 6, + "column": 25 + }, + "end": { + "line": 6, + "column": 45 + } + }, + "value": "'./MyComponent1.vue'" + }, + { + "type": "HTMLWhitespace", + "range": [ + 102, + 103 + ], + "loc": { + "start": { + "line": 6, + "column": 45 + }, + "end": { + "line": 7, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 103, + 106 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 3 + } + }, + "value": "let" + }, + { + "type": "HTMLWhitespace", + "range": [ + 106, + 107 + ], + "loc": { + "start": { + "line": 7, + "column": 3 + }, + "end": { + "line": 7, + "column": 4 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 107, + 112 + ], + "loc": { + "start": { + "line": 7, + "column": 4 + }, + "end": { + "line": 7, + "column": 9 + } + }, + "value": "count" + }, + { + "type": "HTMLWhitespace", + "range": [ + 112, + 113 + ], + "loc": { + "start": { + "line": 7, + "column": 9 + }, + "end": { + "line": 7, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 113, + 114 + ], + "loc": { + "start": { + "line": 7, + "column": 10 + }, + "end": { + "line": 7, + "column": 11 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 114, + 115 + ], + "loc": { + "start": { + "line": 7, + "column": 11 + }, + "end": { + "line": 7, + "column": 12 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 115, + 117 + ], + "loc": { + "start": { + "line": 7, + "column": 12 + }, + "end": { + "line": 7, + "column": 14 + } + }, + "value": "42" + }, + { + "type": "HTMLWhitespace", + "range": [ + 117, + 118 + ], + "loc": { + "start": { + "line": 7, + "column": 14 + }, + "end": { + "line": 8, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 118, + 124 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 6 + } + }, + "value": "import" + }, + { + "type": "HTMLWhitespace", + "range": [ + 124, + 125 + ], + "loc": { + "start": { + "line": 8, + "column": 6 + }, + "end": { + "line": 8, + "column": 7 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 125, + 137 + ], + "loc": { + "start": { + "line": 8, + "column": 7 + }, + "end": { + "line": 8, + "column": 19 + } + }, + "value": "MyComponent2" + }, + { + "type": "HTMLWhitespace", + "range": [ + 137, + 138 + ], + "loc": { + "start": { + "line": 8, + "column": 19 + }, + "end": { + "line": 8, + "column": 20 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 138, + 142 + ], + "loc": { + "start": { + "line": 8, + "column": 20 + }, + "end": { + "line": 8, + "column": 24 + } + }, + "value": "from" + }, + { + "type": "HTMLWhitespace", + "range": [ + 142, + 143 + ], + "loc": { + "start": { + "line": 8, + "column": 24 + }, + "end": { + "line": 8, + "column": 25 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 143, + 163 + ], + "loc": { + "start": { + "line": 8, + "column": 25 + }, + "end": { + "line": 8, + "column": 45 + } + }, + "value": "'./MyComponent2.vue'" + }, + { + "type": "HTMLWhitespace", + "range": [ + 163, + 164 + ], + "loc": { + "start": { + "line": 8, + "column": 45 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 164, + 167 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 3 + } + }, + "value": "let" + }, + { + "type": "HTMLWhitespace", + "range": [ + 167, + 168 + ], + "loc": { + "start": { + "line": 9, + "column": 3 + }, + "end": { + "line": 9, + "column": 4 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 168, + 169 + ], + "loc": { + "start": { + "line": 9, + "column": 4 + }, + "end": { + "line": 9, + "column": 5 + } + }, + "value": "a" + }, + { + "type": "HTMLWhitespace", + "range": [ + 169, + 170 + ], + "loc": { + "start": { + "line": 9, + "column": 5 + }, + "end": { + "line": 9, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 170, + 171 + ], + "loc": { + "start": { + "line": 9, + "column": 6 + }, + "end": { + "line": 9, + "column": 7 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 171, + 172 + ], + "loc": { + "start": { + "line": 9, + "column": 7 + }, + "end": { + "line": 9, + "column": 8 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 172, + 173 + ], + "loc": { + "start": { + "line": 9, + "column": 8 + }, + "end": { + "line": 9, + "column": 9 + } + }, + "value": "b" + }, + { + "type": "HTMLWhitespace", + "range": [ + 173, + 174 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 9, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 174, + 175 + ], + "loc": { + "start": { + "line": 9, + "column": 10 + }, + "end": { + "line": 9, + "column": 11 + } + }, + "value": "+" + }, + { + "type": "HTMLWhitespace", + "range": [ + 175, + 176 + ], + "loc": { + "start": { + "line": 9, + "column": 11 + }, + "end": { + "line": 9, + "column": 12 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 176, + 177 + ], + "loc": { + "start": { + "line": 9, + "column": 12 + }, + "end": { + "line": 9, + "column": 13 + } + }, + "value": "c" + }, + { + "type": "HTMLWhitespace", + "range": [ + 177, + 178 + ], + "loc": { + "start": { + "line": 9, + "column": 13 + }, + "end": { + "line": 10, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 178, + 186 + ], + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 186, + 187 + ], + "loc": { + "start": { + "line": 10, + "column": 8 + }, + "end": { + "line": 10, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 187, + 189 + ], + "loc": { + "start": { + "line": 10, + "column": 9 + }, + "end": { + "line": 12, + "column": 0 + } + }, + "value": "\n\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 189, + 198 + ], + "loc": { + "start": { + "line": 12, + "column": 0 + }, + "end": { + "line": 12, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 198, + 199 + ], + "loc": { + "start": { + "line": 12, + "column": 9 + }, + "end": { + "line": 12, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 199, + 204 + ], + "loc": { + "start": { + "line": 12, + "column": 10 + }, + "end": { + "line": 13, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 204, + 217 + ], + "loc": { + "start": { + "line": 13, + "column": 4 + }, + "end": { + "line": 13, + "column": 17 + } + }, + "value": "mycomponent1" + }, + { + "type": "HTMLTagClose", + "range": [ + 217, + 218 + ], + "loc": { + "start": { + "line": 13, + "column": 17 + }, + "end": { + "line": 13, + "column": 18 + } + }, + "value": "" + }, + { + "type": "VExpressionStart", + "range": [ + 218, + 220 + ], + "loc": { + "start": { + "line": 13, + "column": 18 + }, + "end": { + "line": 13, + "column": 20 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "value": "count", + "range": [ + 221, + 226 + ], + "loc": { + "start": { + "line": 13, + "column": 21 + }, + "end": { + "line": 13, + "column": 26 + } + } + }, + { + "type": "VExpressionEnd", + "range": [ + 227, + 229 + ], + "loc": { + "start": { + "line": 13, + "column": 27 + }, + "end": { + "line": 13, + "column": 29 + } + }, + "value": "}}" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 229, + 243 + ], + "loc": { + "start": { + "line": 13, + "column": 29 + }, + "end": { + "line": 13, + "column": 43 + } + }, + "value": "mycomponent1" + }, + { + "type": "HTMLTagClose", + "range": [ + 243, + 244 + ], + "loc": { + "start": { + "line": 13, + "column": 43 + }, + "end": { + "line": 13, + "column": 44 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 244, + 249 + ], + "loc": { + "start": { + "line": 13, + "column": 44 + }, + "end": { + "line": 14, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 249, + 262 + ], + "loc": { + "start": { + "line": 14, + "column": 4 + }, + "end": { + "line": 14, + "column": 17 + } + }, + "value": "mycomponent2" + }, + { + "type": "HTMLSelfClosingTagClose", + "range": [ + 262, + 264 + ], + "loc": { + "start": { + "line": 14, + "column": 17 + }, + "end": { + "line": 14, + "column": 19 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 264, + 265 + ], + "loc": { + "start": { + "line": 14, + "column": 19 + }, + "end": { + "line": 15, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 265, + 275 + ], + "loc": { + "start": { + "line": 15, + "column": 0 + }, + "end": { + "line": 15, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 275, + 276 + ], + "loc": { + "start": { + "line": 15, + "column": 10 + }, + "end": { + "line": 15, + "column": 11 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 276, + 278 + ], + "loc": { + "start": { + "line": 15, + "column": 11 + }, + "end": { + "line": 17, + "column": 0 + } + }, + "value": "\n\n" + } + ], + "comments": [], + "errors": [ + { + "message": "non-void-html-element-start-tag-with-trailing-solidus", + "index": 249, + "lineNumber": 14, + "column": 4 + } + ] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-with-ts-7/parser-options.json b/test/fixtures/ast/multiple-scripts-with-ts-7/parser-options.json new file mode 100644 index 00000000..6e1a0ab4 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-ts-7/parser-options.json @@ -0,0 +1,4 @@ +{ + "sourceType": "module", + "parser": "@typescript-eslint/parser" +} diff --git a/test/fixtures/ast/multiple-scripts-with-ts-7/requirements.json b/test/fixtures/ast/multiple-scripts-with-ts-7/requirements.json new file mode 100644 index 00000000..945cf775 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-ts-7/requirements.json @@ -0,0 +1,3 @@ +{ + "@typescript-eslint/parser": "^4.0.0" +} \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-with-ts-7/scope.json b/test/fixtures/ast/multiple-scripts-with-ts-7/scope.json new file mode 100644 index 00000000..0e204975 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-ts-7/scope.json @@ -0,0 +1,1319 @@ +{ + "type": "global", + "variables": [ + { + "name": "Symbol", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PropertyKey", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PropertyDescriptor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PropertyDescriptorMap", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Object", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ObjectConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Function", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "FunctionConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ThisParameterType", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "OmitThisParameter", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "CallableFunction", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "NewableFunction", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "IArguments", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "String", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "StringConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Boolean", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "BooleanConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Number", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "NumberConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "TemplateStringsArray", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ImportMeta", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Math", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Date", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "DateConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "RegExpMatchArray", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "RegExpExecArray", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "RegExp", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "RegExpConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Error", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "EvalError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "EvalErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "RangeError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "RangeErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ReferenceError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ReferenceErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SyntaxError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SyntaxErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "TypeError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "TypeErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "URIError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "URIErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "JSON", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ReadonlyArray", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ConcatArray", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Array", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "TypedPropertyDescriptor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassDecorator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PropertyDecorator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "MethodDecorator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ParameterDecorator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PromiseConstructorLike", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PromiseLike", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Promise", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayLike", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Partial", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Required", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Readonly", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Pick", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Record", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Exclude", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Extract", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Omit", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "NonNullable", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Parameters", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ConstructorParameters", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ReturnType", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "InstanceType", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Uppercase", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Lowercase", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Capitalize", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Uncapitalize", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ThisType", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayBuffer", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayBufferTypes", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayBufferLike", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayBufferConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayBufferView", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "DataView", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "DataViewConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Int8Array", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Int8ArrayConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Uint8Array", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Uint8ArrayConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Uint8ClampedArray", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Uint8ClampedArrayConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Int16Array", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Int16ArrayConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Uint16Array", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Uint16ArrayConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Int32Array", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Int32ArrayConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Uint32Array", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Uint32ArrayConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Float32Array", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Float32ArrayConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Float64Array", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Float64ArrayConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Intl", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Map", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "MapConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ReadonlyMap", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "WeakMap", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "WeakMapConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Set", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SetConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ReadonlySet", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "WeakSet", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "WeakSetConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SymbolConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "IteratorYieldResult", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "IteratorReturnResult", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "IteratorResult", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Iterator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Iterable", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "IterableIterator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PromiseConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Generator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "GeneratorFunction", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "GeneratorFunctionConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ProxyHandler", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ProxyConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Reflect", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SharedArrayBuffer", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SharedArrayBufferConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Atomics", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncIterator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncIterable", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncIterableIterator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncGenerator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncGeneratorFunction", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncGeneratorFunctionConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "const", + "identifiers": [], + "defs": [], + "references": [] + } + ], + "references": [], + "childScopes": [ + { + "type": "module", + "variables": [ + { + "name": "count", + "identifiers": [ + { + "type": "Identifier", + "name": "count", + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 16 + } + } + }, + { + "type": "Identifier", + "name": "count", + "loc": { + "start": { + "line": 7, + "column": 4 + }, + "end": { + "line": 7, + "column": 9 + } + } + } + ], + "defs": [ + { + "type": "Variable", + "node": { + "type": "VariableDeclarator", + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 21 + } + } + }, + "name": "count" + }, + { + "type": "Variable", + "node": { + "type": "VariableDeclarator", + "loc": { + "start": { + "line": 7, + "column": 4 + }, + "end": { + "line": 7, + "column": 14 + } + } + }, + "name": "count" + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "count", + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 16 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "count", + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 16 + } + } + }, + "init": true + }, + { + "identifier": { + "type": "Identifier", + "name": "count", + "loc": { + "start": { + "line": 7, + "column": 4 + }, + "end": { + "line": 7, + "column": 9 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "count", + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 16 + } + } + }, + "init": true + } + ] + }, + { + "name": "MyComponent1", + "identifiers": [ + { + "type": "Identifier", + "name": "MyComponent1", + "loc": { + "start": { + "line": 6, + "column": 7 + }, + "end": { + "line": 6, + "column": 19 + } + } + } + ], + "defs": [ + { + "type": "ImportBinding", + "node": { + "type": "ImportDefaultSpecifier", + "loc": { + "start": { + "line": 6, + "column": 7 + }, + "end": { + "line": 6, + "column": 19 + } + } + }, + "name": "MyComponent1" + } + ], + "references": [] + }, + { + "name": "MyComponent2", + "identifiers": [ + { + "type": "Identifier", + "name": "MyComponent2", + "loc": { + "start": { + "line": 8, + "column": 7 + }, + "end": { + "line": 8, + "column": 19 + } + } + } + ], + "defs": [ + { + "type": "ImportBinding", + "node": { + "type": "ImportDefaultSpecifier", + "loc": { + "start": { + "line": 8, + "column": 7 + }, + "end": { + "line": 8, + "column": 19 + } + } + }, + "name": "MyComponent2" + } + ], + "references": [] + }, + { + "name": "a", + "identifiers": [ + { + "type": "Identifier", + "name": "a", + "loc": { + "start": { + "line": 9, + "column": 4 + }, + "end": { + "line": 9, + "column": 5 + } + } + } + ], + "defs": [ + { + "type": "Variable", + "node": { + "type": "VariableDeclarator", + "loc": { + "start": { + "line": 9, + "column": 4 + }, + "end": { + "line": 9, + "column": 13 + } + } + }, + "name": "a" + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "a", + "loc": { + "start": { + "line": 9, + "column": 4 + }, + "end": { + "line": 9, + "column": 5 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "a", + "loc": { + "start": { + "line": 9, + "column": 4 + }, + "end": { + "line": 9, + "column": 5 + } + } + }, + "init": true + } + ] + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "count", + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 16 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "count", + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 16 + } + } + }, + "init": true + }, + { + "identifier": { + "type": "Identifier", + "name": "count", + "loc": { + "start": { + "line": 7, + "column": 4 + }, + "end": { + "line": 7, + "column": 9 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "count", + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 16 + } + } + }, + "init": true + }, + { + "identifier": { + "type": "Identifier", + "name": "a", + "loc": { + "start": { + "line": 9, + "column": 4 + }, + "end": { + "line": 9, + "column": 5 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "a", + "loc": { + "start": { + "line": 9, + "column": 4 + }, + "end": { + "line": 9, + "column": 5 + } + } + }, + "init": true + }, + { + "identifier": { + "type": "Identifier", + "name": "b", + "loc": { + "start": { + "line": 9, + "column": 8 + }, + "end": { + "line": 9, + "column": 9 + } + } + }, + "from": "module", + "resolved": null, + "init": null + }, + { + "identifier": { + "type": "Identifier", + "name": "c", + "loc": { + "start": { + "line": 9, + "column": 12 + }, + "end": { + "line": 9, + "column": 13 + } + } + }, + "from": "module", + "resolved": null, + "init": null + } + ], + "childScopes": [], + "through": [ + { + "identifier": { + "type": "Identifier", + "name": "b", + "loc": { + "start": { + "line": 9, + "column": 8 + }, + "end": { + "line": 9, + "column": 9 + } + } + }, + "from": "module", + "resolved": null, + "init": null + }, + { + "identifier": { + "type": "Identifier", + "name": "c", + "loc": { + "start": { + "line": 9, + "column": 12 + }, + "end": { + "line": 9, + "column": 13 + } + } + }, + "from": "module", + "resolved": null, + "init": null + } + ] + } + ], + "through": [ + { + "identifier": { + "type": "Identifier", + "name": "b", + "loc": { + "start": { + "line": 9, + "column": 8 + }, + "end": { + "line": 9, + "column": 9 + } + } + }, + "from": "module", + "resolved": null, + "init": null + }, + { + "identifier": { + "type": "Identifier", + "name": "c", + "loc": { + "start": { + "line": 9, + "column": 12 + }, + "end": { + "line": 9, + "column": 13 + } + } + }, + "from": "module", + "resolved": null, + "init": null + } + ] +} \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-with-ts-7/source.vue b/test/fixtures/ast/multiple-scripts-with-ts-7/source.vue new file mode 100644 index 00000000..3bd3b5d1 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-ts-7/source.vue @@ -0,0 +1,16 @@ + + + + + + diff --git a/test/fixtures/ast/multiple-scripts-with-ts-7/token-ranges.json b/test/fixtures/ast/multiple-scripts-with-ts-7/token-ranges.json new file mode 100644 index 00000000..acbbc20c --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-ts-7/token-ranges.json @@ -0,0 +1,105 @@ +[ + "", + "", + "", + "\n", + "export", + " ", + "let", + " ", + "count", + " ", + "=", + " ", + "42", + "\n", + "", + "\n\n", + "", + "\n", + "import", + " ", + "MyComponent1", + " ", + "from", + " ", + "'./MyComponent1.vue'", + "\n", + "let", + " ", + "count", + " ", + "=", + " ", + "42", + "\n", + "import", + " ", + "MyComponent2", + " ", + "from", + " ", + "'./MyComponent2.vue'", + "\n", + "let", + " ", + "a", + " ", + "=", + " ", + "b", + " ", + "+", + " ", + "c", + "\n", + "", + "\n\n", + "", + "\n ", + "", + "{{", + "count", + "}}", + "", + "\n ", + "", + "\n", + "", + "\n\n" +] \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-with-ts-7/tree.json b/test/fixtures/ast/multiple-scripts-with-ts-7/tree.json new file mode 100644 index 00000000..b3d62709 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-ts-7/tree.json @@ -0,0 +1,71 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-with-ts-export-decorator-1/ast.json b/test/fixtures/ast/multiple-scripts-with-ts-export-decorator-1/ast.json new file mode 100644 index 00000000..eeeed2fc --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-ts-export-decorator-1/ast.json @@ -0,0 +1,733 @@ +{ + "type": "Program", + "body": [ + { + "type": "ExportNamedDeclaration", + "declaration": { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "a", + "range": [ + 20, + 21 + ], + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 12 + } + } + }, + "init": { + "type": "Literal", + "value": 42, + "raw": "42", + "range": [ + 24, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 17 + } + } + }, + "range": [ + 20, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 17 + } + } + } + ], + "kind": "let", + "range": [ + 16, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 17 + } + } + }, + "specifiers": [], + "source": null, + "exportKind": "value", + "range": [ + 9, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 17 + } + } + }, + { + "type": "ExportNamedDeclaration", + "declaration": { + "type": "ClassDeclaration", + "id": { + "type": "Identifier", + "name": "A", + "range": [ + 77, + 78 + ], + "loc": { + "start": { + "line": 7, + "column": 13 + }, + "end": { + "line": 7, + "column": 14 + } + } + }, + "body": { + "type": "ClassBody", + "body": [], + "range": [ + 79, + 82 + ], + "loc": { + "start": { + "line": 7, + "column": 15 + }, + "end": { + "line": 8, + "column": 1 + } + } + }, + "superClass": null, + "range": [ + 53, + 82 + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 8, + "column": 1 + } + }, + "decorators": [ + { + "type": "Decorator", + "expression": { + "type": "Identifier", + "name": "Decorator", + "range": [ + 54, + 63 + ], + "loc": { + "start": { + "line": 6, + "column": 1 + }, + "end": { + "line": 6, + "column": 10 + } + } + }, + "range": [ + 53, + 63 + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 10 + } + } + } + ] + }, + "specifiers": [], + "source": null, + "exportKind": "value", + "range": [ + 64, + 82 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 8, + "column": 1 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "a", + "range": [ + 89, + 90 + ], + "loc": { + "start": { + "line": 9, + "column": 6 + }, + "end": { + "line": 9, + "column": 7 + } + } + }, + "init": { + "type": "NewExpression", + "callee": { + "type": "Identifier", + "name": "A", + "range": [ + 97, + 98 + ], + "loc": { + "start": { + "line": 9, + "column": 14 + }, + "end": { + "line": 9, + "column": 15 + } + } + }, + "arguments": [], + "range": [ + 93, + 100 + ], + "loc": { + "start": { + "line": 9, + "column": 10 + }, + "end": { + "line": 9, + "column": 17 + } + } + }, + "range": [ + 89, + 100 + ], + "loc": { + "start": { + "line": 9, + "column": 6 + }, + "end": { + "line": 9, + "column": 17 + } + } + } + ], + "kind": "const", + "range": [ + 83, + 100 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 17 + } + } + } + ], + "sourceType": "module", + "range": [ + 9, + 100 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 9, + "column": 17 + } + }, + "tokens": [ + { + "type": "Punctuator", + "range": [ + 0, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 38, + 52 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 14 + } + }, + "value": "" + } + ], + "comments": [] +} \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-with-ts-export-decorator-1/parser-options.json b/test/fixtures/ast/multiple-scripts-with-ts-export-decorator-1/parser-options.json new file mode 100644 index 00000000..6e1a0ab4 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-ts-export-decorator-1/parser-options.json @@ -0,0 +1,4 @@ +{ + "sourceType": "module", + "parser": "@typescript-eslint/parser" +} diff --git a/test/fixtures/ast/multiple-scripts-with-ts-export-decorator-1/requirements.json b/test/fixtures/ast/multiple-scripts-with-ts-export-decorator-1/requirements.json new file mode 100644 index 00000000..945cf775 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-ts-export-decorator-1/requirements.json @@ -0,0 +1,3 @@ +{ + "@typescript-eslint/parser": "^4.0.0" +} \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-with-ts-export-decorator-1/source.vue b/test/fixtures/ast/multiple-scripts-with-ts-export-decorator-1/source.vue new file mode 100644 index 00000000..a91efd79 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-ts-export-decorator-1/source.vue @@ -0,0 +1,10 @@ + + + diff --git a/test/fixtures/ast/multiple-scripts-with-ts-export-decorator-1/token-ranges.json b/test/fixtures/ast/multiple-scripts-with-ts-export-decorator-1/token-ranges.json new file mode 100644 index 00000000..deeb00ef --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-ts-export-decorator-1/token-ranges.json @@ -0,0 +1,25 @@ +[ + "", + "" +] \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-with-ts-export-decorator-1/tree.json b/test/fixtures/ast/multiple-scripts-with-ts-export-decorator-1/tree.json new file mode 100644 index 00000000..0637a088 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-ts-export-decorator-1/tree.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-with-ts/ast.json b/test/fixtures/ast/multiple-scripts-with-ts/ast.json new file mode 100644 index 00000000..7a9a4eb9 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-ts/ast.json @@ -0,0 +1,544 @@ +{ + "type": "Program", + "range": [ + 9, + 98 + ], + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "arguments": [], + "callee": { + "type": "Identifier", + "decorators": [], + "name": "performGlobalSideEffect", + "optional": false, + "range": [ + 9, + 32 + ], + "loc": { + "end": { + "line": 2, + "column": 23 + }, + "start": { + "line": 2, + "column": 0 + } + } + }, + "optional": false, + "range": [ + 9, + 34 + ], + "loc": { + "end": { + "line": 2, + "column": 25 + }, + "start": { + "line": 2, + "column": 0 + } + } + }, + "range": [ + 9, + 34 + ], + "loc": { + "end": { + "line": 2, + "column": 25 + }, + "start": { + "line": 2, + "column": 0 + } + } + }, + { + "type": "ExportNamedDeclaration", + "range": [ + 36, + 58 + ], + "attributes": [], + "declaration": { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "definite": false, + "id": { + "type": "Identifier", + "decorators": [], + "name": "named", + "optional": false, + "range": [ + 49, + 54 + ], + "loc": { + "end": { + "line": 4, + "column": 18 + }, + "start": { + "line": 4, + "column": 13 + } + } + }, + "init": { + "type": "Literal", + "raw": "1", + "value": 1, + "range": [ + 57, + 58 + ], + "loc": { + "end": { + "line": 4, + "column": 22 + }, + "start": { + "line": 4, + "column": 21 + } + } + }, + "range": [ + 49, + 58 + ], + "loc": { + "end": { + "line": 4, + "column": 22 + }, + "start": { + "line": 4, + "column": 13 + } + } + } + ], + "declare": false, + "kind": "const", + "range": [ + 43, + 58 + ], + "loc": { + "end": { + "line": 4, + "column": 22 + }, + "start": { + "line": 4, + "column": 7 + } + } + }, + "exportKind": "value", + "source": null, + "specifiers": [], + "loc": { + "end": { + "line": 4, + "column": 22 + }, + "start": { + "line": 4, + "column": 0 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "definite": false, + "id": { + "type": "Identifier", + "decorators": [], + "name": "count", + "optional": false, + "range": [ + 89, + 94 + ], + "loc": { + "end": { + "line": 8, + "column": 9 + }, + "start": { + "line": 8, + "column": 4 + } + } + }, + "init": { + "type": "Literal", + "raw": "0", + "value": 0, + "range": [ + 97, + 98 + ], + "loc": { + "end": { + "line": 8, + "column": 13 + }, + "start": { + "line": 8, + "column": 12 + } + } + }, + "range": [ + 89, + 98 + ], + "loc": { + "end": { + "line": 8, + "column": 13 + }, + "start": { + "line": 8, + "column": 4 + } + } + } + ], + "declare": false, + "kind": "let", + "range": [ + 85, + 98 + ], + "loc": { + "end": { + "line": 8, + "column": 13 + }, + "start": { + "line": 8, + "column": 0 + } + } + } + ], + "comments": [], + "sourceType": "module", + "tokens": [ + { + "type": "Punctuator", + "range": [ + 0, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 70, + 84 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 14 + } + }, + "value": "" + } + ], + "loc": { + "end": { + "line": 8, + "column": 13 + }, + "start": { + "line": 2, + "column": 0 + } + } +} \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-with-ts/parser-options.json b/test/fixtures/ast/multiple-scripts-with-ts/parser-options.json new file mode 100644 index 00000000..6e1a0ab4 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-ts/parser-options.json @@ -0,0 +1,4 @@ +{ + "sourceType": "module", + "parser": "@typescript-eslint/parser" +} diff --git a/test/fixtures/ast/multiple-scripts-with-ts/source.vue b/test/fixtures/ast/multiple-scripts-with-ts/source.vue new file mode 100644 index 00000000..f1b3e9d4 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-ts/source.vue @@ -0,0 +1,9 @@ + + + diff --git a/test/fixtures/ast/multiple-scripts-with-ts/token-ranges.json b/test/fixtures/ast/multiple-scripts-with-ts/token-ranges.json new file mode 100644 index 00000000..c7118715 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-ts/token-ranges.json @@ -0,0 +1,18 @@ +[ + "", + "" +] \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts-with-ts/tree.json b/test/fixtures/ast/multiple-scripts-with-ts/tree.json new file mode 100644 index 00000000..0637a088 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-ts/tree.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts/ast.json b/test/fixtures/ast/multiple-scripts/ast.json new file mode 100644 index 00000000..0867d769 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts/ast.json @@ -0,0 +1,583 @@ +{ + "type": "Program", + "start": 8, + "end": 99, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 8, + "column": 13 + } + }, + "range": [ + 9, + 98 + ], + "body": [ + { + "type": "ExpressionStatement", + "start": 9, + "end": 34, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "range": [ + 9, + 34 + ], + "expression": { + "type": "CallExpression", + "start": 9, + "end": 34, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "range": [ + 9, + 34 + ], + "callee": { + "type": "Identifier", + "start": 9, + "end": 32, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 23 + } + }, + "range": [ + 9, + 32 + ], + "name": "performGlobalSideEffect" + }, + "arguments": [], + "optional": false + } + }, + { + "type": "ExportNamedDeclaration", + "start": 36, + "end": 58, + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 22 + } + }, + "range": [ + 36, + 58 + ], + "declaration": { + "type": "VariableDeclaration", + "start": 43, + "end": 58, + "loc": { + "start": { + "line": 4, + "column": 7 + }, + "end": { + "line": 4, + "column": 22 + } + }, + "range": [ + 43, + 58 + ], + "declarations": [ + { + "type": "VariableDeclarator", + "start": 49, + "end": 58, + "loc": { + "start": { + "line": 4, + "column": 13 + }, + "end": { + "line": 4, + "column": 22 + } + }, + "range": [ + 49, + 58 + ], + "id": { + "type": "Identifier", + "start": 49, + "end": 54, + "loc": { + "start": { + "line": 4, + "column": 13 + }, + "end": { + "line": 4, + "column": 18 + } + }, + "range": [ + 49, + 54 + ], + "name": "named" + }, + "init": { + "type": "Literal", + "start": 57, + "end": 58, + "loc": { + "start": { + "line": 4, + "column": 21 + }, + "end": { + "line": 4, + "column": 22 + } + }, + "range": [ + 57, + 58 + ], + "value": 1, + "raw": "1" + } + } + ], + "kind": "const" + }, + "specifiers": [], + "source": null, + "attributes": [] + }, + { + "type": "VariableDeclaration", + "start": 85, + "end": 98, + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 13 + } + }, + "range": [ + 85, + 98 + ], + "declarations": [ + { + "type": "VariableDeclarator", + "start": 89, + "end": 98, + "loc": { + "start": { + "line": 8, + "column": 4 + }, + "end": { + "line": 8, + "column": 13 + } + }, + "range": [ + 89, + 98 + ], + "id": { + "type": "Identifier", + "start": 89, + "end": 94, + "loc": { + "start": { + "line": 8, + "column": 4 + }, + "end": { + "line": 8, + "column": 9 + } + }, + "range": [ + 89, + 94 + ], + "name": "count" + }, + "init": { + "type": "Literal", + "start": 97, + "end": 98, + "loc": { + "start": { + "line": 8, + "column": 12 + }, + "end": { + "line": 8, + "column": 13 + } + }, + "range": [ + 97, + 98 + ], + "value": 0, + "raw": "0" + } + } + ], + "kind": "let" + } + ], + "sourceType": "module", + "comments": [], + "tokens": [ + { + "type": "Punctuator", + "range": [ + 0, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 70, + 84 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 14 + } + }, + "value": "" + } + ] +} \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts/parser-options.json b/test/fixtures/ast/multiple-scripts/parser-options.json new file mode 100644 index 00000000..2104ca43 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts/parser-options.json @@ -0,0 +1,3 @@ +{ + "sourceType": "module" +} diff --git a/test/fixtures/ast/multiple-scripts/requirements.json b/test/fixtures/ast/multiple-scripts/requirements.json new file mode 100644 index 00000000..36659b1f --- /dev/null +++ b/test/fixtures/ast/multiple-scripts/requirements.json @@ -0,0 +1,3 @@ +{ + "eslint": ">=8" +} \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts/source.vue b/test/fixtures/ast/multiple-scripts/source.vue new file mode 100644 index 00000000..f1b3e9d4 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts/source.vue @@ -0,0 +1,9 @@ + + + diff --git a/test/fixtures/ast/multiple-scripts/token-ranges.json b/test/fixtures/ast/multiple-scripts/token-ranges.json new file mode 100644 index 00000000..c7118715 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts/token-ranges.json @@ -0,0 +1,18 @@ +[ + "", + "" +] \ No newline at end of file diff --git a/test/fixtures/ast/multiple-scripts/tree.json b/test/fixtures/ast/multiple-scripts/tree.json new file mode 100644 index 00000000..0637a088 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts/tree.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/fixtures/ast/mustache-errors-in-textarea/ast.json b/test/fixtures/ast/mustache-errors-in-textarea/ast.json new file mode 100644 index 00000000..9dd73fed --- /dev/null +++ b/test/fixtures/ast/mustache-errors-in-textarea/ast.json @@ -0,0 +1,495 @@ +{ + "type": "Program", + "start": 0, + "end": 0, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 0 + } + }, + "range": [ + 0, + 0 + ], + "body": [], + "sourceType": "module", + "comments": [], + "tokens": [], + "templateBody": { + "type": "VElement", + "range": [ + 0, + 59 + ], + "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, + 15 + ], + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 2, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 15, + 47 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 36 + } + }, + "name": "textarea", + "rawName": "textarea", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 15, + 25 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VExpressionContainer", + "range": [ + 25, + 36 + ], + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "expression": null, + "references": [] + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 36, + 47 + ], + "loc": { + "start": { + "line": 2, + "column": 25 + }, + "end": { + "line": 2, + "column": 36 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 47, + 48 + ], + "loc": { + "start": { + "line": 2, + "column": 36 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 48, + 59 + ], + "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, + 15 + ], + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 2, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 15, + 24 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "value": "textarea" + }, + { + "type": "HTMLTagClose", + "range": [ + 24, + 25 + ], + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "value": "" + }, + { + "type": "VExpressionStart", + "range": [ + 25, + 27 + ], + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "value": "{{" + }, + { + "type": "HTMLRCDataText", + "range": [ + 27, + 30 + ], + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "value": "foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 30, + 31 + ], + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "value": " " + }, + { + "type": "HTMLRCDataText", + "range": [ + 31, + 34 + ], + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 23 + } + }, + "value": "bar" + }, + { + "type": "VExpressionEnd", + "range": [ + 34, + 36 + ], + "loc": { + "start": { + "line": 2, + "column": 23 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "value": "}}" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 36, + 46 + ], + "loc": { + "start": { + "line": 2, + "column": 25 + }, + "end": { + "line": 2, + "column": 35 + } + }, + "value": "textarea" + }, + { + "type": "HTMLTagClose", + "range": [ + 46, + 47 + ], + "loc": { + "start": { + "line": 2, + "column": 35 + }, + "end": { + "line": 2, + "column": 36 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 47, + 48 + ], + "loc": { + "start": { + "line": 2, + "column": 36 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 48, + 58 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 58, + 59 + ], + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 59, + 60 + ], + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "value": "\n" + } + ], + "comments": [], + "errors": [ + { + "message": "Unexpected token bar", + "index": 31, + "lineNumber": 2, + "column": 20 + } + ] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/mustache-errors-in-textarea/source.vue b/test/fixtures/ast/mustache-errors-in-textarea/source.vue new file mode 100644 index 00000000..da4a40ab --- /dev/null +++ b/test/fixtures/ast/mustache-errors-in-textarea/source.vue @@ -0,0 +1,3 @@ + diff --git a/test/fixtures/ast/mustache-errors-in-textarea/token-ranges.json b/test/fixtures/ast/mustache-errors-in-textarea/token-ranges.json new file mode 100644 index 00000000..8f3b13ea --- /dev/null +++ b/test/fixtures/ast/mustache-errors-in-textarea/token-ranges.json @@ -0,0 +1,18 @@ +[ + "", + "\n ", + "", + "{{", + "foo", + " ", + "bar", + "}}", + "", + "\n", + "", + "\n" +] \ No newline at end of file diff --git a/test/fixtures/ast/mustache-errors-in-textarea/tree.json b/test/fixtures/ast/mustache-errors-in-textarea/tree.json new file mode 100644 index 00000000..f5b30cc1 --- /dev/null +++ b/test/fixtures/ast/mustache-errors-in-textarea/tree.json @@ -0,0 +1,49 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/ast/mustache-errors-opt-interpolation-as-non-html/ast.json b/test/fixtures/ast/mustache-errors-opt-interpolation-as-non-html/ast.json new file mode 100644 index 00000000..3d5e6b8a --- /dev/null +++ b/test/fixtures/ast/mustache-errors-opt-interpolation-as-non-html/ast.json @@ -0,0 +1,273 @@ +{ + "type": "Program", + "start": 0, + "end": 0, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 0 + } + }, + "range": [ + 0, + 0 + ], + "body": [], + "sourceType": "module", + "comments": [], + "tokens": [], + "templateBody": { + "type": "VElement", + "range": [ + 0, + 30 + ], + "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, + 19 + ], + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n {{a\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 19, + 30 + ], + "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, + 15 + ], + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 2, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "VExpressionStart", + "range": [ + 15, + 17 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 6 + } + }, + "value": "{{" + }, + { + "type": "HTMLText", + "range": [ + 17, + 18 + ], + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "value": "a" + }, + { + "type": "HTMLWhitespace", + "range": [ + 18, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 19, + 29 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 29, + 30 + ], + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 30, + 31 + ], + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "value": "\n" + } + ], + "comments": [], + "errors": [ + { + "message": "x-missing-interpolation-end", + "index": 16, + "lineNumber": 2, + "column": 5 + } + ] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/mustache-errors-opt-interpolation-as-non-html/parser-options.json b/test/fixtures/ast/mustache-errors-opt-interpolation-as-non-html/parser-options.json new file mode 100644 index 00000000..466a4eef --- /dev/null +++ b/test/fixtures/ast/mustache-errors-opt-interpolation-as-non-html/parser-options.json @@ -0,0 +1,5 @@ +{ + "vueFeatures": { + "interpolationAsNonHTML": true + } +} diff --git a/test/fixtures/ast/mustache-errors-opt-interpolation-as-non-html/source.vue b/test/fixtures/ast/mustache-errors-opt-interpolation-as-non-html/source.vue new file mode 100644 index 00000000..ffc8cd5f --- /dev/null +++ b/test/fixtures/ast/mustache-errors-opt-interpolation-as-non-html/source.vue @@ -0,0 +1,3 @@ + diff --git a/test/fixtures/ast/mustache-errors-opt-interpolation-as-non-html/token-ranges.json b/test/fixtures/ast/mustache-errors-opt-interpolation-as-non-html/token-ranges.json new file mode 100644 index 00000000..eaa307ee --- /dev/null +++ b/test/fixtures/ast/mustache-errors-opt-interpolation-as-non-html/token-ranges.json @@ -0,0 +1,11 @@ +[ + "", + "\n ", + "{{", + "a", + "\n", + "", + "\n" +] \ No newline at end of file diff --git a/test/fixtures/ast/mustache-errors-opt-interpolation-as-non-html/tree.json b/test/fixtures/ast/mustache-errors-opt-interpolation-as-non-html/tree.json new file mode 100644 index 00000000..3ea9dbc0 --- /dev/null +++ b/test/fixtures/ast/mustache-errors-opt-interpolation-as-non-html/tree.json @@ -0,0 +1,23 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/ast/mustache-errors/ast.json b/test/fixtures/ast/mustache-errors/ast.json index 7d1a3129..9fc7248b 100644 --- a/test/fixtures/ast/mustache-errors/ast.json +++ b/test/fixtures/ast/mustache-errors/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/mustache-in-escape-opt-interpolation-as-non-html/ast.json b/test/fixtures/ast/mustache-in-escape-opt-interpolation-as-non-html/ast.json new file mode 100644 index 00000000..b7b14002 --- /dev/null +++ b/test/fixtures/ast/mustache-in-escape-opt-interpolation-as-non-html/ast.json @@ -0,0 +1,675 @@ +{ + "type": "Program", + "start": 0, + "end": 0, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 0 + } + }, + "range": [ + 0, + 0 + ], + "body": [], + "sourceType": "module", + "comments": [], + "tokens": [], + "templateBody": { + "type": "VElement", + "range": [ + 0, + 47 + ], + "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, + 15 + ], + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 2, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "VExpressionContainer", + "range": [ + 15, + 35 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 24 + } + }, + "expression": { + "type": "LogicalExpression", + "start": 17, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "range": [ + 17, + 33 + ], + "left": { + "type": "BinaryExpression", + "start": 17, + "end": 20, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "range": [ + 17, + 20 + ], + "left": { + "type": "Identifier", + "start": 17, + "end": 18, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "range": [ + 17, + 18 + ], + "name": "a" + }, + "operator": "<", + "right": { + "type": "Identifier", + "start": 19, + "end": 20, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "range": [ + 19, + 20 + ], + "name": "b" + } + }, + "operator": "&&", + "right": { + "type": "BinaryExpression", + "start": 30, + "end": 33, + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "range": [ + 30, + 33 + ], + "left": { + "type": "Identifier", + "start": 30, + "end": 31, + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "range": [ + 30, + 31 + ], + "name": "b" + }, + "operator": "<", + "right": { + "type": "Identifier", + "start": 32, + "end": 33, + "loc": { + "start": { + "line": 2, + "column": 21 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "range": [ + 32, + 33 + ], + "name": "c" + } + } + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 17, + "end": 18, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "range": [ + 17, + 18 + ], + "name": "a" + }, + "mode": "r" + }, + { + "id": { + "type": "Identifier", + "start": 19, + "end": 20, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "range": [ + 19, + 20 + ], + "name": "b" + }, + "mode": "r" + }, + { + "id": { + "type": "Identifier", + "start": 30, + "end": 31, + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "range": [ + 30, + 31 + ], + "name": "b" + }, + "mode": "r" + }, + { + "id": { + "type": "Identifier", + "start": 32, + "end": 33, + "loc": { + "start": { + "line": 2, + "column": 21 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "range": [ + 32, + 33 + ], + "name": "c" + }, + "mode": "r" + } + ] + }, + { + "type": "VText", + "range": [ + 35, + 36 + ], + "loc": { + "start": { + "line": 2, + "column": 24 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 36, + 47 + ], + "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, + 15 + ], + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 2, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "VExpressionStart", + "range": [ + 15, + 17 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 6 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "value": "a", + "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": "b", + "start": 19, + "end": 20, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "range": [ + 19, + 20 + ] + }, + { + "type": "Punctuator", + "value": "&&", + "start": 20, + "end": 22, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "range": [ + 20, + 30 + ] + }, + { + "type": "Identifier", + "value": "b", + "start": 30, + "end": 31, + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "range": [ + 30, + 31 + ] + }, + { + "type": "Punctuator", + "value": "<", + "start": 31, + "end": 32, + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "range": [ + 31, + 32 + ] + }, + { + "type": "Identifier", + "value": "c", + "start": 32, + "end": 33, + "loc": { + "start": { + "line": 2, + "column": 21 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "range": [ + 32, + 33 + ] + }, + { + "type": "VExpressionEnd", + "range": [ + 33, + 35 + ], + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 2, + "column": 24 + } + }, + "value": "}}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 35, + 36 + ], + "loc": { + "start": { + "line": 2, + "column": 24 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 36, + 46 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 46, + 47 + ], + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 47, + 48 + ], + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "value": "\n" + } + ], + "comments": [], + "errors": [] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/mustache-in-escape-opt-interpolation-as-non-html/parser-options.json b/test/fixtures/ast/mustache-in-escape-opt-interpolation-as-non-html/parser-options.json new file mode 100644 index 00000000..466a4eef --- /dev/null +++ b/test/fixtures/ast/mustache-in-escape-opt-interpolation-as-non-html/parser-options.json @@ -0,0 +1,5 @@ +{ + "vueFeatures": { + "interpolationAsNonHTML": true + } +} diff --git a/test/fixtures/ast/mustache-in-escape-opt-interpolation-as-non-html/source.vue b/test/fixtures/ast/mustache-in-escape-opt-interpolation-as-non-html/source.vue new file mode 100644 index 00000000..e53df4b7 --- /dev/null +++ b/test/fixtures/ast/mustache-in-escape-opt-interpolation-as-non-html/source.vue @@ -0,0 +1,3 @@ +