diff --git a/.eslintignore b/.eslintignore index b77b6607..537f1533 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,7 +1,7 @@ /.nyc_output /.temp /coverage -/node_modules +node_modules /src/external /src/html/util /test/fixtures diff --git a/.eslintrc.yml b/.eslintrc.yml index d1ee2dff..9a375797 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -1,14 +1,878 @@ +plugins: + - prettier extends: - - plugin:@mysticatea/es2015 - - plugin:@mysticatea/+node - - plugin:@mysticatea/+modules + - plugin:node-dependencies/recommended + - plugin:jsonc/recommended-with-jsonc +globals: + root: off +parserOptions: + ecmaFeatures: + globalReturn: false + sourceType: module + ecmaVersion: 2020 + loggerFn: false + project: tsconfig.json +rules: + prettier/prettier: + - error + - tabWidth: 4 + semi: false + trailingComma: all + - usePrettierrc: false overrides: - - files: "*.ts" + - files: "*.json" rules: - "@mysticatea/ts/no-use-before-define": "off" + prettier/prettier: + - error + - tabWidth: 2 + semi: false + trailingComma: all + - usePrettierrc: false + - files: "**/*.ts" + plugins: + - "@typescript-eslint" + - eslint-comments + - node + parser: "@typescript-eslint/parser" + rules: + prettier/prettier: + - error + - tabWidth: 4 + semi: false + trailingComma: all + parser: typescript + - usePrettierrc: false + "@typescript-eslint/consistent-type-imports": error + no-duplicate-imports: off + "@typescript-eslint/no-duplicate-imports": error + "@typescript-eslint/no-var-requires": off + node/no-unsupported-features/es-syntax: + - off + - ignores: + - modules + - dynamicImport + node/no-extraneous-import: + - error + node/file-extension-in-import: + - error + - always + - .js: never + .ts: never + .tsx: never + node/no-missing-import: + - error + node/no-unpublished-import: + - error + node/exports-style: + - error + - module.exports + node/no-callback-literal: + - off + node/no-deprecated-api: + - error + node/no-exports-assign: + - error + node/no-extraneous-require: + - error + node/no-missing-require: + - error + node/no-unpublished-bin: + - error + node/no-unpublished-require: + - error + node/no-unsupported-features/es-builtins: + - error + node/no-unsupported-features/node-builtins: + - error + node/prefer-global/buffer: + - error + node/prefer-global/console: + - error + node/prefer-global/process: + - error + node/prefer-global/text-decoder: + - off + node/prefer-global/text-encoder: + - off + node/prefer-global/url-search-params: + - off + node/prefer-global/url: + - off + node/prefer-promises/dns: + - off + node/prefer-promises/fs: + - off + node/process-exit-as-throw: + - error + node/shebang: + - error + "@typescript-eslint/adjacent-overload-signatures": + - error + "@typescript-eslint/array-type": + - error + "@typescript-eslint/await-thenable": + - error + "@typescript-eslint/ban-ts-comment": + - error + "@typescript-eslint/consistent-type-assertions": + - error + "@typescript-eslint/explicit-member-accessibility": + - error + "@typescript-eslint/no-array-constructor": + - error + "@typescript-eslint/no-empty-interface": + - error + "@typescript-eslint/no-extraneous-class": + - error + "@typescript-eslint/no-floating-promises": + - error + "@typescript-eslint/no-for-in-array": + - error + "@typescript-eslint/no-inferrable-types": + - error + "@typescript-eslint/no-misused-new": + - error + "@typescript-eslint/no-misused-promises": + - error + "@typescript-eslint/no-parameter-properties": + - error + "@typescript-eslint/no-require-imports": + - error + "@typescript-eslint/no-this-alias": + - error + - allowDestructuring: true + "@typescript-eslint/no-unnecessary-qualifier": + - error + "@typescript-eslint/no-unnecessary-type-arguments": + - error + "@typescript-eslint/no-unnecessary-type-assertion": + - error + "@typescript-eslint/prefer-function-type": + - off + "@typescript-eslint/prefer-includes": + - error + "@typescript-eslint/prefer-namespace-keyword": + - error + "@typescript-eslint/prefer-readonly": + - off + "@typescript-eslint/prefer-regexp-exec": + - error + "@typescript-eslint/prefer-string-starts-ends-with": + - error + "@typescript-eslint/restrict-plus-operands": + - error + "@typescript-eslint/require-array-sort-compare": + - error + "@typescript-eslint/triple-slash-reference": + - error + "@typescript-eslint/unbound-method": + - off + - ignoreStatic: true + "@typescript-eslint/unified-signatures": + - off + camelcase: + - off + no-empty-function: + - off + "@typescript-eslint/no-empty-function": + - error + no-useless-constructor: + - off + "@typescript-eslint/no-useless-constructor": + - error + require-await: + - off + "@typescript-eslint/require-await": + - error + func-style: + - off + - declaration + init-declarations: + - off + lines-between-class-members: + - off + no-dupe-class-members: + - off + no-invalid-this: + - off + no-loop-func: + - off + no-redeclare: + - off + - builtinGlobals: true + no-undef: + - off + - typeof: true + no-unused-vars: + - off + - args: all + argsIgnorePattern: "^_(?:[^_].*)?$" + caughtErrors: all + vars: all + varsIgnorePattern: "^_(?:[^_].*)?$" + no-use-before-define: + - off + - nofunc + one-var: + - off + - initialized: never + uninitialized: always + "@typescript-eslint/ban-types": + - off + "@typescript-eslint/brace-style": + - off + "@typescript-eslint/consistent-type-definitions": + - off + "@typescript-eslint/explicit-function-return-type": + - off + "@typescript-eslint/func-call-spacing": + - off + "@typescript-eslint/generic-type-naming": + - off + "@typescript-eslint/indent": + - off + "@typescript-eslint/member-delimiter-style": + - off + "@typescript-eslint/member-ordering": + - off + "@typescript-eslint/no-explicit-any": + - off + "@typescript-eslint/no-extra-parens": + - off + "@typescript-eslint/no-magic-numbers": + - off + "@typescript-eslint/no-namespace": + - off + "@typescript-eslint/no-non-null-assertion": + - off + "@typescript-eslint/no-type-alias": + - off + "@typescript-eslint/no-unnecessary-condition": + - off + "@typescript-eslint/no-unused-vars": + - off + "@typescript-eslint/no-use-before-define": + - off + "@typescript-eslint/prefer-for-of": + - off + "@typescript-eslint/promise-function-async": + - off + "@typescript-eslint/quotes": + - off + "@typescript-eslint/semi": + - off + "@typescript-eslint/strict-boolean-expressions": + - off + "@typescript-eslint/type-annotation-spacing": + - off + "@typescript-eslint/typedef": + - off + arrow-body-style: + - error + constructor-super: + - error + default-param-last: + - error + no-class-assign: + - error + no-const-assign: + - error + no-import-assign: + - error + no-new-symbol: + - error + no-template-curly-in-string: + - error + no-this-before-super: + - error + no-useless-computed-key: + - error + no-useless-rename: + - error + no-var: + - error + object-shorthand: + - error + - always + - avoidExplicitReturnArrows: true + prefer-arrow-callback: + - error + prefer-const: + - error + prefer-numeric-literals: + - error + prefer-rest-params: + - error + prefer-spread: + - error + prefer-template: + - error + require-unicode-regexp: + - error + require-yield: + - error + symbol-description: + - error + class-methods-use-this: + - warn + arrow-parens: + - off + arrow-spacing: + - off + generator-star-spacing: + - off + no-confusing-arrow: + - off + rest-spread-spacing: + - off + template-curly-spacing: + - off + yield-star-spacing: + - off + no-inner-declarations: + - off + - functions + no-restricted-imports: + - off + prefer-destructuring: + - off + sort-imports: + - off + accessor-pairs: + - error + - enforceForClassMembers: true + getWithoutSet: false + setWithoutGet: true + array-callback-return: + - error + consistent-return: + - error + curly: + - error + default-case: + - error + dot-notation: + - error + eqeqeq: + - error + - always + - "null": ignore + for-direction: + - error + getter-return: + - error + linebreak-style: + - error + - unix + max-statements-per-line: + - error + - max: 1 + multiline-comment-style: + - error + - separate-lines + new-cap: + - error + no-alert: + - error + no-array-constructor: + - error + no-async-promise-executor: + - error + no-caller: + - error + no-case-declarations: + - error + no-compare-neg-zero: + - error + no-cond-assign: + - error + no-constant-condition: + - error + no-control-regex: + - error + no-debugger: + - error + no-delete-var: + - error + no-div-regex: + - error + no-dupe-args: + - error + no-dupe-keys: + - error + no-duplicate-case: + - error + no-else-return: + - error + no-empty: + - error + no-empty-character-class: + - error + no-empty-pattern: + - error + no-eval: + - error + no-ex-assign: + - error + no-extend-native: + - error + no-extra-bind: + - error + no-extra-boolean-cast: + - error + no-extra-label: + - error + no-fallthrough: + - error + no-func-assign: + - error + no-global-assign: + - error + no-implicit-coercion: + - error + no-implicit-globals: + - error + no-implied-eval: + - error + no-invalid-regexp: + - error + no-irregular-whitespace: + - error + - skipComments: false + skipRegExps: false + skipStrings: false + skipTemplates: false + no-iterator: + - error + no-label-var: + - error + no-lone-blocks: + - error + no-lonely-if: + - error + no-misleading-character-class: + - error + no-mixed-operators: + - error + - groups: + - + - "&" + - "|" + - ^ + - "~" + - << + - ">>" + - ">>>" + - + - "&&" + - "||" + allowSamePrecedence: true + no-new: + - error + no-new-object: + - error + no-new-require: + - error + no-new-wrappers: + - error + no-obj-calls: + - error + no-octal: + - error + no-octal-escape: + - error + no-param-reassign: + - error + - props: false + no-process-env: + - error + no-process-exit: + - error + no-prototype-builtins: + - error + no-regex-spaces: + - error + no-restricted-properties: + - error + - property: __count__ + - property: __noSuchMethod__ + - property: __parent__ + - property: __defineGetter__ + - property: __defineSetter__ + - property: __lookupGetter__ + - property: __lookupSetter__ + no-return-assign: + - error + no-return-await: + - error + no-script-url: + - error + no-self-assign: + - error + - props: true + no-self-compare: + - error + no-sequences: + - error + "@typescript-eslint/no-shadow": + - error + - builtinGlobals: true + hoist: functions + no-shadow-restricted-names: + - error + no-sparse-arrays: + - error + no-tabs: + - error + no-throw-literal: + - error + no-unexpected-multiline: + - error + no-unmodified-loop-condition: + - error + no-unneeded-ternary: + - error + no-unreachable: + - error + no-unsafe-finally: + - error + no-unsafe-negation: + - error + - enforceForOrderingRelations: true + no-unused-expressions: + - error + no-unused-labels: + - error + no-useless-call: + - error + no-useless-catch: + - error + no-useless-concat: + - error + no-useless-escape: + - error + no-useless-return: + - error + no-void: + - error + no-with: + - error + padding-line-between-statements: + - error + - blankLine: always + next: "*" + prev: directive + - blankLine: always + next: function + prev: "*" + - blankLine: always + next: "*" + prev: function + prefer-promise-reject-errors: + - error + prefer-regex-literals: + - error + quotes: + - error + - double + - avoidEscape: true + radix: + - error + require-atomic-updates: + - error + spaced-comment: + - error + - always + - block: + balanced: true + markers: + - eslint + - eslint-env + - eslint-disable + - eslint-enable + - exported + - globals + - istanbul + line: + exceptions: + - "-" + - = + markers: + - eslint-disable-line + - eslint-disable-next-line + - istanbul + - "TODO:" + - "FIXME:" + strict: + - error + - global + use-isnan: + - error + - enforceForIndexOf: true + enforceForSwitchCase: true + valid-typeof: + - error + - requireStringLiterals: true + yoda: + - error + - never + - exceptRange: true + onlyEquality: false + complexity: + - warn + - max: 16 + max-nested-callbacks: + - warn + - max: 4 + max-params: + - warn + - max: 8 + no-console: + - warn + - allow: + - assert + - error + array-bracket-newline: + - off + array-bracket-spacing: + - off + array-element-newline: + - off + block-spacing: + - off + brace-style: + - off + comma-dangle: + - off + comma-spacing: + - off + comma-style: + - off + computed-property-spacing: + - off + dot-location: + - off + eol-last: + - off + func-call-spacing: + - off + function-call-argument-newline: + - off + function-paren-newline: + - off + implicit-arrow-linebreak: + - off + indent: + - off + jsx-quotes: + - off + key-spacing: + - off + keyword-spacing: + - off + multiline-ternary: + - off + new-parens: + - off + newline-per-chained-call: + - off + no-extra-parens: + - off + no-extra-semi: + - off + no-floating-decimal: + - off + no-mixed-spaces-and-tabs: + - off + no-multi-spaces: + - off + no-multiple-empty-lines: + - off + no-trailing-spaces: + - off + no-whitespace-before-property: + - off + nonblock-statement-body-position: + - off + object-curly-newline: + - off + object-curly-spacing: + - off + object-property-newline: + - off + one-var-declaration-per-line: + - off + operator-linebreak: + - off + padded-blocks: + - off + quote-props: + - off + semi: + - off + semi-spacing: + - off + semi-style: + - off + space-before-blocks: + - off + space-before-function-paren: + - off + space-in-parens: + - off + space-infix-ops: + - off + space-unary-ops: + - off + switch-colon-spacing: + - off + template-tag-spacing: + - off + unicode-bom: + - off + wrap-iife: + - off + wrap-regex: + - off + block-scoped-var: + - off + callback-return: + - off + capitalized-comments: + - off + consistent-this: + - off + func-name-matching: + - off + func-names: + - off + global-require: + - off + guard-for-in: + - off + handle-callback-err: + - off + id-blacklist: + - off + id-length: + - off + id-match: + - off + line-comment-position: + - off + lines-around-comment: + - off + max-classes-per-file: + - off + max-depth: + - off + max-len: + - off + max-lines: + - off + max-lines-per-function: + - off + max-statements: + - off + no-await-in-loop: + - off + no-bitwise: + - off + no-buffer-constructor: + - off + no-continue: + - off + no-eq-null: + - off + no-inline-comments: + - off + no-labels: + - off + no-magic-numbers: + - off + no-mixed-requires: + - off + no-multi-assign: + - off + no-multi-str: + - off + no-negated-condition: + - off + no-nested-ternary: + - off + no-new-func: + - off + no-path-concat: + - off + no-plusplus: + - off + no-proto: + - off + no-restricted-globals: + - off + no-restricted-modules: + - off + no-restricted-syntax: + - off + no-sync: + - off + no-ternary: + - off + no-undef-init: + - off + no-undefined: + - off + no-underscore-dangle: + - off + no-warning-comments: + - off + operator-assignment: + - off + prefer-named-capture-group: + - off + prefer-object-spread: + - off + sort-keys: + - off + sort-vars: + - off + vars-on-top: + - off + eslint-comments/disable-enable-pair: + - error + eslint-comments/no-aggregating-enable: + - error + eslint-comments/no-duplicate-disable: + - error + eslint-comments/no-restricted-disable: + - off + eslint-comments/no-unlimited-disable: + - error + eslint-comments/no-unused-disable: + - error + eslint-comments/no-unused-enable: + - error + eslint-comments/no-use: + - error + - allow: + - eslint-disable + - eslint-disable-line + - eslint-disable-next-line + - eslint-enable + - eslint-env + - globals - files: "typings/**" rules: - node/no-missing-import: + node/no-missing-import: - error - - allowModules: - - estree + - allowModules: + - estree + - files: package.json + rules: + "@mysticatea/prettier": off +settings: + node: + tryExtensions: + - .ts + - .js + - .json diff --git a/.gitattributes b/.gitattributes index e561ec1e..fa8984c7 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,2 @@ -*.ts eol=lf +* text=auto eol=lf /test/fixtures/crlf.vue eol=crlf diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 00000000..ce763b1f --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,2 @@ +github: +- mysticatea diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml new file mode 100644 index 00000000..6e4c23bd --- /dev/null +++ b/.github/workflows/CI.yml @@ -0,0 +1,98 @@ +name: CI +on: + push: + branches: [master, try] + pull_request: + branches: [master] + schedule: + - cron: 0 0 * * 0 + +jobs: + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Checkout submodules + run: git submodule update --init + - name: Install Node.js + uses: actions/setup-node@v3 + with: + node-version: 16 + - name: Install Packages + run: npm install && cd test/fixtures/eslint && npm install + - name: Lint + run: npm run -s lint + + test: + name: Test + strategy: + matrix: + eslint: [7, 8] + node: [16, 17] + os: [ubuntu-latest] + include: + # On other platforms + - eslint: 7 + node: 16 + os: windows-latest + - eslint: 7 + node: 16 + os: macos-latest + # On old Node.js versions + - eslint: 7 + node: 14 + os: ubuntu-latest + # On old ESLint versions + - eslint: 6 + node: 16 + os: ubuntu-latest + # On the minimum supported ESLint/Node.js version + - eslint: 6 + node: 14 + os: ubuntu-latest + + runs-on: ${{ matrix.os }} + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Checkout submodules + run: git submodule update --init + - name: Install Node.js v${{ matrix.node }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node }} + - name: Install Packages + run: npm install --legacy-peer-deps + - 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 + + test-cov: + name: Test and Send Coverage + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Checkout submodules + run: git submodule update --init + - name: Install Node.js v16 + uses: actions/setup-node@v3 + with: + node-version: 16 + - name: Install Packages + run: npm install + - name: Install ESLint v8 + run: node scripts/ci-install-eslint 8.12.0 + - 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 }} diff --git a/.gitignore b/.gitignore index 80b13514..8bf60fc5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,10 @@ /.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 diff --git a/.nycrc b/.nycrc new file mode 100644 index 00000000..a31275f2 --- /dev/null +++ b/.nycrc @@ -0,0 +1,19 @@ +{ + "include": [ + "src/**/*.ts" + ], + "exclude": [ + "src/external/**/*.ts" + ], + "extension": [ + ".ts" + ], + "require": [ + "ts-node/register" + ], + "reporter": [ + "lcov", + "text-summary" + ], + "sourceMap": true +} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index e80c880e..00000000 --- a/.travis.yml +++ /dev/null @@ -1,13 +0,0 @@ -sudo: false - -language: node_js -node_js: - - "6.5" - - "8" - - "10" - -before_script: - - npm run setup - -after_success: - - npm run codecov diff --git a/.vscode/settings.json b/.vscode/settings.json index 0bcb47f3..72446f43 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,8 +1,3 @@ { - "eslint.validate": [ - "javascript", - {"language": "html", "autoFix": true}, - {"language": "vue", "autoFix": true}, - {"language": "typescript", "autoFix": true} - ] + "typescript.tsdk": "node_modules/typescript/lib" } diff --git a/README.md b/README.md index e7e7933c..dc7b2123 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,9 @@ [![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://travis-ci.org/mysticatea/vue-eslint-parser.svg?branch=master)](https://travis-ci.org/mysticatea/vue-eslint-parser) -[![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) +[![Coverage Status](https://codecov.io/gh/vuejs/vue-eslint-parser/branch/master/graph/badge.svg)](https://codecov.io/gh/vuejs/vue-eslint-parser) +[![Dependency Status](https://david-dm.org/vuejs/vue-eslint-parser.svg)](https://david-dm.org/vuejs/vue-eslint-parser) The ESLint custom parser for `.vue` files. @@ -15,13 +15,11 @@ This parser allows us to lint the ` diff --git a/test/fixtures/ast/directive-error-1/token-ranges.json b/test/fixtures/ast/directive-error-1/token-ranges.json new file mode 100644 index 00000000..2fad76ab --- /dev/null +++ b/test/fixtures/ast/directive-error-1/token-ranges.json @@ -0,0 +1,16 @@ +[ + "", + "\n ", + "", + "", + "\n", + "", + "\n" +] \ No newline at end of file diff --git a/test/fixtures/ast/directive-error-1/tree.json b/test/fixtures/ast/directive-error-1/tree.json new file mode 100644 index 00000000..7fffb24d --- /dev/null +++ b/test/fixtures/ast/directive-error-1/tree.json @@ -0,0 +1,67 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/ast/directive-error-2/ast.json b/test/fixtures/ast/directive-error-2/ast.json new file mode 100644 index 00000000..f59e6a92 --- /dev/null +++ b/test/fixtures/ast/directive-error-2/ast.json @@ -0,0 +1,517 @@ +{ + "type": "Program", + "start": 0, + "end": 0, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 0 + } + }, + "range": [ + 0, + 0 + ], + "body": [], + "sourceType": "script", + "comments": [], + "tokens": [], + "templateBody": { + "type": "VElement", + "range": [ + 0, + 43 + ], + "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, + 31 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "name": "div", + "rawName": "div", + "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": [ + { + "type": "VAttribute", + "range": [ + 20, + 24 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "directive": true, + "key": { + "type": "VDirectiveKey", + "range": [ + 20, + 24 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "name": { + "type": "VIdentifier", + "range": [ + 20, + 22 + ], + "loc": { + "start": { + "column": 9, + "line": 2 + }, + "end": { + "column": 11, + "line": 2 + } + }, + "name": "", + "rawName": "" + }, + "argument": null, + "modifiers": [ + { + "type": "VIdentifier", + "range": [ + 23, + 24 + ], + "loc": { + "start": { + "column": 12, + "line": 2 + }, + "end": { + "column": 13, + "line": 2 + } + }, + "name": "a", + "rawName": "a" + } + ] + }, + "value": null + } + ] + }, + "children": [], + "endTag": { + "type": "VEndTag", + "range": [ + 25, + 31 + ], + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 20 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 31, + 32 + ], + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 32, + 43 + ], + "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": "HTMLIdentifier", + "range": [ + 20, + 22 + ], + "loc": { + "start": { + "column": 9, + "line": 2 + }, + "end": { + "column": 11, + "line": 2 + } + }, + "value": "v-" + }, + { + "type": "Punctuator", + "range": [ + 22, + 23 + ], + "loc": { + "start": { + "column": 11, + "line": 2 + }, + "end": { + "column": 12, + "line": 2 + } + }, + "value": "." + }, + { + "type": "HTMLIdentifier", + "range": [ + 23, + 24 + ], + "loc": { + "start": { + "column": 12, + "line": 2 + }, + "end": { + "column": 13, + "line": 2 + } + }, + "value": "a" + }, + { + "type": "HTMLTagClose", + "range": [ + 24, + 25 + ], + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "value": "" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 25, + 30 + ], + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "value": "div" + }, + { + "type": "HTMLTagClose", + "range": [ + 30, + 31 + ], + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 31, + 32 + ], + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 32, + 42 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 42, + 43 + ], + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 43, + 44 + ], + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "value": "\n" + } + ], + "comments": [], + "errors": [ + { + "message": "Unexpected token '.'", + "index": 22, + "lineNumber": 2, + "column": 11 + } + ] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/directive-error-2/source.vue b/test/fixtures/ast/directive-error-2/source.vue new file mode 100644 index 00000000..8f52cc61 --- /dev/null +++ b/test/fixtures/ast/directive-error-2/source.vue @@ -0,0 +1,3 @@ + diff --git a/test/fixtures/ast/directive-error-2/token-ranges.json b/test/fixtures/ast/directive-error-2/token-ranges.json new file mode 100644 index 00000000..1f83196e --- /dev/null +++ b/test/fixtures/ast/directive-error-2/token-ranges.json @@ -0,0 +1,16 @@ +[ + "", + "\n ", + "", + "", + "\n", + "", + "\n" +] \ No newline at end of file diff --git a/test/fixtures/ast/directive-error-2/tree.json b/test/fixtures/ast/directive-error-2/tree.json new file mode 100644 index 00000000..64425516 --- /dev/null +++ b/test/fixtures/ast/directive-error-2/tree.json @@ -0,0 +1,67 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/ast/directive-error-3/ast.json b/test/fixtures/ast/directive-error-3/ast.json new file mode 100644 index 00000000..b7e95cc6 --- /dev/null +++ b/test/fixtures/ast/directive-error-3/ast.json @@ -0,0 +1,517 @@ +{ + "type": "Program", + "start": 0, + "end": 0, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 0 + } + }, + "range": [ + 0, + 0 + ], + "body": [], + "sourceType": "script", + "comments": [], + "tokens": [], + "templateBody": { + "type": "VElement", + "range": [ + 0, + 42 + ], + "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, + 30 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "name": "div", + "rawName": "div", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 15, + 24 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "selfClosing": false, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 20, + 23 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "directive": true, + "key": { + "type": "VDirectiveKey", + "range": [ + 20, + 23 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "name": { + "type": "VIdentifier", + "range": [ + 20, + 21 + ], + "loc": { + "start": { + "column": 9, + "line": 2 + }, + "end": { + "column": 10, + "line": 2 + } + }, + "name": "bind", + "rawName": ":" + }, + "argument": null, + "modifiers": [ + { + "type": "VIdentifier", + "range": [ + 22, + 23 + ], + "loc": { + "start": { + "column": 11, + "line": 2 + }, + "end": { + "column": 12, + "line": 2 + } + }, + "name": "a", + "rawName": "a" + } + ] + }, + "value": null + } + ] + }, + "children": [], + "endTag": { + "type": "VEndTag", + "range": [ + 24, + 30 + ], + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 19 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 30, + 31 + ], + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 31, + 42 + ], + "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": "Punctuator", + "range": [ + 20, + 21 + ], + "loc": { + "start": { + "column": 9, + "line": 2 + }, + "end": { + "column": 10, + "line": 2 + } + }, + "value": ":" + }, + { + "type": "Punctuator", + "range": [ + 21, + 22 + ], + "loc": { + "start": { + "column": 10, + "line": 2 + }, + "end": { + "column": 11, + "line": 2 + } + }, + "value": "." + }, + { + "type": "HTMLIdentifier", + "range": [ + 22, + 23 + ], + "loc": { + "start": { + "column": 11, + "line": 2 + }, + "end": { + "column": 12, + "line": 2 + } + }, + "value": "a" + }, + { + "type": "HTMLTagClose", + "range": [ + 23, + 24 + ], + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "value": "" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 24, + 29 + ], + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "value": "div" + }, + { + "type": "HTMLTagClose", + "range": [ + 29, + 30 + ], + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 30, + 31 + ], + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 31, + 41 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 41, + 42 + ], + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 42, + 43 + ], + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "value": "\n" + } + ], + "comments": [], + "errors": [ + { + "message": "Unexpected token '.'", + "index": 21, + "lineNumber": 2, + "column": 10 + } + ] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/directive-error-3/source.vue b/test/fixtures/ast/directive-error-3/source.vue new file mode 100644 index 00000000..5fc99f7e --- /dev/null +++ b/test/fixtures/ast/directive-error-3/source.vue @@ -0,0 +1,3 @@ + diff --git a/test/fixtures/ast/directive-error-3/token-ranges.json b/test/fixtures/ast/directive-error-3/token-ranges.json new file mode 100644 index 00000000..c93ea59a --- /dev/null +++ b/test/fixtures/ast/directive-error-3/token-ranges.json @@ -0,0 +1,16 @@ +[ + "", + "\n ", + "", + "", + "\n", + "", + "\n" +] \ No newline at end of file diff --git a/test/fixtures/ast/directive-error-3/tree.json b/test/fixtures/ast/directive-error-3/tree.json new file mode 100644 index 00000000..9ee91385 --- /dev/null +++ b/test/fixtures/ast/directive-error-3/tree.json @@ -0,0 +1,67 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/ast/directive-error-4/ast.json b/test/fixtures/ast/directive-error-4/ast.json new file mode 100644 index 00000000..3888d0db --- /dev/null +++ b/test/fixtures/ast/directive-error-4/ast.json @@ -0,0 +1,529 @@ +{ + "type": "Program", + "start": 0, + "end": 0, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 0 + } + }, + "range": [ + 0, + 0 + ], + "body": [], + "sourceType": "script", + "comments": [], + "tokens": [], + "templateBody": { + "type": "VElement", + "range": [ + 0, + 45 + ], + "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, + 33 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "name": "div", + "rawName": "div", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 15, + 27 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "selfClosing": false, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 20, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "directive": true, + "key": { + "type": "VDirectiveKey", + "range": [ + 20, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "name": { + "type": "VIdentifier", + "range": [ + 20, + 22 + ], + "loc": { + "start": { + "column": 9, + "line": 2 + }, + "end": { + "column": 11, + "line": 2 + } + }, + "name": "", + "rawName": "" + }, + "argument": null, + "modifiers": [ + { + "type": "VIdentifier", + "range": [ + 25, + 26 + ], + "loc": { + "start": { + "column": 14, + "line": 2 + }, + "end": { + "column": 15, + "line": 2 + } + }, + "name": "b", + "rawName": "b" + } + ] + }, + "value": null + } + ] + }, + "children": [], + "endTag": { + "type": "VEndTag", + "range": [ + 27, + 33 + ], + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 22 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 33, + 34 + ], + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 34, + 45 + ], + "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": "HTMLIdentifier", + "range": [ + 20, + 22 + ], + "loc": { + "start": { + "column": 9, + "line": 2 + }, + "end": { + "column": 11, + "line": 2 + } + }, + "value": "v-" + }, + { + "type": "Punctuator", + "range": [ + 22, + 25 + ], + "loc": { + "start": { + "column": 11, + "line": 2 + }, + "end": { + "column": 14, + "line": 2 + } + }, + "value": "." + }, + { + "type": "HTMLIdentifier", + "range": [ + 25, + 26 + ], + "loc": { + "start": { + "column": 14, + "line": 2 + }, + "end": { + "column": 15, + "line": 2 + } + }, + "value": "b" + }, + { + "type": "HTMLTagClose", + "range": [ + 26, + 27 + ], + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "value": "" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 27, + 32 + ], + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "value": "div" + }, + { + "type": "HTMLTagClose", + "range": [ + 32, + 33 + ], + "loc": { + "start": { + "line": 2, + "column": 21 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 33, + 34 + ], + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 34, + 44 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 44, + 45 + ], + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 45, + 46 + ], + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "value": "\n" + } + ], + "comments": [], + "errors": [ + { + "message": "Unexpected token ':'", + "index": 22, + "lineNumber": 2, + "column": 11 + }, + { + "message": "Unexpected token '.'", + "index": 23, + "lineNumber": 2, + "column": 12 + }, + { + "message": "Unexpected token '.'", + "index": 24, + "lineNumber": 2, + "column": 13 + } + ] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/directive-error-4/source.vue b/test/fixtures/ast/directive-error-4/source.vue new file mode 100644 index 00000000..5c69e57f --- /dev/null +++ b/test/fixtures/ast/directive-error-4/source.vue @@ -0,0 +1,3 @@ + diff --git a/test/fixtures/ast/directive-error-4/token-ranges.json b/test/fixtures/ast/directive-error-4/token-ranges.json new file mode 100644 index 00000000..907da872 --- /dev/null +++ b/test/fixtures/ast/directive-error-4/token-ranges.json @@ -0,0 +1,16 @@ +[ + "", + "\n ", + "", + "", + "\n", + "", + "\n" +] \ No newline at end of file diff --git a/test/fixtures/ast/directive-error-4/tree.json b/test/fixtures/ast/directive-error-4/tree.json new file mode 100644 index 00000000..b24c143a --- /dev/null +++ b/test/fixtures/ast/directive-error-4/tree.json @@ -0,0 +1,67 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/ast/directive-modifiers/ast.json b/test/fixtures/ast/directive-modifiers/ast.json index 4e1e4f30..3e8e9d73 100644 --- a/test/fixtures/ast/directive-modifiers/ast.json +++ b/test/fixtures/ast/directive-modifiers/ast.json @@ -147,19 +147,47 @@ "column": 14 } }, - "name": "a", + "name": { + "type": "VIdentifier", + "range": [ + 20, + 23 + ], + "loc": { + "start": { + "column": 9, + "line": 2 + }, + "end": { + "column": 12, + "line": 2 + } + }, + "name": "a", + "rawName": "a" + }, "argument": null, "modifiers": [ - "b" - ], - "shorthand": false, - "raw": { - "name": "a", - "argument": null, - "modifiers": [ - "b" - ] - } + { + "type": "VIdentifier", + "range": [ + 24, + 25 + ], + "loc": { + "start": { + "column": 13, + "line": 2 + }, + "end": { + "column": 14, + "line": 2 + } + }, + "name": "b", + "rawName": "b" + } + ] }, "value": null } @@ -273,19 +301,47 @@ "column": 14 } }, - "name": "a", + "name": { + "type": "VIdentifier", + "range": [ + 42, + 45 + ], + "loc": { + "start": { + "column": 9, + "line": 3 + }, + "end": { + "column": 12, + "line": 3 + } + }, + "name": "a", + "rawName": "a" + }, "argument": null, "modifiers": [ - "b" - ], - "shorthand": false, - "raw": { - "name": "a", - "argument": null, - "modifiers": [ - "b" - ] - } + { + "type": "VIdentifier", + "range": [ + 46, + 47 + ], + "loc": { + "start": { + "column": 13, + "line": 3 + }, + "end": { + "column": 14, + "line": 3 + } + }, + "name": "b", + "rawName": "b" + } + ] }, "value": { "type": "VExpressionContainer", @@ -460,21 +516,66 @@ "column": 16 } }, - "name": "a", + "name": { + "type": "VIdentifier", + "range": [ + 66, + 69 + ], + "loc": { + "start": { + "column": 9, + "line": 4 + }, + "end": { + "column": 12, + "line": 4 + } + }, + "name": "a", + "rawName": "a" + }, "argument": null, "modifiers": [ - "b", - "c" - ], - "shorthand": false, - "raw": { - "name": "a", - "argument": null, - "modifiers": [ - "b", - "c" - ] - } + { + "type": "VIdentifier", + "range": [ + 70, + 71 + ], + "loc": { + "start": { + "column": 13, + "line": 4 + }, + "end": { + "column": 14, + "line": 4 + } + }, + "name": "b", + "rawName": "b" + }, + { + "type": "VIdentifier", + "range": [ + 72, + 73 + ], + "loc": { + "start": { + "column": 15, + "line": 4 + }, + "end": { + "column": 16, + "line": 4 + } + }, + "name": "c", + "rawName": "c" + } + ] }, "value": { "type": "VExpressionContainer", @@ -675,19 +776,55 @@ "type": "HTMLIdentifier", "range": [ 20, + 23 + ], + "loc": { + "start": { + "column": 9, + "line": 2 + }, + "end": { + "column": 12, + "line": 2 + } + }, + "value": "v-a" + }, + { + "type": "Punctuator", + "range": [ + 23, + 24 + ], + "loc": { + "start": { + "column": 12, + "line": 2 + }, + "end": { + "column": 13, + "line": 2 + } + }, + "value": "." + }, + { + "type": "HTMLIdentifier", + "range": [ + 24, 25 ], "loc": { "start": { - "line": 2, - "column": 9 + "column": 13, + "line": 2 }, "end": { - "line": 2, - "column": 14 + "column": 14, + "line": 2 } }, - "value": "v-a.b" + "value": "b" }, { "type": "HTMLTagClose", @@ -783,19 +920,55 @@ "type": "HTMLIdentifier", "range": [ 42, + 45 + ], + "loc": { + "start": { + "column": 9, + "line": 3 + }, + "end": { + "column": 12, + "line": 3 + } + }, + "value": "v-a" + }, + { + "type": "Punctuator", + "range": [ + 45, + 46 + ], + "loc": { + "start": { + "column": 12, + "line": 3 + }, + "end": { + "column": 13, + "line": 3 + } + }, + "value": "." + }, + { + "type": "HTMLIdentifier", + "range": [ + 46, 47 ], "loc": { "start": { - "line": 3, - "column": 9 + "column": 13, + "line": 3 }, "end": { - "line": 3, - "column": 14 + "column": 14, + "line": 3 } }, - "value": "v-a.b" + "value": "b" }, { "type": "HTMLAssociation", @@ -929,19 +1102,91 @@ "type": "HTMLIdentifier", "range": [ 66, + 69 + ], + "loc": { + "start": { + "column": 9, + "line": 4 + }, + "end": { + "column": 12, + "line": 4 + } + }, + "value": "v-a" + }, + { + "type": "Punctuator", + "range": [ + 69, + 70 + ], + "loc": { + "start": { + "column": 12, + "line": 4 + }, + "end": { + "column": 13, + "line": 4 + } + }, + "value": "." + }, + { + "type": "HTMLIdentifier", + "range": [ + 70, + 71 + ], + "loc": { + "start": { + "column": 13, + "line": 4 + }, + "end": { + "column": 14, + "line": 4 + } + }, + "value": "b" + }, + { + "type": "Punctuator", + "range": [ + 71, + 72 + ], + "loc": { + "start": { + "column": 14, + "line": 4 + }, + "end": { + "column": 15, + "line": 4 + } + }, + "value": "." + }, + { + "type": "HTMLIdentifier", + "range": [ + 72, 73 ], "loc": { "start": { - "line": 4, - "column": 9 + "column": 15, + "line": 4 }, "end": { - "line": 4, - "column": 16 + "column": 16, + "line": 4 } }, - "value": "v-a.b.c" + "value": "c" }, { "type": "HTMLAssociation", diff --git a/test/fixtures/ast/directive-modifiers/token-ranges.json b/test/fixtures/ast/directive-modifiers/token-ranges.json index 313a7554..5f7cac78 100644 --- a/test/fixtures/ast/directive-modifiers/token-ranges.json +++ b/test/fixtures/ast/directive-modifiers/token-ranges.json @@ -3,13 +3,17 @@ ">", "\n ", "", "", "\n ", "", @@ -17,7 +21,11 @@ ">", "\n ", "", diff --git a/test/fixtures/ast/directive-modifiers/tree.json b/test/fixtures/ast/directive-modifiers/tree.json index ffa17b91..fc5bd1b0 100644 --- a/test/fixtures/ast/directive-modifiers/tree.json +++ b/test/fixtures/ast/directive-modifiers/tree.json @@ -28,7 +28,18 @@ { "type": "VDirectiveKey", "text": "v-a.b", - "children": [] + "children": [ + { + "type": "VIdentifier", + "text": "v-a", + "children": [] + }, + { + "type": "VIdentifier", + "text": "b", + "children": [] + } + ] } ] } @@ -61,7 +72,18 @@ { "type": "VDirectiveKey", "text": "v-a.b", - "children": [] + "children": [ + { + "type": "VIdentifier", + "text": "v-a", + "children": [] + }, + { + "type": "VIdentifier", + "text": "b", + "children": [] + } + ] }, { "type": "VExpressionContainer", @@ -105,7 +127,23 @@ { "type": "VDirectiveKey", "text": "v-a.b.c", - "children": [] + "children": [ + { + "type": "VIdentifier", + "text": "v-a", + "children": [] + }, + { + "type": "VIdentifier", + "text": "b", + "children": [] + }, + { + "type": "VIdentifier", + "text": "c", + "children": [] + } + ] }, { "type": "VExpressionContainer", diff --git a/test/fixtures/ast/directive-shorthands/ast.json b/test/fixtures/ast/directive-shorthands/ast.json index 673e3e74..546066ce 100644 --- a/test/fixtures/ast/directive-shorthands/ast.json +++ b/test/fixtures/ast/directive-shorthands/ast.json @@ -147,19 +147,65 @@ "column": 13 } }, - "name": "bind", - "argument": "a", - "modifiers": [ - "b" - ], - "shorthand": true, - "raw": { + "name": { + "type": "VIdentifier", + "range": [ + 20, + 21 + ], + "loc": { + "start": { + "column": 9, + "line": 2 + }, + "end": { + "column": 10, + "line": 2 + } + }, "name": "bind", - "argument": "a", - "modifiers": [ - "b" - ] - } + "rawName": ":" + }, + "argument": { + "type": "VIdentifier", + "range": [ + 21, + 22 + ], + "loc": { + "start": { + "column": 10, + "line": 2 + }, + "end": { + "column": 11, + "line": 2 + } + }, + "name": "a", + "rawName": "a" + }, + "modifiers": [ + { + "type": "VIdentifier", + "range": [ + 23, + 24 + ], + "loc": { + "start": { + "column": 12, + "line": 2 + }, + "end": { + "column": 13, + "line": 2 + } + }, + "name": "b", + "rawName": "b" + } + ] }, "value": null } @@ -273,19 +319,65 @@ "column": 13 } }, - "name": "on", - "argument": "a", - "modifiers": [ - "b" - ], - "shorthand": true, - "raw": { + "name": { + "type": "VIdentifier", + "range": [ + 41, + 42 + ], + "loc": { + "start": { + "column": 9, + "line": 3 + }, + "end": { + "column": 10, + "line": 3 + } + }, "name": "on", - "argument": "a", - "modifiers": [ - "b" - ] - } + "rawName": "@" + }, + "argument": { + "type": "VIdentifier", + "range": [ + 42, + 43 + ], + "loc": { + "start": { + "column": 10, + "line": 3 + }, + "end": { + "column": 11, + "line": 3 + } + }, + "name": "a", + "rawName": "a" + }, + "modifiers": [ + { + "type": "VIdentifier", + "range": [ + 44, + 45 + ], + "loc": { + "start": { + "column": 12, + "line": 3 + }, + "end": { + "column": 13, + "line": 3 + } + }, + "name": "b", + "rawName": "b" + } + ] }, "value": null } @@ -422,22 +514,76 @@ "value": "div" }, { - "type": "HTMLIdentifier", + "type": "Punctuator", "range": [ 20, + 21 + ], + "loc": { + "start": { + "column": 9, + "line": 2 + }, + "end": { + "column": 10, + "line": 2 + } + }, + "value": ":" + }, + { + "type": "HTMLIdentifier", + "range": [ + 21, + 22 + ], + "loc": { + "start": { + "column": 10, + "line": 2 + }, + "end": { + "column": 11, + "line": 2 + } + }, + "value": "a" + }, + { + "type": "Punctuator", + "range": [ + 22, + 23 + ], + "loc": { + "start": { + "column": 11, + "line": 2 + }, + "end": { + "column": 12, + "line": 2 + } + }, + "value": "." + }, + { + "type": "HTMLIdentifier", + "range": [ + 23, 24 ], "loc": { "start": { - "line": 2, - "column": 9 + "column": 12, + "line": 2 }, "end": { - "line": 2, - "column": 13 + "column": 13, + "line": 2 } }, - "value": ":a.b" + "value": "b" }, { "type": "HTMLTagClose", @@ -530,22 +676,76 @@ "value": "div" }, { - "type": "HTMLIdentifier", + "type": "Punctuator", "range": [ 41, + 42 + ], + "loc": { + "start": { + "column": 9, + "line": 3 + }, + "end": { + "column": 10, + "line": 3 + } + }, + "value": "@" + }, + { + "type": "HTMLIdentifier", + "range": [ + 42, + 43 + ], + "loc": { + "start": { + "column": 10, + "line": 3 + }, + "end": { + "column": 11, + "line": 3 + } + }, + "value": "a" + }, + { + "type": "Punctuator", + "range": [ + 43, + 44 + ], + "loc": { + "start": { + "column": 11, + "line": 3 + }, + "end": { + "column": 12, + "line": 3 + } + }, + "value": "." + }, + { + "type": "HTMLIdentifier", + "range": [ + 44, 45 ], "loc": { "start": { - "line": 3, - "column": 9 + "column": 12, + "line": 3 }, "end": { - "line": 3, - "column": 13 + "column": 13, + "line": 3 } }, - "value": "@a.b" + "value": "b" }, { "type": "HTMLTagClose", diff --git a/test/fixtures/ast/directive-shorthands/token-ranges.json b/test/fixtures/ast/directive-shorthands/token-ranges.json index cfd67b7a..bde8e8ea 100644 --- a/test/fixtures/ast/directive-shorthands/token-ranges.json +++ b/test/fixtures/ast/directive-shorthands/token-ranges.json @@ -3,13 +3,19 @@ ">", "\n ", "", "", "\n ", "", "", diff --git a/test/fixtures/ast/directive-shorthands/tree.json b/test/fixtures/ast/directive-shorthands/tree.json index ed65f607..a7e8083e 100644 --- a/test/fixtures/ast/directive-shorthands/tree.json +++ b/test/fixtures/ast/directive-shorthands/tree.json @@ -28,7 +28,23 @@ { "type": "VDirectiveKey", "text": ":a.b", - "children": [] + "children": [ + { + "type": "VIdentifier", + "text": ":", + "children": [] + }, + { + "type": "VIdentifier", + "text": "a", + "children": [] + }, + { + "type": "VIdentifier", + "text": "b", + "children": [] + } + ] } ] } @@ -61,7 +77,23 @@ { "type": "VDirectiveKey", "text": "@a.b", - "children": [] + "children": [ + { + "type": "VIdentifier", + "text": "@", + "children": [] + }, + { + "type": "VIdentifier", + "text": "a", + "children": [] + }, + { + "type": "VIdentifier", + "text": "b", + "children": [] + } + ] } ] } diff --git a/test/fixtures/ast/directives/ast.json b/test/fixtures/ast/directives/ast.json index bb7ac14e..b78d69a5 100644 --- a/test/fixtures/ast/directives/ast.json +++ b/test/fixtures/ast/directives/ast.json @@ -147,15 +147,27 @@ "column": 12 } }, - "name": "a", - "argument": null, - "modifiers": [], - "shorthand": false, - "raw": { + "name": { + "type": "VIdentifier", + "range": [ + 20, + 23 + ], + "loc": { + "start": { + "column": 9, + "line": 2 + }, + "end": { + "column": 12, + "line": 2 + } + }, "name": "a", - "argument": null, - "modifiers": [] - } + "rawName": "a" + }, + "argument": null, + "modifiers": [] }, "value": null } @@ -269,15 +281,27 @@ "column": 12 } }, - "name": "a", - "argument": null, - "modifiers": [], - "shorthand": false, - "raw": { + "name": { + "type": "VIdentifier", + "range": [ + 40, + 43 + ], + "loc": { + "start": { + "column": 9, + "line": 3 + }, + "end": { + "column": 12, + "line": 3 + } + }, "name": "a", - "argument": null, - "modifiers": [] - } + "rawName": "a" + }, + "argument": null, + "modifiers": [] }, "value": null } @@ -391,15 +415,27 @@ "column": 12 } }, - "name": "a", - "argument": null, - "modifiers": [], - "shorthand": false, - "raw": { + "name": { + "type": "VIdentifier", + "range": [ + 61, + 64 + ], + "loc": { + "start": { + "column": 9, + "line": 4 + }, + "end": { + "column": 12, + "line": 4 + } + }, "name": "a", - "argument": null, - "modifiers": [] - } + "rawName": "a" + }, + "argument": null, + "modifiers": [] }, "value": { "type": "VExpressionContainer", @@ -574,15 +610,27 @@ "column": 12 } }, - "name": "a", - "argument": null, - "modifiers": [], - "shorthand": false, - "raw": { + "name": { + "type": "VIdentifier", + "range": [ + 83, + 86 + ], + "loc": { + "start": { + "column": 9, + "line": 5 + }, + "end": { + "column": 12, + "line": 5 + } + }, "name": "a", - "argument": null, - "modifiers": [] - } + "rawName": "a" + }, + "argument": null, + "modifiers": [] }, "value": { "type": "VExpressionContainer", @@ -757,15 +805,27 @@ "column": 12 } }, - "name": "a", - "argument": null, - "modifiers": [], - "shorthand": false, - "raw": { + "name": { + "type": "VIdentifier", + "range": [ + 107, + 110 + ], + "loc": { + "start": { + "column": 9, + "line": 6 + }, + "end": { + "column": 12, + "line": 6 + } + }, "name": "a", - "argument": null, - "modifiers": [] - } + "rawName": "a" + }, + "argument": null, + "modifiers": [] }, "value": { "type": "VExpressionContainer", @@ -940,15 +1000,27 @@ "column": 12 } }, - "name": "a", - "argument": null, - "modifiers": [], - "shorthand": false, - "raw": { + "name": { + "type": "VIdentifier", + "range": [ + 131, + 134 + ], + "loc": { + "start": { + "column": 9, + "line": 7 + }, + "end": { + "column": 12, + "line": 7 + } + }, "name": "a", - "argument": null, - "modifiers": [] - } + "rawName": "a" + }, + "argument": null, + "modifiers": [] }, "value": { "type": "VExpressionContainer", @@ -1080,15 +1152,27 @@ "column": 12 } }, - "name": "a", - "argument": null, - "modifiers": [], - "shorthand": false, - "raw": { + "name": { + "type": "VIdentifier", + "range": [ + 154, + 157 + ], + "loc": { + "start": { + "column": 9, + "line": 8 + }, + "end": { + "column": 12, + "line": 8 + } + }, "name": "a", - "argument": null, - "modifiers": [] - } + "rawName": "a" + }, + "argument": null, + "modifiers": [] }, "value": { "type": "VExpressionContainer", @@ -1250,12 +1334,12 @@ ], "loc": { "start": { - "line": 2, - "column": 9 + "column": 9, + "line": 2 }, "end": { - "line": 2, - "column": 12 + "column": 12, + "line": 2 } }, "value": "v-a" @@ -1358,12 +1442,12 @@ ], "loc": { "start": { - "line": 3, - "column": 9 + "column": 9, + "line": 3 }, "end": { - "line": 3, - "column": 12 + "column": 12, + "line": 3 } }, "value": "v-a" @@ -1484,12 +1568,12 @@ ], "loc": { "start": { - "line": 4, - "column": 9 + "column": 9, + "line": 4 }, "end": { - "line": 4, - "column": 12 + "column": 12, + "line": 4 } }, "value": "v-a" @@ -1630,12 +1714,12 @@ ], "loc": { "start": { - "line": 5, - "column": 9 + "column": 9, + "line": 5 }, "end": { - "line": 5, - "column": 12 + "column": 12, + "line": 5 } }, "value": "v-a" @@ -1812,12 +1896,12 @@ ], "loc": { "start": { - "line": 6, - "column": 9 + "column": 9, + "line": 6 }, "end": { - "line": 6, - "column": 12 + "column": 12, + "line": 6 } }, "value": "v-a" @@ -1994,12 +2078,12 @@ ], "loc": { "start": { - "line": 7, - "column": 9 + "column": 9, + "line": 7 }, "end": { - "line": 7, - "column": 12 + "column": 12, + "line": 7 } }, "value": "v-a" @@ -2156,12 +2240,12 @@ ], "loc": { "start": { - "line": 8, - "column": 9 + "column": 9, + "line": 8 }, "end": { - "line": 8, - "column": 12 + "column": 12, + "line": 8 } }, "value": "v-a" diff --git a/test/fixtures/ast/directives/tree.json b/test/fixtures/ast/directives/tree.json index d0c9bf38..d4af3a86 100644 --- a/test/fixtures/ast/directives/tree.json +++ b/test/fixtures/ast/directives/tree.json @@ -28,7 +28,13 @@ { "type": "VDirectiveKey", "text": "v-a", - "children": [] + "children": [ + { + "type": "VIdentifier", + "text": "v-a", + "children": [] + } + ] } ] } @@ -61,7 +67,13 @@ { "type": "VDirectiveKey", "text": "v-a", - "children": [] + "children": [ + { + "type": "VIdentifier", + "text": "v-a", + "children": [] + } + ] } ] } @@ -94,7 +106,13 @@ { "type": "VDirectiveKey", "text": "v-a", - "children": [] + "children": [ + { + "type": "VIdentifier", + "text": "v-a", + "children": [] + } + ] }, { "type": "VExpressionContainer", @@ -138,7 +156,13 @@ { "type": "VDirectiveKey", "text": "v-a", - "children": [] + "children": [ + { + "type": "VIdentifier", + "text": "v-a", + "children": [] + } + ] }, { "type": "VExpressionContainer", @@ -182,7 +206,13 @@ { "type": "VDirectiveKey", "text": "v-a", - "children": [] + "children": [ + { + "type": "VIdentifier", + "text": "v-a", + "children": [] + } + ] }, { "type": "VExpressionContainer", @@ -226,7 +256,13 @@ { "type": "VDirectiveKey", "text": "v-a", - "children": [] + "children": [ + { + "type": "VIdentifier", + "text": "v-a", + "children": [] + } + ] }, { "type": "VExpressionContainer", @@ -264,7 +300,13 @@ { "type": "VDirectiveKey", "text": "v-a", - "children": [] + "children": [ + { + "type": "VIdentifier", + "text": "v-a", + "children": [] + } + ] }, { "type": "VExpressionContainer", diff --git a/test/fixtures/ast/dynamic-argument-dot/ast.json b/test/fixtures/ast/dynamic-argument-dot/ast.json new file mode 100644 index 00000000..6beacb73 --- /dev/null +++ b/test/fixtures/ast/dynamic-argument-dot/ast.json @@ -0,0 +1,787 @@ +{ + "type": "Program", + "start": 0, + "end": 0, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 0 + } + }, + "range": [ + 0, + 0 + ], + "body": [], + "sourceType": "script", + "comments": [], + "tokens": [], + "templateBody": { + "type": "VElement", + "range": [ + 0, + 62 + ], + "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, + 50 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 39 + } + }, + "name": "button", + "rawName": "button", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 15, + 41 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 30 + } + }, + "selfClosing": false, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 23, + 40 + ], + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 29 + } + }, + "directive": true, + "key": { + "type": "VDirectiveKey", + "range": [ + 23, + 34 + ], + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 23 + } + }, + "name": { + "type": "VIdentifier", + "range": [ + 23, + 24 + ], + "loc": { + "start": { + "column": 12, + "line": 2 + }, + "end": { + "column": 13, + "line": 2 + } + }, + "name": "bind", + "rawName": ":" + }, + "argument": { + "type": "VExpressionContainer", + "range": [ + 24, + 34 + ], + "loc": { + "start": { + "column": 13, + "line": 2 + }, + "end": { + "column": 23, + "line": 2 + } + }, + "expression": { + "type": "MemberExpression", + "start": 25, + "end": 33, + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "range": [ + 25, + 33 + ], + "object": { + "type": "Identifier", + "start": 25, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "range": [ + 25, + 28 + ], + "name": "obj" + }, + "property": { + "type": "Identifier", + "start": 29, + "end": 33, + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "range": [ + 29, + 33 + ], + "name": "prop" + }, + "computed": false, + "optional": false + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 25, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "range": [ + 25, + 28 + ], + "name": "obj" + }, + "mode": "r" + } + ] + }, + "modifiers": [] + }, + "value": { + "type": "VExpressionContainer", + "range": [ + 35, + 40 + ], + "loc": { + "start": { + "line": 2, + "column": 24 + }, + "end": { + "line": 2, + "column": 29 + } + }, + "expression": { + "type": "Identifier", + "start": 36, + "end": 39, + "loc": { + "start": { + "line": 2, + "column": 25 + }, + "end": { + "line": 2, + "column": 28 + } + }, + "range": [ + 36, + 39 + ], + "name": "foo" + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 36, + "end": 39, + "loc": { + "start": { + "line": 2, + "column": 25 + }, + "end": { + "line": 2, + "column": 28 + } + }, + "range": [ + 36, + 39 + ], + "name": "foo" + }, + "mode": "r" + } + ] + } + } + ] + }, + "children": [], + "endTag": { + "type": "VEndTag", + "range": [ + 41, + 50 + ], + "loc": { + "start": { + "line": 2, + "column": 30 + }, + "end": { + "line": 2, + "column": 39 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 50, + 51 + ], + "loc": { + "start": { + "line": 2, + "column": 39 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 51, + 62 + ], + "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, + 22 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "value": "button" + }, + { + "type": "Punctuator", + "range": [ + 23, + 24 + ], + "loc": { + "start": { + "column": 12, + "line": 2 + }, + "end": { + "column": 13, + "line": 2 + } + }, + "value": ":" + }, + { + "type": "Punctuator", + "range": [ + 24, + 25 + ], + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "value": "[" + }, + { + "type": "Identifier", + "value": "obj", + "start": 25, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "range": [ + 25, + 28 + ] + }, + { + "type": "Punctuator", + "value": ".", + "start": 28, + "end": 29, + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "range": [ + 28, + 29 + ] + }, + { + "type": "Identifier", + "value": "prop", + "start": 29, + "end": 33, + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "range": [ + 29, + 33 + ] + }, + { + "type": "Punctuator", + "range": [ + 33, + 34 + ], + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 2, + "column": 23 + } + }, + "value": "]" + }, + { + "type": "HTMLAssociation", + "range": [ + 34, + 35 + ], + "loc": { + "start": { + "line": 2, + "column": 23 + }, + "end": { + "line": 2, + "column": 24 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 35, + 36 + ], + "loc": { + "start": { + "line": 2, + "column": 24 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "value": "foo", + "start": 36, + "end": 39, + "loc": { + "start": { + "line": 2, + "column": 25 + }, + "end": { + "line": 2, + "column": 28 + } + }, + "range": [ + 36, + 39 + ] + }, + { + "type": "Punctuator", + "range": [ + 39, + 40 + ], + "loc": { + "start": { + "line": 2, + "column": 28 + }, + "end": { + "line": 2, + "column": 29 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 40, + 41 + ], + "loc": { + "start": { + "line": 2, + "column": 29 + }, + "end": { + "line": 2, + "column": 30 + } + }, + "value": "" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 41, + 49 + ], + "loc": { + "start": { + "line": 2, + "column": 30 + }, + "end": { + "line": 2, + "column": 38 + } + }, + "value": "button" + }, + { + "type": "HTMLTagClose", + "range": [ + 49, + 50 + ], + "loc": { + "start": { + "line": 2, + "column": 38 + }, + "end": { + "line": 2, + "column": 39 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 50, + 51 + ], + "loc": { + "start": { + "line": 2, + "column": 39 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 51, + 61 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 61, + 62 + ], + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 62, + 63 + ], + "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/dynamic-argument-dot/source.vue b/test/fixtures/ast/dynamic-argument-dot/source.vue new file mode 100644 index 00000000..d1ff60cc --- /dev/null +++ b/test/fixtures/ast/dynamic-argument-dot/source.vue @@ -0,0 +1,3 @@ + diff --git a/test/fixtures/ast/dynamic-argument-dot/token-ranges.json b/test/fixtures/ast/dynamic-argument-dot/token-ranges.json new file mode 100644 index 00000000..f69491e2 --- /dev/null +++ b/test/fixtures/ast/dynamic-argument-dot/token-ranges.json @@ -0,0 +1,23 @@ +[ + "", + "\n ", + "", + "", + "\n", + "", + "\n" +] \ No newline at end of file diff --git a/test/fixtures/ast/dynamic-argument-dot/tree.json b/test/fixtures/ast/dynamic-argument-dot/tree.json new file mode 100644 index 00000000..67360bb8 --- /dev/null +++ b/test/fixtures/ast/dynamic-argument-dot/tree.json @@ -0,0 +1,95 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/ast/dynamic-argument-error-1/ast.json b/test/fixtures/ast/dynamic-argument-error-1/ast.json new file mode 100644 index 00000000..6a8e5a06 --- /dev/null +++ b/test/fixtures/ast/dynamic-argument-error-1/ast.json @@ -0,0 +1,632 @@ +{ + "type": "Program", + "start": 0, + "end": 0, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 0 + } + }, + "range": [ + 0, + 0 + ], + "body": [], + "sourceType": "script", + "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": "button", + "rawName": "button", + "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": false, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 23, + 37 + ], + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 26 + } + }, + "directive": true, + "key": { + "type": "VDirectiveKey", + "range": [ + 23, + 31 + ], + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "name": { + "type": "VIdentifier", + "range": [ + 23, + 24 + ], + "loc": { + "start": { + "column": 12, + "line": 2 + }, + "end": { + "column": 13, + "line": 2 + } + }, + "name": "bind", + "rawName": ":" + }, + "argument": { + "type": "VExpressionContainer", + "range": [ + 24, + 31 + ], + "loc": { + "start": { + "column": 13, + "line": 2 + }, + "end": { + "column": 20, + "line": 2 + } + }, + "expression": null, + "references": [] + }, + "modifiers": [] + }, + "value": { + "type": "VExpressionContainer", + "range": [ + 32, + 37 + ], + "loc": { + "start": { + "line": 2, + "column": 21 + }, + "end": { + "line": 2, + "column": 26 + } + }, + "expression": { + "type": "Identifier", + "start": 33, + "end": 36, + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "range": [ + 33, + 36 + ], + "name": "foo" + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 33, + "end": 36, + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "range": [ + 33, + 36 + ], + "name": "foo" + }, + "mode": "r" + } + ] + } + } + ] + }, + "children": [], + "endTag": { + "type": "VEndTag", + "range": [ + 38, + 47 + ], + "loc": { + "start": { + "line": 2, + "column": 27 + }, + "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, + 22 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "value": "button" + }, + { + "type": "Punctuator", + "range": [ + 23, + 24 + ], + "loc": { + "start": { + "column": 12, + "line": 2 + }, + "end": { + "column": 13, + "line": 2 + } + }, + "value": ":" + }, + { + "type": "HTMLIdentifier", + "range": [ + 24, + 31 + ], + "loc": { + "start": { + "column": 13, + "line": 2 + }, + "end": { + "column": 20, + "line": 2 + } + }, + "value": "[key+!]" + }, + { + "type": "HTMLAssociation", + "range": [ + 31, + 32 + ], + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 32, + 33 + ], + "loc": { + "start": { + "line": 2, + "column": 21 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "value": "foo", + "start": 33, + "end": 36, + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "range": [ + 33, + 36 + ] + }, + { + "type": "Punctuator", + "range": [ + 36, + 37 + ], + "loc": { + "start": { + "line": 2, + "column": 25 + }, + "end": { + "line": 2, + "column": 26 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 37, + 38 + ], + "loc": { + "start": { + "line": 2, + "column": 26 + }, + "end": { + "line": 2, + "column": 27 + } + }, + "value": "" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 38, + 46 + ], + "loc": { + "start": { + "line": 2, + "column": 27 + }, + "end": { + "line": 2, + "column": 35 + } + }, + "value": "button" + }, + { + "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 end of expression.", + "index": 30, + "lineNumber": 2, + "column": 19 + } + ] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/dynamic-argument-error-1/source.vue b/test/fixtures/ast/dynamic-argument-error-1/source.vue new file mode 100644 index 00000000..77bf3f04 --- /dev/null +++ b/test/fixtures/ast/dynamic-argument-error-1/source.vue @@ -0,0 +1,3 @@ + diff --git a/test/fixtures/ast/dynamic-argument-error-1/token-ranges.json b/test/fixtures/ast/dynamic-argument-error-1/token-ranges.json new file mode 100644 index 00000000..4c1d9d62 --- /dev/null +++ b/test/fixtures/ast/dynamic-argument-error-1/token-ranges.json @@ -0,0 +1,19 @@ +[ + "", + "\n ", + "", + "", + "\n", + "", + "\n" +] \ No newline at end of file diff --git a/test/fixtures/ast/dynamic-argument-error-1/tree.json b/test/fixtures/ast/dynamic-argument-error-1/tree.json new file mode 100644 index 00000000..e2856e9f --- /dev/null +++ b/test/fixtures/ast/dynamic-argument-error-1/tree.json @@ -0,0 +1,78 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/ast/dynamic-argument-error-2/ast.json b/test/fixtures/ast/dynamic-argument-error-2/ast.json new file mode 100644 index 00000000..a337e3c1 --- /dev/null +++ b/test/fixtures/ast/dynamic-argument-error-2/ast.json @@ -0,0 +1,674 @@ +{ + "type": "Program", + "start": 0, + "end": 0, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 0 + } + }, + "range": [ + 0, + 0 + ], + "body": [], + "sourceType": "script", + "comments": [], + "tokens": [], + "templateBody": { + "type": "VElement", + "range": [ + 0, + 64 + ], + "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, + 52 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 41 + } + }, + "name": "button", + "rawName": "button", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 15, + 43 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 32 + } + }, + "selfClosing": false, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 23, + 28 + ], + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "directive": true, + "key": { + "type": "VDirectiveKey", + "range": [ + 23, + 28 + ], + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "name": { + "type": "VIdentifier", + "range": [ + 23, + 24 + ], + "loc": { + "start": { + "column": 12, + "line": 2 + }, + "end": { + "column": 13, + "line": 2 + } + }, + "name": "bind", + "rawName": ":" + }, + "argument": { + "type": "VIdentifier", + "range": [ + 24, + 28 + ], + "loc": { + "start": { + "column": 13, + "line": 2 + }, + "end": { + "column": 17, + "line": 2 + } + }, + "name": "[\"a\"", + "rawName": "[\"a\"" + }, + "modifiers": [] + }, + "value": null + }, + { + "type": "VAttribute", + "range": [ + 29, + 30 + ], + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "directive": false, + "key": { + "type": "VIdentifier", + "range": [ + 29, + 30 + ], + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "name": "+", + "rawName": "+" + }, + "value": null + }, + { + "type": "VAttribute", + "range": [ + 31, + 42 + ], + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 31 + } + }, + "directive": false, + "key": { + "type": "VIdentifier", + "range": [ + 31, + 36 + ], + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "name": "name]", + "rawName": "name]" + }, + "value": { + "type": "VLiteral", + "range": [ + 37, + 42 + ], + "loc": { + "start": { + "line": 2, + "column": 26 + }, + "end": { + "line": 2, + "column": 31 + } + }, + "value": "foo" + } + } + ] + }, + "children": [], + "endTag": { + "type": "VEndTag", + "range": [ + 43, + 52 + ], + "loc": { + "start": { + "line": 2, + "column": 32 + }, + "end": { + "line": 2, + "column": 41 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 52, + 53 + ], + "loc": { + "start": { + "line": 2, + "column": 41 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 53, + 64 + ], + "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, + 22 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "value": "button" + }, + { + "type": "Punctuator", + "range": [ + 23, + 24 + ], + "loc": { + "start": { + "column": 12, + "line": 2 + }, + "end": { + "column": 13, + "line": 2 + } + }, + "value": ":" + }, + { + "type": "HTMLIdentifier", + "range": [ + 24, + 28 + ], + "loc": { + "start": { + "column": 13, + "line": 2 + }, + "end": { + "column": 17, + "line": 2 + } + }, + "value": "[\"a\"" + }, + { + "type": "HTMLIdentifier", + "range": [ + 29, + 30 + ], + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "value": "+" + }, + { + "type": "HTMLIdentifier", + "range": [ + 31, + 36 + ], + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "value": "name]" + }, + { + "type": "HTMLAssociation", + "range": [ + 36, + 37 + ], + "loc": { + "start": { + "line": 2, + "column": 25 + }, + "end": { + "line": 2, + "column": 26 + } + }, + "value": "" + }, + { + "type": "HTMLLiteral", + "range": [ + 37, + 42 + ], + "loc": { + "start": { + "line": 2, + "column": 26 + }, + "end": { + "line": 2, + "column": 31 + } + }, + "value": "foo" + }, + { + "type": "HTMLTagClose", + "range": [ + 42, + 43 + ], + "loc": { + "start": { + "line": 2, + "column": 31 + }, + "end": { + "line": 2, + "column": 32 + } + }, + "value": "" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 43, + 51 + ], + "loc": { + "start": { + "line": 2, + "column": 32 + }, + "end": { + "line": 2, + "column": 40 + } + }, + "value": "button" + }, + { + "type": "HTMLTagClose", + "range": [ + 51, + 52 + ], + "loc": { + "start": { + "line": 2, + "column": 40 + }, + "end": { + "line": 2, + "column": 41 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 52, + 53 + ], + "loc": { + "start": { + "line": 2, + "column": 41 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 53, + 63 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 63, + 64 + ], + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 64, + 65 + ], + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "value": "\n" + } + ], + "comments": [], + "errors": [ + { + "message": "unexpected-character-in-attribute-name", + "index": 25, + "lineNumber": 2, + "column": 14 + }, + { + "message": "unexpected-character-in-attribute-name", + "index": 27, + "lineNumber": 2, + "column": 16 + }, + { + "message": "Dynamic argument cannot contain the ' ' character.", + "index": 28, + "lineNumber": 2, + "column": 17 + } + ] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/dynamic-argument-error-2/source.vue b/test/fixtures/ast/dynamic-argument-error-2/source.vue new file mode 100644 index 00000000..9c712eba --- /dev/null +++ b/test/fixtures/ast/dynamic-argument-error-2/source.vue @@ -0,0 +1,3 @@ + diff --git a/test/fixtures/ast/dynamic-argument-error-2/token-ranges.json b/test/fixtures/ast/dynamic-argument-error-2/token-ranges.json new file mode 100644 index 00000000..08d20608 --- /dev/null +++ b/test/fixtures/ast/dynamic-argument-error-2/token-ranges.json @@ -0,0 +1,19 @@ +[ + "", + "\n ", + "", + "", + "\n", + "", + "\n" +] \ No newline at end of file diff --git a/test/fixtures/ast/dynamic-argument-error-2/tree.json b/test/fixtures/ast/dynamic-argument-error-2/tree.json new file mode 100644 index 00000000..abef1aa5 --- /dev/null +++ b/test/fixtures/ast/dynamic-argument-error-2/tree.json @@ -0,0 +1,94 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/ast/dynamic-argument-error-4/ast.json b/test/fixtures/ast/dynamic-argument-error-4/ast.json new file mode 100644 index 00000000..a4b2104e --- /dev/null +++ b/test/fixtures/ast/dynamic-argument-error-4/ast.json @@ -0,0 +1,327 @@ +{ + "type": "Program", + "start": 0, + "end": 0, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 0 + } + }, + "range": [ + 0, + 0 + ], + "body": [], + "sourceType": "script", + "comments": [], + "tokens": [], + "templateBody": { + "type": "VElement", + "range": [ + 0, + 28 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "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, + 28 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "name": "button", + "rawName": "button", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 15, + 28 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "selfClosing": false, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 23, + 28 + ], + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "directive": true, + "key": { + "type": "VDirectiveKey", + "range": [ + 23, + 28 + ], + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "name": { + "type": "VIdentifier", + "range": [ + 23, + 24 + ], + "loc": { + "start": { + "column": 12, + "line": 2 + }, + "end": { + "column": 13, + "line": 2 + } + }, + "name": "bind", + "rawName": ":" + }, + "argument": { + "type": "VIdentifier", + "range": [ + 24, + 28 + ], + "loc": { + "start": { + "column": 13, + "line": 2 + }, + "end": { + "column": 17, + "line": 2 + } + }, + "name": "[obj", + "rawName": "[obj" + }, + "modifiers": [] + }, + "value": null + } + ] + }, + "children": [], + "endTag": null, + "variables": [] + } + ], + "endTag": null, + "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, + 22 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "value": "button" + }, + { + "type": "Punctuator", + "range": [ + 23, + 24 + ], + "loc": { + "start": { + "column": 12, + "line": 2 + }, + "end": { + "column": 13, + "line": 2 + } + }, + "value": ":" + }, + { + "type": "HTMLIdentifier", + "range": [ + 24, + 28 + ], + "loc": { + "start": { + "column": 13, + "line": 2 + }, + "end": { + "column": 17, + "line": 2 + } + }, + "value": "[obj" + } + ], + "comments": [], + "errors": [ + { + "message": "Dynamic argument cannot contain the '\\n' character.", + "index": 28, + "lineNumber": 2, + "column": 17 + }, + { + "message": "eof-in-tag", + "index": 29, + "lineNumber": 3, + "column": 0 + } + ] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/dynamic-argument-error-4/source.vue b/test/fixtures/ast/dynamic-argument-error-4/source.vue new file mode 100644 index 00000000..d859f01c --- /dev/null +++ b/test/fixtures/ast/dynamic-argument-error-4/source.vue @@ -0,0 +1,2 @@ + diff --git a/test/fixtures/ast/dynamic-argument-expr/token-ranges.json b/test/fixtures/ast/dynamic-argument-expr/token-ranges.json new file mode 100644 index 00000000..ac4ca1e5 --- /dev/null +++ b/test/fixtures/ast/dynamic-argument-expr/token-ranges.json @@ -0,0 +1,23 @@ +[ + "", + "\n ", + "", + "", + "\n", + "", + "\n" +] \ No newline at end of file diff --git a/test/fixtures/ast/dynamic-argument-expr/tree.json b/test/fixtures/ast/dynamic-argument-expr/tree.json new file mode 100644 index 00000000..0e6ce495 --- /dev/null +++ b/test/fixtures/ast/dynamic-argument-expr/tree.json @@ -0,0 +1,95 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/ast/dynamic-argument-v-bind/ast.json b/test/fixtures/ast/dynamic-argument-v-bind/ast.json new file mode 100644 index 00000000..1e9ff9af --- /dev/null +++ b/test/fixtures/ast/dynamic-argument-v-bind/ast.json @@ -0,0 +1,1768 @@ +{ + "type": "Program", + "start": 0, + "end": 0, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 0 + } + }, + "range": [ + 0, + 0 + ], + "body": [], + "sourceType": "script", + "comments": [], + "tokens": [], + "templateBody": { + "type": "VElement", + "range": [ + 0, + 139 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "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, + 51 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 40 + } + }, + "name": "button", + "rawName": "button", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 15, + 42 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 31 + } + }, + "selfClosing": false, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 23, + 41 + ], + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 30 + } + }, + "directive": true, + "key": { + "type": "VDirectiveKey", + "range": [ + 23, + 35 + ], + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 24 + } + }, + "name": { + "type": "VIdentifier", + "range": [ + 23, + 29 + ], + "loc": { + "start": { + "column": 12, + "line": 2 + }, + "end": { + "column": 18, + "line": 2 + } + }, + "name": "bind", + "rawName": "bind" + }, + "argument": { + "type": "VExpressionContainer", + "range": [ + 30, + 35 + ], + "loc": { + "start": { + "column": 19, + "line": 2 + }, + "end": { + "column": 24, + "line": 2 + } + }, + "expression": { + "type": "Identifier", + "start": 31, + "end": 34, + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 23 + } + }, + "range": [ + 31, + 34 + ], + "name": "key" + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 31, + "end": 34, + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 23 + } + }, + "range": [ + 31, + 34 + ], + "name": "key" + }, + "mode": "r" + } + ] + }, + "modifiers": [] + }, + "value": { + "type": "VExpressionContainer", + "range": [ + 36, + 41 + ], + "loc": { + "start": { + "line": 2, + "column": 25 + }, + "end": { + "line": 2, + "column": 30 + } + }, + "expression": { + "type": "Identifier", + "start": 37, + "end": 40, + "loc": { + "start": { + "line": 2, + "column": 26 + }, + "end": { + "line": 2, + "column": 29 + } + }, + "range": [ + 37, + 40 + ], + "name": "foo" + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 37, + "end": 40, + "loc": { + "start": { + "line": 2, + "column": 26 + }, + "end": { + "line": 2, + "column": 29 + } + }, + "range": [ + 37, + 40 + ], + "name": "foo" + }, + "mode": "r" + } + ] + } + } + ] + }, + "children": [], + "endTag": { + "type": "VEndTag", + "range": [ + 42, + 51 + ], + "loc": { + "start": { + "line": 2, + "column": 31 + }, + "end": { + "line": 2, + "column": 40 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 51, + 56 + ], + "loc": { + "start": { + "line": 2, + "column": 40 + }, + "end": { + "line": 3, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 56, + 86 + ], + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 34 + } + }, + "name": "button", + "rawName": "button", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 56, + 77 + ], + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 25 + } + }, + "selfClosing": false, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 64, + 76 + ], + "loc": { + "start": { + "line": 3, + "column": 12 + }, + "end": { + "line": 3, + "column": 24 + } + }, + "directive": true, + "key": { + "type": "VDirectiveKey", + "range": [ + 64, + 70 + ], + "loc": { + "start": { + "line": 3, + "column": 12 + }, + "end": { + "line": 3, + "column": 18 + } + }, + "name": { + "type": "VIdentifier", + "range": [ + 64, + 65 + ], + "loc": { + "start": { + "column": 12, + "line": 3 + }, + "end": { + "column": 13, + "line": 3 + } + }, + "name": "bind", + "rawName": ":" + }, + "argument": { + "type": "VExpressionContainer", + "range": [ + 65, + 70 + ], + "loc": { + "start": { + "column": 13, + "line": 3 + }, + "end": { + "column": 18, + "line": 3 + } + }, + "expression": { + "type": "Identifier", + "start": 66, + "end": 69, + "loc": { + "start": { + "line": 3, + "column": 14 + }, + "end": { + "line": 3, + "column": 17 + } + }, + "range": [ + 66, + 69 + ], + "name": "key" + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 66, + "end": 69, + "loc": { + "start": { + "line": 3, + "column": 14 + }, + "end": { + "line": 3, + "column": 17 + } + }, + "range": [ + 66, + 69 + ], + "name": "key" + }, + "mode": "r" + } + ] + }, + "modifiers": [] + }, + "value": { + "type": "VExpressionContainer", + "range": [ + 71, + 76 + ], + "loc": { + "start": { + "line": 3, + "column": 19 + }, + "end": { + "line": 3, + "column": 24 + } + }, + "expression": { + "type": "Identifier", + "start": 72, + "end": 75, + "loc": { + "start": { + "line": 3, + "column": 20 + }, + "end": { + "line": 3, + "column": 23 + } + }, + "range": [ + 72, + 75 + ], + "name": "foo" + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 72, + "end": 75, + "loc": { + "start": { + "line": 3, + "column": 20 + }, + "end": { + "line": 3, + "column": 23 + } + }, + "range": [ + 72, + 75 + ], + "name": "foo" + }, + "mode": "r" + } + ] + } + } + ] + }, + "children": [], + "endTag": { + "type": "VEndTag", + "range": [ + 77, + 86 + ], + "loc": { + "start": { + "line": 3, + "column": 25 + }, + "end": { + "line": 3, + "column": 34 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 86, + 91 + ], + "loc": { + "start": { + "line": 3, + "column": 34 + }, + "end": { + "line": 4, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 91, + 127 + ], + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 40 + } + }, + "name": "button", + "rawName": "button", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 91, + 118 + ], + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 31 + } + }, + "selfClosing": false, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 99, + 117 + ], + "loc": { + "start": { + "line": 4, + "column": 12 + }, + "end": { + "line": 4, + "column": 30 + } + }, + "directive": true, + "key": { + "type": "VDirectiveKey", + "range": [ + 99, + 111 + ], + "loc": { + "start": { + "line": 4, + "column": 12 + }, + "end": { + "line": 4, + "column": 24 + } + }, + "name": { + "type": "VIdentifier", + "range": [ + 99, + 100 + ], + "loc": { + "start": { + "column": 12, + "line": 4 + }, + "end": { + "column": 13, + "line": 4 + } + }, + "name": "bind", + "rawName": ":" + }, + "argument": { + "type": "VExpressionContainer", + "range": [ + 100, + 105 + ], + "loc": { + "start": { + "column": 13, + "line": 4 + }, + "end": { + "column": 18, + "line": 4 + } + }, + "expression": { + "type": "Identifier", + "start": 101, + "end": 104, + "loc": { + "start": { + "line": 4, + "column": 14 + }, + "end": { + "line": 4, + "column": 17 + } + }, + "range": [ + 101, + 104 + ], + "name": "key" + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 101, + "end": 104, + "loc": { + "start": { + "line": 4, + "column": 14 + }, + "end": { + "line": 4, + "column": 17 + } + }, + "range": [ + 101, + 104 + ], + "name": "key" + }, + "mode": "r" + } + ] + }, + "modifiers": [ + { + "type": "VIdentifier", + "range": [ + 106, + 111 + ], + "loc": { + "start": { + "column": 19, + "line": 4 + }, + "end": { + "column": 24, + "line": 4 + } + }, + "name": "enter", + "rawName": "enter" + } + ] + }, + "value": { + "type": "VExpressionContainer", + "range": [ + 112, + 117 + ], + "loc": { + "start": { + "line": 4, + "column": 25 + }, + "end": { + "line": 4, + "column": 30 + } + }, + "expression": { + "type": "Identifier", + "start": 113, + "end": 116, + "loc": { + "start": { + "line": 4, + "column": 26 + }, + "end": { + "line": 4, + "column": 29 + } + }, + "range": [ + 113, + 116 + ], + "name": "foo" + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 113, + "end": 116, + "loc": { + "start": { + "line": 4, + "column": 26 + }, + "end": { + "line": 4, + "column": 29 + } + }, + "range": [ + 113, + 116 + ], + "name": "foo" + }, + "mode": "r" + } + ] + } + } + ] + }, + "children": [], + "endTag": { + "type": "VEndTag", + "range": [ + 118, + 127 + ], + "loc": { + "start": { + "line": 4, + "column": 31 + }, + "end": { + "line": 4, + "column": 40 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 127, + 128 + ], + "loc": { + "start": { + "line": 4, + "column": 40 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 128, + 139 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "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, + 22 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "value": "button" + }, + { + "type": "HTMLIdentifier", + "range": [ + 23, + 29 + ], + "loc": { + "start": { + "column": 12, + "line": 2 + }, + "end": { + "column": 18, + "line": 2 + } + }, + "value": "v-bind" + }, + { + "type": "Punctuator", + "range": [ + 29, + 30 + ], + "loc": { + "start": { + "column": 18, + "line": 2 + }, + "end": { + "column": 19, + "line": 2 + } + }, + "value": ":" + }, + { + "type": "Punctuator", + "range": [ + 30, + 31 + ], + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "value": "[" + }, + { + "type": "Identifier", + "value": "key", + "start": 31, + "end": 34, + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 23 + } + }, + "range": [ + 31, + 34 + ] + }, + { + "type": "Punctuator", + "range": [ + 34, + 35 + ], + "loc": { + "start": { + "line": 2, + "column": 23 + }, + "end": { + "line": 2, + "column": 24 + } + }, + "value": "]" + }, + { + "type": "HTMLAssociation", + "range": [ + 35, + 36 + ], + "loc": { + "start": { + "line": 2, + "column": 24 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 36, + 37 + ], + "loc": { + "start": { + "line": 2, + "column": 25 + }, + "end": { + "line": 2, + "column": 26 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "value": "foo", + "start": 37, + "end": 40, + "loc": { + "start": { + "line": 2, + "column": 26 + }, + "end": { + "line": 2, + "column": 29 + } + }, + "range": [ + 37, + 40 + ] + }, + { + "type": "Punctuator", + "range": [ + 40, + 41 + ], + "loc": { + "start": { + "line": 2, + "column": 29 + }, + "end": { + "line": 2, + "column": 30 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 41, + 42 + ], + "loc": { + "start": { + "line": 2, + "column": 30 + }, + "end": { + "line": 2, + "column": 31 + } + }, + "value": "" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 42, + 50 + ], + "loc": { + "start": { + "line": 2, + "column": 31 + }, + "end": { + "line": 2, + "column": 39 + } + }, + "value": "button" + }, + { + "type": "HTMLTagClose", + "range": [ + 50, + 51 + ], + "loc": { + "start": { + "line": 2, + "column": 39 + }, + "end": { + "line": 2, + "column": 40 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 51, + 56 + ], + "loc": { + "start": { + "line": 2, + "column": 40 + }, + "end": { + "line": 3, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 56, + 63 + ], + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "value": "button" + }, + { + "type": "Punctuator", + "range": [ + 64, + 65 + ], + "loc": { + "start": { + "column": 12, + "line": 3 + }, + "end": { + "column": 13, + "line": 3 + } + }, + "value": ":" + }, + { + "type": "Punctuator", + "range": [ + 65, + 66 + ], + "loc": { + "start": { + "line": 3, + "column": 13 + }, + "end": { + "line": 3, + "column": 14 + } + }, + "value": "[" + }, + { + "type": "Identifier", + "value": "key", + "start": 66, + "end": 69, + "loc": { + "start": { + "line": 3, + "column": 14 + }, + "end": { + "line": 3, + "column": 17 + } + }, + "range": [ + 66, + 69 + ] + }, + { + "type": "Punctuator", + "range": [ + 69, + 70 + ], + "loc": { + "start": { + "line": 3, + "column": 17 + }, + "end": { + "line": 3, + "column": 18 + } + }, + "value": "]" + }, + { + "type": "HTMLAssociation", + "range": [ + 70, + 71 + ], + "loc": { + "start": { + "line": 3, + "column": 18 + }, + "end": { + "line": 3, + "column": 19 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 71, + 72 + ], + "loc": { + "start": { + "line": 3, + "column": 19 + }, + "end": { + "line": 3, + "column": 20 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "value": "foo", + "start": 72, + "end": 75, + "loc": { + "start": { + "line": 3, + "column": 20 + }, + "end": { + "line": 3, + "column": 23 + } + }, + "range": [ + 72, + 75 + ] + }, + { + "type": "Punctuator", + "range": [ + 75, + 76 + ], + "loc": { + "start": { + "line": 3, + "column": 23 + }, + "end": { + "line": 3, + "column": 24 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 76, + 77 + ], + "loc": { + "start": { + "line": 3, + "column": 24 + }, + "end": { + "line": 3, + "column": 25 + } + }, + "value": "" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 77, + 85 + ], + "loc": { + "start": { + "line": 3, + "column": 25 + }, + "end": { + "line": 3, + "column": 33 + } + }, + "value": "button" + }, + { + "type": "HTMLTagClose", + "range": [ + 85, + 86 + ], + "loc": { + "start": { + "line": 3, + "column": 33 + }, + "end": { + "line": 3, + "column": 34 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 86, + 91 + ], + "loc": { + "start": { + "line": 3, + "column": 34 + }, + "end": { + "line": 4, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 91, + 98 + ], + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 11 + } + }, + "value": "button" + }, + { + "type": "Punctuator", + "range": [ + 99, + 100 + ], + "loc": { + "start": { + "column": 12, + "line": 4 + }, + "end": { + "column": 13, + "line": 4 + } + }, + "value": ":" + }, + { + "type": "Punctuator", + "range": [ + 100, + 101 + ], + "loc": { + "start": { + "line": 4, + "column": 13 + }, + "end": { + "line": 4, + "column": 14 + } + }, + "value": "[" + }, + { + "type": "Identifier", + "value": "key", + "start": 101, + "end": 104, + "loc": { + "start": { + "line": 4, + "column": 14 + }, + "end": { + "line": 4, + "column": 17 + } + }, + "range": [ + 101, + 104 + ] + }, + { + "type": "Punctuator", + "range": [ + 104, + 105 + ], + "loc": { + "start": { + "line": 4, + "column": 17 + }, + "end": { + "line": 4, + "column": 18 + } + }, + "value": "]" + }, + { + "type": "Punctuator", + "range": [ + 105, + 106 + ], + "loc": { + "start": { + "column": 18, + "line": 4 + }, + "end": { + "column": 19, + "line": 4 + } + }, + "value": "." + }, + { + "type": "HTMLIdentifier", + "range": [ + 106, + 111 + ], + "loc": { + "start": { + "column": 19, + "line": 4 + }, + "end": { + "column": 24, + "line": 4 + } + }, + "value": "enter" + }, + { + "type": "HTMLAssociation", + "range": [ + 111, + 112 + ], + "loc": { + "start": { + "line": 4, + "column": 24 + }, + "end": { + "line": 4, + "column": 25 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 112, + 113 + ], + "loc": { + "start": { + "line": 4, + "column": 25 + }, + "end": { + "line": 4, + "column": 26 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "value": "foo", + "start": 113, + "end": 116, + "loc": { + "start": { + "line": 4, + "column": 26 + }, + "end": { + "line": 4, + "column": 29 + } + }, + "range": [ + 113, + 116 + ] + }, + { + "type": "Punctuator", + "range": [ + 116, + 117 + ], + "loc": { + "start": { + "line": 4, + "column": 29 + }, + "end": { + "line": 4, + "column": 30 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 117, + 118 + ], + "loc": { + "start": { + "line": 4, + "column": 30 + }, + "end": { + "line": 4, + "column": 31 + } + }, + "value": "" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 118, + 126 + ], + "loc": { + "start": { + "line": 4, + "column": 31 + }, + "end": { + "line": 4, + "column": 39 + } + }, + "value": "button" + }, + { + "type": "HTMLTagClose", + "range": [ + 126, + 127 + ], + "loc": { + "start": { + "line": 4, + "column": 39 + }, + "end": { + "line": 4, + "column": 40 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 127, + 128 + ], + "loc": { + "start": { + "line": 4, + "column": 40 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 128, + 138 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 138, + 139 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 11 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 139, + 140 + ], + "loc": { + "start": { + "line": 5, + "column": 11 + }, + "end": { + "line": 6, + "column": 0 + } + }, + "value": "\n" + } + ], + "comments": [], + "errors": [] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/dynamic-argument-v-bind/source.vue b/test/fixtures/ast/dynamic-argument-v-bind/source.vue new file mode 100644 index 00000000..3531635f --- /dev/null +++ b/test/fixtures/ast/dynamic-argument-v-bind/source.vue @@ -0,0 +1,5 @@ + diff --git a/test/fixtures/ast/dynamic-argument-v-bind/token-ranges.json b/test/fixtures/ast/dynamic-argument-v-bind/token-ranges.json new file mode 100644 index 00000000..383676b0 --- /dev/null +++ b/test/fixtures/ast/dynamic-argument-v-bind/token-ranges.json @@ -0,0 +1,50 @@ +[ + "", + "\n ", + "", + "", + "\n ", + "", + "", + "\n ", + "", + "", + "\n", + "", + "\n" +] \ No newline at end of file diff --git a/test/fixtures/ast/dynamic-argument-v-bind/tree.json b/test/fixtures/ast/dynamic-argument-v-bind/tree.json new file mode 100644 index 00000000..61824b98 --- /dev/null +++ b/test/fixtures/ast/dynamic-argument-v-bind/tree.json @@ -0,0 +1,211 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/ast/dynamic-argument-v-on/ast.json b/test/fixtures/ast/dynamic-argument-v-on/ast.json new file mode 100644 index 00000000..c8c1873c --- /dev/null +++ b/test/fixtures/ast/dynamic-argument-v-on/ast.json @@ -0,0 +1,1768 @@ +{ + "type": "Program", + "start": 0, + "end": 0, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 0 + } + }, + "range": [ + 0, + 0 + ], + "body": [], + "sourceType": "script", + "comments": [], + "tokens": [], + "templateBody": { + "type": "VElement", + "range": [ + 0, + 137 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "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, + 49 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 38 + } + }, + "name": "button", + "rawName": "button", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 15, + 40 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 29 + } + }, + "selfClosing": false, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 23, + 39 + ], + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 28 + } + }, + "directive": true, + "key": { + "type": "VDirectiveKey", + "range": [ + 23, + 33 + ], + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "name": { + "type": "VIdentifier", + "range": [ + 23, + 27 + ], + "loc": { + "start": { + "column": 12, + "line": 2 + }, + "end": { + "column": 16, + "line": 2 + } + }, + "name": "on", + "rawName": "on" + }, + "argument": { + "type": "VExpressionContainer", + "range": [ + 28, + 33 + ], + "loc": { + "start": { + "column": 17, + "line": 2 + }, + "end": { + "column": 22, + "line": 2 + } + }, + "expression": { + "type": "Identifier", + "start": 29, + "end": 32, + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "range": [ + 29, + 32 + ], + "name": "key" + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 29, + "end": 32, + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "range": [ + 29, + 32 + ], + "name": "key" + }, + "mode": "r" + } + ] + }, + "modifiers": [] + }, + "value": { + "type": "VExpressionContainer", + "range": [ + 34, + 39 + ], + "loc": { + "start": { + "line": 2, + "column": 23 + }, + "end": { + "line": 2, + "column": 28 + } + }, + "expression": { + "type": "Identifier", + "start": 35, + "end": 38, + "loc": { + "start": { + "line": 2, + "column": 24 + }, + "end": { + "line": 2, + "column": 27 + } + }, + "range": [ + 35, + 38 + ], + "name": "foo" + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 35, + "end": 38, + "loc": { + "start": { + "line": 2, + "column": 24 + }, + "end": { + "line": 2, + "column": 27 + } + }, + "range": [ + 35, + 38 + ], + "name": "foo" + }, + "mode": "r" + } + ] + } + } + ] + }, + "children": [], + "endTag": { + "type": "VEndTag", + "range": [ + 40, + 49 + ], + "loc": { + "start": { + "line": 2, + "column": 29 + }, + "end": { + "line": 2, + "column": 38 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 49, + 54 + ], + "loc": { + "start": { + "line": 2, + "column": 38 + }, + "end": { + "line": 3, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 54, + 84 + ], + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 34 + } + }, + "name": "button", + "rawName": "button", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 54, + 75 + ], + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 25 + } + }, + "selfClosing": false, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 62, + 74 + ], + "loc": { + "start": { + "line": 3, + "column": 12 + }, + "end": { + "line": 3, + "column": 24 + } + }, + "directive": true, + "key": { + "type": "VDirectiveKey", + "range": [ + 62, + 68 + ], + "loc": { + "start": { + "line": 3, + "column": 12 + }, + "end": { + "line": 3, + "column": 18 + } + }, + "name": { + "type": "VIdentifier", + "range": [ + 62, + 63 + ], + "loc": { + "start": { + "column": 12, + "line": 3 + }, + "end": { + "column": 13, + "line": 3 + } + }, + "name": "on", + "rawName": "@" + }, + "argument": { + "type": "VExpressionContainer", + "range": [ + 63, + 68 + ], + "loc": { + "start": { + "column": 13, + "line": 3 + }, + "end": { + "column": 18, + "line": 3 + } + }, + "expression": { + "type": "Identifier", + "start": 64, + "end": 67, + "loc": { + "start": { + "line": 3, + "column": 14 + }, + "end": { + "line": 3, + "column": 17 + } + }, + "range": [ + 64, + 67 + ], + "name": "key" + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 64, + "end": 67, + "loc": { + "start": { + "line": 3, + "column": 14 + }, + "end": { + "line": 3, + "column": 17 + } + }, + "range": [ + 64, + 67 + ], + "name": "key" + }, + "mode": "r" + } + ] + }, + "modifiers": [] + }, + "value": { + "type": "VExpressionContainer", + "range": [ + 69, + 74 + ], + "loc": { + "start": { + "line": 3, + "column": 19 + }, + "end": { + "line": 3, + "column": 24 + } + }, + "expression": { + "type": "Identifier", + "start": 70, + "end": 73, + "loc": { + "start": { + "line": 3, + "column": 20 + }, + "end": { + "line": 3, + "column": 23 + } + }, + "range": [ + 70, + 73 + ], + "name": "foo" + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 70, + "end": 73, + "loc": { + "start": { + "line": 3, + "column": 20 + }, + "end": { + "line": 3, + "column": 23 + } + }, + "range": [ + 70, + 73 + ], + "name": "foo" + }, + "mode": "r" + } + ] + } + } + ] + }, + "children": [], + "endTag": { + "type": "VEndTag", + "range": [ + 75, + 84 + ], + "loc": { + "start": { + "line": 3, + "column": 25 + }, + "end": { + "line": 3, + "column": 34 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 84, + 89 + ], + "loc": { + "start": { + "line": 3, + "column": 34 + }, + "end": { + "line": 4, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 89, + 125 + ], + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 40 + } + }, + "name": "button", + "rawName": "button", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 89, + 116 + ], + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 31 + } + }, + "selfClosing": false, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 97, + 115 + ], + "loc": { + "start": { + "line": 4, + "column": 12 + }, + "end": { + "line": 4, + "column": 30 + } + }, + "directive": true, + "key": { + "type": "VDirectiveKey", + "range": [ + 97, + 109 + ], + "loc": { + "start": { + "line": 4, + "column": 12 + }, + "end": { + "line": 4, + "column": 24 + } + }, + "name": { + "type": "VIdentifier", + "range": [ + 97, + 98 + ], + "loc": { + "start": { + "column": 12, + "line": 4 + }, + "end": { + "column": 13, + "line": 4 + } + }, + "name": "on", + "rawName": "@" + }, + "argument": { + "type": "VExpressionContainer", + "range": [ + 98, + 103 + ], + "loc": { + "start": { + "column": 13, + "line": 4 + }, + "end": { + "column": 18, + "line": 4 + } + }, + "expression": { + "type": "Identifier", + "start": 99, + "end": 102, + "loc": { + "start": { + "line": 4, + "column": 14 + }, + "end": { + "line": 4, + "column": 17 + } + }, + "range": [ + 99, + 102 + ], + "name": "key" + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 99, + "end": 102, + "loc": { + "start": { + "line": 4, + "column": 14 + }, + "end": { + "line": 4, + "column": 17 + } + }, + "range": [ + 99, + 102 + ], + "name": "key" + }, + "mode": "r" + } + ] + }, + "modifiers": [ + { + "type": "VIdentifier", + "range": [ + 104, + 109 + ], + "loc": { + "start": { + "column": 19, + "line": 4 + }, + "end": { + "column": 24, + "line": 4 + } + }, + "name": "enter", + "rawName": "enter" + } + ] + }, + "value": { + "type": "VExpressionContainer", + "range": [ + 110, + 115 + ], + "loc": { + "start": { + "line": 4, + "column": 25 + }, + "end": { + "line": 4, + "column": 30 + } + }, + "expression": { + "type": "Identifier", + "start": 111, + "end": 114, + "loc": { + "start": { + "line": 4, + "column": 26 + }, + "end": { + "line": 4, + "column": 29 + } + }, + "range": [ + 111, + 114 + ], + "name": "foo" + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 111, + "end": 114, + "loc": { + "start": { + "line": 4, + "column": 26 + }, + "end": { + "line": 4, + "column": 29 + } + }, + "range": [ + 111, + 114 + ], + "name": "foo" + }, + "mode": "r" + } + ] + } + } + ] + }, + "children": [], + "endTag": { + "type": "VEndTag", + "range": [ + 116, + 125 + ], + "loc": { + "start": { + "line": 4, + "column": 31 + }, + "end": { + "line": 4, + "column": 40 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 125, + 126 + ], + "loc": { + "start": { + "line": 4, + "column": 40 + }, + "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": "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, + 22 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "value": "button" + }, + { + "type": "HTMLIdentifier", + "range": [ + 23, + 27 + ], + "loc": { + "start": { + "column": 12, + "line": 2 + }, + "end": { + "column": 16, + "line": 2 + } + }, + "value": "v-on" + }, + { + "type": "Punctuator", + "range": [ + 27, + 28 + ], + "loc": { + "start": { + "column": 16, + "line": 2 + }, + "end": { + "column": 17, + "line": 2 + } + }, + "value": ":" + }, + { + "type": "Punctuator", + "range": [ + 28, + 29 + ], + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "value": "[" + }, + { + "type": "Identifier", + "value": "key", + "start": 29, + "end": 32, + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "range": [ + 29, + 32 + ] + }, + { + "type": "Punctuator", + "range": [ + 32, + 33 + ], + "loc": { + "start": { + "line": 2, + "column": 21 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "value": "]" + }, + { + "type": "HTMLAssociation", + "range": [ + 33, + 34 + ], + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 2, + "column": 23 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 34, + 35 + ], + "loc": { + "start": { + "line": 2, + "column": 23 + }, + "end": { + "line": 2, + "column": 24 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "value": "foo", + "start": 35, + "end": 38, + "loc": { + "start": { + "line": 2, + "column": 24 + }, + "end": { + "line": 2, + "column": 27 + } + }, + "range": [ + 35, + 38 + ] + }, + { + "type": "Punctuator", + "range": [ + 38, + 39 + ], + "loc": { + "start": { + "line": 2, + "column": 27 + }, + "end": { + "line": 2, + "column": 28 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 39, + 40 + ], + "loc": { + "start": { + "line": 2, + "column": 28 + }, + "end": { + "line": 2, + "column": 29 + } + }, + "value": "" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 40, + 48 + ], + "loc": { + "start": { + "line": 2, + "column": 29 + }, + "end": { + "line": 2, + "column": 37 + } + }, + "value": "button" + }, + { + "type": "HTMLTagClose", + "range": [ + 48, + 49 + ], + "loc": { + "start": { + "line": 2, + "column": 37 + }, + "end": { + "line": 2, + "column": 38 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 49, + 54 + ], + "loc": { + "start": { + "line": 2, + "column": 38 + }, + "end": { + "line": 3, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 54, + 61 + ], + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "value": "button" + }, + { + "type": "Punctuator", + "range": [ + 62, + 63 + ], + "loc": { + "start": { + "column": 12, + "line": 3 + }, + "end": { + "column": 13, + "line": 3 + } + }, + "value": "@" + }, + { + "type": "Punctuator", + "range": [ + 63, + 64 + ], + "loc": { + "start": { + "line": 3, + "column": 13 + }, + "end": { + "line": 3, + "column": 14 + } + }, + "value": "[" + }, + { + "type": "Identifier", + "value": "key", + "start": 64, + "end": 67, + "loc": { + "start": { + "line": 3, + "column": 14 + }, + "end": { + "line": 3, + "column": 17 + } + }, + "range": [ + 64, + 67 + ] + }, + { + "type": "Punctuator", + "range": [ + 67, + 68 + ], + "loc": { + "start": { + "line": 3, + "column": 17 + }, + "end": { + "line": 3, + "column": 18 + } + }, + "value": "]" + }, + { + "type": "HTMLAssociation", + "range": [ + 68, + 69 + ], + "loc": { + "start": { + "line": 3, + "column": 18 + }, + "end": { + "line": 3, + "column": 19 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 69, + 70 + ], + "loc": { + "start": { + "line": 3, + "column": 19 + }, + "end": { + "line": 3, + "column": 20 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "value": "foo", + "start": 70, + "end": 73, + "loc": { + "start": { + "line": 3, + "column": 20 + }, + "end": { + "line": 3, + "column": 23 + } + }, + "range": [ + 70, + 73 + ] + }, + { + "type": "Punctuator", + "range": [ + 73, + 74 + ], + "loc": { + "start": { + "line": 3, + "column": 23 + }, + "end": { + "line": 3, + "column": 24 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 74, + 75 + ], + "loc": { + "start": { + "line": 3, + "column": 24 + }, + "end": { + "line": 3, + "column": 25 + } + }, + "value": "" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 75, + 83 + ], + "loc": { + "start": { + "line": 3, + "column": 25 + }, + "end": { + "line": 3, + "column": 33 + } + }, + "value": "button" + }, + { + "type": "HTMLTagClose", + "range": [ + 83, + 84 + ], + "loc": { + "start": { + "line": 3, + "column": 33 + }, + "end": { + "line": 3, + "column": 34 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 84, + 89 + ], + "loc": { + "start": { + "line": 3, + "column": 34 + }, + "end": { + "line": 4, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 89, + 96 + ], + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 11 + } + }, + "value": "button" + }, + { + "type": "Punctuator", + "range": [ + 97, + 98 + ], + "loc": { + "start": { + "column": 12, + "line": 4 + }, + "end": { + "column": 13, + "line": 4 + } + }, + "value": "@" + }, + { + "type": "Punctuator", + "range": [ + 98, + 99 + ], + "loc": { + "start": { + "line": 4, + "column": 13 + }, + "end": { + "line": 4, + "column": 14 + } + }, + "value": "[" + }, + { + "type": "Identifier", + "value": "key", + "start": 99, + "end": 102, + "loc": { + "start": { + "line": 4, + "column": 14 + }, + "end": { + "line": 4, + "column": 17 + } + }, + "range": [ + 99, + 102 + ] + }, + { + "type": "Punctuator", + "range": [ + 102, + 103 + ], + "loc": { + "start": { + "line": 4, + "column": 17 + }, + "end": { + "line": 4, + "column": 18 + } + }, + "value": "]" + }, + { + "type": "Punctuator", + "range": [ + 103, + 104 + ], + "loc": { + "start": { + "column": 18, + "line": 4 + }, + "end": { + "column": 19, + "line": 4 + } + }, + "value": "." + }, + { + "type": "HTMLIdentifier", + "range": [ + 104, + 109 + ], + "loc": { + "start": { + "column": 19, + "line": 4 + }, + "end": { + "column": 24, + "line": 4 + } + }, + "value": "enter" + }, + { + "type": "HTMLAssociation", + "range": [ + 109, + 110 + ], + "loc": { + "start": { + "line": 4, + "column": 24 + }, + "end": { + "line": 4, + "column": 25 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 110, + 111 + ], + "loc": { + "start": { + "line": 4, + "column": 25 + }, + "end": { + "line": 4, + "column": 26 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "value": "foo", + "start": 111, + "end": 114, + "loc": { + "start": { + "line": 4, + "column": 26 + }, + "end": { + "line": 4, + "column": 29 + } + }, + "range": [ + 111, + 114 + ] + }, + { + "type": "Punctuator", + "range": [ + 114, + 115 + ], + "loc": { + "start": { + "line": 4, + "column": 29 + }, + "end": { + "line": 4, + "column": 30 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 115, + 116 + ], + "loc": { + "start": { + "line": 4, + "column": 30 + }, + "end": { + "line": 4, + "column": 31 + } + }, + "value": "" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 116, + 124 + ], + "loc": { + "start": { + "line": 4, + "column": 31 + }, + "end": { + "line": 4, + "column": 39 + } + }, + "value": "button" + }, + { + "type": "HTMLTagClose", + "range": [ + 124, + 125 + ], + "loc": { + "start": { + "line": 4, + "column": 39 + }, + "end": { + "line": 4, + "column": 40 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 125, + 126 + ], + "loc": { + "start": { + "line": 4, + "column": 40 + }, + "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" + } + ], + "comments": [], + "errors": [] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/dynamic-argument-v-on/source.vue b/test/fixtures/ast/dynamic-argument-v-on/source.vue new file mode 100644 index 00000000..33f9b698 --- /dev/null +++ b/test/fixtures/ast/dynamic-argument-v-on/source.vue @@ -0,0 +1,5 @@ + diff --git a/test/fixtures/ast/dynamic-argument-v-on/token-ranges.json b/test/fixtures/ast/dynamic-argument-v-on/token-ranges.json new file mode 100644 index 00000000..b4a70bf7 --- /dev/null +++ b/test/fixtures/ast/dynamic-argument-v-on/token-ranges.json @@ -0,0 +1,50 @@ +[ + "", + "\n ", + "", + "", + "\n ", + "", + "", + "\n ", + "", + "", + "\n", + "", + "\n" +] \ No newline at end of file diff --git a/test/fixtures/ast/dynamic-argument-v-on/tree.json b/test/fixtures/ast/dynamic-argument-v-on/tree.json new file mode 100644 index 00000000..7f0e919f --- /dev/null +++ b/test/fixtures/ast/dynamic-argument-v-on/tree.json @@ -0,0 +1,211 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/ast/dynamic-argument-v-slot/ast.json b/test/fixtures/ast/dynamic-argument-v-slot/ast.json new file mode 100644 index 00000000..d98a7503 --- /dev/null +++ b/test/fixtures/ast/dynamic-argument-v-slot/ast.json @@ -0,0 +1,1256 @@ +{ + "type": "Program", + "start": 0, + "end": 0, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 0 + } + }, + "range": [ + 0, + 0 + ], + "body": [], + "sourceType": "script", + "comments": [], + "tokens": [], + "templateBody": { + "type": "VElement", + "range": [ + 0, + 98 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "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, + 51 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 40 + } + }, + "name": "button", + "rawName": "button", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 15, + 42 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 31 + } + }, + "selfClosing": false, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 23, + 41 + ], + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 30 + } + }, + "directive": true, + "key": { + "type": "VDirectiveKey", + "range": [ + 23, + 35 + ], + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 24 + } + }, + "name": { + "type": "VIdentifier", + "range": [ + 23, + 29 + ], + "loc": { + "start": { + "column": 12, + "line": 2 + }, + "end": { + "column": 18, + "line": 2 + } + }, + "name": "slot", + "rawName": "slot" + }, + "argument": { + "type": "VExpressionContainer", + "range": [ + 30, + 35 + ], + "loc": { + "start": { + "column": 19, + "line": 2 + }, + "end": { + "column": 24, + "line": 2 + } + }, + "expression": { + "type": "Identifier", + "start": 31, + "end": 34, + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 23 + } + }, + "range": [ + 31, + 34 + ], + "name": "key" + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 31, + "end": 34, + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 23 + } + }, + "range": [ + 31, + 34 + ], + "name": "key" + }, + "mode": "r" + } + ] + }, + "modifiers": [] + }, + "value": { + "type": "VExpressionContainer", + "range": [ + 36, + 41 + ], + "loc": { + "start": { + "line": 2, + "column": 25 + }, + "end": { + "line": 2, + "column": 30 + } + }, + "expression": { + "type": "VSlotScopeExpression", + "range": [ + 37, + 40 + ], + "loc": { + "start": { + "line": 2, + "column": 26 + }, + "end": { + "line": 2, + "column": 29 + } + }, + "params": [ + { + "type": "Identifier", + "start": 37, + "end": 40, + "loc": { + "start": { + "line": 2, + "column": 26 + }, + "end": { + "line": 2, + "column": 29 + } + }, + "range": [ + 37, + 40 + ], + "name": "foo" + } + ] + }, + "references": [] + } + } + ] + }, + "children": [], + "endTag": { + "type": "VEndTag", + "range": [ + 42, + 51 + ], + "loc": { + "start": { + "line": 2, + "column": 31 + }, + "end": { + "line": 2, + "column": 40 + } + } + }, + "variables": [ + { + "id": { + "type": "Identifier", + "start": 37, + "end": 40, + "loc": { + "start": { + "line": 2, + "column": 26 + }, + "end": { + "line": 2, + "column": 29 + } + }, + "range": [ + 37, + 40 + ], + "name": "foo" + }, + "kind": "scope" + } + ] + }, + { + "type": "VText", + "range": [ + 51, + 56 + ], + "loc": { + "start": { + "line": 2, + "column": 40 + }, + "end": { + "line": 3, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 56, + 86 + ], + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 34 + } + }, + "name": "button", + "rawName": "button", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 56, + 77 + ], + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 25 + } + }, + "selfClosing": false, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 64, + 76 + ], + "loc": { + "start": { + "line": 3, + "column": 12 + }, + "end": { + "line": 3, + "column": 24 + } + }, + "directive": true, + "key": { + "type": "VDirectiveKey", + "range": [ + 64, + 70 + ], + "loc": { + "start": { + "line": 3, + "column": 12 + }, + "end": { + "line": 3, + "column": 18 + } + }, + "name": { + "type": "VIdentifier", + "range": [ + 64, + 65 + ], + "loc": { + "start": { + "column": 12, + "line": 3 + }, + "end": { + "column": 13, + "line": 3 + } + }, + "name": "slot", + "rawName": "#" + }, + "argument": { + "type": "VExpressionContainer", + "range": [ + 65, + 70 + ], + "loc": { + "start": { + "column": 13, + "line": 3 + }, + "end": { + "column": 18, + "line": 3 + } + }, + "expression": { + "type": "Identifier", + "start": 66, + "end": 69, + "loc": { + "start": { + "line": 3, + "column": 14 + }, + "end": { + "line": 3, + "column": 17 + } + }, + "range": [ + 66, + 69 + ], + "name": "key" + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 66, + "end": 69, + "loc": { + "start": { + "line": 3, + "column": 14 + }, + "end": { + "line": 3, + "column": 17 + } + }, + "range": [ + 66, + 69 + ], + "name": "key" + }, + "mode": "r" + } + ] + }, + "modifiers": [] + }, + "value": { + "type": "VExpressionContainer", + "range": [ + 71, + 76 + ], + "loc": { + "start": { + "line": 3, + "column": 19 + }, + "end": { + "line": 3, + "column": 24 + } + }, + "expression": { + "type": "VSlotScopeExpression", + "range": [ + 72, + 75 + ], + "loc": { + "start": { + "line": 3, + "column": 20 + }, + "end": { + "line": 3, + "column": 23 + } + }, + "params": [ + { + "type": "Identifier", + "start": 72, + "end": 75, + "loc": { + "start": { + "line": 3, + "column": 20 + }, + "end": { + "line": 3, + "column": 23 + } + }, + "range": [ + 72, + 75 + ], + "name": "foo" + } + ] + }, + "references": [] + } + } + ] + }, + "children": [], + "endTag": { + "type": "VEndTag", + "range": [ + 77, + 86 + ], + "loc": { + "start": { + "line": 3, + "column": 25 + }, + "end": { + "line": 3, + "column": 34 + } + } + }, + "variables": [ + { + "id": { + "type": "Identifier", + "start": 72, + "end": 75, + "loc": { + "start": { + "line": 3, + "column": 20 + }, + "end": { + "line": 3, + "column": 23 + } + }, + "range": [ + 72, + 75 + ], + "name": "foo" + }, + "kind": "scope" + } + ] + }, + { + "type": "VText", + "range": [ + 86, + 87 + ], + "loc": { + "start": { + "line": 3, + "column": 34 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 87, + 98 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "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, + 22 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "value": "button" + }, + { + "type": "HTMLIdentifier", + "range": [ + 23, + 29 + ], + "loc": { + "start": { + "column": 12, + "line": 2 + }, + "end": { + "column": 18, + "line": 2 + } + }, + "value": "v-slot" + }, + { + "type": "Punctuator", + "range": [ + 29, + 30 + ], + "loc": { + "start": { + "column": 18, + "line": 2 + }, + "end": { + "column": 19, + "line": 2 + } + }, + "value": ":" + }, + { + "type": "Punctuator", + "range": [ + 30, + 31 + ], + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "value": "[" + }, + { + "type": "Identifier", + "value": "key", + "start": 31, + "end": 34, + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 23 + } + }, + "range": [ + 31, + 34 + ] + }, + { + "type": "Punctuator", + "range": [ + 34, + 35 + ], + "loc": { + "start": { + "line": 2, + "column": 23 + }, + "end": { + "line": 2, + "column": 24 + } + }, + "value": "]" + }, + { + "type": "HTMLAssociation", + "range": [ + 35, + 36 + ], + "loc": { + "start": { + "line": 2, + "column": 24 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 36, + 37 + ], + "loc": { + "start": { + "line": 2, + "column": 25 + }, + "end": { + "line": 2, + "column": 26 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "value": "foo", + "start": 37, + "end": 40, + "loc": { + "start": { + "line": 2, + "column": 26 + }, + "end": { + "line": 2, + "column": 29 + } + }, + "range": [ + 37, + 40 + ] + }, + { + "type": "Punctuator", + "range": [ + 40, + 41 + ], + "loc": { + "start": { + "line": 2, + "column": 29 + }, + "end": { + "line": 2, + "column": 30 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 41, + 42 + ], + "loc": { + "start": { + "line": 2, + "column": 30 + }, + "end": { + "line": 2, + "column": 31 + } + }, + "value": "" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 42, + 50 + ], + "loc": { + "start": { + "line": 2, + "column": 31 + }, + "end": { + "line": 2, + "column": 39 + } + }, + "value": "button" + }, + { + "type": "HTMLTagClose", + "range": [ + 50, + 51 + ], + "loc": { + "start": { + "line": 2, + "column": 39 + }, + "end": { + "line": 2, + "column": 40 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 51, + 56 + ], + "loc": { + "start": { + "line": 2, + "column": 40 + }, + "end": { + "line": 3, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 56, + 63 + ], + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "value": "button" + }, + { + "type": "Punctuator", + "range": [ + 64, + 65 + ], + "loc": { + "start": { + "column": 12, + "line": 3 + }, + "end": { + "column": 13, + "line": 3 + } + }, + "value": "#" + }, + { + "type": "Punctuator", + "range": [ + 65, + 66 + ], + "loc": { + "start": { + "line": 3, + "column": 13 + }, + "end": { + "line": 3, + "column": 14 + } + }, + "value": "[" + }, + { + "type": "Identifier", + "value": "key", + "start": 66, + "end": 69, + "loc": { + "start": { + "line": 3, + "column": 14 + }, + "end": { + "line": 3, + "column": 17 + } + }, + "range": [ + 66, + 69 + ] + }, + { + "type": "Punctuator", + "range": [ + 69, + 70 + ], + "loc": { + "start": { + "line": 3, + "column": 17 + }, + "end": { + "line": 3, + "column": 18 + } + }, + "value": "]" + }, + { + "type": "HTMLAssociation", + "range": [ + 70, + 71 + ], + "loc": { + "start": { + "line": 3, + "column": 18 + }, + "end": { + "line": 3, + "column": 19 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 71, + 72 + ], + "loc": { + "start": { + "line": 3, + "column": 19 + }, + "end": { + "line": 3, + "column": 20 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "value": "foo", + "start": 72, + "end": 75, + "loc": { + "start": { + "line": 3, + "column": 20 + }, + "end": { + "line": 3, + "column": 23 + } + }, + "range": [ + 72, + 75 + ] + }, + { + "type": "Punctuator", + "range": [ + 75, + 76 + ], + "loc": { + "start": { + "line": 3, + "column": 23 + }, + "end": { + "line": 3, + "column": 24 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 76, + 77 + ], + "loc": { + "start": { + "line": 3, + "column": 24 + }, + "end": { + "line": 3, + "column": 25 + } + }, + "value": "" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 77, + 85 + ], + "loc": { + "start": { + "line": 3, + "column": 25 + }, + "end": { + "line": 3, + "column": 33 + } + }, + "value": "button" + }, + { + "type": "HTMLTagClose", + "range": [ + 85, + 86 + ], + "loc": { + "start": { + "line": 3, + "column": 33 + }, + "end": { + "line": 3, + "column": 34 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 86, + 87 + ], + "loc": { + "start": { + "line": 3, + "column": 34 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 87, + 97 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 97, + 98 + ], + "loc": { + "start": { + "line": 4, + "column": 10 + }, + "end": { + "line": 4, + "column": 11 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 98, + 99 + ], + "loc": { + "start": { + "line": 4, + "column": 11 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "value": "\n" + } + ], + "comments": [], + "errors": [] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/dynamic-argument-v-slot/source.vue b/test/fixtures/ast/dynamic-argument-v-slot/source.vue new file mode 100644 index 00000000..06630a3d --- /dev/null +++ b/test/fixtures/ast/dynamic-argument-v-slot/source.vue @@ -0,0 +1,4 @@ + diff --git a/test/fixtures/ast/dynamic-argument-v-slot/token-ranges.json b/test/fixtures/ast/dynamic-argument-v-slot/token-ranges.json new file mode 100644 index 00000000..48a2e3f2 --- /dev/null +++ b/test/fixtures/ast/dynamic-argument-v-slot/token-ranges.json @@ -0,0 +1,35 @@ +[ + "", + "\n ", + "", + "", + "\n ", + "", + "", + "\n", + "", + "\n" +] \ No newline at end of file diff --git a/test/fixtures/ast/dynamic-argument-v-slot/tree.json b/test/fixtures/ast/dynamic-argument-v-slot/tree.json new file mode 100644 index 00000000..1f9ddf04 --- /dev/null +++ b/test/fixtures/ast/dynamic-argument-v-slot/tree.json @@ -0,0 +1,157 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/ast/end-of-line01/ast.json b/test/fixtures/ast/end-of-line01/ast.json new file mode 100644 index 00000000..600e0aaf --- /dev/null +++ b/test/fixtures/ast/end-of-line01/ast.json @@ -0,0 +1,2803 @@ +{ + "type": "Program", + "start": 192, + "end": 203, + "loc": { + "start": { + "line": 16, + "column": 0 + }, + "end": { + "line": 16, + "column": 11 + } + }, + "range": [ + 192, + 203 + ], + "body": [ + { + "type": "VariableDeclaration", + "start": 192, + "end": 203, + "loc": { + "start": { + "line": 16, + "column": 0 + }, + "end": { + "line": 16, + "column": 11 + } + }, + "range": [ + 192, + 203 + ], + "declarations": [ + { + "type": "VariableDeclarator", + "start": 196, + "end": 203, + "loc": { + "start": { + "line": 16, + "column": 4 + }, + "end": { + "line": 16, + "column": 11 + } + }, + "range": [ + 196, + 203 + ], + "id": { + "type": "Identifier", + "start": 196, + "end": 197, + "loc": { + "start": { + "line": 16, + "column": 4 + }, + "end": { + "line": 16, + "column": 5 + } + }, + "range": [ + 196, + 197 + ], + "name": "a" + }, + "init": { + "type": "Identifier", + "start": 200, + "end": 203, + "loc": { + "start": { + "line": 16, + "column": 8 + }, + "end": { + "line": 16, + "column": 11 + } + }, + "range": [ + 200, + 203 + ], + "name": "foo" + } + } + ], + "kind": "var" + } + ], + "sourceType": "script", + "comments": [], + "tokens": [ + { + "type": "Punctuator", + "range": [ + 183, + 191 + ], + "loc": { + "start": { + "line": 15, + "column": 0 + }, + "end": { + "line": 15, + "column": 8 + } + }, + "value": "" + } + ], + "templateBody": { + "type": "VElement", + "range": [ + 0, + 182 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 14, + "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, + 44 + ], + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 4, + "column": 9 + } + }, + "name": "div", + "rawName": "div", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 13, + 38 + ], + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 4, + "column": 3 + } + }, + "selfClosing": false, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 22, + 34 + ], + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 16 + } + }, + "directive": true, + "key": { + "type": "VDirectiveKey", + "range": [ + 22, + 28 + ], + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 10 + } + }, + "name": { + "type": "VIdentifier", + "range": [ + 22, + 23 + ], + "loc": { + "start": { + "column": 4, + "line": 3 + }, + "end": { + "column": 5, + "line": 3 + } + }, + "name": "on", + "rawName": "@" + }, + "argument": { + "type": "VIdentifier", + "range": [ + 23, + 28 + ], + "loc": { + "start": { + "column": 5, + "line": 3 + }, + "end": { + "column": 10, + "line": 3 + } + }, + "name": "click", + "rawName": "click" + }, + "modifiers": [] + }, + "value": { + "type": "VExpressionContainer", + "range": [ + 29, + 34 + ], + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 3, + "column": 16 + } + }, + "expression": { + "type": "VOnExpression", + "range": [ + 30, + 33 + ], + "loc": { + "start": { + "line": 3, + "column": 12 + }, + "end": { + "line": 3, + "column": 15 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 30, + "end": 33, + "loc": { + "start": { + "line": 3, + "column": 12 + }, + "end": { + "line": 3, + "column": 15 + } + }, + "range": [ + 30, + 33 + ], + "expression": { + "type": "AssignmentExpression", + "start": 30, + "end": 33, + "loc": { + "start": { + "line": 3, + "column": 12 + }, + "end": { + "line": 3, + "column": 15 + } + }, + "range": [ + 30, + 33 + ], + "operator": "=", + "left": { + "type": "Identifier", + "start": 30, + "end": 31, + "loc": { + "start": { + "line": 3, + "column": 12 + }, + "end": { + "line": 3, + "column": 13 + } + }, + "range": [ + 30, + 31 + ], + "name": "a" + }, + "right": { + "type": "Identifier", + "start": 32, + "end": 33, + "loc": { + "start": { + "line": 3, + "column": 14 + }, + "end": { + "line": 3, + "column": 15 + } + }, + "range": [ + 32, + 33 + ], + "name": "b" + } + } + } + ] + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 30, + "end": 31, + "loc": { + "start": { + "line": 3, + "column": 12 + }, + "end": { + "line": 3, + "column": 13 + } + }, + "range": [ + 30, + 31 + ], + "name": "a" + }, + "mode": "w" + }, + { + "id": { + "type": "Identifier", + "start": 32, + "end": 33, + "loc": { + "start": { + "line": 3, + "column": 14 + }, + "end": { + "line": 3, + "column": 15 + } + }, + "range": [ + 32, + 33 + ], + "name": "b" + }, + "mode": "r" + } + ] + } + } + ] + }, + "children": [], + "endTag": { + "type": "VEndTag", + "range": [ + 38, + 44 + ], + "loc": { + "start": { + "line": 4, + "column": 3 + }, + "end": { + "line": 4, + "column": 9 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 44, + 47 + ], + "loc": { + "start": { + "line": 4, + "column": 9 + }, + "end": { + "line": 5, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 47, + 83 + ], + "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": [ + 47, + 77 + ], + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 7, + "column": 3 + } + }, + "selfClosing": false, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 56, + 73 + ], + "loc": { + "start": { + "line": 6, + "column": 4 + }, + "end": { + "line": 6, + "column": 21 + } + }, + "directive": true, + "key": { + "type": "VDirectiveKey", + "range": [ + 56, + 67 + ], + "loc": { + "start": { + "line": 6, + "column": 4 + }, + "end": { + "line": 6, + "column": 15 + } + }, + "name": { + "type": "VIdentifier", + "range": [ + 56, + 57 + ], + "loc": { + "start": { + "column": 4, + "line": 6 + }, + "end": { + "column": 5, + "line": 6 + } + }, + "name": "bind", + "rawName": ":" + }, + "argument": { + "type": "VIdentifier", + "range": [ + 57, + 67 + ], + "loc": { + "start": { + "column": 5, + "line": 6 + }, + "end": { + "column": 15, + "line": 6 + } + }, + "name": "data-click", + "rawName": "data-click" + }, + "modifiers": [] + }, + "value": { + "type": "VExpressionContainer", + "range": [ + 68, + 73 + ], + "loc": { + "start": { + "line": 6, + "column": 16 + }, + "end": { + "line": 6, + "column": 21 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 69, + "end": 72, + "loc": { + "start": { + "line": 6, + "column": 17 + }, + "end": { + "line": 6, + "column": 20 + } + }, + "range": [ + 69, + 72 + ], + "operator": "=", + "left": { + "type": "Identifier", + "start": 69, + "end": 70, + "loc": { + "start": { + "line": 6, + "column": 17 + }, + "end": { + "line": 6, + "column": 18 + } + }, + "range": [ + 69, + 70 + ], + "name": "a" + }, + "right": { + "type": "Identifier", + "start": 71, + "end": 72, + "loc": { + "start": { + "line": 6, + "column": 19 + }, + "end": { + "line": 6, + "column": 20 + } + }, + "range": [ + 71, + 72 + ], + "name": "b" + } + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 69, + "end": 70, + "loc": { + "start": { + "line": 6, + "column": 17 + }, + "end": { + "line": 6, + "column": 18 + } + }, + "range": [ + 69, + 70 + ], + "name": "a" + }, + "mode": "w" + }, + { + "id": { + "type": "Identifier", + "start": 71, + "end": 72, + "loc": { + "start": { + "line": 6, + "column": 19 + }, + "end": { + "line": 6, + "column": 20 + } + }, + "range": [ + 71, + 72 + ], + "name": "b" + }, + "mode": "r" + } + ] + } + } + ] + }, + "children": [], + "endTag": { + "type": "VEndTag", + "range": [ + 77, + 83 + ], + "loc": { + "start": { + "line": 7, + "column": 3 + }, + "end": { + "line": 7, + "column": 9 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 83, + 86 + ], + "loc": { + "start": { + "line": 7, + "column": 9 + }, + "end": { + "line": 8, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 86, + 129 + ], + "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": [ + 86, + 123 + ], + "loc": { + "start": { + "line": 8, + "column": 2 + }, + "end": { + "line": 10, + "column": 3 + } + }, + "selfClosing": false, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 95, + 119 + ], + "loc": { + "start": { + "line": 9, + "column": 4 + }, + "end": { + "line": 9, + "column": 28 + } + }, + "directive": true, + "key": { + "type": "VDirectiveKey", + "range": [ + 95, + 104 + ], + "loc": { + "start": { + "line": 9, + "column": 4 + }, + "end": { + "line": 9, + "column": 13 + } + }, + "name": { + "type": "VIdentifier", + "range": [ + 95, + 96 + ], + "loc": { + "start": { + "column": 4, + "line": 9 + }, + "end": { + "column": 5, + "line": 9 + } + }, + "name": "bind", + "rawName": ":" + }, + "argument": { + "type": "VIdentifier", + "range": [ + 96, + 104 + ], + "loc": { + "start": { + "column": 5, + "line": 9 + }, + "end": { + "column": 13, + "line": 9 + } + }, + "name": "data-foo", + "rawName": "data-foo" + }, + "modifiers": [] + }, + "value": { + "type": "VExpressionContainer", + "range": [ + 105, + 119 + ], + "loc": { + "start": { + "line": 9, + "column": 14 + }, + "end": { + "line": 9, + "column": 28 + } + }, + "expression": { + "type": "LogicalExpression", + "start": 106, + "end": 110, + "loc": { + "start": { + "line": 9, + "column": 15 + }, + "end": { + "line": 9, + "column": 27 + } + }, + "range": [ + 106, + 118 + ], + "left": { + "type": "Identifier", + "start": 106, + "end": 107, + "loc": { + "start": { + "line": 9, + "column": 15 + }, + "end": { + "line": 9, + "column": 16 + } + }, + "range": [ + 106, + 107 + ], + "name": "c" + }, + "operator": "&&", + "right": { + "type": "Identifier", + "start": 117, + "end": 118, + "loc": { + "start": { + "line": 9, + "column": 26 + }, + "end": { + "line": 9, + "column": 27 + } + }, + "range": [ + 117, + 118 + ], + "name": "d" + } + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 106, + "end": 107, + "loc": { + "start": { + "line": 9, + "column": 15 + }, + "end": { + "line": 9, + "column": 16 + } + }, + "range": [ + 106, + 107 + ], + "name": "c" + }, + "mode": "r" + }, + { + "id": { + "type": "Identifier", + "start": 117, + "end": 118, + "loc": { + "start": { + "line": 9, + "column": 26 + }, + "end": { + "line": 9, + "column": 27 + } + }, + "range": [ + 117, + 118 + ], + "name": "d" + }, + "mode": "r" + } + ] + } + } + ] + }, + "children": [], + "endTag": { + "type": "VEndTag", + "range": [ + 123, + 129 + ], + "loc": { + "start": { + "line": 10, + "column": 3 + }, + "end": { + "line": 10, + "column": 9 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 129, + 132 + ], + "loc": { + "start": { + "line": 10, + "column": 9 + }, + "end": { + "line": 11, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 132, + 170 + ], + "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": [ + 132, + 164 + ], + "loc": { + "start": { + "line": 11, + "column": 2 + }, + "end": { + "line": 13, + "column": 3 + } + }, + "selfClosing": false, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 141, + 160 + ], + "loc": { + "start": { + "line": 12, + "column": 4 + }, + "end": { + "line": 12, + "column": 23 + } + }, + "directive": true, + "key": { + "type": "VDirectiveKey", + "range": [ + 141, + 145 + ], + "loc": { + "start": { + "line": 12, + "column": 4 + }, + "end": { + "line": 12, + "column": 8 + } + }, + "name": { + "type": "VIdentifier", + "range": [ + 141, + 142 + ], + "loc": { + "start": { + "column": 4, + "line": 12 + }, + "end": { + "column": 5, + "line": 12 + } + }, + "name": "on", + "rawName": "@" + }, + "argument": { + "type": "VIdentifier", + "range": [ + 142, + 145 + ], + "loc": { + "start": { + "column": 5, + "line": 12 + }, + "end": { + "column": 8, + "line": 12 + } + }, + "name": "foo", + "rawName": "foo" + }, + "modifiers": [] + }, + "value": { + "type": "VExpressionContainer", + "range": [ + 146, + 160 + ], + "loc": { + "start": { + "line": 12, + "column": 9 + }, + "end": { + "line": 12, + "column": 23 + } + }, + "expression": { + "type": "VOnExpression", + "range": [ + 147, + 159 + ], + "loc": { + "start": { + "line": 12, + "column": 10 + }, + "end": { + "line": 12, + "column": 22 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 147, + "end": 151, + "loc": { + "start": { + "line": 12, + "column": 10 + }, + "end": { + "line": 12, + "column": 22 + } + }, + "range": [ + 147, + 159 + ], + "expression": { + "type": "LogicalExpression", + "start": 147, + "end": 151, + "loc": { + "start": { + "line": 12, + "column": 10 + }, + "end": { + "line": 12, + "column": 22 + } + }, + "range": [ + 147, + 159 + ], + "left": { + "type": "Identifier", + "start": 147, + "end": 148, + "loc": { + "start": { + "line": 12, + "column": 10 + }, + "end": { + "line": 12, + "column": 11 + } + }, + "range": [ + 147, + 148 + ], + "name": "c" + }, + "operator": "&&", + "right": { + "type": "Identifier", + "start": 158, + "end": 159, + "loc": { + "start": { + "line": 12, + "column": 21 + }, + "end": { + "line": 12, + "column": 22 + } + }, + "range": [ + 158, + 159 + ], + "name": "d" + } + } + } + ] + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 147, + "end": 148, + "loc": { + "start": { + "line": 12, + "column": 10 + }, + "end": { + "line": 12, + "column": 11 + } + }, + "range": [ + 147, + 148 + ], + "name": "c" + }, + "mode": "r" + }, + { + "id": { + "type": "Identifier", + "start": 158, + "end": 159, + "loc": { + "start": { + "line": 12, + "column": 21 + }, + "end": { + "line": 12, + "column": 22 + } + }, + "range": [ + 158, + 159 + ], + "name": "d" + }, + "mode": "r" + } + ] + } + } + ] + }, + "children": [], + "endTag": { + "type": "VEndTag", + "range": [ + 164, + 170 + ], + "loc": { + "start": { + "line": 13, + "column": 3 + }, + "end": { + "line": 13, + "column": 9 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 170, + 171 + ], + "loc": { + "start": { + "line": 13, + "column": 9 + }, + "end": { + "line": 14, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 171, + 182 + ], + "loc": { + "start": { + "line": 14, + "column": 0 + }, + "end": { + "line": 14, + "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": "Punctuator", + "range": [ + 22, + 23 + ], + "loc": { + "start": { + "column": 4, + "line": 3 + }, + "end": { + "column": 5, + "line": 3 + } + }, + "value": "@" + }, + { + "type": "HTMLIdentifier", + "range": [ + 23, + 28 + ], + "loc": { + "start": { + "column": 5, + "line": 3 + }, + "end": { + "column": 10, + "line": 3 + } + }, + "value": "click" + }, + { + "type": "HTMLAssociation", + "range": [ + 28, + 29 + ], + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 29, + 30 + ], + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 3, + "column": 12 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "value": "a", + "start": 30, + "end": 31, + "loc": { + "start": { + "line": 3, + "column": 12 + }, + "end": { + "line": 3, + "column": 13 + } + }, + "range": [ + 30, + 31 + ] + }, + { + "type": "Punctuator", + "value": "=", + "start": 31, + "end": 32, + "loc": { + "start": { + "line": 3, + "column": 13 + }, + "end": { + "line": 3, + "column": 14 + } + }, + "range": [ + 31, + 32 + ] + }, + { + "type": "Identifier", + "value": "b", + "start": 32, + "end": 33, + "loc": { + "start": { + "line": 3, + "column": 14 + }, + "end": { + "line": 3, + "column": 15 + } + }, + "range": [ + 32, + 33 + ] + }, + { + "type": "Punctuator", + "range": [ + 33, + 34 + ], + "loc": { + "start": { + "line": 3, + "column": 15 + }, + "end": { + "line": 3, + "column": 16 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 37, + 38 + ], + "loc": { + "start": { + "line": 4, + "column": 2 + }, + "end": { + "line": 4, + "column": 3 + } + }, + "value": "" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 38, + 43 + ], + "loc": { + "start": { + "line": 4, + "column": 3 + }, + "end": { + "line": 4, + "column": 8 + } + }, + "value": "div" + }, + { + "type": "HTMLTagClose", + "range": [ + 43, + 44 + ], + "loc": { + "start": { + "line": 4, + "column": 8 + }, + "end": { + "line": 4, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 44, + 47 + ], + "loc": { + "start": { + "line": 4, + "column": 9 + }, + "end": { + "line": 5, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 47, + 51 + ], + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 5, + "column": 6 + } + }, + "value": "div" + }, + { + "type": "Punctuator", + "range": [ + 56, + 57 + ], + "loc": { + "start": { + "column": 4, + "line": 6 + }, + "end": { + "column": 5, + "line": 6 + } + }, + "value": ":" + }, + { + "type": "HTMLIdentifier", + "range": [ + 57, + 67 + ], + "loc": { + "start": { + "column": 5, + "line": 6 + }, + "end": { + "column": 15, + "line": 6 + } + }, + "value": "data-click" + }, + { + "type": "HTMLAssociation", + "range": [ + 67, + 68 + ], + "loc": { + "start": { + "line": 6, + "column": 15 + }, + "end": { + "line": 6, + "column": 16 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 68, + 69 + ], + "loc": { + "start": { + "line": 6, + "column": 16 + }, + "end": { + "line": 6, + "column": 17 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "value": "a", + "start": 69, + "end": 70, + "loc": { + "start": { + "line": 6, + "column": 17 + }, + "end": { + "line": 6, + "column": 18 + } + }, + "range": [ + 69, + 70 + ] + }, + { + "type": "Punctuator", + "value": "=", + "start": 70, + "end": 71, + "loc": { + "start": { + "line": 6, + "column": 18 + }, + "end": { + "line": 6, + "column": 19 + } + }, + "range": [ + 70, + 71 + ] + }, + { + "type": "Identifier", + "value": "b", + "start": 71, + "end": 72, + "loc": { + "start": { + "line": 6, + "column": 19 + }, + "end": { + "line": 6, + "column": 20 + } + }, + "range": [ + 71, + 72 + ] + }, + { + "type": "Punctuator", + "range": [ + 72, + 73 + ], + "loc": { + "start": { + "line": 6, + "column": 20 + }, + "end": { + "line": 6, + "column": 21 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 76, + 77 + ], + "loc": { + "start": { + "line": 7, + "column": 2 + }, + "end": { + "line": 7, + "column": 3 + } + }, + "value": "" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 77, + 82 + ], + "loc": { + "start": { + "line": 7, + "column": 3 + }, + "end": { + "line": 7, + "column": 8 + } + }, + "value": "div" + }, + { + "type": "HTMLTagClose", + "range": [ + 82, + 83 + ], + "loc": { + "start": { + "line": 7, + "column": 8 + }, + "end": { + "line": 7, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 83, + 86 + ], + "loc": { + "start": { + "line": 7, + "column": 9 + }, + "end": { + "line": 8, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 86, + 90 + ], + "loc": { + "start": { + "line": 8, + "column": 2 + }, + "end": { + "line": 8, + "column": 6 + } + }, + "value": "div" + }, + { + "type": "Punctuator", + "range": [ + 95, + 96 + ], + "loc": { + "start": { + "column": 4, + "line": 9 + }, + "end": { + "column": 5, + "line": 9 + } + }, + "value": ":" + }, + { + "type": "HTMLIdentifier", + "range": [ + 96, + 104 + ], + "loc": { + "start": { + "column": 5, + "line": 9 + }, + "end": { + "column": 13, + "line": 9 + } + }, + "value": "data-foo" + }, + { + "type": "HTMLAssociation", + "range": [ + 104, + 105 + ], + "loc": { + "start": { + "line": 9, + "column": 13 + }, + "end": { + "line": 9, + "column": 14 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 105, + 106 + ], + "loc": { + "start": { + "line": 9, + "column": 14 + }, + "end": { + "line": 9, + "column": 15 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "value": "c", + "start": 106, + "end": 107, + "loc": { + "start": { + "line": 9, + "column": 15 + }, + "end": { + "line": 9, + "column": 16 + } + }, + "range": [ + 106, + 107 + ] + }, + { + "type": "Punctuator", + "value": "&&", + "start": 107, + "end": 109, + "loc": { + "start": { + "line": 9, + "column": 16 + }, + "end": { + "line": 9, + "column": 26 + } + }, + "range": [ + 107, + 117 + ] + }, + { + "type": "Identifier", + "value": "d", + "start": 117, + "end": 118, + "loc": { + "start": { + "line": 9, + "column": 26 + }, + "end": { + "line": 9, + "column": 27 + } + }, + "range": [ + 117, + 118 + ] + }, + { + "type": "Punctuator", + "range": [ + 118, + 119 + ], + "loc": { + "start": { + "line": 9, + "column": 27 + }, + "end": { + "line": 9, + "column": 28 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 122, + 123 + ], + "loc": { + "start": { + "line": 10, + "column": 2 + }, + "end": { + "line": 10, + "column": 3 + } + }, + "value": "" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 123, + 128 + ], + "loc": { + "start": { + "line": 10, + "column": 3 + }, + "end": { + "line": 10, + "column": 8 + } + }, + "value": "div" + }, + { + "type": "HTMLTagClose", + "range": [ + 128, + 129 + ], + "loc": { + "start": { + "line": 10, + "column": 8 + }, + "end": { + "line": 10, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 129, + 132 + ], + "loc": { + "start": { + "line": 10, + "column": 9 + }, + "end": { + "line": 11, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 132, + 136 + ], + "loc": { + "start": { + "line": 11, + "column": 2 + }, + "end": { + "line": 11, + "column": 6 + } + }, + "value": "div" + }, + { + "type": "Punctuator", + "range": [ + 141, + 142 + ], + "loc": { + "start": { + "column": 4, + "line": 12 + }, + "end": { + "column": 5, + "line": 12 + } + }, + "value": "@" + }, + { + "type": "HTMLIdentifier", + "range": [ + 142, + 145 + ], + "loc": { + "start": { + "column": 5, + "line": 12 + }, + "end": { + "column": 8, + "line": 12 + } + }, + "value": "foo" + }, + { + "type": "HTMLAssociation", + "range": [ + 145, + 146 + ], + "loc": { + "start": { + "line": 12, + "column": 8 + }, + "end": { + "line": 12, + "column": 9 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 146, + 147 + ], + "loc": { + "start": { + "line": 12, + "column": 9 + }, + "end": { + "line": 12, + "column": 10 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "value": "c", + "start": 147, + "end": 148, + "loc": { + "start": { + "line": 12, + "column": 10 + }, + "end": { + "line": 12, + "column": 11 + } + }, + "range": [ + 147, + 148 + ] + }, + { + "type": "Punctuator", + "value": "&&", + "start": 148, + "end": 150, + "loc": { + "start": { + "line": 12, + "column": 11 + }, + "end": { + "line": 12, + "column": 21 + } + }, + "range": [ + 148, + 158 + ] + }, + { + "type": "Identifier", + "value": "d", + "start": 158, + "end": 159, + "loc": { + "start": { + "line": 12, + "column": 21 + }, + "end": { + "line": 12, + "column": 22 + } + }, + "range": [ + 158, + 159 + ] + }, + { + "type": "Punctuator", + "range": [ + 159, + 160 + ], + "loc": { + "start": { + "line": 12, + "column": 22 + }, + "end": { + "line": 12, + "column": 23 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 163, + 164 + ], + "loc": { + "start": { + "line": 13, + "column": 2 + }, + "end": { + "line": 13, + "column": 3 + } + }, + "value": "" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 164, + 169 + ], + "loc": { + "start": { + "line": 13, + "column": 3 + }, + "end": { + "line": 13, + "column": 8 + } + }, + "value": "div" + }, + { + "type": "HTMLTagClose", + "range": [ + 169, + 170 + ], + "loc": { + "start": { + "line": 13, + "column": 8 + }, + "end": { + "line": 13, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 170, + 171 + ], + "loc": { + "start": { + "line": 13, + "column": 9 + }, + "end": { + "line": 14, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 171, + 181 + ], + "loc": { + "start": { + "line": 14, + "column": 0 + }, + "end": { + "line": 14, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 181, + 182 + ], + "loc": { + "start": { + "line": 14, + "column": 10 + }, + "end": { + "line": 14, + "column": 11 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 182, + 183 + ], + "loc": { + "start": { + "line": 14, + "column": 11 + }, + "end": { + "line": 15, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 183, + 190 + ], + "loc": { + "start": { + "line": 15, + "column": 0 + }, + "end": { + "line": 15, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 190, + 191 + ], + "loc": { + "start": { + "line": 15, + "column": 7 + }, + "end": { + "line": 15, + "column": 8 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 191, + 192 + ], + "loc": { + "start": { + "line": 15, + "column": 8 + }, + "end": { + "line": 16, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 192, + 195 + ], + "loc": { + "start": { + "line": 16, + "column": 0 + }, + "end": { + "line": 16, + "column": 3 + } + }, + "value": "var" + }, + { + "type": "HTMLWhitespace", + "range": [ + 195, + 196 + ], + "loc": { + "start": { + "line": 16, + "column": 3 + }, + "end": { + "line": 16, + "column": 4 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 196, + 197 + ], + "loc": { + "start": { + "line": 16, + "column": 4 + }, + "end": { + "line": 16, + "column": 5 + } + }, + "value": "a" + }, + { + "type": "HTMLWhitespace", + "range": [ + 197, + 198 + ], + "loc": { + "start": { + "line": 16, + "column": 5 + }, + "end": { + "line": 16, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 198, + 199 + ], + "loc": { + "start": { + "line": 16, + "column": 6 + }, + "end": { + "line": 16, + "column": 7 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 199, + 200 + ], + "loc": { + "start": { + "line": 16, + "column": 7 + }, + "end": { + "line": 16, + "column": 8 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 200, + 203 + ], + "loc": { + "start": { + "line": 16, + "column": 8 + }, + "end": { + "line": 16, + "column": 11 + } + }, + "value": "foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 203, + 204 + ], + "loc": { + "start": { + "line": 16, + "column": 11 + }, + "end": { + "line": 17, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 204, + 212 + ], + "loc": { + "start": { + "line": 17, + "column": 0 + }, + "end": { + "line": 17, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 212, + 213 + ], + "loc": { + "start": { + "line": 17, + "column": 8 + }, + "end": { + "line": 17, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 213, + 214 + ], + "loc": { + "start": { + "line": 17, + "column": 9 + }, + "end": { + "line": 18, + "column": 0 + } + }, + "value": "\n" + } + ], + "comments": [], + "errors": [] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/end-of-line01/requirements.json b/test/fixtures/ast/end-of-line01/requirements.json new file mode 100644 index 00000000..36659b1f --- /dev/null +++ b/test/fixtures/ast/end-of-line01/requirements.json @@ -0,0 +1,3 @@ +{ + "eslint": ">=8" +} \ No newline at end of file diff --git a/test/fixtures/ast/end-of-line01/source.vue b/test/fixtures/ast/end-of-line01/source.vue new file mode 100644 index 00000000..4f0ac53a --- /dev/null +++ b/test/fixtures/ast/end-of-line01/source.vue @@ -0,0 +1,17 @@ + + 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..a4a1bead --- /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": "script", + "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-message-empty/ast.json b/test/fixtures/ast/error-message-empty/ast.json index 30f96eb5..6f8a32e2 100644 --- a/test/fixtures/ast/error-message-empty/ast.json +++ b/test/fixtures/ast/error-message-empty/ast.json @@ -184,15 +184,45 @@ "column": 11 } }, - "name": "bind", - "argument": "a", - "modifiers": [], - "shorthand": true, - "raw": { + "name": { + "type": "VIdentifier", + "range": [ + 39, + 40 + ], + "loc": { + "start": { + "column": 9, + "line": 4 + }, + "end": { + "column": 10, + "line": 4 + } + }, "name": "bind", - "argument": "a", - "modifiers": [] - } + "rawName": ":" + }, + "argument": { + "type": "VIdentifier", + "range": [ + 40, + 41 + ], + "loc": { + "start": { + "column": 10, + "line": 4 + }, + "end": { + "column": 11, + "line": 4 + } + }, + "name": "a", + "rawName": "a" + }, + "modifiers": [] }, "value": { "type": "VExpressionContainer", @@ -324,15 +354,45 @@ "column": 11 } }, - "name": "bind", - "argument": "b", - "modifiers": [], - "shorthand": true, - "raw": { + "name": { + "type": "VIdentifier", + "range": [ + 61, + 62 + ], + "loc": { + "start": { + "column": 9, + "line": 5 + }, + "end": { + "column": 10, + "line": 5 + } + }, "name": "bind", - "argument": "b", - "modifiers": [] - } + "rawName": ":" + }, + "argument": { + "type": "VIdentifier", + "range": [ + 62, + 63 + ], + "loc": { + "start": { + "column": 10, + "line": 5 + }, + "end": { + "column": 11, + "line": 5 + } + }, + "name": "b", + "rawName": "b" + }, + "modifiers": [] }, "value": { "type": "VExpressionContainer", @@ -464,15 +524,45 @@ "column": 11 } }, - "name": "on", - "argument": "a", - "modifiers": [], - "shorthand": true, - "raw": { + "name": { + "type": "VIdentifier", + "range": [ + 84, + 85 + ], + "loc": { + "start": { + "column": 9, + "line": 6 + }, + "end": { + "column": 10, + "line": 6 + } + }, "name": "on", - "argument": "a", - "modifiers": [] - } + "rawName": "@" + }, + "argument": { + "type": "VIdentifier", + "range": [ + 85, + 86 + ], + "loc": { + "start": { + "column": 10, + "line": 6 + }, + "end": { + "column": 11, + "line": 6 + } + }, + "name": "a", + "rawName": "a" + }, + "modifiers": [] }, "value": { "type": "VExpressionContainer", @@ -604,15 +694,45 @@ "column": 11 } }, - "name": "on", - "argument": "b", - "modifiers": [], - "shorthand": true, - "raw": { + "name": { + "type": "VIdentifier", + "range": [ + 106, + 107 + ], + "loc": { + "start": { + "column": 9, + "line": 7 + }, + "end": { + "column": 10, + "line": 7 + } + }, "name": "on", - "argument": "b", - "modifiers": [] - } + "rawName": "@" + }, + "argument": { + "type": "VIdentifier", + "range": [ + 107, + 108 + ], + "loc": { + "start": { + "column": 10, + "line": 7 + }, + "end": { + "column": 11, + "line": 7 + } + }, + "name": "b", + "rawName": "b" + }, + "modifiers": [] }, "value": { "type": "VExpressionContainer", @@ -744,15 +864,27 @@ "column": 14 } }, - "name": "for", - "argument": null, - "modifiers": [], - "shorthand": false, - "raw": { + "name": { + "type": "VIdentifier", + "range": [ + 129, + 134 + ], + "loc": { + "start": { + "column": 9, + "line": 8 + }, + "end": { + "column": 14, + "line": 8 + } + }, "name": "for", - "argument": null, - "modifiers": [] - } + "rawName": "for" + }, + "argument": null, + "modifiers": [] }, "value": { "type": "VExpressionContainer", @@ -884,15 +1016,27 @@ "column": 14 } }, - "name": "for", - "argument": null, - "modifiers": [], - "shorthand": false, - "raw": { + "name": { + "type": "VIdentifier", + "range": [ + 154, + 159 + ], + "loc": { + "start": { + "column": 9, + "line": 9 + }, + "end": { + "column": 14, + "line": 9 + } + }, "name": "for", - "argument": null, - "modifiers": [] - } + "rawName": "for" + }, + "argument": null, + "modifiers": [] }, "value": { "type": "VExpressionContainer", @@ -1155,22 +1299,40 @@ "value": "div" }, { - "type": "HTMLIdentifier", + "type": "Punctuator", "range": [ 39, + 40 + ], + "loc": { + "start": { + "column": 9, + "line": 4 + }, + "end": { + "column": 10, + "line": 4 + } + }, + "value": ":" + }, + { + "type": "HTMLIdentifier", + "range": [ + 40, 41 ], "loc": { "start": { - "line": 4, - "column": 9 + "column": 10, + "line": 4 }, "end": { - "line": 4, - "column": 11 + "column": 11, + "line": 4 } }, - "value": ":a" + "value": "a" }, { "type": "HTMLAssociation", @@ -1317,22 +1479,40 @@ "value": "div" }, { - "type": "HTMLIdentifier", + "type": "Punctuator", "range": [ 61, + 62 + ], + "loc": { + "start": { + "column": 9, + "line": 5 + }, + "end": { + "column": 10, + "line": 5 + } + }, + "value": ":" + }, + { + "type": "HTMLIdentifier", + "range": [ + 62, 63 ], "loc": { "start": { - "line": 5, - "column": 9 + "column": 10, + "line": 5 }, "end": { - "line": 5, - "column": 11 + "column": 11, + "line": 5 } }, - "value": ":b" + "value": "b" }, { "type": "HTMLAssociation", @@ -1461,22 +1641,40 @@ "value": "div" }, { - "type": "HTMLIdentifier", + "type": "Punctuator", "range": [ 84, + 85 + ], + "loc": { + "start": { + "column": 9, + "line": 6 + }, + "end": { + "column": 10, + "line": 6 + } + }, + "value": "@" + }, + { + "type": "HTMLIdentifier", + "range": [ + 85, 86 ], "loc": { "start": { - "line": 6, - "column": 9 + "column": 10, + "line": 6 }, "end": { - "line": 6, - "column": 11 + "column": 11, + "line": 6 } }, - "value": "@a" + "value": "a" }, { "type": "HTMLAssociation", @@ -1623,22 +1821,40 @@ "value": "div" }, { - "type": "HTMLIdentifier", + "type": "Punctuator", "range": [ 106, + 107 + ], + "loc": { + "start": { + "column": 9, + "line": 7 + }, + "end": { + "column": 10, + "line": 7 + } + }, + "value": "@" + }, + { + "type": "HTMLIdentifier", + "range": [ + 107, 108 ], "loc": { "start": { - "line": 7, - "column": 9 + "column": 10, + "line": 7 }, "end": { - "line": 7, - "column": 11 + "column": 11, + "line": 7 } }, - "value": "@b" + "value": "b" }, { "type": "HTMLAssociation", @@ -1774,12 +1990,12 @@ ], "loc": { "start": { - "line": 8, - "column": 9 + "column": 9, + "line": 8 }, "end": { - "line": 8, - "column": 14 + "column": 14, + "line": 8 } }, "value": "v-for" @@ -1936,12 +2152,12 @@ ], "loc": { "start": { - "line": 9, - "column": 9 + "column": 9, + "line": 9 }, "end": { - "line": 9, - "column": 14 + "column": 14, + "line": 9 } }, "value": "v-for" diff --git a/test/fixtures/ast/error-message-empty/token-ranges.json b/test/fixtures/ast/error-message-empty/token-ranges.json index 27eef13d..d1b55359 100644 --- a/test/fixtures/ast/error-message-empty/token-ranges.json +++ b/test/fixtures/ast/error-message-empty/token-ranges.json @@ -9,7 +9,8 @@ "}}", "\n ", "", "\n ", "", @@ -26,7 +28,8 @@ ">", "\n ", "", "\n ", "", diff --git a/test/fixtures/ast/error-message-empty/tree.json b/test/fixtures/ast/error-message-empty/tree.json index a706963d..5abcaea7 100644 --- a/test/fixtures/ast/error-message-empty/tree.json +++ b/test/fixtures/ast/error-message-empty/tree.json @@ -38,7 +38,18 @@ { "type": "VDirectiveKey", "text": ":a", - "children": [] + "children": [ + { + "type": "VIdentifier", + "text": ":", + "children": [] + }, + { + "type": "VIdentifier", + "text": "a", + "children": [] + } + ] }, { "type": "VExpressionContainer", @@ -76,7 +87,18 @@ { "type": "VDirectiveKey", "text": ":b", - "children": [] + "children": [ + { + "type": "VIdentifier", + "text": ":", + "children": [] + }, + { + "type": "VIdentifier", + "text": "b", + "children": [] + } + ] }, { "type": "VExpressionContainer", @@ -114,7 +136,18 @@ { "type": "VDirectiveKey", "text": "@a", - "children": [] + "children": [ + { + "type": "VIdentifier", + "text": "@", + "children": [] + }, + { + "type": "VIdentifier", + "text": "a", + "children": [] + } + ] }, { "type": "VExpressionContainer", @@ -152,7 +185,18 @@ { "type": "VDirectiveKey", "text": "@b", - "children": [] + "children": [ + { + "type": "VIdentifier", + "text": "@", + "children": [] + }, + { + "type": "VIdentifier", + "text": "b", + "children": [] + } + ] }, { "type": "VExpressionContainer", @@ -190,7 +234,13 @@ { "type": "VDirectiveKey", "text": "v-for", - "children": [] + "children": [ + { + "type": "VIdentifier", + "text": "v-for", + "children": [] + } + ] }, { "type": "VExpressionContainer", @@ -228,7 +278,13 @@ { "type": "VDirectiveKey", "text": "v-for", - "children": [] + "children": [ + { + "type": "VIdentifier", + "text": "v-for", + "children": [] + } + ] }, { "type": "VExpressionContainer", diff --git a/test/fixtures/ast/error-message-outside/ast.json b/test/fixtures/ast/error-message-outside/ast.json index 2343c8d8..4e041bcb 100644 --- a/test/fixtures/ast/error-message-outside/ast.json +++ b/test/fixtures/ast/error-message-outside/ast.json @@ -24,7 +24,7 @@ "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, @@ -184,21 +184,33 @@ "column": 14 } }, - "name": "for", - "argument": null, - "modifiers": [], - "shorthand": false, - "raw": { + "name": { + "type": "VIdentifier", + "range": [ + 33, + 38 + ], + "loc": { + "start": { + "column": 9, + "line": 3 + }, + "end": { + "column": 14, + "line": 3 + } + }, "name": "for", - "argument": null, - "modifiers": [] - } + "rawName": "for" + }, + "argument": null, + "modifiers": [] }, "value": { "type": "VExpressionContainer", "range": [ 39, - 44 + 50 ], "loc": { "start": { @@ -207,7 +219,7 @@ }, "end": { "line": 3, - "column": 20 + "column": 26 } }, "expression": null, @@ -220,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 } } }, @@ -239,13 +251,13 @@ { "type": "VText", "range": [ - 51, - 56 + 57, + 62 ], "loc": { "start": { "line": 3, - "column": 27 + "column": 33 }, "end": { "line": 4, @@ -257,8 +269,8 @@ { "type": "VElement", "range": [ - 56, - 83 + 62, + 89 ], "loc": { "start": { @@ -276,8 +288,8 @@ "startTag": { "type": "VStartTag", "range": [ - 56, - 77 + 62, + 83 ], "loc": { "start": { @@ -294,8 +306,8 @@ { "type": "VAttribute", "range": [ - 61, - 76 + 67, + 82 ], "loc": { "start": { @@ -311,8 +323,8 @@ "key": { "type": "VDirectiveKey", "range": [ - 61, - 65 + 67, + 71 ], "loc": { "start": { @@ -324,21 +336,51 @@ "column": 13 } }, - "name": "bind", - "argument": "foo", - "modifiers": [], - "shorthand": true, - "raw": { + "name": { + "type": "VIdentifier", + "range": [ + 67, + 68 + ], + "loc": { + "start": { + "column": 9, + "line": 4 + }, + "end": { + "column": 10, + "line": 4 + } + }, "name": "bind", - "argument": "foo", - "modifiers": [] - } + "rawName": ":" + }, + "argument": { + "type": "VIdentifier", + "range": [ + 68, + 71 + ], + "loc": { + "start": { + "column": 10, + "line": 4 + }, + "end": { + "column": 13, + "line": 4 + } + }, + "name": "foo", + "rawName": "foo" + }, + "modifiers": [] }, "value": { "type": "VExpressionContainer", "range": [ - 66, - 76 + 72, + 82 ], "loc": { "start": { @@ -360,8 +402,8 @@ "endTag": { "type": "VEndTag", "range": [ - 77, - 83 + 83, + 89 ], "loc": { "start": { @@ -379,8 +421,8 @@ { "type": "VText", "range": [ - 83, - 88 + 89, + 94 ], "loc": { "start": { @@ -397,8 +439,8 @@ { "type": "VElement", "range": [ - 88, - 120 + 94, + 126 ], "loc": { "start": { @@ -416,8 +458,8 @@ "startTag": { "type": "VStartTag", "range": [ - 88, - 114 + 94, + 120 ], "loc": { "start": { @@ -434,8 +476,8 @@ { "type": "VAttribute", "range": [ - 93, - 113 + 99, + 119 ], "loc": { "start": { @@ -451,8 +493,8 @@ "key": { "type": "VDirectiveKey", "range": [ - 93, - 99 + 99, + 105 ], "loc": { "start": { @@ -464,21 +506,51 @@ "column": 15 } }, - "name": "on", - "argument": "click", - "modifiers": [], - "shorthand": true, - "raw": { + "name": { + "type": "VIdentifier", + "range": [ + 99, + 100 + ], + "loc": { + "start": { + "column": 9, + "line": 5 + }, + "end": { + "column": 10, + "line": 5 + } + }, "name": "on", - "argument": "click", - "modifiers": [] - } + "rawName": "@" + }, + "argument": { + "type": "VIdentifier", + "range": [ + 100, + 105 + ], + "loc": { + "start": { + "column": 10, + "line": 5 + }, + "end": { + "column": 15, + "line": 5 + } + }, + "name": "click", + "rawName": "click" + }, + "modifiers": [] }, "value": { "type": "VExpressionContainer", "range": [ - 100, - 113 + 106, + 119 ], "loc": { "start": { @@ -500,8 +572,8 @@ "endTag": { "type": "VEndTag", "range": [ - 114, - 120 + 120, + 126 ], "loc": { "start": { @@ -519,8 +591,8 @@ { "type": "VText", "range": [ - 120, - 121 + 126, + 127 ], "loc": { "start": { @@ -538,8 +610,8 @@ "endTag": { "type": "VEndTag", "range": [ - 121, - 132 + 127, + 138 ], "loc": { "start": { @@ -760,12 +832,12 @@ ], "loc": { "start": { - "line": 3, - "column": 9 + "column": 9, + "line": 3 }, "end": { - "line": 3, - "column": 14 + "column": 14, + "line": 3 } }, "value": "v-for" @@ -792,7 +864,7 @@ "type": "HTMLLiteral", "range": [ 39, - 44 + 50 ], "loc": { "start": { @@ -801,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": "" @@ -827,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" @@ -845,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": "" @@ -863,13 +935,13 @@ { "type": "HTMLWhitespace", "range": [ - 51, - 56 + 57, + 62 ], "loc": { "start": { "line": 3, - "column": 27 + "column": 33 }, "end": { "line": 4, @@ -881,8 +953,8 @@ { "type": "HTMLTagOpen", "range": [ - 56, - 60 + 62, + 66 ], "loc": { "start": { @@ -896,29 +968,47 @@ }, "value": "div" }, + { + "type": "Punctuator", + "range": [ + 67, + 68 + ], + "loc": { + "start": { + "column": 9, + "line": 4 + }, + "end": { + "column": 10, + "line": 4 + } + }, + "value": ":" + }, { "type": "HTMLIdentifier", "range": [ - 61, - 65 + 68, + 71 ], "loc": { "start": { - "line": 4, - "column": 9 + "column": 10, + "line": 4 }, "end": { - "line": 4, - "column": 13 + "column": 13, + "line": 4 } }, - "value": ":foo" + "value": "foo" }, { "type": "HTMLAssociation", "range": [ - 65, - 66 + 71, + 72 ], "loc": { "start": { @@ -935,8 +1025,8 @@ { "type": "HTMLLiteral", "range": [ - 66, - 76 + 72, + 82 ], "loc": { "start": { @@ -953,8 +1043,8 @@ { "type": "HTMLTagClose", "range": [ - 76, - 77 + 82, + 83 ], "loc": { "start": { @@ -971,8 +1061,8 @@ { "type": "HTMLEndTagOpen", "range": [ - 77, - 82 + 83, + 88 ], "loc": { "start": { @@ -989,8 +1079,8 @@ { "type": "HTMLTagClose", "range": [ - 82, - 83 + 88, + 89 ], "loc": { "start": { @@ -1007,8 +1097,8 @@ { "type": "HTMLWhitespace", "range": [ - 83, - 88 + 89, + 94 ], "loc": { "start": { @@ -1025,8 +1115,8 @@ { "type": "HTMLTagOpen", "range": [ - 88, - 92 + 94, + 98 ], "loc": { "start": { @@ -1040,29 +1130,47 @@ }, "value": "div" }, + { + "type": "Punctuator", + "range": [ + 99, + 100 + ], + "loc": { + "start": { + "column": 9, + "line": 5 + }, + "end": { + "column": 10, + "line": 5 + } + }, + "value": "@" + }, { "type": "HTMLIdentifier", "range": [ - 93, - 99 + 100, + 105 ], "loc": { "start": { - "line": 5, - "column": 9 + "column": 10, + "line": 5 }, "end": { - "line": 5, - "column": 15 + "column": 15, + "line": 5 } }, - "value": "@click" + "value": "click" }, { "type": "HTMLAssociation", "range": [ - 99, - 100 + 105, + 106 ], "loc": { "start": { @@ -1079,8 +1187,8 @@ { "type": "HTMLLiteral", "range": [ - 100, - 113 + 106, + 119 ], "loc": { "start": { @@ -1097,8 +1205,8 @@ { "type": "HTMLTagClose", "range": [ - 113, - 114 + 119, + 120 ], "loc": { "start": { @@ -1115,8 +1223,8 @@ { "type": "HTMLEndTagOpen", "range": [ - 114, - 119 + 120, + 125 ], "loc": { "start": { @@ -1133,8 +1241,8 @@ { "type": "HTMLTagClose", "range": [ - 119, - 120 + 125, + 126 ], "loc": { "start": { @@ -1151,8 +1259,8 @@ { "type": "HTMLWhitespace", "range": [ - 120, - 121 + 126, + 127 ], "loc": { "start": { @@ -1169,8 +1277,8 @@ { "type": "HTMLEndTagOpen", "range": [ - 121, - 131 + 127, + 137 ], "loc": { "start": { @@ -1187,8 +1295,8 @@ { "type": "HTMLTagClose", "range": [ - 131, - 132 + 137, + 138 ], "loc": { "start": { @@ -1205,8 +1313,8 @@ { "type": "HTMLWhitespace", "range": [ - 132, - 133 + 138, + 139 ], "loc": { "start": { @@ -1231,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 6ae3bf41..b7754866 100644 --- a/test/fixtures/ast/error-message-outside/token-ranges.json +++ b/test/fixtures/ast/error-message-outside/token-ranges.json @@ -12,13 +12,14 @@ "", "", "\n ", "", @@ -26,7 +27,8 @@ ">", "\n ", "", diff --git a/test/fixtures/ast/error-message-outside/tree.json b/test/fixtures/ast/error-message-outside/tree.json index 69734095..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,24 +25,30 @@ }, { "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", "text": "v-for", - "children": [] + "children": [ + { + "type": "VIdentifier", + "text": "v-for", + "children": [] + } + ] }, { "type": "VExpressionContainer", - "text": "\"abc\"", + "text": "\"i in abc.\"", "children": [] } ] @@ -76,7 +82,18 @@ { "type": "VDirectiveKey", "text": ":foo", - "children": [] + "children": [ + { + "type": "VIdentifier", + "text": ":", + "children": [] + }, + { + "type": "VIdentifier", + "text": "foo", + "children": [] + } + ] }, { "type": "VExpressionContainer", @@ -114,7 +131,18 @@ { "type": "VDirectiveKey", "text": "@click", - "children": [] + "children": [ + { + "type": "VIdentifier", + "text": "@", + "children": [] + }, + { + "type": "VIdentifier", + "text": "click", + "children": [] + } + ] }, { "type": "VExpressionContainer", 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 bf7e0cd9..0e6de9bd 100644 --- a/test/fixtures/ast/error-v-on-function-expression/ast.json +++ b/test/fixtures/ast/error-v-on-function-expression/ast.json @@ -147,15 +147,45 @@ "column": 18 } }, - "name": "on", - "argument": "click", - "modifiers": [], - "shorthand": true, - "raw": { + "name": { + "type": "VIdentifier", + "range": [ + 23, + 24 + ], + "loc": { + "start": { + "column": 12, + "line": 2 + }, + "end": { + "column": 13, + "line": 2 + } + }, "name": "on", - "argument": "click", - "modifiers": [] - } + "rawName": "@" + }, + "argument": { + "type": "VIdentifier", + "range": [ + 24, + 29 + ], + "loc": { + "start": { + "column": 13, + "line": 2 + }, + "end": { + "column": 18, + "line": 2 + } + }, + "name": "click", + "rawName": "click" + }, + "modifiers": [] }, "value": { "type": "VExpressionContainer", @@ -310,22 +340,40 @@ "value": "button" }, { - "type": "HTMLIdentifier", + "type": "Punctuator", "range": [ 23, + 24 + ], + "loc": { + "start": { + "column": 12, + "line": 2 + }, + "end": { + "column": 13, + "line": 2 + } + }, + "value": "@" + }, + { + "type": "HTMLIdentifier", + "range": [ + 24, 29 ], "loc": { "start": { - "line": 2, - "column": 12 + "column": 13, + "line": 2 }, "end": { - "line": 2, - "column": 18 + "column": 18, + "line": 2 } }, - "value": "@click" + "value": "click" }, { "type": "HTMLAssociation", diff --git a/test/fixtures/ast/error-v-on-function-expression/token-ranges.json b/test/fixtures/ast/error-v-on-function-expression/token-ranges.json index 9eb022c2..ae0dce3e 100644 --- a/test/fixtures/ast/error-v-on-function-expression/token-ranges.json +++ b/test/fixtures/ast/error-v-on-function-expression/token-ranges.json @@ -3,7 +3,8 @@ ">", "\n ", "", diff --git a/test/fixtures/ast/error-v-on-function-expression/tree.json b/test/fixtures/ast/error-v-on-function-expression/tree.json index 1747a052..dd740d67 100644 --- a/test/fixtures/ast/error-v-on-function-expression/tree.json +++ b/test/fixtures/ast/error-v-on-function-expression/tree.json @@ -28,7 +28,18 @@ { "type": "VDirectiveKey", "text": "@click", - "children": [] + "children": [ + { + "type": "VIdentifier", + "text": "@", + "children": [] + }, + { + "type": "VIdentifier", + "text": "click", + "children": [] + } + ] }, { "type": "VExpressionContainer", diff --git a/test/fixtures/ast/filters-3/ast.json b/test/fixtures/ast/filters-3/ast.json index 74c4433d..59d0eeaa 100644 --- a/test/fixtures/ast/filters-3/ast.json +++ b/test/fixtures/ast/filters-3/ast.json @@ -147,15 +147,45 @@ "column": 14 } }, - "name": "bind", - "argument": "attr", - "modifiers": [], - "shorthand": true, - "raw": { + "name": { + "type": "VIdentifier", + "range": [ + 20, + 21 + ], + "loc": { + "start": { + "column": 9, + "line": 2 + }, + "end": { + "column": 10, + "line": 2 + } + }, "name": "bind", - "argument": "attr", - "modifiers": [] - } + "rawName": ":" + }, + "argument": { + "type": "VIdentifier", + "range": [ + 21, + 25 + ], + "loc": { + "start": { + "column": 10, + "line": 2 + }, + "end": { + "column": 14, + "line": 2 + } + }, + "name": "attr", + "rawName": "attr" + }, + "modifiers": [] }, "value": { "type": "VExpressionContainer", @@ -524,22 +554,40 @@ "value": "div" }, { - "type": "HTMLIdentifier", + "type": "Punctuator", "range": [ 20, + 21 + ], + "loc": { + "start": { + "column": 9, + "line": 2 + }, + "end": { + "column": 10, + "line": 2 + } + }, + "value": ":" + }, + { + "type": "HTMLIdentifier", + "range": [ + 21, 25 ], "loc": { "start": { - "line": 2, - "column": 9 + "column": 10, + "line": 2 }, "end": { - "line": 2, - "column": 14 + "column": 14, + "line": 2 } }, - "value": ":attr" + "value": "attr" }, { "type": "HTMLAssociation", diff --git a/test/fixtures/ast/filters-3/token-ranges.json b/test/fixtures/ast/filters-3/token-ranges.json index 2359e85e..aaab971d 100644 --- a/test/fixtures/ast/filters-3/token-ranges.json +++ b/test/fixtures/ast/filters-3/token-ranges.json @@ -3,7 +3,8 @@ ">", "\n ", "", "\n ", "", + "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..56f5ef80 --- /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": "script", + "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..5ea7e9fe --- /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": "script", + "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..f227023b 100644 --- a/test/fixtures/ast/filters/ast.json +++ b/test/fixtures/ast/filters/ast.json @@ -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..a0633d60 --- /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": "script", + "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..b1e10d56 100644 --- a/test/fixtures/ast/foreignobject/ast.json +++ b/test/fixtures/ast/foreignobject/ast.json @@ -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 6c215871..2c8dfa86 100644 --- a/test/fixtures/ast/hole-in-array/ast.json +++ b/test/fixtures/ast/hole-in-array/ast.json @@ -204,15 +204,27 @@ "column": 18 } }, - "name": "for", - "argument": null, - "modifiers": [], - "shorthand": false, - "raw": { + "name": { + "type": "VIdentifier", + "range": [ + 34, + 39 + ], + "loc": { + "start": { + "column": 13, + "line": 3 + }, + "end": { + "column": 18, + "line": 3 + } + }, "name": "for", - "argument": null, - "modifiers": [] - } + "rawName": "for" + }, + "argument": null, + "modifiers": [] }, "value": { "type": "VExpressionContainer", @@ -616,12 +628,12 @@ ], "loc": { "start": { - "line": 3, - "column": 13 + "column": 13, + "line": 3 }, "end": { - "line": 3, - "column": 18 + "column": 18, + "line": 3 } }, "value": "v-for" diff --git a/test/fixtures/ast/hole-in-array/tree.json b/test/fixtures/ast/hole-in-array/tree.json index 92750f15..eb69b8ab 100644 --- a/test/fixtures/ast/hole-in-array/tree.json +++ b/test/fixtures/ast/hole-in-array/tree.json @@ -42,7 +42,13 @@ { "type": "VDirectiveKey", "text": "v-for", - "children": [] + "children": [ + { + "type": "VIdentifier", + "text": "v-for", + "children": [] + } + ] }, { "type": "VExpressionContainer", diff --git a/test/fixtures/ast/html-entities/ast.json b/test/fixtures/ast/html-entities/ast.json index c4841c6f..0d9c4201 100644 --- a/test/fixtures/ast/html-entities/ast.json +++ b/test/fixtures/ast/html-entities/ast.json @@ -147,15 +147,27 @@ "column": 13 } }, - "name": "if", - "argument": null, - "modifiers": [], - "shorthand": false, - "raw": { + "name": { + "type": "VIdentifier", + "range": [ + 20, + 24 + ], + "loc": { + "start": { + "column": 9, + "line": 2 + }, + "end": { + "column": 13, + "line": 2 + } + }, "name": "if", - "argument": null, - "modifiers": [] - } + "rawName": "if" + }, + "argument": null, + "modifiers": [] }, "value": { "type": "VExpressionContainer", @@ -549,12 +561,12 @@ ], "loc": { "start": { - "line": 2, - "column": 9 + "column": 9, + "line": 2 }, "end": { - "line": 2, - "column": 13 + "column": 13, + "line": 2 } }, "value": "v-if" diff --git a/test/fixtures/ast/html-entities/tree.json b/test/fixtures/ast/html-entities/tree.json index ce396876..053ae026 100644 --- a/test/fixtures/ast/html-entities/tree.json +++ b/test/fixtures/ast/html-entities/tree.json @@ -28,7 +28,13 @@ { "type": "VDirectiveKey", "text": "v-if", - "children": [] + "children": [ + { + "type": "VIdentifier", + "text": "v-if", + "children": [] + } + ] }, { "type": "VExpressionContainer", diff --git a/test/fixtures/ast/input-component/ast.json b/test/fixtures/ast/input-component/ast.json new file mode 100644 index 00000000..422c77da --- /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": "script", + "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..f24d7201 --- /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": "script", + "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/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..87bdc971 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-11/ast.json @@ -0,0 +1,3338 @@ +{ + "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'" + } + }, + { + "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'" + } + }, + { + "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..3a94a274 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-2/ast.json @@ -0,0 +1,884 @@ +{ + "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'" + } + }, + { + "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'" + } + }, + { + "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..0c0ff3e9 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-5/ast.json @@ -0,0 +1,1727 @@ +{ + "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 + }, + { + "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'" + } + }, + { + "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..06ab461d --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-6/ast.json @@ -0,0 +1,582 @@ +{ + "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 + } + ], + "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..6689eb9a --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-7/ast.json @@ -0,0 +1,2682 @@ +{ + "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 + }, + { + "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'" + } + }, + { + "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'" + } + }, + { + "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..ba64ede6 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-8/ast.json @@ -0,0 +1,3445 @@ +{ + "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 + }, + { + "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'" + } + }, + { + "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'" + } + }, + { + "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..ae3782a8 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-9/ast.json @@ -0,0 +1,259 @@ +{ + "type": "Program", + "start": 8, + "end": 48, + "loc": { + "start": { + "line": 3, + "column": 12 + }, + "end": { + "line": 4, + "column": 13 + } + }, + "range": [ + 31, + 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..2b9018f4 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-export01/ast.json @@ -0,0 +1,462 @@ +{ + "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 + } + ], + "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..2d8fc7a3 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-export02/ast.json @@ -0,0 +1,2518 @@ +{ + "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'" + } + }, + { + "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 + }, + { + "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'" + } + }, + { + "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'" + } + }, + { + "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 + }, + { + "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 + }, + { + "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 + }, + { + "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..449ffd40 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-export03/ast.json @@ -0,0 +1,2054 @@ +{ + "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'" + } + }, + { + "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'" + } + }, + { + "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'" + } + }, + { + "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'" + } + }, + { + "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'" + } + }, + { + "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'" + } + }, + { + "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..c95d2858 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-export04/ast.json @@ -0,0 +1,1191 @@ +{ + "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 + }, + { + "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 + }, + { + "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'" + } + }, + { + "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 + }, + { + "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 + } + ], + "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..0f45883f --- /dev/null +++ b/test/fixtures/ast/multiple-scripts-with-ts/ast.json @@ -0,0 +1,534 @@ +{ + "type": "Program", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "Identifier", + "name": "performGlobalSideEffect", + "range": [ + 9, + 32 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 23 + } + } + }, + "arguments": [], + "optional": false, + "range": [ + 9, + 34 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 25 + } + } + }, + "range": [ + 9, + 34 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 25 + } + } + }, + { + "type": "ExportNamedDeclaration", + "declaration": { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "named", + "range": [ + 49, + 54 + ], + "loc": { + "start": { + "line": 4, + "column": 13 + }, + "end": { + "line": 4, + "column": 18 + } + } + }, + "init": { + "type": "Literal", + "value": 1, + "raw": "1", + "range": [ + 57, + 58 + ], + "loc": { + "start": { + "line": 4, + "column": 21 + }, + "end": { + "line": 4, + "column": 22 + } + } + }, + "range": [ + 49, + 58 + ], + "loc": { + "start": { + "line": 4, + "column": 13 + }, + "end": { + "line": 4, + "column": 22 + } + } + } + ], + "kind": "const", + "range": [ + 43, + 58 + ], + "loc": { + "start": { + "line": 4, + "column": 7 + }, + "end": { + "line": 4, + "column": 22 + } + } + }, + "specifiers": [], + "source": null, + "exportKind": "value", + "range": [ + 36, + 58 + ], + "assertions": [], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 22 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "count", + "range": [ + 89, + 94 + ], + "loc": { + "start": { + "line": 8, + "column": 4 + }, + "end": { + "line": 8, + "column": 9 + } + } + }, + "init": { + "type": "Literal", + "value": 0, + "raw": "0", + "range": [ + 97, + 98 + ], + "loc": { + "start": { + "line": 8, + "column": 12 + }, + "end": { + "line": 8, + "column": 13 + } + } + }, + "range": [ + 89, + 98 + ], + "loc": { + "start": { + "line": 8, + "column": 4 + }, + "end": { + "line": 8, + "column": 13 + } + } + } + ], + "kind": "let", + "range": [ + 85, + 98 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 13 + } + } + } + ], + "sourceType": "module", + "range": [ + 9, + 98 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 8, + "column": 13 + } + }, + "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": "" + } + ], + "comments": [] +} \ 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..bdaec0c7 --- /dev/null +++ b/test/fixtures/ast/multiple-scripts/ast.json @@ -0,0 +1,582 @@ +{ + "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 + }, + { + "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-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..712ef57e --- /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": "script", + "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 2fbfe3ba..7d1a3129 100644 --- a/test/fixtures/ast/mustache-errors/ast.json +++ b/test/fixtures/ast/mustache-errors/ast.json @@ -184,15 +184,45 @@ "column": 13 } }, - "name": "bind", - "argument": "foo", - "modifiers": [], - "shorthand": true, - "raw": { + "name": { + "type": "VIdentifier", + "range": [ + 32, + 33 + ], + "loc": { + "start": { + "column": 9, + "line": 3 + }, + "end": { + "column": 10, + "line": 3 + } + }, "name": "bind", - "argument": "foo", - "modifiers": [] - } + "rawName": ":" + }, + "argument": { + "type": "VIdentifier", + "range": [ + 33, + 36 + ], + "loc": { + "start": { + "column": 10, + "line": 3 + }, + "end": { + "column": 13, + "line": 3 + } + }, + "name": "foo", + "rawName": "foo" + }, + "modifiers": [] }, "value": { "type": "VExpressionContainer", @@ -324,15 +354,27 @@ "column": 19 } }, - "name": "scope", - "argument": null, - "modifiers": [], - "shorthand": false, - "raw": { + "name": { + "type": "VIdentifier", + "range": [ + 64, + 69 + ], + "loc": { + "start": { + "column": 14, + "line": 4 + }, + "end": { + "column": 19, + "line": 4 + } + }, "name": "scope", - "argument": null, - "modifiers": [] - } + "rawName": "scope" + }, + "argument": null, + "modifiers": [] }, "value": { "type": "VExpressionContainer", @@ -595,22 +637,40 @@ "value": "div" }, { - "type": "HTMLIdentifier", + "type": "Punctuator", "range": [ 32, + 33 + ], + "loc": { + "start": { + "column": 9, + "line": 3 + }, + "end": { + "column": 10, + "line": 3 + } + }, + "value": ":" + }, + { + "type": "HTMLIdentifier", + "range": [ + 33, 36 ], "loc": { "start": { - "line": 3, - "column": 9 + "column": 10, + "line": 3 }, "end": { - "line": 3, - "column": 13 + "column": 13, + "line": 3 } }, - "value": ":foo" + "value": "foo" }, { "type": "HTMLAssociation", @@ -746,12 +806,12 @@ ], "loc": { "start": { - "line": 4, - "column": 14 + "column": 14, + "line": 4 }, "end": { - "line": 4, - "column": 19 + "column": 19, + "line": 4 } }, "value": "scope" diff --git a/test/fixtures/ast/mustache-errors/token-ranges.json b/test/fixtures/ast/mustache-errors/token-ranges.json index 1ec39189..9b766e0d 100644 --- a/test/fixtures/ast/mustache-errors/token-ranges.json +++ b/test/fixtures/ast/mustache-errors/token-ranges.json @@ -9,7 +9,8 @@ "}}", "\n ", "", diff --git a/test/fixtures/ast/mustache-errors/tree.json b/test/fixtures/ast/mustache-errors/tree.json index f777f207..fafcda50 100644 --- a/test/fixtures/ast/mustache-errors/tree.json +++ b/test/fixtures/ast/mustache-errors/tree.json @@ -38,7 +38,18 @@ { "type": "VDirectiveKey", "text": ":foo", - "children": [] + "children": [ + { + "type": "VIdentifier", + "text": ":", + "children": [] + }, + { + "type": "VIdentifier", + "text": "foo", + "children": [] + } + ] }, { "type": "VExpressionContainer", @@ -76,7 +87,13 @@ { "type": "VDirectiveKey", "text": "scope", - "children": [] + "children": [ + { + "type": "VIdentifier", + "text": "scope", + "children": [] + } + ] }, { "type": "VExpressionContainer", 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..0aa3bd99 --- /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": "script", + "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 @@ +