diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index b77b6607..00000000 --- a/.eslintignore +++ /dev/null @@ -1,10 +0,0 @@ -/.nyc_output -/.temp -/coverage -/node_modules -/src/external -/src/html/util -/test/fixtures -/test/temp -/index.d.ts -/index.js diff --git a/.eslintrc.yml b/.eslintrc.yml deleted file mode 100644 index 9a375797..00000000 --- a/.eslintrc.yml +++ /dev/null @@ -1,878 +0,0 @@ -plugins: - - prettier -extends: - - 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: "*.json" - rules: - 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: - - error - - allowModules: - - estree - - files: package.json - rules: - "@mysticatea/prettier": off -settings: - node: - tryExtensions: - - .ts - - .js - - .json diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index ce763b1f..71f6fe76 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,2 +1,3 @@ github: +- ota-meshi - mysticatea diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 00000000..2c55f6c5 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,84 @@ +name: Bug report +description: Create a report to help us improve. + +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to fill out this bug report! + - type: checkboxes + id: sanity-checks + attributes: + label: Before You File a Bug Report Please Confirm You Have Done The Following... + description: If any of these required steps are not taken, we may not be able to review your issue. Help us to help you! + options: + - label: I'm using [eslint-plugin-vue](https://github.com/vuejs/eslint-plugin-vue). + - label: I'm sure the problem is a parser problem. (If you are not sure, search for the issue in [eslint-plugin-vue](https://github.com/vuejs/eslint-plugin-vue) repo and open the issue in [eslint-plugin-vue](https://github.com/vuejs/eslint-plugin-vue) repo if there is no solution. + required: true + - label: I have tried restarting my IDE and the issue persists. + required: true + - label: I have updated to the latest version of the packages. + required: true + - type: input + id: eslint-version + attributes: + label: What version of ESLint are you using? + placeholder: 0.0.0 + validations: + required: true + - type: textarea + id: eslint-plugin-vue-version + attributes: + label: What version of `eslint-plugin-vue` and `vue-eslint-parser` are you using? + value: | + - vue-eslint-parser@0.0.0 + - eslint-plugin-vue@0.0.0 + validations: + required: true + - type: textarea + attributes: + label: What did you do? + description: | + Please include a *minimal* reproduction case. + value: | +
+ Configuration + + ``` + + ``` +
+ + ```vue + + ``` + validations: + required: true + - type: textarea + attributes: + label: What did you expect to happen? + description: | + You can use Markdown in this field. + validations: + required: true + - type: textarea + attributes: + label: What actually happened? + description: | + Please copy-paste the actual ESLint output. You can use Markdown in this field. + validations: + required: true + - type: textarea + id: bug-reproduction + attributes: + label: Link to Minimal Reproducible Example + description: | + Create a minimal reproduction of the problem. **A minimal reproduction is required** so that others can help debug your issue. **If a report has no reproduction, it will be closed.** + [Why Reproductions are Required](https://antfu.me/posts/why-reproductions-are-required) + placeholder: | + https://github.com/[your]/[repo] + validations: + required: true + - type: textarea + attributes: + label: Additional comments diff --git a/.github/ISSUE_TEMPLATE/other.md b/.github/ISSUE_TEMPLATE/other.md new file mode 100644 index 00000000..565795b2 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/other.md @@ -0,0 +1,7 @@ +--- +name: Other +about: An issue that doesn't fit into the other categories. +title: "" +labels: "" +assignees: "" +--- diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 545a0cc4..e1d1e9de 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -13,15 +13,15 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Checkout submodules run: git submodule update --init - name: Install Node.js - uses: actions/setup-node@v1 + uses: actions/setup-node@v4 with: - node-version: 14 + node-version: 'lts/*' - name: Install Packages - run: npm install && cd test/fixtures/eslint && npm install + run: npm install - name: Lint run: npm run -s lint @@ -29,70 +29,57 @@ jobs: name: Test strategy: matrix: - eslint: [7, 8] - node: [14, 16] + eslint: [9] + node: [18, 20, 21, 'lts/*'] os: [ubuntu-latest] include: # On other platforms - - eslint: 7 - node: 14 + - eslint: 9 + node: 'lts/*' os: windows-latest - - eslint: 7 - node: 14 + - eslint: 9 + node: 'lts/*' os: macos-latest - # On old Node.js versions - - eslint: 7 - node: 12 - os: ubuntu-latest - # On old ESLint versions - - eslint: 6 - node: 14 - os: ubuntu-latest - # On the minimum supported ESLint/Node.js version - - eslint: 6 - node: 12 - os: ubuntu-latest runs-on: ${{ matrix.os }} steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Checkout submodules run: git submodule update --init - name: Install Node.js v${{ matrix.node }} - uses: actions/setup-node@v1 + uses: actions/setup-node@v4 with: node-version: ${{ matrix.node }} - name: Install Packages - run: npm install --legacy-peer-deps + run: npm install -f - name: Install ESLint v${{ matrix.eslint }} run: node scripts/ci-install-eslint ${{ matrix.eslint }} - name: Build run: npm run -s build - name: Test run: npm run -s test:mocha + test-for-old-eslint: + name: Test + strategy: + matrix: + eslint: [8] + node: ['lts/*'] + os: [ubuntu-latest] - test-cov: - name: Test and Send Coverage - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Checkout submodules run: git submodule update --init - - name: Install Node.js v14 - uses: actions/setup-node@v1 + - name: Install Node.js v${{ matrix.node }} + uses: actions/setup-node@v4 with: - node-version: 14 + node-version: ${{ matrix.node }} - name: Install Packages - run: npm install - - name: Install ESLint v7 - run: node scripts/ci-install-eslint 7 - - name: Build - run: npm run -s build + run: npm install -f + - name: Install ESLint v${{ matrix.eslint }} + run: node scripts/ci-install-eslint ${{ matrix.eslint }} - name: Test - run: npm run -s test:mocha - - name: Send Coverage - run: npm run -s codecov - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + run: npm run -s test:debug diff --git a/.gitignore b/.gitignore index 6ea559ee..8bf60fc5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +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/.gitmodules b/.gitmodules index 45ed6b45..e69de29b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +0,0 @@ -[submodule "test/fixtures/eslint"] - path = test/fixtures/eslint - url = https://github.com/eslint/eslint.git diff --git a/.vscode/settings.json b/.vscode/settings.json index 72446f43..7ff99747 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,12 @@ { - "typescript.tsdk": "node_modules/typescript/lib" + "typescript.tsdk": "node_modules/typescript/lib", + "eslint.validate": [ + "javascript", + "javascriptreact", + "typescript", + "typescriptreact", + "vue", + "json", + "jsonc" + ] } diff --git a/README.md b/README.md index 62f128eb..57e0668f 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,6 @@ [![npm version](https://img.shields.io/npm/v/vue-eslint-parser.svg)](https://www.npmjs.com/package/vue-eslint-parser) [![Downloads/month](https://img.shields.io/npm/dm/vue-eslint-parser.svg)](http://www.npmtrends.com/vue-eslint-parser) [![Build Status](https://github.com/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. @@ -18,25 +16,21 @@ This parser allows us to lint the ` diff --git a/test/fixtures/ast/mustache-without-open-in-textarea/token-ranges.json b/test/fixtures/ast/mustache-without-open-in-textarea/token-ranges.json new file mode 100644 index 00000000..8d08b5f6 --- /dev/null +++ b/test/fixtures/ast/mustache-without-open-in-textarea/token-ranges.json @@ -0,0 +1,22 @@ +[ + "", + "\n ", + "{{", + "123", + "}}", + "\n ", + "", + " ", + "}}", + " ", + "", + "\n", + "", + "\n" +] \ No newline at end of file diff --git a/test/fixtures/ast/mustache-without-open-in-textarea/tree.json b/test/fixtures/ast/mustache-without-open-in-textarea/tree.json new file mode 100644 index 00000000..7312fcac --- /dev/null +++ b/test/fixtures/ast/mustache-without-open-in-textarea/tree.json @@ -0,0 +1,65 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/ast/mustache/ast.json b/test/fixtures/ast/mustache/ast.json index 590d2632..0b1fbe13 100644 --- a/test/fixtures/ast/mustache/ast.json +++ b/test/fixtures/ast/mustache/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/no-filters/ast.json b/test/fixtures/ast/no-filters/ast.json index adcb6056..2f1ed4af 100644 --- a/test/fixtures/ast/no-filters/ast.json +++ b/test/fixtures/ast/no-filters/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/not-closing-elements/ast.json b/test/fixtures/ast/not-closing-elements/ast.json index 0ebf4ca1..0c68b5cb 100644 --- a/test/fixtures/ast/not-closing-elements/ast.json +++ b/test/fixtures/ast/not-closing-elements/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/parser-option-multiple-parsers-1/ast.json b/test/fixtures/ast/parser-option-multiple-parsers-1/ast.json index 97d900ed..1225bef4 100644 --- a/test/fixtures/ast/parser-option-multiple-parsers-1/ast.json +++ b/test/fixtures/ast/parser-option-multiple-parsers-1/ast.json @@ -1,64 +1,58 @@ { "type": "Program", + "range": [ + 60, + 70 + ], "body": [ { "type": "ExpressionStatement", "expression": { "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "a", - "range": [ - 60, - 61 - ], - "loc": { - "start": { - "line": 5, - "column": 2 - }, - "end": { - "line": 5, - "column": 3 - } - } - }, "arguments": [ { "type": "Identifier", + "decorators": [], "name": "d", + "optional": false, "range": [ 67, 68 ], "loc": { - "start": { - "line": 5, - "column": 9 - }, "end": { "line": 5, "column": 10 + }, + "start": { + "line": 5, + "column": 9 } } } ], - "optional": false, - "range": [ - 60, - 69 - ], - "loc": { - "start": { - "line": 5, - "column": 2 - }, - "end": { - "line": 5, - "column": 11 + "callee": { + "type": "Identifier", + "decorators": [], + "name": "a", + "optional": false, + "range": [ + 60, + 61 + ], + "loc": { + "end": { + "line": 5, + "column": 3 + }, + "start": { + "line": 5, + "column": 2 + } } }, - "typeParameters": { + "optional": false, + "typeArguments": { "type": "TSTypeParameterInstantiation", "range": [ 61, @@ -72,19 +66,21 @@ "type": "TSTypeReference", "typeName": { "type": "Identifier", + "decorators": [], "name": "b", + "optional": false, "range": [ 62, 63 ], "loc": { - "start": { - "line": 5, - "column": 4 - }, "end": { "line": 5, "column": 5 + }, + "start": { + "line": 5, + "column": 4 } } }, @@ -93,13 +89,13 @@ 63 ], "loc": { - "start": { - "line": 5, - "column": 4 - }, "end": { "line": 5, "column": 5 + }, + "start": { + "line": 5, + "column": 4 } } }, @@ -107,19 +103,21 @@ "type": "TSTypeReference", "typeName": { "type": "Identifier", + "decorators": [], "name": "c", + "optional": false, "range": [ 64, 65 ], "loc": { - "start": { - "line": 5, - "column": 6 - }, "end": { "line": 5, "column": 7 + }, + "start": { + "line": 5, + "column": 6 } } }, @@ -128,13 +126,13 @@ 65 ], "loc": { - "start": { - "line": 5, - "column": 6 - }, "end": { "line": 5, "column": 7 + }, + "start": { + "line": 5, + "column": 6 } } } @@ -144,27 +142,41 @@ 65 ], "loc": { - "start": { - "line": 5, - "column": 4 - }, "end": { "line": 5, "column": 7 + }, + "start": { + "line": 5, + "column": 4 } } } ], "loc": { - "start": { - "line": 5, - "column": 3 - }, "end": { "line": 5, "column": 8 + }, + "start": { + "line": 5, + "column": 3 } } + }, + "range": [ + 60, + 69 + ], + "loc": { + "end": { + "line": 5, + "column": 11 + }, + "start": { + "line": 5, + "column": 2 + } } }, "range": [ @@ -172,32 +184,19 @@ 69 ], "loc": { - "start": { - "line": 5, - "column": 2 - }, "end": { "line": 5, "column": 11 + }, + "start": { + "line": 5, + "column": 2 } } } ], + "comments": [], "sourceType": "module", - "range": [ - 60, - 70 - ], - "loc": { - "start": { - "line": 5, - "column": 2 - }, - "end": { - "line": 6, - "column": 0 - } - }, "tokens": [ { "type": "Punctuator", @@ -219,165 +218,165 @@ }, { "type": "Identifier", - "value": "a", + "loc": { + "end": { + "line": 5, + "column": 3 + }, + "start": { + "line": 5, + "column": 2 + } + }, "range": [ 60, 61 ], + "value": "a" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 2 + "column": 4 }, - "end": { + "start": { "line": 5, "column": 3 } - } - }, - { - "type": "Punctuator", - "value": "<", + }, "range": [ 61, 62 ], + "value": "<" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 5, - "column": 3 + "column": 5 }, - "end": { + "start": { "line": 5, "column": 4 } - } - }, - { - "type": "Identifier", - "value": "b", + }, "range": [ 62, 63 ], + "value": "b" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 4 + "column": 6 }, - "end": { + "start": { "line": 5, "column": 5 } - } - }, - { - "type": "Punctuator", - "value": "|", + }, "range": [ 63, 64 ], + "value": "|" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 5, - "column": 5 + "column": 7 }, - "end": { + "start": { "line": 5, "column": 6 } - } - }, - { - "type": "Identifier", - "value": "c", + }, "range": [ 64, 65 ], + "value": "c" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 6 + "column": 8 }, - "end": { + "start": { "line": 5, "column": 7 } - } - }, - { - "type": "Punctuator", - "value": ">", + }, "range": [ 65, 66 ], + "value": ">" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 7 + "column": 9 }, - "end": { + "start": { "line": 5, "column": 8 } - } - }, - { - "type": "Punctuator", - "value": "(", + }, "range": [ 66, 67 ], + "value": "(" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 5, - "column": 8 + "column": 10 }, - "end": { + "start": { "line": 5, "column": 9 } - } - }, - { - "type": "Identifier", - "value": "d", + }, "range": [ 67, 68 ], + "value": "d" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 9 + "column": 11 }, - "end": { + "start": { "line": 5, "column": 10 } - } - }, - { - "type": "Punctuator", - "value": ")", + }, "range": [ 68, 69 ], - "loc": { - "start": { - "line": 5, - "column": 10 - }, - "end": { - "line": 5, - "column": 11 - } - } + "value": ")" }, { "type": "Punctuator", @@ -398,7 +397,16 @@ "value": "" } ], - "comments": [], + "loc": { + "end": { + "line": 6, + "column": 0 + }, + "start": { + "line": 5, + "column": 2 + } + }, "templateBody": { "type": "VElement", "range": [ @@ -474,60 +482,50 @@ }, "expression": { "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "a", - "range": [ - 15, - 16 - ], - "loc": { - "start": { - "line": 2, - "column": 4 - }, - "end": { - "line": 2, - "column": 5 - } - } - }, "arguments": [ { "type": "Identifier", + "decorators": [], "name": "d", + "optional": false, "range": [ 22, 23 ], "loc": { - "start": { - "line": 2, - "column": 11 - }, "end": { "line": 2, "column": 12 + }, + "start": { + "line": 2, + "column": 11 } } } - ], - "optional": false, - "range": [ - 15, - 24 - ], - "loc": { - "start": { - "line": 2, - "column": 4 - }, - "end": { - "line": 2, - "column": 13 - } + ], + "callee": { + "type": "Identifier", + "decorators": [], + "name": "a", + "optional": false, + "range": [ + 15, + 16 + ], + "loc": { + "end": { + "line": 2, + "column": 5 + }, + "start": { + "line": 2, + "column": 4 + } + } }, - "typeParameters": { + "optional": false, + "typeArguments": { "type": "TSTypeParameterInstantiation", "range": [ 16, @@ -541,19 +539,21 @@ "type": "TSTypeReference", "typeName": { "type": "Identifier", + "decorators": [], "name": "b", + "optional": false, "range": [ 17, 18 ], "loc": { - "start": { - "line": 2, - "column": 6 - }, "end": { "line": 2, "column": 7 + }, + "start": { + "line": 2, + "column": 6 } } }, @@ -562,13 +562,13 @@ 18 ], "loc": { - "start": { - "line": 2, - "column": 6 - }, "end": { "line": 2, "column": 7 + }, + "start": { + "line": 2, + "column": 6 } } }, @@ -576,19 +576,21 @@ "type": "TSTypeReference", "typeName": { "type": "Identifier", + "decorators": [], "name": "c", + "optional": false, "range": [ 19, 20 ], "loc": { - "start": { - "line": 2, - "column": 8 - }, "end": { "line": 2, "column": 9 + }, + "start": { + "line": 2, + "column": 8 } } }, @@ -597,13 +599,13 @@ 20 ], "loc": { - "start": { - "line": 2, - "column": 8 - }, "end": { "line": 2, "column": 9 + }, + "start": { + "line": 2, + "column": 8 } } } @@ -613,71 +615,143 @@ 20 ], "loc": { - "start": { - "line": 2, - "column": 6 - }, "end": { "line": 2, "column": 9 + }, + "start": { + "line": 2, + "column": 6 } } } ], "loc": { - "start": { - "line": 2, - "column": 5 - }, "end": { "line": 2, "column": 10 + }, + "start": { + "line": 2, + "column": 5 } } + }, + "range": [ + 15, + 24 + ], + "loc": { + "end": { + "line": 2, + "column": 13 + }, + "start": { + "line": 2, + "column": 4 + } } }, "references": [ { "id": { "type": "Identifier", + "decorators": [], "name": "a", + "optional": false, "range": [ 15, 16 ], "loc": { - "start": { - "line": 2, - "column": 4 - }, "end": { "line": 2, "column": 5 + }, + "start": { + "line": 2, + "column": 4 } } }, - "mode": "r" + "mode": "r", + "isValueReference": true, + "isTypeReference": false }, { "id": { "type": "Identifier", + "decorators": [], "name": "d", + "optional": false, "range": [ 22, 23 ], "loc": { + "end": { + "line": 2, + "column": 12 + }, "start": { "line": 2, "column": 11 + } + } + }, + "mode": "r", + "isValueReference": true, + "isTypeReference": false + }, + { + "id": { + "type": "Identifier", + "decorators": [], + "name": "b", + "optional": false, + "range": [ + 17, + 18 + ], + "loc": { + "end": { + "line": 2, + "column": 7 }, + "start": { + "line": 2, + "column": 6 + } + } + }, + "mode": "r", + "isValueReference": false, + "isTypeReference": true + }, + { + "id": { + "type": "Identifier", + "decorators": [], + "name": "c", + "optional": false, + "range": [ + 19, + 20 + ], + "loc": { "end": { "line": 2, - "column": 12 + "column": 9 + }, + "start": { + "line": 2, + "column": 8 } } }, - "mode": "r" + "mode": "r", + "isValueReference": false, + "isTypeReference": true } ] }, @@ -793,165 +867,165 @@ }, { "type": "Identifier", - "value": "a", + "loc": { + "end": { + "line": 2, + "column": 5 + }, + "start": { + "line": 2, + "column": 4 + } + }, "range": [ 15, 16 ], + "value": "a" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 4 + "column": 6 }, - "end": { + "start": { "line": 2, "column": 5 } - } - }, - { - "type": "Punctuator", - "value": "<", + }, "range": [ 16, 17 ], + "value": "<" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 2, - "column": 5 + "column": 7 }, - "end": { + "start": { "line": 2, "column": 6 } - } - }, - { - "type": "Identifier", - "value": "b", + }, "range": [ 17, 18 ], + "value": "b" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 6 + "column": 8 }, - "end": { + "start": { "line": 2, "column": 7 } - } - }, - { - "type": "Punctuator", - "value": "|", + }, "range": [ 18, 19 ], + "value": "|" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 2, - "column": 7 + "column": 9 }, - "end": { + "start": { "line": 2, "column": 8 } - } - }, - { - "type": "Identifier", - "value": "c", + }, "range": [ 19, 20 ], + "value": "c" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 8 + "column": 10 }, - "end": { + "start": { "line": 2, "column": 9 } - } - }, - { - "type": "Punctuator", - "value": ">", + }, "range": [ 20, 21 ], + "value": ">" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 9 + "column": 11 }, - "end": { + "start": { "line": 2, "column": 10 } - } - }, - { - "type": "Punctuator", - "value": "(", + }, "range": [ 21, 22 ], + "value": "(" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 2, - "column": 10 + "column": 12 }, - "end": { + "start": { "line": 2, "column": 11 } - } - }, - { - "type": "Identifier", - "value": "d", + }, "range": [ 22, 23 ], + "value": "d" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 11 + "column": 13 }, - "end": { + "start": { "line": 2, "column": 12 } - } - }, - { - "type": "Punctuator", - "value": ")", + }, "range": [ 23, 24 ], - "loc": { - "start": { - "line": 2, - "column": 12 - }, - "end": { - "line": 2, - "column": 13 - } - } + "value": ")" }, { "type": "VExpressionEnd", diff --git a/test/fixtures/ast/parser-option-multiple-parsers-1/services.json b/test/fixtures/ast/parser-option-multiple-parsers-1/services.json index 7159ba5a..7f661a33 100644 --- a/test/fixtures/ast/parser-option-multiple-parsers-1/services.json +++ b/test/fixtures/ast/parser-option-multiple-parsers-1/services.json @@ -2,10 +2,12 @@ "defineCustomBlocksVisitor", "defineDocumentVisitor", "defineTemplateBodyVisitor", + "emitDecoratorMetadata", "esTreeNodeToTSNodeMap", + "experimentalDecorators", "getDocumentFragment", "getTemplateBodyTokenStore", - "hasFullTypeInformation", + "isolatedDeclarations", "program", "tsNodeToESTreeNodeMap" ] \ No newline at end of file diff --git a/test/fixtures/ast/parser-option-multiple-parsers-3/ast.json b/test/fixtures/ast/parser-option-multiple-parsers-3/ast.json index b3dadbb8..83f26de3 100644 --- a/test/fixtures/ast/parser-option-multiple-parsers-3/ast.json +++ b/test/fixtures/ast/parser-option-multiple-parsers-3/ast.json @@ -1,64 +1,58 @@ { "type": "Program", + "range": [ + 60, + 70 + ], "body": [ { "type": "ExpressionStatement", "expression": { "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "a", - "range": [ - 60, - 61 - ], - "loc": { - "start": { - "line": 5, - "column": 2 - }, - "end": { - "line": 5, - "column": 3 - } - } - }, "arguments": [ { "type": "Identifier", + "decorators": [], "name": "d", + "optional": false, "range": [ 67, 68 ], "loc": { - "start": { - "line": 5, - "column": 9 - }, "end": { "line": 5, "column": 10 + }, + "start": { + "line": 5, + "column": 9 } } } ], - "optional": false, - "range": [ - 60, - 69 - ], - "loc": { - "start": { - "line": 5, - "column": 2 - }, - "end": { - "line": 5, - "column": 11 + "callee": { + "type": "Identifier", + "decorators": [], + "name": "a", + "optional": false, + "range": [ + 60, + 61 + ], + "loc": { + "end": { + "line": 5, + "column": 3 + }, + "start": { + "line": 5, + "column": 2 + } } }, - "typeParameters": { + "optional": false, + "typeArguments": { "type": "TSTypeParameterInstantiation", "range": [ 61, @@ -72,19 +66,21 @@ "type": "TSTypeReference", "typeName": { "type": "Identifier", + "decorators": [], "name": "b", + "optional": false, "range": [ 62, 63 ], "loc": { - "start": { - "line": 5, - "column": 4 - }, "end": { "line": 5, "column": 5 + }, + "start": { + "line": 5, + "column": 4 } } }, @@ -93,13 +89,13 @@ 63 ], "loc": { - "start": { - "line": 5, - "column": 4 - }, "end": { "line": 5, "column": 5 + }, + "start": { + "line": 5, + "column": 4 } } }, @@ -107,19 +103,21 @@ "type": "TSTypeReference", "typeName": { "type": "Identifier", + "decorators": [], "name": "c", + "optional": false, "range": [ 64, 65 ], "loc": { - "start": { - "line": 5, - "column": 6 - }, "end": { "line": 5, "column": 7 + }, + "start": { + "line": 5, + "column": 6 } } }, @@ -128,13 +126,13 @@ 65 ], "loc": { - "start": { - "line": 5, - "column": 6 - }, "end": { "line": 5, "column": 7 + }, + "start": { + "line": 5, + "column": 6 } } } @@ -144,27 +142,41 @@ 65 ], "loc": { - "start": { - "line": 5, - "column": 4 - }, "end": { "line": 5, "column": 7 + }, + "start": { + "line": 5, + "column": 4 } } } ], "loc": { - "start": { - "line": 5, - "column": 3 - }, "end": { "line": 5, "column": 8 + }, + "start": { + "line": 5, + "column": 3 } } + }, + "range": [ + 60, + 69 + ], + "loc": { + "end": { + "line": 5, + "column": 11 + }, + "start": { + "line": 5, + "column": 2 + } } }, "range": [ @@ -172,32 +184,19 @@ 69 ], "loc": { - "start": { - "line": 5, - "column": 2 - }, "end": { "line": 5, "column": 11 + }, + "start": { + "line": 5, + "column": 2 } } } ], + "comments": [], "sourceType": "module", - "range": [ - 60, - 70 - ], - "loc": { - "start": { - "line": 5, - "column": 2 - }, - "end": { - "line": 6, - "column": 0 - } - }, "tokens": [ { "type": "Punctuator", @@ -219,165 +218,165 @@ }, { "type": "Identifier", - "value": "a", + "loc": { + "end": { + "line": 5, + "column": 3 + }, + "start": { + "line": 5, + "column": 2 + } + }, "range": [ 60, 61 ], + "value": "a" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 2 + "column": 4 }, - "end": { + "start": { "line": 5, "column": 3 } - } - }, - { - "type": "Punctuator", - "value": "<", + }, "range": [ 61, 62 ], + "value": "<" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 5, - "column": 3 + "column": 5 }, - "end": { + "start": { "line": 5, "column": 4 } - } - }, - { - "type": "Identifier", - "value": "b", + }, "range": [ 62, 63 ], + "value": "b" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 4 + "column": 6 }, - "end": { + "start": { "line": 5, "column": 5 } - } - }, - { - "type": "Punctuator", - "value": "|", + }, "range": [ 63, 64 ], + "value": "|" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 5, - "column": 5 + "column": 7 }, - "end": { + "start": { "line": 5, "column": 6 } - } - }, - { - "type": "Identifier", - "value": "c", + }, "range": [ 64, 65 ], + "value": "c" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 6 + "column": 8 }, - "end": { + "start": { "line": 5, "column": 7 } - } - }, - { - "type": "Punctuator", - "value": ">", + }, "range": [ 65, 66 ], + "value": ">" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 7 + "column": 9 }, - "end": { + "start": { "line": 5, "column": 8 } - } - }, - { - "type": "Punctuator", - "value": "(", + }, "range": [ 66, 67 ], + "value": "(" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 5, - "column": 8 + "column": 10 }, - "end": { + "start": { "line": 5, "column": 9 } - } - }, - { - "type": "Identifier", - "value": "d", + }, "range": [ 67, 68 ], + "value": "d" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 9 + "column": 11 }, - "end": { + "start": { "line": 5, "column": 10 } - } - }, - { - "type": "Punctuator", - "value": ")", + }, "range": [ 68, 69 ], - "loc": { - "start": { - "line": 5, - "column": 10 - }, - "end": { - "line": 5, - "column": 11 - } - } + "value": ")" }, { "type": "Punctuator", @@ -398,7 +397,16 @@ "value": "" } ], - "comments": [], + "loc": { + "end": { + "line": 6, + "column": 0 + }, + "start": { + "line": 5, + "column": 2 + } + }, "templateBody": { "type": "VElement", "range": [ diff --git a/test/fixtures/ast/parser-option-multiple-parsers-3/services.json b/test/fixtures/ast/parser-option-multiple-parsers-3/services.json index 7159ba5a..7f661a33 100644 --- a/test/fixtures/ast/parser-option-multiple-parsers-3/services.json +++ b/test/fixtures/ast/parser-option-multiple-parsers-3/services.json @@ -2,10 +2,12 @@ "defineCustomBlocksVisitor", "defineDocumentVisitor", "defineTemplateBodyVisitor", + "emitDecoratorMetadata", "esTreeNodeToTSNodeMap", + "experimentalDecorators", "getDocumentFragment", "getTemplateBodyTokenStore", - "hasFullTypeInformation", + "isolatedDeclarations", "program", "tsNodeToESTreeNodeMap" ] \ No newline at end of file diff --git a/test/fixtures/ast/parser-option-multiple-parsers-without-script/ast.json b/test/fixtures/ast/parser-option-multiple-parsers-without-script/ast.json index b7deda38..bfb9997e 100644 --- a/test/fixtures/ast/parser-option-multiple-parsers-without-script/ast.json +++ b/test/fixtures/ast/parser-option-multiple-parsers-without-script/ast.json @@ -1,23 +1,23 @@ { "type": "Program", - "body": [], - "sourceType": "module", "range": [ 0, 0 ], + "body": [], + "comments": [], + "sourceType": "module", + "tokens": [], "loc": { - "start": { - "line": 1, - "column": 0 - }, "end": { - "line": 1, - "column": 0 + "column": 0, + "line": 1 + }, + "start": { + "column": 0, + "line": 1 } }, - "tokens": [], - "comments": [], "templateBody": { "type": "VElement", "range": [ @@ -93,60 +93,50 @@ }, "expression": { "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "a", - "range": [ - 15, - 16 - ], - "loc": { - "start": { - "line": 2, - "column": 4 - }, - "end": { - "line": 2, - "column": 5 - } - } - }, "arguments": [ { "type": "Identifier", + "decorators": [], "name": "d", + "optional": false, "range": [ 22, 23 ], "loc": { - "start": { - "line": 2, - "column": 11 - }, "end": { "line": 2, "column": 12 + }, + "start": { + "line": 2, + "column": 11 } } } ], - "optional": false, - "range": [ - 15, - 24 - ], - "loc": { - "start": { - "line": 2, - "column": 4 - }, - "end": { - "line": 2, - "column": 13 + "callee": { + "type": "Identifier", + "decorators": [], + "name": "a", + "optional": false, + "range": [ + 15, + 16 + ], + "loc": { + "end": { + "line": 2, + "column": 5 + }, + "start": { + "line": 2, + "column": 4 + } } }, - "typeParameters": { + "optional": false, + "typeArguments": { "type": "TSTypeParameterInstantiation", "range": [ 16, @@ -160,19 +150,21 @@ "type": "TSTypeReference", "typeName": { "type": "Identifier", + "decorators": [], "name": "b", + "optional": false, "range": [ 17, 18 ], "loc": { - "start": { - "line": 2, - "column": 6 - }, "end": { "line": 2, "column": 7 + }, + "start": { + "line": 2, + "column": 6 } } }, @@ -181,13 +173,13 @@ 18 ], "loc": { - "start": { - "line": 2, - "column": 6 - }, "end": { "line": 2, "column": 7 + }, + "start": { + "line": 2, + "column": 6 } } }, @@ -195,19 +187,21 @@ "type": "TSTypeReference", "typeName": { "type": "Identifier", + "decorators": [], "name": "c", + "optional": false, "range": [ 19, 20 ], "loc": { - "start": { - "line": 2, - "column": 8 - }, "end": { "line": 2, "column": 9 + }, + "start": { + "line": 2, + "column": 8 } } }, @@ -216,13 +210,13 @@ 20 ], "loc": { - "start": { - "line": 2, - "column": 8 - }, "end": { "line": 2, "column": 9 + }, + "start": { + "line": 2, + "column": 8 } } } @@ -232,71 +226,143 @@ 20 ], "loc": { - "start": { - "line": 2, - "column": 6 - }, "end": { "line": 2, "column": 9 + }, + "start": { + "line": 2, + "column": 6 } } } ], "loc": { - "start": { - "line": 2, - "column": 5 - }, "end": { "line": 2, "column": 10 + }, + "start": { + "line": 2, + "column": 5 } } + }, + "range": [ + 15, + 24 + ], + "loc": { + "end": { + "line": 2, + "column": 13 + }, + "start": { + "line": 2, + "column": 4 + } } }, "references": [ { "id": { "type": "Identifier", + "decorators": [], "name": "a", + "optional": false, "range": [ 15, 16 ], "loc": { - "start": { - "line": 2, - "column": 4 - }, "end": { "line": 2, "column": 5 + }, + "start": { + "line": 2, + "column": 4 } } }, - "mode": "r" + "mode": "r", + "isValueReference": true, + "isTypeReference": false }, { "id": { "type": "Identifier", + "decorators": [], "name": "d", + "optional": false, "range": [ 22, 23 ], "loc": { + "end": { + "line": 2, + "column": 12 + }, "start": { "line": 2, "column": 11 + } + } + }, + "mode": "r", + "isValueReference": true, + "isTypeReference": false + }, + { + "id": { + "type": "Identifier", + "decorators": [], + "name": "b", + "optional": false, + "range": [ + 17, + 18 + ], + "loc": { + "end": { + "line": 2, + "column": 7 }, + "start": { + "line": 2, + "column": 6 + } + } + }, + "mode": "r", + "isValueReference": false, + "isTypeReference": true + }, + { + "id": { + "type": "Identifier", + "decorators": [], + "name": "c", + "optional": false, + "range": [ + 19, + 20 + ], + "loc": { "end": { "line": 2, - "column": 12 + "column": 9 + }, + "start": { + "line": 2, + "column": 8 } } }, - "mode": "r" + "mode": "r", + "isValueReference": false, + "isTypeReference": true } ] }, @@ -412,165 +478,165 @@ }, { "type": "Identifier", - "value": "a", + "loc": { + "end": { + "line": 2, + "column": 5 + }, + "start": { + "line": 2, + "column": 4 + } + }, "range": [ 15, 16 ], + "value": "a" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 4 + "column": 6 }, - "end": { + "start": { "line": 2, "column": 5 } - } - }, - { - "type": "Punctuator", - "value": "<", + }, "range": [ 16, 17 ], + "value": "<" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 2, - "column": 5 + "column": 7 }, - "end": { + "start": { "line": 2, "column": 6 } - } - }, - { - "type": "Identifier", - "value": "b", + }, "range": [ 17, 18 ], + "value": "b" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 6 + "column": 8 }, - "end": { + "start": { "line": 2, "column": 7 } - } - }, - { - "type": "Punctuator", - "value": "|", + }, "range": [ 18, 19 ], + "value": "|" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 2, - "column": 7 + "column": 9 }, - "end": { + "start": { "line": 2, "column": 8 } - } - }, - { - "type": "Identifier", - "value": "c", + }, "range": [ 19, 20 ], + "value": "c" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 8 + "column": 10 }, - "end": { + "start": { "line": 2, "column": 9 } - } - }, - { - "type": "Punctuator", - "value": ">", + }, "range": [ 20, 21 ], + "value": ">" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 9 + "column": 11 }, - "end": { + "start": { "line": 2, "column": 10 } - } - }, - { - "type": "Punctuator", - "value": "(", + }, "range": [ 21, 22 ], + "value": "(" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 2, - "column": 10 + "column": 12 }, - "end": { + "start": { "line": 2, "column": 11 } - } - }, - { - "type": "Identifier", - "value": "d", + }, "range": [ 22, 23 ], + "value": "d" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 11 + "column": 13 }, - "end": { + "start": { "line": 2, "column": 12 } - } - }, - { - "type": "Punctuator", - "value": ")", + }, "range": [ 23, 24 ], - "loc": { - "start": { - "line": 2, - "column": 12 - }, - "end": { - "line": 2, - "column": 13 - } - } + "value": ")" }, { "type": "VExpressionEnd", diff --git a/test/fixtures/ast/parser-option-multiple-parsers-without-script/services.json b/test/fixtures/ast/parser-option-multiple-parsers-without-script/services.json index 7159ba5a..7f661a33 100644 --- a/test/fixtures/ast/parser-option-multiple-parsers-without-script/services.json +++ b/test/fixtures/ast/parser-option-multiple-parsers-without-script/services.json @@ -2,10 +2,12 @@ "defineCustomBlocksVisitor", "defineDocumentVisitor", "defineTemplateBodyVisitor", + "emitDecoratorMetadata", "esTreeNodeToTSNodeMap", + "experimentalDecorators", "getDocumentFragment", "getTemplateBodyTokenStore", - "hasFullTypeInformation", + "isolatedDeclarations", "program", "tsNodeToESTreeNodeMap" ] \ No newline at end of file diff --git a/test/fixtures/ast/pug/ast.json b/test/fixtures/ast/pug/ast.json index 0905cb4d..a10daf83 100644 --- a/test/fixtures/ast/pug/ast.json +++ b/test/fixtures/ast/pug/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [] } \ No newline at end of file diff --git a/test/fixtures/ast/raw-names/ast.json b/test/fixtures/ast/raw-names/ast.json index de79e673..c8a2e087 100644 --- a/test/fixtures/ast/raw-names/ast.json +++ b/test/fixtures/ast/raw-names/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/rawtext/ast.json b/test/fixtures/ast/rawtext/ast.json index 290dd4ec..d0eea386 100644 --- a/test/fixtures/ast/rawtext/ast.json +++ b/test/fixtures/ast/rawtext/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/script-setup-example01/ast.json b/test/fixtures/ast/script-setup-example01/ast.json index e4d8d462..d9adadbf 100644 --- a/test/fixtures/ast/script-setup-example01/ast.json +++ b/test/fixtures/ast/script-setup-example01/ast.json @@ -96,7 +96,8 @@ ], "value": "./Foo.vue", "raw": "'./Foo.vue'" - } + }, + "attributes": [] }, { "type": "ImportDeclaration", @@ -197,7 +198,8 @@ ], "value": "vue", "raw": "'vue'" - } + }, + "attributes": [] }, { "type": "VariableDeclaration", diff --git a/test/fixtures/ast/script-setup-example05/ast.json b/test/fixtures/ast/script-setup-example05/ast.json index d179c1df..a187f101 100644 --- a/test/fixtures/ast/script-setup-example05/ast.json +++ b/test/fixtures/ast/script-setup-example05/ast.json @@ -96,7 +96,8 @@ ], "value": "./Foo.vue", "raw": "'./Foo.vue'" - } + }, + "attributes": [] }, { "type": "ImportDeclaration", @@ -177,7 +178,8 @@ ], "value": "./MyComponent.vue", "raw": "'./MyComponent.vue'" - } + }, + "attributes": [] } ], "sourceType": "module", diff --git a/test/fixtures/ast/script-setup-example06/ast.json b/test/fixtures/ast/script-setup-example06/ast.json index 9b8daba2..e07644fb 100644 --- a/test/fixtures/ast/script-setup-example06/ast.json +++ b/test/fixtures/ast/script-setup-example06/ast.json @@ -96,7 +96,8 @@ ], "value": "./Foo.vue", "raw": "'./Foo.vue'" - } + }, + "attributes": [] }, { "type": "ImportDeclaration", @@ -177,7 +178,8 @@ ], "value": "./Bar.vue", "raw": "'./Bar.vue'" - } + }, + "attributes": [] } ], "sourceType": "module", diff --git a/test/fixtures/ast/script-setup-example07/ast.json b/test/fixtures/ast/script-setup-example07/ast.json index 46ad7ed6..1f16bdb6 100644 --- a/test/fixtures/ast/script-setup-example07/ast.json +++ b/test/fixtures/ast/script-setup-example07/ast.json @@ -116,7 +116,8 @@ ], "value": "v-click-outside", "raw": "'v-click-outside'" - } + }, + "attributes": [] } ], "sourceType": "module", diff --git a/test/fixtures/ast/script-setup-example09/ast.json b/test/fixtures/ast/script-setup-example09/ast.json index 8cc45989..02ac7838 100644 --- a/test/fixtures/ast/script-setup-example09/ast.json +++ b/test/fixtures/ast/script-setup-example09/ast.json @@ -175,7 +175,8 @@ ], "value": "vue", "raw": "'vue'" - } + }, + "attributes": [] }, { "type": "VariableDeclaration", diff --git a/test/fixtures/ast/script-setup-example13/ast.json b/test/fixtures/ast/script-setup-example13/ast.json index 6a67da3b..8e2d4fe6 100644 --- a/test/fixtures/ast/script-setup-example13/ast.json +++ b/test/fixtures/ast/script-setup-example13/ast.json @@ -340,7 +340,6 @@ ], "name": "a" }, - "kind": "init", "value": { "type": "Identifier", "start": 62, @@ -360,7 +359,8 @@ 63 ], "name": "a" - } + }, + "kind": "init" }, { "type": "Property", @@ -403,7 +403,6 @@ ], "name": "b" }, - "kind": "init", "value": { "type": "Identifier", "start": 67, @@ -423,7 +422,8 @@ 68 ], "name": "b" - } + }, + "kind": "init" } ] } diff --git a/test/fixtures/ast/script-setup-example14/ast.json b/test/fixtures/ast/script-setup-example14/ast.json index 03765608..288e20da 100644 --- a/test/fixtures/ast/script-setup-example14/ast.json +++ b/test/fixtures/ast/script-setup-example14/ast.json @@ -178,7 +178,8 @@ "kind": "const" }, "specifiers": [], - "source": null + "source": null, + "attributes": [] }, { "type": "VariableDeclaration", diff --git a/test/fixtures/ast/script-setup-with-export/ast.json b/test/fixtures/ast/script-setup-with-export/ast.json index 932e9dd3..f97586b0 100644 --- a/test/fixtures/ast/script-setup-with-export/ast.json +++ b/test/fixtures/ast/script-setup-with-export/ast.json @@ -118,7 +118,8 @@ "kind": "let" }, "specifiers": [], - "source": null + "source": null, + "attributes": [] } ], "sourceType": "module", diff --git a/test/fixtures/ast/self-closing-elements/ast.json b/test/fixtures/ast/self-closing-elements/ast.json index ff1cbfb7..68aecb41 100644 --- a/test/fixtures/ast/self-closing-elements/ast.json +++ b/test/fixtures/ast/self-closing-elements/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/slot-scope-default/ast.json b/test/fixtures/ast/slot-scope-default/ast.json index cb985254..1dadf2d4 100644 --- a/test/fixtures/ast/slot-scope-default/ast.json +++ b/test/fixtures/ast/slot-scope-default/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/slot-scope-destructuring/ast.json b/test/fixtures/ast/slot-scope-destructuring/ast.json index b7360160..9ef5942d 100644 --- a/test/fixtures/ast/slot-scope-destructuring/ast.json +++ b/test/fixtures/ast/slot-scope-destructuring/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { @@ -319,7 +319,6 @@ ], "name": "a" }, - "kind": "init", "value": { "type": "Identifier", "start": 58, @@ -339,7 +338,8 @@ 59 ], "name": "a" - } + }, + "kind": "init" }, { "type": "Property", @@ -382,7 +382,6 @@ ], "name": "b" }, - "kind": "init", "value": { "type": "Identifier", "start": 61, @@ -402,7 +401,8 @@ 62 ], "name": "b" - } + }, + "kind": "init" }, { "type": "RestElement", diff --git a/test/fixtures/ast/slot-scope-multi-parameters/ast.json b/test/fixtures/ast/slot-scope-multi-parameters/ast.json index 4fe53628..a34a8fca 100644 --- a/test/fixtures/ast/slot-scope-multi-parameters/ast.json +++ b/test/fixtures/ast/slot-scope-multi-parameters/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/slot-scope-rest-parameter/ast.json b/test/fixtures/ast/slot-scope-rest-parameter/ast.json index 9a9e0e0e..9a2ed552 100644 --- a/test/fixtures/ast/slot-scope-rest-parameter/ast.json +++ b/test/fixtures/ast/slot-scope-rest-parameter/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/slot-scope/ast.json b/test/fixtures/ast/slot-scope/ast.json index c888fc67..ecf8d2f1 100644 --- a/test/fixtures/ast/slot-scope/ast.json +++ b/test/fixtures/ast/slot-scope/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/svg-attrs-camel-case/ast.json b/test/fixtures/ast/svg-attrs-camel-case/ast.json index 1e3a6aa0..3a3a3927 100644 --- a/test/fixtures/ast/svg-attrs-camel-case/ast.json +++ b/test/fixtures/ast/svg-attrs-camel-case/ast.json @@ -138,7 +138,7 @@ } } ], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [ { diff --git a/test/fixtures/ast/svg-attrs-colon/ast.json b/test/fixtures/ast/svg-attrs-colon/ast.json index b5a4c622..46367cd4 100644 --- a/test/fixtures/ast/svg-attrs-colon/ast.json +++ b/test/fixtures/ast/svg-attrs-colon/ast.json @@ -138,7 +138,7 @@ } } ], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [ { diff --git a/test/fixtures/ast/svg-namespace/ast.json b/test/fixtures/ast/svg-namespace/ast.json index 68f9c796..ce6d4e1b 100644 --- a/test/fixtures/ast/svg-namespace/ast.json +++ b/test/fixtures/ast/svg-namespace/ast.json @@ -138,7 +138,7 @@ } } ], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [ { diff --git a/test/fixtures/ast/svg-upper/ast.json b/test/fixtures/ast/svg-upper/ast.json index 24ac6fb7..26e58850 100644 --- a/test/fixtures/ast/svg-upper/ast.json +++ b/test/fixtures/ast/svg-upper/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/table/ast.json b/test/fixtures/ast/table/ast.json index 5baa64c5..f0488a41 100644 --- a/test/fixtures/ast/table/ast.json +++ b/test/fixtures/ast/table/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/text-and-expression-container/ast.json b/test/fixtures/ast/text-and-expression-container/ast.json index 3983af11..233bcc06 100644 --- a/test/fixtures/ast/text-and-expression-container/ast.json +++ b/test/fixtures/ast/text-and-expression-container/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/text/ast.json b/test/fixtures/ast/text/ast.json index ffb6c8b5..d529f26e 100644 --- a/test/fixtures/ast/text/ast.json +++ b/test/fixtures/ast/text/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/textarea/ast.json b/test/fixtures/ast/textarea/ast.json index 8e1cd026..793c9979 100644 --- a/test/fixtures/ast/textarea/ast.json +++ b/test/fixtures/ast/textarea/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/ts-script-setup-with-use-global-var/ast.json b/test/fixtures/ast/ts-script-setup-with-use-global-var/ast.json new file mode 100644 index 00000000..5f70958e --- /dev/null +++ b/test/fixtures/ast/ts-script-setup-with-use-global-var/ast.json @@ -0,0 +1,1085 @@ +{ + "type": "Program", + "range": [ + 116, + 116 + ], + "body": [], + "comments": [], + "sourceType": "module", + "tokens": [ + { + "type": "Punctuator", + "range": [ + 91, + 115 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 24 + } + }, + "value": "" + } + ], + "loc": { + "end": { + "line": 8, + "column": 0 + }, + "start": { + "line": 8, + "column": 0 + } + }, + "templateBody": { + "type": "VElement", + "range": [ + 0, + 89 + ], + "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, + 77 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 4, + "column": 10 + } + }, + "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": "VText", + "range": [ + 20, + 29 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "value": "\n " + }, + { + "type": "VExpressionContainer", + "range": [ + 29, + 66 + ], + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 45 + } + }, + "expression": { + "type": "CallExpression", + "arguments": [ + { + "type": "ObjectExpression", + "properties": [ + { + "type": "Property", + "computed": false, + "key": { + "type": "Identifier", + "decorators": [], + "name": "test", + "optional": false, + "range": [ + 49, + 53 + ], + "loc": { + "end": { + "line": 3, + "column": 32 + }, + "start": { + "line": 3, + "column": 28 + } + } + }, + "kind": "init", + "method": false, + "optional": false, + "shorthand": false, + "value": { + "type": "Literal", + "raw": "'test'", + "value": "test", + "range": [ + 55, + 61 + ], + "loc": { + "end": { + "line": 3, + "column": 40 + }, + "start": { + "line": 3, + "column": 34 + } + } + }, + "range": [ + 49, + 61 + ], + "loc": { + "end": { + "line": 3, + "column": 40 + }, + "start": { + "line": 3, + "column": 28 + } + } + } + ], + "range": [ + 47, + 62 + ], + "loc": { + "end": { + "line": 3, + "column": 41 + }, + "start": { + "line": 3, + "column": 26 + } + } + } + ], + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "decorators": [], + "name": "JSON", + "optional": false, + "range": [ + 32, + 36 + ], + "loc": { + "end": { + "line": 3, + "column": 15 + }, + "start": { + "line": 3, + "column": 11 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "decorators": [], + "name": "stringify", + "optional": false, + "range": [ + 37, + 46 + ], + "loc": { + "end": { + "line": 3, + "column": 25 + }, + "start": { + "line": 3, + "column": 16 + } + } + }, + "range": [ + 32, + 46 + ], + "loc": { + "end": { + "line": 3, + "column": 25 + }, + "start": { + "line": 3, + "column": 11 + } + } + }, + "optional": false, + "range": [ + 32, + 63 + ], + "loc": { + "end": { + "line": 3, + "column": 42 + }, + "start": { + "line": 3, + "column": 11 + } + } + }, + "references": [ + { + "id": { + "type": "Identifier", + "decorators": [], + "name": "JSON", + "optional": false, + "range": [ + 32, + 36 + ], + "loc": { + "end": { + "line": 3, + "column": 15 + }, + "start": { + "line": 3, + "column": 11 + } + } + }, + "mode": "r", + "isValueReference": true, + "isTypeReference": false + } + ] + }, + { + "type": "VText", + "range": [ + 66, + 71 + ], + "loc": { + "start": { + "line": 3, + "column": 45 + }, + "end": { + "line": 4, + "column": 4 + } + }, + "value": "\n " + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 71, + 77 + ], + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 10 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 77, + 78 + ], + "loc": { + "start": { + "line": 4, + "column": 10 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 78, + 89 + ], + "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, + 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": "HTMLWhitespace", + "range": [ + 20, + 29 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "value": "\n " + }, + { + "type": "VExpressionStart", + "range": [ + 29, + 31 + ], + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 10 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 3, + "column": 15 + }, + "start": { + "line": 3, + "column": 11 + } + }, + "range": [ + 32, + 36 + ], + "value": "JSON" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 16 + }, + "start": { + "line": 3, + "column": 15 + } + }, + "range": [ + 36, + 37 + ], + "value": "." + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 3, + "column": 25 + }, + "start": { + "line": 3, + "column": 16 + } + }, + "range": [ + 37, + 46 + ], + "value": "stringify" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 26 + }, + "start": { + "line": 3, + "column": 25 + } + }, + "range": [ + 46, + 47 + ], + "value": "(" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 27 + }, + "start": { + "line": 3, + "column": 26 + } + }, + "range": [ + 47, + 48 + ], + "value": "{" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 3, + "column": 32 + }, + "start": { + "line": 3, + "column": 28 + } + }, + "range": [ + 49, + 53 + ], + "value": "test" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 33 + }, + "start": { + "line": 3, + "column": 32 + } + }, + "range": [ + 53, + 54 + ], + "value": ":" + }, + { + "type": "String", + "loc": { + "end": { + "line": 3, + "column": 40 + }, + "start": { + "line": 3, + "column": 34 + } + }, + "range": [ + 55, + 61 + ], + "value": "'test'" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 41 + }, + "start": { + "line": 3, + "column": 40 + } + }, + "range": [ + 61, + 62 + ], + "value": "}" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 42 + }, + "start": { + "line": 3, + "column": 41 + } + }, + "range": [ + 62, + 63 + ], + "value": ")" + }, + { + "type": "VExpressionEnd", + "range": [ + 64, + 66 + ], + "loc": { + "start": { + "line": 3, + "column": 43 + }, + "end": { + "line": 3, + "column": 45 + } + }, + "value": "}}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 66, + 71 + ], + "loc": { + "start": { + "line": 3, + "column": 45 + }, + "end": { + "line": 4, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 71, + 76 + ], + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 9 + } + }, + "value": "div" + }, + { + "type": "HTMLTagClose", + "range": [ + 76, + 77 + ], + "loc": { + "start": { + "line": 4, + "column": 9 + }, + "end": { + "line": 4, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 77, + 78 + ], + "loc": { + "start": { + "line": 4, + "column": 10 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 78, + 88 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 88, + 89 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 11 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 89, + 91 + ], + "loc": { + "start": { + "line": 5, + "column": 11 + }, + "end": { + "line": 7, + "column": 0 + } + }, + "value": "\n\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 91, + 98 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLIdentifier", + "range": [ + 99, + 103 + ], + "loc": { + "start": { + "line": 7, + "column": 8 + }, + "end": { + "line": 7, + "column": 12 + } + }, + "value": "lang" + }, + { + "type": "HTMLAssociation", + "range": [ + 103, + 104 + ], + "loc": { + "start": { + "line": 7, + "column": 12 + }, + "end": { + "line": 7, + "column": 13 + } + }, + "value": "" + }, + { + "type": "HTMLLiteral", + "range": [ + 104, + 108 + ], + "loc": { + "start": { + "line": 7, + "column": 13 + }, + "end": { + "line": 7, + "column": 17 + } + }, + "value": "ts" + }, + { + "type": "HTMLIdentifier", + "range": [ + 109, + 114 + ], + "loc": { + "start": { + "line": 7, + "column": 18 + }, + "end": { + "line": 7, + "column": 23 + } + }, + "value": "setup" + }, + { + "type": "HTMLTagClose", + "range": [ + 114, + 115 + ], + "loc": { + "start": { + "line": 7, + "column": 23 + }, + "end": { + "line": 7, + "column": 24 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 115, + 116 + ], + "loc": { + "start": { + "line": 7, + "column": 24 + }, + "end": { + "line": 8, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 116, + 124 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 124, + 125 + ], + "loc": { + "start": { + "line": 8, + "column": 8 + }, + "end": { + "line": 8, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 125, + 126 + ], + "loc": { + "start": { + "line": 8, + "column": 9 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "value": "\n" + } + ], + "comments": [], + "errors": [] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/ts-script-setup-with-use-global-var/parser-options.json b/test/fixtures/ast/ts-script-setup-with-use-global-var/parser-options.json new file mode 100644 index 00000000..0ead30e9 --- /dev/null +++ b/test/fixtures/ast/ts-script-setup-with-use-global-var/parser-options.json @@ -0,0 +1,6 @@ +{ + "sourceType": "module", + "parser": { + "ts": "@typescript-eslint/parser" + } +} diff --git a/test/fixtures/ast/ts-script-setup-with-use-global-var/scope.json b/test/fixtures/ast/ts-script-setup-with-use-global-var/scope.json new file mode 100644 index 00000000..3849ae94 --- /dev/null +++ b/test/fixtures/ast/ts-script-setup-with-use-global-var/scope.json @@ -0,0 +1,1174 @@ +{ + "type": "global", + "variables": [ + { + "name": "Intl", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SymbolConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Function", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Disposable", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncDisposable", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SuppressedError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SuppressedErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "DisposableStack", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "DisposableStackConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncDisposableStack", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncDisposableStackConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "IteratorObject", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncIteratorObject", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ReadonlySetLike", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Set", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ReadonlySet", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Iterator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "IteratorObjectConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PromiseConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Float16Array", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Float16ArrayConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Math", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "DataView", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayBuffer", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayBufferConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "MapConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ObjectConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PromiseWithResolvers", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "RegExp", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Atomics", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SharedArrayBuffer", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SharedArrayBufferConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "String", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassMemberDecoratorContext", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "DecoratorContext", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "DecoratorMetadataObject", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "DecoratorMetadata", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassDecoratorContext", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassMethodDecoratorContext", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassGetterDecoratorContext", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassSetterDecoratorContext", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassAccessorDecoratorContext", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassAccessorDecoratorTarget", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassAccessorDecoratorResult", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassFieldDecoratorContext", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "IteratorYieldResult", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "IteratorReturnResult", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "IteratorResult", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Iterable", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "IterableIterator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "BuiltinIteratorReturn", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayIterator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Array", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ReadonlyArray", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "IArguments", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "MapIterator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Map", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ReadonlyMap", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "WeakMap", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "WeakMapConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SetIterator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SetConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "WeakSet", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "WeakSetConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Promise", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "StringIterator", + "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": "AsyncIterator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncIterable", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncIterableIterator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "BigInt64Array", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "BigUint64Array", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "WeakKeyTypes", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "BigIntToLocaleStringOptions", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "BigInt", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "BigIntConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "BigInt64ArrayConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "BigUint64ArrayConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ErrorOptions", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Error", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "EvalErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "RangeErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ReferenceErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SyntaxErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "TypeErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "URIErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AggregateErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "RegExpMatchArray", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "RegExpExecArray", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "RegExpIndicesArray", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AggregateError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "WeakRef", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "WeakRefConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "FinalizationRegistry", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "FinalizationRegistryConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Date", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Number", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PromiseFulfilledResult", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PromiseRejectedResult", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PromiseSettledResult", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "RegExpStringIterator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Symbol", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "JSON", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "GeneratorFunction", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "RegExpConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "FlatArray", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncGenerator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncGeneratorFunction", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncGeneratorFunctionConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "DateConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayBufferTypes", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PropertyKey", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PropertyDescriptor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PropertyDescriptorMap", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Object", + "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": "StringConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Boolean", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "BooleanConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "NumberConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "TemplateStringsArray", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ImportMeta", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ImportCallOptions", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ImportAssertions", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ImportAttributes", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "EvalError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "RangeError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ReferenceError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SyntaxError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "TypeError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "URIError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ConcatArray", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "TypedPropertyDescriptor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PromiseConstructorLike", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PromiseLike", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Awaited", + "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": "NoInfer", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ThisType", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "WeakKey", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayBufferLike", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayBufferView", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "DataViewConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Generator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "GeneratorFunctionConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ProxyHandler", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ProxyConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Reflect", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassDecorator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PropertyDecorator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "MethodDecorator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ParameterDecorator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "const", + "identifiers": [], + "defs": [], + "references": [] + } + ], + "references": [], + "childScopes": [ + { + "type": "module", + "variables": [], + "references": [], + "childScopes": [], + "through": [] + } + ], + "through": [] +} \ No newline at end of file diff --git a/test/fixtures/ast/ts-script-setup-with-use-global-var/services.json b/test/fixtures/ast/ts-script-setup-with-use-global-var/services.json new file mode 100644 index 00000000..7f661a33 --- /dev/null +++ b/test/fixtures/ast/ts-script-setup-with-use-global-var/services.json @@ -0,0 +1,13 @@ +[ + "defineCustomBlocksVisitor", + "defineDocumentVisitor", + "defineTemplateBodyVisitor", + "emitDecoratorMetadata", + "esTreeNodeToTSNodeMap", + "experimentalDecorators", + "getDocumentFragment", + "getTemplateBodyTokenStore", + "isolatedDeclarations", + "program", + "tsNodeToESTreeNodeMap" +] \ No newline at end of file diff --git a/test/fixtures/ast/ts-script-setup-with-use-global-var/source.vue b/test/fixtures/ast/ts-script-setup-with-use-global-var/source.vue new file mode 100644 index 00000000..32aa1772 --- /dev/null +++ b/test/fixtures/ast/ts-script-setup-with-use-global-var/source.vue @@ -0,0 +1,8 @@ + + + diff --git a/test/fixtures/ast/ts-script-setup-with-use-global-var/token-ranges.json b/test/fixtures/ast/ts-script-setup-with-use-global-var/token-ranges.json new file mode 100644 index 00000000..b5c5f60f --- /dev/null +++ b/test/fixtures/ast/ts-script-setup-with-use-global-var/token-ranges.json @@ -0,0 +1,39 @@ +[ + "", + "", + "\n ", + "", + "\n ", + "{{", + "JSON", + ".", + "stringify", + "(", + "{", + "test", + ":", + "'test'", + "}", + ")", + "}}", + "\n ", + "", + "\n", + "", + "\n\n", + "", + "\n", + "", + "\n" +] \ No newline at end of file diff --git a/test/fixtures/ast/ts-script-setup-with-use-global-var/tree.json b/test/fixtures/ast/ts-script-setup-with-use-global-var/tree.json new file mode 100644 index 00000000..d8308723 --- /dev/null +++ b/test/fixtures/ast/ts-script-setup-with-use-global-var/tree.json @@ -0,0 +1,104 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/ast/user-macro01/ast.json b/test/fixtures/ast/user-macro01/ast.json new file mode 100644 index 00000000..9aaf297b --- /dev/null +++ b/test/fixtures/ast/user-macro01/ast.json @@ -0,0 +1,283 @@ +{ + "type": "Program", + "start": 15, + "end": 38, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 23 + } + }, + "range": [ + 15, + 38 + ], + "body": [ + { + "type": "VariableDeclaration", + "start": 15, + "end": 38, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 23 + } + }, + "range": [ + 15, + 38 + ], + "declarations": [ + { + "type": "VariableDeclarator", + "start": 21, + "end": 38, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 23 + } + }, + "range": [ + 21, + 38 + ], + "id": { + "type": "Identifier", + "start": 21, + "end": 24, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "range": [ + 21, + 24 + ], + "name": "foo" + }, + "init": { + "type": "CallExpression", + "start": 27, + "end": 38, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 23 + } + }, + "range": [ + 27, + 38 + ], + "callee": { + "type": "Identifier", + "start": 27, + "end": 36, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "range": [ + 27, + 36 + ], + "name": "userMacro" + }, + "arguments": [], + "optional": false + } + } + ], + "kind": "const" + } + ], + "sourceType": "module", + "comments": [], + "tokens": [ + { + "type": "Punctuator", + "range": [ + 0, + 14 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "value": "" + } + ] +} \ No newline at end of file diff --git a/test/fixtures/ast/user-macro01/parser-options.json b/test/fixtures/ast/user-macro01/parser-options.json new file mode 100644 index 00000000..c53f27c2 --- /dev/null +++ b/test/fixtures/ast/user-macro01/parser-options.json @@ -0,0 +1,6 @@ +{ + "sourceType": "module", + "vueFeatures": { + "customMacros": ["userMacro"] + } +} diff --git a/test/fixtures/ast/user-macro01/requirements.json b/test/fixtures/ast/user-macro01/requirements.json new file mode 100644 index 00000000..36659b1f --- /dev/null +++ b/test/fixtures/ast/user-macro01/requirements.json @@ -0,0 +1,3 @@ +{ + "eslint": ">=8" +} \ No newline at end of file diff --git a/test/fixtures/ast/user-macro01/scope.json b/test/fixtures/ast/user-macro01/scope.json new file mode 100644 index 00000000..e43b8b3c --- /dev/null +++ b/test/fixtures/ast/user-macro01/scope.json @@ -0,0 +1,184 @@ +{ + "type": "global", + "variables": [ + { + "name": "userMacro", + "identifiers": [], + "defs": [], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "userMacro", + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 21 + } + } + }, + "from": "module", + "init": null + } + ] + } + ], + "references": [], + "childScopes": [ + { + "type": "module", + "variables": [ + { + "name": "foo", + "identifiers": [ + { + "type": "Identifier", + "name": "foo", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 9 + } + } + } + ], + "defs": [ + { + "type": "Variable", + "node": { + "type": "VariableDeclarator", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 23 + } + } + }, + "name": "foo" + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "foo", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 9 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "foo", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 9 + } + } + }, + "init": true + } + ] + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "foo", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 9 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "foo", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 9 + } + } + }, + "init": true + }, + { + "identifier": { + "type": "Identifier", + "name": "userMacro", + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 21 + } + } + }, + "from": "module", + "init": null + } + ], + "childScopes": [], + "through": [ + { + "identifier": { + "type": "Identifier", + "name": "userMacro", + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 21 + } + } + }, + "from": "module", + "init": null + } + ] + } + ], + "through": [] +} \ No newline at end of file diff --git a/test/fixtures/ast/user-macro01/source.vue b/test/fixtures/ast/user-macro01/source.vue new file mode 100644 index 00000000..9990d5a3 --- /dev/null +++ b/test/fixtures/ast/user-macro01/source.vue @@ -0,0 +1,3 @@ + diff --git a/test/fixtures/ast/user-macro01/token-ranges.json b/test/fixtures/ast/user-macro01/token-ranges.json new file mode 100644 index 00000000..7292be36 --- /dev/null +++ b/test/fixtures/ast/user-macro01/token-ranges.json @@ -0,0 +1,10 @@ +[ + "" +] \ No newline at end of file diff --git a/test/fixtures/ast/user-macro01/tree.json b/test/fixtures/ast/user-macro01/tree.json new file mode 100644 index 00000000..0637a088 --- /dev/null +++ b/test/fixtures/ast/user-macro01/tree.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/fixtures/ast/user-macro02-without-option/ast.json b/test/fixtures/ast/user-macro02-without-option/ast.json new file mode 100644 index 00000000..9aaf297b --- /dev/null +++ b/test/fixtures/ast/user-macro02-without-option/ast.json @@ -0,0 +1,283 @@ +{ + "type": "Program", + "start": 15, + "end": 38, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 23 + } + }, + "range": [ + 15, + 38 + ], + "body": [ + { + "type": "VariableDeclaration", + "start": 15, + "end": 38, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 23 + } + }, + "range": [ + 15, + 38 + ], + "declarations": [ + { + "type": "VariableDeclarator", + "start": 21, + "end": 38, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 23 + } + }, + "range": [ + 21, + 38 + ], + "id": { + "type": "Identifier", + "start": 21, + "end": 24, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "range": [ + 21, + 24 + ], + "name": "foo" + }, + "init": { + "type": "CallExpression", + "start": 27, + "end": 38, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 23 + } + }, + "range": [ + 27, + 38 + ], + "callee": { + "type": "Identifier", + "start": 27, + "end": 36, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "range": [ + 27, + 36 + ], + "name": "userMacro" + }, + "arguments": [], + "optional": false + } + } + ], + "kind": "const" + } + ], + "sourceType": "module", + "comments": [], + "tokens": [ + { + "type": "Punctuator", + "range": [ + 0, + 14 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "value": "" + } + ] +} \ No newline at end of file diff --git a/test/fixtures/ast/user-macro02-without-option/parser-options.json b/test/fixtures/ast/user-macro02-without-option/parser-options.json new file mode 100644 index 00000000..2104ca43 --- /dev/null +++ b/test/fixtures/ast/user-macro02-without-option/parser-options.json @@ -0,0 +1,3 @@ +{ + "sourceType": "module" +} diff --git a/test/fixtures/ast/user-macro02-without-option/requirements.json b/test/fixtures/ast/user-macro02-without-option/requirements.json new file mode 100644 index 00000000..36659b1f --- /dev/null +++ b/test/fixtures/ast/user-macro02-without-option/requirements.json @@ -0,0 +1,3 @@ +{ + "eslint": ">=8" +} \ No newline at end of file diff --git a/test/fixtures/ast/user-macro02-without-option/scope.json b/test/fixtures/ast/user-macro02-without-option/scope.json new file mode 100644 index 00000000..f8ecd4a8 --- /dev/null +++ b/test/fixtures/ast/user-macro02-without-option/scope.json @@ -0,0 +1,180 @@ +{ + "type": "global", + "variables": [], + "references": [], + "childScopes": [ + { + "type": "module", + "variables": [ + { + "name": "foo", + "identifiers": [ + { + "type": "Identifier", + "name": "foo", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 9 + } + } + } + ], + "defs": [ + { + "type": "Variable", + "node": { + "type": "VariableDeclarator", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 23 + } + } + }, + "name": "foo" + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "foo", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 9 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "foo", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 9 + } + } + }, + "init": true + } + ] + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "foo", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 9 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "foo", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 9 + } + } + }, + "init": true + }, + { + "identifier": { + "type": "Identifier", + "name": "userMacro", + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 21 + } + } + }, + "from": "module", + "resolved": null, + "init": null + } + ], + "childScopes": [], + "through": [ + { + "identifier": { + "type": "Identifier", + "name": "userMacro", + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 21 + } + } + }, + "from": "module", + "resolved": null, + "init": null + } + ] + } + ], + "through": [ + { + "identifier": { + "type": "Identifier", + "name": "userMacro", + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 21 + } + } + }, + "from": "module", + "resolved": null, + "init": null + } + ] +} \ No newline at end of file diff --git a/test/fixtures/ast/user-macro02-without-option/source.vue b/test/fixtures/ast/user-macro02-without-option/source.vue new file mode 100644 index 00000000..9990d5a3 --- /dev/null +++ b/test/fixtures/ast/user-macro02-without-option/source.vue @@ -0,0 +1,3 @@ + diff --git a/test/fixtures/ast/user-macro02-without-option/token-ranges.json b/test/fixtures/ast/user-macro02-without-option/token-ranges.json new file mode 100644 index 00000000..7292be36 --- /dev/null +++ b/test/fixtures/ast/user-macro02-without-option/token-ranges.json @@ -0,0 +1,10 @@ +[ + "" +] \ No newline at end of file diff --git a/test/fixtures/ast/user-macro02-without-option/tree.json b/test/fixtures/ast/user-macro02-without-option/tree.json new file mode 100644 index 00000000..0637a088 --- /dev/null +++ b/test/fixtures/ast/user-macro02-without-option/tree.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/fixtures/ast/v-bind-prop-shorthand/ast.json b/test/fixtures/ast/v-bind-prop-shorthand/ast.json index ba515f2f..dc3c2610 100644 --- a/test/fixtures/ast/v-bind-prop-shorthand/ast.json +++ b/test/fixtures/ast/v-bind-prop-shorthand/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/v-bind-same-name-shorthand01-script-setup/ast.json b/test/fixtures/ast/v-bind-same-name-shorthand01-script-setup/ast.json new file mode 100644 index 00000000..085e4279 --- /dev/null +++ b/test/fixtures/ast/v-bind-same-name-shorthand01-script-setup/ast.json @@ -0,0 +1,968 @@ +{ + "type": "Program", + "start": 15, + "end": 57, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 42 + } + }, + "range": [ + 15, + 57 + ], + "body": [ + { + "type": "VariableDeclaration", + "start": 15, + "end": 57, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 42 + } + }, + "range": [ + 15, + 57 + ], + "declarations": [ + { + "type": "VariableDeclarator", + "start": 21, + "end": 57, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 42 + } + }, + "range": [ + 21, + 57 + ], + "id": { + "type": "Identifier", + "start": 21, + "end": 24, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "range": [ + 21, + 24 + ], + "name": "src" + }, + "init": { + "type": "Literal", + "start": 27, + "end": 57, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 42 + } + }, + "range": [ + 27, + 57 + ], + "value": "https://github.com/vuejs.png", + "raw": "\"https://github.com/vuejs.png\"" + } + } + ], + "kind": "const" + } + ], + "sourceType": "module", + "comments": [], + "tokens": [ + { + "type": "Punctuator", + "range": [ + 0, + 14 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "value": "" + } + ], + "templateBody": { + "type": "VElement", + "range": [ + 69, + 104 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 7, + "column": 11 + } + }, + "name": "template", + "rawName": "template", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 69, + 79 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 79, + 82 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 6, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 82, + 92 + ], + "loc": { + "start": { + "line": 6, + "column": 2 + }, + "end": { + "line": 6, + "column": 12 + } + }, + "name": "img", + "rawName": "img", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 82, + 92 + ], + "loc": { + "start": { + "line": 6, + "column": 2 + }, + "end": { + "line": 6, + "column": 12 + } + }, + "selfClosing": false, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 87, + 91 + ], + "loc": { + "start": { + "line": 6, + "column": 7 + }, + "end": { + "line": 6, + "column": 11 + } + }, + "directive": true, + "key": { + "type": "VDirectiveKey", + "range": [ + 87, + 91 + ], + "loc": { + "start": { + "line": 6, + "column": 7 + }, + "end": { + "line": 6, + "column": 11 + } + }, + "name": { + "type": "VIdentifier", + "range": [ + 87, + 88 + ], + "loc": { + "start": { + "column": 7, + "line": 6 + }, + "end": { + "column": 8, + "line": 6 + } + }, + "name": "bind", + "rawName": ":" + }, + "argument": { + "type": "VIdentifier", + "range": [ + 88, + 91 + ], + "loc": { + "start": { + "column": 8, + "line": 6 + }, + "end": { + "column": 11, + "line": 6 + } + }, + "name": "src", + "rawName": "src" + }, + "modifiers": [] + }, + "value": { + "type": "VExpressionContainer", + "range": [ + 88, + 91 + ], + "loc": { + "start": { + "column": 8, + "line": 6 + }, + "end": { + "column": 11, + "line": 6 + } + }, + "expression": { + "type": "Identifier", + "start": 88, + "loc": { + "start": { + "line": 6, + "column": 8 + }, + "end": { + "column": 11, + "line": 6 + } + }, + "range": [ + 88, + 91 + ], + "name": "src" + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 88, + "loc": { + "start": { + "line": 6, + "column": 8 + }, + "end": { + "column": 11, + "line": 6 + } + }, + "range": [ + 88, + 91 + ], + "name": "src" + }, + "mode": "r", + "variable": null + } + ] + } + } + ] + }, + "children": [], + "endTag": null, + "variables": [] + }, + { + "type": "VText", + "range": [ + 92, + 93 + ], + "loc": { + "start": { + "line": 6, + "column": 12 + }, + "end": { + "line": 7, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 93, + 104 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 11 + } + } + }, + "variables": [], + "tokens": [ + { + "type": "HTMLTagOpen", + "range": [ + 0, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLIdentifier", + "range": [ + 8, + 13 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": "setup" + }, + { + "type": "HTMLTagClose", + "range": [ + 13, + 14 + ], + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 14, + 15 + ], + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 15, + 20 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 20, + 21 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 21, + 24 + ], + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "value": "src" + }, + { + "type": "HTMLWhitespace", + "range": [ + 24, + 25 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 25, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 26, + 27 + ], + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 27, + 57 + ], + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 42 + } + }, + "value": "\"https://github.com/vuejs.png\"" + }, + { + "type": "HTMLWhitespace", + "range": [ + 57, + 58 + ], + "loc": { + "start": { + "line": 2, + "column": 42 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 58, + 66 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 66, + 67 + ], + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 67, + 69 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "value": "\n\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 69, + 78 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 78, + 79 + ], + "loc": { + "start": { + "line": 5, + "column": 9 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 79, + 82 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 6, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 82, + 86 + ], + "loc": { + "start": { + "line": 6, + "column": 2 + }, + "end": { + "line": 6, + "column": 6 + } + }, + "value": "img" + }, + { + "type": "Punctuator", + "range": [ + 87, + 88 + ], + "loc": { + "start": { + "column": 7, + "line": 6 + }, + "end": { + "column": 8, + "line": 6 + } + }, + "value": ":" + }, + { + "type": "HTMLIdentifier", + "range": [ + 88, + 91 + ], + "loc": { + "start": { + "column": 8, + "line": 6 + }, + "end": { + "column": 11, + "line": 6 + } + }, + "value": "src" + }, + { + "type": "HTMLTagClose", + "range": [ + 91, + 92 + ], + "loc": { + "start": { + "line": 6, + "column": 11 + }, + "end": { + "line": 6, + "column": 12 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 92, + 93 + ], + "loc": { + "start": { + "line": 6, + "column": 12 + }, + "end": { + "line": 7, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 93, + 103 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 103, + 104 + ], + "loc": { + "start": { + "line": 7, + "column": 10 + }, + "end": { + "line": 7, + "column": 11 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 104, + 105 + ], + "loc": { + "start": { + "line": 7, + "column": 11 + }, + "end": { + "line": 8, + "column": 0 + } + }, + "value": "\n" + } + ], + "comments": [], + "errors": [] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/v-bind-same-name-shorthand01-script-setup/parser-options.json b/test/fixtures/ast/v-bind-same-name-shorthand01-script-setup/parser-options.json new file mode 100644 index 00000000..2104ca43 --- /dev/null +++ b/test/fixtures/ast/v-bind-same-name-shorthand01-script-setup/parser-options.json @@ -0,0 +1,3 @@ +{ + "sourceType": "module" +} diff --git a/test/fixtures/ast/v-bind-same-name-shorthand01-script-setup/requirements.json b/test/fixtures/ast/v-bind-same-name-shorthand01-script-setup/requirements.json new file mode 100644 index 00000000..36659b1f --- /dev/null +++ b/test/fixtures/ast/v-bind-same-name-shorthand01-script-setup/requirements.json @@ -0,0 +1,3 @@ +{ + "eslint": ">=8" +} \ No newline at end of file diff --git a/test/fixtures/ast/v-bind-same-name-shorthand01-script-setup/scope.json b/test/fixtures/ast/v-bind-same-name-shorthand01-script-setup/scope.json new file mode 100644 index 00000000..95d2857d --- /dev/null +++ b/test/fixtures/ast/v-bind-same-name-shorthand01-script-setup/scope.json @@ -0,0 +1,154 @@ +{ + "type": "global", + "variables": [], + "references": [], + "childScopes": [ + { + "type": "module", + "variables": [ + { + "name": "src", + "identifiers": [ + { + "type": "Identifier", + "name": "src", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 9 + } + } + } + ], + "defs": [ + { + "type": "Variable", + "node": { + "type": "VariableDeclarator", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 42 + } + } + }, + "name": "src" + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "src", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 9 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "src", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 9 + } + } + }, + "init": true + }, + { + "identifier": { + "type": "Identifier", + "name": "src", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 9 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "src", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 9 + } + } + }, + "init": null, + "vueUsedInTemplate": true + } + ] + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "src", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 9 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "src", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 9 + } + } + }, + "init": true + } + ], + "childScopes": [], + "through": [] + } + ], + "through": [] +} \ No newline at end of file diff --git a/test/fixtures/ast/v-bind-same-name-shorthand01-script-setup/source.vue b/test/fixtures/ast/v-bind-same-name-shorthand01-script-setup/source.vue new file mode 100644 index 00000000..902ca750 --- /dev/null +++ b/test/fixtures/ast/v-bind-same-name-shorthand01-script-setup/source.vue @@ -0,0 +1,7 @@ + + + diff --git a/test/fixtures/ast/v-bind-same-name-shorthand01-script-setup/token-ranges.json b/test/fixtures/ast/v-bind-same-name-shorthand01-script-setup/token-ranges.json new file mode 100644 index 00000000..1666d2b9 --- /dev/null +++ b/test/fixtures/ast/v-bind-same-name-shorthand01-script-setup/token-ranges.json @@ -0,0 +1,34 @@ +[ + "", + "", + "\n", + "const", + " ", + "src", + " ", + "=", + " ", + "\"https://github.com/vuejs.png\"", + "\n", + "", + "\n\n", + "", + "\n ", + "", + "\n", + "", + "\n" +] \ No newline at end of file diff --git a/test/fixtures/ast/v-bind-same-name-shorthand01-script-setup/tree.json b/test/fixtures/ast/v-bind-same-name-shorthand01-script-setup/tree.json new file mode 100644 index 00000000..403f2688 --- /dev/null +++ b/test/fixtures/ast/v-bind-same-name-shorthand01-script-setup/tree.json @@ -0,0 +1,73 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/ast/v-bind-same-name-shorthand02-options/ast.json b/test/fixtures/ast/v-bind-same-name-shorthand02-options/ast.json new file mode 100644 index 00000000..55f56637 --- /dev/null +++ b/test/fixtures/ast/v-bind-same-name-shorthand02-options/ast.json @@ -0,0 +1,1644 @@ +{ + "type": "Program", + "start": 9, + "end": 104, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 8, + "column": 1 + } + }, + "range": [ + 9, + 104 + ], + "body": [ + { + "type": "ExportDefaultDeclaration", + "start": 9, + "end": 104, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 8, + "column": 1 + } + }, + "range": [ + 9, + 104 + ], + "declaration": { + "type": "ObjectExpression", + "start": 24, + "end": 104, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 8, + "column": 1 + } + }, + "range": [ + 24, + 104 + ], + "properties": [ + { + "type": "Property", + "start": 28, + "end": 102, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 7, + "column": 3 + } + }, + "range": [ + 28, + 102 + ], + "method": true, + "shorthand": false, + "computed": false, + "key": { + "type": "Identifier", + "start": 28, + "end": 32, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 6 + } + }, + "range": [ + 28, + 32 + ], + "name": "data" + }, + "value": { + "type": "FunctionExpression", + "start": 33, + "end": 102, + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 7, + "column": 3 + } + }, + "range": [ + 33, + 102 + ], + "id": null, + "expression": false, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 36, + "end": 102, + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 7, + "column": 3 + } + }, + "range": [ + 36, + 102 + ], + "body": [ + { + "type": "ReturnStatement", + "start": 42, + "end": 98, + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 6, + "column": 5 + } + }, + "range": [ + 42, + 98 + ], + "argument": { + "type": "ObjectExpression", + "start": 49, + "end": 98, + "loc": { + "start": { + "line": 4, + "column": 11 + }, + "end": { + "line": 6, + "column": 5 + } + }, + "range": [ + 49, + 98 + ], + "properties": [ + { + "type": "Property", + "start": 57, + "end": 92, + "loc": { + "start": { + "line": 5, + "column": 6 + }, + "end": { + "line": 5, + "column": 41 + } + }, + "range": [ + 57, + 92 + ], + "method": false, + "shorthand": false, + "computed": false, + "key": { + "type": "Identifier", + "start": 57, + "end": 60, + "loc": { + "start": { + "line": 5, + "column": 6 + }, + "end": { + "line": 5, + "column": 9 + } + }, + "range": [ + 57, + 60 + ], + "name": "src" + }, + "value": { + "type": "Literal", + "start": 62, + "end": 92, + "loc": { + "start": { + "line": 5, + "column": 11 + }, + "end": { + "line": 5, + "column": 41 + } + }, + "range": [ + 62, + 92 + ], + "value": "https://github.com/vuejs.png", + "raw": "\"https://github.com/vuejs.png\"" + }, + "kind": "init" + } + ] + } + } + ] + } + }, + "kind": "init" + } + ] + } + } + ], + "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": [ + 116, + 151 + ], + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 13, + "column": 11 + } + }, + "name": "template", + "rawName": "template", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 116, + 126 + ], + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 10 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 126, + 129 + ], + "loc": { + "start": { + "line": 11, + "column": 10 + }, + "end": { + "line": 12, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 129, + 139 + ], + "loc": { + "start": { + "line": 12, + "column": 2 + }, + "end": { + "line": 12, + "column": 12 + } + }, + "name": "img", + "rawName": "img", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 129, + 139 + ], + "loc": { + "start": { + "line": 12, + "column": 2 + }, + "end": { + "line": 12, + "column": 12 + } + }, + "selfClosing": false, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 134, + 138 + ], + "loc": { + "start": { + "line": 12, + "column": 7 + }, + "end": { + "line": 12, + "column": 11 + } + }, + "directive": true, + "key": { + "type": "VDirectiveKey", + "range": [ + 134, + 138 + ], + "loc": { + "start": { + "line": 12, + "column": 7 + }, + "end": { + "line": 12, + "column": 11 + } + }, + "name": { + "type": "VIdentifier", + "range": [ + 134, + 135 + ], + "loc": { + "start": { + "column": 7, + "line": 12 + }, + "end": { + "column": 8, + "line": 12 + } + }, + "name": "bind", + "rawName": ":" + }, + "argument": { + "type": "VIdentifier", + "range": [ + 135, + 138 + ], + "loc": { + "start": { + "column": 8, + "line": 12 + }, + "end": { + "column": 11, + "line": 12 + } + }, + "name": "src", + "rawName": "src" + }, + "modifiers": [] + }, + "value": { + "type": "VExpressionContainer", + "range": [ + 135, + 138 + ], + "loc": { + "start": { + "column": 8, + "line": 12 + }, + "end": { + "column": 11, + "line": 12 + } + }, + "expression": { + "type": "Identifier", + "start": 135, + "loc": { + "start": { + "line": 12, + "column": 8 + }, + "end": { + "column": 11, + "line": 12 + } + }, + "range": [ + 135, + 138 + ], + "name": "src" + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 135, + "loc": { + "start": { + "line": 12, + "column": 8 + }, + "end": { + "column": 11, + "line": 12 + } + }, + "range": [ + 135, + 138 + ], + "name": "src" + }, + "mode": "r", + "variable": null + } + ] + } + } + ] + }, + "children": [], + "endTag": null, + "variables": [] + }, + { + "type": "VText", + "range": [ + 139, + 140 + ], + "loc": { + "start": { + "line": 12, + "column": 12 + }, + "end": { + "line": 13, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 140, + 151 + ], + "loc": { + "start": { + "line": 13, + "column": 0 + }, + "end": { + "line": 13, + "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, + 23 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "value": "default" + }, + { + "type": "HTMLWhitespace", + "range": [ + 23, + 24 + ], + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 24, + 25 + ], + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "value": "{" + }, + { + "type": "HTMLWhitespace", + "range": [ + 25, + 28 + ], + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 3, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "HTMLRawText", + "range": [ + 28, + 32 + ], + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 6 + } + }, + "value": "data" + }, + { + "type": "HTMLWhitespace", + "range": [ + 32, + 33 + ], + "loc": { + "start": { + "line": 3, + "column": 6 + }, + "end": { + "line": 3, + "column": 7 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 33, + 35 + ], + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "value": "()" + }, + { + "type": "HTMLWhitespace", + "range": [ + 35, + 36 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 3, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 36, + 37 + ], + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "value": "{" + }, + { + "type": "HTMLWhitespace", + "range": [ + 37, + 42 + ], + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 4, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "HTMLRawText", + "range": [ + 42, + 48 + ], + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 10 + } + }, + "value": "return" + }, + { + "type": "HTMLWhitespace", + "range": [ + 48, + 49 + ], + "loc": { + "start": { + "line": 4, + "column": 10 + }, + "end": { + "line": 4, + "column": 11 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 49, + 50 + ], + "loc": { + "start": { + "line": 4, + "column": 11 + }, + "end": { + "line": 4, + "column": 12 + } + }, + "value": "{" + }, + { + "type": "HTMLWhitespace", + "range": [ + 50, + 57 + ], + "loc": { + "start": { + "line": 4, + "column": 12 + }, + "end": { + "line": 5, + "column": 6 + } + }, + "value": "\n " + }, + { + "type": "HTMLRawText", + "range": [ + 57, + 61 + ], + "loc": { + "start": { + "line": 5, + "column": 6 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "value": "src:" + }, + { + "type": "HTMLWhitespace", + "range": [ + 61, + 62 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 11 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 62, + 92 + ], + "loc": { + "start": { + "line": 5, + "column": 11 + }, + "end": { + "line": 5, + "column": 41 + } + }, + "value": "\"https://github.com/vuejs.png\"" + }, + { + "type": "HTMLWhitespace", + "range": [ + 92, + 97 + ], + "loc": { + "start": { + "line": 5, + "column": 41 + }, + "end": { + "line": 6, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "HTMLRawText", + "range": [ + 97, + 98 + ], + "loc": { + "start": { + "line": 6, + "column": 4 + }, + "end": { + "line": 6, + "column": 5 + } + }, + "value": "}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 98, + 101 + ], + "loc": { + "start": { + "line": 6, + "column": 5 + }, + "end": { + "line": 7, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "HTMLRawText", + "range": [ + 101, + 102 + ], + "loc": { + "start": { + "line": 7, + "column": 2 + }, + "end": { + "line": 7, + "column": 3 + } + }, + "value": "}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 102, + 103 + ], + "loc": { + "start": { + "line": 7, + "column": 3 + }, + "end": { + "line": 8, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 103, + 104 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 1 + } + }, + "value": "}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 104, + 105 + ], + "loc": { + "start": { + "line": 8, + "column": 1 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 105, + 113 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 113, + 114 + ], + "loc": { + "start": { + "line": 9, + "column": 8 + }, + "end": { + "line": 9, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 114, + 116 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 11, + "column": 0 + } + }, + "value": "\n\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 116, + 125 + ], + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 125, + 126 + ], + "loc": { + "start": { + "line": 11, + "column": 9 + }, + "end": { + "line": 11, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 126, + 129 + ], + "loc": { + "start": { + "line": 11, + "column": 10 + }, + "end": { + "line": 12, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 129, + 133 + ], + "loc": { + "start": { + "line": 12, + "column": 2 + }, + "end": { + "line": 12, + "column": 6 + } + }, + "value": "img" + }, + { + "type": "Punctuator", + "range": [ + 134, + 135 + ], + "loc": { + "start": { + "column": 7, + "line": 12 + }, + "end": { + "column": 8, + "line": 12 + } + }, + "value": ":" + }, + { + "type": "HTMLIdentifier", + "range": [ + 135, + 138 + ], + "loc": { + "start": { + "column": 8, + "line": 12 + }, + "end": { + "column": 11, + "line": 12 + } + }, + "value": "src" + }, + { + "type": "HTMLTagClose", + "range": [ + 138, + 139 + ], + "loc": { + "start": { + "line": 12, + "column": 11 + }, + "end": { + "line": 12, + "column": 12 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 139, + 140 + ], + "loc": { + "start": { + "line": 12, + "column": 12 + }, + "end": { + "line": 13, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 140, + 150 + ], + "loc": { + "start": { + "line": 13, + "column": 0 + }, + "end": { + "line": 13, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 150, + 151 + ], + "loc": { + "start": { + "line": 13, + "column": 10 + }, + "end": { + "line": 13, + "column": 11 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 151, + 152 + ], + "loc": { + "start": { + "line": 13, + "column": 11 + }, + "end": { + "line": 14, + "column": 0 + } + }, + "value": "\n" + } + ], + "comments": [], + "errors": [] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/v-bind-same-name-shorthand02-options/parser-options.json b/test/fixtures/ast/v-bind-same-name-shorthand02-options/parser-options.json new file mode 100644 index 00000000..2104ca43 --- /dev/null +++ b/test/fixtures/ast/v-bind-same-name-shorthand02-options/parser-options.json @@ -0,0 +1,3 @@ +{ + "sourceType": "module" +} diff --git a/test/fixtures/ast/v-bind-same-name-shorthand02-options/requirements.json b/test/fixtures/ast/v-bind-same-name-shorthand02-options/requirements.json new file mode 100644 index 00000000..36659b1f --- /dev/null +++ b/test/fixtures/ast/v-bind-same-name-shorthand02-options/requirements.json @@ -0,0 +1,3 @@ +{ + "eslint": ">=8" +} \ No newline at end of file diff --git a/test/fixtures/ast/v-bind-same-name-shorthand02-options/scope.json b/test/fixtures/ast/v-bind-same-name-shorthand02-options/scope.json new file mode 100644 index 00000000..66d2c7f4 --- /dev/null +++ b/test/fixtures/ast/v-bind-same-name-shorthand02-options/scope.json @@ -0,0 +1,22 @@ +{ + "type": "global", + "variables": [], + "references": [], + "childScopes": [ + { + "type": "function", + "variables": [ + { + "name": "arguments", + "identifiers": [], + "defs": [], + "references": [] + } + ], + "references": [], + "childScopes": [], + "through": [] + } + ], + "through": [] +} \ No newline at end of file diff --git a/test/fixtures/ast/v-bind-same-name-shorthand02-options/source.vue b/test/fixtures/ast/v-bind-same-name-shorthand02-options/source.vue new file mode 100644 index 00000000..633c03c2 --- /dev/null +++ b/test/fixtures/ast/v-bind-same-name-shorthand02-options/source.vue @@ -0,0 +1,13 @@ + + + diff --git a/test/fixtures/ast/v-bind-same-name-shorthand02-options/token-ranges.json b/test/fixtures/ast/v-bind-same-name-shorthand02-options/token-ranges.json new file mode 100644 index 00000000..75da3231 --- /dev/null +++ b/test/fixtures/ast/v-bind-same-name-shorthand02-options/token-ranges.json @@ -0,0 +1,62 @@ +[ + "", + "", + "\n", + "export", + " ", + "default", + " ", + "{", + "\n ", + "data", + " ", + "()", + " ", + "{", + "\n ", + "return", + " ", + "{", + "\n ", + "src:", + " ", + "\"https://github.com/vuejs.png\"", + "\n ", + "}", + "\n ", + "}", + "\n", + "}", + "\n", + "", + "\n\n", + "", + "\n ", + "", + "\n", + "", + "\n" +] \ No newline at end of file diff --git a/test/fixtures/ast/v-bind-same-name-shorthand02-options/tree.json b/test/fixtures/ast/v-bind-same-name-shorthand02-options/tree.json new file mode 100644 index 00000000..403f2688 --- /dev/null +++ b/test/fixtures/ast/v-bind-same-name-shorthand02-options/tree.json @@ -0,0 +1,73 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/ast/v-bind-same-name-shorthand03-with-v-for/ast.json b/test/fixtures/ast/v-bind-same-name-shorthand03-with-v-for/ast.json new file mode 100644 index 00000000..64389542 --- /dev/null +++ b/test/fixtures/ast/v-bind-same-name-shorthand03-with-v-for/ast.json @@ -0,0 +1,1736 @@ +{ + "type": "Program", + "start": 15, + "end": 120, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 5, + "column": 7 + } + }, + "range": [ + 15, + 120 + ], + "body": [ + { + "type": "VariableDeclaration", + "start": 15, + "end": 120, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 5, + "column": 7 + } + }, + "range": [ + 15, + 120 + ], + "declarations": [ + { + "type": "VariableDeclarator", + "start": 21, + "end": 120, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 5, + "column": 7 + } + }, + "range": [ + 21, + 120 + ], + "id": { + "type": "Identifier", + "start": 21, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "range": [ + 21, + 28 + ], + "name": "srcList" + }, + "init": { + "type": "ArrayExpression", + "start": 31, + "end": 120, + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 5, + "column": 7 + } + }, + "range": [ + 31, + 120 + ], + "elements": [ + { + "type": "Literal", + "start": 41, + "end": 71, + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 38 + } + }, + "range": [ + 41, + 71 + ], + "value": "https://github.com/vuejs.png", + "raw": "\"https://github.com/vuejs.png\"" + }, + { + "type": "Literal", + "start": 81, + "end": 112, + "loc": { + "start": { + "line": 4, + "column": 8 + }, + "end": { + "line": 4, + "column": 39 + } + }, + "range": [ + 81, + 112 + ], + "value": "https://github.com/vitejs.png", + "raw": "\"https://github.com/vitejs.png\"" + } + ] + } + } + ], + "kind": "const" + } + ], + "sourceType": "module", + "comments": [], + "tokens": [ + { + "type": "Punctuator", + "range": [ + 0, + 14 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "value": "" + } + ], + "templateBody": { + "type": "VElement", + "range": [ + 132, + 209 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 12, + "column": 11 + } + }, + "name": "template", + "rawName": "template", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 132, + 142 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 10 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 142, + 145 + ], + "loc": { + "start": { + "line": 8, + "column": 10 + }, + "end": { + "line": 9, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 145, + 197 + ], + "loc": { + "start": { + "line": 9, + "column": 2 + }, + "end": { + "line": 11, + "column": 8 + } + }, + "name": "div", + "rawName": "div", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 145, + 150 + ], + "loc": { + "start": { + "line": 9, + "column": 2 + }, + "end": { + "line": 9, + "column": 7 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 150, + 155 + ], + "loc": { + "start": { + "line": 9, + "column": 7 + }, + "end": { + "line": 10, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 155, + 188 + ], + "loc": { + "start": { + "line": 10, + "column": 4 + }, + "end": { + "line": 10, + "column": 37 + } + }, + "name": "img", + "rawName": "img", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 155, + 188 + ], + "loc": { + "start": { + "line": 10, + "column": 4 + }, + "end": { + "line": 10, + "column": 37 + } + }, + "selfClosing": false, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 160, + 182 + ], + "loc": { + "start": { + "line": 10, + "column": 9 + }, + "end": { + "line": 10, + "column": 31 + } + }, + "directive": true, + "key": { + "type": "VDirectiveKey", + "range": [ + 160, + 165 + ], + "loc": { + "start": { + "line": 10, + "column": 9 + }, + "end": { + "line": 10, + "column": 14 + } + }, + "name": { + "type": "VIdentifier", + "range": [ + 160, + 165 + ], + "loc": { + "start": { + "column": 9, + "line": 10 + }, + "end": { + "column": 14, + "line": 10 + } + }, + "name": "for", + "rawName": "for" + }, + "argument": null, + "modifiers": [] + }, + "value": { + "type": "VExpressionContainer", + "range": [ + 166, + 182 + ], + "loc": { + "start": { + "line": 10, + "column": 15 + }, + "end": { + "line": 10, + "column": 31 + } + }, + "expression": { + "type": "VForExpression", + "range": [ + 167, + 181 + ], + "loc": { + "start": { + "line": 10, + "column": 16 + }, + "end": { + "line": 10, + "column": 30 + } + }, + "left": [ + { + "type": "Identifier", + "start": 167, + "end": 170, + "loc": { + "start": { + "line": 10, + "column": 16 + }, + "end": { + "line": 10, + "column": 19 + } + }, + "range": [ + 167, + 170 + ], + "name": "src" + } + ], + "right": { + "type": "Identifier", + "start": 174, + "end": 181, + "loc": { + "start": { + "line": 10, + "column": 23 + }, + "end": { + "line": 10, + "column": 30 + } + }, + "range": [ + 174, + 181 + ], + "name": "srcList" + } + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 174, + "end": 181, + "loc": { + "start": { + "line": 10, + "column": 23 + }, + "end": { + "line": 10, + "column": 30 + } + }, + "range": [ + 174, + 181 + ], + "name": "srcList" + }, + "mode": "r" + } + ] + } + }, + { + "type": "VAttribute", + "range": [ + 183, + 187 + ], + "loc": { + "start": { + "line": 10, + "column": 32 + }, + "end": { + "line": 10, + "column": 36 + } + }, + "directive": true, + "key": { + "type": "VDirectiveKey", + "range": [ + 183, + 187 + ], + "loc": { + "start": { + "line": 10, + "column": 32 + }, + "end": { + "line": 10, + "column": 36 + } + }, + "name": { + "type": "VIdentifier", + "range": [ + 183, + 184 + ], + "loc": { + "start": { + "column": 32, + "line": 10 + }, + "end": { + "column": 33, + "line": 10 + } + }, + "name": "bind", + "rawName": ":" + }, + "argument": { + "type": "VIdentifier", + "range": [ + 184, + 187 + ], + "loc": { + "start": { + "column": 33, + "line": 10 + }, + "end": { + "column": 36, + "line": 10 + } + }, + "name": "src", + "rawName": "src" + }, + "modifiers": [] + }, + "value": { + "type": "VExpressionContainer", + "range": [ + 184, + 187 + ], + "loc": { + "start": { + "column": 33, + "line": 10 + }, + "end": { + "column": 36, + "line": 10 + } + }, + "expression": { + "type": "Identifier", + "start": 184, + "loc": { + "start": { + "line": 10, + "column": 33 + }, + "end": { + "column": 36, + "line": 10 + } + }, + "range": [ + 184, + 187 + ], + "name": "src" + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 184, + "loc": { + "start": { + "line": 10, + "column": 33 + }, + "end": { + "column": 36, + "line": 10 + } + }, + "range": [ + 184, + 187 + ], + "name": "src" + }, + "mode": "r", + "variable": { + "id": { + "type": "Identifier", + "start": 167, + "end": 170, + "loc": { + "start": { + "line": 10, + "column": 16 + }, + "end": { + "line": 10, + "column": 19 + } + }, + "range": [ + 167, + 170 + ], + "name": "src" + }, + "kind": "v-for" + } + } + ] + } + } + ] + }, + "children": [], + "endTag": null, + "variables": [ + { + "id": { + "type": "Identifier", + "start": 167, + "end": 170, + "loc": { + "start": { + "line": 10, + "column": 16 + }, + "end": { + "line": 10, + "column": 19 + } + }, + "range": [ + 167, + 170 + ], + "name": "src" + }, + "kind": "v-for" + } + ] + }, + { + "type": "VText", + "range": [ + 188, + 191 + ], + "loc": { + "start": { + "line": 10, + "column": 37 + }, + "end": { + "line": 11, + "column": 2 + } + }, + "value": "\n " + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 191, + 197 + ], + "loc": { + "start": { + "line": 11, + "column": 2 + }, + "end": { + "line": 11, + "column": 8 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 197, + 198 + ], + "loc": { + "start": { + "line": 11, + "column": 8 + }, + "end": { + "line": 12, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 198, + 209 + ], + "loc": { + "start": { + "line": 12, + "column": 0 + }, + "end": { + "line": 12, + "column": 11 + } + } + }, + "variables": [], + "tokens": [ + { + "type": "HTMLTagOpen", + "range": [ + 0, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLIdentifier", + "range": [ + 8, + 13 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": "setup" + }, + { + "type": "HTMLTagClose", + "range": [ + 13, + 14 + ], + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 14, + 15 + ], + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 15, + 20 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 20, + 21 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 21, + 28 + ], + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "value": "srcList" + }, + { + "type": "HTMLWhitespace", + "range": [ + 28, + 29 + ], + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 29, + 30 + ], + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 30, + 31 + ], + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 31, + 32 + ], + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "value": "[" + }, + { + "type": "HTMLWhitespace", + "range": [ + 32, + 41 + ], + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "value": "\n " + }, + { + "type": "HTMLRawText", + "range": [ + 41, + 72 + ], + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 39 + } + }, + "value": "\"https://github.com/vuejs.png\"," + }, + { + "type": "HTMLWhitespace", + "range": [ + 72, + 81 + ], + "loc": { + "start": { + "line": 3, + "column": 39 + }, + "end": { + "line": 4, + "column": 8 + } + }, + "value": "\n " + }, + { + "type": "HTMLRawText", + "range": [ + 81, + 112 + ], + "loc": { + "start": { + "line": 4, + "column": 8 + }, + "end": { + "line": 4, + "column": 39 + } + }, + "value": "\"https://github.com/vitejs.png\"" + }, + { + "type": "HTMLWhitespace", + "range": [ + 112, + 119 + ], + "loc": { + "start": { + "line": 4, + "column": 39 + }, + "end": { + "line": 5, + "column": 6 + } + }, + "value": "\n " + }, + { + "type": "HTMLRawText", + "range": [ + 119, + 120 + ], + "loc": { + "start": { + "line": 5, + "column": 6 + }, + "end": { + "line": 5, + "column": 7 + } + }, + "value": "]" + }, + { + "type": "HTMLWhitespace", + "range": [ + 120, + 121 + ], + "loc": { + "start": { + "line": 5, + "column": 7 + }, + "end": { + "line": 6, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 121, + 129 + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 129, + 130 + ], + "loc": { + "start": { + "line": 6, + "column": 8 + }, + "end": { + "line": 6, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 130, + 132 + ], + "loc": { + "start": { + "line": 6, + "column": 9 + }, + "end": { + "line": 8, + "column": 0 + } + }, + "value": "\n\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 132, + 141 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 141, + 142 + ], + "loc": { + "start": { + "line": 8, + "column": 9 + }, + "end": { + "line": 8, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 142, + 145 + ], + "loc": { + "start": { + "line": 8, + "column": 10 + }, + "end": { + "line": 9, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 145, + 149 + ], + "loc": { + "start": { + "line": 9, + "column": 2 + }, + "end": { + "line": 9, + "column": 6 + } + }, + "value": "div" + }, + { + "type": "HTMLTagClose", + "range": [ + 149, + 150 + ], + "loc": { + "start": { + "line": 9, + "column": 6 + }, + "end": { + "line": 9, + "column": 7 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 150, + 155 + ], + "loc": { + "start": { + "line": 9, + "column": 7 + }, + "end": { + "line": 10, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 155, + 159 + ], + "loc": { + "start": { + "line": 10, + "column": 4 + }, + "end": { + "line": 10, + "column": 8 + } + }, + "value": "img" + }, + { + "type": "HTMLIdentifier", + "range": [ + 160, + 165 + ], + "loc": { + "start": { + "column": 9, + "line": 10 + }, + "end": { + "column": 14, + "line": 10 + } + }, + "value": "v-for" + }, + { + "type": "HTMLAssociation", + "range": [ + 165, + 166 + ], + "loc": { + "start": { + "line": 10, + "column": 14 + }, + "end": { + "line": 10, + "column": 15 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 166, + 167 + ], + "loc": { + "start": { + "line": 10, + "column": 15 + }, + "end": { + "line": 10, + "column": 16 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "value": "src", + "start": 167, + "end": 170, + "loc": { + "start": { + "line": 10, + "column": 16 + }, + "end": { + "line": 10, + "column": 19 + } + }, + "range": [ + 167, + 170 + ] + }, + { + "type": "Keyword", + "value": "in", + "start": 171, + "end": 173, + "loc": { + "start": { + "line": 10, + "column": 20 + }, + "end": { + "line": 10, + "column": 22 + } + }, + "range": [ + 171, + 173 + ] + }, + { + "type": "Identifier", + "value": "srcList", + "start": 174, + "end": 181, + "loc": { + "start": { + "line": 10, + "column": 23 + }, + "end": { + "line": 10, + "column": 30 + } + }, + "range": [ + 174, + 181 + ] + }, + { + "type": "Punctuator", + "range": [ + 181, + 182 + ], + "loc": { + "start": { + "line": 10, + "column": 30 + }, + "end": { + "line": 10, + "column": 31 + } + }, + "value": "\"" + }, + { + "type": "Punctuator", + "range": [ + 183, + 184 + ], + "loc": { + "start": { + "column": 32, + "line": 10 + }, + "end": { + "column": 33, + "line": 10 + } + }, + "value": ":" + }, + { + "type": "HTMLIdentifier", + "range": [ + 184, + 187 + ], + "loc": { + "start": { + "column": 33, + "line": 10 + }, + "end": { + "column": 36, + "line": 10 + } + }, + "value": "src" + }, + { + "type": "HTMLTagClose", + "range": [ + 187, + 188 + ], + "loc": { + "start": { + "line": 10, + "column": 36 + }, + "end": { + "line": 10, + "column": 37 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 188, + 191 + ], + "loc": { + "start": { + "line": 10, + "column": 37 + }, + "end": { + "line": 11, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 191, + 196 + ], + "loc": { + "start": { + "line": 11, + "column": 2 + }, + "end": { + "line": 11, + "column": 7 + } + }, + "value": "div" + }, + { + "type": "HTMLTagClose", + "range": [ + 196, + 197 + ], + "loc": { + "start": { + "line": 11, + "column": 7 + }, + "end": { + "line": 11, + "column": 8 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 197, + 198 + ], + "loc": { + "start": { + "line": 11, + "column": 8 + }, + "end": { + "line": 12, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 198, + 208 + ], + "loc": { + "start": { + "line": 12, + "column": 0 + }, + "end": { + "line": 12, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 208, + 209 + ], + "loc": { + "start": { + "line": 12, + "column": 10 + }, + "end": { + "line": 12, + "column": 11 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 209, + 210 + ], + "loc": { + "start": { + "line": 12, + "column": 11 + }, + "end": { + "line": 13, + "column": 0 + } + }, + "value": "\n" + } + ], + "comments": [], + "errors": [] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/v-bind-same-name-shorthand03-with-v-for/parser-options.json b/test/fixtures/ast/v-bind-same-name-shorthand03-with-v-for/parser-options.json new file mode 100644 index 00000000..2104ca43 --- /dev/null +++ b/test/fixtures/ast/v-bind-same-name-shorthand03-with-v-for/parser-options.json @@ -0,0 +1,3 @@ +{ + "sourceType": "module" +} diff --git a/test/fixtures/ast/v-bind-same-name-shorthand03-with-v-for/requirements.json b/test/fixtures/ast/v-bind-same-name-shorthand03-with-v-for/requirements.json new file mode 100644 index 00000000..36659b1f --- /dev/null +++ b/test/fixtures/ast/v-bind-same-name-shorthand03-with-v-for/requirements.json @@ -0,0 +1,3 @@ +{ + "eslint": ">=8" +} \ No newline at end of file diff --git a/test/fixtures/ast/v-bind-same-name-shorthand03-with-v-for/scope.json b/test/fixtures/ast/v-bind-same-name-shorthand03-with-v-for/scope.json new file mode 100644 index 00000000..9c8001a6 --- /dev/null +++ b/test/fixtures/ast/v-bind-same-name-shorthand03-with-v-for/scope.json @@ -0,0 +1,154 @@ +{ + "type": "global", + "variables": [], + "references": [], + "childScopes": [ + { + "type": "module", + "variables": [ + { + "name": "srcList", + "identifiers": [ + { + "type": "Identifier", + "name": "srcList", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 13 + } + } + } + ], + "defs": [ + { + "type": "Variable", + "node": { + "type": "VariableDeclarator", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 5, + "column": 7 + } + } + }, + "name": "srcList" + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "srcList", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 13 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "srcList", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 13 + } + } + }, + "init": true + }, + { + "identifier": { + "type": "Identifier", + "name": "srcList", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 13 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "srcList", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 13 + } + } + }, + "init": null, + "vueUsedInTemplate": true + } + ] + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "srcList", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 13 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "srcList", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 13 + } + } + }, + "init": true + } + ], + "childScopes": [], + "through": [] + } + ], + "through": [] +} \ No newline at end of file diff --git a/test/fixtures/ast/v-bind-same-name-shorthand03-with-v-for/source.vue b/test/fixtures/ast/v-bind-same-name-shorthand03-with-v-for/source.vue new file mode 100644 index 00000000..5a8ed1db --- /dev/null +++ b/test/fixtures/ast/v-bind-same-name-shorthand03-with-v-for/source.vue @@ -0,0 +1,12 @@ + + + diff --git a/test/fixtures/ast/v-bind-same-name-shorthand03-with-v-for/token-ranges.json b/test/fixtures/ast/v-bind-same-name-shorthand03-with-v-for/token-ranges.json new file mode 100644 index 00000000..5550abfa --- /dev/null +++ b/test/fixtures/ast/v-bind-same-name-shorthand03-with-v-for/token-ranges.json @@ -0,0 +1,57 @@ +[ + "", + "", + "\n", + "const", + " ", + "srcList", + " ", + "=", + " ", + "[", + "\n ", + "\"https://github.com/vuejs.png\",", + "\n ", + "\"https://github.com/vitejs.png\"", + "\n ", + "]", + "\n", + "", + "\n\n", + "", + "\n ", + "", + "\n ", + "", + "\n ", + "", + "\n", + "", + "\n" +] \ No newline at end of file diff --git a/test/fixtures/ast/v-bind-same-name-shorthand03-with-v-for/tree.json b/test/fixtures/ast/v-bind-same-name-shorthand03-with-v-for/tree.json new file mode 100644 index 00000000..3f22d76a --- /dev/null +++ b/test/fixtures/ast/v-bind-same-name-shorthand03-with-v-for/tree.json @@ -0,0 +1,138 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/ast/v-bind-same-name-shorthand04-with-v-for/ast.json b/test/fixtures/ast/v-bind-same-name-shorthand04-with-v-for/ast.json new file mode 100644 index 00000000..05fdd689 --- /dev/null +++ b/test/fixtures/ast/v-bind-same-name-shorthand04-with-v-for/ast.json @@ -0,0 +1,2412 @@ +{ + "type": "Program", + "start": 9, + "end": 167, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 11, + "column": 1 + } + }, + "range": [ + 9, + 167 + ], + "body": [ + { + "type": "ExportDefaultDeclaration", + "start": 9, + "end": 167, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 11, + "column": 1 + } + }, + "range": [ + 9, + 167 + ], + "declaration": { + "type": "ObjectExpression", + "start": 24, + "end": 167, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 11, + "column": 1 + } + }, + "range": [ + 24, + 167 + ], + "properties": [ + { + "type": "Property", + "start": 28, + "end": 165, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 10, + "column": 3 + } + }, + "range": [ + 28, + 165 + ], + "method": true, + "shorthand": false, + "computed": false, + "key": { + "type": "Identifier", + "start": 28, + "end": 32, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 6 + } + }, + "range": [ + 28, + 32 + ], + "name": "data" + }, + "value": { + "type": "FunctionExpression", + "start": 33, + "end": 165, + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 10, + "column": 3 + } + }, + "range": [ + 33, + 165 + ], + "id": null, + "expression": false, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 36, + "end": 165, + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 10, + "column": 3 + } + }, + "range": [ + 36, + 165 + ], + "body": [ + { + "type": "ReturnStatement", + "start": 42, + "end": 161, + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 9, + "column": 5 + } + }, + "range": [ + 42, + 161 + ], + "argument": { + "type": "ObjectExpression", + "start": 49, + "end": 161, + "loc": { + "start": { + "line": 4, + "column": 11 + }, + "end": { + "line": 9, + "column": 5 + } + }, + "range": [ + 49, + 161 + ], + "properties": [ + { + "type": "Property", + "start": 57, + "end": 155, + "loc": { + "start": { + "line": 5, + "column": 6 + }, + "end": { + "line": 8, + "column": 7 + } + }, + "range": [ + 57, + 155 + ], + "method": false, + "shorthand": false, + "computed": false, + "key": { + "type": "Identifier", + "start": 57, + "end": 64, + "loc": { + "start": { + "line": 5, + "column": 6 + }, + "end": { + "line": 5, + "column": 13 + } + }, + "range": [ + 57, + 64 + ], + "name": "srcList" + }, + "value": { + "type": "ArrayExpression", + "start": 66, + "end": 155, + "loc": { + "start": { + "line": 5, + "column": 15 + }, + "end": { + "line": 8, + "column": 7 + } + }, + "range": [ + 66, + 155 + ], + "elements": [ + { + "type": "Literal", + "start": 76, + "end": 106, + "loc": { + "start": { + "line": 6, + "column": 8 + }, + "end": { + "line": 6, + "column": 38 + } + }, + "range": [ + 76, + 106 + ], + "value": "https://github.com/vuejs.png", + "raw": "\"https://github.com/vuejs.png\"" + }, + { + "type": "Literal", + "start": 116, + "end": 147, + "loc": { + "start": { + "line": 7, + "column": 8 + }, + "end": { + "line": 7, + "column": 39 + } + }, + "range": [ + 116, + 147 + ], + "value": "https://github.com/vitejs.png", + "raw": "\"https://github.com/vitejs.png\"" + } + ] + }, + "kind": "init" + } + ] + } + } + ] + } + }, + "kind": "init" + } + ] + } + } + ], + "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": [ + 179, + 256 + ], + "loc": { + "start": { + "line": 14, + "column": 0 + }, + "end": { + "line": 18, + "column": 11 + } + }, + "name": "template", + "rawName": "template", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 179, + 189 + ], + "loc": { + "start": { + "line": 14, + "column": 0 + }, + "end": { + "line": 14, + "column": 10 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 189, + 192 + ], + "loc": { + "start": { + "line": 14, + "column": 10 + }, + "end": { + "line": 15, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 192, + 244 + ], + "loc": { + "start": { + "line": 15, + "column": 2 + }, + "end": { + "line": 17, + "column": 8 + } + }, + "name": "div", + "rawName": "div", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 192, + 197 + ], + "loc": { + "start": { + "line": 15, + "column": 2 + }, + "end": { + "line": 15, + "column": 7 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 197, + 202 + ], + "loc": { + "start": { + "line": 15, + "column": 7 + }, + "end": { + "line": 16, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 202, + 235 + ], + "loc": { + "start": { + "line": 16, + "column": 4 + }, + "end": { + "line": 16, + "column": 37 + } + }, + "name": "img", + "rawName": "img", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 202, + 235 + ], + "loc": { + "start": { + "line": 16, + "column": 4 + }, + "end": { + "line": 16, + "column": 37 + } + }, + "selfClosing": false, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 207, + 229 + ], + "loc": { + "start": { + "line": 16, + "column": 9 + }, + "end": { + "line": 16, + "column": 31 + } + }, + "directive": true, + "key": { + "type": "VDirectiveKey", + "range": [ + 207, + 212 + ], + "loc": { + "start": { + "line": 16, + "column": 9 + }, + "end": { + "line": 16, + "column": 14 + } + }, + "name": { + "type": "VIdentifier", + "range": [ + 207, + 212 + ], + "loc": { + "start": { + "column": 9, + "line": 16 + }, + "end": { + "column": 14, + "line": 16 + } + }, + "name": "for", + "rawName": "for" + }, + "argument": null, + "modifiers": [] + }, + "value": { + "type": "VExpressionContainer", + "range": [ + 213, + 229 + ], + "loc": { + "start": { + "line": 16, + "column": 15 + }, + "end": { + "line": 16, + "column": 31 + } + }, + "expression": { + "type": "VForExpression", + "range": [ + 214, + 228 + ], + "loc": { + "start": { + "line": 16, + "column": 16 + }, + "end": { + "line": 16, + "column": 30 + } + }, + "left": [ + { + "type": "Identifier", + "start": 214, + "end": 217, + "loc": { + "start": { + "line": 16, + "column": 16 + }, + "end": { + "line": 16, + "column": 19 + } + }, + "range": [ + 214, + 217 + ], + "name": "src" + } + ], + "right": { + "type": "Identifier", + "start": 221, + "end": 228, + "loc": { + "start": { + "line": 16, + "column": 23 + }, + "end": { + "line": 16, + "column": 30 + } + }, + "range": [ + 221, + 228 + ], + "name": "srcList" + } + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 221, + "end": 228, + "loc": { + "start": { + "line": 16, + "column": 23 + }, + "end": { + "line": 16, + "column": 30 + } + }, + "range": [ + 221, + 228 + ], + "name": "srcList" + }, + "mode": "r" + } + ] + } + }, + { + "type": "VAttribute", + "range": [ + 230, + 234 + ], + "loc": { + "start": { + "line": 16, + "column": 32 + }, + "end": { + "line": 16, + "column": 36 + } + }, + "directive": true, + "key": { + "type": "VDirectiveKey", + "range": [ + 230, + 234 + ], + "loc": { + "start": { + "line": 16, + "column": 32 + }, + "end": { + "line": 16, + "column": 36 + } + }, + "name": { + "type": "VIdentifier", + "range": [ + 230, + 231 + ], + "loc": { + "start": { + "column": 32, + "line": 16 + }, + "end": { + "column": 33, + "line": 16 + } + }, + "name": "bind", + "rawName": ":" + }, + "argument": { + "type": "VIdentifier", + "range": [ + 231, + 234 + ], + "loc": { + "start": { + "column": 33, + "line": 16 + }, + "end": { + "column": 36, + "line": 16 + } + }, + "name": "src", + "rawName": "src" + }, + "modifiers": [] + }, + "value": { + "type": "VExpressionContainer", + "range": [ + 231, + 234 + ], + "loc": { + "start": { + "column": 33, + "line": 16 + }, + "end": { + "column": 36, + "line": 16 + } + }, + "expression": { + "type": "Identifier", + "start": 231, + "loc": { + "start": { + "line": 16, + "column": 33 + }, + "end": { + "column": 36, + "line": 16 + } + }, + "range": [ + 231, + 234 + ], + "name": "src" + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 231, + "loc": { + "start": { + "line": 16, + "column": 33 + }, + "end": { + "column": 36, + "line": 16 + } + }, + "range": [ + 231, + 234 + ], + "name": "src" + }, + "mode": "r", + "variable": { + "id": { + "type": "Identifier", + "start": 214, + "end": 217, + "loc": { + "start": { + "line": 16, + "column": 16 + }, + "end": { + "line": 16, + "column": 19 + } + }, + "range": [ + 214, + 217 + ], + "name": "src" + }, + "kind": "v-for" + } + } + ] + } + } + ] + }, + "children": [], + "endTag": null, + "variables": [ + { + "id": { + "type": "Identifier", + "start": 214, + "end": 217, + "loc": { + "start": { + "line": 16, + "column": 16 + }, + "end": { + "line": 16, + "column": 19 + } + }, + "range": [ + 214, + 217 + ], + "name": "src" + }, + "kind": "v-for" + } + ] + }, + { + "type": "VText", + "range": [ + 235, + 238 + ], + "loc": { + "start": { + "line": 16, + "column": 37 + }, + "end": { + "line": 17, + "column": 2 + } + }, + "value": "\n " + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 238, + 244 + ], + "loc": { + "start": { + "line": 17, + "column": 2 + }, + "end": { + "line": 17, + "column": 8 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 244, + 245 + ], + "loc": { + "start": { + "line": 17, + "column": 8 + }, + "end": { + "line": 18, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 245, + 256 + ], + "loc": { + "start": { + "line": 18, + "column": 0 + }, + "end": { + "line": 18, + "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, + 23 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "value": "default" + }, + { + "type": "HTMLWhitespace", + "range": [ + 23, + 24 + ], + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 24, + 25 + ], + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "value": "{" + }, + { + "type": "HTMLWhitespace", + "range": [ + 25, + 28 + ], + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 3, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "HTMLRawText", + "range": [ + 28, + 32 + ], + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 6 + } + }, + "value": "data" + }, + { + "type": "HTMLWhitespace", + "range": [ + 32, + 33 + ], + "loc": { + "start": { + "line": 3, + "column": 6 + }, + "end": { + "line": 3, + "column": 7 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 33, + 35 + ], + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "value": "()" + }, + { + "type": "HTMLWhitespace", + "range": [ + 35, + 36 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 3, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 36, + 37 + ], + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "value": "{" + }, + { + "type": "HTMLWhitespace", + "range": [ + 37, + 42 + ], + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 4, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "HTMLRawText", + "range": [ + 42, + 48 + ], + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 10 + } + }, + "value": "return" + }, + { + "type": "HTMLWhitespace", + "range": [ + 48, + 49 + ], + "loc": { + "start": { + "line": 4, + "column": 10 + }, + "end": { + "line": 4, + "column": 11 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 49, + 50 + ], + "loc": { + "start": { + "line": 4, + "column": 11 + }, + "end": { + "line": 4, + "column": 12 + } + }, + "value": "{" + }, + { + "type": "HTMLWhitespace", + "range": [ + 50, + 57 + ], + "loc": { + "start": { + "line": 4, + "column": 12 + }, + "end": { + "line": 5, + "column": 6 + } + }, + "value": "\n " + }, + { + "type": "HTMLRawText", + "range": [ + 57, + 65 + ], + "loc": { + "start": { + "line": 5, + "column": 6 + }, + "end": { + "line": 5, + "column": 14 + } + }, + "value": "srcList:" + }, + { + "type": "HTMLWhitespace", + "range": [ + 65, + 66 + ], + "loc": { + "start": { + "line": 5, + "column": 14 + }, + "end": { + "line": 5, + "column": 15 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 66, + 67 + ], + "loc": { + "start": { + "line": 5, + "column": 15 + }, + "end": { + "line": 5, + "column": 16 + } + }, + "value": "[" + }, + { + "type": "HTMLWhitespace", + "range": [ + 67, + 76 + ], + "loc": { + "start": { + "line": 5, + "column": 16 + }, + "end": { + "line": 6, + "column": 8 + } + }, + "value": "\n " + }, + { + "type": "HTMLRawText", + "range": [ + 76, + 107 + ], + "loc": { + "start": { + "line": 6, + "column": 8 + }, + "end": { + "line": 6, + "column": 39 + } + }, + "value": "\"https://github.com/vuejs.png\"," + }, + { + "type": "HTMLWhitespace", + "range": [ + 107, + 116 + ], + "loc": { + "start": { + "line": 6, + "column": 39 + }, + "end": { + "line": 7, + "column": 8 + } + }, + "value": "\n " + }, + { + "type": "HTMLRawText", + "range": [ + 116, + 147 + ], + "loc": { + "start": { + "line": 7, + "column": 8 + }, + "end": { + "line": 7, + "column": 39 + } + }, + "value": "\"https://github.com/vitejs.png\"" + }, + { + "type": "HTMLWhitespace", + "range": [ + 147, + 154 + ], + "loc": { + "start": { + "line": 7, + "column": 39 + }, + "end": { + "line": 8, + "column": 6 + } + }, + "value": "\n " + }, + { + "type": "HTMLRawText", + "range": [ + 154, + 155 + ], + "loc": { + "start": { + "line": 8, + "column": 6 + }, + "end": { + "line": 8, + "column": 7 + } + }, + "value": "]" + }, + { + "type": "HTMLWhitespace", + "range": [ + 155, + 160 + ], + "loc": { + "start": { + "line": 8, + "column": 7 + }, + "end": { + "line": 9, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "HTMLRawText", + "range": [ + 160, + 161 + ], + "loc": { + "start": { + "line": 9, + "column": 4 + }, + "end": { + "line": 9, + "column": 5 + } + }, + "value": "}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 161, + 164 + ], + "loc": { + "start": { + "line": 9, + "column": 5 + }, + "end": { + "line": 10, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "HTMLRawText", + "range": [ + 164, + 165 + ], + "loc": { + "start": { + "line": 10, + "column": 2 + }, + "end": { + "line": 10, + "column": 3 + } + }, + "value": "}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 165, + 166 + ], + "loc": { + "start": { + "line": 10, + "column": 3 + }, + "end": { + "line": 11, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 166, + 167 + ], + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 1 + } + }, + "value": "}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 167, + 168 + ], + "loc": { + "start": { + "line": 11, + "column": 1 + }, + "end": { + "line": 12, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 168, + 176 + ], + "loc": { + "start": { + "line": 12, + "column": 0 + }, + "end": { + "line": 12, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 176, + 177 + ], + "loc": { + "start": { + "line": 12, + "column": 8 + }, + "end": { + "line": 12, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 177, + 179 + ], + "loc": { + "start": { + "line": 12, + "column": 9 + }, + "end": { + "line": 14, + "column": 0 + } + }, + "value": "\n\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 179, + 188 + ], + "loc": { + "start": { + "line": 14, + "column": 0 + }, + "end": { + "line": 14, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 188, + 189 + ], + "loc": { + "start": { + "line": 14, + "column": 9 + }, + "end": { + "line": 14, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 189, + 192 + ], + "loc": { + "start": { + "line": 14, + "column": 10 + }, + "end": { + "line": 15, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 192, + 196 + ], + "loc": { + "start": { + "line": 15, + "column": 2 + }, + "end": { + "line": 15, + "column": 6 + } + }, + "value": "div" + }, + { + "type": "HTMLTagClose", + "range": [ + 196, + 197 + ], + "loc": { + "start": { + "line": 15, + "column": 6 + }, + "end": { + "line": 15, + "column": 7 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 197, + 202 + ], + "loc": { + "start": { + "line": 15, + "column": 7 + }, + "end": { + "line": 16, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 202, + 206 + ], + "loc": { + "start": { + "line": 16, + "column": 4 + }, + "end": { + "line": 16, + "column": 8 + } + }, + "value": "img" + }, + { + "type": "HTMLIdentifier", + "range": [ + 207, + 212 + ], + "loc": { + "start": { + "column": 9, + "line": 16 + }, + "end": { + "column": 14, + "line": 16 + } + }, + "value": "v-for" + }, + { + "type": "HTMLAssociation", + "range": [ + 212, + 213 + ], + "loc": { + "start": { + "line": 16, + "column": 14 + }, + "end": { + "line": 16, + "column": 15 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 213, + 214 + ], + "loc": { + "start": { + "line": 16, + "column": 15 + }, + "end": { + "line": 16, + "column": 16 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "value": "src", + "start": 214, + "end": 217, + "loc": { + "start": { + "line": 16, + "column": 16 + }, + "end": { + "line": 16, + "column": 19 + } + }, + "range": [ + 214, + 217 + ] + }, + { + "type": "Keyword", + "value": "in", + "start": 218, + "end": 220, + "loc": { + "start": { + "line": 16, + "column": 20 + }, + "end": { + "line": 16, + "column": 22 + } + }, + "range": [ + 218, + 220 + ] + }, + { + "type": "Identifier", + "value": "srcList", + "start": 221, + "end": 228, + "loc": { + "start": { + "line": 16, + "column": 23 + }, + "end": { + "line": 16, + "column": 30 + } + }, + "range": [ + 221, + 228 + ] + }, + { + "type": "Punctuator", + "range": [ + 228, + 229 + ], + "loc": { + "start": { + "line": 16, + "column": 30 + }, + "end": { + "line": 16, + "column": 31 + } + }, + "value": "\"" + }, + { + "type": "Punctuator", + "range": [ + 230, + 231 + ], + "loc": { + "start": { + "column": 32, + "line": 16 + }, + "end": { + "column": 33, + "line": 16 + } + }, + "value": ":" + }, + { + "type": "HTMLIdentifier", + "range": [ + 231, + 234 + ], + "loc": { + "start": { + "column": 33, + "line": 16 + }, + "end": { + "column": 36, + "line": 16 + } + }, + "value": "src" + }, + { + "type": "HTMLTagClose", + "range": [ + 234, + 235 + ], + "loc": { + "start": { + "line": 16, + "column": 36 + }, + "end": { + "line": 16, + "column": 37 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 235, + 238 + ], + "loc": { + "start": { + "line": 16, + "column": 37 + }, + "end": { + "line": 17, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 238, + 243 + ], + "loc": { + "start": { + "line": 17, + "column": 2 + }, + "end": { + "line": 17, + "column": 7 + } + }, + "value": "div" + }, + { + "type": "HTMLTagClose", + "range": [ + 243, + 244 + ], + "loc": { + "start": { + "line": 17, + "column": 7 + }, + "end": { + "line": 17, + "column": 8 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 244, + 245 + ], + "loc": { + "start": { + "line": 17, + "column": 8 + }, + "end": { + "line": 18, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 245, + 255 + ], + "loc": { + "start": { + "line": 18, + "column": 0 + }, + "end": { + "line": 18, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 255, + 256 + ], + "loc": { + "start": { + "line": 18, + "column": 10 + }, + "end": { + "line": 18, + "column": 11 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 256, + 257 + ], + "loc": { + "start": { + "line": 18, + "column": 11 + }, + "end": { + "line": 19, + "column": 0 + } + }, + "value": "\n" + } + ], + "comments": [], + "errors": [] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/v-bind-same-name-shorthand04-with-v-for/parser-options.json b/test/fixtures/ast/v-bind-same-name-shorthand04-with-v-for/parser-options.json new file mode 100644 index 00000000..2104ca43 --- /dev/null +++ b/test/fixtures/ast/v-bind-same-name-shorthand04-with-v-for/parser-options.json @@ -0,0 +1,3 @@ +{ + "sourceType": "module" +} diff --git a/test/fixtures/ast/v-bind-same-name-shorthand04-with-v-for/requirements.json b/test/fixtures/ast/v-bind-same-name-shorthand04-with-v-for/requirements.json new file mode 100644 index 00000000..36659b1f --- /dev/null +++ b/test/fixtures/ast/v-bind-same-name-shorthand04-with-v-for/requirements.json @@ -0,0 +1,3 @@ +{ + "eslint": ">=8" +} \ No newline at end of file diff --git a/test/fixtures/ast/v-bind-same-name-shorthand04-with-v-for/scope.json b/test/fixtures/ast/v-bind-same-name-shorthand04-with-v-for/scope.json new file mode 100644 index 00000000..66d2c7f4 --- /dev/null +++ b/test/fixtures/ast/v-bind-same-name-shorthand04-with-v-for/scope.json @@ -0,0 +1,22 @@ +{ + "type": "global", + "variables": [], + "references": [], + "childScopes": [ + { + "type": "function", + "variables": [ + { + "name": "arguments", + "identifiers": [], + "defs": [], + "references": [] + } + ], + "references": [], + "childScopes": [], + "through": [] + } + ], + "through": [] +} \ No newline at end of file diff --git a/test/fixtures/ast/v-bind-same-name-shorthand04-with-v-for/source.vue b/test/fixtures/ast/v-bind-same-name-shorthand04-with-v-for/source.vue new file mode 100644 index 00000000..5717a8b8 --- /dev/null +++ b/test/fixtures/ast/v-bind-same-name-shorthand04-with-v-for/source.vue @@ -0,0 +1,18 @@ + + + diff --git a/test/fixtures/ast/v-bind-same-name-shorthand04-with-v-for/token-ranges.json b/test/fixtures/ast/v-bind-same-name-shorthand04-with-v-for/token-ranges.json new file mode 100644 index 00000000..6b5b352b --- /dev/null +++ b/test/fixtures/ast/v-bind-same-name-shorthand04-with-v-for/token-ranges.json @@ -0,0 +1,85 @@ +[ + "", + "", + "\n", + "export", + " ", + "default", + " ", + "{", + "\n ", + "data", + " ", + "()", + " ", + "{", + "\n ", + "return", + " ", + "{", + "\n ", + "srcList:", + " ", + "[", + "\n ", + "\"https://github.com/vuejs.png\",", + "\n ", + "\"https://github.com/vitejs.png\"", + "\n ", + "]", + "\n ", + "}", + "\n ", + "}", + "\n", + "}", + "\n", + "", + "\n\n", + "", + "\n ", + "", + "\n ", + "", + "\n ", + "", + "\n", + "", + "\n" +] \ No newline at end of file diff --git a/test/fixtures/ast/v-bind-same-name-shorthand04-with-v-for/tree.json b/test/fixtures/ast/v-bind-same-name-shorthand04-with-v-for/tree.json new file mode 100644 index 00000000..3f22d76a --- /dev/null +++ b/test/fixtures/ast/v-bind-same-name-shorthand04-with-v-for/tree.json @@ -0,0 +1,138 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/ast/v-bind-same-name-shorthand05-kebab/ast.json b/test/fixtures/ast/v-bind-same-name-shorthand05-kebab/ast.json new file mode 100644 index 00000000..1825f93e --- /dev/null +++ b/test/fixtures/ast/v-bind-same-name-shorthand05-kebab/ast.json @@ -0,0 +1,1166 @@ +{ + "type": "Program", + "start": 15, + "end": 40, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "range": [ + 15, + 40 + ], + "body": [ + { + "type": "VariableDeclaration", + "start": 15, + "end": 40, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "range": [ + 15, + 40 + ], + "declarations": [ + { + "type": "VariableDeclarator", + "start": 21, + "end": 40, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "range": [ + 21, + 40 + ], + "id": { + "type": "Identifier", + "start": 21, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "range": [ + 21, + 30 + ], + "name": "ariaLabel" + }, + "init": { + "type": "Literal", + "start": 33, + "end": 40, + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "range": [ + 33, + 40 + ], + "value": "Close", + "raw": "\"Close\"" + } + } + ], + "kind": "const" + } + ], + "sourceType": "module", + "comments": [], + "tokens": [ + { + "type": "Punctuator", + "range": [ + 0, + 14 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "value": "" + } + ], + "templateBody": { + "type": "VElement", + "range": [ + 52, + 125 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 7, + "column": 11 + } + }, + "name": "template", + "rawName": "template", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 52, + 62 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 62, + 65 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 6, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 65, + 113 + ], + "loc": { + "start": { + "line": 6, + "column": 2 + }, + "end": { + "line": 6, + "column": 50 + } + }, + "name": "button", + "rawName": "button", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 65, + 103 + ], + "loc": { + "start": { + "line": 6, + "column": 2 + }, + "end": { + "line": 6, + "column": 40 + } + }, + "selfClosing": false, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 73, + 84 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 21 + } + }, + "directive": true, + "key": { + "type": "VDirectiveKey", + "range": [ + 73, + 84 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 21 + } + }, + "name": { + "type": "VIdentifier", + "range": [ + 73, + 74 + ], + "loc": { + "start": { + "column": 10, + "line": 6 + }, + "end": { + "column": 11, + "line": 6 + } + }, + "name": "bind", + "rawName": ":" + }, + "argument": { + "type": "VIdentifier", + "range": [ + 74, + 84 + ], + "loc": { + "start": { + "column": 11, + "line": 6 + }, + "end": { + "column": 21, + "line": 6 + } + }, + "name": "aria-label", + "rawName": "aria-label" + }, + "modifiers": [] + }, + "value": { + "type": "VExpressionContainer", + "range": [ + 74, + 84 + ], + "loc": { + "start": { + "column": 11, + "line": 6 + }, + "end": { + "column": 21, + "line": 6 + } + }, + "expression": { + "type": "Identifier", + "start": 74, + "loc": { + "start": { + "line": 6, + "column": 11 + }, + "end": { + "column": 21, + "line": 6 + } + }, + "range": [ + 74, + 84 + ], + "name": "ariaLabel" + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 74, + "loc": { + "start": { + "line": 6, + "column": 11 + }, + "end": { + "column": 21, + "line": 6 + } + }, + "range": [ + 74, + 84 + ], + "name": "ariaLabel" + }, + "mode": "r", + "variable": null + } + ] + } + }, + { + "type": "VAttribute", + "range": [ + 85, + 102 + ], + "loc": { + "start": { + "line": 6, + "column": 22 + }, + "end": { + "line": 6, + "column": 39 + } + }, + "directive": false, + "key": { + "type": "VIdentifier", + "range": [ + 85, + 87 + ], + "loc": { + "start": { + "line": 6, + "column": 22 + }, + "end": { + "line": 6, + "column": 24 + } + }, + "name": "id", + "rawName": "id" + }, + "value": { + "type": "VLiteral", + "range": [ + 88, + 102 + ], + "loc": { + "start": { + "line": 6, + "column": 25 + }, + "end": { + "line": 6, + "column": 39 + } + }, + "value": "close-button" + } + } + ] + }, + "children": [ + { + "type": "VText", + "range": [ + 103, + 104 + ], + "loc": { + "start": { + "line": 6, + "column": 40 + }, + "end": { + "line": 6, + "column": 41 + } + }, + "value": "X" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 104, + 113 + ], + "loc": { + "start": { + "line": 6, + "column": 41 + }, + "end": { + "line": 6, + "column": 50 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 113, + 114 + ], + "loc": { + "start": { + "line": 6, + "column": 50 + }, + "end": { + "line": 7, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 114, + 125 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 11 + } + } + }, + "variables": [], + "tokens": [ + { + "type": "HTMLTagOpen", + "range": [ + 0, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLIdentifier", + "range": [ + 8, + 13 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": "setup" + }, + { + "type": "HTMLTagClose", + "range": [ + 13, + 14 + ], + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 14, + 15 + ], + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 15, + 20 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 20, + 21 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 21, + 30 + ], + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "value": "ariaLabel" + }, + { + "type": "HTMLWhitespace", + "range": [ + 30, + 31 + ], + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 31, + 32 + ], + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 32, + 33 + ], + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 33, + 40 + ], + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "value": "\"Close\"" + }, + { + "type": "HTMLWhitespace", + "range": [ + 40, + 41 + ], + "loc": { + "start": { + "line": 2, + "column": 25 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 41, + 49 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 49, + 50 + ], + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 50, + 52 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "value": "\n\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 52, + 61 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 61, + 62 + ], + "loc": { + "start": { + "line": 5, + "column": 9 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 62, + 65 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 6, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 65, + 72 + ], + "loc": { + "start": { + "line": 6, + "column": 2 + }, + "end": { + "line": 6, + "column": 9 + } + }, + "value": "button" + }, + { + "type": "Punctuator", + "range": [ + 73, + 74 + ], + "loc": { + "start": { + "column": 10, + "line": 6 + }, + "end": { + "column": 11, + "line": 6 + } + }, + "value": ":" + }, + { + "type": "HTMLIdentifier", + "range": [ + 74, + 84 + ], + "loc": { + "start": { + "column": 11, + "line": 6 + }, + "end": { + "column": 21, + "line": 6 + } + }, + "value": "aria-label" + }, + { + "type": "HTMLIdentifier", + "range": [ + 85, + 87 + ], + "loc": { + "start": { + "line": 6, + "column": 22 + }, + "end": { + "line": 6, + "column": 24 + } + }, + "value": "id" + }, + { + "type": "HTMLAssociation", + "range": [ + 87, + 88 + ], + "loc": { + "start": { + "line": 6, + "column": 24 + }, + "end": { + "line": 6, + "column": 25 + } + }, + "value": "" + }, + { + "type": "HTMLLiteral", + "range": [ + 88, + 102 + ], + "loc": { + "start": { + "line": 6, + "column": 25 + }, + "end": { + "line": 6, + "column": 39 + } + }, + "value": "close-button" + }, + { + "type": "HTMLTagClose", + "range": [ + 102, + 103 + ], + "loc": { + "start": { + "line": 6, + "column": 39 + }, + "end": { + "line": 6, + "column": 40 + } + }, + "value": "" + }, + { + "type": "HTMLText", + "range": [ + 103, + 104 + ], + "loc": { + "start": { + "line": 6, + "column": 40 + }, + "end": { + "line": 6, + "column": 41 + } + }, + "value": "X" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 104, + 112 + ], + "loc": { + "start": { + "line": 6, + "column": 41 + }, + "end": { + "line": 6, + "column": 49 + } + }, + "value": "button" + }, + { + "type": "HTMLTagClose", + "range": [ + 112, + 113 + ], + "loc": { + "start": { + "line": 6, + "column": 49 + }, + "end": { + "line": 6, + "column": 50 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 113, + 114 + ], + "loc": { + "start": { + "line": 6, + "column": 50 + }, + "end": { + "line": 7, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 114, + 124 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 124, + 125 + ], + "loc": { + "start": { + "line": 7, + "column": 10 + }, + "end": { + "line": 7, + "column": 11 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 125, + 126 + ], + "loc": { + "start": { + "line": 7, + "column": 11 + }, + "end": { + "line": 8, + "column": 0 + } + }, + "value": "\n" + } + ], + "comments": [], + "errors": [] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/v-bind-same-name-shorthand05-kebab/parser-options.json b/test/fixtures/ast/v-bind-same-name-shorthand05-kebab/parser-options.json new file mode 100644 index 00000000..2104ca43 --- /dev/null +++ b/test/fixtures/ast/v-bind-same-name-shorthand05-kebab/parser-options.json @@ -0,0 +1,3 @@ +{ + "sourceType": "module" +} diff --git a/test/fixtures/ast/v-bind-same-name-shorthand05-kebab/requirements.json b/test/fixtures/ast/v-bind-same-name-shorthand05-kebab/requirements.json new file mode 100644 index 00000000..36659b1f --- /dev/null +++ b/test/fixtures/ast/v-bind-same-name-shorthand05-kebab/requirements.json @@ -0,0 +1,3 @@ +{ + "eslint": ">=8" +} \ No newline at end of file diff --git a/test/fixtures/ast/v-bind-same-name-shorthand05-kebab/scope.json b/test/fixtures/ast/v-bind-same-name-shorthand05-kebab/scope.json new file mode 100644 index 00000000..b6a55688 --- /dev/null +++ b/test/fixtures/ast/v-bind-same-name-shorthand05-kebab/scope.json @@ -0,0 +1,154 @@ +{ + "type": "global", + "variables": [], + "references": [], + "childScopes": [ + { + "type": "module", + "variables": [ + { + "name": "ariaLabel", + "identifiers": [ + { + "type": "Identifier", + "name": "ariaLabel", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 15 + } + } + } + ], + "defs": [ + { + "type": "Variable", + "node": { + "type": "VariableDeclarator", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 25 + } + } + }, + "name": "ariaLabel" + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "ariaLabel", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 15 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "ariaLabel", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 15 + } + } + }, + "init": true + }, + { + "identifier": { + "type": "Identifier", + "name": "ariaLabel", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 15 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "ariaLabel", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 15 + } + } + }, + "init": null, + "vueUsedInTemplate": true + } + ] + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "ariaLabel", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 15 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "ariaLabel", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 15 + } + } + }, + "init": true + } + ], + "childScopes": [], + "through": [] + } + ], + "through": [] +} \ No newline at end of file diff --git a/test/fixtures/ast/v-bind-same-name-shorthand05-kebab/source.vue b/test/fixtures/ast/v-bind-same-name-shorthand05-kebab/source.vue new file mode 100644 index 00000000..8ec33eb1 --- /dev/null +++ b/test/fixtures/ast/v-bind-same-name-shorthand05-kebab/source.vue @@ -0,0 +1,7 @@ + + + diff --git a/test/fixtures/ast/v-bind-same-name-shorthand05-kebab/token-ranges.json b/test/fixtures/ast/v-bind-same-name-shorthand05-kebab/token-ranges.json new file mode 100644 index 00000000..da1ef87b --- /dev/null +++ b/test/fixtures/ast/v-bind-same-name-shorthand05-kebab/token-ranges.json @@ -0,0 +1,40 @@ +[ + "", + "", + "\n", + "const", + " ", + "ariaLabel", + " ", + "=", + " ", + "\"Close\"", + "\n", + "", + "\n\n", + "", + "\n ", + "", + "X", + "", + "\n", + "", + "\n" +] \ No newline at end of file diff --git a/test/fixtures/ast/v-bind-same-name-shorthand05-kebab/tree.json b/test/fixtures/ast/v-bind-same-name-shorthand05-kebab/tree.json new file mode 100644 index 00000000..aca3bf7e --- /dev/null +++ b/test/fixtures/ast/v-bind-same-name-shorthand05-kebab/tree.json @@ -0,0 +1,99 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/ast/v-bind-same-name-shorthand06-invalid/ast.json b/test/fixtures/ast/v-bind-same-name-shorthand06-invalid/ast.json new file mode 100644 index 00000000..2077a1b0 --- /dev/null +++ b/test/fixtures/ast/v-bind-same-name-shorthand06-invalid/ast.json @@ -0,0 +1,1078 @@ +{ + "type": "Program", + "start": 15, + "end": 36, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "range": [ + 15, + 36 + ], + "body": [ + { + "type": "VariableDeclaration", + "start": 15, + "end": 36, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "range": [ + 15, + 36 + ], + "declarations": [ + { + "type": "VariableDeclarator", + "start": 21, + "end": 36, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "range": [ + 21, + 36 + ], + "id": { + "type": "Identifier", + "start": 21, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "range": [ + 21, + 26 + ], + "name": "title" + }, + "init": { + "type": "Literal", + "start": 29, + "end": 36, + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "range": [ + 29, + 36 + ], + "value": "title", + "raw": "'title'" + } + } + ], + "kind": "const" + } + ], + "sourceType": "module", + "comments": [], + "tokens": [ + { + "type": "Punctuator", + "range": [ + 0, + 14 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "value": "" + } + ], + "templateBody": { + "type": "VElement", + "range": [ + 48, + 101 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 7, + "column": 11 + } + }, + "name": "template", + "rawName": "template", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 48, + 58 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 58, + 61 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 6, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 61, + 89 + ], + "loc": { + "start": { + "line": 6, + "column": 2 + }, + "end": { + "line": 6, + "column": 30 + } + }, + "name": "button", + "rawName": "button", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 61, + 79 + ], + "loc": { + "start": { + "line": 6, + "column": 2 + }, + "end": { + "line": 6, + "column": 20 + } + }, + "selfClosing": false, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 69, + 77 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 18 + } + }, + "directive": true, + "key": { + "type": "VDirectiveKey", + "range": [ + 69, + 77 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 18 + } + }, + "name": { + "type": "VIdentifier", + "range": [ + 69, + 70 + ], + "loc": { + "start": { + "column": 10, + "line": 6 + }, + "end": { + "column": 11, + "line": 6 + } + }, + "name": "bind", + "rawName": ":" + }, + "argument": { + "type": "VExpressionContainer", + "range": [ + 70, + 77 + ], + "loc": { + "start": { + "column": 11, + "line": 6 + }, + "end": { + "column": 18, + "line": 6 + } + }, + "expression": { + "type": "Identifier", + "start": 71, + "end": 76, + "loc": { + "start": { + "line": 6, + "column": 12 + }, + "end": { + "line": 6, + "column": 17 + } + }, + "range": [ + 71, + 76 + ], + "name": "title" + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 71, + "end": 76, + "loc": { + "start": { + "line": 6, + "column": 12 + }, + "end": { + "line": 6, + "column": 17 + } + }, + "range": [ + 71, + 76 + ], + "name": "title" + }, + "mode": "r" + } + ] + }, + "modifiers": [] + }, + "value": null + } + ] + }, + "children": [ + { + "type": "VText", + "range": [ + 79, + 80 + ], + "loc": { + "start": { + "line": 6, + "column": 20 + }, + "end": { + "line": 6, + "column": 21 + } + }, + "value": "X" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 80, + 89 + ], + "loc": { + "start": { + "line": 6, + "column": 21 + }, + "end": { + "line": 6, + "column": 30 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 89, + 90 + ], + "loc": { + "start": { + "line": 6, + "column": 30 + }, + "end": { + "line": 7, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 90, + 101 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 11 + } + } + }, + "variables": [], + "tokens": [ + { + "type": "HTMLTagOpen", + "range": [ + 0, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLIdentifier", + "range": [ + 8, + 13 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": "setup" + }, + { + "type": "HTMLTagClose", + "range": [ + 13, + 14 + ], + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 14, + 15 + ], + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 15, + 20 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 20, + 21 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 21, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "value": "title" + }, + { + "type": "HTMLWhitespace", + "range": [ + 26, + 27 + ], + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 27, + 28 + ], + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 28, + 29 + ], + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 29, + 36 + ], + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "value": "'title'" + }, + { + "type": "HTMLWhitespace", + "range": [ + 36, + 37 + ], + "loc": { + "start": { + "line": 2, + "column": 21 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 37, + 45 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 45, + 46 + ], + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 46, + 48 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "value": "\n\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 48, + 57 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 57, + 58 + ], + "loc": { + "start": { + "line": 5, + "column": 9 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 58, + 61 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 6, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 61, + 68 + ], + "loc": { + "start": { + "line": 6, + "column": 2 + }, + "end": { + "line": 6, + "column": 9 + } + }, + "value": "button" + }, + { + "type": "Punctuator", + "range": [ + 69, + 70 + ], + "loc": { + "start": { + "column": 10, + "line": 6 + }, + "end": { + "column": 11, + "line": 6 + } + }, + "value": ":" + }, + { + "type": "Punctuator", + "range": [ + 70, + 71 + ], + "loc": { + "start": { + "line": 6, + "column": 11 + }, + "end": { + "line": 6, + "column": 12 + } + }, + "value": "[" + }, + { + "type": "Identifier", + "value": "title", + "start": 71, + "end": 76, + "loc": { + "start": { + "line": 6, + "column": 12 + }, + "end": { + "line": 6, + "column": 17 + } + }, + "range": [ + 71, + 76 + ] + }, + { + "type": "Punctuator", + "range": [ + 76, + 77 + ], + "loc": { + "start": { + "line": 6, + "column": 17 + }, + "end": { + "line": 6, + "column": 18 + } + }, + "value": "]" + }, + { + "type": "HTMLTagClose", + "range": [ + 78, + 79 + ], + "loc": { + "start": { + "line": 6, + "column": 19 + }, + "end": { + "line": 6, + "column": 20 + } + }, + "value": "" + }, + { + "type": "HTMLText", + "range": [ + 79, + 80 + ], + "loc": { + "start": { + "line": 6, + "column": 20 + }, + "end": { + "line": 6, + "column": 21 + } + }, + "value": "X" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 80, + 88 + ], + "loc": { + "start": { + "line": 6, + "column": 21 + }, + "end": { + "line": 6, + "column": 29 + } + }, + "value": "button" + }, + { + "type": "HTMLTagClose", + "range": [ + 88, + 89 + ], + "loc": { + "start": { + "line": 6, + "column": 29 + }, + "end": { + "line": 6, + "column": 30 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 89, + 90 + ], + "loc": { + "start": { + "line": 6, + "column": 30 + }, + "end": { + "line": 7, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 90, + 100 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 100, + 101 + ], + "loc": { + "start": { + "line": 7, + "column": 10 + }, + "end": { + "line": 7, + "column": 11 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 101, + 102 + ], + "loc": { + "start": { + "line": 7, + "column": 11 + }, + "end": { + "line": 8, + "column": 0 + } + }, + "value": "\n" + } + ], + "comments": [], + "errors": [] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/v-bind-same-name-shorthand06-invalid/parser-options.json b/test/fixtures/ast/v-bind-same-name-shorthand06-invalid/parser-options.json new file mode 100644 index 00000000..2104ca43 --- /dev/null +++ b/test/fixtures/ast/v-bind-same-name-shorthand06-invalid/parser-options.json @@ -0,0 +1,3 @@ +{ + "sourceType": "module" +} diff --git a/test/fixtures/ast/v-bind-same-name-shorthand06-invalid/requirements.json b/test/fixtures/ast/v-bind-same-name-shorthand06-invalid/requirements.json new file mode 100644 index 00000000..36659b1f --- /dev/null +++ b/test/fixtures/ast/v-bind-same-name-shorthand06-invalid/requirements.json @@ -0,0 +1,3 @@ +{ + "eslint": ">=8" +} \ No newline at end of file diff --git a/test/fixtures/ast/v-bind-same-name-shorthand06-invalid/scope.json b/test/fixtures/ast/v-bind-same-name-shorthand06-invalid/scope.json new file mode 100644 index 00000000..eb7b762d --- /dev/null +++ b/test/fixtures/ast/v-bind-same-name-shorthand06-invalid/scope.json @@ -0,0 +1,154 @@ +{ + "type": "global", + "variables": [], + "references": [], + "childScopes": [ + { + "type": "module", + "variables": [ + { + "name": "title", + "identifiers": [ + { + "type": "Identifier", + "name": "title", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 11 + } + } + } + ], + "defs": [ + { + "type": "Variable", + "node": { + "type": "VariableDeclarator", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 21 + } + } + }, + "name": "title" + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "title", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 11 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "title", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 11 + } + } + }, + "init": true + }, + { + "identifier": { + "type": "Identifier", + "name": "title", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 11 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "title", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 11 + } + } + }, + "init": null, + "vueUsedInTemplate": true + } + ] + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "title", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 11 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "title", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 11 + } + } + }, + "init": true + } + ], + "childScopes": [], + "through": [] + } + ], + "through": [] +} \ No newline at end of file diff --git a/test/fixtures/ast/v-bind-same-name-shorthand06-invalid/source.vue b/test/fixtures/ast/v-bind-same-name-shorthand06-invalid/source.vue new file mode 100644 index 00000000..9fae2ab1 --- /dev/null +++ b/test/fixtures/ast/v-bind-same-name-shorthand06-invalid/source.vue @@ -0,0 +1,7 @@ + + + diff --git a/test/fixtures/ast/v-bind-same-name-shorthand06-invalid/token-ranges.json b/test/fixtures/ast/v-bind-same-name-shorthand06-invalid/token-ranges.json new file mode 100644 index 00000000..27b0500b --- /dev/null +++ b/test/fixtures/ast/v-bind-same-name-shorthand06-invalid/token-ranges.json @@ -0,0 +1,39 @@ +[ + "", + "", + "\n", + "const", + " ", + "title", + " ", + "=", + " ", + "'title'", + "\n", + "", + "\n\n", + "", + "\n ", + "", + "X", + "", + "\n", + "", + "\n" +] \ No newline at end of file diff --git a/test/fixtures/ast/v-bind-same-name-shorthand06-invalid/tree.json b/test/fixtures/ast/v-bind-same-name-shorthand06-invalid/tree.json new file mode 100644 index 00000000..c5fdc90c --- /dev/null +++ b/test/fixtures/ast/v-bind-same-name-shorthand06-invalid/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/v-bind-same-name-shorthand07-camelcase/ast.json b/test/fixtures/ast/v-bind-same-name-shorthand07-camelcase/ast.json new file mode 100644 index 00000000..06d41c77 --- /dev/null +++ b/test/fixtures/ast/v-bind-same-name-shorthand07-camelcase/ast.json @@ -0,0 +1,968 @@ +{ + "type": "Program", + "start": 15, + "end": 60, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 45 + } + }, + "range": [ + 15, + 60 + ], + "body": [ + { + "type": "VariableDeclaration", + "start": 15, + "end": 60, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 45 + } + }, + "range": [ + 15, + 60 + ], + "declarations": [ + { + "type": "VariableDeclarator", + "start": 21, + "end": 60, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 45 + } + }, + "range": [ + 21, + 60 + ], + "id": { + "type": "Identifier", + "start": 21, + "end": 27, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "range": [ + 21, + 27 + ], + "name": "srcUrl" + }, + "init": { + "type": "Literal", + "start": 30, + "end": 60, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 45 + } + }, + "range": [ + 30, + 60 + ], + "value": "https://github.com/vuejs.png", + "raw": "\"https://github.com/vuejs.png\"" + } + } + ], + "kind": "const" + } + ], + "sourceType": "module", + "comments": [], + "tokens": [ + { + "type": "Punctuator", + "range": [ + 0, + 14 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "value": "" + } + ], + "templateBody": { + "type": "VElement", + "range": [ + 72, + 110 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 7, + "column": 11 + } + }, + "name": "template", + "rawName": "template", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 72, + 82 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 82, + 85 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 6, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 85, + 98 + ], + "loc": { + "start": { + "line": 6, + "column": 2 + }, + "end": { + "line": 6, + "column": 15 + } + }, + "name": "img", + "rawName": "img", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 85, + 98 + ], + "loc": { + "start": { + "line": 6, + "column": 2 + }, + "end": { + "line": 6, + "column": 15 + } + }, + "selfClosing": false, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 90, + 97 + ], + "loc": { + "start": { + "line": 6, + "column": 7 + }, + "end": { + "line": 6, + "column": 14 + } + }, + "directive": true, + "key": { + "type": "VDirectiveKey", + "range": [ + 90, + 97 + ], + "loc": { + "start": { + "line": 6, + "column": 7 + }, + "end": { + "line": 6, + "column": 14 + } + }, + "name": { + "type": "VIdentifier", + "range": [ + 90, + 91 + ], + "loc": { + "start": { + "column": 7, + "line": 6 + }, + "end": { + "column": 8, + "line": 6 + } + }, + "name": "bind", + "rawName": ":" + }, + "argument": { + "type": "VIdentifier", + "range": [ + 91, + 97 + ], + "loc": { + "start": { + "column": 8, + "line": 6 + }, + "end": { + "column": 14, + "line": 6 + } + }, + "name": "srcurl", + "rawName": "srcUrl" + }, + "modifiers": [] + }, + "value": { + "type": "VExpressionContainer", + "range": [ + 91, + 97 + ], + "loc": { + "start": { + "column": 8, + "line": 6 + }, + "end": { + "column": 14, + "line": 6 + } + }, + "expression": { + "type": "Identifier", + "start": 91, + "loc": { + "start": { + "line": 6, + "column": 8 + }, + "end": { + "column": 14, + "line": 6 + } + }, + "range": [ + 91, + 97 + ], + "name": "srcUrl" + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 91, + "loc": { + "start": { + "line": 6, + "column": 8 + }, + "end": { + "column": 14, + "line": 6 + } + }, + "range": [ + 91, + 97 + ], + "name": "srcUrl" + }, + "mode": "r", + "variable": null + } + ] + } + } + ] + }, + "children": [], + "endTag": null, + "variables": [] + }, + { + "type": "VText", + "range": [ + 98, + 99 + ], + "loc": { + "start": { + "line": 6, + "column": 15 + }, + "end": { + "line": 7, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 99, + 110 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 11 + } + } + }, + "variables": [], + "tokens": [ + { + "type": "HTMLTagOpen", + "range": [ + 0, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLIdentifier", + "range": [ + 8, + 13 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": "setup" + }, + { + "type": "HTMLTagClose", + "range": [ + 13, + 14 + ], + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 14, + 15 + ], + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 15, + 20 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 20, + 21 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 21, + 27 + ], + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "value": "srcUrl" + }, + { + "type": "HTMLWhitespace", + "range": [ + 27, + 28 + ], + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 28, + 29 + ], + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 29, + 30 + ], + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 30, + 60 + ], + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 45 + } + }, + "value": "\"https://github.com/vuejs.png\"" + }, + { + "type": "HTMLWhitespace", + "range": [ + 60, + 61 + ], + "loc": { + "start": { + "line": 2, + "column": 45 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 61, + 69 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 69, + 70 + ], + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 70, + 72 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "value": "\n\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 72, + 81 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 81, + 82 + ], + "loc": { + "start": { + "line": 5, + "column": 9 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 82, + 85 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 6, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 85, + 89 + ], + "loc": { + "start": { + "line": 6, + "column": 2 + }, + "end": { + "line": 6, + "column": 6 + } + }, + "value": "img" + }, + { + "type": "Punctuator", + "range": [ + 90, + 91 + ], + "loc": { + "start": { + "column": 7, + "line": 6 + }, + "end": { + "column": 8, + "line": 6 + } + }, + "value": ":" + }, + { + "type": "HTMLIdentifier", + "range": [ + 91, + 97 + ], + "loc": { + "start": { + "column": 8, + "line": 6 + }, + "end": { + "column": 14, + "line": 6 + } + }, + "value": "srcUrl" + }, + { + "type": "HTMLTagClose", + "range": [ + 97, + 98 + ], + "loc": { + "start": { + "line": 6, + "column": 14 + }, + "end": { + "line": 6, + "column": 15 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 98, + 99 + ], + "loc": { + "start": { + "line": 6, + "column": 15 + }, + "end": { + "line": 7, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 99, + 109 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 109, + 110 + ], + "loc": { + "start": { + "line": 7, + "column": 10 + }, + "end": { + "line": 7, + "column": 11 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 110, + 111 + ], + "loc": { + "start": { + "line": 7, + "column": 11 + }, + "end": { + "line": 8, + "column": 0 + } + }, + "value": "\n" + } + ], + "comments": [], + "errors": [] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/v-bind-same-name-shorthand07-camelcase/parser-options.json b/test/fixtures/ast/v-bind-same-name-shorthand07-camelcase/parser-options.json new file mode 100644 index 00000000..2104ca43 --- /dev/null +++ b/test/fixtures/ast/v-bind-same-name-shorthand07-camelcase/parser-options.json @@ -0,0 +1,3 @@ +{ + "sourceType": "module" +} diff --git a/test/fixtures/ast/v-bind-same-name-shorthand07-camelcase/requirements.json b/test/fixtures/ast/v-bind-same-name-shorthand07-camelcase/requirements.json new file mode 100644 index 00000000..36659b1f --- /dev/null +++ b/test/fixtures/ast/v-bind-same-name-shorthand07-camelcase/requirements.json @@ -0,0 +1,3 @@ +{ + "eslint": ">=8" +} \ No newline at end of file diff --git a/test/fixtures/ast/v-bind-same-name-shorthand07-camelcase/scope.json b/test/fixtures/ast/v-bind-same-name-shorthand07-camelcase/scope.json new file mode 100644 index 00000000..ca436a8c --- /dev/null +++ b/test/fixtures/ast/v-bind-same-name-shorthand07-camelcase/scope.json @@ -0,0 +1,154 @@ +{ + "type": "global", + "variables": [], + "references": [], + "childScopes": [ + { + "type": "module", + "variables": [ + { + "name": "srcUrl", + "identifiers": [ + { + "type": "Identifier", + "name": "srcUrl", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 12 + } + } + } + ], + "defs": [ + { + "type": "Variable", + "node": { + "type": "VariableDeclarator", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 45 + } + } + }, + "name": "srcUrl" + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "srcUrl", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 12 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "srcUrl", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 12 + } + } + }, + "init": true + }, + { + "identifier": { + "type": "Identifier", + "name": "srcUrl", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 12 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "srcUrl", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 12 + } + } + }, + "init": null, + "vueUsedInTemplate": true + } + ] + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "srcUrl", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 12 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "srcUrl", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 12 + } + } + }, + "init": true + } + ], + "childScopes": [], + "through": [] + } + ], + "through": [] +} \ No newline at end of file diff --git a/test/fixtures/ast/v-bind-same-name-shorthand07-camelcase/source.vue b/test/fixtures/ast/v-bind-same-name-shorthand07-camelcase/source.vue new file mode 100644 index 00000000..6888a5e6 --- /dev/null +++ b/test/fixtures/ast/v-bind-same-name-shorthand07-camelcase/source.vue @@ -0,0 +1,7 @@ + + + diff --git a/test/fixtures/ast/v-bind-same-name-shorthand07-camelcase/token-ranges.json b/test/fixtures/ast/v-bind-same-name-shorthand07-camelcase/token-ranges.json new file mode 100644 index 00000000..9fa6dc66 --- /dev/null +++ b/test/fixtures/ast/v-bind-same-name-shorthand07-camelcase/token-ranges.json @@ -0,0 +1,34 @@ +[ + "", + "", + "\n", + "const", + " ", + "srcUrl", + " ", + "=", + " ", + "\"https://github.com/vuejs.png\"", + "\n", + "", + "\n\n", + "", + "\n ", + "", + "\n", + "", + "\n" +] \ No newline at end of file diff --git a/test/fixtures/ast/v-bind-same-name-shorthand07-camelcase/tree.json b/test/fixtures/ast/v-bind-same-name-shorthand07-camelcase/tree.json new file mode 100644 index 00000000..75a9fb2c --- /dev/null +++ b/test/fixtures/ast/v-bind-same-name-shorthand07-camelcase/tree.json @@ -0,0 +1,73 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/ast/v-bind-sequence-expression/ast.json b/test/fixtures/ast/v-bind-sequence-expression/ast.json index 79cbf7a3..34ebd90b 100644 --- a/test/fixtures/ast/v-bind-sequence-expression/ast.json +++ b/test/fixtures/ast/v-bind-sequence-expression/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/v-bind-spread-element/ast.json b/test/fixtures/ast/v-bind-spread-element/ast.json index 8600e444..ab827027 100644 --- a/test/fixtures/ast/v-bind-spread-element/ast.json +++ b/test/fixtures/ast/v-bind-spread-element/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/v-for-directives-error-with-es5/parser-options.json b/test/fixtures/ast/v-for-directives-error-with-es5/parser-options.json index fcc8a62f..03c6610d 100644 --- a/test/fixtures/ast/v-for-directives-error-with-es5/parser-options.json +++ b/test/fixtures/ast/v-for-directives-error-with-es5/parser-options.json @@ -1,3 +1,4 @@ { - "ecmaVersion": 5 + "ecmaVersion": 5, + "sourceType": "script" } diff --git a/test/fixtures/ast/v-for-directives-error/ast.json b/test/fixtures/ast/v-for-directives-error/ast.json index a79f66fa..9c9bf3fd 100644 --- a/test/fixtures/ast/v-for-directives-error/ast.json +++ b/test/fixtures/ast/v-for-directives-error/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/v-for-directives-index/ast.json b/test/fixtures/ast/v-for-directives-index/ast.json index 36768789..df5c82af 100644 --- a/test/fixtures/ast/v-for-directives-index/ast.json +++ b/test/fixtures/ast/v-for-directives-index/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/v-for-directives-with-destructuring/ast.json b/test/fixtures/ast/v-for-directives-with-destructuring/ast.json index 6e5ebe7d..b6ede250 100644 --- a/test/fixtures/ast/v-for-directives-with-destructuring/ast.json +++ b/test/fixtures/ast/v-for-directives-with-destructuring/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { @@ -262,7 +262,6 @@ ], "name": "key" }, - "kind": "init", "value": { "type": "Identifier", "start": 28, @@ -282,7 +281,8 @@ 31 ], "name": "key" - } + }, + "kind": "init" }, { "type": "Property", @@ -325,7 +325,6 @@ ], "name": "name" }, - "kind": "init", "value": { "type": "Identifier", "start": 32, @@ -345,7 +344,8 @@ 36 ], "name": "name" - } + }, + "kind": "init" } ] } @@ -1460,7 +1460,6 @@ ], "name": "name" }, - "kind": "init", "value": { "type": "Identifier", "start": 163, @@ -1480,7 +1479,8 @@ 167 ], "name": "name" - } + }, + "kind": "init" } ] } diff --git a/test/fixtures/ast/v-for-directives-with-es5-2/parser-options.json b/test/fixtures/ast/v-for-directives-with-es5-2/parser-options.json index fcc8a62f..03c6610d 100644 --- a/test/fixtures/ast/v-for-directives-with-es5-2/parser-options.json +++ b/test/fixtures/ast/v-for-directives-with-es5-2/parser-options.json @@ -1,3 +1,4 @@ { - "ecmaVersion": 5 + "ecmaVersion": 5, + "sourceType": "script" } diff --git a/test/fixtures/ast/v-for-directives-with-es5/parser-options.json b/test/fixtures/ast/v-for-directives-with-es5/parser-options.json index fcc8a62f..03c6610d 100644 --- a/test/fixtures/ast/v-for-directives-with-es5/parser-options.json +++ b/test/fixtures/ast/v-for-directives-with-es5/parser-options.json @@ -1,3 +1,4 @@ { - "ecmaVersion": 5 + "ecmaVersion": 5, + "sourceType": "script" } diff --git a/test/fixtures/ast/v-for-directives/ast.json b/test/fixtures/ast/v-for-directives/ast.json index 4672c8d4..eb74e84d 100644 --- a/test/fixtures/ast/v-for-directives/ast.json +++ b/test/fixtures/ast/v-for-directives/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/v-on-arrow-function-expression.1/ast.json b/test/fixtures/ast/v-on-arrow-function-expression.1/ast.json index 4ecfef08..e96836d7 100644 --- a/test/fixtures/ast/v-on-arrow-function-expression.1/ast.json +++ b/test/fixtures/ast/v-on-arrow-function-expression.1/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/v-on-arrow-function-expression.2/ast.json b/test/fixtures/ast/v-on-arrow-function-expression.2/ast.json index a4a43c5b..79b19281 100644 --- a/test/fixtures/ast/v-on-arrow-function-expression.2/ast.json +++ b/test/fixtures/ast/v-on-arrow-function-expression.2/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/v-on-async-arrow-function-expression/ast.json b/test/fixtures/ast/v-on-async-arrow-function-expression/ast.json new file mode 100644 index 00000000..76c9ea47 --- /dev/null +++ b/test/fixtures/ast/v-on-async-arrow-function-expression/ast.json @@ -0,0 +1,829 @@ +{ + "type": "Program", + "start": 0, + "end": 0, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 0 + } + }, + "range": [ + 0, + 0 + ], + "body": [], + "sourceType": "module", + "comments": [], + "tokens": [], + "templateBody": { + "type": "VElement", + "range": [ + 0, + 77 + ], + "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, + 65 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 54 + } + }, + "name": "button", + "rawName": "button", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 15, + 56 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 45 + } + }, + "selfClosing": false, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 23, + 55 + ], + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 44 + } + }, + "directive": true, + "key": { + "type": "VDirectiveKey", + "range": [ + 23, + 29 + ], + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "name": { + "type": "VIdentifier", + "range": [ + 23, + 24 + ], + "loc": { + "start": { + "column": 12, + "line": 2 + }, + "end": { + "column": 13, + "line": 2 + } + }, + "name": "on", + "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", + "range": [ + 30, + 55 + ], + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 44 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 31, + "end": 54, + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 43 + } + }, + "range": [ + 31, + 54 + ], + "id": null, + "expression": true, + "generator": false, + "async": true, + "params": [], + "body": { + "type": "AwaitExpression", + "start": 43, + "end": 54, + "loc": { + "start": { + "line": 2, + "column": 32 + }, + "end": { + "line": 2, + "column": 43 + } + }, + "range": [ + 43, + 54 + ], + "argument": { + "type": "CallExpression", + "start": 49, + "end": 54, + "loc": { + "start": { + "line": 2, + "column": 38 + }, + "end": { + "line": 2, + "column": 43 + } + }, + "range": [ + 49, + 54 + ], + "callee": { + "type": "Identifier", + "start": 49, + "end": 52, + "loc": { + "start": { + "line": 2, + "column": 38 + }, + "end": { + "line": 2, + "column": 41 + } + }, + "range": [ + 49, + 52 + ], + "name": "act" + }, + "arguments": [], + "optional": false + } + } + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 49, + "end": 52, + "loc": { + "start": { + "line": 2, + "column": 38 + }, + "end": { + "line": 2, + "column": 41 + } + }, + "range": [ + 49, + 52 + ], + "name": "act" + }, + "mode": "r" + } + ] + } + } + ] + }, + "children": [], + "endTag": { + "type": "VEndTag", + "range": [ + 56, + 65 + ], + "loc": { + "start": { + "line": 2, + "column": 45 + }, + "end": { + "line": 2, + "column": 54 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 65, + 66 + ], + "loc": { + "start": { + "line": 2, + "column": 54 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 66, + 77 + ], + "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, + 29 + ], + "loc": { + "start": { + "column": 13, + "line": 2 + }, + "end": { + "column": 18, + "line": 2 + } + }, + "value": "click" + }, + { + "type": "HTMLAssociation", + "range": [ + 29, + 30 + ], + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 30, + 31 + ], + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "value": "async", + "start": 31, + "end": 36, + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "range": [ + 31, + 36 + ] + }, + { + "type": "Punctuator", + "value": "(", + "start": 37, + "end": 38, + "loc": { + "start": { + "line": 2, + "column": 26 + }, + "end": { + "line": 2, + "column": 27 + } + }, + "range": [ + 37, + 38 + ] + }, + { + "type": "Punctuator", + "value": ")", + "start": 38, + "end": 39, + "loc": { + "start": { + "line": 2, + "column": 27 + }, + "end": { + "line": 2, + "column": 28 + } + }, + "range": [ + 38, + 39 + ] + }, + { + "type": "Punctuator", + "value": "=>", + "start": 40, + "end": 42, + "loc": { + "start": { + "line": 2, + "column": 29 + }, + "end": { + "line": 2, + "column": 31 + } + }, + "range": [ + 40, + 42 + ] + }, + { + "type": "Identifier", + "value": "await", + "start": 43, + "end": 48, + "loc": { + "start": { + "line": 2, + "column": 32 + }, + "end": { + "line": 2, + "column": 37 + } + }, + "range": [ + 43, + 48 + ] + }, + { + "type": "Identifier", + "value": "act", + "start": 49, + "end": 52, + "loc": { + "start": { + "line": 2, + "column": 38 + }, + "end": { + "line": 2, + "column": 41 + } + }, + "range": [ + 49, + 52 + ] + }, + { + "type": "Punctuator", + "value": "(", + "start": 52, + "end": 53, + "loc": { + "start": { + "line": 2, + "column": 41 + }, + "end": { + "line": 2, + "column": 42 + } + }, + "range": [ + 52, + 53 + ] + }, + { + "type": "Punctuator", + "value": ")", + "start": 53, + "end": 54, + "loc": { + "start": { + "line": 2, + "column": 42 + }, + "end": { + "line": 2, + "column": 43 + } + }, + "range": [ + 53, + 54 + ] + }, + { + "type": "Punctuator", + "range": [ + 54, + 55 + ], + "loc": { + "start": { + "line": 2, + "column": 43 + }, + "end": { + "line": 2, + "column": 44 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 55, + 56 + ], + "loc": { + "start": { + "line": 2, + "column": 44 + }, + "end": { + "line": 2, + "column": 45 + } + }, + "value": "" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 56, + 64 + ], + "loc": { + "start": { + "line": 2, + "column": 45 + }, + "end": { + "line": 2, + "column": 53 + } + }, + "value": "button" + }, + { + "type": "HTMLTagClose", + "range": [ + 64, + 65 + ], + "loc": { + "start": { + "line": 2, + "column": 53 + }, + "end": { + "line": 2, + "column": 54 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 65, + 66 + ], + "loc": { + "start": { + "line": 2, + "column": 54 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 66, + 76 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 76, + 77 + ], + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 77, + 78 + ], + "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/v-on-async-arrow-function-expression/source.vue b/test/fixtures/ast/v-on-async-arrow-function-expression/source.vue new file mode 100644 index 00000000..9cdad449 --- /dev/null +++ b/test/fixtures/ast/v-on-async-arrow-function-expression/source.vue @@ -0,0 +1,3 @@ + diff --git a/test/fixtures/ast/v-on-async-arrow-function-expression/token-ranges.json b/test/fixtures/ast/v-on-async-arrow-function-expression/token-ranges.json new file mode 100644 index 00000000..032294ca --- /dev/null +++ b/test/fixtures/ast/v-on-async-arrow-function-expression/token-ranges.json @@ -0,0 +1,26 @@ +[ + "", + "\n ", + "", + "await", + "act", + "(", + ")", + "\"", + ">", + "", + "\n", + "", + "\n" +] \ No newline at end of file diff --git a/test/fixtures/ast/v-on-async-arrow-function-expression/tree.json b/test/fixtures/ast/v-on-async-arrow-function-expression/tree.json new file mode 100644 index 00000000..d272edfa --- /dev/null +++ b/test/fixtures/ast/v-on-async-arrow-function-expression/tree.json @@ -0,0 +1,96 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/ast/v-on-async-function-expression/ast.json b/test/fixtures/ast/v-on-async-function-expression/ast.json new file mode 100644 index 00000000..af3d12eb --- /dev/null +++ b/test/fixtures/ast/v-on-async-function-expression/ast.json @@ -0,0 +1,909 @@ +{ + "type": "Program", + "start": 0, + "end": 0, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 0 + } + }, + "range": [ + 0, + 0 + ], + "body": [], + "sourceType": "module", + "comments": [], + "tokens": [], + "templateBody": { + "type": "VElement", + "range": [ + 0, + 86 + ], + "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, + 74 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 63 + } + }, + "name": "button", + "rawName": "button", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 15, + 65 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 54 + } + }, + "selfClosing": false, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 23, + 64 + ], + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 53 + } + }, + "directive": true, + "key": { + "type": "VDirectiveKey", + "range": [ + 23, + 29 + ], + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "name": { + "type": "VIdentifier", + "range": [ + 23, + 24 + ], + "loc": { + "start": { + "column": 12, + "line": 2 + }, + "end": { + "column": 13, + "line": 2 + } + }, + "name": "on", + "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", + "range": [ + 30, + 64 + ], + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 53 + } + }, + "expression": { + "type": "FunctionExpression", + "start": 31, + "end": 63, + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 52 + } + }, + "range": [ + 31, + 63 + ], + "id": null, + "expression": false, + "generator": false, + "async": true, + "params": [], + "body": { + "type": "BlockStatement", + "start": 48, + "end": 63, + "loc": { + "start": { + "line": 2, + "column": 37 + }, + "end": { + "line": 2, + "column": 52 + } + }, + "range": [ + 48, + 63 + ], + "body": [ + { + "type": "ExpressionStatement", + "start": 50, + "end": 61, + "loc": { + "start": { + "line": 2, + "column": 39 + }, + "end": { + "line": 2, + "column": 50 + } + }, + "range": [ + 50, + 61 + ], + "expression": { + "type": "AwaitExpression", + "start": 50, + "end": 61, + "loc": { + "start": { + "line": 2, + "column": 39 + }, + "end": { + "line": 2, + "column": 50 + } + }, + "range": [ + 50, + 61 + ], + "argument": { + "type": "CallExpression", + "start": 56, + "end": 61, + "loc": { + "start": { + "line": 2, + "column": 45 + }, + "end": { + "line": 2, + "column": 50 + } + }, + "range": [ + 56, + 61 + ], + "callee": { + "type": "Identifier", + "start": 56, + "end": 59, + "loc": { + "start": { + "line": 2, + "column": 45 + }, + "end": { + "line": 2, + "column": 48 + } + }, + "range": [ + 56, + 59 + ], + "name": "act" + }, + "arguments": [], + "optional": false + } + } + } + ] + } + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 56, + "end": 59, + "loc": { + "start": { + "line": 2, + "column": 45 + }, + "end": { + "line": 2, + "column": 48 + } + }, + "range": [ + 56, + 59 + ], + "name": "act" + }, + "mode": "r" + } + ] + } + } + ] + }, + "children": [], + "endTag": { + "type": "VEndTag", + "range": [ + 65, + 74 + ], + "loc": { + "start": { + "line": 2, + "column": 54 + }, + "end": { + "line": 2, + "column": 63 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 74, + 75 + ], + "loc": { + "start": { + "line": 2, + "column": 63 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 75, + 86 + ], + "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, + 29 + ], + "loc": { + "start": { + "column": 13, + "line": 2 + }, + "end": { + "column": 18, + "line": 2 + } + }, + "value": "click" + }, + { + "type": "HTMLAssociation", + "range": [ + 29, + 30 + ], + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 30, + 31 + ], + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "value": "async", + "start": 31, + "end": 36, + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "range": [ + 31, + 36 + ] + }, + { + "type": "Keyword", + "value": "function", + "start": 37, + "end": 45, + "loc": { + "start": { + "line": 2, + "column": 26 + }, + "end": { + "line": 2, + "column": 34 + } + }, + "range": [ + 37, + 45 + ] + }, + { + "type": "Punctuator", + "value": "(", + "start": 45, + "end": 46, + "loc": { + "start": { + "line": 2, + "column": 34 + }, + "end": { + "line": 2, + "column": 35 + } + }, + "range": [ + 45, + 46 + ] + }, + { + "type": "Punctuator", + "value": ")", + "start": 46, + "end": 47, + "loc": { + "start": { + "line": 2, + "column": 35 + }, + "end": { + "line": 2, + "column": 36 + } + }, + "range": [ + 46, + 47 + ] + }, + { + "type": "Punctuator", + "value": "{", + "start": 48, + "end": 49, + "loc": { + "start": { + "line": 2, + "column": 37 + }, + "end": { + "line": 2, + "column": 38 + } + }, + "range": [ + 48, + 49 + ] + }, + { + "type": "Identifier", + "value": "await", + "start": 50, + "end": 55, + "loc": { + "start": { + "line": 2, + "column": 39 + }, + "end": { + "line": 2, + "column": 44 + } + }, + "range": [ + 50, + 55 + ] + }, + { + "type": "Identifier", + "value": "act", + "start": 56, + "end": 59, + "loc": { + "start": { + "line": 2, + "column": 45 + }, + "end": { + "line": 2, + "column": 48 + } + }, + "range": [ + 56, + 59 + ] + }, + { + "type": "Punctuator", + "value": "(", + "start": 59, + "end": 60, + "loc": { + "start": { + "line": 2, + "column": 48 + }, + "end": { + "line": 2, + "column": 49 + } + }, + "range": [ + 59, + 60 + ] + }, + { + "type": "Punctuator", + "value": ")", + "start": 60, + "end": 61, + "loc": { + "start": { + "line": 2, + "column": 49 + }, + "end": { + "line": 2, + "column": 50 + } + }, + "range": [ + 60, + 61 + ] + }, + { + "type": "Punctuator", + "value": "}", + "start": 62, + "end": 63, + "loc": { + "start": { + "line": 2, + "column": 51 + }, + "end": { + "line": 2, + "column": 52 + } + }, + "range": [ + 62, + 63 + ] + }, + { + "type": "Punctuator", + "range": [ + 63, + 64 + ], + "loc": { + "start": { + "line": 2, + "column": 52 + }, + "end": { + "line": 2, + "column": 53 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 64, + 65 + ], + "loc": { + "start": { + "line": 2, + "column": 53 + }, + "end": { + "line": 2, + "column": 54 + } + }, + "value": "" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 65, + 73 + ], + "loc": { + "start": { + "line": 2, + "column": 54 + }, + "end": { + "line": 2, + "column": 62 + } + }, + "value": "button" + }, + { + "type": "HTMLTagClose", + "range": [ + 73, + 74 + ], + "loc": { + "start": { + "line": 2, + "column": 62 + }, + "end": { + "line": 2, + "column": 63 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 74, + 75 + ], + "loc": { + "start": { + "line": 2, + "column": 63 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 75, + 85 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 85, + 86 + ], + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 86, + 87 + ], + "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/v-on-async-function-expression/source.vue b/test/fixtures/ast/v-on-async-function-expression/source.vue new file mode 100644 index 00000000..fb86873b --- /dev/null +++ b/test/fixtures/ast/v-on-async-function-expression/source.vue @@ -0,0 +1,3 @@ + diff --git a/test/fixtures/ast/v-on-async-function-expression/token-ranges.json b/test/fixtures/ast/v-on-async-function-expression/token-ranges.json new file mode 100644 index 00000000..77fdd025 --- /dev/null +++ b/test/fixtures/ast/v-on-async-function-expression/token-ranges.json @@ -0,0 +1,28 @@ +[ + "", + "\n ", + "", + "", + "\n", + "", + "\n" +] \ No newline at end of file diff --git a/test/fixtures/ast/v-on-async-function-expression/tree.json b/test/fixtures/ast/v-on-async-function-expression/tree.json new file mode 100644 index 00000000..5fdf6e87 --- /dev/null +++ b/test/fixtures/ast/v-on-async-function-expression/tree.json @@ -0,0 +1,108 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/ast/v-on-function-expression/ast.json b/test/fixtures/ast/v-on-function-expression/ast.json index 24049e41..946439ac 100644 --- a/test/fixtures/ast/v-on-function-expression/ast.json +++ b/test/fixtures/ast/v-on-function-expression/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/v-on-multiple-statements/ast.json b/test/fixtures/ast/v-on-multiple-statements/ast.json index 03f0a0c4..9b285e71 100644 --- a/test/fixtures/ast/v-on-multiple-statements/ast.json +++ b/test/fixtures/ast/v-on-multiple-statements/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/v-on-object-expression/ast.json b/test/fixtures/ast/v-on-object-expression/ast.json index c8cbcb81..c6d4163a 100644 --- a/test/fixtures/ast/v-on-object-expression/ast.json +++ b/test/fixtures/ast/v-on-object-expression/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/v-on-simple-path.1/ast.json b/test/fixtures/ast/v-on-simple-path.1/ast.json index d580550e..8a1e525d 100644 --- a/test/fixtures/ast/v-on-simple-path.1/ast.json +++ b/test/fixtures/ast/v-on-simple-path.1/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/v-on-simple-path.2/ast.json b/test/fixtures/ast/v-on-simple-path.2/ast.json index 9f05e47b..71f7779c 100644 --- a/test/fixtures/ast/v-on-simple-path.2/ast.json +++ b/test/fixtures/ast/v-on-simple-path.2/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/v-on-simple-path.3/ast.json b/test/fixtures/ast/v-on-simple-path.3/ast.json index a9b40fae..1ac5a8d2 100644 --- a/test/fixtures/ast/v-on-simple-path.3/ast.json +++ b/test/fixtures/ast/v-on-simple-path.3/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/v-on-simple-path.4/ast.json b/test/fixtures/ast/v-on-simple-path.4/ast.json index 10bc3274..5dd52cb6 100644 --- a/test/fixtures/ast/v-on-simple-path.4/ast.json +++ b/test/fixtures/ast/v-on-simple-path.4/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/v-pre/ast.json b/test/fixtures/ast/v-pre/ast.json index baaa037c..04772d33 100644 --- a/test/fixtures/ast/v-pre/ast.json +++ b/test/fixtures/ast/v-pre/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/v-slot-default-shorthand/ast.json b/test/fixtures/ast/v-slot-default-shorthand/ast.json index c6ca641e..fc107094 100644 --- a/test/fixtures/ast/v-slot-default-shorthand/ast.json +++ b/test/fixtures/ast/v-slot-default-shorthand/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { @@ -280,7 +280,6 @@ ], "name": "foo" }, - "kind": "init", "value": { "type": "Identifier", "start": 43, @@ -300,7 +299,8 @@ 46 ], "name": "foo" - } + }, + "kind": "init" } ] } diff --git a/test/fixtures/ast/v-slot-default/ast.json b/test/fixtures/ast/v-slot-default/ast.json index f1ce9aee..38fcf4da 100644 --- a/test/fixtures/ast/v-slot-default/ast.json +++ b/test/fixtures/ast/v-slot-default/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { @@ -262,7 +262,6 @@ ], "name": "foo" }, - "kind": "init", "value": { "type": "Identifier", "start": 41, @@ -282,7 +281,8 @@ 44 ], "name": "foo" - } + }, + "kind": "init" } ] } diff --git a/test/fixtures/ast/v-slot-named-shorthand/ast.json b/test/fixtures/ast/v-slot-named-shorthand/ast.json index 4a94e5d4..f7004d68 100644 --- a/test/fixtures/ast/v-slot-named-shorthand/ast.json +++ b/test/fixtures/ast/v-slot-named-shorthand/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { @@ -337,7 +337,6 @@ ], "name": "foo" }, - "kind": "init", "value": { "type": "Identifier", "start": 61, @@ -357,7 +356,8 @@ 64 ], "name": "foo" - } + }, + "kind": "init" } ] } diff --git a/test/fixtures/ast/v-slot-named/ast.json b/test/fixtures/ast/v-slot-named/ast.json index 60ab37e6..1c337d08 100644 --- a/test/fixtures/ast/v-slot-named/ast.json +++ b/test/fixtures/ast/v-slot-named/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { @@ -337,7 +337,6 @@ ], "name": "foo" }, - "kind": "init", "value": { "type": "Identifier", "start": 67, @@ -357,7 +356,8 @@ 70 ], "name": "foo" - } + }, + "kind": "init" } ] } diff --git a/test/fixtures/ast/vue3.3-generic-1/ast.json b/test/fixtures/ast/vue3.3-generic-1/ast.json new file mode 100644 index 00000000..6c0f8f26 --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-1/ast.json @@ -0,0 +1,1059 @@ +{ + "type": "Program", + "range": [ + 37, + 60 + ], + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "arguments": [], + "callee": { + "type": "Identifier", + "decorators": [], + "name": "defineProps", + "optional": false, + "range": [ + 37, + 48 + ], + "loc": { + "end": { + "line": 2, + "column": 11 + }, + "start": { + "line": 2, + "column": 0 + } + } + }, + "optional": false, + "typeArguments": { + "type": "TSTypeParameterInstantiation", + "range": [ + 48, + 57 + ], + "params": [ + { + "type": "TSTypeLiteral", + "members": [ + { + "type": "TSPropertySignature", + "computed": false, + "key": { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 50, + 53 + ], + "loc": { + "end": { + "line": 2, + "column": 16 + }, + "start": { + "line": 2, + "column": 13 + } + } + }, + "optional": false, + "readonly": false, + "static": false, + "typeAnnotation": { + "type": "TSTypeAnnotation", + "loc": { + "end": { + "line": 2, + "column": 18 + }, + "start": { + "line": 2, + "column": 16 + } + }, + "range": [ + 53, + 55 + ], + "typeAnnotation": { + "type": "TSTypeReference", + "typeName": { + "type": "Identifier", + "decorators": [], + "name": "T", + "optional": false, + "range": [ + 54, + 55 + ], + "loc": { + "end": { + "line": 2, + "column": 18 + }, + "start": { + "line": 2, + "column": 17 + } + } + }, + "range": [ + 54, + 55 + ], + "loc": { + "end": { + "line": 2, + "column": 18 + }, + "start": { + "line": 2, + "column": 17 + } + } + } + }, + "range": [ + 50, + 55 + ], + "loc": { + "end": { + "line": 2, + "column": 18 + }, + "start": { + "line": 2, + "column": 13 + } + } + } + ], + "range": [ + 49, + 56 + ], + "loc": { + "end": { + "line": 2, + "column": 19 + }, + "start": { + "line": 2, + "column": 12 + } + } + } + ], + "loc": { + "end": { + "line": 2, + "column": 20 + }, + "start": { + "line": 2, + "column": 11 + } + } + }, + "range": [ + 37, + 59 + ], + "loc": { + "end": { + "line": 2, + "column": 22 + }, + "start": { + "line": 2, + "column": 0 + } + } + }, + "range": [ + 37, + 59 + ], + "loc": { + "end": { + "line": 2, + "column": 22 + }, + "start": { + "line": 2, + "column": 0 + } + } + } + ], + "comments": [], + "sourceType": "module", + "tokens": [ + { + "type": "Punctuator", + "range": [ + 0, + 36 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "value": "" + } + ], + "loc": { + "end": { + "line": 3, + "column": 0 + }, + "start": { + "line": 2, + "column": 0 + } + }, + "templateBody": { + "type": "VElement", + "range": [ + 70, + 100 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 6, + "column": 11 + } + }, + "name": "template", + "rawName": "template", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 70, + 80 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 10 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 80, + 81 + ], + "loc": { + "start": { + "line": 4, + "column": 10 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionContainer", + "range": [ + 81, + 88 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 7 + } + }, + "expression": { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 83, + 86 + ], + "loc": { + "end": { + "line": 5, + "column": 5 + }, + "start": { + "line": 5, + "column": 2 + } + } + }, + "references": [ + { + "id": { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 83, + 86 + ], + "loc": { + "end": { + "line": 5, + "column": 5 + }, + "start": { + "line": 5, + "column": 2 + } + } + }, + "mode": "r", + "isValueReference": true, + "isTypeReference": false + } + ] + }, + { + "type": "VText", + "range": [ + 88, + 89 + ], + "loc": { + "start": { + "line": 5, + "column": 7 + }, + "end": { + "line": 6, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 89, + 100 + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 11 + } + } + }, + "variables": [], + "tokens": [ + { + "type": "HTMLTagOpen", + "range": [ + 0, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLIdentifier", + "range": [ + 8, + 13 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": "setup" + }, + { + "type": "HTMLIdentifier", + "range": [ + 14, + 18 + ], + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "value": "lang" + }, + { + "type": "HTMLAssociation", + "range": [ + 18, + 19 + ], + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "value": "" + }, + { + "type": "HTMLLiteral", + "range": [ + 19, + 23 + ], + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "value": "ts" + }, + { + "type": "HTMLIdentifier", + "range": [ + 24, + 31 + ], + "loc": { + "start": { + "column": 24, + "line": 1 + }, + "end": { + "column": 31, + "line": 1 + } + }, + "value": "generic" + }, + { + "type": "HTMLAssociation", + "range": [ + 31, + 32 + ], + "loc": { + "start": { + "line": 1, + "column": 31 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 32, + 33 + ], + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 1, + "column": 34 + }, + "start": { + "line": 1, + "column": 33 + } + }, + "range": [ + 33, + 34 + ], + "value": "T" + }, + { + "type": "Punctuator", + "range": [ + 34, + 35 + ], + "loc": { + "start": { + "line": 1, + "column": 34 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 35, + 36 + ], + "loc": { + "start": { + "line": 1, + "column": 35 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 36, + 37 + ], + "loc": { + "start": { + "line": 1, + "column": 36 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 37, + 59 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "value": "defineProps<{foo:T}>()" + }, + { + "type": "HTMLWhitespace", + "range": [ + 59, + 60 + ], + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 60, + 68 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 68, + 69 + ], + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 69, + 70 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 70, + 79 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 79, + 80 + ], + "loc": { + "start": { + "line": 4, + "column": 9 + }, + "end": { + "line": 4, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 80, + 81 + ], + "loc": { + "start": { + "line": 4, + "column": 10 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionStart", + "range": [ + 81, + 83 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 2 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 5, + "column": 5 + }, + "start": { + "line": 5, + "column": 2 + } + }, + "range": [ + 83, + 86 + ], + "value": "foo" + }, + { + "type": "VExpressionEnd", + "range": [ + 86, + 88 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 7 + } + }, + "value": "}}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 88, + 89 + ], + "loc": { + "start": { + "line": 5, + "column": 7 + }, + "end": { + "line": 6, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 89, + 99 + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 99, + 100 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 11 + } + }, + "value": "" + } + ], + "comments": [], + "errors": [] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/vue3.3-generic-1/parser-options.json b/test/fixtures/ast/vue3.3-generic-1/parser-options.json new file mode 100644 index 00000000..0ead30e9 --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-1/parser-options.json @@ -0,0 +1,6 @@ +{ + "sourceType": "module", + "parser": { + "ts": "@typescript-eslint/parser" + } +} diff --git a/test/fixtures/ast/vue3.3-generic-1/scope.json b/test/fixtures/ast/vue3.3-generic-1/scope.json new file mode 100644 index 00000000..cdafa028 --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-1/scope.json @@ -0,0 +1,1298 @@ +{ + "type": "global", + "variables": [ + { + "name": "Intl", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SymbolConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Function", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Disposable", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncDisposable", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SuppressedError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SuppressedErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "DisposableStack", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "DisposableStackConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncDisposableStack", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncDisposableStackConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "IteratorObject", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncIteratorObject", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ReadonlySetLike", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Set", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ReadonlySet", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Iterator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "IteratorObjectConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PromiseConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Float16Array", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Float16ArrayConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Math", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "DataView", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayBuffer", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayBufferConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "MapConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ObjectConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PromiseWithResolvers", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "RegExp", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Atomics", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SharedArrayBuffer", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SharedArrayBufferConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "String", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassMemberDecoratorContext", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "DecoratorContext", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "DecoratorMetadataObject", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "DecoratorMetadata", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassDecoratorContext", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassMethodDecoratorContext", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassGetterDecoratorContext", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassSetterDecoratorContext", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassAccessorDecoratorContext", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassAccessorDecoratorTarget", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassAccessorDecoratorResult", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassFieldDecoratorContext", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "IteratorYieldResult", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "IteratorReturnResult", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "IteratorResult", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Iterable", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "IterableIterator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "BuiltinIteratorReturn", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayIterator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Array", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ReadonlyArray", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "IArguments", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "MapIterator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Map", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ReadonlyMap", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "WeakMap", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "WeakMapConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SetIterator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SetConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "WeakSet", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "WeakSetConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Promise", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "StringIterator", + "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": "AsyncIterator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncIterable", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncIterableIterator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "BigInt64Array", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "BigUint64Array", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "WeakKeyTypes", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "BigIntToLocaleStringOptions", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "BigInt", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "BigIntConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "BigInt64ArrayConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "BigUint64ArrayConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ErrorOptions", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Error", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "EvalErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "RangeErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ReferenceErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SyntaxErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "TypeErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "URIErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AggregateErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "RegExpMatchArray", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "RegExpExecArray", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "RegExpIndicesArray", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AggregateError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "WeakRef", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "WeakRefConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "FinalizationRegistry", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "FinalizationRegistryConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Date", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Number", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PromiseFulfilledResult", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PromiseRejectedResult", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PromiseSettledResult", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "RegExpStringIterator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Symbol", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "JSON", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "GeneratorFunction", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "RegExpConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "FlatArray", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncGenerator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncGeneratorFunction", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncGeneratorFunctionConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "DateConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayBufferTypes", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PropertyKey", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PropertyDescriptor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PropertyDescriptorMap", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Object", + "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": "StringConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Boolean", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "BooleanConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "NumberConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "TemplateStringsArray", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ImportMeta", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ImportCallOptions", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ImportAssertions", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ImportAttributes", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "EvalError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "RangeError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ReferenceError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SyntaxError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "TypeError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "URIError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ConcatArray", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "TypedPropertyDescriptor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PromiseConstructorLike", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PromiseLike", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Awaited", + "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": "NoInfer", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ThisType", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "WeakKey", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayBufferLike", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayBufferView", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "DataViewConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Generator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "GeneratorFunctionConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ProxyHandler", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ProxyConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Reflect", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassDecorator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PropertyDecorator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "MethodDecorator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ParameterDecorator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "const", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "defineProps", + "identifiers": [], + "defs": [], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "defineProps", + "loc": { + "end": { + "line": 2, + "column": 11 + }, + "start": { + "line": 2, + "column": 0 + } + } + }, + "from": "module", + "init": null + } + ] + }, + { + "name": "T", + "identifiers": [], + "defs": [], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "T", + "loc": { + "end": { + "line": 2, + "column": 18 + }, + "start": { + "line": 2, + "column": 17 + } + } + }, + "from": "module", + "init": null + } + ] + } + ], + "references": [], + "childScopes": [ + { + "type": "module", + "variables": [], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "defineProps", + "loc": { + "end": { + "line": 2, + "column": 11 + }, + "start": { + "line": 2, + "column": 0 + } + } + }, + "from": "module", + "init": null + }, + { + "identifier": { + "type": "Identifier", + "name": "T", + "loc": { + "end": { + "line": 2, + "column": 18 + }, + "start": { + "line": 2, + "column": 17 + } + } + }, + "from": "module", + "init": null + } + ], + "childScopes": [], + "through": [ + { + "identifier": { + "type": "Identifier", + "name": "defineProps", + "loc": { + "end": { + "line": 2, + "column": 11 + }, + "start": { + "line": 2, + "column": 0 + } + } + }, + "from": "module", + "init": null + }, + { + "identifier": { + "type": "Identifier", + "name": "T", + "loc": { + "end": { + "line": 2, + "column": 18 + }, + "start": { + "line": 2, + "column": 17 + } + } + }, + "from": "module", + "init": null + } + ] + } + ], + "through": [] +} \ No newline at end of file diff --git a/test/fixtures/ast/vue3.3-generic-1/source.vue b/test/fixtures/ast/vue3.3-generic-1/source.vue new file mode 100644 index 00000000..fc54be37 --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-1/source.vue @@ -0,0 +1,6 @@ + + \ No newline at end of file diff --git a/test/fixtures/ast/vue3.3-generic-1/token-ranges.json b/test/fixtures/ast/vue3.3-generic-1/token-ranges.json new file mode 100644 index 00000000..debb41a2 --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-1/token-ranges.json @@ -0,0 +1,40 @@ +[ + "", + "", + "\n", + "defineProps<{foo:T}>()", + "\n", + "", + "\n", + "", + "\n", + "{{", + "foo", + "}}", + "\n", + "" +] \ No newline at end of file diff --git a/test/fixtures/ast/vue3.3-generic-1/tree.json b/test/fixtures/ast/vue3.3-generic-1/tree.json new file mode 100644 index 00000000..eea3840c --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-1/tree.json @@ -0,0 +1,39 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/ast/vue3.3-generic-2/ast.json b/test/fixtures/ast/vue3.3-generic-2/ast.json new file mode 100644 index 00000000..6eab96ca --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-2/ast.json @@ -0,0 +1,2488 @@ +{ + "type": "Program", + "range": [ + 9, + 162 + ], + "body": [ + { + "type": "TSTypeAliasDeclaration", + "declare": false, + "id": { + "type": "Identifier", + "decorators": [], + "name": "Foo", + "optional": false, + "range": [ + 14, + 17 + ], + "loc": { + "end": { + "line": 2, + "column": 8 + }, + "start": { + "line": 2, + "column": 5 + } + } + }, + "typeAnnotation": { + "type": "TSUnionType", + "types": [ + { + "type": "TSNumberKeyword", + "range": [ + 20, + 26 + ], + "loc": { + "end": { + "line": 2, + "column": 17 + }, + "start": { + "line": 2, + "column": 11 + } + } + }, + { + "type": "TSStringKeyword", + "range": [ + 29, + 35 + ], + "loc": { + "end": { + "line": 2, + "column": 26 + }, + "start": { + "line": 2, + "column": 20 + } + } + } + ], + "range": [ + 20, + 35 + ], + "loc": { + "end": { + "line": 2, + "column": 26 + }, + "start": { + "line": 2, + "column": 11 + } + } + }, + "range": [ + 9, + 35 + ], + "loc": { + "end": { + "line": 2, + "column": 26 + }, + "start": { + "line": 2, + "column": 0 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "definite": false, + "id": { + "type": "Identifier", + "decorators": [], + "name": "p", + "optional": false, + "range": [ + 101, + 102 + ], + "loc": { + "end": { + "line": 5, + "column": 7 + }, + "start": { + "line": 5, + "column": 6 + } + } + }, + "init": { + "type": "CallExpression", + "arguments": [], + "callee": { + "type": "Identifier", + "decorators": [], + "name": "defineProps", + "optional": false, + "range": [ + 105, + 116 + ], + "loc": { + "end": { + "line": 5, + "column": 21 + }, + "start": { + "line": 5, + "column": 10 + } + } + }, + "optional": false, + "typeArguments": { + "type": "TSTypeParameterInstantiation", + "range": [ + 116, + 125 + ], + "params": [ + { + "type": "TSTypeLiteral", + "members": [ + { + "type": "TSPropertySignature", + "computed": false, + "key": { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 118, + 121 + ], + "loc": { + "end": { + "line": 5, + "column": 26 + }, + "start": { + "line": 5, + "column": 23 + } + } + }, + "optional": false, + "readonly": false, + "static": false, + "typeAnnotation": { + "type": "TSTypeAnnotation", + "loc": { + "end": { + "line": 5, + "column": 28 + }, + "start": { + "line": 5, + "column": 26 + } + }, + "range": [ + 121, + 123 + ], + "typeAnnotation": { + "type": "TSTypeReference", + "typeName": { + "type": "Identifier", + "decorators": [], + "name": "T", + "optional": false, + "range": [ + 122, + 123 + ], + "loc": { + "end": { + "line": 5, + "column": 28 + }, + "start": { + "line": 5, + "column": 27 + } + } + }, + "range": [ + 122, + 123 + ], + "loc": { + "end": { + "line": 5, + "column": 28 + }, + "start": { + "line": 5, + "column": 27 + } + } + } + }, + "range": [ + 118, + 123 + ], + "loc": { + "end": { + "line": 5, + "column": 28 + }, + "start": { + "line": 5, + "column": 23 + } + } + } + ], + "range": [ + 117, + 124 + ], + "loc": { + "end": { + "line": 5, + "column": 29 + }, + "start": { + "line": 5, + "column": 22 + } + } + } + ], + "loc": { + "end": { + "line": 5, + "column": 30 + }, + "start": { + "line": 5, + "column": 21 + } + } + }, + "range": [ + 105, + 127 + ], + "loc": { + "end": { + "line": 5, + "column": 32 + }, + "start": { + "line": 5, + "column": 10 + } + } + }, + "range": [ + 101, + 127 + ], + "loc": { + "end": { + "line": 5, + "column": 32 + }, + "start": { + "line": 5, + "column": 6 + } + } + } + ], + "declare": false, + "kind": "const", + "range": [ + 95, + 127 + ], + "loc": { + "end": { + "line": 5, + "column": 32 + }, + "start": { + "line": 5, + "column": 0 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "definite": false, + "id": { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 134, + 137 + ], + "loc": { + "end": { + "line": 6, + "column": 9 + }, + "start": { + "line": 6, + "column": 6 + } + } + }, + "init": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "decorators": [], + "name": "p", + "optional": false, + "range": [ + 140, + 141 + ], + "loc": { + "end": { + "line": 6, + "column": 13 + }, + "start": { + "line": 6, + "column": 12 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 142, + 145 + ], + "loc": { + "end": { + "line": 6, + "column": 17 + }, + "start": { + "line": 6, + "column": 14 + } + } + }, + "range": [ + 140, + 145 + ], + "loc": { + "end": { + "line": 6, + "column": 17 + }, + "start": { + "line": 6, + "column": 12 + } + } + }, + "range": [ + 134, + 145 + ], + "loc": { + "end": { + "line": 6, + "column": 17 + }, + "start": { + "line": 6, + "column": 6 + } + } + } + ], + "declare": false, + "kind": "const", + "range": [ + 128, + 145 + ], + "loc": { + "end": { + "line": 6, + "column": 17 + }, + "start": { + "line": 6, + "column": 0 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "arguments": [ + { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 158, + 161 + ], + "loc": { + "end": { + "line": 7, + "column": 15 + }, + "start": { + "line": 7, + "column": 12 + } + } + } + ], + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "decorators": [], + "name": "console", + "optional": false, + "range": [ + 146, + 153 + ], + "loc": { + "end": { + "line": 7, + "column": 7 + }, + "start": { + "line": 7, + "column": 0 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "decorators": [], + "name": "log", + "optional": false, + "range": [ + 154, + 157 + ], + "loc": { + "end": { + "line": 7, + "column": 11 + }, + "start": { + "line": 7, + "column": 8 + } + } + }, + "range": [ + 146, + 157 + ], + "loc": { + "end": { + "line": 7, + "column": 11 + }, + "start": { + "line": 7, + "column": 0 + } + } + }, + "optional": false, + "range": [ + 146, + 162 + ], + "loc": { + "end": { + "line": 7, + "column": 16 + }, + "start": { + "line": 7, + "column": 0 + } + } + }, + "range": [ + 146, + 162 + ], + "loc": { + "end": { + "line": 7, + "column": 16 + }, + "start": { + "line": 7, + "column": 0 + } + } + } + ], + "comments": [], + "sourceType": "module", + "tokens": [ + { + "type": "Punctuator", + "range": [ + 0, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 46, + 94 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 48 + } + }, + "value": "" + } + ], + "loc": { + "end": { + "line": 7, + "column": 16 + }, + "start": { + "line": 2, + "column": 0 + } + }, + "templateBody": { + "type": "VElement", + "range": [ + 173, + 203 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 11, + "column": 11 + } + }, + "name": "template", + "rawName": "template", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 173, + 183 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 10 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 183, + 184 + ], + "loc": { + "start": { + "line": 9, + "column": 10 + }, + "end": { + "line": 10, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionContainer", + "range": [ + 184, + 191 + ], + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 7 + } + }, + "expression": { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 186, + 189 + ], + "loc": { + "end": { + "line": 10, + "column": 5 + }, + "start": { + "line": 10, + "column": 2 + } + } + }, + "references": [ + { + "id": { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 186, + 189 + ], + "loc": { + "end": { + "line": 10, + "column": 5 + }, + "start": { + "line": 10, + "column": 2 + } + } + }, + "mode": "r", + "isValueReference": true, + "isTypeReference": false + } + ] + }, + { + "type": "VText", + "range": [ + 191, + 192 + ], + "loc": { + "start": { + "line": 10, + "column": 7 + }, + "end": { + "line": 11, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 192, + 203 + ], + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "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, + 13 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 4 + } + }, + "value": "type" + }, + { + "type": "HTMLWhitespace", + "range": [ + 13, + 14 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 5 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 14, + 17 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "value": "Foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 17, + 18 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 18, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 19, + 20 + ], + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 20, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "value": "number" + }, + { + "type": "HTMLWhitespace", + "range": [ + 26, + 27 + ], + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 27, + 28 + ], + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "value": "|" + }, + { + "type": "HTMLWhitespace", + "range": [ + 28, + 29 + ], + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 29, + 35 + ], + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 26 + } + }, + "value": "string" + }, + { + "type": "HTMLWhitespace", + "range": [ + 35, + 36 + ], + "loc": { + "start": { + "line": 2, + "column": 26 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 36, + 44 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 44, + 45 + ], + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 45, + 46 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 46, + 53 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLIdentifier", + "range": [ + 54, + 59 + ], + "loc": { + "start": { + "line": 4, + "column": 8 + }, + "end": { + "line": 4, + "column": 13 + } + }, + "value": "setup" + }, + { + "type": "HTMLIdentifier", + "range": [ + 60, + 64 + ], + "loc": { + "start": { + "line": 4, + "column": 14 + }, + "end": { + "line": 4, + "column": 18 + } + }, + "value": "lang" + }, + { + "type": "HTMLAssociation", + "range": [ + 64, + 65 + ], + "loc": { + "start": { + "line": 4, + "column": 18 + }, + "end": { + "line": 4, + "column": 19 + } + }, + "value": "" + }, + { + "type": "HTMLLiteral", + "range": [ + 65, + 69 + ], + "loc": { + "start": { + "line": 4, + "column": 19 + }, + "end": { + "line": 4, + "column": 23 + } + }, + "value": "ts" + }, + { + "type": "HTMLIdentifier", + "range": [ + 70, + 77 + ], + "loc": { + "start": { + "column": 24, + "line": 4 + }, + "end": { + "column": 31, + "line": 4 + } + }, + "value": "generic" + }, + { + "type": "HTMLAssociation", + "range": [ + 77, + 78 + ], + "loc": { + "start": { + "line": 4, + "column": 31 + }, + "end": { + "line": 4, + "column": 32 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 78, + 79 + ], + "loc": { + "start": { + "line": 4, + "column": 32 + }, + "end": { + "line": 4, + "column": 33 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 4, + "column": 34 + }, + "start": { + "line": 4, + "column": 33 + } + }, + "range": [ + 79, + 80 + ], + "value": "T" + }, + { + "type": "Keyword", + "loc": { + "end": { + "line": 4, + "column": 42 + }, + "start": { + "line": 4, + "column": 35 + } + }, + "range": [ + 81, + 88 + ], + "value": "extends" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 4, + "column": 46 + }, + "start": { + "line": 4, + "column": 43 + } + }, + "range": [ + 89, + 92 + ], + "value": "Foo" + }, + { + "type": "Punctuator", + "range": [ + 92, + 93 + ], + "loc": { + "start": { + "line": 4, + "column": 46 + }, + "end": { + "line": 4, + "column": 47 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 93, + 94 + ], + "loc": { + "start": { + "line": 4, + "column": 47 + }, + "end": { + "line": 4, + "column": 48 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 94, + 95 + ], + "loc": { + "start": { + "line": 4, + "column": 48 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 95, + 100 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 100, + 101 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 101, + 102 + ], + "loc": { + "start": { + "line": 5, + "column": 6 + }, + "end": { + "line": 5, + "column": 7 + } + }, + "value": "p" + }, + { + "type": "HTMLWhitespace", + "range": [ + 102, + 103 + ], + "loc": { + "start": { + "line": 5, + "column": 7 + }, + "end": { + "line": 5, + "column": 8 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 103, + 104 + ], + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 9 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 104, + 105 + ], + "loc": { + "start": { + "line": 5, + "column": 9 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 105, + 127 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 32 + } + }, + "value": "defineProps<{foo:T}>()" + }, + { + "type": "HTMLWhitespace", + "range": [ + 127, + 128 + ], + "loc": { + "start": { + "line": 5, + "column": 32 + }, + "end": { + "line": 6, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 128, + 133 + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 133, + 134 + ], + "loc": { + "start": { + "line": 6, + "column": 5 + }, + "end": { + "line": 6, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 134, + 137 + ], + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 9 + } + }, + "value": "foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 137, + 138 + ], + "loc": { + "start": { + "line": 6, + "column": 9 + }, + "end": { + "line": 6, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 138, + 139 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 11 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 139, + 140 + ], + "loc": { + "start": { + "line": 6, + "column": 11 + }, + "end": { + "line": 6, + "column": 12 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 140, + 145 + ], + "loc": { + "start": { + "line": 6, + "column": 12 + }, + "end": { + "line": 6, + "column": 17 + } + }, + "value": "p.foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 145, + 146 + ], + "loc": { + "start": { + "line": 6, + "column": 17 + }, + "end": { + "line": 7, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 146, + 162 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 16 + } + }, + "value": "console.log(foo)" + }, + { + "type": "HTMLWhitespace", + "range": [ + 162, + 163 + ], + "loc": { + "start": { + "line": 7, + "column": 16 + }, + "end": { + "line": 8, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 163, + 171 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 171, + 172 + ], + "loc": { + "start": { + "line": 8, + "column": 8 + }, + "end": { + "line": 8, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 172, + 173 + ], + "loc": { + "start": { + "line": 8, + "column": 9 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 173, + 182 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 182, + 183 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 9, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 183, + 184 + ], + "loc": { + "start": { + "line": 9, + "column": 10 + }, + "end": { + "line": 10, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionStart", + "range": [ + 184, + 186 + ], + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 2 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 10, + "column": 5 + }, + "start": { + "line": 10, + "column": 2 + } + }, + "range": [ + 186, + 189 + ], + "value": "foo" + }, + { + "type": "VExpressionEnd", + "range": [ + 189, + 191 + ], + "loc": { + "start": { + "line": 10, + "column": 5 + }, + "end": { + "line": 10, + "column": 7 + } + }, + "value": "}}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 191, + 192 + ], + "loc": { + "start": { + "line": 10, + "column": 7 + }, + "end": { + "line": 11, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 192, + 202 + ], + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 202, + 203 + ], + "loc": { + "start": { + "line": 11, + "column": 10 + }, + "end": { + "line": 11, + "column": 11 + } + }, + "value": "" + } + ], + "comments": [], + "errors": [] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/vue3.3-generic-2/parser-options.json b/test/fixtures/ast/vue3.3-generic-2/parser-options.json new file mode 100644 index 00000000..0ead30e9 --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-2/parser-options.json @@ -0,0 +1,6 @@ +{ + "sourceType": "module", + "parser": { + "ts": "@typescript-eslint/parser" + } +} diff --git a/test/fixtures/ast/vue3.3-generic-2/scope.json b/test/fixtures/ast/vue3.3-generic-2/scope.json new file mode 100644 index 00000000..df9d4a47 --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-2/scope.json @@ -0,0 +1,1799 @@ +{ + "type": "global", + "variables": [ + { + "name": "Intl", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SymbolConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Function", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Disposable", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncDisposable", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SuppressedError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SuppressedErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "DisposableStack", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "DisposableStackConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncDisposableStack", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncDisposableStackConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "IteratorObject", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncIteratorObject", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ReadonlySetLike", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Set", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ReadonlySet", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Iterator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "IteratorObjectConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PromiseConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Float16Array", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Float16ArrayConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Math", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "DataView", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayBuffer", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayBufferConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "MapConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ObjectConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PromiseWithResolvers", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "RegExp", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Atomics", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SharedArrayBuffer", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SharedArrayBufferConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "String", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassMemberDecoratorContext", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "DecoratorContext", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "DecoratorMetadataObject", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "DecoratorMetadata", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassDecoratorContext", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassMethodDecoratorContext", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassGetterDecoratorContext", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassSetterDecoratorContext", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassAccessorDecoratorContext", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassAccessorDecoratorTarget", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassAccessorDecoratorResult", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassFieldDecoratorContext", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "IteratorYieldResult", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "IteratorReturnResult", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "IteratorResult", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Iterable", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "IterableIterator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "BuiltinIteratorReturn", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayIterator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Array", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ReadonlyArray", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "IArguments", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "MapIterator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Map", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ReadonlyMap", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "WeakMap", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "WeakMapConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SetIterator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SetConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "WeakSet", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "WeakSetConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Promise", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "StringIterator", + "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": "AsyncIterator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncIterable", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncIterableIterator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "BigInt64Array", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "BigUint64Array", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "WeakKeyTypes", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "BigIntToLocaleStringOptions", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "BigInt", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "BigIntConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "BigInt64ArrayConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "BigUint64ArrayConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ErrorOptions", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Error", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "EvalErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "RangeErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ReferenceErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SyntaxErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "TypeErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "URIErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AggregateErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "RegExpMatchArray", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "RegExpExecArray", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "RegExpIndicesArray", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AggregateError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "WeakRef", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "WeakRefConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "FinalizationRegistry", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "FinalizationRegistryConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Date", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Number", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PromiseFulfilledResult", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PromiseRejectedResult", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PromiseSettledResult", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "RegExpStringIterator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Symbol", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "JSON", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "GeneratorFunction", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "RegExpConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "FlatArray", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncGenerator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncGeneratorFunction", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncGeneratorFunctionConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "DateConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayBufferTypes", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PropertyKey", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PropertyDescriptor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PropertyDescriptorMap", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Object", + "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": "StringConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Boolean", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "BooleanConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "NumberConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "TemplateStringsArray", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ImportMeta", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ImportCallOptions", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ImportAssertions", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ImportAttributes", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "EvalError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "RangeError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ReferenceError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SyntaxError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "TypeError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "URIError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ConcatArray", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "TypedPropertyDescriptor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PromiseConstructorLike", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PromiseLike", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Awaited", + "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": "NoInfer", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ThisType", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "WeakKey", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayBufferLike", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayBufferView", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "DataViewConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Generator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "GeneratorFunctionConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ProxyHandler", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ProxyConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Reflect", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassDecorator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PropertyDecorator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "MethodDecorator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ParameterDecorator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "const", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "defineProps", + "identifiers": [], + "defs": [], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "defineProps", + "loc": { + "end": { + "line": 5, + "column": 21 + }, + "start": { + "line": 5, + "column": 10 + } + } + }, + "from": "module", + "init": null + } + ] + }, + { + "name": "T", + "identifiers": [], + "defs": [], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "T", + "loc": { + "end": { + "line": 5, + "column": 28 + }, + "start": { + "line": 5, + "column": 27 + } + } + }, + "from": "module", + "init": null + } + ] + } + ], + "references": [], + "childScopes": [ + { + "type": "module", + "variables": [ + { + "name": "Foo", + "identifiers": [ + { + "type": "Identifier", + "name": "Foo", + "loc": { + "end": { + "line": 2, + "column": 8 + }, + "start": { + "line": 2, + "column": 5 + } + } + } + ], + "defs": [ + { + "type": "Type", + "node": { + "type": "TSTypeAliasDeclaration", + "loc": { + "end": { + "line": 2, + "column": 26 + }, + "start": { + "line": 2, + "column": 0 + } + } + }, + "name": "Foo" + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "Foo", + "loc": { + "end": { + "line": 2, + "column": 8 + }, + "start": { + "line": 2, + "column": 5 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "Foo", + "loc": { + "end": { + "line": 2, + "column": 8 + }, + "start": { + "line": 2, + "column": 5 + } + } + }, + "init": null, + "vueUsedInTemplate": true + } + ] + }, + { + "name": "p", + "identifiers": [ + { + "type": "Identifier", + "name": "p", + "loc": { + "end": { + "line": 5, + "column": 7 + }, + "start": { + "line": 5, + "column": 6 + } + } + } + ], + "defs": [ + { + "type": "Variable", + "node": { + "type": "VariableDeclarator", + "loc": { + "end": { + "line": 5, + "column": 32 + }, + "start": { + "line": 5, + "column": 6 + } + } + }, + "name": "p" + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "p", + "loc": { + "end": { + "line": 5, + "column": 7 + }, + "start": { + "line": 5, + "column": 6 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "p", + "loc": { + "end": { + "line": 5, + "column": 7 + }, + "start": { + "line": 5, + "column": 6 + } + } + }, + "init": true + }, + { + "identifier": { + "type": "Identifier", + "name": "p", + "loc": { + "end": { + "line": 6, + "column": 13 + }, + "start": { + "line": 6, + "column": 12 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "p", + "loc": { + "end": { + "line": 5, + "column": 7 + }, + "start": { + "line": 5, + "column": 6 + } + } + }, + "init": null + } + ] + }, + { + "name": "foo", + "identifiers": [ + { + "type": "Identifier", + "name": "foo", + "loc": { + "end": { + "line": 6, + "column": 9 + }, + "start": { + "line": 6, + "column": 6 + } + } + } + ], + "defs": [ + { + "type": "Variable", + "node": { + "type": "VariableDeclarator", + "loc": { + "end": { + "line": 6, + "column": 17 + }, + "start": { + "line": 6, + "column": 6 + } + } + }, + "name": "foo" + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "foo", + "loc": { + "end": { + "line": 6, + "column": 9 + }, + "start": { + "line": 6, + "column": 6 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "foo", + "loc": { + "end": { + "line": 6, + "column": 9 + }, + "start": { + "line": 6, + "column": 6 + } + } + }, + "init": true + }, + { + "identifier": { + "type": "Identifier", + "name": "foo", + "loc": { + "end": { + "line": 7, + "column": 15 + }, + "start": { + "line": 7, + "column": 12 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "foo", + "loc": { + "end": { + "line": 6, + "column": 9 + }, + "start": { + "line": 6, + "column": 6 + } + } + }, + "init": null + }, + { + "identifier": { + "type": "Identifier", + "name": "foo", + "loc": { + "end": { + "line": 6, + "column": 9 + }, + "start": { + "line": 6, + "column": 6 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "foo", + "loc": { + "end": { + "line": 6, + "column": 9 + }, + "start": { + "line": 6, + "column": 6 + } + } + }, + "init": null, + "vueUsedInTemplate": true + } + ] + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "p", + "loc": { + "end": { + "line": 5, + "column": 7 + }, + "start": { + "line": 5, + "column": 6 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "p", + "loc": { + "end": { + "line": 5, + "column": 7 + }, + "start": { + "line": 5, + "column": 6 + } + } + }, + "init": true + }, + { + "identifier": { + "type": "Identifier", + "name": "defineProps", + "loc": { + "end": { + "line": 5, + "column": 21 + }, + "start": { + "line": 5, + "column": 10 + } + } + }, + "from": "module", + "init": null + }, + { + "identifier": { + "type": "Identifier", + "name": "T", + "loc": { + "end": { + "line": 5, + "column": 28 + }, + "start": { + "line": 5, + "column": 27 + } + } + }, + "from": "module", + "init": null + }, + { + "identifier": { + "type": "Identifier", + "name": "foo", + "loc": { + "end": { + "line": 6, + "column": 9 + }, + "start": { + "line": 6, + "column": 6 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "foo", + "loc": { + "end": { + "line": 6, + "column": 9 + }, + "start": { + "line": 6, + "column": 6 + } + } + }, + "init": true + }, + { + "identifier": { + "type": "Identifier", + "name": "p", + "loc": { + "end": { + "line": 6, + "column": 13 + }, + "start": { + "line": 6, + "column": 12 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "p", + "loc": { + "end": { + "line": 5, + "column": 7 + }, + "start": { + "line": 5, + "column": 6 + } + } + }, + "init": null + }, + { + "identifier": { + "type": "Identifier", + "name": "console", + "loc": { + "end": { + "line": 7, + "column": 7 + }, + "start": { + "line": 7, + "column": 0 + } + } + }, + "from": "module", + "resolved": null, + "init": null + }, + { + "identifier": { + "type": "Identifier", + "name": "foo", + "loc": { + "end": { + "line": 7, + "column": 15 + }, + "start": { + "line": 7, + "column": 12 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "foo", + "loc": { + "end": { + "line": 6, + "column": 9 + }, + "start": { + "line": 6, + "column": 6 + } + } + }, + "init": null + } + ], + "childScopes": [], + "through": [ + { + "identifier": { + "type": "Identifier", + "name": "defineProps", + "loc": { + "end": { + "line": 5, + "column": 21 + }, + "start": { + "line": 5, + "column": 10 + } + } + }, + "from": "module", + "init": null + }, + { + "identifier": { + "type": "Identifier", + "name": "T", + "loc": { + "end": { + "line": 5, + "column": 28 + }, + "start": { + "line": 5, + "column": 27 + } + } + }, + "from": "module", + "init": null + }, + { + "identifier": { + "type": "Identifier", + "name": "console", + "loc": { + "end": { + "line": 7, + "column": 7 + }, + "start": { + "line": 7, + "column": 0 + } + } + }, + "from": "module", + "resolved": null, + "init": null + } + ] + } + ], + "through": [ + { + "identifier": { + "type": "Identifier", + "name": "console", + "loc": { + "end": { + "line": 7, + "column": 7 + }, + "start": { + "line": 7, + "column": 0 + } + } + }, + "from": "module", + "resolved": null, + "init": null + } + ] +} \ No newline at end of file diff --git a/test/fixtures/ast/vue3.3-generic-2/source.vue b/test/fixtures/ast/vue3.3-generic-2/source.vue new file mode 100644 index 00000000..e42bea85 --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-2/source.vue @@ -0,0 +1,11 @@ + + + \ No newline at end of file diff --git a/test/fixtures/ast/vue3.3-generic-2/token-ranges.json b/test/fixtures/ast/vue3.3-generic-2/token-ranges.json new file mode 100644 index 00000000..8c7613a8 --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-2/token-ranges.json @@ -0,0 +1,99 @@ +[ + "", + "", + "", + "\n", + "type", + " ", + "Foo", + " ", + "=", + " ", + "number", + " ", + "|", + " ", + "string", + "\n", + "", + "\n", + "", + "\n", + "const", + " ", + "p", + " ", + "=", + " ", + "defineProps<{foo:T}>()", + "\n", + "const", + " ", + "foo", + " ", + "=", + " ", + "p.foo", + "\n", + "console.log(foo)", + "\n", + "", + "\n", + "", + "\n", + "{{", + "foo", + "}}", + "\n", + "" +] \ No newline at end of file diff --git a/test/fixtures/ast/vue3.3-generic-2/tree.json b/test/fixtures/ast/vue3.3-generic-2/tree.json new file mode 100644 index 00000000..eea3840c --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-2/tree.json @@ -0,0 +1,39 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/ast/vue3.3-generic-3/ast.json b/test/fixtures/ast/vue3.3-generic-3/ast.json new file mode 100644 index 00000000..cb599c07 --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-3/ast.json @@ -0,0 +1,2799 @@ +{ + "type": "Program", + "range": [ + 9, + 183 + ], + "body": [ + { + "type": "TSTypeAliasDeclaration", + "declare": false, + "id": { + "type": "Identifier", + "decorators": [], + "name": "Foo", + "optional": false, + "range": [ + 14, + 17 + ], + "loc": { + "end": { + "line": 2, + "column": 8 + }, + "start": { + "line": 2, + "column": 5 + } + } + }, + "typeAnnotation": { + "type": "TSUnionType", + "types": [ + { + "type": "TSNumberKeyword", + "range": [ + 20, + 26 + ], + "loc": { + "end": { + "line": 2, + "column": 17 + }, + "start": { + "line": 2, + "column": 11 + } + } + }, + { + "type": "TSStringKeyword", + "range": [ + 29, + 35 + ], + "loc": { + "end": { + "line": 2, + "column": 26 + }, + "start": { + "line": 2, + "column": 20 + } + } + } + ], + "range": [ + 20, + 35 + ], + "loc": { + "end": { + "line": 2, + "column": 26 + }, + "start": { + "line": 2, + "column": 11 + } + } + }, + "range": [ + 9, + 35 + ], + "loc": { + "end": { + "line": 2, + "column": 26 + }, + "start": { + "line": 2, + "column": 0 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "definite": false, + "id": { + "type": "Identifier", + "decorators": [], + "name": "p", + "optional": false, + "range": [ + 114, + 115 + ], + "loc": { + "end": { + "line": 5, + "column": 7 + }, + "start": { + "line": 5, + "column": 6 + } + } + }, + "init": { + "type": "CallExpression", + "arguments": [], + "callee": { + "type": "Identifier", + "decorators": [], + "name": "defineProps", + "optional": false, + "range": [ + 118, + 129 + ], + "loc": { + "end": { + "line": 5, + "column": 21 + }, + "start": { + "line": 5, + "column": 10 + } + } + }, + "optional": false, + "typeArguments": { + "type": "TSTypeParameterInstantiation", + "range": [ + 129, + 146 + ], + "params": [ + { + "type": "TSTypeLiteral", + "members": [ + { + "type": "TSPropertySignature", + "computed": false, + "key": { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 131, + 134 + ], + "loc": { + "end": { + "line": 5, + "column": 26 + }, + "start": { + "line": 5, + "column": 23 + } + } + }, + "optional": false, + "readonly": false, + "static": false, + "typeAnnotation": { + "type": "TSTypeAnnotation", + "loc": { + "end": { + "line": 5, + "column": 28 + }, + "start": { + "line": 5, + "column": 26 + } + }, + "range": [ + 134, + 136 + ], + "typeAnnotation": { + "type": "TSTypeReference", + "typeName": { + "type": "Identifier", + "decorators": [], + "name": "T", + "optional": false, + "range": [ + 135, + 136 + ], + "loc": { + "end": { + "line": 5, + "column": 28 + }, + "start": { + "line": 5, + "column": 27 + } + } + }, + "range": [ + 135, + 136 + ], + "loc": { + "end": { + "line": 5, + "column": 28 + }, + "start": { + "line": 5, + "column": 27 + } + } + } + }, + "range": [ + 131, + 137 + ], + "loc": { + "end": { + "line": 5, + "column": 29 + }, + "start": { + "line": 5, + "column": 23 + } + } + }, + { + "type": "TSPropertySignature", + "computed": false, + "key": { + "type": "Identifier", + "decorators": [], + "name": "bar", + "optional": false, + "range": [ + 138, + 141 + ], + "loc": { + "end": { + "line": 5, + "column": 33 + }, + "start": { + "line": 5, + "column": 30 + } + } + }, + "optional": false, + "readonly": false, + "static": false, + "typeAnnotation": { + "type": "TSTypeAnnotation", + "loc": { + "end": { + "line": 5, + "column": 36 + }, + "start": { + "line": 5, + "column": 33 + } + }, + "range": [ + 141, + 144 + ], + "typeAnnotation": { + "type": "TSTypeReference", + "typeName": { + "type": "Identifier", + "decorators": [], + "name": "U", + "optional": false, + "range": [ + 143, + 144 + ], + "loc": { + "end": { + "line": 5, + "column": 36 + }, + "start": { + "line": 5, + "column": 35 + } + } + }, + "range": [ + 143, + 144 + ], + "loc": { + "end": { + "line": 5, + "column": 36 + }, + "start": { + "line": 5, + "column": 35 + } + } + } + }, + "range": [ + 138, + 144 + ], + "loc": { + "end": { + "line": 5, + "column": 36 + }, + "start": { + "line": 5, + "column": 30 + } + } + } + ], + "range": [ + 130, + 145 + ], + "loc": { + "end": { + "line": 5, + "column": 37 + }, + "start": { + "line": 5, + "column": 22 + } + } + } + ], + "loc": { + "end": { + "line": 5, + "column": 38 + }, + "start": { + "line": 5, + "column": 21 + } + } + }, + "range": [ + 118, + 148 + ], + "loc": { + "end": { + "line": 5, + "column": 40 + }, + "start": { + "line": 5, + "column": 10 + } + } + }, + "range": [ + 114, + 148 + ], + "loc": { + "end": { + "line": 5, + "column": 40 + }, + "start": { + "line": 5, + "column": 6 + } + } + } + ], + "declare": false, + "kind": "const", + "range": [ + 108, + 148 + ], + "loc": { + "end": { + "line": 5, + "column": 40 + }, + "start": { + "line": 5, + "column": 0 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "definite": false, + "id": { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 155, + 158 + ], + "loc": { + "end": { + "line": 6, + "column": 9 + }, + "start": { + "line": 6, + "column": 6 + } + } + }, + "init": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "decorators": [], + "name": "p", + "optional": false, + "range": [ + 161, + 162 + ], + "loc": { + "end": { + "line": 6, + "column": 13 + }, + "start": { + "line": 6, + "column": 12 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 163, + 166 + ], + "loc": { + "end": { + "line": 6, + "column": 17 + }, + "start": { + "line": 6, + "column": 14 + } + } + }, + "range": [ + 161, + 166 + ], + "loc": { + "end": { + "line": 6, + "column": 17 + }, + "start": { + "line": 6, + "column": 12 + } + } + }, + "range": [ + 155, + 166 + ], + "loc": { + "end": { + "line": 6, + "column": 17 + }, + "start": { + "line": 6, + "column": 6 + } + } + } + ], + "declare": false, + "kind": "const", + "range": [ + 149, + 166 + ], + "loc": { + "end": { + "line": 6, + "column": 17 + }, + "start": { + "line": 6, + "column": 0 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "arguments": [ + { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 179, + 182 + ], + "loc": { + "end": { + "line": 7, + "column": 15 + }, + "start": { + "line": 7, + "column": 12 + } + } + } + ], + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "decorators": [], + "name": "console", + "optional": false, + "range": [ + 167, + 174 + ], + "loc": { + "end": { + "line": 7, + "column": 7 + }, + "start": { + "line": 7, + "column": 0 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "decorators": [], + "name": "log", + "optional": false, + "range": [ + 175, + 178 + ], + "loc": { + "end": { + "line": 7, + "column": 11 + }, + "start": { + "line": 7, + "column": 8 + } + } + }, + "range": [ + 167, + 178 + ], + "loc": { + "end": { + "line": 7, + "column": 11 + }, + "start": { + "line": 7, + "column": 0 + } + } + }, + "optional": false, + "range": [ + 167, + 183 + ], + "loc": { + "end": { + "line": 7, + "column": 16 + }, + "start": { + "line": 7, + "column": 0 + } + } + }, + "range": [ + 167, + 183 + ], + "loc": { + "end": { + "line": 7, + "column": 16 + }, + "start": { + "line": 7, + "column": 0 + } + } + } + ], + "comments": [], + "sourceType": "module", + "tokens": [ + { + "type": "Punctuator", + "range": [ + 0, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 46, + 107 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 61 + } + }, + "value": "" + } + ], + "loc": { + "end": { + "line": 7, + "column": 16 + }, + "start": { + "line": 2, + "column": 0 + } + }, + "templateBody": { + "type": "VElement", + "range": [ + 194, + 224 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 11, + "column": 11 + } + }, + "name": "template", + "rawName": "template", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 194, + 204 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 10 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 204, + 205 + ], + "loc": { + "start": { + "line": 9, + "column": 10 + }, + "end": { + "line": 10, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionContainer", + "range": [ + 205, + 212 + ], + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 7 + } + }, + "expression": { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 207, + 210 + ], + "loc": { + "end": { + "line": 10, + "column": 5 + }, + "start": { + "line": 10, + "column": 2 + } + } + }, + "references": [ + { + "id": { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 207, + 210 + ], + "loc": { + "end": { + "line": 10, + "column": 5 + }, + "start": { + "line": 10, + "column": 2 + } + } + }, + "mode": "r", + "isValueReference": true, + "isTypeReference": false + } + ] + }, + { + "type": "VText", + "range": [ + 212, + 213 + ], + "loc": { + "start": { + "line": 10, + "column": 7 + }, + "end": { + "line": 11, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 213, + 224 + ], + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "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, + 13 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 4 + } + }, + "value": "type" + }, + { + "type": "HTMLWhitespace", + "range": [ + 13, + 14 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 5 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 14, + 17 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "value": "Foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 17, + 18 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 18, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 19, + 20 + ], + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 20, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "value": "number" + }, + { + "type": "HTMLWhitespace", + "range": [ + 26, + 27 + ], + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 27, + 28 + ], + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "value": "|" + }, + { + "type": "HTMLWhitespace", + "range": [ + 28, + 29 + ], + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 29, + 35 + ], + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 26 + } + }, + "value": "string" + }, + { + "type": "HTMLWhitespace", + "range": [ + 35, + 36 + ], + "loc": { + "start": { + "line": 2, + "column": 26 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 36, + 44 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 44, + 45 + ], + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 45, + 46 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 46, + 53 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLIdentifier", + "range": [ + 54, + 59 + ], + "loc": { + "start": { + "line": 4, + "column": 8 + }, + "end": { + "line": 4, + "column": 13 + } + }, + "value": "setup" + }, + { + "type": "HTMLIdentifier", + "range": [ + 60, + 64 + ], + "loc": { + "start": { + "line": 4, + "column": 14 + }, + "end": { + "line": 4, + "column": 18 + } + }, + "value": "lang" + }, + { + "type": "HTMLAssociation", + "range": [ + 64, + 65 + ], + "loc": { + "start": { + "line": 4, + "column": 18 + }, + "end": { + "line": 4, + "column": 19 + } + }, + "value": "" + }, + { + "type": "HTMLLiteral", + "range": [ + 65, + 69 + ], + "loc": { + "start": { + "line": 4, + "column": 19 + }, + "end": { + "line": 4, + "column": 23 + } + }, + "value": "ts" + }, + { + "type": "HTMLIdentifier", + "range": [ + 70, + 77 + ], + "loc": { + "start": { + "column": 24, + "line": 4 + }, + "end": { + "column": 31, + "line": 4 + } + }, + "value": "generic" + }, + { + "type": "HTMLAssociation", + "range": [ + 77, + 78 + ], + "loc": { + "start": { + "line": 4, + "column": 31 + }, + "end": { + "line": 4, + "column": 32 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 78, + 79 + ], + "loc": { + "start": { + "line": 4, + "column": 32 + }, + "end": { + "line": 4, + "column": 33 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 4, + "column": 34 + }, + "start": { + "line": 4, + "column": 33 + } + }, + "range": [ + 79, + 80 + ], + "value": "T" + }, + { + "type": "Keyword", + "loc": { + "end": { + "line": 4, + "column": 42 + }, + "start": { + "line": 4, + "column": 35 + } + }, + "range": [ + 81, + 88 + ], + "value": "extends" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 4, + "column": 46 + }, + "start": { + "line": 4, + "column": 43 + } + }, + "range": [ + 89, + 92 + ], + "value": "Foo" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 4, + "column": 47 + }, + "start": { + "line": 4, + "column": 46 + } + }, + "range": [ + 92, + 93 + ], + "value": "," + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 4, + "column": 49 + }, + "start": { + "line": 4, + "column": 48 + } + }, + "range": [ + 94, + 95 + ], + "value": "U" + }, + { + "type": "Keyword", + "loc": { + "end": { + "line": 4, + "column": 57 + }, + "start": { + "line": 4, + "column": 50 + } + }, + "range": [ + 96, + 103 + ], + "value": "extends" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 4, + "column": 59 + }, + "start": { + "line": 4, + "column": 58 + } + }, + "range": [ + 104, + 105 + ], + "value": "T" + }, + { + "type": "Punctuator", + "range": [ + 105, + 106 + ], + "loc": { + "start": { + "line": 4, + "column": 59 + }, + "end": { + "line": 4, + "column": 60 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 106, + 107 + ], + "loc": { + "start": { + "line": 4, + "column": 60 + }, + "end": { + "line": 4, + "column": 61 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 107, + 108 + ], + "loc": { + "start": { + "line": 4, + "column": 61 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 108, + 113 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 113, + 114 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 114, + 115 + ], + "loc": { + "start": { + "line": 5, + "column": 6 + }, + "end": { + "line": 5, + "column": 7 + } + }, + "value": "p" + }, + { + "type": "HTMLWhitespace", + "range": [ + 115, + 116 + ], + "loc": { + "start": { + "line": 5, + "column": 7 + }, + "end": { + "line": 5, + "column": 8 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 116, + 117 + ], + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 9 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 117, + 118 + ], + "loc": { + "start": { + "line": 5, + "column": 9 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 118, + 137 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 29 + } + }, + "value": "defineProps<{foo:T," + }, + { + "type": "HTMLWhitespace", + "range": [ + 137, + 138 + ], + "loc": { + "start": { + "line": 5, + "column": 29 + }, + "end": { + "line": 5, + "column": 30 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 138, + 142 + ], + "loc": { + "start": { + "line": 5, + "column": 30 + }, + "end": { + "line": 5, + "column": 34 + } + }, + "value": "bar:" + }, + { + "type": "HTMLWhitespace", + "range": [ + 142, + 143 + ], + "loc": { + "start": { + "line": 5, + "column": 34 + }, + "end": { + "line": 5, + "column": 35 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 143, + 148 + ], + "loc": { + "start": { + "line": 5, + "column": 35 + }, + "end": { + "line": 5, + "column": 40 + } + }, + "value": "U}>()" + }, + { + "type": "HTMLWhitespace", + "range": [ + 148, + 149 + ], + "loc": { + "start": { + "line": 5, + "column": 40 + }, + "end": { + "line": 6, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 149, + 154 + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 154, + 155 + ], + "loc": { + "start": { + "line": 6, + "column": 5 + }, + "end": { + "line": 6, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 155, + 158 + ], + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 9 + } + }, + "value": "foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 158, + 159 + ], + "loc": { + "start": { + "line": 6, + "column": 9 + }, + "end": { + "line": 6, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 159, + 160 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 11 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 160, + 161 + ], + "loc": { + "start": { + "line": 6, + "column": 11 + }, + "end": { + "line": 6, + "column": 12 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 161, + 166 + ], + "loc": { + "start": { + "line": 6, + "column": 12 + }, + "end": { + "line": 6, + "column": 17 + } + }, + "value": "p.foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 166, + 167 + ], + "loc": { + "start": { + "line": 6, + "column": 17 + }, + "end": { + "line": 7, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 167, + 183 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 16 + } + }, + "value": "console.log(foo)" + }, + { + "type": "HTMLWhitespace", + "range": [ + 183, + 184 + ], + "loc": { + "start": { + "line": 7, + "column": 16 + }, + "end": { + "line": 8, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 184, + 192 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 192, + 193 + ], + "loc": { + "start": { + "line": 8, + "column": 8 + }, + "end": { + "line": 8, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 193, + 194 + ], + "loc": { + "start": { + "line": 8, + "column": 9 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 194, + 203 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 203, + 204 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 9, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 204, + 205 + ], + "loc": { + "start": { + "line": 9, + "column": 10 + }, + "end": { + "line": 10, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionStart", + "range": [ + 205, + 207 + ], + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 2 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 10, + "column": 5 + }, + "start": { + "line": 10, + "column": 2 + } + }, + "range": [ + 207, + 210 + ], + "value": "foo" + }, + { + "type": "VExpressionEnd", + "range": [ + 210, + 212 + ], + "loc": { + "start": { + "line": 10, + "column": 5 + }, + "end": { + "line": 10, + "column": 7 + } + }, + "value": "}}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 212, + 213 + ], + "loc": { + "start": { + "line": 10, + "column": 7 + }, + "end": { + "line": 11, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 213, + 223 + ], + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 223, + 224 + ], + "loc": { + "start": { + "line": 11, + "column": 10 + }, + "end": { + "line": 11, + "column": 11 + } + }, + "value": "" + } + ], + "comments": [], + "errors": [] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/vue3.3-generic-3/parser-options.json b/test/fixtures/ast/vue3.3-generic-3/parser-options.json new file mode 100644 index 00000000..0ead30e9 --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-3/parser-options.json @@ -0,0 +1,6 @@ +{ + "sourceType": "module", + "parser": { + "ts": "@typescript-eslint/parser" + } +} diff --git a/test/fixtures/ast/vue3.3-generic-3/scope.json b/test/fixtures/ast/vue3.3-generic-3/scope.json new file mode 100644 index 00000000..01a2cda1 --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-3/scope.json @@ -0,0 +1,1860 @@ +{ + "type": "global", + "variables": [ + { + "name": "Intl", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SymbolConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Function", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Disposable", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncDisposable", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SuppressedError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SuppressedErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "DisposableStack", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "DisposableStackConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncDisposableStack", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncDisposableStackConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "IteratorObject", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncIteratorObject", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ReadonlySetLike", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Set", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ReadonlySet", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Iterator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "IteratorObjectConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PromiseConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Float16Array", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Float16ArrayConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Math", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "DataView", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayBuffer", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayBufferConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "MapConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ObjectConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PromiseWithResolvers", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "RegExp", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Atomics", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SharedArrayBuffer", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SharedArrayBufferConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "String", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassMemberDecoratorContext", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "DecoratorContext", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "DecoratorMetadataObject", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "DecoratorMetadata", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassDecoratorContext", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassMethodDecoratorContext", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassGetterDecoratorContext", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassSetterDecoratorContext", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassAccessorDecoratorContext", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassAccessorDecoratorTarget", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassAccessorDecoratorResult", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassFieldDecoratorContext", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "IteratorYieldResult", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "IteratorReturnResult", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "IteratorResult", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Iterable", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "IterableIterator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "BuiltinIteratorReturn", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayIterator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Array", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ReadonlyArray", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "IArguments", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "MapIterator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Map", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ReadonlyMap", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "WeakMap", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "WeakMapConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SetIterator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SetConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "WeakSet", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "WeakSetConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Promise", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "StringIterator", + "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": "AsyncIterator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncIterable", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncIterableIterator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "BigInt64Array", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "BigUint64Array", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "WeakKeyTypes", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "BigIntToLocaleStringOptions", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "BigInt", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "BigIntConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "BigInt64ArrayConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "BigUint64ArrayConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ErrorOptions", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Error", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "EvalErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "RangeErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ReferenceErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SyntaxErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "TypeErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "URIErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AggregateErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "RegExpMatchArray", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "RegExpExecArray", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "RegExpIndicesArray", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AggregateError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "WeakRef", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "WeakRefConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "FinalizationRegistry", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "FinalizationRegistryConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Date", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Number", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PromiseFulfilledResult", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PromiseRejectedResult", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PromiseSettledResult", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "RegExpStringIterator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Symbol", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "JSON", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "GeneratorFunction", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "RegExpConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "FlatArray", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncGenerator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncGeneratorFunction", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncGeneratorFunctionConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "DateConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayBufferTypes", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PropertyKey", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PropertyDescriptor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PropertyDescriptorMap", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Object", + "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": "StringConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Boolean", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "BooleanConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "NumberConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "TemplateStringsArray", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ImportMeta", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ImportCallOptions", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ImportAssertions", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ImportAttributes", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "EvalError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "RangeError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ReferenceError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SyntaxError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "TypeError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "URIError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ConcatArray", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "TypedPropertyDescriptor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PromiseConstructorLike", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PromiseLike", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Awaited", + "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": "NoInfer", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ThisType", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "WeakKey", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayBufferLike", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayBufferView", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "DataViewConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Generator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "GeneratorFunctionConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ProxyHandler", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ProxyConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Reflect", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassDecorator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PropertyDecorator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "MethodDecorator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ParameterDecorator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "const", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "defineProps", + "identifiers": [], + "defs": [], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "defineProps", + "loc": { + "end": { + "line": 5, + "column": 21 + }, + "start": { + "line": 5, + "column": 10 + } + } + }, + "from": "module", + "init": null + } + ] + }, + { + "name": "T", + "identifiers": [], + "defs": [], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "T", + "loc": { + "end": { + "line": 5, + "column": 28 + }, + "start": { + "line": 5, + "column": 27 + } + } + }, + "from": "module", + "init": null + } + ] + }, + { + "name": "U", + "identifiers": [], + "defs": [], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "U", + "loc": { + "end": { + "line": 5, + "column": 36 + }, + "start": { + "line": 5, + "column": 35 + } + } + }, + "from": "module", + "init": null + } + ] + } + ], + "references": [], + "childScopes": [ + { + "type": "module", + "variables": [ + { + "name": "Foo", + "identifiers": [ + { + "type": "Identifier", + "name": "Foo", + "loc": { + "end": { + "line": 2, + "column": 8 + }, + "start": { + "line": 2, + "column": 5 + } + } + } + ], + "defs": [ + { + "type": "Type", + "node": { + "type": "TSTypeAliasDeclaration", + "loc": { + "end": { + "line": 2, + "column": 26 + }, + "start": { + "line": 2, + "column": 0 + } + } + }, + "name": "Foo" + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "Foo", + "loc": { + "end": { + "line": 2, + "column": 8 + }, + "start": { + "line": 2, + "column": 5 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "Foo", + "loc": { + "end": { + "line": 2, + "column": 8 + }, + "start": { + "line": 2, + "column": 5 + } + } + }, + "init": null, + "vueUsedInTemplate": true + } + ] + }, + { + "name": "p", + "identifiers": [ + { + "type": "Identifier", + "name": "p", + "loc": { + "end": { + "line": 5, + "column": 7 + }, + "start": { + "line": 5, + "column": 6 + } + } + } + ], + "defs": [ + { + "type": "Variable", + "node": { + "type": "VariableDeclarator", + "loc": { + "end": { + "line": 5, + "column": 40 + }, + "start": { + "line": 5, + "column": 6 + } + } + }, + "name": "p" + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "p", + "loc": { + "end": { + "line": 5, + "column": 7 + }, + "start": { + "line": 5, + "column": 6 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "p", + "loc": { + "end": { + "line": 5, + "column": 7 + }, + "start": { + "line": 5, + "column": 6 + } + } + }, + "init": true + }, + { + "identifier": { + "type": "Identifier", + "name": "p", + "loc": { + "end": { + "line": 6, + "column": 13 + }, + "start": { + "line": 6, + "column": 12 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "p", + "loc": { + "end": { + "line": 5, + "column": 7 + }, + "start": { + "line": 5, + "column": 6 + } + } + }, + "init": null + } + ] + }, + { + "name": "foo", + "identifiers": [ + { + "type": "Identifier", + "name": "foo", + "loc": { + "end": { + "line": 6, + "column": 9 + }, + "start": { + "line": 6, + "column": 6 + } + } + } + ], + "defs": [ + { + "type": "Variable", + "node": { + "type": "VariableDeclarator", + "loc": { + "end": { + "line": 6, + "column": 17 + }, + "start": { + "line": 6, + "column": 6 + } + } + }, + "name": "foo" + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "foo", + "loc": { + "end": { + "line": 6, + "column": 9 + }, + "start": { + "line": 6, + "column": 6 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "foo", + "loc": { + "end": { + "line": 6, + "column": 9 + }, + "start": { + "line": 6, + "column": 6 + } + } + }, + "init": true + }, + { + "identifier": { + "type": "Identifier", + "name": "foo", + "loc": { + "end": { + "line": 7, + "column": 15 + }, + "start": { + "line": 7, + "column": 12 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "foo", + "loc": { + "end": { + "line": 6, + "column": 9 + }, + "start": { + "line": 6, + "column": 6 + } + } + }, + "init": null + }, + { + "identifier": { + "type": "Identifier", + "name": "foo", + "loc": { + "end": { + "line": 6, + "column": 9 + }, + "start": { + "line": 6, + "column": 6 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "foo", + "loc": { + "end": { + "line": 6, + "column": 9 + }, + "start": { + "line": 6, + "column": 6 + } + } + }, + "init": null, + "vueUsedInTemplate": true + } + ] + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "p", + "loc": { + "end": { + "line": 5, + "column": 7 + }, + "start": { + "line": 5, + "column": 6 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "p", + "loc": { + "end": { + "line": 5, + "column": 7 + }, + "start": { + "line": 5, + "column": 6 + } + } + }, + "init": true + }, + { + "identifier": { + "type": "Identifier", + "name": "defineProps", + "loc": { + "end": { + "line": 5, + "column": 21 + }, + "start": { + "line": 5, + "column": 10 + } + } + }, + "from": "module", + "init": null + }, + { + "identifier": { + "type": "Identifier", + "name": "T", + "loc": { + "end": { + "line": 5, + "column": 28 + }, + "start": { + "line": 5, + "column": 27 + } + } + }, + "from": "module", + "init": null + }, + { + "identifier": { + "type": "Identifier", + "name": "U", + "loc": { + "end": { + "line": 5, + "column": 36 + }, + "start": { + "line": 5, + "column": 35 + } + } + }, + "from": "module", + "init": null + }, + { + "identifier": { + "type": "Identifier", + "name": "foo", + "loc": { + "end": { + "line": 6, + "column": 9 + }, + "start": { + "line": 6, + "column": 6 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "foo", + "loc": { + "end": { + "line": 6, + "column": 9 + }, + "start": { + "line": 6, + "column": 6 + } + } + }, + "init": true + }, + { + "identifier": { + "type": "Identifier", + "name": "p", + "loc": { + "end": { + "line": 6, + "column": 13 + }, + "start": { + "line": 6, + "column": 12 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "p", + "loc": { + "end": { + "line": 5, + "column": 7 + }, + "start": { + "line": 5, + "column": 6 + } + } + }, + "init": null + }, + { + "identifier": { + "type": "Identifier", + "name": "console", + "loc": { + "end": { + "line": 7, + "column": 7 + }, + "start": { + "line": 7, + "column": 0 + } + } + }, + "from": "module", + "resolved": null, + "init": null + }, + { + "identifier": { + "type": "Identifier", + "name": "foo", + "loc": { + "end": { + "line": 7, + "column": 15 + }, + "start": { + "line": 7, + "column": 12 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "foo", + "loc": { + "end": { + "line": 6, + "column": 9 + }, + "start": { + "line": 6, + "column": 6 + } + } + }, + "init": null + } + ], + "childScopes": [], + "through": [ + { + "identifier": { + "type": "Identifier", + "name": "defineProps", + "loc": { + "end": { + "line": 5, + "column": 21 + }, + "start": { + "line": 5, + "column": 10 + } + } + }, + "from": "module", + "init": null + }, + { + "identifier": { + "type": "Identifier", + "name": "T", + "loc": { + "end": { + "line": 5, + "column": 28 + }, + "start": { + "line": 5, + "column": 27 + } + } + }, + "from": "module", + "init": null + }, + { + "identifier": { + "type": "Identifier", + "name": "U", + "loc": { + "end": { + "line": 5, + "column": 36 + }, + "start": { + "line": 5, + "column": 35 + } + } + }, + "from": "module", + "init": null + }, + { + "identifier": { + "type": "Identifier", + "name": "console", + "loc": { + "end": { + "line": 7, + "column": 7 + }, + "start": { + "line": 7, + "column": 0 + } + } + }, + "from": "module", + "resolved": null, + "init": null + } + ] + } + ], + "through": [ + { + "identifier": { + "type": "Identifier", + "name": "console", + "loc": { + "end": { + "line": 7, + "column": 7 + }, + "start": { + "line": 7, + "column": 0 + } + } + }, + "from": "module", + "resolved": null, + "init": null + } + ] +} \ No newline at end of file diff --git a/test/fixtures/ast/vue3.3-generic-3/source.vue b/test/fixtures/ast/vue3.3-generic-3/source.vue new file mode 100644 index 00000000..5d3590d2 --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-3/source.vue @@ -0,0 +1,11 @@ + + + \ No newline at end of file diff --git a/test/fixtures/ast/vue3.3-generic-3/token-ranges.json b/test/fixtures/ast/vue3.3-generic-3/token-ranges.json new file mode 100644 index 00000000..cec12a2a --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-3/token-ranges.json @@ -0,0 +1,111 @@ +[ + "", + "", + "", + "\n", + "type", + " ", + "Foo", + " ", + "=", + " ", + "number", + " ", + "|", + " ", + "string", + "\n", + "", + "\n", + "", + "\n", + "const", + " ", + "p", + " ", + "=", + " ", + "defineProps<{foo:T,", + " ", + "bar:", + " ", + "U}>()", + "\n", + "const", + " ", + "foo", + " ", + "=", + " ", + "p.foo", + "\n", + "console.log(foo)", + "\n", + "", + "\n", + "", + "\n", + "{{", + "foo", + "}}", + "\n", + "" +] \ No newline at end of file diff --git a/test/fixtures/ast/vue3.3-generic-3/tree.json b/test/fixtures/ast/vue3.3-generic-3/tree.json new file mode 100644 index 00000000..eea3840c --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-3/tree.json @@ -0,0 +1,39 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/ast/vue3.3-generic-4-with-spaces/ast.json b/test/fixtures/ast/vue3.3-generic-4-with-spaces/ast.json new file mode 100644 index 00000000..6efed59a --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-4-with-spaces/ast.json @@ -0,0 +1,2674 @@ +{ + "type": "Program", + "range": [ + 92, + 195 + ], + "body": [ + { + "type": "TSTypeAliasDeclaration", + "declare": false, + "id": { + "type": "Identifier", + "decorators": [], + "name": "Foo", + "optional": false, + "range": [ + 97, + 100 + ], + "loc": { + "end": { + "line": 8, + "column": 8 + }, + "start": { + "line": 8, + "column": 5 + } + } + }, + "typeAnnotation": { + "type": "TSUnionType", + "types": [ + { + "type": "TSNumberKeyword", + "range": [ + 103, + 109 + ], + "loc": { + "end": { + "line": 8, + "column": 17 + }, + "start": { + "line": 8, + "column": 11 + } + } + }, + { + "type": "TSStringKeyword", + "range": [ + 112, + 118 + ], + "loc": { + "end": { + "line": 8, + "column": 26 + }, + "start": { + "line": 8, + "column": 20 + } + } + } + ], + "range": [ + 103, + 118 + ], + "loc": { + "end": { + "line": 8, + "column": 26 + }, + "start": { + "line": 8, + "column": 11 + } + } + }, + "range": [ + 92, + 118 + ], + "loc": { + "end": { + "line": 8, + "column": 26 + }, + "start": { + "line": 8, + "column": 0 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "definite": false, + "id": { + "type": "Identifier", + "decorators": [], + "name": "p", + "optional": false, + "range": [ + 125, + 126 + ], + "loc": { + "end": { + "line": 9, + "column": 7 + }, + "start": { + "line": 9, + "column": 6 + } + } + }, + "init": { + "type": "CallExpression", + "arguments": [], + "callee": { + "type": "Identifier", + "decorators": [], + "name": "defineProps", + "optional": false, + "range": [ + 129, + 140 + ], + "loc": { + "end": { + "line": 9, + "column": 21 + }, + "start": { + "line": 9, + "column": 10 + } + } + }, + "optional": false, + "typeArguments": { + "type": "TSTypeParameterInstantiation", + "range": [ + 140, + 157 + ], + "params": [ + { + "type": "TSTypeLiteral", + "members": [ + { + "type": "TSPropertySignature", + "computed": false, + "key": { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 142, + 145 + ], + "loc": { + "end": { + "line": 9, + "column": 26 + }, + "start": { + "line": 9, + "column": 23 + } + } + }, + "optional": false, + "readonly": false, + "static": false, + "typeAnnotation": { + "type": "TSTypeAnnotation", + "loc": { + "end": { + "line": 9, + "column": 28 + }, + "start": { + "line": 9, + "column": 26 + } + }, + "range": [ + 145, + 147 + ], + "typeAnnotation": { + "type": "TSTypeReference", + "typeName": { + "type": "Identifier", + "decorators": [], + "name": "T", + "optional": false, + "range": [ + 146, + 147 + ], + "loc": { + "end": { + "line": 9, + "column": 28 + }, + "start": { + "line": 9, + "column": 27 + } + } + }, + "range": [ + 146, + 147 + ], + "loc": { + "end": { + "line": 9, + "column": 28 + }, + "start": { + "line": 9, + "column": 27 + } + } + } + }, + "range": [ + 142, + 148 + ], + "loc": { + "end": { + "line": 9, + "column": 29 + }, + "start": { + "line": 9, + "column": 23 + } + } + }, + { + "type": "TSPropertySignature", + "computed": false, + "key": { + "type": "Identifier", + "decorators": [], + "name": "bar", + "optional": false, + "range": [ + 149, + 152 + ], + "loc": { + "end": { + "line": 9, + "column": 33 + }, + "start": { + "line": 9, + "column": 30 + } + } + }, + "optional": false, + "readonly": false, + "static": false, + "typeAnnotation": { + "type": "TSTypeAnnotation", + "loc": { + "end": { + "line": 9, + "column": 36 + }, + "start": { + "line": 9, + "column": 33 + } + }, + "range": [ + 152, + 155 + ], + "typeAnnotation": { + "type": "TSTypeReference", + "typeName": { + "type": "Identifier", + "decorators": [], + "name": "U", + "optional": false, + "range": [ + 154, + 155 + ], + "loc": { + "end": { + "line": 9, + "column": 36 + }, + "start": { + "line": 9, + "column": 35 + } + } + }, + "range": [ + 154, + 155 + ], + "loc": { + "end": { + "line": 9, + "column": 36 + }, + "start": { + "line": 9, + "column": 35 + } + } + } + }, + "range": [ + 149, + 155 + ], + "loc": { + "end": { + "line": 9, + "column": 36 + }, + "start": { + "line": 9, + "column": 30 + } + } + } + ], + "range": [ + 141, + 156 + ], + "loc": { + "end": { + "line": 9, + "column": 37 + }, + "start": { + "line": 9, + "column": 22 + } + } + } + ], + "loc": { + "end": { + "line": 9, + "column": 38 + }, + "start": { + "line": 9, + "column": 21 + } + } + }, + "range": [ + 129, + 159 + ], + "loc": { + "end": { + "line": 9, + "column": 40 + }, + "start": { + "line": 9, + "column": 10 + } + } + }, + "range": [ + 125, + 159 + ], + "loc": { + "end": { + "line": 9, + "column": 40 + }, + "start": { + "line": 9, + "column": 6 + } + } + } + ], + "declare": false, + "kind": "const", + "range": [ + 119, + 159 + ], + "loc": { + "end": { + "line": 9, + "column": 40 + }, + "start": { + "line": 9, + "column": 0 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "definite": false, + "id": { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 166, + 169 + ], + "loc": { + "end": { + "line": 10, + "column": 9 + }, + "start": { + "line": 10, + "column": 6 + } + } + }, + "init": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "decorators": [], + "name": "p", + "optional": false, + "range": [ + 172, + 173 + ], + "loc": { + "end": { + "line": 10, + "column": 13 + }, + "start": { + "line": 10, + "column": 12 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 174, + 177 + ], + "loc": { + "end": { + "line": 10, + "column": 17 + }, + "start": { + "line": 10, + "column": 14 + } + } + }, + "range": [ + 172, + 177 + ], + "loc": { + "end": { + "line": 10, + "column": 17 + }, + "start": { + "line": 10, + "column": 12 + } + } + }, + "range": [ + 166, + 177 + ], + "loc": { + "end": { + "line": 10, + "column": 17 + }, + "start": { + "line": 10, + "column": 6 + } + } + } + ], + "declare": false, + "kind": "const", + "range": [ + 160, + 177 + ], + "loc": { + "end": { + "line": 10, + "column": 17 + }, + "start": { + "line": 10, + "column": 0 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "arguments": [ + { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 190, + 193 + ], + "loc": { + "end": { + "line": 11, + "column": 15 + }, + "start": { + "line": 11, + "column": 12 + } + } + } + ], + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "decorators": [], + "name": "console", + "optional": false, + "range": [ + 178, + 185 + ], + "loc": { + "end": { + "line": 11, + "column": 7 + }, + "start": { + "line": 11, + "column": 0 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "decorators": [], + "name": "log", + "optional": false, + "range": [ + 186, + 189 + ], + "loc": { + "end": { + "line": 11, + "column": 11 + }, + "start": { + "line": 11, + "column": 8 + } + } + }, + "range": [ + 178, + 189 + ], + "loc": { + "end": { + "line": 11, + "column": 11 + }, + "start": { + "line": 11, + "column": 0 + } + } + }, + "optional": false, + "range": [ + 178, + 194 + ], + "loc": { + "end": { + "line": 11, + "column": 16 + }, + "start": { + "line": 11, + "column": 0 + } + } + }, + "range": [ + 178, + 194 + ], + "loc": { + "end": { + "line": 11, + "column": 16 + }, + "start": { + "line": 11, + "column": 0 + } + } + } + ], + "comments": [], + "sourceType": "module", + "tokens": [ + { + "type": "Punctuator", + "range": [ + 0, + 91 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 7, + "column": 2 + } + }, + "value": "" + } + ], + "loc": { + "end": { + "line": 12, + "column": 0 + }, + "start": { + "line": 8, + "column": 0 + } + }, + "templateBody": { + "type": "VElement", + "range": [ + 205, + 235 + ], + "loc": { + "start": { + "line": 13, + "column": 0 + }, + "end": { + "line": 15, + "column": 11 + } + }, + "name": "template", + "rawName": "template", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 205, + 215 + ], + "loc": { + "start": { + "line": 13, + "column": 0 + }, + "end": { + "line": 13, + "column": 10 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 215, + 216 + ], + "loc": { + "start": { + "line": 13, + "column": 10 + }, + "end": { + "line": 14, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionContainer", + "range": [ + 216, + 223 + ], + "loc": { + "start": { + "line": 14, + "column": 0 + }, + "end": { + "line": 14, + "column": 7 + } + }, + "expression": { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 218, + 221 + ], + "loc": { + "end": { + "line": 14, + "column": 5 + }, + "start": { + "line": 14, + "column": 2 + } + } + }, + "references": [ + { + "id": { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 218, + 221 + ], + "loc": { + "end": { + "line": 14, + "column": 5 + }, + "start": { + "line": 14, + "column": 2 + } + } + }, + "mode": "r", + "isValueReference": true, + "isTypeReference": false + } + ] + }, + { + "type": "VText", + "range": [ + 223, + 224 + ], + "loc": { + "start": { + "line": 14, + "column": 7 + }, + "end": { + "line": 15, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 224, + 235 + ], + "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": "HTMLIdentifier", + "range": [ + 8, + 13 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": "setup" + }, + { + "type": "HTMLIdentifier", + "range": [ + 14, + 18 + ], + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "value": "lang" + }, + { + "type": "HTMLAssociation", + "range": [ + 18, + 19 + ], + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "value": "" + }, + { + "type": "HTMLLiteral", + "range": [ + 19, + 23 + ], + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "value": "ts" + }, + { + "type": "HTMLIdentifier", + "range": [ + 24, + 31 + ], + "loc": { + "start": { + "column": 24, + "line": 1 + }, + "end": { + "column": 31, + "line": 1 + } + }, + "value": "generic" + }, + { + "type": "HTMLAssociation", + "range": [ + 31, + 32 + ], + "loc": { + "start": { + "line": 1, + "column": 31 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 32, + 33 + ], + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 2, + "column": 3 + }, + "start": { + "line": 2, + "column": 2 + } + }, + "range": [ + 36, + 37 + ], + "value": "T" + }, + { + "type": "Keyword", + "loc": { + "end": { + "line": 3, + "column": 11 + }, + "start": { + "line": 3, + "column": 4 + } + }, + "range": [ + 42, + 49 + ], + "value": "extends" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 3, + "column": 15 + }, + "start": { + "line": 3, + "column": 12 + } + }, + "range": [ + 50, + 53 + ], + "value": "Foo" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 16 + }, + "start": { + "line": 3, + "column": 15 + } + }, + "range": [ + 53, + 54 + ], + "value": "," + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 5, + "column": 3 + }, + "start": { + "line": 5, + "column": 2 + } + }, + "range": [ + 73, + 74 + ], + "value": "U" + }, + { + "type": "Keyword", + "loc": { + "end": { + "line": 5, + "column": 11 + }, + "start": { + "line": 5, + "column": 4 + } + }, + "range": [ + 75, + 82 + ], + "value": "extends" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 6, + "column": 5 + }, + "start": { + "line": 6, + "column": 4 + } + }, + "range": [ + 87, + 88 + ], + "value": "T" + }, + { + "type": "Punctuator", + "range": [ + 89, + 90 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 90, + 91 + ], + "loc": { + "start": { + "line": 7, + "column": 1 + }, + "end": { + "line": 7, + "column": 2 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 91, + 92 + ], + "loc": { + "start": { + "line": 7, + "column": 2 + }, + "end": { + "line": 8, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 92, + 96 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 4 + } + }, + "value": "type" + }, + { + "type": "HTMLWhitespace", + "range": [ + 96, + 97 + ], + "loc": { + "start": { + "line": 8, + "column": 4 + }, + "end": { + "line": 8, + "column": 5 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 97, + 100 + ], + "loc": { + "start": { + "line": 8, + "column": 5 + }, + "end": { + "line": 8, + "column": 8 + } + }, + "value": "Foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 100, + 101 + ], + "loc": { + "start": { + "line": 8, + "column": 8 + }, + "end": { + "line": 8, + "column": 9 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 101, + 102 + ], + "loc": { + "start": { + "line": 8, + "column": 9 + }, + "end": { + "line": 8, + "column": 10 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 102, + 103 + ], + "loc": { + "start": { + "line": 8, + "column": 10 + }, + "end": { + "line": 8, + "column": 11 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 103, + 109 + ], + "loc": { + "start": { + "line": 8, + "column": 11 + }, + "end": { + "line": 8, + "column": 17 + } + }, + "value": "number" + }, + { + "type": "HTMLWhitespace", + "range": [ + 109, + 110 + ], + "loc": { + "start": { + "line": 8, + "column": 17 + }, + "end": { + "line": 8, + "column": 18 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 110, + 111 + ], + "loc": { + "start": { + "line": 8, + "column": 18 + }, + "end": { + "line": 8, + "column": 19 + } + }, + "value": "|" + }, + { + "type": "HTMLWhitespace", + "range": [ + 111, + 112 + ], + "loc": { + "start": { + "line": 8, + "column": 19 + }, + "end": { + "line": 8, + "column": 20 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 112, + 118 + ], + "loc": { + "start": { + "line": 8, + "column": 20 + }, + "end": { + "line": 8, + "column": 26 + } + }, + "value": "string" + }, + { + "type": "HTMLWhitespace", + "range": [ + 118, + 119 + ], + "loc": { + "start": { + "line": 8, + "column": 26 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 119, + 124 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 124, + 125 + ], + "loc": { + "start": { + "line": 9, + "column": 5 + }, + "end": { + "line": 9, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 125, + 126 + ], + "loc": { + "start": { + "line": 9, + "column": 6 + }, + "end": { + "line": 9, + "column": 7 + } + }, + "value": "p" + }, + { + "type": "HTMLWhitespace", + "range": [ + 126, + 127 + ], + "loc": { + "start": { + "line": 9, + "column": 7 + }, + "end": { + "line": 9, + "column": 8 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 127, + 128 + ], + "loc": { + "start": { + "line": 9, + "column": 8 + }, + "end": { + "line": 9, + "column": 9 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 128, + 129 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 9, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 129, + 148 + ], + "loc": { + "start": { + "line": 9, + "column": 10 + }, + "end": { + "line": 9, + "column": 29 + } + }, + "value": "defineProps<{foo:T," + }, + { + "type": "HTMLWhitespace", + "range": [ + 148, + 149 + ], + "loc": { + "start": { + "line": 9, + "column": 29 + }, + "end": { + "line": 9, + "column": 30 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 149, + 153 + ], + "loc": { + "start": { + "line": 9, + "column": 30 + }, + "end": { + "line": 9, + "column": 34 + } + }, + "value": "bar:" + }, + { + "type": "HTMLWhitespace", + "range": [ + 153, + 154 + ], + "loc": { + "start": { + "line": 9, + "column": 34 + }, + "end": { + "line": 9, + "column": 35 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 154, + 159 + ], + "loc": { + "start": { + "line": 9, + "column": 35 + }, + "end": { + "line": 9, + "column": 40 + } + }, + "value": "U}>()" + }, + { + "type": "HTMLWhitespace", + "range": [ + 159, + 160 + ], + "loc": { + "start": { + "line": 9, + "column": 40 + }, + "end": { + "line": 10, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 160, + 165 + ], + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 165, + 166 + ], + "loc": { + "start": { + "line": 10, + "column": 5 + }, + "end": { + "line": 10, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 166, + 169 + ], + "loc": { + "start": { + "line": 10, + "column": 6 + }, + "end": { + "line": 10, + "column": 9 + } + }, + "value": "foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 169, + 170 + ], + "loc": { + "start": { + "line": 10, + "column": 9 + }, + "end": { + "line": 10, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 170, + 171 + ], + "loc": { + "start": { + "line": 10, + "column": 10 + }, + "end": { + "line": 10, + "column": 11 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 171, + 172 + ], + "loc": { + "start": { + "line": 10, + "column": 11 + }, + "end": { + "line": 10, + "column": 12 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 172, + 177 + ], + "loc": { + "start": { + "line": 10, + "column": 12 + }, + "end": { + "line": 10, + "column": 17 + } + }, + "value": "p.foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 177, + 178 + ], + "loc": { + "start": { + "line": 10, + "column": 17 + }, + "end": { + "line": 11, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 178, + 194 + ], + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 16 + } + }, + "value": "console.log(foo)" + }, + { + "type": "HTMLWhitespace", + "range": [ + 194, + 195 + ], + "loc": { + "start": { + "line": 11, + "column": 16 + }, + "end": { + "line": 12, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 195, + 203 + ], + "loc": { + "start": { + "line": 12, + "column": 0 + }, + "end": { + "line": 12, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 203, + 204 + ], + "loc": { + "start": { + "line": 12, + "column": 8 + }, + "end": { + "line": 12, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 204, + 205 + ], + "loc": { + "start": { + "line": 12, + "column": 9 + }, + "end": { + "line": 13, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 205, + 214 + ], + "loc": { + "start": { + "line": 13, + "column": 0 + }, + "end": { + "line": 13, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 214, + 215 + ], + "loc": { + "start": { + "line": 13, + "column": 9 + }, + "end": { + "line": 13, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 215, + 216 + ], + "loc": { + "start": { + "line": 13, + "column": 10 + }, + "end": { + "line": 14, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionStart", + "range": [ + 216, + 218 + ], + "loc": { + "start": { + "line": 14, + "column": 0 + }, + "end": { + "line": 14, + "column": 2 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 14, + "column": 5 + }, + "start": { + "line": 14, + "column": 2 + } + }, + "range": [ + 218, + 221 + ], + "value": "foo" + }, + { + "type": "VExpressionEnd", + "range": [ + 221, + 223 + ], + "loc": { + "start": { + "line": 14, + "column": 5 + }, + "end": { + "line": 14, + "column": 7 + } + }, + "value": "}}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 223, + 224 + ], + "loc": { + "start": { + "line": 14, + "column": 7 + }, + "end": { + "line": 15, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 224, + 234 + ], + "loc": { + "start": { + "line": 15, + "column": 0 + }, + "end": { + "line": 15, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 234, + 235 + ], + "loc": { + "start": { + "line": 15, + "column": 10 + }, + "end": { + "line": 15, + "column": 11 + } + }, + "value": "" + } + ], + "comments": [ + { + "type": "Line", + "loc": { + "end": { + "line": 4, + "column": 15 + }, + "start": { + "line": 4, + "column": 4 + } + }, + "range": [ + 59, + 70 + ], + "value": " Comments" + } + ], + "errors": [] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/vue3.3-generic-4-with-spaces/parser-options.json b/test/fixtures/ast/vue3.3-generic-4-with-spaces/parser-options.json new file mode 100644 index 00000000..0ead30e9 --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-4-with-spaces/parser-options.json @@ -0,0 +1,6 @@ +{ + "sourceType": "module", + "parser": { + "ts": "@typescript-eslint/parser" + } +} diff --git a/test/fixtures/ast/vue3.3-generic-4-with-spaces/source.vue b/test/fixtures/ast/vue3.3-generic-4-with-spaces/source.vue new file mode 100644 index 00000000..7b4d167f --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-4-with-spaces/source.vue @@ -0,0 +1,15 @@ + + \ No newline at end of file diff --git a/test/fixtures/ast/vue3.3-generic-4-with-spaces/token-ranges.json b/test/fixtures/ast/vue3.3-generic-4-with-spaces/token-ranges.json new file mode 100644 index 00000000..66951b9a --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-4-with-spaces/token-ranges.json @@ -0,0 +1,104 @@ +[ + "", + "", + "\n", + "type", + " ", + "Foo", + " ", + "=", + " ", + "number", + " ", + "|", + " ", + "string", + "\n", + "const", + " ", + "p", + " ", + "=", + " ", + "defineProps<{foo:T,", + " ", + "bar:", + " ", + "U}>()", + "\n", + "const", + " ", + "foo", + " ", + "=", + " ", + "p.foo", + "\n", + "console.log(foo)", + "\n", + "", + "\n", + "", + "\n", + "{{", + "foo", + "}}", + "\n", + "", + "// Comments" +] \ No newline at end of file diff --git a/test/fixtures/ast/vue3.3-generic-4-with-spaces/tree.json b/test/fixtures/ast/vue3.3-generic-4-with-spaces/tree.json new file mode 100644 index 00000000..eea3840c --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-4-with-spaces/tree.json @@ -0,0 +1,39 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/ast/vue3.3-generic-5-with-spaces/ast.json b/test/fixtures/ast/vue3.3-generic-5-with-spaces/ast.json new file mode 100644 index 00000000..b2319f0c --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-5-with-spaces/ast.json @@ -0,0 +1,2800 @@ +{ + "type": "Program", + "range": [ + 142, + 245 + ], + "body": [ + { + "type": "TSTypeAliasDeclaration", + "declare": false, + "id": { + "type": "Identifier", + "decorators": [], + "name": "Foo", + "optional": false, + "range": [ + 147, + 150 + ], + "loc": { + "end": { + "line": 9, + "column": 8 + }, + "start": { + "line": 9, + "column": 5 + } + } + }, + "typeAnnotation": { + "type": "TSUnionType", + "types": [ + { + "type": "TSNumberKeyword", + "range": [ + 153, + 159 + ], + "loc": { + "end": { + "line": 9, + "column": 17 + }, + "start": { + "line": 9, + "column": 11 + } + } + }, + { + "type": "TSStringKeyword", + "range": [ + 162, + 168 + ], + "loc": { + "end": { + "line": 9, + "column": 26 + }, + "start": { + "line": 9, + "column": 20 + } + } + } + ], + "range": [ + 153, + 168 + ], + "loc": { + "end": { + "line": 9, + "column": 26 + }, + "start": { + "line": 9, + "column": 11 + } + } + }, + "range": [ + 142, + 168 + ], + "loc": { + "end": { + "line": 9, + "column": 26 + }, + "start": { + "line": 9, + "column": 0 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "definite": false, + "id": { + "type": "Identifier", + "decorators": [], + "name": "p", + "optional": false, + "range": [ + 175, + 176 + ], + "loc": { + "end": { + "line": 10, + "column": 7 + }, + "start": { + "line": 10, + "column": 6 + } + } + }, + "init": { + "type": "CallExpression", + "arguments": [], + "callee": { + "type": "Identifier", + "decorators": [], + "name": "defineProps", + "optional": false, + "range": [ + 179, + 190 + ], + "loc": { + "end": { + "line": 10, + "column": 21 + }, + "start": { + "line": 10, + "column": 10 + } + } + }, + "optional": false, + "typeArguments": { + "type": "TSTypeParameterInstantiation", + "range": [ + 190, + 207 + ], + "params": [ + { + "type": "TSTypeLiteral", + "members": [ + { + "type": "TSPropertySignature", + "computed": false, + "key": { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 192, + 195 + ], + "loc": { + "end": { + "line": 10, + "column": 26 + }, + "start": { + "line": 10, + "column": 23 + } + } + }, + "optional": false, + "readonly": false, + "static": false, + "typeAnnotation": { + "type": "TSTypeAnnotation", + "loc": { + "end": { + "line": 10, + "column": 28 + }, + "start": { + "line": 10, + "column": 26 + } + }, + "range": [ + 195, + 197 + ], + "typeAnnotation": { + "type": "TSTypeReference", + "typeName": { + "type": "Identifier", + "decorators": [], + "name": "T", + "optional": false, + "range": [ + 196, + 197 + ], + "loc": { + "end": { + "line": 10, + "column": 28 + }, + "start": { + "line": 10, + "column": 27 + } + } + }, + "range": [ + 196, + 197 + ], + "loc": { + "end": { + "line": 10, + "column": 28 + }, + "start": { + "line": 10, + "column": 27 + } + } + } + }, + "range": [ + 192, + 198 + ], + "loc": { + "end": { + "line": 10, + "column": 29 + }, + "start": { + "line": 10, + "column": 23 + } + } + }, + { + "type": "TSPropertySignature", + "computed": false, + "key": { + "type": "Identifier", + "decorators": [], + "name": "bar", + "optional": false, + "range": [ + 199, + 202 + ], + "loc": { + "end": { + "line": 10, + "column": 33 + }, + "start": { + "line": 10, + "column": 30 + } + } + }, + "optional": false, + "readonly": false, + "static": false, + "typeAnnotation": { + "type": "TSTypeAnnotation", + "loc": { + "end": { + "line": 10, + "column": 36 + }, + "start": { + "line": 10, + "column": 33 + } + }, + "range": [ + 202, + 205 + ], + "typeAnnotation": { + "type": "TSTypeReference", + "typeName": { + "type": "Identifier", + "decorators": [], + "name": "U", + "optional": false, + "range": [ + 204, + 205 + ], + "loc": { + "end": { + "line": 10, + "column": 36 + }, + "start": { + "line": 10, + "column": 35 + } + } + }, + "range": [ + 204, + 205 + ], + "loc": { + "end": { + "line": 10, + "column": 36 + }, + "start": { + "line": 10, + "column": 35 + } + } + } + }, + "range": [ + 199, + 205 + ], + "loc": { + "end": { + "line": 10, + "column": 36 + }, + "start": { + "line": 10, + "column": 30 + } + } + } + ], + "range": [ + 191, + 206 + ], + "loc": { + "end": { + "line": 10, + "column": 37 + }, + "start": { + "line": 10, + "column": 22 + } + } + } + ], + "loc": { + "end": { + "line": 10, + "column": 38 + }, + "start": { + "line": 10, + "column": 21 + } + } + }, + "range": [ + 179, + 209 + ], + "loc": { + "end": { + "line": 10, + "column": 40 + }, + "start": { + "line": 10, + "column": 10 + } + } + }, + "range": [ + 175, + 209 + ], + "loc": { + "end": { + "line": 10, + "column": 40 + }, + "start": { + "line": 10, + "column": 6 + } + } + } + ], + "declare": false, + "kind": "const", + "range": [ + 169, + 209 + ], + "loc": { + "end": { + "line": 10, + "column": 40 + }, + "start": { + "line": 10, + "column": 0 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "definite": false, + "id": { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 216, + 219 + ], + "loc": { + "end": { + "line": 11, + "column": 9 + }, + "start": { + "line": 11, + "column": 6 + } + } + }, + "init": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "decorators": [], + "name": "p", + "optional": false, + "range": [ + 222, + 223 + ], + "loc": { + "end": { + "line": 11, + "column": 13 + }, + "start": { + "line": 11, + "column": 12 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 224, + 227 + ], + "loc": { + "end": { + "line": 11, + "column": 17 + }, + "start": { + "line": 11, + "column": 14 + } + } + }, + "range": [ + 222, + 227 + ], + "loc": { + "end": { + "line": 11, + "column": 17 + }, + "start": { + "line": 11, + "column": 12 + } + } + }, + "range": [ + 216, + 227 + ], + "loc": { + "end": { + "line": 11, + "column": 17 + }, + "start": { + "line": 11, + "column": 6 + } + } + } + ], + "declare": false, + "kind": "const", + "range": [ + 210, + 227 + ], + "loc": { + "end": { + "line": 11, + "column": 17 + }, + "start": { + "line": 11, + "column": 0 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "arguments": [ + { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 240, + 243 + ], + "loc": { + "end": { + "line": 12, + "column": 15 + }, + "start": { + "line": 12, + "column": 12 + } + } + } + ], + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "decorators": [], + "name": "console", + "optional": false, + "range": [ + 228, + 235 + ], + "loc": { + "end": { + "line": 12, + "column": 7 + }, + "start": { + "line": 12, + "column": 0 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "decorators": [], + "name": "log", + "optional": false, + "range": [ + 236, + 239 + ], + "loc": { + "end": { + "line": 12, + "column": 11 + }, + "start": { + "line": 12, + "column": 8 + } + } + }, + "range": [ + 228, + 239 + ], + "loc": { + "end": { + "line": 12, + "column": 11 + }, + "start": { + "line": 12, + "column": 0 + } + } + }, + "optional": false, + "range": [ + 228, + 244 + ], + "loc": { + "end": { + "line": 12, + "column": 16 + }, + "start": { + "line": 12, + "column": 0 + } + } + }, + "range": [ + 228, + 244 + ], + "loc": { + "end": { + "line": 12, + "column": 16 + }, + "start": { + "line": 12, + "column": 0 + } + } + } + ], + "comments": [], + "sourceType": "module", + "tokens": [ + { + "type": "Punctuator", + "range": [ + 0, + 141 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 8, + "column": 2 + } + }, + "value": "" + } + ], + "loc": { + "end": { + "line": 13, + "column": 0 + }, + "start": { + "line": 9, + "column": 0 + } + }, + "templateBody": { + "type": "VElement", + "range": [ + 255, + 285 + ], + "loc": { + "start": { + "line": 14, + "column": 0 + }, + "end": { + "line": 16, + "column": 11 + } + }, + "name": "template", + "rawName": "template", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 255, + 265 + ], + "loc": { + "start": { + "line": 14, + "column": 0 + }, + "end": { + "line": 14, + "column": 10 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 265, + 266 + ], + "loc": { + "start": { + "line": 14, + "column": 10 + }, + "end": { + "line": 15, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionContainer", + "range": [ + 266, + 273 + ], + "loc": { + "start": { + "line": 15, + "column": 0 + }, + "end": { + "line": 15, + "column": 7 + } + }, + "expression": { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 268, + 271 + ], + "loc": { + "end": { + "line": 15, + "column": 5 + }, + "start": { + "line": 15, + "column": 2 + } + } + }, + "references": [ + { + "id": { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 268, + 271 + ], + "loc": { + "end": { + "line": 15, + "column": 5 + }, + "start": { + "line": 15, + "column": 2 + } + } + }, + "mode": "r", + "isValueReference": true, + "isTypeReference": false + } + ] + }, + { + "type": "VText", + "range": [ + 273, + 274 + ], + "loc": { + "start": { + "line": 15, + "column": 7 + }, + "end": { + "line": 16, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 274, + 285 + ], + "loc": { + "start": { + "line": 16, + "column": 0 + }, + "end": { + "line": 16, + "column": 11 + } + } + }, + "variables": [], + "tokens": [ + { + "type": "HTMLTagOpen", + "range": [ + 0, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLIdentifier", + "range": [ + 8, + 13 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": "setup" + }, + { + "type": "HTMLIdentifier", + "range": [ + 14, + 18 + ], + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "value": "lang" + }, + { + "type": "HTMLAssociation", + "range": [ + 18, + 19 + ], + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "value": "" + }, + { + "type": "HTMLLiteral", + "range": [ + 19, + 23 + ], + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "value": "ts" + }, + { + "type": "HTMLIdentifier", + "range": [ + 24, + 31 + ], + "loc": { + "start": { + "column": 24, + "line": 1 + }, + "end": { + "column": 31, + "line": 1 + } + }, + "value": "generic" + }, + { + "type": "HTMLAssociation", + "range": [ + 31, + 32 + ], + "loc": { + "start": { + "line": 1, + "column": 31 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 32, + 33 + ], + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 2, + "column": 3 + }, + "start": { + "line": 2, + "column": 2 + } + }, + "range": [ + 36, + 37 + ], + "value": "T" + }, + { + "type": "Keyword", + "loc": { + "end": { + "line": 3, + "column": 11 + }, + "start": { + "line": 3, + "column": 4 + } + }, + "range": [ + 54, + 61 + ], + "value": "extends" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 3, + "column": 15 + }, + "start": { + "line": 3, + "column": 12 + } + }, + "range": [ + 62, + 65 + ], + "value": "Foo" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 16 + }, + "start": { + "line": 3, + "column": 15 + } + }, + "range": [ + 65, + 66 + ], + "value": "," + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 5, + "column": 3 + }, + "start": { + "line": 5, + "column": 2 + } + }, + "range": [ + 85, + 86 + ], + "value": "U" + }, + { + "type": "Keyword", + "loc": { + "end": { + "line": 6, + "column": 11 + }, + "start": { + "line": 6, + "column": 4 + } + }, + "range": [ + 106, + 113 + ], + "value": "extends" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 7, + "column": 10 + }, + "start": { + "line": 7, + "column": 4 + } + }, + "range": [ + 118, + 124 + ], + "value": "Record" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 7, + "column": 14 + }, + "start": { + "line": 7, + "column": 10 + } + }, + "range": [ + 124, + 128 + ], + "value": "<" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 7, + "column": 20 + }, + "start": { + "line": 7, + "column": 14 + } + }, + "range": [ + 128, + 134 + ], + "value": "string" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 7, + "column": 21 + }, + "start": { + "line": 7, + "column": 20 + } + }, + "range": [ + 134, + 135 + ], + "value": "," + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 7, + "column": 23 + }, + "start": { + "line": 7, + "column": 22 + } + }, + "range": [ + 136, + 137 + ], + "value": "T" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 7, + "column": 24 + }, + "start": { + "line": 7, + "column": 23 + } + }, + "range": [ + 137, + 138 + ], + "value": ">" + }, + { + "type": "Punctuator", + "range": [ + 139, + 140 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 1 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 140, + 141 + ], + "loc": { + "start": { + "line": 8, + "column": 1 + }, + "end": { + "line": 8, + "column": 2 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 141, + 142 + ], + "loc": { + "start": { + "line": 8, + "column": 2 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 142, + 146 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 4 + } + }, + "value": "type" + }, + { + "type": "HTMLWhitespace", + "range": [ + 146, + 147 + ], + "loc": { + "start": { + "line": 9, + "column": 4 + }, + "end": { + "line": 9, + "column": 5 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 147, + 150 + ], + "loc": { + "start": { + "line": 9, + "column": 5 + }, + "end": { + "line": 9, + "column": 8 + } + }, + "value": "Foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 150, + 151 + ], + "loc": { + "start": { + "line": 9, + "column": 8 + }, + "end": { + "line": 9, + "column": 9 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 151, + 152 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 9, + "column": 10 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 152, + 153 + ], + "loc": { + "start": { + "line": 9, + "column": 10 + }, + "end": { + "line": 9, + "column": 11 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 153, + 159 + ], + "loc": { + "start": { + "line": 9, + "column": 11 + }, + "end": { + "line": 9, + "column": 17 + } + }, + "value": "number" + }, + { + "type": "HTMLWhitespace", + "range": [ + 159, + 160 + ], + "loc": { + "start": { + "line": 9, + "column": 17 + }, + "end": { + "line": 9, + "column": 18 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 160, + 161 + ], + "loc": { + "start": { + "line": 9, + "column": 18 + }, + "end": { + "line": 9, + "column": 19 + } + }, + "value": "|" + }, + { + "type": "HTMLWhitespace", + "range": [ + 161, + 162 + ], + "loc": { + "start": { + "line": 9, + "column": 19 + }, + "end": { + "line": 9, + "column": 20 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 162, + 168 + ], + "loc": { + "start": { + "line": 9, + "column": 20 + }, + "end": { + "line": 9, + "column": 26 + } + }, + "value": "string" + }, + { + "type": "HTMLWhitespace", + "range": [ + 168, + 169 + ], + "loc": { + "start": { + "line": 9, + "column": 26 + }, + "end": { + "line": 10, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 169, + 174 + ], + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 174, + 175 + ], + "loc": { + "start": { + "line": 10, + "column": 5 + }, + "end": { + "line": 10, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 175, + 176 + ], + "loc": { + "start": { + "line": 10, + "column": 6 + }, + "end": { + "line": 10, + "column": 7 + } + }, + "value": "p" + }, + { + "type": "HTMLWhitespace", + "range": [ + 176, + 177 + ], + "loc": { + "start": { + "line": 10, + "column": 7 + }, + "end": { + "line": 10, + "column": 8 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 177, + 178 + ], + "loc": { + "start": { + "line": 10, + "column": 8 + }, + "end": { + "line": 10, + "column": 9 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 178, + 179 + ], + "loc": { + "start": { + "line": 10, + "column": 9 + }, + "end": { + "line": 10, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 179, + 198 + ], + "loc": { + "start": { + "line": 10, + "column": 10 + }, + "end": { + "line": 10, + "column": 29 + } + }, + "value": "defineProps<{foo:T," + }, + { + "type": "HTMLWhitespace", + "range": [ + 198, + 199 + ], + "loc": { + "start": { + "line": 10, + "column": 29 + }, + "end": { + "line": 10, + "column": 30 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 199, + 203 + ], + "loc": { + "start": { + "line": 10, + "column": 30 + }, + "end": { + "line": 10, + "column": 34 + } + }, + "value": "bar:" + }, + { + "type": "HTMLWhitespace", + "range": [ + 203, + 204 + ], + "loc": { + "start": { + "line": 10, + "column": 34 + }, + "end": { + "line": 10, + "column": 35 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 204, + 209 + ], + "loc": { + "start": { + "line": 10, + "column": 35 + }, + "end": { + "line": 10, + "column": 40 + } + }, + "value": "U}>()" + }, + { + "type": "HTMLWhitespace", + "range": [ + 209, + 210 + ], + "loc": { + "start": { + "line": 10, + "column": 40 + }, + "end": { + "line": 11, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 210, + 215 + ], + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 215, + 216 + ], + "loc": { + "start": { + "line": 11, + "column": 5 + }, + "end": { + "line": 11, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 216, + 219 + ], + "loc": { + "start": { + "line": 11, + "column": 6 + }, + "end": { + "line": 11, + "column": 9 + } + }, + "value": "foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 219, + 220 + ], + "loc": { + "start": { + "line": 11, + "column": 9 + }, + "end": { + "line": 11, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 220, + 221 + ], + "loc": { + "start": { + "line": 11, + "column": 10 + }, + "end": { + "line": 11, + "column": 11 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 221, + 222 + ], + "loc": { + "start": { + "line": 11, + "column": 11 + }, + "end": { + "line": 11, + "column": 12 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 222, + 227 + ], + "loc": { + "start": { + "line": 11, + "column": 12 + }, + "end": { + "line": 11, + "column": 17 + } + }, + "value": "p.foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 227, + 228 + ], + "loc": { + "start": { + "line": 11, + "column": 17 + }, + "end": { + "line": 12, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 228, + 244 + ], + "loc": { + "start": { + "line": 12, + "column": 0 + }, + "end": { + "line": 12, + "column": 16 + } + }, + "value": "console.log(foo)" + }, + { + "type": "HTMLWhitespace", + "range": [ + 244, + 245 + ], + "loc": { + "start": { + "line": 12, + "column": 16 + }, + "end": { + "line": 13, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 245, + 253 + ], + "loc": { + "start": { + "line": 13, + "column": 0 + }, + "end": { + "line": 13, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 253, + 254 + ], + "loc": { + "start": { + "line": 13, + "column": 8 + }, + "end": { + "line": 13, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 254, + 255 + ], + "loc": { + "start": { + "line": 13, + "column": 9 + }, + "end": { + "line": 14, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 255, + 264 + ], + "loc": { + "start": { + "line": 14, + "column": 0 + }, + "end": { + "line": 14, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 264, + 265 + ], + "loc": { + "start": { + "line": 14, + "column": 9 + }, + "end": { + "line": 14, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 265, + 266 + ], + "loc": { + "start": { + "line": 14, + "column": 10 + }, + "end": { + "line": 15, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionStart", + "range": [ + 266, + 268 + ], + "loc": { + "start": { + "line": 15, + "column": 0 + }, + "end": { + "line": 15, + "column": 2 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 15, + "column": 5 + }, + "start": { + "line": 15, + "column": 2 + } + }, + "range": [ + 268, + 271 + ], + "value": "foo" + }, + { + "type": "VExpressionEnd", + "range": [ + 271, + 273 + ], + "loc": { + "start": { + "line": 15, + "column": 5 + }, + "end": { + "line": 15, + "column": 7 + } + }, + "value": "}}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 273, + 274 + ], + "loc": { + "start": { + "line": 15, + "column": 7 + }, + "end": { + "line": 16, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 274, + 284 + ], + "loc": { + "start": { + "line": 16, + "column": 0 + }, + "end": { + "line": 16, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 284, + 285 + ], + "loc": { + "start": { + "line": 16, + "column": 10 + }, + "end": { + "line": 16, + "column": 11 + } + }, + "value": "" + } + ], + "comments": [ + { + "type": "Line", + "loc": { + "end": { + "line": 2, + "column": 15 + }, + "start": { + "line": 2, + "column": 4 + } + }, + "range": [ + 38, + 49 + ], + "value": " Comments" + }, + { + "type": "Line", + "loc": { + "end": { + "line": 4, + "column": 15 + }, + "start": { + "line": 4, + "column": 4 + } + }, + "range": [ + 71, + 82 + ], + "value": " Comments" + }, + { + "type": "Block", + "loc": { + "end": { + "line": 5, + "column": 18 + }, + "start": { + "line": 5, + "column": 4 + } + }, + "range": [ + 87, + 101 + ], + "value": " Comments " + } + ], + "errors": [] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/vue3.3-generic-5-with-spaces/parser-options.json b/test/fixtures/ast/vue3.3-generic-5-with-spaces/parser-options.json new file mode 100644 index 00000000..0ead30e9 --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-5-with-spaces/parser-options.json @@ -0,0 +1,6 @@ +{ + "sourceType": "module", + "parser": { + "ts": "@typescript-eslint/parser" + } +} diff --git a/test/fixtures/ast/vue3.3-generic-5-with-spaces/source.vue b/test/fixtures/ast/vue3.3-generic-5-with-spaces/source.vue new file mode 100644 index 00000000..1ce43570 --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-5-with-spaces/source.vue @@ -0,0 +1,16 @@ + + \ No newline at end of file diff --git a/test/fixtures/ast/vue3.3-generic-5-with-spaces/token-ranges.json b/test/fixtures/ast/vue3.3-generic-5-with-spaces/token-ranges.json new file mode 100644 index 00000000..1af7d0bd --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-5-with-spaces/token-ranges.json @@ -0,0 +1,111 @@ +[ + "", + "", + "\"", + ">", + "\n", + "type", + " ", + "Foo", + " ", + "=", + " ", + "number", + " ", + "|", + " ", + "string", + "\n", + "const", + " ", + "p", + " ", + "=", + " ", + "defineProps<{foo:T,", + " ", + "bar:", + " ", + "U}>()", + "\n", + "const", + " ", + "foo", + " ", + "=", + " ", + "p.foo", + "\n", + "console.log(foo)", + "\n", + "", + "\n", + "", + "\n", + "{{", + "foo", + "}}", + "\n", + "", + "// Comments", + "// Comments", + "/* Comments */" +] \ No newline at end of file diff --git a/test/fixtures/ast/vue3.3-generic-5-with-spaces/tree.json b/test/fixtures/ast/vue3.3-generic-5-with-spaces/tree.json new file mode 100644 index 00000000..eea3840c --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-5-with-spaces/tree.json @@ -0,0 +1,39 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/ast/vue3.3-generic-6-with-default/ast.json b/test/fixtures/ast/vue3.3-generic-6-with-default/ast.json new file mode 100644 index 00000000..df9f6fee --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-6-with-default/ast.json @@ -0,0 +1,3016 @@ +{ + "type": "Program", + "range": [ + 228, + 331 + ], + "body": [ + { + "type": "TSTypeAliasDeclaration", + "declare": false, + "id": { + "type": "Identifier", + "decorators": [], + "name": "Foo", + "optional": false, + "range": [ + 233, + 236 + ], + "loc": { + "end": { + "line": 14, + "column": 8 + }, + "start": { + "line": 14, + "column": 5 + } + } + }, + "typeAnnotation": { + "type": "TSUnionType", + "types": [ + { + "type": "TSNumberKeyword", + "range": [ + 239, + 245 + ], + "loc": { + "end": { + "line": 14, + "column": 17 + }, + "start": { + "line": 14, + "column": 11 + } + } + }, + { + "type": "TSStringKeyword", + "range": [ + 248, + 254 + ], + "loc": { + "end": { + "line": 14, + "column": 26 + }, + "start": { + "line": 14, + "column": 20 + } + } + } + ], + "range": [ + 239, + 254 + ], + "loc": { + "end": { + "line": 14, + "column": 26 + }, + "start": { + "line": 14, + "column": 11 + } + } + }, + "range": [ + 228, + 254 + ], + "loc": { + "end": { + "line": 14, + "column": 26 + }, + "start": { + "line": 14, + "column": 0 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "definite": false, + "id": { + "type": "Identifier", + "decorators": [], + "name": "p", + "optional": false, + "range": [ + 261, + 262 + ], + "loc": { + "end": { + "line": 15, + "column": 7 + }, + "start": { + "line": 15, + "column": 6 + } + } + }, + "init": { + "type": "CallExpression", + "arguments": [], + "callee": { + "type": "Identifier", + "decorators": [], + "name": "defineProps", + "optional": false, + "range": [ + 265, + 276 + ], + "loc": { + "end": { + "line": 15, + "column": 21 + }, + "start": { + "line": 15, + "column": 10 + } + } + }, + "optional": false, + "typeArguments": { + "type": "TSTypeParameterInstantiation", + "range": [ + 276, + 293 + ], + "params": [ + { + "type": "TSTypeLiteral", + "members": [ + { + "type": "TSPropertySignature", + "computed": false, + "key": { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 278, + 281 + ], + "loc": { + "end": { + "line": 15, + "column": 26 + }, + "start": { + "line": 15, + "column": 23 + } + } + }, + "optional": false, + "readonly": false, + "static": false, + "typeAnnotation": { + "type": "TSTypeAnnotation", + "loc": { + "end": { + "line": 15, + "column": 28 + }, + "start": { + "line": 15, + "column": 26 + } + }, + "range": [ + 281, + 283 + ], + "typeAnnotation": { + "type": "TSTypeReference", + "typeName": { + "type": "Identifier", + "decorators": [], + "name": "T", + "optional": false, + "range": [ + 282, + 283 + ], + "loc": { + "end": { + "line": 15, + "column": 28 + }, + "start": { + "line": 15, + "column": 27 + } + } + }, + "range": [ + 282, + 283 + ], + "loc": { + "end": { + "line": 15, + "column": 28 + }, + "start": { + "line": 15, + "column": 27 + } + } + } + }, + "range": [ + 278, + 284 + ], + "loc": { + "end": { + "line": 15, + "column": 29 + }, + "start": { + "line": 15, + "column": 23 + } + } + }, + { + "type": "TSPropertySignature", + "computed": false, + "key": { + "type": "Identifier", + "decorators": [], + "name": "bar", + "optional": false, + "range": [ + 285, + 288 + ], + "loc": { + "end": { + "line": 15, + "column": 33 + }, + "start": { + "line": 15, + "column": 30 + } + } + }, + "optional": false, + "readonly": false, + "static": false, + "typeAnnotation": { + "type": "TSTypeAnnotation", + "loc": { + "end": { + "line": 15, + "column": 36 + }, + "start": { + "line": 15, + "column": 33 + } + }, + "range": [ + 288, + 291 + ], + "typeAnnotation": { + "type": "TSTypeReference", + "typeName": { + "type": "Identifier", + "decorators": [], + "name": "U", + "optional": false, + "range": [ + 290, + 291 + ], + "loc": { + "end": { + "line": 15, + "column": 36 + }, + "start": { + "line": 15, + "column": 35 + } + } + }, + "range": [ + 290, + 291 + ], + "loc": { + "end": { + "line": 15, + "column": 36 + }, + "start": { + "line": 15, + "column": 35 + } + } + } + }, + "range": [ + 285, + 291 + ], + "loc": { + "end": { + "line": 15, + "column": 36 + }, + "start": { + "line": 15, + "column": 30 + } + } + } + ], + "range": [ + 277, + 292 + ], + "loc": { + "end": { + "line": 15, + "column": 37 + }, + "start": { + "line": 15, + "column": 22 + } + } + } + ], + "loc": { + "end": { + "line": 15, + "column": 38 + }, + "start": { + "line": 15, + "column": 21 + } + } + }, + "range": [ + 265, + 295 + ], + "loc": { + "end": { + "line": 15, + "column": 40 + }, + "start": { + "line": 15, + "column": 10 + } + } + }, + "range": [ + 261, + 295 + ], + "loc": { + "end": { + "line": 15, + "column": 40 + }, + "start": { + "line": 15, + "column": 6 + } + } + } + ], + "declare": false, + "kind": "const", + "range": [ + 255, + 295 + ], + "loc": { + "end": { + "line": 15, + "column": 40 + }, + "start": { + "line": 15, + "column": 0 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "definite": false, + "id": { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 302, + 305 + ], + "loc": { + "end": { + "line": 16, + "column": 9 + }, + "start": { + "line": 16, + "column": 6 + } + } + }, + "init": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "decorators": [], + "name": "p", + "optional": false, + "range": [ + 308, + 309 + ], + "loc": { + "end": { + "line": 16, + "column": 13 + }, + "start": { + "line": 16, + "column": 12 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 310, + 313 + ], + "loc": { + "end": { + "line": 16, + "column": 17 + }, + "start": { + "line": 16, + "column": 14 + } + } + }, + "range": [ + 308, + 313 + ], + "loc": { + "end": { + "line": 16, + "column": 17 + }, + "start": { + "line": 16, + "column": 12 + } + } + }, + "range": [ + 302, + 313 + ], + "loc": { + "end": { + "line": 16, + "column": 17 + }, + "start": { + "line": 16, + "column": 6 + } + } + } + ], + "declare": false, + "kind": "const", + "range": [ + 296, + 313 + ], + "loc": { + "end": { + "line": 16, + "column": 17 + }, + "start": { + "line": 16, + "column": 0 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "arguments": [ + { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 326, + 329 + ], + "loc": { + "end": { + "line": 17, + "column": 15 + }, + "start": { + "line": 17, + "column": 12 + } + } + } + ], + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "decorators": [], + "name": "console", + "optional": false, + "range": [ + 314, + 321 + ], + "loc": { + "end": { + "line": 17, + "column": 7 + }, + "start": { + "line": 17, + "column": 0 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "decorators": [], + "name": "log", + "optional": false, + "range": [ + 322, + 325 + ], + "loc": { + "end": { + "line": 17, + "column": 11 + }, + "start": { + "line": 17, + "column": 8 + } + } + }, + "range": [ + 314, + 325 + ], + "loc": { + "end": { + "line": 17, + "column": 11 + }, + "start": { + "line": 17, + "column": 0 + } + } + }, + "optional": false, + "range": [ + 314, + 330 + ], + "loc": { + "end": { + "line": 17, + "column": 16 + }, + "start": { + "line": 17, + "column": 0 + } + } + }, + "range": [ + 314, + 330 + ], + "loc": { + "end": { + "line": 17, + "column": 16 + }, + "start": { + "line": 17, + "column": 0 + } + } + } + ], + "comments": [], + "sourceType": "module", + "tokens": [ + { + "type": "Punctuator", + "range": [ + 0, + 227 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 13, + "column": 2 + } + }, + "value": "" + } + ], + "loc": { + "end": { + "line": 18, + "column": 0 + }, + "start": { + "line": 14, + "column": 0 + } + }, + "templateBody": { + "type": "VElement", + "range": [ + 341, + 371 + ], + "loc": { + "start": { + "line": 19, + "column": 0 + }, + "end": { + "line": 21, + "column": 11 + } + }, + "name": "template", + "rawName": "template", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 341, + 351 + ], + "loc": { + "start": { + "line": 19, + "column": 0 + }, + "end": { + "line": 19, + "column": 10 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 351, + 352 + ], + "loc": { + "start": { + "line": 19, + "column": 10 + }, + "end": { + "line": 20, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionContainer", + "range": [ + 352, + 359 + ], + "loc": { + "start": { + "line": 20, + "column": 0 + }, + "end": { + "line": 20, + "column": 7 + } + }, + "expression": { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 354, + 357 + ], + "loc": { + "end": { + "line": 20, + "column": 5 + }, + "start": { + "line": 20, + "column": 2 + } + } + }, + "references": [ + { + "id": { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 354, + 357 + ], + "loc": { + "end": { + "line": 20, + "column": 5 + }, + "start": { + "line": 20, + "column": 2 + } + } + }, + "mode": "r", + "isValueReference": true, + "isTypeReference": false + } + ] + }, + { + "type": "VText", + "range": [ + 359, + 360 + ], + "loc": { + "start": { + "line": 20, + "column": 7 + }, + "end": { + "line": 21, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 360, + 371 + ], + "loc": { + "start": { + "line": 21, + "column": 0 + }, + "end": { + "line": 21, + "column": 11 + } + } + }, + "variables": [], + "tokens": [ + { + "type": "HTMLTagOpen", + "range": [ + 0, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLIdentifier", + "range": [ + 8, + 13 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": "setup" + }, + { + "type": "HTMLIdentifier", + "range": [ + 14, + 18 + ], + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "value": "lang" + }, + { + "type": "HTMLAssociation", + "range": [ + 18, + 19 + ], + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "value": "" + }, + { + "type": "HTMLLiteral", + "range": [ + 19, + 23 + ], + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "value": "ts" + }, + { + "type": "HTMLIdentifier", + "range": [ + 24, + 31 + ], + "loc": { + "start": { + "column": 24, + "line": 1 + }, + "end": { + "column": 31, + "line": 1 + } + }, + "value": "generic" + }, + { + "type": "HTMLAssociation", + "range": [ + 31, + 32 + ], + "loc": { + "start": { + "line": 1, + "column": 31 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 32, + 33 + ], + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 2, + "column": 3 + }, + "start": { + "line": 2, + "column": 2 + } + }, + "range": [ + 36, + 37 + ], + "value": "T" + }, + { + "type": "Keyword", + "loc": { + "end": { + "line": 3, + "column": 11 + }, + "start": { + "line": 3, + "column": 4 + } + }, + "range": [ + 54, + 61 + ], + "value": "extends" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 3, + "column": 23 + }, + "start": { + "line": 3, + "column": 20 + } + }, + "range": [ + 70, + 73 + ], + "value": "Foo" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 25 + }, + "start": { + "line": 3, + "column": 24 + } + }, + "range": [ + 74, + 75 + ], + "value": "=" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 3, + "column": 32 + }, + "start": { + "line": 3, + "column": 26 + } + }, + "range": [ + 76, + 82 + ], + "value": "number" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 33 + }, + "start": { + "line": 3, + "column": 32 + } + }, + "range": [ + 82, + 83 + ], + "value": "," + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 5, + "column": 3 + }, + "start": { + "line": 5, + "column": 2 + } + }, + "range": [ + 102, + 103 + ], + "value": "U" + }, + { + "type": "Keyword", + "loc": { + "end": { + "line": 6, + "column": 11 + }, + "start": { + "line": 6, + "column": 4 + } + }, + "range": [ + 122, + 129 + ], + "value": "extends" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 7, + "column": 10 + }, + "start": { + "line": 7, + "column": 4 + } + }, + "range": [ + 134, + 140 + ], + "value": "Record" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 7, + "column": 14 + }, + "start": { + "line": 7, + "column": 10 + } + }, + "range": [ + 140, + 144 + ], + "value": "<" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 9, + "column": 12 + }, + "start": { + "line": 9, + "column": 6 + } + }, + "range": [ + 165, + 171 + ], + "value": "string" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 9, + "column": 13 + }, + "start": { + "line": 9, + "column": 12 + } + }, + "range": [ + 171, + 172 + ], + "value": "," + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 10, + "column": 7 + }, + "start": { + "line": 10, + "column": 6 + } + }, + "range": [ + 184, + 185 + ], + "value": "T" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 11, + "column": 5 + }, + "start": { + "line": 11, + "column": 4 + } + }, + "range": [ + 190, + 191 + ], + "value": ">" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 12, + "column": 6 + }, + "start": { + "line": 12, + "column": 5 + } + }, + "range": [ + 197, + 198 + ], + "value": "=" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 12, + "column": 13 + }, + "start": { + "line": 12, + "column": 7 + } + }, + "range": [ + 199, + 205 + ], + "value": "Record" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 12, + "column": 14 + }, + "start": { + "line": 12, + "column": 13 + } + }, + "range": [ + 205, + 206 + ], + "value": "<" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 12, + "column": 20 + }, + "start": { + "line": 12, + "column": 14 + } + }, + "range": [ + 206, + 212 + ], + "value": "string" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 12, + "column": 21 + }, + "start": { + "line": 12, + "column": 20 + } + }, + "range": [ + 212, + 213 + ], + "value": "," + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 12, + "column": 28 + }, + "start": { + "line": 12, + "column": 22 + } + }, + "range": [ + 214, + 220 + ], + "value": "number" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 12, + "column": 32 + }, + "start": { + "line": 12, + "column": 28 + } + }, + "range": [ + 220, + 224 + ], + "value": ">" + }, + { + "type": "Punctuator", + "range": [ + 225, + 226 + ], + "loc": { + "start": { + "line": 13, + "column": 0 + }, + "end": { + "line": 13, + "column": 1 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 226, + 227 + ], + "loc": { + "start": { + "line": 13, + "column": 1 + }, + "end": { + "line": 13, + "column": 2 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 227, + 228 + ], + "loc": { + "start": { + "line": 13, + "column": 2 + }, + "end": { + "line": 14, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 228, + 232 + ], + "loc": { + "start": { + "line": 14, + "column": 0 + }, + "end": { + "line": 14, + "column": 4 + } + }, + "value": "type" + }, + { + "type": "HTMLWhitespace", + "range": [ + 232, + 233 + ], + "loc": { + "start": { + "line": 14, + "column": 4 + }, + "end": { + "line": 14, + "column": 5 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 233, + 236 + ], + "loc": { + "start": { + "line": 14, + "column": 5 + }, + "end": { + "line": 14, + "column": 8 + } + }, + "value": "Foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 236, + 237 + ], + "loc": { + "start": { + "line": 14, + "column": 8 + }, + "end": { + "line": 14, + "column": 9 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 237, + 238 + ], + "loc": { + "start": { + "line": 14, + "column": 9 + }, + "end": { + "line": 14, + "column": 10 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 238, + 239 + ], + "loc": { + "start": { + "line": 14, + "column": 10 + }, + "end": { + "line": 14, + "column": 11 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 239, + 245 + ], + "loc": { + "start": { + "line": 14, + "column": 11 + }, + "end": { + "line": 14, + "column": 17 + } + }, + "value": "number" + }, + { + "type": "HTMLWhitespace", + "range": [ + 245, + 246 + ], + "loc": { + "start": { + "line": 14, + "column": 17 + }, + "end": { + "line": 14, + "column": 18 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 246, + 247 + ], + "loc": { + "start": { + "line": 14, + "column": 18 + }, + "end": { + "line": 14, + "column": 19 + } + }, + "value": "|" + }, + { + "type": "HTMLWhitespace", + "range": [ + 247, + 248 + ], + "loc": { + "start": { + "line": 14, + "column": 19 + }, + "end": { + "line": 14, + "column": 20 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 248, + 254 + ], + "loc": { + "start": { + "line": 14, + "column": 20 + }, + "end": { + "line": 14, + "column": 26 + } + }, + "value": "string" + }, + { + "type": "HTMLWhitespace", + "range": [ + 254, + 255 + ], + "loc": { + "start": { + "line": 14, + "column": 26 + }, + "end": { + "line": 15, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 255, + 260 + ], + "loc": { + "start": { + "line": 15, + "column": 0 + }, + "end": { + "line": 15, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 260, + 261 + ], + "loc": { + "start": { + "line": 15, + "column": 5 + }, + "end": { + "line": 15, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 261, + 262 + ], + "loc": { + "start": { + "line": 15, + "column": 6 + }, + "end": { + "line": 15, + "column": 7 + } + }, + "value": "p" + }, + { + "type": "HTMLWhitespace", + "range": [ + 262, + 263 + ], + "loc": { + "start": { + "line": 15, + "column": 7 + }, + "end": { + "line": 15, + "column": 8 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 263, + 264 + ], + "loc": { + "start": { + "line": 15, + "column": 8 + }, + "end": { + "line": 15, + "column": 9 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 264, + 265 + ], + "loc": { + "start": { + "line": 15, + "column": 9 + }, + "end": { + "line": 15, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 265, + 284 + ], + "loc": { + "start": { + "line": 15, + "column": 10 + }, + "end": { + "line": 15, + "column": 29 + } + }, + "value": "defineProps<{foo:T," + }, + { + "type": "HTMLWhitespace", + "range": [ + 284, + 285 + ], + "loc": { + "start": { + "line": 15, + "column": 29 + }, + "end": { + "line": 15, + "column": 30 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 285, + 289 + ], + "loc": { + "start": { + "line": 15, + "column": 30 + }, + "end": { + "line": 15, + "column": 34 + } + }, + "value": "bar:" + }, + { + "type": "HTMLWhitespace", + "range": [ + 289, + 290 + ], + "loc": { + "start": { + "line": 15, + "column": 34 + }, + "end": { + "line": 15, + "column": 35 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 290, + 295 + ], + "loc": { + "start": { + "line": 15, + "column": 35 + }, + "end": { + "line": 15, + "column": 40 + } + }, + "value": "U}>()" + }, + { + "type": "HTMLWhitespace", + "range": [ + 295, + 296 + ], + "loc": { + "start": { + "line": 15, + "column": 40 + }, + "end": { + "line": 16, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 296, + 301 + ], + "loc": { + "start": { + "line": 16, + "column": 0 + }, + "end": { + "line": 16, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 301, + 302 + ], + "loc": { + "start": { + "line": 16, + "column": 5 + }, + "end": { + "line": 16, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 302, + 305 + ], + "loc": { + "start": { + "line": 16, + "column": 6 + }, + "end": { + "line": 16, + "column": 9 + } + }, + "value": "foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 305, + 306 + ], + "loc": { + "start": { + "line": 16, + "column": 9 + }, + "end": { + "line": 16, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 306, + 307 + ], + "loc": { + "start": { + "line": 16, + "column": 10 + }, + "end": { + "line": 16, + "column": 11 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 307, + 308 + ], + "loc": { + "start": { + "line": 16, + "column": 11 + }, + "end": { + "line": 16, + "column": 12 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 308, + 313 + ], + "loc": { + "start": { + "line": 16, + "column": 12 + }, + "end": { + "line": 16, + "column": 17 + } + }, + "value": "p.foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 313, + 314 + ], + "loc": { + "start": { + "line": 16, + "column": 17 + }, + "end": { + "line": 17, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 314, + 330 + ], + "loc": { + "start": { + "line": 17, + "column": 0 + }, + "end": { + "line": 17, + "column": 16 + } + }, + "value": "console.log(foo)" + }, + { + "type": "HTMLWhitespace", + "range": [ + 330, + 331 + ], + "loc": { + "start": { + "line": 17, + "column": 16 + }, + "end": { + "line": 18, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 331, + 339 + ], + "loc": { + "start": { + "line": 18, + "column": 0 + }, + "end": { + "line": 18, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 339, + 340 + ], + "loc": { + "start": { + "line": 18, + "column": 8 + }, + "end": { + "line": 18, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 340, + 341 + ], + "loc": { + "start": { + "line": 18, + "column": 9 + }, + "end": { + "line": 19, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 341, + 350 + ], + "loc": { + "start": { + "line": 19, + "column": 0 + }, + "end": { + "line": 19, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 350, + 351 + ], + "loc": { + "start": { + "line": 19, + "column": 9 + }, + "end": { + "line": 19, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 351, + 352 + ], + "loc": { + "start": { + "line": 19, + "column": 10 + }, + "end": { + "line": 20, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionStart", + "range": [ + 352, + 354 + ], + "loc": { + "start": { + "line": 20, + "column": 0 + }, + "end": { + "line": 20, + "column": 2 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 20, + "column": 5 + }, + "start": { + "line": 20, + "column": 2 + } + }, + "range": [ + 354, + 357 + ], + "value": "foo" + }, + { + "type": "VExpressionEnd", + "range": [ + 357, + 359 + ], + "loc": { + "start": { + "line": 20, + "column": 5 + }, + "end": { + "line": 20, + "column": 7 + } + }, + "value": "}}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 359, + 360 + ], + "loc": { + "start": { + "line": 20, + "column": 7 + }, + "end": { + "line": 21, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 360, + 370 + ], + "loc": { + "start": { + "line": 21, + "column": 0 + }, + "end": { + "line": 21, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 370, + 371 + ], + "loc": { + "start": { + "line": 21, + "column": 10 + }, + "end": { + "line": 21, + "column": 11 + } + }, + "value": "" + } + ], + "comments": [ + { + "type": "Line", + "loc": { + "end": { + "line": 2, + "column": 15 + }, + "start": { + "line": 2, + "column": 4 + } + }, + "range": [ + 38, + 49 + ], + "value": " Comments" + }, + { + "type": "Block", + "loc": { + "end": { + "line": 3, + "column": 19 + }, + "start": { + "line": 3, + "column": 12 + } + }, + "range": [ + 62, + 69 + ], + "value": " = " + }, + { + "type": "Line", + "loc": { + "end": { + "line": 4, + "column": 15 + }, + "start": { + "line": 4, + "column": 4 + } + }, + "range": [ + 88, + 99 + ], + "value": " Comments" + }, + { + "type": "Block", + "loc": { + "end": { + "line": 5, + "column": 17 + }, + "start": { + "line": 5, + "column": 4 + } + }, + "range": [ + 104, + 117 + ], + "value": " extends " + }, + { + "type": "Block", + "loc": { + "end": { + "line": 8, + "column": 13 + }, + "start": { + "line": 8, + "column": 6 + } + }, + "range": [ + 151, + 158 + ], + "value": " = " + }, + { + "type": "Line", + "loc": { + "end": { + "line": 9, + "column": 18 + }, + "start": { + "line": 9, + "column": 14 + } + }, + "range": [ + 173, + 177 + ], + "value": " =" + } + ], + "errors": [] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/vue3.3-generic-6-with-default/parser-options.json b/test/fixtures/ast/vue3.3-generic-6-with-default/parser-options.json new file mode 100644 index 00000000..0ead30e9 --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-6-with-default/parser-options.json @@ -0,0 +1,6 @@ +{ + "sourceType": "module", + "parser": { + "ts": "@typescript-eslint/parser" + } +} diff --git a/test/fixtures/ast/vue3.3-generic-6-with-default/source.vue b/test/fixtures/ast/vue3.3-generic-6-with-default/source.vue new file mode 100644 index 00000000..a0ad29c8 --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-6-with-default/source.vue @@ -0,0 +1,21 @@ + + \ No newline at end of file diff --git a/test/fixtures/ast/vue3.3-generic-6-with-default/token-ranges.json b/test/fixtures/ast/vue3.3-generic-6-with-default/token-ranges.json new file mode 100644 index 00000000..25735e17 --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-6-with-default/token-ranges.json @@ -0,0 +1,123 @@ +[ + "", + "", + "=", + "Record", + "<", + "string", + ",", + "number", + ">", + "\"", + ">", + "\n", + "type", + " ", + "Foo", + " ", + "=", + " ", + "number", + " ", + "|", + " ", + "string", + "\n", + "const", + " ", + "p", + " ", + "=", + " ", + "defineProps<{foo:T,", + " ", + "bar:", + " ", + "U}>()", + "\n", + "const", + " ", + "foo", + " ", + "=", + " ", + "p.foo", + "\n", + "console.log(foo)", + "\n", + "", + "\n", + "", + "\n", + "{{", + "foo", + "}}", + "\n", + "", + "// Comments", + "/* = */", + "// Comments", + "/* extends */", + "/* = */", + "// =" +] \ No newline at end of file diff --git a/test/fixtures/ast/vue3.3-generic-6-with-default/tree.json b/test/fixtures/ast/vue3.3-generic-6-with-default/tree.json new file mode 100644 index 00000000..eea3840c --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-6-with-default/tree.json @@ -0,0 +1,39 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/ast/vue3.3-generic-7-with-arrow/ast.json b/test/fixtures/ast/vue3.3-generic-7-with-arrow/ast.json new file mode 100644 index 00000000..f79be40c --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-7-with-arrow/ast.json @@ -0,0 +1,2258 @@ +{ + "type": "Program", + "range": [ + 103, + 141 + ], + "body": [ + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "definite": false, + "id": { + "type": "Identifier", + "decorators": [], + "name": "p", + "optional": false, + "range": [ + 109, + 110 + ], + "loc": { + "end": { + "line": 5, + "column": 7 + }, + "start": { + "line": 5, + "column": 6 + } + } + }, + "init": { + "type": "CallExpression", + "arguments": [], + "callee": { + "type": "Identifier", + "decorators": [], + "name": "defineProps", + "optional": false, + "range": [ + 113, + 124 + ], + "loc": { + "end": { + "line": 5, + "column": 21 + }, + "start": { + "line": 5, + "column": 10 + } + } + }, + "optional": false, + "typeArguments": { + "type": "TSTypeParameterInstantiation", + "range": [ + 124, + 138 + ], + "params": [ + { + "type": "TSTypeLiteral", + "members": [ + { + "type": "TSPropertySignature", + "computed": false, + "key": { + "type": "Identifier", + "decorators": [], + "name": "t", + "optional": false, + "range": [ + 126, + 127 + ], + "loc": { + "end": { + "line": 5, + "column": 24 + }, + "start": { + "line": 5, + "column": 23 + } + } + }, + "optional": false, + "readonly": false, + "static": false, + "typeAnnotation": { + "type": "TSTypeAnnotation", + "loc": { + "end": { + "line": 5, + "column": 27 + }, + "start": { + "line": 5, + "column": 24 + } + }, + "range": [ + 127, + 130 + ], + "typeAnnotation": { + "type": "TSTypeReference", + "typeName": { + "type": "Identifier", + "decorators": [], + "name": "T", + "optional": false, + "range": [ + 129, + 130 + ], + "loc": { + "end": { + "line": 5, + "column": 27 + }, + "start": { + "line": 5, + "column": 26 + } + } + }, + "range": [ + 129, + 130 + ], + "loc": { + "end": { + "line": 5, + "column": 27 + }, + "start": { + "line": 5, + "column": 26 + } + } + } + }, + "range": [ + 126, + 131 + ], + "loc": { + "end": { + "line": 5, + "column": 28 + }, + "start": { + "line": 5, + "column": 23 + } + } + }, + { + "type": "TSPropertySignature", + "computed": false, + "key": { + "type": "Identifier", + "decorators": [], + "name": "u", + "optional": false, + "range": [ + 132, + 133 + ], + "loc": { + "end": { + "line": 5, + "column": 30 + }, + "start": { + "line": 5, + "column": 29 + } + } + }, + "optional": false, + "readonly": false, + "static": false, + "typeAnnotation": { + "type": "TSTypeAnnotation", + "loc": { + "end": { + "line": 5, + "column": 33 + }, + "start": { + "line": 5, + "column": 30 + } + }, + "range": [ + 133, + 136 + ], + "typeAnnotation": { + "type": "TSTypeReference", + "typeName": { + "type": "Identifier", + "decorators": [], + "name": "U", + "optional": false, + "range": [ + 135, + 136 + ], + "loc": { + "end": { + "line": 5, + "column": 33 + }, + "start": { + "line": 5, + "column": 32 + } + } + }, + "range": [ + 135, + 136 + ], + "loc": { + "end": { + "line": 5, + "column": 33 + }, + "start": { + "line": 5, + "column": 32 + } + } + } + }, + "range": [ + 132, + 136 + ], + "loc": { + "end": { + "line": 5, + "column": 33 + }, + "start": { + "line": 5, + "column": 29 + } + } + } + ], + "range": [ + 125, + 137 + ], + "loc": { + "end": { + "line": 5, + "column": 34 + }, + "start": { + "line": 5, + "column": 22 + } + } + } + ], + "loc": { + "end": { + "line": 5, + "column": 35 + }, + "start": { + "line": 5, + "column": 21 + } + } + }, + "range": [ + 113, + 140 + ], + "loc": { + "end": { + "line": 5, + "column": 37 + }, + "start": { + "line": 5, + "column": 10 + } + } + }, + "range": [ + 109, + 140 + ], + "loc": { + "end": { + "line": 5, + "column": 37 + }, + "start": { + "line": 5, + "column": 6 + } + } + } + ], + "declare": false, + "kind": "const", + "range": [ + 103, + 140 + ], + "loc": { + "end": { + "line": 5, + "column": 37 + }, + "start": { + "line": 5, + "column": 0 + } + } + } + ], + "comments": [], + "sourceType": "module", + "tokens": [ + { + "type": "Punctuator", + "range": [ + 0, + 102 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 2 + } + }, + "value": "" + } + ], + "loc": { + "end": { + "line": 6, + "column": 0 + }, + "start": { + "line": 5, + "column": 0 + } + }, + "templateBody": { + "type": "VElement", + "range": [ + 152, + 194 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 11, + "column": 11 + } + }, + "name": "template", + "rawName": "template", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 152, + 162 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 10 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 162, + 163 + ], + "loc": { + "start": { + "line": 8, + "column": 10 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionContainer", + "range": [ + 163, + 172 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 9 + } + }, + "expression": { + "type": "CallExpression", + "arguments": [], + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "decorators": [], + "name": "p", + "optional": false, + "range": [ + 165, + 166 + ], + "loc": { + "end": { + "line": 9, + "column": 3 + }, + "start": { + "line": 9, + "column": 2 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "decorators": [], + "name": "t", + "optional": false, + "range": [ + 167, + 168 + ], + "loc": { + "end": { + "line": 9, + "column": 5 + }, + "start": { + "line": 9, + "column": 4 + } + } + }, + "range": [ + 165, + 168 + ], + "loc": { + "end": { + "line": 9, + "column": 5 + }, + "start": { + "line": 9, + "column": 2 + } + } + }, + "optional": false, + "range": [ + 165, + 170 + ], + "loc": { + "end": { + "line": 9, + "column": 7 + }, + "start": { + "line": 9, + "column": 2 + } + } + }, + "references": [ + { + "id": { + "type": "Identifier", + "decorators": [], + "name": "p", + "optional": false, + "range": [ + 165, + 166 + ], + "loc": { + "end": { + "line": 9, + "column": 3 + }, + "start": { + "line": 9, + "column": 2 + } + } + }, + "mode": "r", + "isValueReference": true, + "isTypeReference": false + } + ] + }, + { + "type": "VText", + "range": [ + 172, + 173 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 10, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionContainer", + "range": [ + 173, + 182 + ], + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 9 + } + }, + "expression": { + "type": "CallExpression", + "arguments": [], + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "decorators": [], + "name": "p", + "optional": false, + "range": [ + 175, + 176 + ], + "loc": { + "end": { + "line": 10, + "column": 3 + }, + "start": { + "line": 10, + "column": 2 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "decorators": [], + "name": "u", + "optional": false, + "range": [ + 177, + 178 + ], + "loc": { + "end": { + "line": 10, + "column": 5 + }, + "start": { + "line": 10, + "column": 4 + } + } + }, + "range": [ + 175, + 178 + ], + "loc": { + "end": { + "line": 10, + "column": 5 + }, + "start": { + "line": 10, + "column": 2 + } + } + }, + "optional": false, + "range": [ + 175, + 180 + ], + "loc": { + "end": { + "line": 10, + "column": 7 + }, + "start": { + "line": 10, + "column": 2 + } + } + }, + "references": [ + { + "id": { + "type": "Identifier", + "decorators": [], + "name": "p", + "optional": false, + "range": [ + 175, + 176 + ], + "loc": { + "end": { + "line": 10, + "column": 3 + }, + "start": { + "line": 10, + "column": 2 + } + } + }, + "mode": "r", + "isValueReference": true, + "isTypeReference": false + } + ] + }, + { + "type": "VText", + "range": [ + 182, + 183 + ], + "loc": { + "start": { + "line": 10, + "column": 9 + }, + "end": { + "line": 11, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 183, + 194 + ], + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 11 + } + } + }, + "variables": [], + "tokens": [ + { + "type": "HTMLTagOpen", + "range": [ + 0, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLIdentifier", + "range": [ + 8, + 13 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": "setup" + }, + { + "type": "HTMLIdentifier", + "range": [ + 14, + 18 + ], + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "value": "lang" + }, + { + "type": "HTMLAssociation", + "range": [ + 18, + 19 + ], + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "value": "" + }, + { + "type": "HTMLLiteral", + "range": [ + 19, + 23 + ], + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "value": "ts" + }, + { + "type": "HTMLIdentifier", + "range": [ + 24, + 31 + ], + "loc": { + "start": { + "column": 24, + "line": 1 + }, + "end": { + "column": 31, + "line": 1 + } + }, + "value": "generic" + }, + { + "type": "HTMLAssociation", + "range": [ + 31, + 32 + ], + "loc": { + "start": { + "line": 1, + "column": 31 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 32, + 33 + ], + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 2, + "column": 3 + }, + "start": { + "line": 2, + "column": 2 + } + }, + "range": [ + 36, + 37 + ], + "value": "T" + }, + { + "type": "Keyword", + "loc": { + "end": { + "line": 2, + "column": 11 + }, + "start": { + "line": 2, + "column": 4 + } + }, + "range": [ + 38, + 45 + ], + "value": "extends" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 2, + "column": 13 + }, + "start": { + "line": 2, + "column": 12 + } + }, + "range": [ + 46, + 47 + ], + "value": "(" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 2, + "column": 14 + }, + "start": { + "line": 2, + "column": 13 + } + }, + "range": [ + 47, + 48 + ], + "value": ")" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 2, + "column": 17 + }, + "start": { + "line": 2, + "column": 15 + } + }, + "range": [ + 49, + 51 + ], + "value": "=>" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 2, + "column": 24 + }, + "start": { + "line": 2, + "column": 18 + } + }, + "range": [ + 52, + 58 + ], + "value": "string" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 2, + "column": 25 + }, + "start": { + "line": 2, + "column": 24 + } + }, + "range": [ + 58, + 59 + ], + "value": "," + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 3, + "column": 3 + }, + "start": { + "line": 3, + "column": 2 + } + }, + "range": [ + 62, + 63 + ], + "value": "U" + }, + { + "type": "Keyword", + "loc": { + "end": { + "line": 3, + "column": 12 + }, + "start": { + "line": 3, + "column": 5 + } + }, + "range": [ + 65, + 72 + ], + "value": "extends" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 14 + }, + "start": { + "line": 3, + "column": 13 + } + }, + "range": [ + 73, + 74 + ], + "value": "(" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 15 + }, + "start": { + "line": 3, + "column": 14 + } + }, + "range": [ + 74, + 75 + ], + "value": ")" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 18 + }, + "start": { + "line": 3, + "column": 16 + } + }, + "range": [ + 76, + 78 + ], + "value": "=>" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 3, + "column": 25 + }, + "start": { + "line": 3, + "column": 19 + } + }, + "range": [ + 79, + 85 + ], + "value": "string" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 27 + }, + "start": { + "line": 3, + "column": 26 + } + }, + "range": [ + 86, + 87 + ], + "value": "=" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 29 + }, + "start": { + "line": 3, + "column": 28 + } + }, + "range": [ + 88, + 89 + ], + "value": "(" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 30 + }, + "start": { + "line": 3, + "column": 29 + } + }, + "range": [ + 89, + 90 + ], + "value": ")" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 33 + }, + "start": { + "line": 3, + "column": 31 + } + }, + "range": [ + 91, + 93 + ], + "value": "=>" + }, + { + "type": "String", + "loc": { + "end": { + "line": 3, + "column": 39 + }, + "start": { + "line": 3, + "column": 34 + } + }, + "range": [ + 94, + 99 + ], + "value": "'abc'" + }, + { + "type": "Punctuator", + "range": [ + 100, + 101 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 101, + 102 + ], + "loc": { + "start": { + "line": 4, + "column": 1 + }, + "end": { + "line": 4, + "column": 2 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 102, + 103 + ], + "loc": { + "start": { + "line": 4, + "column": 2 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 103, + 108 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 108, + 109 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 109, + 110 + ], + "loc": { + "start": { + "line": 5, + "column": 6 + }, + "end": { + "line": 5, + "column": 7 + } + }, + "value": "p" + }, + { + "type": "HTMLWhitespace", + "range": [ + 110, + 111 + ], + "loc": { + "start": { + "line": 5, + "column": 7 + }, + "end": { + "line": 5, + "column": 8 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 111, + 112 + ], + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 9 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 112, + 113 + ], + "loc": { + "start": { + "line": 5, + "column": 9 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 113, + 128 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 25 + } + }, + "value": "defineProps<{t:" + }, + { + "type": "HTMLWhitespace", + "range": [ + 128, + 129 + ], + "loc": { + "start": { + "line": 5, + "column": 25 + }, + "end": { + "line": 5, + "column": 26 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 129, + 131 + ], + "loc": { + "start": { + "line": 5, + "column": 26 + }, + "end": { + "line": 5, + "column": 28 + } + }, + "value": "T," + }, + { + "type": "HTMLWhitespace", + "range": [ + 131, + 132 + ], + "loc": { + "start": { + "line": 5, + "column": 28 + }, + "end": { + "line": 5, + "column": 29 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 132, + 134 + ], + "loc": { + "start": { + "line": 5, + "column": 29 + }, + "end": { + "line": 5, + "column": 31 + } + }, + "value": "u:" + }, + { + "type": "HTMLWhitespace", + "range": [ + 134, + 135 + ], + "loc": { + "start": { + "line": 5, + "column": 31 + }, + "end": { + "line": 5, + "column": 32 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 135, + 140 + ], + "loc": { + "start": { + "line": 5, + "column": 32 + }, + "end": { + "line": 5, + "column": 37 + } + }, + "value": "U}>()" + }, + { + "type": "HTMLWhitespace", + "range": [ + 140, + 141 + ], + "loc": { + "start": { + "line": 5, + "column": 37 + }, + "end": { + "line": 6, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 141, + 149 + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 149, + 150 + ], + "loc": { + "start": { + "line": 6, + "column": 8 + }, + "end": { + "line": 6, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 150, + 152 + ], + "loc": { + "start": { + "line": 6, + "column": 9 + }, + "end": { + "line": 8, + "column": 0 + } + }, + "value": "\n\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 152, + 161 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 161, + 162 + ], + "loc": { + "start": { + "line": 8, + "column": 9 + }, + "end": { + "line": 8, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 162, + 163 + ], + "loc": { + "start": { + "line": 8, + "column": 10 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionStart", + "range": [ + 163, + 165 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 2 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 9, + "column": 3 + }, + "start": { + "line": 9, + "column": 2 + } + }, + "range": [ + 165, + 166 + ], + "value": "p" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 9, + "column": 4 + }, + "start": { + "line": 9, + "column": 3 + } + }, + "range": [ + 166, + 167 + ], + "value": "." + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 9, + "column": 5 + }, + "start": { + "line": 9, + "column": 4 + } + }, + "range": [ + 167, + 168 + ], + "value": "t" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 9, + "column": 6 + }, + "start": { + "line": 9, + "column": 5 + } + }, + "range": [ + 168, + 169 + ], + "value": "(" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 9, + "column": 7 + }, + "start": { + "line": 9, + "column": 6 + } + }, + "range": [ + 169, + 170 + ], + "value": ")" + }, + { + "type": "VExpressionEnd", + "range": [ + 170, + 172 + ], + "loc": { + "start": { + "line": 9, + "column": 7 + }, + "end": { + "line": 9, + "column": 9 + } + }, + "value": "}}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 172, + 173 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 10, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionStart", + "range": [ + 173, + 175 + ], + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 2 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 10, + "column": 3 + }, + "start": { + "line": 10, + "column": 2 + } + }, + "range": [ + 175, + 176 + ], + "value": "p" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 10, + "column": 4 + }, + "start": { + "line": 10, + "column": 3 + } + }, + "range": [ + 176, + 177 + ], + "value": "." + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 10, + "column": 5 + }, + "start": { + "line": 10, + "column": 4 + } + }, + "range": [ + 177, + 178 + ], + "value": "u" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 10, + "column": 6 + }, + "start": { + "line": 10, + "column": 5 + } + }, + "range": [ + 178, + 179 + ], + "value": "(" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 10, + "column": 7 + }, + "start": { + "line": 10, + "column": 6 + } + }, + "range": [ + 179, + 180 + ], + "value": ")" + }, + { + "type": "VExpressionEnd", + "range": [ + 180, + 182 + ], + "loc": { + "start": { + "line": 10, + "column": 7 + }, + "end": { + "line": 10, + "column": 9 + } + }, + "value": "}}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 182, + 183 + ], + "loc": { + "start": { + "line": 10, + "column": 9 + }, + "end": { + "line": 11, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 183, + 193 + ], + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 193, + 194 + ], + "loc": { + "start": { + "line": 11, + "column": 10 + }, + "end": { + "line": 11, + "column": 11 + } + }, + "value": "" + } + ], + "comments": [], + "errors": [] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/vue3.3-generic-7-with-arrow/parser-options.json b/test/fixtures/ast/vue3.3-generic-7-with-arrow/parser-options.json new file mode 100644 index 00000000..0ead30e9 --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-7-with-arrow/parser-options.json @@ -0,0 +1,6 @@ +{ + "sourceType": "module", + "parser": { + "ts": "@typescript-eslint/parser" + } +} diff --git a/test/fixtures/ast/vue3.3-generic-7-with-arrow/source.vue b/test/fixtures/ast/vue3.3-generic-7-with-arrow/source.vue new file mode 100644 index 00000000..d1a84af7 --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-7-with-arrow/source.vue @@ -0,0 +1,11 @@ + + + \ No newline at end of file diff --git a/test/fixtures/ast/vue3.3-generic-7-with-arrow/token-ranges.json b/test/fixtures/ast/vue3.3-generic-7-with-arrow/token-ranges.json new file mode 100644 index 00000000..6ae5ff6d --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-7-with-arrow/token-ranges.json @@ -0,0 +1,88 @@ +[ + "", + "", + "string", + ",", + "U", + "extends", + "(", + ")", + "=>", + "string", + "=", + "(", + ")", + "=>", + "'abc'", + "\"", + ">", + "\n", + "const", + " ", + "p", + " ", + "=", + " ", + "defineProps<{t:", + " ", + "T,", + " ", + "u:", + " ", + "U}>()", + "\n", + "", + "\n\n", + "", + "\n", + "{{", + "p", + ".", + "t", + "(", + ")", + "}}", + "\n", + "{{", + "p", + ".", + "u", + "(", + ")", + "}}", + "\n", + "" +] \ No newline at end of file diff --git a/test/fixtures/ast/vue3.3-generic-7-with-arrow/tree.json b/test/fixtures/ast/vue3.3-generic-7-with-arrow/tree.json new file mode 100644 index 00000000..bd27ee7b --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-7-with-arrow/tree.json @@ -0,0 +1,89 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/document-fragment/style-variables-edge-cases/document-fragment.json b/test/fixtures/document-fragment/style-variables-edge-cases/document-fragment.json index 9d703376..8616cb4e 100644 --- a/test/fixtures/document-fragment/style-variables-edge-cases/document-fragment.json +++ b/test/fixtures/document-fragment/style-variables-edge-cases/document-fragment.json @@ -226,7 +226,8 @@ ], "name": "size" }, - "computed": false + "computed": false, + "optional": false }, "references": [ { @@ -348,7 +349,8 @@ "value": "color", "raw": "'color'" } - ] + ], + "optional": false }, "references": [ { @@ -468,7 +470,8 @@ ], "name": "color" }, - "computed": false + "computed": false, + "optional": false }, "references": [ { diff --git a/test/fixtures/document-fragment/style-variables-ignores02/document-fragment.json b/test/fixtures/document-fragment/style-variables-ignores02/document-fragment.json index 187cd4d5..06625d92 100644 --- a/test/fixtures/document-fragment/style-variables-ignores02/document-fragment.json +++ b/test/fixtures/document-fragment/style-variables-ignores02/document-fragment.json @@ -283,7 +283,8 @@ "value": 42, "raw": "42" }, - "computed": true + "computed": true, + "optional": false }, "references": [ { @@ -383,7 +384,8 @@ ], "name": "getColor" }, - "arguments": [] + "arguments": [], + "optional": false }, "references": [ { diff --git a/test/fixtures/document-fragment/style-variables01/document-fragment.json b/test/fixtures/document-fragment/style-variables01/document-fragment.json index 1812ac76..e920516a 100644 --- a/test/fixtures/document-fragment/style-variables01/document-fragment.json +++ b/test/fixtures/document-fragment/style-variables01/document-fragment.json @@ -2361,7 +2361,8 @@ ], "name": "size" }, - "computed": false + "computed": false, + "optional": false }, "references": [ { diff --git a/test/fixtures/document-fragment/style-variables02/document-fragment.json b/test/fixtures/document-fragment/style-variables02/document-fragment.json index 167b24f4..10654bb7 100644 --- a/test/fixtures/document-fragment/style-variables02/document-fragment.json +++ b/test/fixtures/document-fragment/style-variables02/document-fragment.json @@ -244,7 +244,8 @@ ], "name": "font" }, - "computed": false + "computed": false, + "optional": false }, "property": { "type": "Identifier", @@ -266,7 +267,8 @@ ], "name": "size" }, - "computed": false + "computed": false, + "optional": false }, "references": [ { diff --git a/test/fixtures/document-fragment/style-variables05/document-fragment.json b/test/fixtures/document-fragment/style-variables05/document-fragment.json index 58b12495..6c733b31 100644 --- a/test/fixtures/document-fragment/style-variables05/document-fragment.json +++ b/test/fixtures/document-fragment/style-variables05/document-fragment.json @@ -226,7 +226,8 @@ ], "name": "size" }, - "computed": false + "computed": false, + "optional": false }, "references": [ { @@ -348,7 +349,8 @@ "value": "color", "raw": "'color'" } - ] + ], + "optional": false }, "references": [ { @@ -468,7 +470,8 @@ ], "name": "color" }, - "computed": false + "computed": false, + "optional": false }, "references": [ { diff --git a/test/fixtures/document-fragment/vue3.3-generic-1/document-fragment.json b/test/fixtures/document-fragment/vue3.3-generic-1/document-fragment.json new file mode 100644 index 00000000..13c2a968 --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-1/document-fragment.json @@ -0,0 +1,1471 @@ +{ + "type": "VDocumentFragment", + "range": [ + 0, + 100 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 6, + "column": 11 + } + }, + "children": [ + { + "type": "VElement", + "range": [ + 0, + 69 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "name": "script", + "rawName": "script", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 0, + 36 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "selfClosing": false, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 8, + 13 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "directive": false, + "key": { + "type": "VIdentifier", + "range": [ + 8, + 13 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "name": "setup", + "rawName": "setup" + }, + "value": null + }, + { + "type": "VAttribute", + "range": [ + 14, + 23 + ], + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "directive": false, + "key": { + "type": "VIdentifier", + "range": [ + 14, + 18 + ], + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "name": "lang", + "rawName": "lang" + }, + "value": { + "type": "VLiteral", + "range": [ + 19, + 23 + ], + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "value": "ts" + } + }, + { + "type": "VAttribute", + "range": [ + 24, + 35 + ], + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "directive": true, + "key": { + "type": "VDirectiveKey", + "range": [ + 24, + 31 + ], + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "name": { + "type": "VIdentifier", + "range": [ + 24, + 31 + ], + "loc": { + "start": { + "column": 24, + "line": 1 + }, + "end": { + "column": 31, + "line": 1 + } + }, + "name": "generic", + "rawName": "generic" + }, + "argument": null, + "modifiers": [] + }, + "value": { + "type": "VExpressionContainer", + "range": [ + 32, + 35 + ], + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "expression": { + "type": "VGenericExpression", + "range": [ + 33, + 34 + ], + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "params": [ + { + "type": "TSTypeParameter", + "const": false, + "in": false, + "name": { + "type": "Identifier", + "decorators": [], + "name": "T", + "optional": false, + "range": [ + 33, + 34 + ], + "loc": { + "end": { + "line": 1, + "column": 34 + }, + "start": { + "line": 1, + "column": 33 + } + } + }, + "out": false, + "range": [ + 33, + 34 + ], + "loc": { + "end": { + "line": 1, + "column": 34 + }, + "start": { + "line": 1, + "column": 33 + } + } + } + ], + "rawParams": [ + "T" + ] + }, + "references": [] + } + } + ] + }, + "children": [ + { + "type": "VText", + "range": [ + 36, + 60 + ], + "loc": { + "start": { + "line": 1, + "column": 36 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\ndefineProps<{foo:T}>()\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 60, + 69 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 9 + } + } + }, + "variables": [ + { + "id": { + "type": "Identifier", + "decorators": [], + "name": "T", + "optional": false, + "range": [ + 33, + 34 + ], + "loc": { + "end": { + "line": 1, + "column": 34 + }, + "start": { + "line": 1, + "column": 33 + } + } + }, + "kind": "generic" + } + ] + }, + { + "type": "VText", + "range": [ + 69, + 70 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VElement", + "range": [ + 70, + 100 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 6, + "column": 11 + } + }, + "name": "template", + "rawName": "template", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 70, + 80 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 10 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 80, + 81 + ], + "loc": { + "start": { + "line": 4, + "column": 10 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionContainer", + "range": [ + 81, + 88 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 7 + } + }, + "expression": { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 83, + 86 + ], + "loc": { + "end": { + "line": 5, + "column": 5 + }, + "start": { + "line": 5, + "column": 2 + } + } + }, + "references": [ + { + "id": { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 83, + 86 + ], + "loc": { + "end": { + "line": 5, + "column": 5 + }, + "start": { + "line": 5, + "column": 2 + } + } + }, + "mode": "r", + "isValueReference": true, + "isTypeReference": false + } + ] + }, + { + "type": "VText", + "range": [ + 88, + 89 + ], + "loc": { + "start": { + "line": 5, + "column": 7 + }, + "end": { + "line": 6, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 89, + 100 + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 11 + } + } + }, + "variables": [], + "tokens": [ + { + "type": "HTMLTagOpen", + "range": [ + 0, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLIdentifier", + "range": [ + 8, + 13 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": "setup" + }, + { + "type": "HTMLIdentifier", + "range": [ + 14, + 18 + ], + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "value": "lang" + }, + { + "type": "HTMLAssociation", + "range": [ + 18, + 19 + ], + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "value": "" + }, + { + "type": "HTMLLiteral", + "range": [ + 19, + 23 + ], + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "value": "ts" + }, + { + "type": "HTMLIdentifier", + "range": [ + 24, + 31 + ], + "loc": { + "start": { + "column": 24, + "line": 1 + }, + "end": { + "column": 31, + "line": 1 + } + }, + "value": "generic" + }, + { + "type": "HTMLAssociation", + "range": [ + 31, + 32 + ], + "loc": { + "start": { + "line": 1, + "column": 31 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 32, + 33 + ], + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 1, + "column": 34 + }, + "start": { + "line": 1, + "column": 33 + } + }, + "range": [ + 33, + 34 + ], + "value": "T" + }, + { + "type": "Punctuator", + "range": [ + 34, + 35 + ], + "loc": { + "start": { + "line": 1, + "column": 34 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 35, + 36 + ], + "loc": { + "start": { + "line": 1, + "column": 35 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 36, + 37 + ], + "loc": { + "start": { + "line": 1, + "column": 36 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 37, + 59 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "value": "defineProps<{foo:T}>()" + }, + { + "type": "HTMLWhitespace", + "range": [ + 59, + 60 + ], + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 60, + 68 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 68, + 69 + ], + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 69, + 70 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 70, + 79 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 79, + 80 + ], + "loc": { + "start": { + "line": 4, + "column": 9 + }, + "end": { + "line": 4, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 80, + 81 + ], + "loc": { + "start": { + "line": 4, + "column": 10 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionStart", + "range": [ + 81, + 83 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 2 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 5, + "column": 5 + }, + "start": { + "line": 5, + "column": 2 + } + }, + "range": [ + 83, + 86 + ], + "value": "foo" + }, + { + "type": "VExpressionEnd", + "range": [ + 86, + 88 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 7 + } + }, + "value": "}}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 88, + 89 + ], + "loc": { + "start": { + "line": 5, + "column": 7 + }, + "end": { + "line": 6, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 89, + 99 + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 99, + 100 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 11 + } + }, + "value": "" + } + ], + "comments": [], + "errors": [] + } + ], + "tokens": [ + { + "type": "HTMLTagOpen", + "range": [ + 0, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLIdentifier", + "range": [ + 8, + 13 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": "setup" + }, + { + "type": "HTMLIdentifier", + "range": [ + 14, + 18 + ], + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "value": "lang" + }, + { + "type": "HTMLAssociation", + "range": [ + 18, + 19 + ], + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "value": "" + }, + { + "type": "HTMLLiteral", + "range": [ + 19, + 23 + ], + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "value": "ts" + }, + { + "type": "HTMLIdentifier", + "range": [ + 24, + 31 + ], + "loc": { + "start": { + "column": 24, + "line": 1 + }, + "end": { + "column": 31, + "line": 1 + } + }, + "value": "generic" + }, + { + "type": "HTMLAssociation", + "range": [ + 31, + 32 + ], + "loc": { + "start": { + "line": 1, + "column": 31 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 32, + 33 + ], + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 1, + "column": 34 + }, + "start": { + "line": 1, + "column": 33 + } + }, + "range": [ + 33, + 34 + ], + "value": "T" + }, + { + "type": "Punctuator", + "range": [ + 34, + 35 + ], + "loc": { + "start": { + "line": 1, + "column": 34 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 35, + 36 + ], + "loc": { + "start": { + "line": 1, + "column": 35 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 36, + 37 + ], + "loc": { + "start": { + "line": 1, + "column": 36 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 37, + 59 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "value": "defineProps<{foo:T}>()" + }, + { + "type": "HTMLWhitespace", + "range": [ + 59, + 60 + ], + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 60, + 68 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 68, + 69 + ], + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 69, + 70 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 70, + 79 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 79, + 80 + ], + "loc": { + "start": { + "line": 4, + "column": 9 + }, + "end": { + "line": 4, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 80, + 81 + ], + "loc": { + "start": { + "line": 4, + "column": 10 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionStart", + "range": [ + 81, + 83 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 2 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 5, + "column": 5 + }, + "start": { + "line": 5, + "column": 2 + } + }, + "range": [ + 83, + 86 + ], + "value": "foo" + }, + { + "type": "VExpressionEnd", + "range": [ + 86, + 88 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 7 + } + }, + "value": "}}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 88, + 89 + ], + "loc": { + "start": { + "line": 5, + "column": 7 + }, + "end": { + "line": 6, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 89, + 99 + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 99, + 100 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 11 + } + }, + "value": "" + } + ], + "comments": [], + "errors": [] +} \ No newline at end of file diff --git a/test/fixtures/document-fragment/vue3.3-generic-1/parser-options.json b/test/fixtures/document-fragment/vue3.3-generic-1/parser-options.json new file mode 100644 index 00000000..0ead30e9 --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-1/parser-options.json @@ -0,0 +1,6 @@ +{ + "sourceType": "module", + "parser": { + "ts": "@typescript-eslint/parser" + } +} diff --git a/test/fixtures/document-fragment/vue3.3-generic-1/source.vue b/test/fixtures/document-fragment/vue3.3-generic-1/source.vue new file mode 100644 index 00000000..fc54be37 --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-1/source.vue @@ -0,0 +1,6 @@ + + \ No newline at end of file diff --git a/test/fixtures/document-fragment/vue3.3-generic-1/token-ranges.json b/test/fixtures/document-fragment/vue3.3-generic-1/token-ranges.json new file mode 100644 index 00000000..80b1a7d7 --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-1/token-ranges.json @@ -0,0 +1,28 @@ +[ + "", + "\n", + "defineProps<{foo:T}>()", + "\n", + "", + "\n", + "", + "\n", + "{{", + "foo", + "}}", + "\n", + "" +] \ No newline at end of file diff --git a/test/fixtures/document-fragment/vue3.3-generic-1/tree.json b/test/fixtures/document-fragment/vue3.3-generic-1/tree.json new file mode 100644 index 00000000..0c0a767a --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-1/tree.json @@ -0,0 +1,139 @@ +[ + { + "type": "VDocumentFragment", + "text": "\n", + "children": [ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + }, + { + "type": "VText", + "text": "\n", + "children": [] + }, + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/document-fragment/vue3.3-generic-2/document-fragment.json b/test/fixtures/document-fragment/vue3.3-generic-2/document-fragment.json new file mode 100644 index 00000000..370d495c --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-2/document-fragment.json @@ -0,0 +1,2925 @@ +{ + "type": "VDocumentFragment", + "range": [ + 0, + 203 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 11, + "column": 11 + } + }, + "children": [ + { + "type": "VElement", + "range": [ + 0, + 45 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "name": "script", + "rawName": "script", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 0, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 8, + 36 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\ntype Foo = number | string\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 36, + 45 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 9 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 45, + 46 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VElement", + "range": [ + 46, + 172 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 8, + "column": 9 + } + }, + "name": "script", + "rawName": "script", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 46, + 94 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 48 + } + }, + "selfClosing": false, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 54, + 59 + ], + "loc": { + "start": { + "line": 4, + "column": 8 + }, + "end": { + "line": 4, + "column": 13 + } + }, + "directive": false, + "key": { + "type": "VIdentifier", + "range": [ + 54, + 59 + ], + "loc": { + "start": { + "line": 4, + "column": 8 + }, + "end": { + "line": 4, + "column": 13 + } + }, + "name": "setup", + "rawName": "setup" + }, + "value": null + }, + { + "type": "VAttribute", + "range": [ + 60, + 69 + ], + "loc": { + "start": { + "line": 4, + "column": 14 + }, + "end": { + "line": 4, + "column": 23 + } + }, + "directive": false, + "key": { + "type": "VIdentifier", + "range": [ + 60, + 64 + ], + "loc": { + "start": { + "line": 4, + "column": 14 + }, + "end": { + "line": 4, + "column": 18 + } + }, + "name": "lang", + "rawName": "lang" + }, + "value": { + "type": "VLiteral", + "range": [ + 65, + 69 + ], + "loc": { + "start": { + "line": 4, + "column": 19 + }, + "end": { + "line": 4, + "column": 23 + } + }, + "value": "ts" + } + }, + { + "type": "VAttribute", + "range": [ + 70, + 93 + ], + "loc": { + "start": { + "line": 4, + "column": 24 + }, + "end": { + "line": 4, + "column": 47 + } + }, + "directive": true, + "key": { + "type": "VDirectiveKey", + "range": [ + 70, + 77 + ], + "loc": { + "start": { + "line": 4, + "column": 24 + }, + "end": { + "line": 4, + "column": 31 + } + }, + "name": { + "type": "VIdentifier", + "range": [ + 70, + 77 + ], + "loc": { + "start": { + "column": 24, + "line": 4 + }, + "end": { + "column": 31, + "line": 4 + } + }, + "name": "generic", + "rawName": "generic" + }, + "argument": null, + "modifiers": [] + }, + "value": { + "type": "VExpressionContainer", + "range": [ + 78, + 93 + ], + "loc": { + "start": { + "line": 4, + "column": 32 + }, + "end": { + "line": 4, + "column": 47 + } + }, + "expression": { + "type": "VGenericExpression", + "range": [ + 79, + 92 + ], + "loc": { + "start": { + "line": 4, + "column": 33 + }, + "end": { + "line": 4, + "column": 46 + } + }, + "params": [ + { + "type": "TSTypeParameter", + "const": false, + "constraint": { + "type": "TSTypeReference", + "typeName": { + "type": "Identifier", + "decorators": [], + "name": "Foo", + "optional": false, + "range": [ + 89, + 92 + ], + "loc": { + "end": { + "line": 4, + "column": 46 + }, + "start": { + "line": 4, + "column": 43 + } + } + }, + "range": [ + 89, + 92 + ], + "loc": { + "end": { + "line": 4, + "column": 46 + }, + "start": { + "line": 4, + "column": 43 + } + } + }, + "in": false, + "name": { + "type": "Identifier", + "decorators": [], + "name": "T", + "optional": false, + "range": [ + 79, + 80 + ], + "loc": { + "end": { + "line": 4, + "column": 34 + }, + "start": { + "line": 4, + "column": 33 + } + } + }, + "out": false, + "range": [ + 79, + 92 + ], + "loc": { + "end": { + "line": 4, + "column": 46 + }, + "start": { + "line": 4, + "column": 33 + } + } + } + ], + "rawParams": [ + "T extends Foo" + ] + }, + "references": [ + { + "id": { + "type": "Identifier", + "decorators": [], + "name": "Foo", + "optional": false, + "range": [ + 89, + 92 + ], + "loc": { + "end": { + "line": 4, + "column": 46 + }, + "start": { + "line": 4, + "column": 43 + } + } + }, + "mode": "r", + "isValueReference": false, + "isTypeReference": true + } + ] + } + } + ] + }, + "children": [ + { + "type": "VText", + "range": [ + 94, + 163 + ], + "loc": { + "start": { + "line": 4, + "column": 48 + }, + "end": { + "line": 8, + "column": 0 + } + }, + "value": "\nconst p = defineProps<{foo:T}>()\nconst foo = p.foo\nconsole.log(foo)\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 163, + 172 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 9 + } + } + }, + "variables": [ + { + "id": { + "type": "Identifier", + "decorators": [], + "name": "T", + "optional": false, + "range": [ + 79, + 80 + ], + "loc": { + "end": { + "line": 4, + "column": 34 + }, + "start": { + "line": 4, + "column": 33 + } + } + }, + "kind": "generic" + } + ] + }, + { + "type": "VText", + "range": [ + 172, + 173 + ], + "loc": { + "start": { + "line": 8, + "column": 9 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VElement", + "range": [ + 173, + 203 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 11, + "column": 11 + } + }, + "name": "template", + "rawName": "template", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 173, + 183 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 10 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 183, + 184 + ], + "loc": { + "start": { + "line": 9, + "column": 10 + }, + "end": { + "line": 10, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionContainer", + "range": [ + 184, + 191 + ], + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 7 + } + }, + "expression": { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 186, + 189 + ], + "loc": { + "end": { + "line": 10, + "column": 5 + }, + "start": { + "line": 10, + "column": 2 + } + } + }, + "references": [ + { + "id": { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 186, + 189 + ], + "loc": { + "end": { + "line": 10, + "column": 5 + }, + "start": { + "line": 10, + "column": 2 + } + } + }, + "mode": "r", + "isValueReference": true, + "isTypeReference": false + } + ] + }, + { + "type": "VText", + "range": [ + 191, + 192 + ], + "loc": { + "start": { + "line": 10, + "column": 7 + }, + "end": { + "line": 11, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 192, + 203 + ], + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "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, + 13 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 4 + } + }, + "value": "type" + }, + { + "type": "HTMLWhitespace", + "range": [ + 13, + 14 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 5 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 14, + 17 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "value": "Foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 17, + 18 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 18, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 19, + 20 + ], + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 20, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "value": "number" + }, + { + "type": "HTMLWhitespace", + "range": [ + 26, + 27 + ], + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 27, + 28 + ], + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "value": "|" + }, + { + "type": "HTMLWhitespace", + "range": [ + 28, + 29 + ], + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 29, + 35 + ], + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 26 + } + }, + "value": "string" + }, + { + "type": "HTMLWhitespace", + "range": [ + 35, + 36 + ], + "loc": { + "start": { + "line": 2, + "column": 26 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 36, + 44 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 44, + 45 + ], + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 45, + 46 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 46, + 53 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLIdentifier", + "range": [ + 54, + 59 + ], + "loc": { + "start": { + "line": 4, + "column": 8 + }, + "end": { + "line": 4, + "column": 13 + } + }, + "value": "setup" + }, + { + "type": "HTMLIdentifier", + "range": [ + 60, + 64 + ], + "loc": { + "start": { + "line": 4, + "column": 14 + }, + "end": { + "line": 4, + "column": 18 + } + }, + "value": "lang" + }, + { + "type": "HTMLAssociation", + "range": [ + 64, + 65 + ], + "loc": { + "start": { + "line": 4, + "column": 18 + }, + "end": { + "line": 4, + "column": 19 + } + }, + "value": "" + }, + { + "type": "HTMLLiteral", + "range": [ + 65, + 69 + ], + "loc": { + "start": { + "line": 4, + "column": 19 + }, + "end": { + "line": 4, + "column": 23 + } + }, + "value": "ts" + }, + { + "type": "HTMLIdentifier", + "range": [ + 70, + 77 + ], + "loc": { + "start": { + "column": 24, + "line": 4 + }, + "end": { + "column": 31, + "line": 4 + } + }, + "value": "generic" + }, + { + "type": "HTMLAssociation", + "range": [ + 77, + 78 + ], + "loc": { + "start": { + "line": 4, + "column": 31 + }, + "end": { + "line": 4, + "column": 32 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 78, + 79 + ], + "loc": { + "start": { + "line": 4, + "column": 32 + }, + "end": { + "line": 4, + "column": 33 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 4, + "column": 34 + }, + "start": { + "line": 4, + "column": 33 + } + }, + "range": [ + 79, + 80 + ], + "value": "T" + }, + { + "type": "Keyword", + "loc": { + "end": { + "line": 4, + "column": 42 + }, + "start": { + "line": 4, + "column": 35 + } + }, + "range": [ + 81, + 88 + ], + "value": "extends" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 4, + "column": 46 + }, + "start": { + "line": 4, + "column": 43 + } + }, + "range": [ + 89, + 92 + ], + "value": "Foo" + }, + { + "type": "Punctuator", + "range": [ + 92, + 93 + ], + "loc": { + "start": { + "line": 4, + "column": 46 + }, + "end": { + "line": 4, + "column": 47 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 93, + 94 + ], + "loc": { + "start": { + "line": 4, + "column": 47 + }, + "end": { + "line": 4, + "column": 48 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 94, + 95 + ], + "loc": { + "start": { + "line": 4, + "column": 48 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 95, + 100 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 100, + 101 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 101, + 102 + ], + "loc": { + "start": { + "line": 5, + "column": 6 + }, + "end": { + "line": 5, + "column": 7 + } + }, + "value": "p" + }, + { + "type": "HTMLWhitespace", + "range": [ + 102, + 103 + ], + "loc": { + "start": { + "line": 5, + "column": 7 + }, + "end": { + "line": 5, + "column": 8 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 103, + 104 + ], + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 9 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 104, + 105 + ], + "loc": { + "start": { + "line": 5, + "column": 9 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 105, + 127 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 32 + } + }, + "value": "defineProps<{foo:T}>()" + }, + { + "type": "HTMLWhitespace", + "range": [ + 127, + 128 + ], + "loc": { + "start": { + "line": 5, + "column": 32 + }, + "end": { + "line": 6, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 128, + 133 + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 133, + 134 + ], + "loc": { + "start": { + "line": 6, + "column": 5 + }, + "end": { + "line": 6, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 134, + 137 + ], + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 9 + } + }, + "value": "foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 137, + 138 + ], + "loc": { + "start": { + "line": 6, + "column": 9 + }, + "end": { + "line": 6, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 138, + 139 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 11 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 139, + 140 + ], + "loc": { + "start": { + "line": 6, + "column": 11 + }, + "end": { + "line": 6, + "column": 12 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 140, + 145 + ], + "loc": { + "start": { + "line": 6, + "column": 12 + }, + "end": { + "line": 6, + "column": 17 + } + }, + "value": "p.foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 145, + 146 + ], + "loc": { + "start": { + "line": 6, + "column": 17 + }, + "end": { + "line": 7, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 146, + 162 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 16 + } + }, + "value": "console.log(foo)" + }, + { + "type": "HTMLWhitespace", + "range": [ + 162, + 163 + ], + "loc": { + "start": { + "line": 7, + "column": 16 + }, + "end": { + "line": 8, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 163, + 171 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 171, + 172 + ], + "loc": { + "start": { + "line": 8, + "column": 8 + }, + "end": { + "line": 8, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 172, + 173 + ], + "loc": { + "start": { + "line": 8, + "column": 9 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 173, + 182 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 182, + 183 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 9, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 183, + 184 + ], + "loc": { + "start": { + "line": 9, + "column": 10 + }, + "end": { + "line": 10, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionStart", + "range": [ + 184, + 186 + ], + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 2 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 10, + "column": 5 + }, + "start": { + "line": 10, + "column": 2 + } + }, + "range": [ + 186, + 189 + ], + "value": "foo" + }, + { + "type": "VExpressionEnd", + "range": [ + 189, + 191 + ], + "loc": { + "start": { + "line": 10, + "column": 5 + }, + "end": { + "line": 10, + "column": 7 + } + }, + "value": "}}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 191, + 192 + ], + "loc": { + "start": { + "line": 10, + "column": 7 + }, + "end": { + "line": 11, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 192, + 202 + ], + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 202, + 203 + ], + "loc": { + "start": { + "line": 11, + "column": 10 + }, + "end": { + "line": 11, + "column": 11 + } + }, + "value": "" + } + ], + "comments": [], + "errors": [] + } + ], + "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, + 13 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 4 + } + }, + "value": "type" + }, + { + "type": "HTMLWhitespace", + "range": [ + 13, + 14 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 5 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 14, + 17 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "value": "Foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 17, + 18 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 18, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 19, + 20 + ], + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 20, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "value": "number" + }, + { + "type": "HTMLWhitespace", + "range": [ + 26, + 27 + ], + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 27, + 28 + ], + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "value": "|" + }, + { + "type": "HTMLWhitespace", + "range": [ + 28, + 29 + ], + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 29, + 35 + ], + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 26 + } + }, + "value": "string" + }, + { + "type": "HTMLWhitespace", + "range": [ + 35, + 36 + ], + "loc": { + "start": { + "line": 2, + "column": 26 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 36, + 44 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 44, + 45 + ], + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 45, + 46 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 46, + 53 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLIdentifier", + "range": [ + 54, + 59 + ], + "loc": { + "start": { + "line": 4, + "column": 8 + }, + "end": { + "line": 4, + "column": 13 + } + }, + "value": "setup" + }, + { + "type": "HTMLIdentifier", + "range": [ + 60, + 64 + ], + "loc": { + "start": { + "line": 4, + "column": 14 + }, + "end": { + "line": 4, + "column": 18 + } + }, + "value": "lang" + }, + { + "type": "HTMLAssociation", + "range": [ + 64, + 65 + ], + "loc": { + "start": { + "line": 4, + "column": 18 + }, + "end": { + "line": 4, + "column": 19 + } + }, + "value": "" + }, + { + "type": "HTMLLiteral", + "range": [ + 65, + 69 + ], + "loc": { + "start": { + "line": 4, + "column": 19 + }, + "end": { + "line": 4, + "column": 23 + } + }, + "value": "ts" + }, + { + "type": "HTMLIdentifier", + "range": [ + 70, + 77 + ], + "loc": { + "start": { + "column": 24, + "line": 4 + }, + "end": { + "column": 31, + "line": 4 + } + }, + "value": "generic" + }, + { + "type": "HTMLAssociation", + "range": [ + 77, + 78 + ], + "loc": { + "start": { + "line": 4, + "column": 31 + }, + "end": { + "line": 4, + "column": 32 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 78, + 79 + ], + "loc": { + "start": { + "line": 4, + "column": 32 + }, + "end": { + "line": 4, + "column": 33 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 4, + "column": 34 + }, + "start": { + "line": 4, + "column": 33 + } + }, + "range": [ + 79, + 80 + ], + "value": "T" + }, + { + "type": "Keyword", + "loc": { + "end": { + "line": 4, + "column": 42 + }, + "start": { + "line": 4, + "column": 35 + } + }, + "range": [ + 81, + 88 + ], + "value": "extends" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 4, + "column": 46 + }, + "start": { + "line": 4, + "column": 43 + } + }, + "range": [ + 89, + 92 + ], + "value": "Foo" + }, + { + "type": "Punctuator", + "range": [ + 92, + 93 + ], + "loc": { + "start": { + "line": 4, + "column": 46 + }, + "end": { + "line": 4, + "column": 47 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 93, + 94 + ], + "loc": { + "start": { + "line": 4, + "column": 47 + }, + "end": { + "line": 4, + "column": 48 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 94, + 95 + ], + "loc": { + "start": { + "line": 4, + "column": 48 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 95, + 100 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 100, + 101 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 101, + 102 + ], + "loc": { + "start": { + "line": 5, + "column": 6 + }, + "end": { + "line": 5, + "column": 7 + } + }, + "value": "p" + }, + { + "type": "HTMLWhitespace", + "range": [ + 102, + 103 + ], + "loc": { + "start": { + "line": 5, + "column": 7 + }, + "end": { + "line": 5, + "column": 8 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 103, + 104 + ], + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 9 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 104, + 105 + ], + "loc": { + "start": { + "line": 5, + "column": 9 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 105, + 127 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 32 + } + }, + "value": "defineProps<{foo:T}>()" + }, + { + "type": "HTMLWhitespace", + "range": [ + 127, + 128 + ], + "loc": { + "start": { + "line": 5, + "column": 32 + }, + "end": { + "line": 6, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 128, + 133 + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 133, + 134 + ], + "loc": { + "start": { + "line": 6, + "column": 5 + }, + "end": { + "line": 6, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 134, + 137 + ], + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 9 + } + }, + "value": "foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 137, + 138 + ], + "loc": { + "start": { + "line": 6, + "column": 9 + }, + "end": { + "line": 6, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 138, + 139 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 11 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 139, + 140 + ], + "loc": { + "start": { + "line": 6, + "column": 11 + }, + "end": { + "line": 6, + "column": 12 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 140, + 145 + ], + "loc": { + "start": { + "line": 6, + "column": 12 + }, + "end": { + "line": 6, + "column": 17 + } + }, + "value": "p.foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 145, + 146 + ], + "loc": { + "start": { + "line": 6, + "column": 17 + }, + "end": { + "line": 7, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 146, + 162 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 16 + } + }, + "value": "console.log(foo)" + }, + { + "type": "HTMLWhitespace", + "range": [ + 162, + 163 + ], + "loc": { + "start": { + "line": 7, + "column": 16 + }, + "end": { + "line": 8, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 163, + 171 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 171, + 172 + ], + "loc": { + "start": { + "line": 8, + "column": 8 + }, + "end": { + "line": 8, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 172, + 173 + ], + "loc": { + "start": { + "line": 8, + "column": 9 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 173, + 182 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 182, + 183 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 9, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 183, + 184 + ], + "loc": { + "start": { + "line": 9, + "column": 10 + }, + "end": { + "line": 10, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionStart", + "range": [ + 184, + 186 + ], + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 2 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 10, + "column": 5 + }, + "start": { + "line": 10, + "column": 2 + } + }, + "range": [ + 186, + 189 + ], + "value": "foo" + }, + { + "type": "VExpressionEnd", + "range": [ + 189, + 191 + ], + "loc": { + "start": { + "line": 10, + "column": 5 + }, + "end": { + "line": 10, + "column": 7 + } + }, + "value": "}}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 191, + 192 + ], + "loc": { + "start": { + "line": 10, + "column": 7 + }, + "end": { + "line": 11, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 192, + 202 + ], + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 202, + 203 + ], + "loc": { + "start": { + "line": 11, + "column": 10 + }, + "end": { + "line": 11, + "column": 11 + } + }, + "value": "" + } + ], + "comments": [], + "errors": [] +} \ No newline at end of file diff --git a/test/fixtures/document-fragment/vue3.3-generic-2/parser-options.json b/test/fixtures/document-fragment/vue3.3-generic-2/parser-options.json new file mode 100644 index 00000000..0ead30e9 --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-2/parser-options.json @@ -0,0 +1,6 @@ +{ + "sourceType": "module", + "parser": { + "ts": "@typescript-eslint/parser" + } +} diff --git a/test/fixtures/document-fragment/vue3.3-generic-2/source.vue b/test/fixtures/document-fragment/vue3.3-generic-2/source.vue new file mode 100644 index 00000000..e42bea85 --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-2/source.vue @@ -0,0 +1,11 @@ + + + \ No newline at end of file diff --git a/test/fixtures/document-fragment/vue3.3-generic-2/token-ranges.json b/test/fixtures/document-fragment/vue3.3-generic-2/token-ranges.json new file mode 100644 index 00000000..0f21efc8 --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-2/token-ranges.json @@ -0,0 +1,64 @@ +[ + "", + "\n", + "type", + " ", + "Foo", + " ", + "=", + " ", + "number", + " ", + "|", + " ", + "string", + "\n", + "", + "\n", + "", + "\n", + "const", + " ", + "p", + " ", + "=", + " ", + "defineProps<{foo:T}>()", + "\n", + "const", + " ", + "foo", + " ", + "=", + " ", + "p.foo", + "\n", + "console.log(foo)", + "\n", + "", + "\n", + "", + "\n", + "{{", + "foo", + "}}", + "\n", + "" +] \ No newline at end of file diff --git a/test/fixtures/document-fragment/vue3.3-generic-2/tree.json b/test/fixtures/document-fragment/vue3.3-generic-2/tree.json new file mode 100644 index 00000000..02563812 --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-2/tree.json @@ -0,0 +1,176 @@ +[ + { + "type": "VDocumentFragment", + "text": "\n\n", + "children": [ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + }, + { + "type": "VText", + "text": "\n", + "children": [] + }, + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + }, + { + "type": "VText", + "text": "\n", + "children": [] + }, + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/document-fragment/vue3.3-generic-3/document-fragment.json b/test/fixtures/document-fragment/vue3.3-generic-3/document-fragment.json new file mode 100644 index 00000000..352fa378 --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-3/document-fragment.json @@ -0,0 +1,3314 @@ +{ + "type": "VDocumentFragment", + "range": [ + 0, + 224 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 11, + "column": 11 + } + }, + "children": [ + { + "type": "VElement", + "range": [ + 0, + 45 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "name": "script", + "rawName": "script", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 0, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 8, + 36 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\ntype Foo = number | string\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 36, + 45 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 9 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 45, + 46 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VElement", + "range": [ + 46, + 193 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 8, + "column": 9 + } + }, + "name": "script", + "rawName": "script", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 46, + 107 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 61 + } + }, + "selfClosing": false, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 54, + 59 + ], + "loc": { + "start": { + "line": 4, + "column": 8 + }, + "end": { + "line": 4, + "column": 13 + } + }, + "directive": false, + "key": { + "type": "VIdentifier", + "range": [ + 54, + 59 + ], + "loc": { + "start": { + "line": 4, + "column": 8 + }, + "end": { + "line": 4, + "column": 13 + } + }, + "name": "setup", + "rawName": "setup" + }, + "value": null + }, + { + "type": "VAttribute", + "range": [ + 60, + 69 + ], + "loc": { + "start": { + "line": 4, + "column": 14 + }, + "end": { + "line": 4, + "column": 23 + } + }, + "directive": false, + "key": { + "type": "VIdentifier", + "range": [ + 60, + 64 + ], + "loc": { + "start": { + "line": 4, + "column": 14 + }, + "end": { + "line": 4, + "column": 18 + } + }, + "name": "lang", + "rawName": "lang" + }, + "value": { + "type": "VLiteral", + "range": [ + 65, + 69 + ], + "loc": { + "start": { + "line": 4, + "column": 19 + }, + "end": { + "line": 4, + "column": 23 + } + }, + "value": "ts" + } + }, + { + "type": "VAttribute", + "range": [ + 70, + 106 + ], + "loc": { + "start": { + "line": 4, + "column": 24 + }, + "end": { + "line": 4, + "column": 60 + } + }, + "directive": true, + "key": { + "type": "VDirectiveKey", + "range": [ + 70, + 77 + ], + "loc": { + "start": { + "line": 4, + "column": 24 + }, + "end": { + "line": 4, + "column": 31 + } + }, + "name": { + "type": "VIdentifier", + "range": [ + 70, + 77 + ], + "loc": { + "start": { + "column": 24, + "line": 4 + }, + "end": { + "column": 31, + "line": 4 + } + }, + "name": "generic", + "rawName": "generic" + }, + "argument": null, + "modifiers": [] + }, + "value": { + "type": "VExpressionContainer", + "range": [ + 78, + 106 + ], + "loc": { + "start": { + "line": 4, + "column": 32 + }, + "end": { + "line": 4, + "column": 60 + } + }, + "expression": { + "type": "VGenericExpression", + "range": [ + 79, + 105 + ], + "loc": { + "start": { + "line": 4, + "column": 33 + }, + "end": { + "line": 4, + "column": 59 + } + }, + "params": [ + { + "type": "TSTypeParameter", + "const": false, + "constraint": { + "type": "TSTypeReference", + "typeName": { + "type": "Identifier", + "decorators": [], + "name": "Foo", + "optional": false, + "range": [ + 89, + 92 + ], + "loc": { + "end": { + "line": 4, + "column": 46 + }, + "start": { + "line": 4, + "column": 43 + } + } + }, + "range": [ + 89, + 92 + ], + "loc": { + "end": { + "line": 4, + "column": 46 + }, + "start": { + "line": 4, + "column": 43 + } + } + }, + "in": false, + "name": { + "type": "Identifier", + "decorators": [], + "name": "T", + "optional": false, + "range": [ + 79, + 80 + ], + "loc": { + "end": { + "line": 4, + "column": 34 + }, + "start": { + "line": 4, + "column": 33 + } + } + }, + "out": false, + "range": [ + 79, + 92 + ], + "loc": { + "end": { + "line": 4, + "column": 46 + }, + "start": { + "line": 4, + "column": 33 + } + } + }, + { + "type": "TSTypeParameter", + "const": false, + "constraint": { + "type": "TSTypeReference", + "typeName": { + "type": "Identifier", + "decorators": [], + "name": "T", + "optional": false, + "range": [ + 104, + 105 + ], + "loc": { + "end": { + "line": 4, + "column": 59 + }, + "start": { + "line": 4, + "column": 58 + } + } + }, + "range": [ + 104, + 105 + ], + "loc": { + "end": { + "line": 4, + "column": 59 + }, + "start": { + "line": 4, + "column": 58 + } + } + }, + "in": false, + "name": { + "type": "Identifier", + "decorators": [], + "name": "U", + "optional": false, + "range": [ + 94, + 95 + ], + "loc": { + "end": { + "line": 4, + "column": 49 + }, + "start": { + "line": 4, + "column": 48 + } + } + }, + "out": false, + "range": [ + 94, + 105 + ], + "loc": { + "end": { + "line": 4, + "column": 59 + }, + "start": { + "line": 4, + "column": 48 + } + } + } + ], + "rawParams": [ + "T extends Foo", + "U extends T" + ] + }, + "references": [ + { + "id": { + "type": "Identifier", + "decorators": [], + "name": "Foo", + "optional": false, + "range": [ + 89, + 92 + ], + "loc": { + "end": { + "line": 4, + "column": 46 + }, + "start": { + "line": 4, + "column": 43 + } + } + }, + "mode": "r", + "isValueReference": false, + "isTypeReference": true + } + ] + } + } + ] + }, + "children": [ + { + "type": "VText", + "range": [ + 107, + 184 + ], + "loc": { + "start": { + "line": 4, + "column": 61 + }, + "end": { + "line": 8, + "column": 0 + } + }, + "value": "\nconst p = defineProps<{foo:T, bar: U}>()\nconst foo = p.foo\nconsole.log(foo)\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 184, + 193 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 9 + } + } + }, + "variables": [ + { + "id": { + "type": "Identifier", + "decorators": [], + "name": "T", + "optional": false, + "range": [ + 79, + 80 + ], + "loc": { + "end": { + "line": 4, + "column": 34 + }, + "start": { + "line": 4, + "column": 33 + } + } + }, + "kind": "generic" + }, + { + "id": { + "type": "Identifier", + "decorators": [], + "name": "U", + "optional": false, + "range": [ + 94, + 95 + ], + "loc": { + "end": { + "line": 4, + "column": 49 + }, + "start": { + "line": 4, + "column": 48 + } + } + }, + "kind": "generic" + } + ] + }, + { + "type": "VText", + "range": [ + 193, + 194 + ], + "loc": { + "start": { + "line": 8, + "column": 9 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VElement", + "range": [ + 194, + 224 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 11, + "column": 11 + } + }, + "name": "template", + "rawName": "template", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 194, + 204 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 10 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 204, + 205 + ], + "loc": { + "start": { + "line": 9, + "column": 10 + }, + "end": { + "line": 10, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionContainer", + "range": [ + 205, + 212 + ], + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 7 + } + }, + "expression": { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 207, + 210 + ], + "loc": { + "end": { + "line": 10, + "column": 5 + }, + "start": { + "line": 10, + "column": 2 + } + } + }, + "references": [ + { + "id": { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 207, + 210 + ], + "loc": { + "end": { + "line": 10, + "column": 5 + }, + "start": { + "line": 10, + "column": 2 + } + } + }, + "mode": "r", + "isValueReference": true, + "isTypeReference": false + } + ] + }, + { + "type": "VText", + "range": [ + 212, + 213 + ], + "loc": { + "start": { + "line": 10, + "column": 7 + }, + "end": { + "line": 11, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 213, + 224 + ], + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "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, + 13 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 4 + } + }, + "value": "type" + }, + { + "type": "HTMLWhitespace", + "range": [ + 13, + 14 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 5 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 14, + 17 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "value": "Foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 17, + 18 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 18, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 19, + 20 + ], + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 20, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "value": "number" + }, + { + "type": "HTMLWhitespace", + "range": [ + 26, + 27 + ], + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 27, + 28 + ], + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "value": "|" + }, + { + "type": "HTMLWhitespace", + "range": [ + 28, + 29 + ], + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 29, + 35 + ], + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 26 + } + }, + "value": "string" + }, + { + "type": "HTMLWhitespace", + "range": [ + 35, + 36 + ], + "loc": { + "start": { + "line": 2, + "column": 26 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 36, + 44 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 44, + 45 + ], + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 45, + 46 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 46, + 53 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLIdentifier", + "range": [ + 54, + 59 + ], + "loc": { + "start": { + "line": 4, + "column": 8 + }, + "end": { + "line": 4, + "column": 13 + } + }, + "value": "setup" + }, + { + "type": "HTMLIdentifier", + "range": [ + 60, + 64 + ], + "loc": { + "start": { + "line": 4, + "column": 14 + }, + "end": { + "line": 4, + "column": 18 + } + }, + "value": "lang" + }, + { + "type": "HTMLAssociation", + "range": [ + 64, + 65 + ], + "loc": { + "start": { + "line": 4, + "column": 18 + }, + "end": { + "line": 4, + "column": 19 + } + }, + "value": "" + }, + { + "type": "HTMLLiteral", + "range": [ + 65, + 69 + ], + "loc": { + "start": { + "line": 4, + "column": 19 + }, + "end": { + "line": 4, + "column": 23 + } + }, + "value": "ts" + }, + { + "type": "HTMLIdentifier", + "range": [ + 70, + 77 + ], + "loc": { + "start": { + "column": 24, + "line": 4 + }, + "end": { + "column": 31, + "line": 4 + } + }, + "value": "generic" + }, + { + "type": "HTMLAssociation", + "range": [ + 77, + 78 + ], + "loc": { + "start": { + "line": 4, + "column": 31 + }, + "end": { + "line": 4, + "column": 32 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 78, + 79 + ], + "loc": { + "start": { + "line": 4, + "column": 32 + }, + "end": { + "line": 4, + "column": 33 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 4, + "column": 34 + }, + "start": { + "line": 4, + "column": 33 + } + }, + "range": [ + 79, + 80 + ], + "value": "T" + }, + { + "type": "Keyword", + "loc": { + "end": { + "line": 4, + "column": 42 + }, + "start": { + "line": 4, + "column": 35 + } + }, + "range": [ + 81, + 88 + ], + "value": "extends" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 4, + "column": 46 + }, + "start": { + "line": 4, + "column": 43 + } + }, + "range": [ + 89, + 92 + ], + "value": "Foo" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 4, + "column": 47 + }, + "start": { + "line": 4, + "column": 46 + } + }, + "range": [ + 92, + 93 + ], + "value": "," + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 4, + "column": 49 + }, + "start": { + "line": 4, + "column": 48 + } + }, + "range": [ + 94, + 95 + ], + "value": "U" + }, + { + "type": "Keyword", + "loc": { + "end": { + "line": 4, + "column": 57 + }, + "start": { + "line": 4, + "column": 50 + } + }, + "range": [ + 96, + 103 + ], + "value": "extends" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 4, + "column": 59 + }, + "start": { + "line": 4, + "column": 58 + } + }, + "range": [ + 104, + 105 + ], + "value": "T" + }, + { + "type": "Punctuator", + "range": [ + 105, + 106 + ], + "loc": { + "start": { + "line": 4, + "column": 59 + }, + "end": { + "line": 4, + "column": 60 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 106, + 107 + ], + "loc": { + "start": { + "line": 4, + "column": 60 + }, + "end": { + "line": 4, + "column": 61 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 107, + 108 + ], + "loc": { + "start": { + "line": 4, + "column": 61 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 108, + 113 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 113, + 114 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 114, + 115 + ], + "loc": { + "start": { + "line": 5, + "column": 6 + }, + "end": { + "line": 5, + "column": 7 + } + }, + "value": "p" + }, + { + "type": "HTMLWhitespace", + "range": [ + 115, + 116 + ], + "loc": { + "start": { + "line": 5, + "column": 7 + }, + "end": { + "line": 5, + "column": 8 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 116, + 117 + ], + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 9 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 117, + 118 + ], + "loc": { + "start": { + "line": 5, + "column": 9 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 118, + 137 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 29 + } + }, + "value": "defineProps<{foo:T," + }, + { + "type": "HTMLWhitespace", + "range": [ + 137, + 138 + ], + "loc": { + "start": { + "line": 5, + "column": 29 + }, + "end": { + "line": 5, + "column": 30 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 138, + 142 + ], + "loc": { + "start": { + "line": 5, + "column": 30 + }, + "end": { + "line": 5, + "column": 34 + } + }, + "value": "bar:" + }, + { + "type": "HTMLWhitespace", + "range": [ + 142, + 143 + ], + "loc": { + "start": { + "line": 5, + "column": 34 + }, + "end": { + "line": 5, + "column": 35 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 143, + 148 + ], + "loc": { + "start": { + "line": 5, + "column": 35 + }, + "end": { + "line": 5, + "column": 40 + } + }, + "value": "U}>()" + }, + { + "type": "HTMLWhitespace", + "range": [ + 148, + 149 + ], + "loc": { + "start": { + "line": 5, + "column": 40 + }, + "end": { + "line": 6, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 149, + 154 + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 154, + 155 + ], + "loc": { + "start": { + "line": 6, + "column": 5 + }, + "end": { + "line": 6, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 155, + 158 + ], + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 9 + } + }, + "value": "foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 158, + 159 + ], + "loc": { + "start": { + "line": 6, + "column": 9 + }, + "end": { + "line": 6, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 159, + 160 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 11 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 160, + 161 + ], + "loc": { + "start": { + "line": 6, + "column": 11 + }, + "end": { + "line": 6, + "column": 12 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 161, + 166 + ], + "loc": { + "start": { + "line": 6, + "column": 12 + }, + "end": { + "line": 6, + "column": 17 + } + }, + "value": "p.foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 166, + 167 + ], + "loc": { + "start": { + "line": 6, + "column": 17 + }, + "end": { + "line": 7, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 167, + 183 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 16 + } + }, + "value": "console.log(foo)" + }, + { + "type": "HTMLWhitespace", + "range": [ + 183, + 184 + ], + "loc": { + "start": { + "line": 7, + "column": 16 + }, + "end": { + "line": 8, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 184, + 192 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 192, + 193 + ], + "loc": { + "start": { + "line": 8, + "column": 8 + }, + "end": { + "line": 8, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 193, + 194 + ], + "loc": { + "start": { + "line": 8, + "column": 9 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 194, + 203 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 203, + 204 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 9, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 204, + 205 + ], + "loc": { + "start": { + "line": 9, + "column": 10 + }, + "end": { + "line": 10, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionStart", + "range": [ + 205, + 207 + ], + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 2 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 10, + "column": 5 + }, + "start": { + "line": 10, + "column": 2 + } + }, + "range": [ + 207, + 210 + ], + "value": "foo" + }, + { + "type": "VExpressionEnd", + "range": [ + 210, + 212 + ], + "loc": { + "start": { + "line": 10, + "column": 5 + }, + "end": { + "line": 10, + "column": 7 + } + }, + "value": "}}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 212, + 213 + ], + "loc": { + "start": { + "line": 10, + "column": 7 + }, + "end": { + "line": 11, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 213, + 223 + ], + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 223, + 224 + ], + "loc": { + "start": { + "line": 11, + "column": 10 + }, + "end": { + "line": 11, + "column": 11 + } + }, + "value": "" + } + ], + "comments": [], + "errors": [] + } + ], + "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, + 13 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 4 + } + }, + "value": "type" + }, + { + "type": "HTMLWhitespace", + "range": [ + 13, + 14 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 5 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 14, + 17 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "value": "Foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 17, + 18 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 18, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 19, + 20 + ], + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 20, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "value": "number" + }, + { + "type": "HTMLWhitespace", + "range": [ + 26, + 27 + ], + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 27, + 28 + ], + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "value": "|" + }, + { + "type": "HTMLWhitespace", + "range": [ + 28, + 29 + ], + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 29, + 35 + ], + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 26 + } + }, + "value": "string" + }, + { + "type": "HTMLWhitespace", + "range": [ + 35, + 36 + ], + "loc": { + "start": { + "line": 2, + "column": 26 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 36, + 44 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 44, + 45 + ], + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 45, + 46 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 46, + 53 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLIdentifier", + "range": [ + 54, + 59 + ], + "loc": { + "start": { + "line": 4, + "column": 8 + }, + "end": { + "line": 4, + "column": 13 + } + }, + "value": "setup" + }, + { + "type": "HTMLIdentifier", + "range": [ + 60, + 64 + ], + "loc": { + "start": { + "line": 4, + "column": 14 + }, + "end": { + "line": 4, + "column": 18 + } + }, + "value": "lang" + }, + { + "type": "HTMLAssociation", + "range": [ + 64, + 65 + ], + "loc": { + "start": { + "line": 4, + "column": 18 + }, + "end": { + "line": 4, + "column": 19 + } + }, + "value": "" + }, + { + "type": "HTMLLiteral", + "range": [ + 65, + 69 + ], + "loc": { + "start": { + "line": 4, + "column": 19 + }, + "end": { + "line": 4, + "column": 23 + } + }, + "value": "ts" + }, + { + "type": "HTMLIdentifier", + "range": [ + 70, + 77 + ], + "loc": { + "start": { + "column": 24, + "line": 4 + }, + "end": { + "column": 31, + "line": 4 + } + }, + "value": "generic" + }, + { + "type": "HTMLAssociation", + "range": [ + 77, + 78 + ], + "loc": { + "start": { + "line": 4, + "column": 31 + }, + "end": { + "line": 4, + "column": 32 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 78, + 79 + ], + "loc": { + "start": { + "line": 4, + "column": 32 + }, + "end": { + "line": 4, + "column": 33 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 4, + "column": 34 + }, + "start": { + "line": 4, + "column": 33 + } + }, + "range": [ + 79, + 80 + ], + "value": "T" + }, + { + "type": "Keyword", + "loc": { + "end": { + "line": 4, + "column": 42 + }, + "start": { + "line": 4, + "column": 35 + } + }, + "range": [ + 81, + 88 + ], + "value": "extends" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 4, + "column": 46 + }, + "start": { + "line": 4, + "column": 43 + } + }, + "range": [ + 89, + 92 + ], + "value": "Foo" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 4, + "column": 47 + }, + "start": { + "line": 4, + "column": 46 + } + }, + "range": [ + 92, + 93 + ], + "value": "," + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 4, + "column": 49 + }, + "start": { + "line": 4, + "column": 48 + } + }, + "range": [ + 94, + 95 + ], + "value": "U" + }, + { + "type": "Keyword", + "loc": { + "end": { + "line": 4, + "column": 57 + }, + "start": { + "line": 4, + "column": 50 + } + }, + "range": [ + 96, + 103 + ], + "value": "extends" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 4, + "column": 59 + }, + "start": { + "line": 4, + "column": 58 + } + }, + "range": [ + 104, + 105 + ], + "value": "T" + }, + { + "type": "Punctuator", + "range": [ + 105, + 106 + ], + "loc": { + "start": { + "line": 4, + "column": 59 + }, + "end": { + "line": 4, + "column": 60 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 106, + 107 + ], + "loc": { + "start": { + "line": 4, + "column": 60 + }, + "end": { + "line": 4, + "column": 61 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 107, + 108 + ], + "loc": { + "start": { + "line": 4, + "column": 61 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 108, + 113 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 113, + 114 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 114, + 115 + ], + "loc": { + "start": { + "line": 5, + "column": 6 + }, + "end": { + "line": 5, + "column": 7 + } + }, + "value": "p" + }, + { + "type": "HTMLWhitespace", + "range": [ + 115, + 116 + ], + "loc": { + "start": { + "line": 5, + "column": 7 + }, + "end": { + "line": 5, + "column": 8 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 116, + 117 + ], + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 9 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 117, + 118 + ], + "loc": { + "start": { + "line": 5, + "column": 9 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 118, + 137 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 29 + } + }, + "value": "defineProps<{foo:T," + }, + { + "type": "HTMLWhitespace", + "range": [ + 137, + 138 + ], + "loc": { + "start": { + "line": 5, + "column": 29 + }, + "end": { + "line": 5, + "column": 30 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 138, + 142 + ], + "loc": { + "start": { + "line": 5, + "column": 30 + }, + "end": { + "line": 5, + "column": 34 + } + }, + "value": "bar:" + }, + { + "type": "HTMLWhitespace", + "range": [ + 142, + 143 + ], + "loc": { + "start": { + "line": 5, + "column": 34 + }, + "end": { + "line": 5, + "column": 35 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 143, + 148 + ], + "loc": { + "start": { + "line": 5, + "column": 35 + }, + "end": { + "line": 5, + "column": 40 + } + }, + "value": "U}>()" + }, + { + "type": "HTMLWhitespace", + "range": [ + 148, + 149 + ], + "loc": { + "start": { + "line": 5, + "column": 40 + }, + "end": { + "line": 6, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 149, + 154 + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 154, + 155 + ], + "loc": { + "start": { + "line": 6, + "column": 5 + }, + "end": { + "line": 6, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 155, + 158 + ], + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 9 + } + }, + "value": "foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 158, + 159 + ], + "loc": { + "start": { + "line": 6, + "column": 9 + }, + "end": { + "line": 6, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 159, + 160 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 11 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 160, + 161 + ], + "loc": { + "start": { + "line": 6, + "column": 11 + }, + "end": { + "line": 6, + "column": 12 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 161, + 166 + ], + "loc": { + "start": { + "line": 6, + "column": 12 + }, + "end": { + "line": 6, + "column": 17 + } + }, + "value": "p.foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 166, + 167 + ], + "loc": { + "start": { + "line": 6, + "column": 17 + }, + "end": { + "line": 7, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 167, + 183 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 16 + } + }, + "value": "console.log(foo)" + }, + { + "type": "HTMLWhitespace", + "range": [ + 183, + 184 + ], + "loc": { + "start": { + "line": 7, + "column": 16 + }, + "end": { + "line": 8, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 184, + 192 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 192, + 193 + ], + "loc": { + "start": { + "line": 8, + "column": 8 + }, + "end": { + "line": 8, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 193, + 194 + ], + "loc": { + "start": { + "line": 8, + "column": 9 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 194, + 203 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 203, + 204 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 9, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 204, + 205 + ], + "loc": { + "start": { + "line": 9, + "column": 10 + }, + "end": { + "line": 10, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionStart", + "range": [ + 205, + 207 + ], + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 2 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 10, + "column": 5 + }, + "start": { + "line": 10, + "column": 2 + } + }, + "range": [ + 207, + 210 + ], + "value": "foo" + }, + { + "type": "VExpressionEnd", + "range": [ + 210, + 212 + ], + "loc": { + "start": { + "line": 10, + "column": 5 + }, + "end": { + "line": 10, + "column": 7 + } + }, + "value": "}}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 212, + 213 + ], + "loc": { + "start": { + "line": 10, + "column": 7 + }, + "end": { + "line": 11, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 213, + 223 + ], + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 223, + 224 + ], + "loc": { + "start": { + "line": 11, + "column": 10 + }, + "end": { + "line": 11, + "column": 11 + } + }, + "value": "" + } + ], + "comments": [], + "errors": [] +} \ No newline at end of file diff --git a/test/fixtures/document-fragment/vue3.3-generic-3/parser-options.json b/test/fixtures/document-fragment/vue3.3-generic-3/parser-options.json new file mode 100644 index 00000000..0ead30e9 --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-3/parser-options.json @@ -0,0 +1,6 @@ +{ + "sourceType": "module", + "parser": { + "ts": "@typescript-eslint/parser" + } +} diff --git a/test/fixtures/document-fragment/vue3.3-generic-3/source.vue b/test/fixtures/document-fragment/vue3.3-generic-3/source.vue new file mode 100644 index 00000000..5d3590d2 --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-3/source.vue @@ -0,0 +1,11 @@ + + + \ No newline at end of file diff --git a/test/fixtures/document-fragment/vue3.3-generic-3/token-ranges.json b/test/fixtures/document-fragment/vue3.3-generic-3/token-ranges.json new file mode 100644 index 00000000..2c199c64 --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-3/token-ranges.json @@ -0,0 +1,72 @@ +[ + "", + "\n", + "type", + " ", + "Foo", + " ", + "=", + " ", + "number", + " ", + "|", + " ", + "string", + "\n", + "", + "\n", + "", + "\n", + "const", + " ", + "p", + " ", + "=", + " ", + "defineProps<{foo:T,", + " ", + "bar:", + " ", + "U}>()", + "\n", + "const", + " ", + "foo", + " ", + "=", + " ", + "p.foo", + "\n", + "console.log(foo)", + "\n", + "", + "\n", + "", + "\n", + "{{", + "foo", + "}}", + "\n", + "" +] \ No newline at end of file diff --git a/test/fixtures/document-fragment/vue3.3-generic-3/tree.json b/test/fixtures/document-fragment/vue3.3-generic-3/tree.json new file mode 100644 index 00000000..098b5927 --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-3/tree.json @@ -0,0 +1,198 @@ +[ + { + "type": "VDocumentFragment", + "text": "\n\n", + "children": [ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + }, + { + "type": "VText", + "text": "\n", + "children": [] + }, + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + }, + { + "type": "VText", + "text": "\n", + "children": [] + }, + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/document-fragment/vue3.3-generic-4-with-spaces/document-fragment.json b/test/fixtures/document-fragment/vue3.3-generic-4-with-spaces/document-fragment.json new file mode 100644 index 00000000..fd104f1b --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-4-with-spaces/document-fragment.json @@ -0,0 +1,3041 @@ +{ + "type": "VDocumentFragment", + "range": [ + 0, + 235 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 15, + "column": 11 + } + }, + "children": [ + { + "type": "VElement", + "range": [ + 0, + 204 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 12, + "column": 9 + } + }, + "name": "script", + "rawName": "script", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 0, + 91 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 7, + "column": 2 + } + }, + "selfClosing": false, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 8, + 13 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "directive": false, + "key": { + "type": "VIdentifier", + "range": [ + 8, + 13 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "name": "setup", + "rawName": "setup" + }, + "value": null + }, + { + "type": "VAttribute", + "range": [ + 14, + 23 + ], + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "directive": false, + "key": { + "type": "VIdentifier", + "range": [ + 14, + 18 + ], + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "name": "lang", + "rawName": "lang" + }, + "value": { + "type": "VLiteral", + "range": [ + 19, + 23 + ], + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "value": "ts" + } + }, + { + "type": "VAttribute", + "range": [ + 24, + 90 + ], + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "directive": true, + "key": { + "type": "VDirectiveKey", + "range": [ + 24, + 31 + ], + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "name": { + "type": "VIdentifier", + "range": [ + 24, + 31 + ], + "loc": { + "start": { + "column": 24, + "line": 1 + }, + "end": { + "column": 31, + "line": 1 + } + }, + "name": "generic", + "rawName": "generic" + }, + "argument": null, + "modifiers": [] + }, + "value": { + "type": "VExpressionContainer", + "range": [ + 32, + 90 + ], + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "expression": { + "type": "VGenericExpression", + "range": [ + 36, + 88 + ], + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 6, + "column": 5 + } + }, + "params": [ + { + "type": "TSTypeParameter", + "const": false, + "constraint": { + "type": "TSTypeReference", + "typeName": { + "type": "Identifier", + "decorators": [], + "name": "Foo", + "optional": false, + "range": [ + 50, + 53 + ], + "loc": { + "end": { + "line": 3, + "column": 15 + }, + "start": { + "line": 3, + "column": 12 + } + } + }, + "range": [ + 50, + 53 + ], + "loc": { + "end": { + "line": 3, + "column": 15 + }, + "start": { + "line": 3, + "column": 12 + } + } + }, + "in": false, + "name": { + "type": "Identifier", + "decorators": [], + "name": "T", + "optional": false, + "range": [ + 36, + 37 + ], + "loc": { + "end": { + "line": 2, + "column": 3 + }, + "start": { + "line": 2, + "column": 2 + } + } + }, + "out": false, + "range": [ + 36, + 53 + ], + "loc": { + "end": { + "line": 3, + "column": 15 + }, + "start": { + "line": 2, + "column": 2 + } + } + }, + { + "type": "TSTypeParameter", + "const": false, + "constraint": { + "type": "TSTypeReference", + "typeName": { + "type": "Identifier", + "decorators": [], + "name": "T", + "optional": false, + "range": [ + 87, + 88 + ], + "loc": { + "end": { + "line": 6, + "column": 5 + }, + "start": { + "line": 6, + "column": 4 + } + } + }, + "range": [ + 87, + 88 + ], + "loc": { + "end": { + "line": 6, + "column": 5 + }, + "start": { + "line": 6, + "column": 4 + } + } + }, + "in": false, + "name": { + "type": "Identifier", + "decorators": [], + "name": "U", + "optional": false, + "range": [ + 73, + 74 + ], + "loc": { + "end": { + "line": 5, + "column": 3 + }, + "start": { + "line": 5, + "column": 2 + } + } + }, + "out": false, + "range": [ + 73, + 88 + ], + "loc": { + "end": { + "line": 6, + "column": 5 + }, + "start": { + "line": 5, + "column": 2 + } + } + } + ], + "rawParams": [ + "T\n extends Foo", + "U extends\n T" + ] + }, + "references": [ + { + "id": { + "type": "Identifier", + "decorators": [], + "name": "Foo", + "optional": false, + "range": [ + 50, + 53 + ], + "loc": { + "end": { + "line": 3, + "column": 15 + }, + "start": { + "line": 3, + "column": 12 + } + } + }, + "mode": "r", + "isValueReference": false, + "isTypeReference": true + } + ] + } + } + ] + }, + "children": [ + { + "type": "VText", + "range": [ + 91, + 195 + ], + "loc": { + "start": { + "line": 7, + "column": 2 + }, + "end": { + "line": 12, + "column": 0 + } + }, + "value": "\ntype Foo = number | string\nconst p = defineProps<{foo:T, bar: U}>()\nconst foo = p.foo\nconsole.log(foo)\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 195, + 204 + ], + "loc": { + "start": { + "line": 12, + "column": 0 + }, + "end": { + "line": 12, + "column": 9 + } + } + }, + "variables": [ + { + "id": { + "type": "Identifier", + "decorators": [], + "name": "T", + "optional": false, + "range": [ + 36, + 37 + ], + "loc": { + "end": { + "line": 2, + "column": 3 + }, + "start": { + "line": 2, + "column": 2 + } + } + }, + "kind": "generic" + }, + { + "id": { + "type": "Identifier", + "decorators": [], + "name": "U", + "optional": false, + "range": [ + 73, + 74 + ], + "loc": { + "end": { + "line": 5, + "column": 3 + }, + "start": { + "line": 5, + "column": 2 + } + } + }, + "kind": "generic" + } + ] + }, + { + "type": "VText", + "range": [ + 204, + 205 + ], + "loc": { + "start": { + "line": 12, + "column": 9 + }, + "end": { + "line": 13, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VElement", + "range": [ + 205, + 235 + ], + "loc": { + "start": { + "line": 13, + "column": 0 + }, + "end": { + "line": 15, + "column": 11 + } + }, + "name": "template", + "rawName": "template", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 205, + 215 + ], + "loc": { + "start": { + "line": 13, + "column": 0 + }, + "end": { + "line": 13, + "column": 10 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 215, + 216 + ], + "loc": { + "start": { + "line": 13, + "column": 10 + }, + "end": { + "line": 14, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionContainer", + "range": [ + 216, + 223 + ], + "loc": { + "start": { + "line": 14, + "column": 0 + }, + "end": { + "line": 14, + "column": 7 + } + }, + "expression": { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 218, + 221 + ], + "loc": { + "end": { + "line": 14, + "column": 5 + }, + "start": { + "line": 14, + "column": 2 + } + } + }, + "references": [ + { + "id": { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 218, + 221 + ], + "loc": { + "end": { + "line": 14, + "column": 5 + }, + "start": { + "line": 14, + "column": 2 + } + } + }, + "mode": "r", + "isValueReference": true, + "isTypeReference": false + } + ] + }, + { + "type": "VText", + "range": [ + 223, + 224 + ], + "loc": { + "start": { + "line": 14, + "column": 7 + }, + "end": { + "line": 15, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 224, + 235 + ], + "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": "HTMLIdentifier", + "range": [ + 8, + 13 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": "setup" + }, + { + "type": "HTMLIdentifier", + "range": [ + 14, + 18 + ], + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "value": "lang" + }, + { + "type": "HTMLAssociation", + "range": [ + 18, + 19 + ], + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "value": "" + }, + { + "type": "HTMLLiteral", + "range": [ + 19, + 23 + ], + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "value": "ts" + }, + { + "type": "HTMLIdentifier", + "range": [ + 24, + 31 + ], + "loc": { + "start": { + "column": 24, + "line": 1 + }, + "end": { + "column": 31, + "line": 1 + } + }, + "value": "generic" + }, + { + "type": "HTMLAssociation", + "range": [ + 31, + 32 + ], + "loc": { + "start": { + "line": 1, + "column": 31 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 32, + 33 + ], + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 2, + "column": 3 + }, + "start": { + "line": 2, + "column": 2 + } + }, + "range": [ + 36, + 37 + ], + "value": "T" + }, + { + "type": "Keyword", + "loc": { + "end": { + "line": 3, + "column": 11 + }, + "start": { + "line": 3, + "column": 4 + } + }, + "range": [ + 42, + 49 + ], + "value": "extends" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 3, + "column": 15 + }, + "start": { + "line": 3, + "column": 12 + } + }, + "range": [ + 50, + 53 + ], + "value": "Foo" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 16 + }, + "start": { + "line": 3, + "column": 15 + } + }, + "range": [ + 53, + 54 + ], + "value": "," + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 5, + "column": 3 + }, + "start": { + "line": 5, + "column": 2 + } + }, + "range": [ + 73, + 74 + ], + "value": "U" + }, + { + "type": "Keyword", + "loc": { + "end": { + "line": 5, + "column": 11 + }, + "start": { + "line": 5, + "column": 4 + } + }, + "range": [ + 75, + 82 + ], + "value": "extends" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 6, + "column": 5 + }, + "start": { + "line": 6, + "column": 4 + } + }, + "range": [ + 87, + 88 + ], + "value": "T" + }, + { + "type": "Punctuator", + "range": [ + 89, + 90 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 90, + 91 + ], + "loc": { + "start": { + "line": 7, + "column": 1 + }, + "end": { + "line": 7, + "column": 2 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 91, + 92 + ], + "loc": { + "start": { + "line": 7, + "column": 2 + }, + "end": { + "line": 8, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 92, + 96 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 4 + } + }, + "value": "type" + }, + { + "type": "HTMLWhitespace", + "range": [ + 96, + 97 + ], + "loc": { + "start": { + "line": 8, + "column": 4 + }, + "end": { + "line": 8, + "column": 5 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 97, + 100 + ], + "loc": { + "start": { + "line": 8, + "column": 5 + }, + "end": { + "line": 8, + "column": 8 + } + }, + "value": "Foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 100, + 101 + ], + "loc": { + "start": { + "line": 8, + "column": 8 + }, + "end": { + "line": 8, + "column": 9 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 101, + 102 + ], + "loc": { + "start": { + "line": 8, + "column": 9 + }, + "end": { + "line": 8, + "column": 10 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 102, + 103 + ], + "loc": { + "start": { + "line": 8, + "column": 10 + }, + "end": { + "line": 8, + "column": 11 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 103, + 109 + ], + "loc": { + "start": { + "line": 8, + "column": 11 + }, + "end": { + "line": 8, + "column": 17 + } + }, + "value": "number" + }, + { + "type": "HTMLWhitespace", + "range": [ + 109, + 110 + ], + "loc": { + "start": { + "line": 8, + "column": 17 + }, + "end": { + "line": 8, + "column": 18 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 110, + 111 + ], + "loc": { + "start": { + "line": 8, + "column": 18 + }, + "end": { + "line": 8, + "column": 19 + } + }, + "value": "|" + }, + { + "type": "HTMLWhitespace", + "range": [ + 111, + 112 + ], + "loc": { + "start": { + "line": 8, + "column": 19 + }, + "end": { + "line": 8, + "column": 20 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 112, + 118 + ], + "loc": { + "start": { + "line": 8, + "column": 20 + }, + "end": { + "line": 8, + "column": 26 + } + }, + "value": "string" + }, + { + "type": "HTMLWhitespace", + "range": [ + 118, + 119 + ], + "loc": { + "start": { + "line": 8, + "column": 26 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 119, + 124 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 124, + 125 + ], + "loc": { + "start": { + "line": 9, + "column": 5 + }, + "end": { + "line": 9, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 125, + 126 + ], + "loc": { + "start": { + "line": 9, + "column": 6 + }, + "end": { + "line": 9, + "column": 7 + } + }, + "value": "p" + }, + { + "type": "HTMLWhitespace", + "range": [ + 126, + 127 + ], + "loc": { + "start": { + "line": 9, + "column": 7 + }, + "end": { + "line": 9, + "column": 8 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 127, + 128 + ], + "loc": { + "start": { + "line": 9, + "column": 8 + }, + "end": { + "line": 9, + "column": 9 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 128, + 129 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 9, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 129, + 148 + ], + "loc": { + "start": { + "line": 9, + "column": 10 + }, + "end": { + "line": 9, + "column": 29 + } + }, + "value": "defineProps<{foo:T," + }, + { + "type": "HTMLWhitespace", + "range": [ + 148, + 149 + ], + "loc": { + "start": { + "line": 9, + "column": 29 + }, + "end": { + "line": 9, + "column": 30 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 149, + 153 + ], + "loc": { + "start": { + "line": 9, + "column": 30 + }, + "end": { + "line": 9, + "column": 34 + } + }, + "value": "bar:" + }, + { + "type": "HTMLWhitespace", + "range": [ + 153, + 154 + ], + "loc": { + "start": { + "line": 9, + "column": 34 + }, + "end": { + "line": 9, + "column": 35 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 154, + 159 + ], + "loc": { + "start": { + "line": 9, + "column": 35 + }, + "end": { + "line": 9, + "column": 40 + } + }, + "value": "U}>()" + }, + { + "type": "HTMLWhitespace", + "range": [ + 159, + 160 + ], + "loc": { + "start": { + "line": 9, + "column": 40 + }, + "end": { + "line": 10, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 160, + 165 + ], + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 165, + 166 + ], + "loc": { + "start": { + "line": 10, + "column": 5 + }, + "end": { + "line": 10, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 166, + 169 + ], + "loc": { + "start": { + "line": 10, + "column": 6 + }, + "end": { + "line": 10, + "column": 9 + } + }, + "value": "foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 169, + 170 + ], + "loc": { + "start": { + "line": 10, + "column": 9 + }, + "end": { + "line": 10, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 170, + 171 + ], + "loc": { + "start": { + "line": 10, + "column": 10 + }, + "end": { + "line": 10, + "column": 11 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 171, + 172 + ], + "loc": { + "start": { + "line": 10, + "column": 11 + }, + "end": { + "line": 10, + "column": 12 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 172, + 177 + ], + "loc": { + "start": { + "line": 10, + "column": 12 + }, + "end": { + "line": 10, + "column": 17 + } + }, + "value": "p.foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 177, + 178 + ], + "loc": { + "start": { + "line": 10, + "column": 17 + }, + "end": { + "line": 11, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 178, + 194 + ], + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 16 + } + }, + "value": "console.log(foo)" + }, + { + "type": "HTMLWhitespace", + "range": [ + 194, + 195 + ], + "loc": { + "start": { + "line": 11, + "column": 16 + }, + "end": { + "line": 12, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 195, + 203 + ], + "loc": { + "start": { + "line": 12, + "column": 0 + }, + "end": { + "line": 12, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 203, + 204 + ], + "loc": { + "start": { + "line": 12, + "column": 8 + }, + "end": { + "line": 12, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 204, + 205 + ], + "loc": { + "start": { + "line": 12, + "column": 9 + }, + "end": { + "line": 13, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 205, + 214 + ], + "loc": { + "start": { + "line": 13, + "column": 0 + }, + "end": { + "line": 13, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 214, + 215 + ], + "loc": { + "start": { + "line": 13, + "column": 9 + }, + "end": { + "line": 13, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 215, + 216 + ], + "loc": { + "start": { + "line": 13, + "column": 10 + }, + "end": { + "line": 14, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionStart", + "range": [ + 216, + 218 + ], + "loc": { + "start": { + "line": 14, + "column": 0 + }, + "end": { + "line": 14, + "column": 2 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 14, + "column": 5 + }, + "start": { + "line": 14, + "column": 2 + } + }, + "range": [ + 218, + 221 + ], + "value": "foo" + }, + { + "type": "VExpressionEnd", + "range": [ + 221, + 223 + ], + "loc": { + "start": { + "line": 14, + "column": 5 + }, + "end": { + "line": 14, + "column": 7 + } + }, + "value": "}}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 223, + 224 + ], + "loc": { + "start": { + "line": 14, + "column": 7 + }, + "end": { + "line": 15, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 224, + 234 + ], + "loc": { + "start": { + "line": 15, + "column": 0 + }, + "end": { + "line": 15, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 234, + 235 + ], + "loc": { + "start": { + "line": 15, + "column": 10 + }, + "end": { + "line": 15, + "column": 11 + } + }, + "value": "" + } + ], + "comments": [ + { + "type": "Line", + "loc": { + "end": { + "line": 4, + "column": 15 + }, + "start": { + "line": 4, + "column": 4 + } + }, + "range": [ + 59, + 70 + ], + "value": " Comments" + } + ], + "errors": [] + } + ], + "tokens": [ + { + "type": "HTMLTagOpen", + "range": [ + 0, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLIdentifier", + "range": [ + 8, + 13 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": "setup" + }, + { + "type": "HTMLIdentifier", + "range": [ + 14, + 18 + ], + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "value": "lang" + }, + { + "type": "HTMLAssociation", + "range": [ + 18, + 19 + ], + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "value": "" + }, + { + "type": "HTMLLiteral", + "range": [ + 19, + 23 + ], + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "value": "ts" + }, + { + "type": "HTMLIdentifier", + "range": [ + 24, + 31 + ], + "loc": { + "start": { + "column": 24, + "line": 1 + }, + "end": { + "column": 31, + "line": 1 + } + }, + "value": "generic" + }, + { + "type": "HTMLAssociation", + "range": [ + 31, + 32 + ], + "loc": { + "start": { + "line": 1, + "column": 31 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 32, + 33 + ], + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 2, + "column": 3 + }, + "start": { + "line": 2, + "column": 2 + } + }, + "range": [ + 36, + 37 + ], + "value": "T" + }, + { + "type": "Keyword", + "loc": { + "end": { + "line": 3, + "column": 11 + }, + "start": { + "line": 3, + "column": 4 + } + }, + "range": [ + 42, + 49 + ], + "value": "extends" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 3, + "column": 15 + }, + "start": { + "line": 3, + "column": 12 + } + }, + "range": [ + 50, + 53 + ], + "value": "Foo" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 16 + }, + "start": { + "line": 3, + "column": 15 + } + }, + "range": [ + 53, + 54 + ], + "value": "," + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 5, + "column": 3 + }, + "start": { + "line": 5, + "column": 2 + } + }, + "range": [ + 73, + 74 + ], + "value": "U" + }, + { + "type": "Keyword", + "loc": { + "end": { + "line": 5, + "column": 11 + }, + "start": { + "line": 5, + "column": 4 + } + }, + "range": [ + 75, + 82 + ], + "value": "extends" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 6, + "column": 5 + }, + "start": { + "line": 6, + "column": 4 + } + }, + "range": [ + 87, + 88 + ], + "value": "T" + }, + { + "type": "Punctuator", + "range": [ + 89, + 90 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 90, + 91 + ], + "loc": { + "start": { + "line": 7, + "column": 1 + }, + "end": { + "line": 7, + "column": 2 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 91, + 92 + ], + "loc": { + "start": { + "line": 7, + "column": 2 + }, + "end": { + "line": 8, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 92, + 96 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 4 + } + }, + "value": "type" + }, + { + "type": "HTMLWhitespace", + "range": [ + 96, + 97 + ], + "loc": { + "start": { + "line": 8, + "column": 4 + }, + "end": { + "line": 8, + "column": 5 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 97, + 100 + ], + "loc": { + "start": { + "line": 8, + "column": 5 + }, + "end": { + "line": 8, + "column": 8 + } + }, + "value": "Foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 100, + 101 + ], + "loc": { + "start": { + "line": 8, + "column": 8 + }, + "end": { + "line": 8, + "column": 9 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 101, + 102 + ], + "loc": { + "start": { + "line": 8, + "column": 9 + }, + "end": { + "line": 8, + "column": 10 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 102, + 103 + ], + "loc": { + "start": { + "line": 8, + "column": 10 + }, + "end": { + "line": 8, + "column": 11 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 103, + 109 + ], + "loc": { + "start": { + "line": 8, + "column": 11 + }, + "end": { + "line": 8, + "column": 17 + } + }, + "value": "number" + }, + { + "type": "HTMLWhitespace", + "range": [ + 109, + 110 + ], + "loc": { + "start": { + "line": 8, + "column": 17 + }, + "end": { + "line": 8, + "column": 18 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 110, + 111 + ], + "loc": { + "start": { + "line": 8, + "column": 18 + }, + "end": { + "line": 8, + "column": 19 + } + }, + "value": "|" + }, + { + "type": "HTMLWhitespace", + "range": [ + 111, + 112 + ], + "loc": { + "start": { + "line": 8, + "column": 19 + }, + "end": { + "line": 8, + "column": 20 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 112, + 118 + ], + "loc": { + "start": { + "line": 8, + "column": 20 + }, + "end": { + "line": 8, + "column": 26 + } + }, + "value": "string" + }, + { + "type": "HTMLWhitespace", + "range": [ + 118, + 119 + ], + "loc": { + "start": { + "line": 8, + "column": 26 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 119, + 124 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 124, + 125 + ], + "loc": { + "start": { + "line": 9, + "column": 5 + }, + "end": { + "line": 9, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 125, + 126 + ], + "loc": { + "start": { + "line": 9, + "column": 6 + }, + "end": { + "line": 9, + "column": 7 + } + }, + "value": "p" + }, + { + "type": "HTMLWhitespace", + "range": [ + 126, + 127 + ], + "loc": { + "start": { + "line": 9, + "column": 7 + }, + "end": { + "line": 9, + "column": 8 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 127, + 128 + ], + "loc": { + "start": { + "line": 9, + "column": 8 + }, + "end": { + "line": 9, + "column": 9 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 128, + 129 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 9, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 129, + 148 + ], + "loc": { + "start": { + "line": 9, + "column": 10 + }, + "end": { + "line": 9, + "column": 29 + } + }, + "value": "defineProps<{foo:T," + }, + { + "type": "HTMLWhitespace", + "range": [ + 148, + 149 + ], + "loc": { + "start": { + "line": 9, + "column": 29 + }, + "end": { + "line": 9, + "column": 30 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 149, + 153 + ], + "loc": { + "start": { + "line": 9, + "column": 30 + }, + "end": { + "line": 9, + "column": 34 + } + }, + "value": "bar:" + }, + { + "type": "HTMLWhitespace", + "range": [ + 153, + 154 + ], + "loc": { + "start": { + "line": 9, + "column": 34 + }, + "end": { + "line": 9, + "column": 35 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 154, + 159 + ], + "loc": { + "start": { + "line": 9, + "column": 35 + }, + "end": { + "line": 9, + "column": 40 + } + }, + "value": "U}>()" + }, + { + "type": "HTMLWhitespace", + "range": [ + 159, + 160 + ], + "loc": { + "start": { + "line": 9, + "column": 40 + }, + "end": { + "line": 10, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 160, + 165 + ], + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 165, + 166 + ], + "loc": { + "start": { + "line": 10, + "column": 5 + }, + "end": { + "line": 10, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 166, + 169 + ], + "loc": { + "start": { + "line": 10, + "column": 6 + }, + "end": { + "line": 10, + "column": 9 + } + }, + "value": "foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 169, + 170 + ], + "loc": { + "start": { + "line": 10, + "column": 9 + }, + "end": { + "line": 10, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 170, + 171 + ], + "loc": { + "start": { + "line": 10, + "column": 10 + }, + "end": { + "line": 10, + "column": 11 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 171, + 172 + ], + "loc": { + "start": { + "line": 10, + "column": 11 + }, + "end": { + "line": 10, + "column": 12 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 172, + 177 + ], + "loc": { + "start": { + "line": 10, + "column": 12 + }, + "end": { + "line": 10, + "column": 17 + } + }, + "value": "p.foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 177, + 178 + ], + "loc": { + "start": { + "line": 10, + "column": 17 + }, + "end": { + "line": 11, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 178, + 194 + ], + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 16 + } + }, + "value": "console.log(foo)" + }, + { + "type": "HTMLWhitespace", + "range": [ + 194, + 195 + ], + "loc": { + "start": { + "line": 11, + "column": 16 + }, + "end": { + "line": 12, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 195, + 203 + ], + "loc": { + "start": { + "line": 12, + "column": 0 + }, + "end": { + "line": 12, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 203, + 204 + ], + "loc": { + "start": { + "line": 12, + "column": 8 + }, + "end": { + "line": 12, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 204, + 205 + ], + "loc": { + "start": { + "line": 12, + "column": 9 + }, + "end": { + "line": 13, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 205, + 214 + ], + "loc": { + "start": { + "line": 13, + "column": 0 + }, + "end": { + "line": 13, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 214, + 215 + ], + "loc": { + "start": { + "line": 13, + "column": 9 + }, + "end": { + "line": 13, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 215, + 216 + ], + "loc": { + "start": { + "line": 13, + "column": 10 + }, + "end": { + "line": 14, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionStart", + "range": [ + 216, + 218 + ], + "loc": { + "start": { + "line": 14, + "column": 0 + }, + "end": { + "line": 14, + "column": 2 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 14, + "column": 5 + }, + "start": { + "line": 14, + "column": 2 + } + }, + "range": [ + 218, + 221 + ], + "value": "foo" + }, + { + "type": "VExpressionEnd", + "range": [ + 221, + 223 + ], + "loc": { + "start": { + "line": 14, + "column": 5 + }, + "end": { + "line": 14, + "column": 7 + } + }, + "value": "}}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 223, + 224 + ], + "loc": { + "start": { + "line": 14, + "column": 7 + }, + "end": { + "line": 15, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 224, + 234 + ], + "loc": { + "start": { + "line": 15, + "column": 0 + }, + "end": { + "line": 15, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 234, + 235 + ], + "loc": { + "start": { + "line": 15, + "column": 10 + }, + "end": { + "line": 15, + "column": 11 + } + }, + "value": "" + } + ], + "comments": [ + { + "type": "Line", + "loc": { + "end": { + "line": 4, + "column": 15 + }, + "start": { + "line": 4, + "column": 4 + } + }, + "range": [ + 59, + 70 + ], + "value": " Comments" + } + ], + "errors": [] +} \ No newline at end of file diff --git a/test/fixtures/document-fragment/vue3.3-generic-4-with-spaces/parser-options.json b/test/fixtures/document-fragment/vue3.3-generic-4-with-spaces/parser-options.json new file mode 100644 index 00000000..0ead30e9 --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-4-with-spaces/parser-options.json @@ -0,0 +1,6 @@ +{ + "sourceType": "module", + "parser": { + "ts": "@typescript-eslint/parser" + } +} diff --git a/test/fixtures/document-fragment/vue3.3-generic-4-with-spaces/source.vue b/test/fixtures/document-fragment/vue3.3-generic-4-with-spaces/source.vue new file mode 100644 index 00000000..7b4d167f --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-4-with-spaces/source.vue @@ -0,0 +1,15 @@ + + \ No newline at end of file diff --git a/test/fixtures/document-fragment/vue3.3-generic-4-with-spaces/token-ranges.json b/test/fixtures/document-fragment/vue3.3-generic-4-with-spaces/token-ranges.json new file mode 100644 index 00000000..37ed0210 --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-4-with-spaces/token-ranges.json @@ -0,0 +1,67 @@ +[ + "", + "\n", + "type", + " ", + "Foo", + " ", + "=", + " ", + "number", + " ", + "|", + " ", + "string", + "\n", + "const", + " ", + "p", + " ", + "=", + " ", + "defineProps<{foo:T,", + " ", + "bar:", + " ", + "U}>()", + "\n", + "const", + " ", + "foo", + " ", + "=", + " ", + "p.foo", + "\n", + "console.log(foo)", + "\n", + "", + "\n", + "", + "\n", + "{{", + "foo", + "}}", + "\n", + "", + "// Comments" +] \ No newline at end of file diff --git a/test/fixtures/document-fragment/vue3.3-generic-4-with-spaces/tree.json b/test/fixtures/document-fragment/vue3.3-generic-4-with-spaces/tree.json new file mode 100644 index 00000000..8ccbd3bd --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-4-with-spaces/tree.json @@ -0,0 +1,172 @@ +[ + { + "type": "VDocumentFragment", + "text": "\n", + "children": [ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + }, + { + "type": "VText", + "text": "\n", + "children": [] + }, + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/document-fragment/vue3.3-generic-5-with-spaces/document-fragment.json b/test/fixtures/document-fragment/vue3.3-generic-5-with-spaces/document-fragment.json new file mode 100644 index 00000000..6ead8821 --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-5-with-spaces/document-fragment.json @@ -0,0 +1,3366 @@ +{ + "type": "VDocumentFragment", + "range": [ + 0, + 283 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 16, + "column": 11 + } + }, + "children": [ + { + "type": "VElement", + "range": [ + 0, + 252 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 13, + "column": 9 + } + }, + "name": "script", + "rawName": "script", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 0, + 139 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 8, + "column": 2 + } + }, + "selfClosing": false, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 8, + 13 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "directive": false, + "key": { + "type": "VIdentifier", + "range": [ + 8, + 13 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "name": "setup", + "rawName": "setup" + }, + "value": null + }, + { + "type": "VAttribute", + "range": [ + 14, + 23 + ], + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "directive": false, + "key": { + "type": "VIdentifier", + "range": [ + 14, + 18 + ], + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "name": "lang", + "rawName": "lang" + }, + "value": { + "type": "VLiteral", + "range": [ + 19, + 23 + ], + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "value": "ts" + } + }, + { + "type": "VAttribute", + "range": [ + 24, + 138 + ], + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 8, + "column": 1 + } + }, + "directive": true, + "key": { + "type": "VDirectiveKey", + "range": [ + 24, + 31 + ], + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "name": { + "type": "VIdentifier", + "range": [ + 24, + 31 + ], + "loc": { + "start": { + "column": 24, + "line": 1 + }, + "end": { + "column": 31, + "line": 1 + } + }, + "name": "generic", + "rawName": "generic" + }, + "argument": null, + "modifiers": [] + }, + "value": { + "type": "VExpressionContainer", + "range": [ + 32, + 138 + ], + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 8, + "column": 1 + } + }, + "expression": { + "type": "VGenericExpression", + "range": [ + 36, + 136 + ], + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 7, + "column": 24 + } + }, + "params": [ + { + "type": "TSTypeParameter", + "const": false, + "constraint": { + "type": "TSTypeReference", + "typeName": { + "type": "Identifier", + "decorators": [], + "name": "Foo", + "optional": false, + "range": [ + 61, + 64 + ], + "loc": { + "end": { + "line": 3, + "column": 15 + }, + "start": { + "line": 3, + "column": 12 + } + } + }, + "range": [ + 61, + 64 + ], + "loc": { + "end": { + "line": 3, + "column": 15 + }, + "start": { + "line": 3, + "column": 12 + } + } + }, + "in": false, + "name": { + "type": "Identifier", + "decorators": [], + "name": "T", + "optional": false, + "range": [ + 36, + 37 + ], + "loc": { + "end": { + "line": 2, + "column": 3 + }, + "start": { + "line": 2, + "column": 2 + } + } + }, + "out": false, + "range": [ + 36, + 64 + ], + "loc": { + "end": { + "line": 3, + "column": 15 + }, + "start": { + "line": 2, + "column": 2 + } + } + }, + { + "type": "TSTypeParameter", + "const": false, + "constraint": { + "type": "TSTypeReference", + "typeArguments": { + "type": "TSTypeParameterInstantiation", + "range": [ + 122, + 136 + ], + "params": [ + { + "type": "TSStringKeyword", + "range": [ + 126, + 132 + ], + "loc": { + "end": { + "line": 7, + "column": 20 + }, + "start": { + "line": 7, + "column": 14 + } + } + }, + { + "type": "TSTypeReference", + "typeName": { + "type": "Identifier", + "decorators": [], + "name": "T", + "optional": false, + "range": [ + 134, + 135 + ], + "loc": { + "end": { + "line": 7, + "column": 23 + }, + "start": { + "line": 7, + "column": 22 + } + } + }, + "range": [ + 134, + 135 + ], + "loc": { + "end": { + "line": 7, + "column": 23 + }, + "start": { + "line": 7, + "column": 22 + } + } + } + ], + "loc": { + "end": { + "line": 7, + "column": 24 + }, + "start": { + "line": 7, + "column": 10 + } + } + }, + "typeName": { + "type": "Identifier", + "decorators": [], + "name": "Record", + "optional": false, + "range": [ + 116, + 122 + ], + "loc": { + "end": { + "line": 7, + "column": 10 + }, + "start": { + "line": 7, + "column": 4 + } + } + }, + "range": [ + 116, + 136 + ], + "loc": { + "end": { + "line": 7, + "column": 24 + }, + "start": { + "line": 7, + "column": 4 + } + } + }, + "in": false, + "name": { + "type": "Identifier", + "decorators": [], + "name": "U", + "optional": false, + "range": [ + 84, + 85 + ], + "loc": { + "end": { + "line": 5, + "column": 3 + }, + "start": { + "line": 5, + "column": 2 + } + } + }, + "out": false, + "range": [ + 84, + 136 + ], + "loc": { + "end": { + "line": 7, + "column": 24 + }, + "start": { + "line": 5, + "column": 2 + } + } + } + ], + "rawParams": [ + "T // extends\n extends Foo", + "U /* extends */\n extends\n Record" + ] + }, + "references": [ + { + "id": { + "type": "Identifier", + "decorators": [], + "name": "Foo", + "optional": false, + "range": [ + 61, + 64 + ], + "loc": { + "end": { + "line": 3, + "column": 15 + }, + "start": { + "line": 3, + "column": 12 + } + } + }, + "mode": "r", + "isValueReference": false, + "isTypeReference": true + } + ] + } + } + ] + }, + "children": [ + { + "type": "VText", + "range": [ + 139, + 243 + ], + "loc": { + "start": { + "line": 8, + "column": 2 + }, + "end": { + "line": 13, + "column": 0 + } + }, + "value": "\ntype Foo = number | string\nconst p = defineProps<{foo:T, bar: U}>()\nconst foo = p.foo\nconsole.log(foo)\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 243, + 252 + ], + "loc": { + "start": { + "line": 13, + "column": 0 + }, + "end": { + "line": 13, + "column": 9 + } + } + }, + "variables": [ + { + "id": { + "type": "Identifier", + "decorators": [], + "name": "T", + "optional": false, + "range": [ + 36, + 37 + ], + "loc": { + "end": { + "line": 2, + "column": 3 + }, + "start": { + "line": 2, + "column": 2 + } + } + }, + "kind": "generic" + }, + { + "id": { + "type": "Identifier", + "decorators": [], + "name": "U", + "optional": false, + "range": [ + 84, + 85 + ], + "loc": { + "end": { + "line": 5, + "column": 3 + }, + "start": { + "line": 5, + "column": 2 + } + } + }, + "kind": "generic" + } + ] + }, + { + "type": "VText", + "range": [ + 252, + 253 + ], + "loc": { + "start": { + "line": 13, + "column": 9 + }, + "end": { + "line": 14, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VElement", + "range": [ + 253, + 283 + ], + "loc": { + "start": { + "line": 14, + "column": 0 + }, + "end": { + "line": 16, + "column": 11 + } + }, + "name": "template", + "rawName": "template", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 253, + 263 + ], + "loc": { + "start": { + "line": 14, + "column": 0 + }, + "end": { + "line": 14, + "column": 10 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 263, + 264 + ], + "loc": { + "start": { + "line": 14, + "column": 10 + }, + "end": { + "line": 15, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionContainer", + "range": [ + 264, + 271 + ], + "loc": { + "start": { + "line": 15, + "column": 0 + }, + "end": { + "line": 15, + "column": 7 + } + }, + "expression": { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 266, + 269 + ], + "loc": { + "end": { + "line": 15, + "column": 5 + }, + "start": { + "line": 15, + "column": 2 + } + } + }, + "references": [ + { + "id": { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 266, + 269 + ], + "loc": { + "end": { + "line": 15, + "column": 5 + }, + "start": { + "line": 15, + "column": 2 + } + } + }, + "mode": "r", + "isValueReference": true, + "isTypeReference": false + } + ] + }, + { + "type": "VText", + "range": [ + 271, + 272 + ], + "loc": { + "start": { + "line": 15, + "column": 7 + }, + "end": { + "line": 16, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 272, + 283 + ], + "loc": { + "start": { + "line": 16, + "column": 0 + }, + "end": { + "line": 16, + "column": 11 + } + } + }, + "variables": [], + "tokens": [ + { + "type": "HTMLTagOpen", + "range": [ + 0, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLIdentifier", + "range": [ + 8, + 13 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": "setup" + }, + { + "type": "HTMLIdentifier", + "range": [ + 14, + 18 + ], + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "value": "lang" + }, + { + "type": "HTMLAssociation", + "range": [ + 18, + 19 + ], + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "value": "" + }, + { + "type": "HTMLLiteral", + "range": [ + 19, + 23 + ], + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "value": "ts" + }, + { + "type": "HTMLIdentifier", + "range": [ + 24, + 31 + ], + "loc": { + "start": { + "column": 24, + "line": 1 + }, + "end": { + "column": 31, + "line": 1 + } + }, + "value": "generic" + }, + { + "type": "HTMLAssociation", + "range": [ + 31, + 32 + ], + "loc": { + "start": { + "line": 1, + "column": 31 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 32, + 33 + ], + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 2, + "column": 3 + }, + "start": { + "line": 2, + "column": 2 + } + }, + "range": [ + 36, + 37 + ], + "value": "T" + }, + { + "type": "Keyword", + "loc": { + "end": { + "line": 3, + "column": 11 + }, + "start": { + "line": 3, + "column": 4 + } + }, + "range": [ + 53, + 60 + ], + "value": "extends" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 3, + "column": 15 + }, + "start": { + "line": 3, + "column": 12 + } + }, + "range": [ + 61, + 64 + ], + "value": "Foo" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 16 + }, + "start": { + "line": 3, + "column": 15 + } + }, + "range": [ + 64, + 65 + ], + "value": "," + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 5, + "column": 3 + }, + "start": { + "line": 5, + "column": 2 + } + }, + "range": [ + 84, + 85 + ], + "value": "U" + }, + { + "type": "Keyword", + "loc": { + "end": { + "line": 6, + "column": 11 + }, + "start": { + "line": 6, + "column": 4 + } + }, + "range": [ + 104, + 111 + ], + "value": "extends" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 7, + "column": 10 + }, + "start": { + "line": 7, + "column": 4 + } + }, + "range": [ + 116, + 122 + ], + "value": "Record" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 7, + "column": 14 + }, + "start": { + "line": 7, + "column": 10 + } + }, + "range": [ + 122, + 126 + ], + "value": "<" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 7, + "column": 20 + }, + "start": { + "line": 7, + "column": 14 + } + }, + "range": [ + 126, + 132 + ], + "value": "string" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 7, + "column": 21 + }, + "start": { + "line": 7, + "column": 20 + } + }, + "range": [ + 132, + 133 + ], + "value": "," + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 7, + "column": 23 + }, + "start": { + "line": 7, + "column": 22 + } + }, + "range": [ + 134, + 135 + ], + "value": "T" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 7, + "column": 24 + }, + "start": { + "line": 7, + "column": 23 + } + }, + "range": [ + 135, + 136 + ], + "value": ">" + }, + { + "type": "Punctuator", + "range": [ + 137, + 138 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 1 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 138, + 139 + ], + "loc": { + "start": { + "line": 8, + "column": 1 + }, + "end": { + "line": 8, + "column": 2 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 139, + 140 + ], + "loc": { + "start": { + "line": 8, + "column": 2 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 140, + 144 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 4 + } + }, + "value": "type" + }, + { + "type": "HTMLWhitespace", + "range": [ + 144, + 145 + ], + "loc": { + "start": { + "line": 9, + "column": 4 + }, + "end": { + "line": 9, + "column": 5 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 145, + 148 + ], + "loc": { + "start": { + "line": 9, + "column": 5 + }, + "end": { + "line": 9, + "column": 8 + } + }, + "value": "Foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 148, + 149 + ], + "loc": { + "start": { + "line": 9, + "column": 8 + }, + "end": { + "line": 9, + "column": 9 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 149, + 150 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 9, + "column": 10 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 150, + 151 + ], + "loc": { + "start": { + "line": 9, + "column": 10 + }, + "end": { + "line": 9, + "column": 11 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 151, + 157 + ], + "loc": { + "start": { + "line": 9, + "column": 11 + }, + "end": { + "line": 9, + "column": 17 + } + }, + "value": "number" + }, + { + "type": "HTMLWhitespace", + "range": [ + 157, + 158 + ], + "loc": { + "start": { + "line": 9, + "column": 17 + }, + "end": { + "line": 9, + "column": 18 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 158, + 159 + ], + "loc": { + "start": { + "line": 9, + "column": 18 + }, + "end": { + "line": 9, + "column": 19 + } + }, + "value": "|" + }, + { + "type": "HTMLWhitespace", + "range": [ + 159, + 160 + ], + "loc": { + "start": { + "line": 9, + "column": 19 + }, + "end": { + "line": 9, + "column": 20 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 160, + 166 + ], + "loc": { + "start": { + "line": 9, + "column": 20 + }, + "end": { + "line": 9, + "column": 26 + } + }, + "value": "string" + }, + { + "type": "HTMLWhitespace", + "range": [ + 166, + 167 + ], + "loc": { + "start": { + "line": 9, + "column": 26 + }, + "end": { + "line": 10, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 167, + 172 + ], + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 172, + 173 + ], + "loc": { + "start": { + "line": 10, + "column": 5 + }, + "end": { + "line": 10, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 173, + 174 + ], + "loc": { + "start": { + "line": 10, + "column": 6 + }, + "end": { + "line": 10, + "column": 7 + } + }, + "value": "p" + }, + { + "type": "HTMLWhitespace", + "range": [ + 174, + 175 + ], + "loc": { + "start": { + "line": 10, + "column": 7 + }, + "end": { + "line": 10, + "column": 8 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 175, + 176 + ], + "loc": { + "start": { + "line": 10, + "column": 8 + }, + "end": { + "line": 10, + "column": 9 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 176, + 177 + ], + "loc": { + "start": { + "line": 10, + "column": 9 + }, + "end": { + "line": 10, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 177, + 196 + ], + "loc": { + "start": { + "line": 10, + "column": 10 + }, + "end": { + "line": 10, + "column": 29 + } + }, + "value": "defineProps<{foo:T," + }, + { + "type": "HTMLWhitespace", + "range": [ + 196, + 197 + ], + "loc": { + "start": { + "line": 10, + "column": 29 + }, + "end": { + "line": 10, + "column": 30 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 197, + 201 + ], + "loc": { + "start": { + "line": 10, + "column": 30 + }, + "end": { + "line": 10, + "column": 34 + } + }, + "value": "bar:" + }, + { + "type": "HTMLWhitespace", + "range": [ + 201, + 202 + ], + "loc": { + "start": { + "line": 10, + "column": 34 + }, + "end": { + "line": 10, + "column": 35 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 202, + 207 + ], + "loc": { + "start": { + "line": 10, + "column": 35 + }, + "end": { + "line": 10, + "column": 40 + } + }, + "value": "U}>()" + }, + { + "type": "HTMLWhitespace", + "range": [ + 207, + 208 + ], + "loc": { + "start": { + "line": 10, + "column": 40 + }, + "end": { + "line": 11, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 208, + 213 + ], + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 213, + 214 + ], + "loc": { + "start": { + "line": 11, + "column": 5 + }, + "end": { + "line": 11, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 214, + 217 + ], + "loc": { + "start": { + "line": 11, + "column": 6 + }, + "end": { + "line": 11, + "column": 9 + } + }, + "value": "foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 217, + 218 + ], + "loc": { + "start": { + "line": 11, + "column": 9 + }, + "end": { + "line": 11, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 218, + 219 + ], + "loc": { + "start": { + "line": 11, + "column": 10 + }, + "end": { + "line": 11, + "column": 11 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 219, + 220 + ], + "loc": { + "start": { + "line": 11, + "column": 11 + }, + "end": { + "line": 11, + "column": 12 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 220, + 225 + ], + "loc": { + "start": { + "line": 11, + "column": 12 + }, + "end": { + "line": 11, + "column": 17 + } + }, + "value": "p.foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 225, + 226 + ], + "loc": { + "start": { + "line": 11, + "column": 17 + }, + "end": { + "line": 12, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 226, + 242 + ], + "loc": { + "start": { + "line": 12, + "column": 0 + }, + "end": { + "line": 12, + "column": 16 + } + }, + "value": "console.log(foo)" + }, + { + "type": "HTMLWhitespace", + "range": [ + 242, + 243 + ], + "loc": { + "start": { + "line": 12, + "column": 16 + }, + "end": { + "line": 13, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 243, + 251 + ], + "loc": { + "start": { + "line": 13, + "column": 0 + }, + "end": { + "line": 13, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 251, + 252 + ], + "loc": { + "start": { + "line": 13, + "column": 8 + }, + "end": { + "line": 13, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 252, + 253 + ], + "loc": { + "start": { + "line": 13, + "column": 9 + }, + "end": { + "line": 14, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 253, + 262 + ], + "loc": { + "start": { + "line": 14, + "column": 0 + }, + "end": { + "line": 14, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 262, + 263 + ], + "loc": { + "start": { + "line": 14, + "column": 9 + }, + "end": { + "line": 14, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 263, + 264 + ], + "loc": { + "start": { + "line": 14, + "column": 10 + }, + "end": { + "line": 15, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionStart", + "range": [ + 264, + 266 + ], + "loc": { + "start": { + "line": 15, + "column": 0 + }, + "end": { + "line": 15, + "column": 2 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 15, + "column": 5 + }, + "start": { + "line": 15, + "column": 2 + } + }, + "range": [ + 266, + 269 + ], + "value": "foo" + }, + { + "type": "VExpressionEnd", + "range": [ + 269, + 271 + ], + "loc": { + "start": { + "line": 15, + "column": 5 + }, + "end": { + "line": 15, + "column": 7 + } + }, + "value": "}}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 271, + 272 + ], + "loc": { + "start": { + "line": 15, + "column": 7 + }, + "end": { + "line": 16, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 272, + 282 + ], + "loc": { + "start": { + "line": 16, + "column": 0 + }, + "end": { + "line": 16, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 282, + 283 + ], + "loc": { + "start": { + "line": 16, + "column": 10 + }, + "end": { + "line": 16, + "column": 11 + } + }, + "value": "" + } + ], + "comments": [ + { + "type": "Line", + "loc": { + "end": { + "line": 2, + "column": 14 + }, + "start": { + "line": 2, + "column": 4 + } + }, + "range": [ + 38, + 48 + ], + "value": " extends" + }, + { + "type": "Line", + "loc": { + "end": { + "line": 4, + "column": 15 + }, + "start": { + "line": 4, + "column": 4 + } + }, + "range": [ + 70, + 81 + ], + "value": " Comments" + }, + { + "type": "Block", + "loc": { + "end": { + "line": 5, + "column": 17 + }, + "start": { + "line": 5, + "column": 4 + } + }, + "range": [ + 86, + 99 + ], + "value": " extends " + } + ], + "errors": [] + } + ], + "tokens": [ + { + "type": "HTMLTagOpen", + "range": [ + 0, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLIdentifier", + "range": [ + 8, + 13 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": "setup" + }, + { + "type": "HTMLIdentifier", + "range": [ + 14, + 18 + ], + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "value": "lang" + }, + { + "type": "HTMLAssociation", + "range": [ + 18, + 19 + ], + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "value": "" + }, + { + "type": "HTMLLiteral", + "range": [ + 19, + 23 + ], + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "value": "ts" + }, + { + "type": "HTMLIdentifier", + "range": [ + 24, + 31 + ], + "loc": { + "start": { + "column": 24, + "line": 1 + }, + "end": { + "column": 31, + "line": 1 + } + }, + "value": "generic" + }, + { + "type": "HTMLAssociation", + "range": [ + 31, + 32 + ], + "loc": { + "start": { + "line": 1, + "column": 31 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 32, + 33 + ], + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 2, + "column": 3 + }, + "start": { + "line": 2, + "column": 2 + } + }, + "range": [ + 36, + 37 + ], + "value": "T" + }, + { + "type": "Keyword", + "loc": { + "end": { + "line": 3, + "column": 11 + }, + "start": { + "line": 3, + "column": 4 + } + }, + "range": [ + 53, + 60 + ], + "value": "extends" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 3, + "column": 15 + }, + "start": { + "line": 3, + "column": 12 + } + }, + "range": [ + 61, + 64 + ], + "value": "Foo" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 16 + }, + "start": { + "line": 3, + "column": 15 + } + }, + "range": [ + 64, + 65 + ], + "value": "," + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 5, + "column": 3 + }, + "start": { + "line": 5, + "column": 2 + } + }, + "range": [ + 84, + 85 + ], + "value": "U" + }, + { + "type": "Keyword", + "loc": { + "end": { + "line": 6, + "column": 11 + }, + "start": { + "line": 6, + "column": 4 + } + }, + "range": [ + 104, + 111 + ], + "value": "extends" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 7, + "column": 10 + }, + "start": { + "line": 7, + "column": 4 + } + }, + "range": [ + 116, + 122 + ], + "value": "Record" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 7, + "column": 14 + }, + "start": { + "line": 7, + "column": 10 + } + }, + "range": [ + 122, + 126 + ], + "value": "<" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 7, + "column": 20 + }, + "start": { + "line": 7, + "column": 14 + } + }, + "range": [ + 126, + 132 + ], + "value": "string" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 7, + "column": 21 + }, + "start": { + "line": 7, + "column": 20 + } + }, + "range": [ + 132, + 133 + ], + "value": "," + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 7, + "column": 23 + }, + "start": { + "line": 7, + "column": 22 + } + }, + "range": [ + 134, + 135 + ], + "value": "T" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 7, + "column": 24 + }, + "start": { + "line": 7, + "column": 23 + } + }, + "range": [ + 135, + 136 + ], + "value": ">" + }, + { + "type": "Punctuator", + "range": [ + 137, + 138 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 1 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 138, + 139 + ], + "loc": { + "start": { + "line": 8, + "column": 1 + }, + "end": { + "line": 8, + "column": 2 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 139, + 140 + ], + "loc": { + "start": { + "line": 8, + "column": 2 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 140, + 144 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 4 + } + }, + "value": "type" + }, + { + "type": "HTMLWhitespace", + "range": [ + 144, + 145 + ], + "loc": { + "start": { + "line": 9, + "column": 4 + }, + "end": { + "line": 9, + "column": 5 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 145, + 148 + ], + "loc": { + "start": { + "line": 9, + "column": 5 + }, + "end": { + "line": 9, + "column": 8 + } + }, + "value": "Foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 148, + 149 + ], + "loc": { + "start": { + "line": 9, + "column": 8 + }, + "end": { + "line": 9, + "column": 9 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 149, + 150 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 9, + "column": 10 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 150, + 151 + ], + "loc": { + "start": { + "line": 9, + "column": 10 + }, + "end": { + "line": 9, + "column": 11 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 151, + 157 + ], + "loc": { + "start": { + "line": 9, + "column": 11 + }, + "end": { + "line": 9, + "column": 17 + } + }, + "value": "number" + }, + { + "type": "HTMLWhitespace", + "range": [ + 157, + 158 + ], + "loc": { + "start": { + "line": 9, + "column": 17 + }, + "end": { + "line": 9, + "column": 18 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 158, + 159 + ], + "loc": { + "start": { + "line": 9, + "column": 18 + }, + "end": { + "line": 9, + "column": 19 + } + }, + "value": "|" + }, + { + "type": "HTMLWhitespace", + "range": [ + 159, + 160 + ], + "loc": { + "start": { + "line": 9, + "column": 19 + }, + "end": { + "line": 9, + "column": 20 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 160, + 166 + ], + "loc": { + "start": { + "line": 9, + "column": 20 + }, + "end": { + "line": 9, + "column": 26 + } + }, + "value": "string" + }, + { + "type": "HTMLWhitespace", + "range": [ + 166, + 167 + ], + "loc": { + "start": { + "line": 9, + "column": 26 + }, + "end": { + "line": 10, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 167, + 172 + ], + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 172, + 173 + ], + "loc": { + "start": { + "line": 10, + "column": 5 + }, + "end": { + "line": 10, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 173, + 174 + ], + "loc": { + "start": { + "line": 10, + "column": 6 + }, + "end": { + "line": 10, + "column": 7 + } + }, + "value": "p" + }, + { + "type": "HTMLWhitespace", + "range": [ + 174, + 175 + ], + "loc": { + "start": { + "line": 10, + "column": 7 + }, + "end": { + "line": 10, + "column": 8 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 175, + 176 + ], + "loc": { + "start": { + "line": 10, + "column": 8 + }, + "end": { + "line": 10, + "column": 9 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 176, + 177 + ], + "loc": { + "start": { + "line": 10, + "column": 9 + }, + "end": { + "line": 10, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 177, + 196 + ], + "loc": { + "start": { + "line": 10, + "column": 10 + }, + "end": { + "line": 10, + "column": 29 + } + }, + "value": "defineProps<{foo:T," + }, + { + "type": "HTMLWhitespace", + "range": [ + 196, + 197 + ], + "loc": { + "start": { + "line": 10, + "column": 29 + }, + "end": { + "line": 10, + "column": 30 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 197, + 201 + ], + "loc": { + "start": { + "line": 10, + "column": 30 + }, + "end": { + "line": 10, + "column": 34 + } + }, + "value": "bar:" + }, + { + "type": "HTMLWhitespace", + "range": [ + 201, + 202 + ], + "loc": { + "start": { + "line": 10, + "column": 34 + }, + "end": { + "line": 10, + "column": 35 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 202, + 207 + ], + "loc": { + "start": { + "line": 10, + "column": 35 + }, + "end": { + "line": 10, + "column": 40 + } + }, + "value": "U}>()" + }, + { + "type": "HTMLWhitespace", + "range": [ + 207, + 208 + ], + "loc": { + "start": { + "line": 10, + "column": 40 + }, + "end": { + "line": 11, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 208, + 213 + ], + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 213, + 214 + ], + "loc": { + "start": { + "line": 11, + "column": 5 + }, + "end": { + "line": 11, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 214, + 217 + ], + "loc": { + "start": { + "line": 11, + "column": 6 + }, + "end": { + "line": 11, + "column": 9 + } + }, + "value": "foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 217, + 218 + ], + "loc": { + "start": { + "line": 11, + "column": 9 + }, + "end": { + "line": 11, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 218, + 219 + ], + "loc": { + "start": { + "line": 11, + "column": 10 + }, + "end": { + "line": 11, + "column": 11 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 219, + 220 + ], + "loc": { + "start": { + "line": 11, + "column": 11 + }, + "end": { + "line": 11, + "column": 12 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 220, + 225 + ], + "loc": { + "start": { + "line": 11, + "column": 12 + }, + "end": { + "line": 11, + "column": 17 + } + }, + "value": "p.foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 225, + 226 + ], + "loc": { + "start": { + "line": 11, + "column": 17 + }, + "end": { + "line": 12, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 226, + 242 + ], + "loc": { + "start": { + "line": 12, + "column": 0 + }, + "end": { + "line": 12, + "column": 16 + } + }, + "value": "console.log(foo)" + }, + { + "type": "HTMLWhitespace", + "range": [ + 242, + 243 + ], + "loc": { + "start": { + "line": 12, + "column": 16 + }, + "end": { + "line": 13, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 243, + 251 + ], + "loc": { + "start": { + "line": 13, + "column": 0 + }, + "end": { + "line": 13, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 251, + 252 + ], + "loc": { + "start": { + "line": 13, + "column": 8 + }, + "end": { + "line": 13, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 252, + 253 + ], + "loc": { + "start": { + "line": 13, + "column": 9 + }, + "end": { + "line": 14, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 253, + 262 + ], + "loc": { + "start": { + "line": 14, + "column": 0 + }, + "end": { + "line": 14, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 262, + 263 + ], + "loc": { + "start": { + "line": 14, + "column": 9 + }, + "end": { + "line": 14, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 263, + 264 + ], + "loc": { + "start": { + "line": 14, + "column": 10 + }, + "end": { + "line": 15, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionStart", + "range": [ + 264, + 266 + ], + "loc": { + "start": { + "line": 15, + "column": 0 + }, + "end": { + "line": 15, + "column": 2 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 15, + "column": 5 + }, + "start": { + "line": 15, + "column": 2 + } + }, + "range": [ + 266, + 269 + ], + "value": "foo" + }, + { + "type": "VExpressionEnd", + "range": [ + 269, + 271 + ], + "loc": { + "start": { + "line": 15, + "column": 5 + }, + "end": { + "line": 15, + "column": 7 + } + }, + "value": "}}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 271, + 272 + ], + "loc": { + "start": { + "line": 15, + "column": 7 + }, + "end": { + "line": 16, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 272, + 282 + ], + "loc": { + "start": { + "line": 16, + "column": 0 + }, + "end": { + "line": 16, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 282, + 283 + ], + "loc": { + "start": { + "line": 16, + "column": 10 + }, + "end": { + "line": 16, + "column": 11 + } + }, + "value": "" + } + ], + "comments": [ + { + "type": "Line", + "loc": { + "end": { + "line": 2, + "column": 14 + }, + "start": { + "line": 2, + "column": 4 + } + }, + "range": [ + 38, + 48 + ], + "value": " extends" + }, + { + "type": "Line", + "loc": { + "end": { + "line": 4, + "column": 15 + }, + "start": { + "line": 4, + "column": 4 + } + }, + "range": [ + 70, + 81 + ], + "value": " Comments" + }, + { + "type": "Block", + "loc": { + "end": { + "line": 5, + "column": 17 + }, + "start": { + "line": 5, + "column": 4 + } + }, + "range": [ + 86, + 99 + ], + "value": " extends " + } + ], + "errors": [] +} \ No newline at end of file diff --git a/test/fixtures/document-fragment/vue3.3-generic-5-with-spaces/parser-options.json b/test/fixtures/document-fragment/vue3.3-generic-5-with-spaces/parser-options.json new file mode 100644 index 00000000..0ead30e9 --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-5-with-spaces/parser-options.json @@ -0,0 +1,6 @@ +{ + "sourceType": "module", + "parser": { + "ts": "@typescript-eslint/parser" + } +} diff --git a/test/fixtures/document-fragment/vue3.3-generic-5-with-spaces/source.vue b/test/fixtures/document-fragment/vue3.3-generic-5-with-spaces/source.vue new file mode 100644 index 00000000..a5a1b5eb --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-5-with-spaces/source.vue @@ -0,0 +1,16 @@ + + \ No newline at end of file diff --git a/test/fixtures/document-fragment/vue3.3-generic-5-with-spaces/token-ranges.json b/test/fixtures/document-fragment/vue3.3-generic-5-with-spaces/token-ranges.json new file mode 100644 index 00000000..a58b113b --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-5-with-spaces/token-ranges.json @@ -0,0 +1,74 @@ +[ + "", + "\"", + ">", + "\n", + "type", + " ", + "Foo", + " ", + "=", + " ", + "number", + " ", + "|", + " ", + "string", + "\n", + "const", + " ", + "p", + " ", + "=", + " ", + "defineProps<{foo:T,", + " ", + "bar:", + " ", + "U}>()", + "\n", + "const", + " ", + "foo", + " ", + "=", + " ", + "p.foo", + "\n", + "console.log(foo)", + "\n", + "", + "\n", + "", + "\n", + "{{", + "foo", + "}}", + "\n", + "", + "// extends", + "// Comments", + "/* extends */" +] \ No newline at end of file diff --git a/test/fixtures/document-fragment/vue3.3-generic-5-with-spaces/tree.json b/test/fixtures/document-fragment/vue3.3-generic-5-with-spaces/tree.json new file mode 100644 index 00000000..eb531362 --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-5-with-spaces/tree.json @@ -0,0 +1,194 @@ +[ + { + "type": "VDocumentFragment", + "text": "\n", + "children": [ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + }, + { + "type": "VText", + "text": "\n", + "children": [] + }, + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/document-fragment/vue3.3-generic-6-with-default/document-fragment.json b/test/fixtures/document-fragment/vue3.3-generic-6-with-default/document-fragment.json new file mode 100644 index 00000000..36290861 --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-6-with-default/document-fragment.json @@ -0,0 +1,3905 @@ +{ + "type": "VDocumentFragment", + "range": [ + 0, + 371 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 21, + "column": 11 + } + }, + "children": [ + { + "type": "VElement", + "range": [ + 0, + 340 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 18, + "column": 9 + } + }, + "name": "script", + "rawName": "script", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 0, + 227 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 13, + "column": 2 + } + }, + "selfClosing": false, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 8, + 13 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "directive": false, + "key": { + "type": "VIdentifier", + "range": [ + 8, + 13 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "name": "setup", + "rawName": "setup" + }, + "value": null + }, + { + "type": "VAttribute", + "range": [ + 14, + 23 + ], + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "directive": false, + "key": { + "type": "VIdentifier", + "range": [ + 14, + 18 + ], + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "name": "lang", + "rawName": "lang" + }, + "value": { + "type": "VLiteral", + "range": [ + 19, + 23 + ], + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "value": "ts" + } + }, + { + "type": "VAttribute", + "range": [ + 24, + 226 + ], + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 13, + "column": 1 + } + }, + "directive": true, + "key": { + "type": "VDirectiveKey", + "range": [ + 24, + 31 + ], + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "name": { + "type": "VIdentifier", + "range": [ + 24, + 31 + ], + "loc": { + "start": { + "column": 24, + "line": 1 + }, + "end": { + "column": 31, + "line": 1 + } + }, + "name": "generic", + "rawName": "generic" + }, + "argument": null, + "modifiers": [] + }, + "value": { + "type": "VExpressionContainer", + "range": [ + 32, + 226 + ], + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 13, + "column": 1 + } + }, + "expression": { + "type": "VGenericExpression", + "range": [ + 36, + 224 + ], + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 12, + "column": 32 + } + }, + "params": [ + { + "type": "TSTypeParameter", + "const": false, + "constraint": { + "type": "TSTypeReference", + "typeName": { + "type": "Identifier", + "decorators": [], + "name": "Foo", + "optional": false, + "range": [ + 70, + 73 + ], + "loc": { + "end": { + "line": 3, + "column": 23 + }, + "start": { + "line": 3, + "column": 20 + } + } + }, + "range": [ + 70, + 73 + ], + "loc": { + "end": { + "line": 3, + "column": 23 + }, + "start": { + "line": 3, + "column": 20 + } + } + }, + "default": { + "type": "TSNumberKeyword", + "range": [ + 76, + 82 + ], + "loc": { + "end": { + "line": 3, + "column": 32 + }, + "start": { + "line": 3, + "column": 26 + } + } + }, + "in": false, + "name": { + "type": "Identifier", + "decorators": [], + "name": "T", + "optional": false, + "range": [ + 36, + 37 + ], + "loc": { + "end": { + "line": 2, + "column": 3 + }, + "start": { + "line": 2, + "column": 2 + } + } + }, + "out": false, + "range": [ + 36, + 82 + ], + "loc": { + "end": { + "line": 3, + "column": 32 + }, + "start": { + "line": 2, + "column": 2 + } + } + }, + { + "type": "TSTypeParameter", + "const": false, + "constraint": { + "type": "TSTypeReference", + "typeArguments": { + "type": "TSTypeParameterInstantiation", + "range": [ + 140, + 191 + ], + "params": [ + { + "type": "TSStringKeyword", + "range": [ + 165, + 171 + ], + "loc": { + "end": { + "line": 9, + "column": 12 + }, + "start": { + "line": 9, + "column": 6 + } + } + }, + { + "type": "TSTypeReference", + "typeName": { + "type": "Identifier", + "decorators": [], + "name": "T", + "optional": false, + "range": [ + 184, + 185 + ], + "loc": { + "end": { + "line": 10, + "column": 7 + }, + "start": { + "line": 10, + "column": 6 + } + } + }, + "range": [ + 184, + 185 + ], + "loc": { + "end": { + "line": 10, + "column": 7 + }, + "start": { + "line": 10, + "column": 6 + } + } + } + ], + "loc": { + "end": { + "line": 11, + "column": 5 + }, + "start": { + "line": 7, + "column": 10 + } + } + }, + "typeName": { + "type": "Identifier", + "decorators": [], + "name": "Record", + "optional": false, + "range": [ + 134, + 140 + ], + "loc": { + "end": { + "line": 7, + "column": 10 + }, + "start": { + "line": 7, + "column": 4 + } + } + }, + "range": [ + 134, + 191 + ], + "loc": { + "end": { + "line": 11, + "column": 5 + }, + "start": { + "line": 7, + "column": 4 + } + } + }, + "default": { + "type": "TSTypeReference", + "typeArguments": { + "type": "TSTypeParameterInstantiation", + "range": [ + 205, + 224 + ], + "params": [ + { + "type": "TSStringKeyword", + "range": [ + 206, + 212 + ], + "loc": { + "end": { + "line": 12, + "column": 20 + }, + "start": { + "line": 12, + "column": 14 + } + } + }, + { + "type": "TSNumberKeyword", + "range": [ + 214, + 220 + ], + "loc": { + "end": { + "line": 12, + "column": 28 + }, + "start": { + "line": 12, + "column": 22 + } + } + } + ], + "loc": { + "end": { + "line": 12, + "column": 32 + }, + "start": { + "line": 12, + "column": 13 + } + } + }, + "typeName": { + "type": "Identifier", + "decorators": [], + "name": "Record", + "optional": false, + "range": [ + 199, + 205 + ], + "loc": { + "end": { + "line": 12, + "column": 13 + }, + "start": { + "line": 12, + "column": 7 + } + } + }, + "range": [ + 199, + 224 + ], + "loc": { + "end": { + "line": 12, + "column": 32 + }, + "start": { + "line": 12, + "column": 7 + } + } + }, + "in": false, + "name": { + "type": "Identifier", + "decorators": [], + "name": "U", + "optional": false, + "range": [ + 102, + 103 + ], + "loc": { + "end": { + "line": 5, + "column": 3 + }, + "start": { + "line": 5, + "column": 2 + } + } + }, + "out": false, + "range": [ + 102, + 224 + ], + "loc": { + "end": { + "line": 12, + "column": 32 + }, + "start": { + "line": 5, + "column": 2 + } + } + } + ], + "rawParams": [ + "T // Comments\n extends /* = */ Foo = number", + "U /* extends */\n extends\n Record<\n /* = */\n string, // =\n T\n >\n = Record" + ] + }, + "references": [ + { + "id": { + "type": "Identifier", + "decorators": [], + "name": "Foo", + "optional": false, + "range": [ + 70, + 73 + ], + "loc": { + "end": { + "line": 3, + "column": 23 + }, + "start": { + "line": 3, + "column": 20 + } + } + }, + "mode": "r", + "isValueReference": false, + "isTypeReference": true + } + ] + } + } + ] + }, + "children": [ + { + "type": "VText", + "range": [ + 227, + 331 + ], + "loc": { + "start": { + "line": 13, + "column": 2 + }, + "end": { + "line": 18, + "column": 0 + } + }, + "value": "\ntype Foo = number | string\nconst p = defineProps<{foo:T, bar: U}>()\nconst foo = p.foo\nconsole.log(foo)\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 331, + 340 + ], + "loc": { + "start": { + "line": 18, + "column": 0 + }, + "end": { + "line": 18, + "column": 9 + } + } + }, + "variables": [ + { + "id": { + "type": "Identifier", + "decorators": [], + "name": "T", + "optional": false, + "range": [ + 36, + 37 + ], + "loc": { + "end": { + "line": 2, + "column": 3 + }, + "start": { + "line": 2, + "column": 2 + } + } + }, + "kind": "generic" + }, + { + "id": { + "type": "Identifier", + "decorators": [], + "name": "U", + "optional": false, + "range": [ + 102, + 103 + ], + "loc": { + "end": { + "line": 5, + "column": 3 + }, + "start": { + "line": 5, + "column": 2 + } + } + }, + "kind": "generic" + } + ] + }, + { + "type": "VText", + "range": [ + 340, + 341 + ], + "loc": { + "start": { + "line": 18, + "column": 9 + }, + "end": { + "line": 19, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VElement", + "range": [ + 341, + 371 + ], + "loc": { + "start": { + "line": 19, + "column": 0 + }, + "end": { + "line": 21, + "column": 11 + } + }, + "name": "template", + "rawName": "template", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 341, + 351 + ], + "loc": { + "start": { + "line": 19, + "column": 0 + }, + "end": { + "line": 19, + "column": 10 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 351, + 352 + ], + "loc": { + "start": { + "line": 19, + "column": 10 + }, + "end": { + "line": 20, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionContainer", + "range": [ + 352, + 359 + ], + "loc": { + "start": { + "line": 20, + "column": 0 + }, + "end": { + "line": 20, + "column": 7 + } + }, + "expression": { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 354, + 357 + ], + "loc": { + "end": { + "line": 20, + "column": 5 + }, + "start": { + "line": 20, + "column": 2 + } + } + }, + "references": [ + { + "id": { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 354, + 357 + ], + "loc": { + "end": { + "line": 20, + "column": 5 + }, + "start": { + "line": 20, + "column": 2 + } + } + }, + "mode": "r", + "isValueReference": true, + "isTypeReference": false + } + ] + }, + { + "type": "VText", + "range": [ + 359, + 360 + ], + "loc": { + "start": { + "line": 20, + "column": 7 + }, + "end": { + "line": 21, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 360, + 371 + ], + "loc": { + "start": { + "line": 21, + "column": 0 + }, + "end": { + "line": 21, + "column": 11 + } + } + }, + "variables": [], + "tokens": [ + { + "type": "HTMLTagOpen", + "range": [ + 0, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLIdentifier", + "range": [ + 8, + 13 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": "setup" + }, + { + "type": "HTMLIdentifier", + "range": [ + 14, + 18 + ], + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "value": "lang" + }, + { + "type": "HTMLAssociation", + "range": [ + 18, + 19 + ], + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "value": "" + }, + { + "type": "HTMLLiteral", + "range": [ + 19, + 23 + ], + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "value": "ts" + }, + { + "type": "HTMLIdentifier", + "range": [ + 24, + 31 + ], + "loc": { + "start": { + "column": 24, + "line": 1 + }, + "end": { + "column": 31, + "line": 1 + } + }, + "value": "generic" + }, + { + "type": "HTMLAssociation", + "range": [ + 31, + 32 + ], + "loc": { + "start": { + "line": 1, + "column": 31 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 32, + 33 + ], + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 2, + "column": 3 + }, + "start": { + "line": 2, + "column": 2 + } + }, + "range": [ + 36, + 37 + ], + "value": "T" + }, + { + "type": "Keyword", + "loc": { + "end": { + "line": 3, + "column": 11 + }, + "start": { + "line": 3, + "column": 4 + } + }, + "range": [ + 54, + 61 + ], + "value": "extends" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 3, + "column": 23 + }, + "start": { + "line": 3, + "column": 20 + } + }, + "range": [ + 70, + 73 + ], + "value": "Foo" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 25 + }, + "start": { + "line": 3, + "column": 24 + } + }, + "range": [ + 74, + 75 + ], + "value": "=" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 3, + "column": 32 + }, + "start": { + "line": 3, + "column": 26 + } + }, + "range": [ + 76, + 82 + ], + "value": "number" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 33 + }, + "start": { + "line": 3, + "column": 32 + } + }, + "range": [ + 82, + 83 + ], + "value": "," + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 5, + "column": 3 + }, + "start": { + "line": 5, + "column": 2 + } + }, + "range": [ + 102, + 103 + ], + "value": "U" + }, + { + "type": "Keyword", + "loc": { + "end": { + "line": 6, + "column": 11 + }, + "start": { + "line": 6, + "column": 4 + } + }, + "range": [ + 122, + 129 + ], + "value": "extends" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 7, + "column": 10 + }, + "start": { + "line": 7, + "column": 4 + } + }, + "range": [ + 134, + 140 + ], + "value": "Record" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 7, + "column": 14 + }, + "start": { + "line": 7, + "column": 10 + } + }, + "range": [ + 140, + 144 + ], + "value": "<" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 9, + "column": 12 + }, + "start": { + "line": 9, + "column": 6 + } + }, + "range": [ + 165, + 171 + ], + "value": "string" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 9, + "column": 13 + }, + "start": { + "line": 9, + "column": 12 + } + }, + "range": [ + 171, + 172 + ], + "value": "," + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 10, + "column": 7 + }, + "start": { + "line": 10, + "column": 6 + } + }, + "range": [ + 184, + 185 + ], + "value": "T" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 11, + "column": 5 + }, + "start": { + "line": 11, + "column": 4 + } + }, + "range": [ + 190, + 191 + ], + "value": ">" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 12, + "column": 6 + }, + "start": { + "line": 12, + "column": 5 + } + }, + "range": [ + 197, + 198 + ], + "value": "=" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 12, + "column": 13 + }, + "start": { + "line": 12, + "column": 7 + } + }, + "range": [ + 199, + 205 + ], + "value": "Record" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 12, + "column": 14 + }, + "start": { + "line": 12, + "column": 13 + } + }, + "range": [ + 205, + 206 + ], + "value": "<" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 12, + "column": 20 + }, + "start": { + "line": 12, + "column": 14 + } + }, + "range": [ + 206, + 212 + ], + "value": "string" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 12, + "column": 21 + }, + "start": { + "line": 12, + "column": 20 + } + }, + "range": [ + 212, + 213 + ], + "value": "," + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 12, + "column": 28 + }, + "start": { + "line": 12, + "column": 22 + } + }, + "range": [ + 214, + 220 + ], + "value": "number" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 12, + "column": 32 + }, + "start": { + "line": 12, + "column": 28 + } + }, + "range": [ + 220, + 224 + ], + "value": ">" + }, + { + "type": "Punctuator", + "range": [ + 225, + 226 + ], + "loc": { + "start": { + "line": 13, + "column": 0 + }, + "end": { + "line": 13, + "column": 1 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 226, + 227 + ], + "loc": { + "start": { + "line": 13, + "column": 1 + }, + "end": { + "line": 13, + "column": 2 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 227, + 228 + ], + "loc": { + "start": { + "line": 13, + "column": 2 + }, + "end": { + "line": 14, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 228, + 232 + ], + "loc": { + "start": { + "line": 14, + "column": 0 + }, + "end": { + "line": 14, + "column": 4 + } + }, + "value": "type" + }, + { + "type": "HTMLWhitespace", + "range": [ + 232, + 233 + ], + "loc": { + "start": { + "line": 14, + "column": 4 + }, + "end": { + "line": 14, + "column": 5 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 233, + 236 + ], + "loc": { + "start": { + "line": 14, + "column": 5 + }, + "end": { + "line": 14, + "column": 8 + } + }, + "value": "Foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 236, + 237 + ], + "loc": { + "start": { + "line": 14, + "column": 8 + }, + "end": { + "line": 14, + "column": 9 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 237, + 238 + ], + "loc": { + "start": { + "line": 14, + "column": 9 + }, + "end": { + "line": 14, + "column": 10 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 238, + 239 + ], + "loc": { + "start": { + "line": 14, + "column": 10 + }, + "end": { + "line": 14, + "column": 11 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 239, + 245 + ], + "loc": { + "start": { + "line": 14, + "column": 11 + }, + "end": { + "line": 14, + "column": 17 + } + }, + "value": "number" + }, + { + "type": "HTMLWhitespace", + "range": [ + 245, + 246 + ], + "loc": { + "start": { + "line": 14, + "column": 17 + }, + "end": { + "line": 14, + "column": 18 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 246, + 247 + ], + "loc": { + "start": { + "line": 14, + "column": 18 + }, + "end": { + "line": 14, + "column": 19 + } + }, + "value": "|" + }, + { + "type": "HTMLWhitespace", + "range": [ + 247, + 248 + ], + "loc": { + "start": { + "line": 14, + "column": 19 + }, + "end": { + "line": 14, + "column": 20 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 248, + 254 + ], + "loc": { + "start": { + "line": 14, + "column": 20 + }, + "end": { + "line": 14, + "column": 26 + } + }, + "value": "string" + }, + { + "type": "HTMLWhitespace", + "range": [ + 254, + 255 + ], + "loc": { + "start": { + "line": 14, + "column": 26 + }, + "end": { + "line": 15, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 255, + 260 + ], + "loc": { + "start": { + "line": 15, + "column": 0 + }, + "end": { + "line": 15, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 260, + 261 + ], + "loc": { + "start": { + "line": 15, + "column": 5 + }, + "end": { + "line": 15, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 261, + 262 + ], + "loc": { + "start": { + "line": 15, + "column": 6 + }, + "end": { + "line": 15, + "column": 7 + } + }, + "value": "p" + }, + { + "type": "HTMLWhitespace", + "range": [ + 262, + 263 + ], + "loc": { + "start": { + "line": 15, + "column": 7 + }, + "end": { + "line": 15, + "column": 8 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 263, + 264 + ], + "loc": { + "start": { + "line": 15, + "column": 8 + }, + "end": { + "line": 15, + "column": 9 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 264, + 265 + ], + "loc": { + "start": { + "line": 15, + "column": 9 + }, + "end": { + "line": 15, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 265, + 284 + ], + "loc": { + "start": { + "line": 15, + "column": 10 + }, + "end": { + "line": 15, + "column": 29 + } + }, + "value": "defineProps<{foo:T," + }, + { + "type": "HTMLWhitespace", + "range": [ + 284, + 285 + ], + "loc": { + "start": { + "line": 15, + "column": 29 + }, + "end": { + "line": 15, + "column": 30 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 285, + 289 + ], + "loc": { + "start": { + "line": 15, + "column": 30 + }, + "end": { + "line": 15, + "column": 34 + } + }, + "value": "bar:" + }, + { + "type": "HTMLWhitespace", + "range": [ + 289, + 290 + ], + "loc": { + "start": { + "line": 15, + "column": 34 + }, + "end": { + "line": 15, + "column": 35 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 290, + 295 + ], + "loc": { + "start": { + "line": 15, + "column": 35 + }, + "end": { + "line": 15, + "column": 40 + } + }, + "value": "U}>()" + }, + { + "type": "HTMLWhitespace", + "range": [ + 295, + 296 + ], + "loc": { + "start": { + "line": 15, + "column": 40 + }, + "end": { + "line": 16, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 296, + 301 + ], + "loc": { + "start": { + "line": 16, + "column": 0 + }, + "end": { + "line": 16, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 301, + 302 + ], + "loc": { + "start": { + "line": 16, + "column": 5 + }, + "end": { + "line": 16, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 302, + 305 + ], + "loc": { + "start": { + "line": 16, + "column": 6 + }, + "end": { + "line": 16, + "column": 9 + } + }, + "value": "foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 305, + 306 + ], + "loc": { + "start": { + "line": 16, + "column": 9 + }, + "end": { + "line": 16, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 306, + 307 + ], + "loc": { + "start": { + "line": 16, + "column": 10 + }, + "end": { + "line": 16, + "column": 11 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 307, + 308 + ], + "loc": { + "start": { + "line": 16, + "column": 11 + }, + "end": { + "line": 16, + "column": 12 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 308, + 313 + ], + "loc": { + "start": { + "line": 16, + "column": 12 + }, + "end": { + "line": 16, + "column": 17 + } + }, + "value": "p.foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 313, + 314 + ], + "loc": { + "start": { + "line": 16, + "column": 17 + }, + "end": { + "line": 17, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 314, + 330 + ], + "loc": { + "start": { + "line": 17, + "column": 0 + }, + "end": { + "line": 17, + "column": 16 + } + }, + "value": "console.log(foo)" + }, + { + "type": "HTMLWhitespace", + "range": [ + 330, + 331 + ], + "loc": { + "start": { + "line": 17, + "column": 16 + }, + "end": { + "line": 18, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 331, + 339 + ], + "loc": { + "start": { + "line": 18, + "column": 0 + }, + "end": { + "line": 18, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 339, + 340 + ], + "loc": { + "start": { + "line": 18, + "column": 8 + }, + "end": { + "line": 18, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 340, + 341 + ], + "loc": { + "start": { + "line": 18, + "column": 9 + }, + "end": { + "line": 19, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 341, + 350 + ], + "loc": { + "start": { + "line": 19, + "column": 0 + }, + "end": { + "line": 19, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 350, + 351 + ], + "loc": { + "start": { + "line": 19, + "column": 9 + }, + "end": { + "line": 19, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 351, + 352 + ], + "loc": { + "start": { + "line": 19, + "column": 10 + }, + "end": { + "line": 20, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionStart", + "range": [ + 352, + 354 + ], + "loc": { + "start": { + "line": 20, + "column": 0 + }, + "end": { + "line": 20, + "column": 2 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 20, + "column": 5 + }, + "start": { + "line": 20, + "column": 2 + } + }, + "range": [ + 354, + 357 + ], + "value": "foo" + }, + { + "type": "VExpressionEnd", + "range": [ + 357, + 359 + ], + "loc": { + "start": { + "line": 20, + "column": 5 + }, + "end": { + "line": 20, + "column": 7 + } + }, + "value": "}}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 359, + 360 + ], + "loc": { + "start": { + "line": 20, + "column": 7 + }, + "end": { + "line": 21, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 360, + 370 + ], + "loc": { + "start": { + "line": 21, + "column": 0 + }, + "end": { + "line": 21, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 370, + 371 + ], + "loc": { + "start": { + "line": 21, + "column": 10 + }, + "end": { + "line": 21, + "column": 11 + } + }, + "value": "" + } + ], + "comments": [ + { + "type": "Line", + "loc": { + "end": { + "line": 2, + "column": 15 + }, + "start": { + "line": 2, + "column": 4 + } + }, + "range": [ + 38, + 49 + ], + "value": " Comments" + }, + { + "type": "Block", + "loc": { + "end": { + "line": 3, + "column": 19 + }, + "start": { + "line": 3, + "column": 12 + } + }, + "range": [ + 62, + 69 + ], + "value": " = " + }, + { + "type": "Line", + "loc": { + "end": { + "line": 4, + "column": 15 + }, + "start": { + "line": 4, + "column": 4 + } + }, + "range": [ + 88, + 99 + ], + "value": " Comments" + }, + { + "type": "Block", + "loc": { + "end": { + "line": 5, + "column": 17 + }, + "start": { + "line": 5, + "column": 4 + } + }, + "range": [ + 104, + 117 + ], + "value": " extends " + }, + { + "type": "Block", + "loc": { + "end": { + "line": 8, + "column": 13 + }, + "start": { + "line": 8, + "column": 6 + } + }, + "range": [ + 151, + 158 + ], + "value": " = " + }, + { + "type": "Line", + "loc": { + "end": { + "line": 9, + "column": 18 + }, + "start": { + "line": 9, + "column": 14 + } + }, + "range": [ + 173, + 177 + ], + "value": " =" + } + ], + "errors": [] + } + ], + "tokens": [ + { + "type": "HTMLTagOpen", + "range": [ + 0, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLIdentifier", + "range": [ + 8, + 13 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": "setup" + }, + { + "type": "HTMLIdentifier", + "range": [ + 14, + 18 + ], + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "value": "lang" + }, + { + "type": "HTMLAssociation", + "range": [ + 18, + 19 + ], + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "value": "" + }, + { + "type": "HTMLLiteral", + "range": [ + 19, + 23 + ], + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "value": "ts" + }, + { + "type": "HTMLIdentifier", + "range": [ + 24, + 31 + ], + "loc": { + "start": { + "column": 24, + "line": 1 + }, + "end": { + "column": 31, + "line": 1 + } + }, + "value": "generic" + }, + { + "type": "HTMLAssociation", + "range": [ + 31, + 32 + ], + "loc": { + "start": { + "line": 1, + "column": 31 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 32, + 33 + ], + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 2, + "column": 3 + }, + "start": { + "line": 2, + "column": 2 + } + }, + "range": [ + 36, + 37 + ], + "value": "T" + }, + { + "type": "Keyword", + "loc": { + "end": { + "line": 3, + "column": 11 + }, + "start": { + "line": 3, + "column": 4 + } + }, + "range": [ + 54, + 61 + ], + "value": "extends" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 3, + "column": 23 + }, + "start": { + "line": 3, + "column": 20 + } + }, + "range": [ + 70, + 73 + ], + "value": "Foo" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 25 + }, + "start": { + "line": 3, + "column": 24 + } + }, + "range": [ + 74, + 75 + ], + "value": "=" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 3, + "column": 32 + }, + "start": { + "line": 3, + "column": 26 + } + }, + "range": [ + 76, + 82 + ], + "value": "number" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 33 + }, + "start": { + "line": 3, + "column": 32 + } + }, + "range": [ + 82, + 83 + ], + "value": "," + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 5, + "column": 3 + }, + "start": { + "line": 5, + "column": 2 + } + }, + "range": [ + 102, + 103 + ], + "value": "U" + }, + { + "type": "Keyword", + "loc": { + "end": { + "line": 6, + "column": 11 + }, + "start": { + "line": 6, + "column": 4 + } + }, + "range": [ + 122, + 129 + ], + "value": "extends" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 7, + "column": 10 + }, + "start": { + "line": 7, + "column": 4 + } + }, + "range": [ + 134, + 140 + ], + "value": "Record" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 7, + "column": 14 + }, + "start": { + "line": 7, + "column": 10 + } + }, + "range": [ + 140, + 144 + ], + "value": "<" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 9, + "column": 12 + }, + "start": { + "line": 9, + "column": 6 + } + }, + "range": [ + 165, + 171 + ], + "value": "string" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 9, + "column": 13 + }, + "start": { + "line": 9, + "column": 12 + } + }, + "range": [ + 171, + 172 + ], + "value": "," + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 10, + "column": 7 + }, + "start": { + "line": 10, + "column": 6 + } + }, + "range": [ + 184, + 185 + ], + "value": "T" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 11, + "column": 5 + }, + "start": { + "line": 11, + "column": 4 + } + }, + "range": [ + 190, + 191 + ], + "value": ">" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 12, + "column": 6 + }, + "start": { + "line": 12, + "column": 5 + } + }, + "range": [ + 197, + 198 + ], + "value": "=" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 12, + "column": 13 + }, + "start": { + "line": 12, + "column": 7 + } + }, + "range": [ + 199, + 205 + ], + "value": "Record" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 12, + "column": 14 + }, + "start": { + "line": 12, + "column": 13 + } + }, + "range": [ + 205, + 206 + ], + "value": "<" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 12, + "column": 20 + }, + "start": { + "line": 12, + "column": 14 + } + }, + "range": [ + 206, + 212 + ], + "value": "string" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 12, + "column": 21 + }, + "start": { + "line": 12, + "column": 20 + } + }, + "range": [ + 212, + 213 + ], + "value": "," + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 12, + "column": 28 + }, + "start": { + "line": 12, + "column": 22 + } + }, + "range": [ + 214, + 220 + ], + "value": "number" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 12, + "column": 32 + }, + "start": { + "line": 12, + "column": 28 + } + }, + "range": [ + 220, + 224 + ], + "value": ">" + }, + { + "type": "Punctuator", + "range": [ + 225, + 226 + ], + "loc": { + "start": { + "line": 13, + "column": 0 + }, + "end": { + "line": 13, + "column": 1 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 226, + 227 + ], + "loc": { + "start": { + "line": 13, + "column": 1 + }, + "end": { + "line": 13, + "column": 2 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 227, + 228 + ], + "loc": { + "start": { + "line": 13, + "column": 2 + }, + "end": { + "line": 14, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 228, + 232 + ], + "loc": { + "start": { + "line": 14, + "column": 0 + }, + "end": { + "line": 14, + "column": 4 + } + }, + "value": "type" + }, + { + "type": "HTMLWhitespace", + "range": [ + 232, + 233 + ], + "loc": { + "start": { + "line": 14, + "column": 4 + }, + "end": { + "line": 14, + "column": 5 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 233, + 236 + ], + "loc": { + "start": { + "line": 14, + "column": 5 + }, + "end": { + "line": 14, + "column": 8 + } + }, + "value": "Foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 236, + 237 + ], + "loc": { + "start": { + "line": 14, + "column": 8 + }, + "end": { + "line": 14, + "column": 9 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 237, + 238 + ], + "loc": { + "start": { + "line": 14, + "column": 9 + }, + "end": { + "line": 14, + "column": 10 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 238, + 239 + ], + "loc": { + "start": { + "line": 14, + "column": 10 + }, + "end": { + "line": 14, + "column": 11 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 239, + 245 + ], + "loc": { + "start": { + "line": 14, + "column": 11 + }, + "end": { + "line": 14, + "column": 17 + } + }, + "value": "number" + }, + { + "type": "HTMLWhitespace", + "range": [ + 245, + 246 + ], + "loc": { + "start": { + "line": 14, + "column": 17 + }, + "end": { + "line": 14, + "column": 18 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 246, + 247 + ], + "loc": { + "start": { + "line": 14, + "column": 18 + }, + "end": { + "line": 14, + "column": 19 + } + }, + "value": "|" + }, + { + "type": "HTMLWhitespace", + "range": [ + 247, + 248 + ], + "loc": { + "start": { + "line": 14, + "column": 19 + }, + "end": { + "line": 14, + "column": 20 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 248, + 254 + ], + "loc": { + "start": { + "line": 14, + "column": 20 + }, + "end": { + "line": 14, + "column": 26 + } + }, + "value": "string" + }, + { + "type": "HTMLWhitespace", + "range": [ + 254, + 255 + ], + "loc": { + "start": { + "line": 14, + "column": 26 + }, + "end": { + "line": 15, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 255, + 260 + ], + "loc": { + "start": { + "line": 15, + "column": 0 + }, + "end": { + "line": 15, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 260, + 261 + ], + "loc": { + "start": { + "line": 15, + "column": 5 + }, + "end": { + "line": 15, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 261, + 262 + ], + "loc": { + "start": { + "line": 15, + "column": 6 + }, + "end": { + "line": 15, + "column": 7 + } + }, + "value": "p" + }, + { + "type": "HTMLWhitespace", + "range": [ + 262, + 263 + ], + "loc": { + "start": { + "line": 15, + "column": 7 + }, + "end": { + "line": 15, + "column": 8 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 263, + 264 + ], + "loc": { + "start": { + "line": 15, + "column": 8 + }, + "end": { + "line": 15, + "column": 9 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 264, + 265 + ], + "loc": { + "start": { + "line": 15, + "column": 9 + }, + "end": { + "line": 15, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 265, + 284 + ], + "loc": { + "start": { + "line": 15, + "column": 10 + }, + "end": { + "line": 15, + "column": 29 + } + }, + "value": "defineProps<{foo:T," + }, + { + "type": "HTMLWhitespace", + "range": [ + 284, + 285 + ], + "loc": { + "start": { + "line": 15, + "column": 29 + }, + "end": { + "line": 15, + "column": 30 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 285, + 289 + ], + "loc": { + "start": { + "line": 15, + "column": 30 + }, + "end": { + "line": 15, + "column": 34 + } + }, + "value": "bar:" + }, + { + "type": "HTMLWhitespace", + "range": [ + 289, + 290 + ], + "loc": { + "start": { + "line": 15, + "column": 34 + }, + "end": { + "line": 15, + "column": 35 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 290, + 295 + ], + "loc": { + "start": { + "line": 15, + "column": 35 + }, + "end": { + "line": 15, + "column": 40 + } + }, + "value": "U}>()" + }, + { + "type": "HTMLWhitespace", + "range": [ + 295, + 296 + ], + "loc": { + "start": { + "line": 15, + "column": 40 + }, + "end": { + "line": 16, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 296, + 301 + ], + "loc": { + "start": { + "line": 16, + "column": 0 + }, + "end": { + "line": 16, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 301, + 302 + ], + "loc": { + "start": { + "line": 16, + "column": 5 + }, + "end": { + "line": 16, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 302, + 305 + ], + "loc": { + "start": { + "line": 16, + "column": 6 + }, + "end": { + "line": 16, + "column": 9 + } + }, + "value": "foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 305, + 306 + ], + "loc": { + "start": { + "line": 16, + "column": 9 + }, + "end": { + "line": 16, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 306, + 307 + ], + "loc": { + "start": { + "line": 16, + "column": 10 + }, + "end": { + "line": 16, + "column": 11 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 307, + 308 + ], + "loc": { + "start": { + "line": 16, + "column": 11 + }, + "end": { + "line": 16, + "column": 12 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 308, + 313 + ], + "loc": { + "start": { + "line": 16, + "column": 12 + }, + "end": { + "line": 16, + "column": 17 + } + }, + "value": "p.foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 313, + 314 + ], + "loc": { + "start": { + "line": 16, + "column": 17 + }, + "end": { + "line": 17, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 314, + 330 + ], + "loc": { + "start": { + "line": 17, + "column": 0 + }, + "end": { + "line": 17, + "column": 16 + } + }, + "value": "console.log(foo)" + }, + { + "type": "HTMLWhitespace", + "range": [ + 330, + 331 + ], + "loc": { + "start": { + "line": 17, + "column": 16 + }, + "end": { + "line": 18, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 331, + 339 + ], + "loc": { + "start": { + "line": 18, + "column": 0 + }, + "end": { + "line": 18, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 339, + 340 + ], + "loc": { + "start": { + "line": 18, + "column": 8 + }, + "end": { + "line": 18, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 340, + 341 + ], + "loc": { + "start": { + "line": 18, + "column": 9 + }, + "end": { + "line": 19, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 341, + 350 + ], + "loc": { + "start": { + "line": 19, + "column": 0 + }, + "end": { + "line": 19, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 350, + 351 + ], + "loc": { + "start": { + "line": 19, + "column": 9 + }, + "end": { + "line": 19, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 351, + 352 + ], + "loc": { + "start": { + "line": 19, + "column": 10 + }, + "end": { + "line": 20, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionStart", + "range": [ + 352, + 354 + ], + "loc": { + "start": { + "line": 20, + "column": 0 + }, + "end": { + "line": 20, + "column": 2 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 20, + "column": 5 + }, + "start": { + "line": 20, + "column": 2 + } + }, + "range": [ + 354, + 357 + ], + "value": "foo" + }, + { + "type": "VExpressionEnd", + "range": [ + 357, + 359 + ], + "loc": { + "start": { + "line": 20, + "column": 5 + }, + "end": { + "line": 20, + "column": 7 + } + }, + "value": "}}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 359, + 360 + ], + "loc": { + "start": { + "line": 20, + "column": 7 + }, + "end": { + "line": 21, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 360, + 370 + ], + "loc": { + "start": { + "line": 21, + "column": 0 + }, + "end": { + "line": 21, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 370, + 371 + ], + "loc": { + "start": { + "line": 21, + "column": 10 + }, + "end": { + "line": 21, + "column": 11 + } + }, + "value": "" + } + ], + "comments": [ + { + "type": "Line", + "loc": { + "end": { + "line": 2, + "column": 15 + }, + "start": { + "line": 2, + "column": 4 + } + }, + "range": [ + 38, + 49 + ], + "value": " Comments" + }, + { + "type": "Block", + "loc": { + "end": { + "line": 3, + "column": 19 + }, + "start": { + "line": 3, + "column": 12 + } + }, + "range": [ + 62, + 69 + ], + "value": " = " + }, + { + "type": "Line", + "loc": { + "end": { + "line": 4, + "column": 15 + }, + "start": { + "line": 4, + "column": 4 + } + }, + "range": [ + 88, + 99 + ], + "value": " Comments" + }, + { + "type": "Block", + "loc": { + "end": { + "line": 5, + "column": 17 + }, + "start": { + "line": 5, + "column": 4 + } + }, + "range": [ + 104, + 117 + ], + "value": " extends " + }, + { + "type": "Block", + "loc": { + "end": { + "line": 8, + "column": 13 + }, + "start": { + "line": 8, + "column": 6 + } + }, + "range": [ + 151, + 158 + ], + "value": " = " + }, + { + "type": "Line", + "loc": { + "end": { + "line": 9, + "column": 18 + }, + "start": { + "line": 9, + "column": 14 + } + }, + "range": [ + 173, + 177 + ], + "value": " =" + } + ], + "errors": [] +} \ No newline at end of file diff --git a/test/fixtures/document-fragment/vue3.3-generic-6-with-default/parser-options.json b/test/fixtures/document-fragment/vue3.3-generic-6-with-default/parser-options.json new file mode 100644 index 00000000..0ead30e9 --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-6-with-default/parser-options.json @@ -0,0 +1,6 @@ +{ + "sourceType": "module", + "parser": { + "ts": "@typescript-eslint/parser" + } +} diff --git a/test/fixtures/document-fragment/vue3.3-generic-6-with-default/source.vue b/test/fixtures/document-fragment/vue3.3-generic-6-with-default/source.vue new file mode 100644 index 00000000..a0ad29c8 --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-6-with-default/source.vue @@ -0,0 +1,21 @@ + + \ No newline at end of file diff --git a/test/fixtures/document-fragment/vue3.3-generic-6-with-default/token-ranges.json b/test/fixtures/document-fragment/vue3.3-generic-6-with-default/token-ranges.json new file mode 100644 index 00000000..38d59219 --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-6-with-default/token-ranges.json @@ -0,0 +1,86 @@ +[ + "", + "=", + "Record", + "<", + "string", + ",", + "number", + ">", + "\"", + ">", + "\n", + "type", + " ", + "Foo", + " ", + "=", + " ", + "number", + " ", + "|", + " ", + "string", + "\n", + "const", + " ", + "p", + " ", + "=", + " ", + "defineProps<{foo:T,", + " ", + "bar:", + " ", + "U}>()", + "\n", + "const", + " ", + "foo", + " ", + "=", + " ", + "p.foo", + "\n", + "console.log(foo)", + "\n", + "", + "\n", + "", + "\n", + "{{", + "foo", + "}}", + "\n", + "", + "// Comments", + "/* = */", + "// Comments", + "/* extends */", + "/* = */", + "// =" +] \ No newline at end of file diff --git a/test/fixtures/document-fragment/vue3.3-generic-6-with-default/tree.json b/test/fixtures/document-fragment/vue3.3-generic-6-with-default/tree.json new file mode 100644 index 00000000..ab3eb2d9 --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-6-with-default/tree.json @@ -0,0 +1,226 @@ +[ + { + "type": "VDocumentFragment", + "text": "\n", + "children": [ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + }, + { + "type": "VText", + "text": "\n", + "children": [] + }, + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/document-fragment/vue3.3-generic-7-with-arrow/document-fragment.json b/test/fixtures/document-fragment/vue3.3-generic-7-with-arrow/document-fragment.json new file mode 100644 index 00000000..15d9ad50 --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-7-with-arrow/document-fragment.json @@ -0,0 +1,3384 @@ +{ + "type": "VDocumentFragment", + "range": [ + 0, + 194 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 11, + "column": 11 + } + }, + "children": [ + { + "type": "VElement", + "range": [ + 0, + 150 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 6, + "column": 9 + } + }, + "name": "script", + "rawName": "script", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 0, + 102 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 2 + } + }, + "selfClosing": false, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 8, + 13 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "directive": false, + "key": { + "type": "VIdentifier", + "range": [ + 8, + 13 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "name": "setup", + "rawName": "setup" + }, + "value": null + }, + { + "type": "VAttribute", + "range": [ + 14, + 23 + ], + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "directive": false, + "key": { + "type": "VIdentifier", + "range": [ + 14, + 18 + ], + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "name": "lang", + "rawName": "lang" + }, + "value": { + "type": "VLiteral", + "range": [ + 19, + 23 + ], + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "value": "ts" + } + }, + { + "type": "VAttribute", + "range": [ + 24, + 101 + ], + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "directive": true, + "key": { + "type": "VDirectiveKey", + "range": [ + 24, + 31 + ], + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "name": { + "type": "VIdentifier", + "range": [ + 24, + 31 + ], + "loc": { + "start": { + "column": 24, + "line": 1 + }, + "end": { + "column": 31, + "line": 1 + } + }, + "name": "generic", + "rawName": "generic" + }, + "argument": null, + "modifiers": [] + }, + "value": { + "type": "VExpressionContainer", + "range": [ + 32, + 101 + ], + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "expression": { + "type": "VGenericExpression", + "range": [ + 36, + 99 + ], + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 3, + "column": 39 + } + }, + "params": [ + { + "type": "TSTypeParameter", + "const": false, + "constraint": { + "type": "TSFunctionType", + "params": [], + "returnType": { + "type": "TSTypeAnnotation", + "loc": { + "end": { + "line": 2, + "column": 24 + }, + "start": { + "line": 2, + "column": 15 + } + }, + "range": [ + 49, + 58 + ], + "typeAnnotation": { + "type": "TSStringKeyword", + "range": [ + 52, + 58 + ], + "loc": { + "end": { + "line": 2, + "column": 24 + }, + "start": { + "line": 2, + "column": 18 + } + } + } + }, + "range": [ + 46, + 58 + ], + "loc": { + "end": { + "line": 2, + "column": 24 + }, + "start": { + "line": 2, + "column": 12 + } + } + }, + "in": false, + "name": { + "type": "Identifier", + "decorators": [], + "name": "T", + "optional": false, + "range": [ + 36, + 37 + ], + "loc": { + "end": { + "line": 2, + "column": 3 + }, + "start": { + "line": 2, + "column": 2 + } + } + }, + "out": false, + "range": [ + 36, + 58 + ], + "loc": { + "end": { + "line": 2, + "column": 24 + }, + "start": { + "line": 2, + "column": 2 + } + } + }, + { + "type": "TSTypeParameter", + "const": false, + "constraint": { + "type": "TSFunctionType", + "params": [], + "returnType": { + "type": "TSTypeAnnotation", + "loc": { + "end": { + "line": 3, + "column": 25 + }, + "start": { + "line": 3, + "column": 16 + } + }, + "range": [ + 76, + 85 + ], + "typeAnnotation": { + "type": "TSStringKeyword", + "range": [ + 79, + 85 + ], + "loc": { + "end": { + "line": 3, + "column": 25 + }, + "start": { + "line": 3, + "column": 19 + } + } + } + }, + "range": [ + 73, + 85 + ], + "loc": { + "end": { + "line": 3, + "column": 25 + }, + "start": { + "line": 3, + "column": 13 + } + } + }, + "default": { + "type": "TSFunctionType", + "params": [], + "returnType": { + "type": "TSTypeAnnotation", + "loc": { + "end": { + "line": 3, + "column": 39 + }, + "start": { + "line": 3, + "column": 31 + } + }, + "range": [ + 91, + 99 + ], + "typeAnnotation": { + "type": "TSLiteralType", + "literal": { + "type": "Literal", + "raw": "'abc'", + "value": "abc", + "range": [ + 94, + 99 + ], + "loc": { + "end": { + "line": 3, + "column": 39 + }, + "start": { + "line": 3, + "column": 34 + } + } + }, + "range": [ + 94, + 99 + ], + "loc": { + "end": { + "line": 3, + "column": 39 + }, + "start": { + "line": 3, + "column": 34 + } + } + } + }, + "range": [ + 88, + 99 + ], + "loc": { + "end": { + "line": 3, + "column": 39 + }, + "start": { + "line": 3, + "column": 28 + } + } + }, + "in": false, + "name": { + "type": "Identifier", + "decorators": [], + "name": "U", + "optional": false, + "range": [ + 62, + 63 + ], + "loc": { + "end": { + "line": 3, + "column": 3 + }, + "start": { + "line": 3, + "column": 2 + } + } + }, + "out": false, + "range": [ + 62, + 99 + ], + "loc": { + "end": { + "line": 3, + "column": 39 + }, + "start": { + "line": 3, + "column": 2 + } + } + } + ], + "rawParams": [ + "T extends () => string", + "U extends () => string = () => 'abc'" + ] + }, + "references": [] + } + } + ] + }, + "children": [ + { + "type": "VText", + "range": [ + 102, + 141 + ], + "loc": { + "start": { + "line": 4, + "column": 2 + }, + "end": { + "line": 6, + "column": 0 + } + }, + "value": "\nconst p = defineProps<{t: T, u: U}>()\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 141, + 150 + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 9 + } + } + }, + "variables": [ + { + "id": { + "type": "Identifier", + "decorators": [], + "name": "T", + "optional": false, + "range": [ + 36, + 37 + ], + "loc": { + "end": { + "line": 2, + "column": 3 + }, + "start": { + "line": 2, + "column": 2 + } + } + }, + "kind": "generic" + }, + { + "id": { + "type": "Identifier", + "decorators": [], + "name": "U", + "optional": false, + "range": [ + 62, + 63 + ], + "loc": { + "end": { + "line": 3, + "column": 3 + }, + "start": { + "line": 3, + "column": 2 + } + } + }, + "kind": "generic" + } + ] + }, + { + "type": "VText", + "range": [ + 150, + 152 + ], + "loc": { + "start": { + "line": 6, + "column": 9 + }, + "end": { + "line": 8, + "column": 0 + } + }, + "value": "\n\n" + }, + { + "type": "VElement", + "range": [ + 152, + 194 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 11, + "column": 11 + } + }, + "name": "template", + "rawName": "template", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 152, + 162 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 10 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 162, + 163 + ], + "loc": { + "start": { + "line": 8, + "column": 10 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionContainer", + "range": [ + 163, + 172 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 9 + } + }, + "expression": { + "type": "CallExpression", + "arguments": [], + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "decorators": [], + "name": "p", + "optional": false, + "range": [ + 165, + 166 + ], + "loc": { + "end": { + "line": 9, + "column": 3 + }, + "start": { + "line": 9, + "column": 2 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "decorators": [], + "name": "t", + "optional": false, + "range": [ + 167, + 168 + ], + "loc": { + "end": { + "line": 9, + "column": 5 + }, + "start": { + "line": 9, + "column": 4 + } + } + }, + "range": [ + 165, + 168 + ], + "loc": { + "end": { + "line": 9, + "column": 5 + }, + "start": { + "line": 9, + "column": 2 + } + } + }, + "optional": false, + "range": [ + 165, + 170 + ], + "loc": { + "end": { + "line": 9, + "column": 7 + }, + "start": { + "line": 9, + "column": 2 + } + } + }, + "references": [ + { + "id": { + "type": "Identifier", + "decorators": [], + "name": "p", + "optional": false, + "range": [ + 165, + 166 + ], + "loc": { + "end": { + "line": 9, + "column": 3 + }, + "start": { + "line": 9, + "column": 2 + } + } + }, + "mode": "r", + "isValueReference": true, + "isTypeReference": false + } + ] + }, + { + "type": "VText", + "range": [ + 172, + 173 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 10, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionContainer", + "range": [ + 173, + 182 + ], + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 9 + } + }, + "expression": { + "type": "CallExpression", + "arguments": [], + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "decorators": [], + "name": "p", + "optional": false, + "range": [ + 175, + 176 + ], + "loc": { + "end": { + "line": 10, + "column": 3 + }, + "start": { + "line": 10, + "column": 2 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "decorators": [], + "name": "u", + "optional": false, + "range": [ + 177, + 178 + ], + "loc": { + "end": { + "line": 10, + "column": 5 + }, + "start": { + "line": 10, + "column": 4 + } + } + }, + "range": [ + 175, + 178 + ], + "loc": { + "end": { + "line": 10, + "column": 5 + }, + "start": { + "line": 10, + "column": 2 + } + } + }, + "optional": false, + "range": [ + 175, + 180 + ], + "loc": { + "end": { + "line": 10, + "column": 7 + }, + "start": { + "line": 10, + "column": 2 + } + } + }, + "references": [ + { + "id": { + "type": "Identifier", + "decorators": [], + "name": "p", + "optional": false, + "range": [ + 175, + 176 + ], + "loc": { + "end": { + "line": 10, + "column": 3 + }, + "start": { + "line": 10, + "column": 2 + } + } + }, + "mode": "r", + "isValueReference": true, + "isTypeReference": false + } + ] + }, + { + "type": "VText", + "range": [ + 182, + 183 + ], + "loc": { + "start": { + "line": 10, + "column": 9 + }, + "end": { + "line": 11, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 183, + 194 + ], + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 11 + } + } + }, + "variables": [], + "tokens": [ + { + "type": "HTMLTagOpen", + "range": [ + 0, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLIdentifier", + "range": [ + 8, + 13 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": "setup" + }, + { + "type": "HTMLIdentifier", + "range": [ + 14, + 18 + ], + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "value": "lang" + }, + { + "type": "HTMLAssociation", + "range": [ + 18, + 19 + ], + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "value": "" + }, + { + "type": "HTMLLiteral", + "range": [ + 19, + 23 + ], + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "value": "ts" + }, + { + "type": "HTMLIdentifier", + "range": [ + 24, + 31 + ], + "loc": { + "start": { + "column": 24, + "line": 1 + }, + "end": { + "column": 31, + "line": 1 + } + }, + "value": "generic" + }, + { + "type": "HTMLAssociation", + "range": [ + 31, + 32 + ], + "loc": { + "start": { + "line": 1, + "column": 31 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 32, + 33 + ], + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 2, + "column": 3 + }, + "start": { + "line": 2, + "column": 2 + } + }, + "range": [ + 36, + 37 + ], + "value": "T" + }, + { + "type": "Keyword", + "loc": { + "end": { + "line": 2, + "column": 11 + }, + "start": { + "line": 2, + "column": 4 + } + }, + "range": [ + 38, + 45 + ], + "value": "extends" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 2, + "column": 13 + }, + "start": { + "line": 2, + "column": 12 + } + }, + "range": [ + 46, + 47 + ], + "value": "(" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 2, + "column": 14 + }, + "start": { + "line": 2, + "column": 13 + } + }, + "range": [ + 47, + 48 + ], + "value": ")" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 2, + "column": 17 + }, + "start": { + "line": 2, + "column": 15 + } + }, + "range": [ + 49, + 51 + ], + "value": "=>" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 2, + "column": 24 + }, + "start": { + "line": 2, + "column": 18 + } + }, + "range": [ + 52, + 58 + ], + "value": "string" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 2, + "column": 25 + }, + "start": { + "line": 2, + "column": 24 + } + }, + "range": [ + 58, + 59 + ], + "value": "," + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 3, + "column": 3 + }, + "start": { + "line": 3, + "column": 2 + } + }, + "range": [ + 62, + 63 + ], + "value": "U" + }, + { + "type": "Keyword", + "loc": { + "end": { + "line": 3, + "column": 12 + }, + "start": { + "line": 3, + "column": 5 + } + }, + "range": [ + 65, + 72 + ], + "value": "extends" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 14 + }, + "start": { + "line": 3, + "column": 13 + } + }, + "range": [ + 73, + 74 + ], + "value": "(" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 15 + }, + "start": { + "line": 3, + "column": 14 + } + }, + "range": [ + 74, + 75 + ], + "value": ")" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 18 + }, + "start": { + "line": 3, + "column": 16 + } + }, + "range": [ + 76, + 78 + ], + "value": "=>" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 3, + "column": 25 + }, + "start": { + "line": 3, + "column": 19 + } + }, + "range": [ + 79, + 85 + ], + "value": "string" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 27 + }, + "start": { + "line": 3, + "column": 26 + } + }, + "range": [ + 86, + 87 + ], + "value": "=" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 29 + }, + "start": { + "line": 3, + "column": 28 + } + }, + "range": [ + 88, + 89 + ], + "value": "(" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 30 + }, + "start": { + "line": 3, + "column": 29 + } + }, + "range": [ + 89, + 90 + ], + "value": ")" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 33 + }, + "start": { + "line": 3, + "column": 31 + } + }, + "range": [ + 91, + 93 + ], + "value": "=>" + }, + { + "type": "String", + "loc": { + "end": { + "line": 3, + "column": 39 + }, + "start": { + "line": 3, + "column": 34 + } + }, + "range": [ + 94, + 99 + ], + "value": "'abc'" + }, + { + "type": "Punctuator", + "range": [ + 100, + 101 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 101, + 102 + ], + "loc": { + "start": { + "line": 4, + "column": 1 + }, + "end": { + "line": 4, + "column": 2 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 102, + 103 + ], + "loc": { + "start": { + "line": 4, + "column": 2 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 103, + 108 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 108, + 109 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 109, + 110 + ], + "loc": { + "start": { + "line": 5, + "column": 6 + }, + "end": { + "line": 5, + "column": 7 + } + }, + "value": "p" + }, + { + "type": "HTMLWhitespace", + "range": [ + 110, + 111 + ], + "loc": { + "start": { + "line": 5, + "column": 7 + }, + "end": { + "line": 5, + "column": 8 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 111, + 112 + ], + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 9 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 112, + 113 + ], + "loc": { + "start": { + "line": 5, + "column": 9 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 113, + 128 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 25 + } + }, + "value": "defineProps<{t:" + }, + { + "type": "HTMLWhitespace", + "range": [ + 128, + 129 + ], + "loc": { + "start": { + "line": 5, + "column": 25 + }, + "end": { + "line": 5, + "column": 26 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 129, + 131 + ], + "loc": { + "start": { + "line": 5, + "column": 26 + }, + "end": { + "line": 5, + "column": 28 + } + }, + "value": "T," + }, + { + "type": "HTMLWhitespace", + "range": [ + 131, + 132 + ], + "loc": { + "start": { + "line": 5, + "column": 28 + }, + "end": { + "line": 5, + "column": 29 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 132, + 134 + ], + "loc": { + "start": { + "line": 5, + "column": 29 + }, + "end": { + "line": 5, + "column": 31 + } + }, + "value": "u:" + }, + { + "type": "HTMLWhitespace", + "range": [ + 134, + 135 + ], + "loc": { + "start": { + "line": 5, + "column": 31 + }, + "end": { + "line": 5, + "column": 32 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 135, + 140 + ], + "loc": { + "start": { + "line": 5, + "column": 32 + }, + "end": { + "line": 5, + "column": 37 + } + }, + "value": "U}>()" + }, + { + "type": "HTMLWhitespace", + "range": [ + 140, + 141 + ], + "loc": { + "start": { + "line": 5, + "column": 37 + }, + "end": { + "line": 6, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 141, + 149 + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 149, + 150 + ], + "loc": { + "start": { + "line": 6, + "column": 8 + }, + "end": { + "line": 6, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 150, + 152 + ], + "loc": { + "start": { + "line": 6, + "column": 9 + }, + "end": { + "line": 8, + "column": 0 + } + }, + "value": "\n\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 152, + 161 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 161, + 162 + ], + "loc": { + "start": { + "line": 8, + "column": 9 + }, + "end": { + "line": 8, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 162, + 163 + ], + "loc": { + "start": { + "line": 8, + "column": 10 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionStart", + "range": [ + 163, + 165 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 2 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 9, + "column": 3 + }, + "start": { + "line": 9, + "column": 2 + } + }, + "range": [ + 165, + 166 + ], + "value": "p" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 9, + "column": 4 + }, + "start": { + "line": 9, + "column": 3 + } + }, + "range": [ + 166, + 167 + ], + "value": "." + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 9, + "column": 5 + }, + "start": { + "line": 9, + "column": 4 + } + }, + "range": [ + 167, + 168 + ], + "value": "t" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 9, + "column": 6 + }, + "start": { + "line": 9, + "column": 5 + } + }, + "range": [ + 168, + 169 + ], + "value": "(" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 9, + "column": 7 + }, + "start": { + "line": 9, + "column": 6 + } + }, + "range": [ + 169, + 170 + ], + "value": ")" + }, + { + "type": "VExpressionEnd", + "range": [ + 170, + 172 + ], + "loc": { + "start": { + "line": 9, + "column": 7 + }, + "end": { + "line": 9, + "column": 9 + } + }, + "value": "}}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 172, + 173 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 10, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionStart", + "range": [ + 173, + 175 + ], + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 2 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 10, + "column": 3 + }, + "start": { + "line": 10, + "column": 2 + } + }, + "range": [ + 175, + 176 + ], + "value": "p" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 10, + "column": 4 + }, + "start": { + "line": 10, + "column": 3 + } + }, + "range": [ + 176, + 177 + ], + "value": "." + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 10, + "column": 5 + }, + "start": { + "line": 10, + "column": 4 + } + }, + "range": [ + 177, + 178 + ], + "value": "u" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 10, + "column": 6 + }, + "start": { + "line": 10, + "column": 5 + } + }, + "range": [ + 178, + 179 + ], + "value": "(" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 10, + "column": 7 + }, + "start": { + "line": 10, + "column": 6 + } + }, + "range": [ + 179, + 180 + ], + "value": ")" + }, + { + "type": "VExpressionEnd", + "range": [ + 180, + 182 + ], + "loc": { + "start": { + "line": 10, + "column": 7 + }, + "end": { + "line": 10, + "column": 9 + } + }, + "value": "}}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 182, + 183 + ], + "loc": { + "start": { + "line": 10, + "column": 9 + }, + "end": { + "line": 11, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 183, + 193 + ], + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 193, + 194 + ], + "loc": { + "start": { + "line": 11, + "column": 10 + }, + "end": { + "line": 11, + "column": 11 + } + }, + "value": "" + } + ], + "comments": [], + "errors": [] + } + ], + "tokens": [ + { + "type": "HTMLTagOpen", + "range": [ + 0, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLIdentifier", + "range": [ + 8, + 13 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": "setup" + }, + { + "type": "HTMLIdentifier", + "range": [ + 14, + 18 + ], + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "value": "lang" + }, + { + "type": "HTMLAssociation", + "range": [ + 18, + 19 + ], + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "value": "" + }, + { + "type": "HTMLLiteral", + "range": [ + 19, + 23 + ], + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "value": "ts" + }, + { + "type": "HTMLIdentifier", + "range": [ + 24, + 31 + ], + "loc": { + "start": { + "column": 24, + "line": 1 + }, + "end": { + "column": 31, + "line": 1 + } + }, + "value": "generic" + }, + { + "type": "HTMLAssociation", + "range": [ + 31, + 32 + ], + "loc": { + "start": { + "line": 1, + "column": 31 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 32, + 33 + ], + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 2, + "column": 3 + }, + "start": { + "line": 2, + "column": 2 + } + }, + "range": [ + 36, + 37 + ], + "value": "T" + }, + { + "type": "Keyword", + "loc": { + "end": { + "line": 2, + "column": 11 + }, + "start": { + "line": 2, + "column": 4 + } + }, + "range": [ + 38, + 45 + ], + "value": "extends" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 2, + "column": 13 + }, + "start": { + "line": 2, + "column": 12 + } + }, + "range": [ + 46, + 47 + ], + "value": "(" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 2, + "column": 14 + }, + "start": { + "line": 2, + "column": 13 + } + }, + "range": [ + 47, + 48 + ], + "value": ")" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 2, + "column": 17 + }, + "start": { + "line": 2, + "column": 15 + } + }, + "range": [ + 49, + 51 + ], + "value": "=>" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 2, + "column": 24 + }, + "start": { + "line": 2, + "column": 18 + } + }, + "range": [ + 52, + 58 + ], + "value": "string" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 2, + "column": 25 + }, + "start": { + "line": 2, + "column": 24 + } + }, + "range": [ + 58, + 59 + ], + "value": "," + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 3, + "column": 3 + }, + "start": { + "line": 3, + "column": 2 + } + }, + "range": [ + 62, + 63 + ], + "value": "U" + }, + { + "type": "Keyword", + "loc": { + "end": { + "line": 3, + "column": 12 + }, + "start": { + "line": 3, + "column": 5 + } + }, + "range": [ + 65, + 72 + ], + "value": "extends" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 14 + }, + "start": { + "line": 3, + "column": 13 + } + }, + "range": [ + 73, + 74 + ], + "value": "(" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 15 + }, + "start": { + "line": 3, + "column": 14 + } + }, + "range": [ + 74, + 75 + ], + "value": ")" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 18 + }, + "start": { + "line": 3, + "column": 16 + } + }, + "range": [ + 76, + 78 + ], + "value": "=>" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 3, + "column": 25 + }, + "start": { + "line": 3, + "column": 19 + } + }, + "range": [ + 79, + 85 + ], + "value": "string" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 27 + }, + "start": { + "line": 3, + "column": 26 + } + }, + "range": [ + 86, + 87 + ], + "value": "=" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 29 + }, + "start": { + "line": 3, + "column": 28 + } + }, + "range": [ + 88, + 89 + ], + "value": "(" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 30 + }, + "start": { + "line": 3, + "column": 29 + } + }, + "range": [ + 89, + 90 + ], + "value": ")" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 33 + }, + "start": { + "line": 3, + "column": 31 + } + }, + "range": [ + 91, + 93 + ], + "value": "=>" + }, + { + "type": "String", + "loc": { + "end": { + "line": 3, + "column": 39 + }, + "start": { + "line": 3, + "column": 34 + } + }, + "range": [ + 94, + 99 + ], + "value": "'abc'" + }, + { + "type": "Punctuator", + "range": [ + 100, + 101 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 101, + 102 + ], + "loc": { + "start": { + "line": 4, + "column": 1 + }, + "end": { + "line": 4, + "column": 2 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 102, + 103 + ], + "loc": { + "start": { + "line": 4, + "column": 2 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 103, + 108 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 108, + 109 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 109, + 110 + ], + "loc": { + "start": { + "line": 5, + "column": 6 + }, + "end": { + "line": 5, + "column": 7 + } + }, + "value": "p" + }, + { + "type": "HTMLWhitespace", + "range": [ + 110, + 111 + ], + "loc": { + "start": { + "line": 5, + "column": 7 + }, + "end": { + "line": 5, + "column": 8 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 111, + 112 + ], + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 9 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 112, + 113 + ], + "loc": { + "start": { + "line": 5, + "column": 9 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 113, + 128 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 25 + } + }, + "value": "defineProps<{t:" + }, + { + "type": "HTMLWhitespace", + "range": [ + 128, + 129 + ], + "loc": { + "start": { + "line": 5, + "column": 25 + }, + "end": { + "line": 5, + "column": 26 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 129, + 131 + ], + "loc": { + "start": { + "line": 5, + "column": 26 + }, + "end": { + "line": 5, + "column": 28 + } + }, + "value": "T," + }, + { + "type": "HTMLWhitespace", + "range": [ + 131, + 132 + ], + "loc": { + "start": { + "line": 5, + "column": 28 + }, + "end": { + "line": 5, + "column": 29 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 132, + 134 + ], + "loc": { + "start": { + "line": 5, + "column": 29 + }, + "end": { + "line": 5, + "column": 31 + } + }, + "value": "u:" + }, + { + "type": "HTMLWhitespace", + "range": [ + 134, + 135 + ], + "loc": { + "start": { + "line": 5, + "column": 31 + }, + "end": { + "line": 5, + "column": 32 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 135, + 140 + ], + "loc": { + "start": { + "line": 5, + "column": 32 + }, + "end": { + "line": 5, + "column": 37 + } + }, + "value": "U}>()" + }, + { + "type": "HTMLWhitespace", + "range": [ + 140, + 141 + ], + "loc": { + "start": { + "line": 5, + "column": 37 + }, + "end": { + "line": 6, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 141, + 149 + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 149, + 150 + ], + "loc": { + "start": { + "line": 6, + "column": 8 + }, + "end": { + "line": 6, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 150, + 152 + ], + "loc": { + "start": { + "line": 6, + "column": 9 + }, + "end": { + "line": 8, + "column": 0 + } + }, + "value": "\n\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 152, + 161 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 161, + 162 + ], + "loc": { + "start": { + "line": 8, + "column": 9 + }, + "end": { + "line": 8, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 162, + 163 + ], + "loc": { + "start": { + "line": 8, + "column": 10 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionStart", + "range": [ + 163, + 165 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 2 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 9, + "column": 3 + }, + "start": { + "line": 9, + "column": 2 + } + }, + "range": [ + 165, + 166 + ], + "value": "p" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 9, + "column": 4 + }, + "start": { + "line": 9, + "column": 3 + } + }, + "range": [ + 166, + 167 + ], + "value": "." + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 9, + "column": 5 + }, + "start": { + "line": 9, + "column": 4 + } + }, + "range": [ + 167, + 168 + ], + "value": "t" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 9, + "column": 6 + }, + "start": { + "line": 9, + "column": 5 + } + }, + "range": [ + 168, + 169 + ], + "value": "(" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 9, + "column": 7 + }, + "start": { + "line": 9, + "column": 6 + } + }, + "range": [ + 169, + 170 + ], + "value": ")" + }, + { + "type": "VExpressionEnd", + "range": [ + 170, + 172 + ], + "loc": { + "start": { + "line": 9, + "column": 7 + }, + "end": { + "line": 9, + "column": 9 + } + }, + "value": "}}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 172, + 173 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 10, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionStart", + "range": [ + 173, + 175 + ], + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 2 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 10, + "column": 3 + }, + "start": { + "line": 10, + "column": 2 + } + }, + "range": [ + 175, + 176 + ], + "value": "p" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 10, + "column": 4 + }, + "start": { + "line": 10, + "column": 3 + } + }, + "range": [ + 176, + 177 + ], + "value": "." + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 10, + "column": 5 + }, + "start": { + "line": 10, + "column": 4 + } + }, + "range": [ + 177, + 178 + ], + "value": "u" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 10, + "column": 6 + }, + "start": { + "line": 10, + "column": 5 + } + }, + "range": [ + 178, + 179 + ], + "value": "(" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 10, + "column": 7 + }, + "start": { + "line": 10, + "column": 6 + } + }, + "range": [ + 179, + 180 + ], + "value": ")" + }, + { + "type": "VExpressionEnd", + "range": [ + 180, + 182 + ], + "loc": { + "start": { + "line": 10, + "column": 7 + }, + "end": { + "line": 10, + "column": 9 + } + }, + "value": "}}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 182, + 183 + ], + "loc": { + "start": { + "line": 10, + "column": 9 + }, + "end": { + "line": 11, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 183, + 193 + ], + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 193, + 194 + ], + "loc": { + "start": { + "line": 11, + "column": 10 + }, + "end": { + "line": 11, + "column": 11 + } + }, + "value": "" + } + ], + "comments": [], + "errors": [] +} \ No newline at end of file diff --git a/test/fixtures/document-fragment/vue3.3-generic-7-with-arrow/parser-options.json b/test/fixtures/document-fragment/vue3.3-generic-7-with-arrow/parser-options.json new file mode 100644 index 00000000..0ead30e9 --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-7-with-arrow/parser-options.json @@ -0,0 +1,6 @@ +{ + "sourceType": "module", + "parser": { + "ts": "@typescript-eslint/parser" + } +} diff --git a/test/fixtures/document-fragment/vue3.3-generic-7-with-arrow/source.vue b/test/fixtures/document-fragment/vue3.3-generic-7-with-arrow/source.vue new file mode 100644 index 00000000..d1a84af7 --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-7-with-arrow/source.vue @@ -0,0 +1,11 @@ + + + \ No newline at end of file diff --git a/test/fixtures/document-fragment/vue3.3-generic-7-with-arrow/token-ranges.json b/test/fixtures/document-fragment/vue3.3-generic-7-with-arrow/token-ranges.json new file mode 100644 index 00000000..19b7461d --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-7-with-arrow/token-ranges.json @@ -0,0 +1,69 @@ +[ + "", + "string", + ",", + "U", + "extends", + "(", + ")", + "=>", + "string", + "=", + "(", + ")", + "=>", + "'abc'", + "\"", + ">", + "\n", + "const", + " ", + "p", + " ", + "=", + " ", + "defineProps<{t:", + " ", + "T,", + " ", + "u:", + " ", + "U}>()", + "\n", + "", + "\n\n", + "", + "\n", + "{{", + "p", + ".", + "t", + "(", + ")", + "}}", + "\n", + "{{", + "p", + ".", + "u", + "(", + ")", + "}}", + "\n", + "" +] \ No newline at end of file diff --git a/test/fixtures/document-fragment/vue3.3-generic-7-with-arrow/tree.json b/test/fixtures/document-fragment/vue3.3-generic-7-with-arrow/tree.json new file mode 100644 index 00000000..64d30e2d --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-7-with-arrow/tree.json @@ -0,0 +1,257 @@ +[ + { + "type": "VDocumentFragment", + "text": "\n\n", + "children": [ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + }, + { + "type": "VText", + "text": "\n\n", + "children": [] + }, + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/eslint b/test/fixtures/eslint deleted file mode 160000 index 2774043e..00000000 --- a/test/fixtures/eslint +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 2774043e6bc0b5709df02ac6bb61be6ac950f77d diff --git a/test/fixtures/integrations/script-setup-with-typescript-eslint/.eslintrc.js b/test/fixtures/integrations/script-setup-with-typescript-eslint/.eslintrc.js new file mode 100644 index 00000000..ef47614d --- /dev/null +++ b/test/fixtures/integrations/script-setup-with-typescript-eslint/.eslintrc.js @@ -0,0 +1,14 @@ +"use strict"; + +module.exports = { + root: true, + parser: require.resolve("../../../../src/index.ts"), + parserOptions: { + ecmaVersion: 2020, + sourceType: "module", + parser: "@typescript-eslint/parser", + project: require.resolve("./tsconfig.test.json"), + extraFileExtensions: ['.vue'] + }, + plugins: ["@typescript-eslint"], +}; diff --git a/test/fixtures/integrations/script-setup-with-typescript-eslint/.npmrc b/test/fixtures/integrations/script-setup-with-typescript-eslint/.npmrc new file mode 100644 index 00000000..c1ca392f --- /dev/null +++ b/test/fixtures/integrations/script-setup-with-typescript-eslint/.npmrc @@ -0,0 +1 @@ +package-lock = false diff --git a/test/fixtures/integrations/script-setup-with-typescript-eslint/consistent-type-imports/.eslintrc.json b/test/fixtures/integrations/script-setup-with-typescript-eslint/consistent-type-imports/.eslintrc.json new file mode 100644 index 00000000..a884ca94 --- /dev/null +++ b/test/fixtures/integrations/script-setup-with-typescript-eslint/consistent-type-imports/.eslintrc.json @@ -0,0 +1,5 @@ +{ + "rules": { + "@typescript-eslint/consistent-type-imports": "error" + } +} diff --git a/test/fixtures/integrations/script-setup-with-typescript-eslint/consistent-type-imports/valid-type-import.vue b/test/fixtures/integrations/script-setup-with-typescript-eslint/consistent-type-imports/valid-type-import.vue new file mode 100644 index 00000000..c1c451fc --- /dev/null +++ b/test/fixtures/integrations/script-setup-with-typescript-eslint/consistent-type-imports/valid-type-import.vue @@ -0,0 +1,11 @@ + + + + diff --git a/test/fixtures/integrations/script-setup-with-typescript-eslint/consistent-type-imports/valid.vue b/test/fixtures/integrations/script-setup-with-typescript-eslint/consistent-type-imports/valid.vue new file mode 100644 index 00000000..cee3d088 --- /dev/null +++ b/test/fixtures/integrations/script-setup-with-typescript-eslint/consistent-type-imports/valid.vue @@ -0,0 +1,9 @@ + + + + diff --git a/test/fixtures/integrations/script-setup-with-typescript-eslint/no-obj-calls/.eslintrc.json b/test/fixtures/integrations/script-setup-with-typescript-eslint/no-obj-calls/.eslintrc.json new file mode 100644 index 00000000..0fe9a184 --- /dev/null +++ b/test/fixtures/integrations/script-setup-with-typescript-eslint/no-obj-calls/.eslintrc.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-obj-calls": "error" + } +} diff --git a/test/fixtures/integrations/script-setup-with-typescript-eslint/no-obj-calls/valid.vue b/test/fixtures/integrations/script-setup-with-typescript-eslint/no-obj-calls/valid.vue new file mode 100644 index 00000000..32aa1772 --- /dev/null +++ b/test/fixtures/integrations/script-setup-with-typescript-eslint/no-obj-calls/valid.vue @@ -0,0 +1,8 @@ + + + diff --git a/test/fixtures/integrations/script-setup-with-typescript-eslint/no-undef/.eslintrc.json b/test/fixtures/integrations/script-setup-with-typescript-eslint/no-undef/.eslintrc.json new file mode 100644 index 00000000..f21f62ca --- /dev/null +++ b/test/fixtures/integrations/script-setup-with-typescript-eslint/no-undef/.eslintrc.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-undef": "error" + } +} diff --git a/test/fixtures/integrations/script-setup-with-typescript-eslint/no-undef/invalid/generic.vue b/test/fixtures/integrations/script-setup-with-typescript-eslint/no-undef/invalid/generic.vue new file mode 100644 index 00000000..f5752f73 --- /dev/null +++ b/test/fixtures/integrations/script-setup-with-typescript-eslint/no-undef/invalid/generic.vue @@ -0,0 +1,11 @@ + diff --git a/test/fixtures/integrations/script-setup-with-typescript-eslint/no-undef/invalid/with-defaults.vue b/test/fixtures/integrations/script-setup-with-typescript-eslint/no-undef/invalid/with-defaults.vue new file mode 100644 index 00000000..7496058b --- /dev/null +++ b/test/fixtures/integrations/script-setup-with-typescript-eslint/no-undef/invalid/with-defaults.vue @@ -0,0 +1,13 @@ + diff --git a/test/fixtures/integrations/script-setup-with-typescript-eslint/no-undef/valid/generic-with-spaces.vue b/test/fixtures/integrations/script-setup-with-typescript-eslint/no-undef/valid/generic-with-spaces.vue new file mode 100644 index 00000000..8eecb84d --- /dev/null +++ b/test/fixtures/integrations/script-setup-with-typescript-eslint/no-undef/valid/generic-with-spaces.vue @@ -0,0 +1,13 @@ + diff --git a/test/fixtures/integrations/script-setup-with-typescript-eslint/no-undef/valid/generic.vue b/test/fixtures/integrations/script-setup-with-typescript-eslint/no-undef/valid/generic.vue new file mode 100644 index 00000000..fce7db53 --- /dev/null +++ b/test/fixtures/integrations/script-setup-with-typescript-eslint/no-undef/valid/generic.vue @@ -0,0 +1,10 @@ + diff --git a/test/fixtures/integrations/script-setup-with-typescript-eslint/no-undef/valid/generic2.vue b/test/fixtures/integrations/script-setup-with-typescript-eslint/no-undef/valid/generic2.vue new file mode 100644 index 00000000..7d10afcf --- /dev/null +++ b/test/fixtures/integrations/script-setup-with-typescript-eslint/no-undef/valid/generic2.vue @@ -0,0 +1,13 @@ + + diff --git a/test/fixtures/integrations/script-setup-with-typescript-eslint/no-undef/valid/with-defaults.vue b/test/fixtures/integrations/script-setup-with-typescript-eslint/no-undef/valid/with-defaults.vue new file mode 100644 index 00000000..6e2bd254 --- /dev/null +++ b/test/fixtures/integrations/script-setup-with-typescript-eslint/no-undef/valid/with-defaults.vue @@ -0,0 +1,11 @@ + diff --git a/test/fixtures/integrations/script-setup-with-typescript-eslint/no-unused-vars/.eslintrc.json b/test/fixtures/integrations/script-setup-with-typescript-eslint/no-unused-vars/.eslintrc.json new file mode 100644 index 00000000..7592b0b5 --- /dev/null +++ b/test/fixtures/integrations/script-setup-with-typescript-eslint/no-unused-vars/.eslintrc.json @@ -0,0 +1,5 @@ +{ + "rules": { + "@typescript-eslint/no-unused-vars": "error" + } +} diff --git a/test/fixtures/integrations/script-setup-with-typescript-eslint/no-unused-vars/valid/type-def.vue b/test/fixtures/integrations/script-setup-with-typescript-eslint/no-unused-vars/valid/type-def.vue new file mode 100644 index 00000000..ba631bff --- /dev/null +++ b/test/fixtures/integrations/script-setup-with-typescript-eslint/no-unused-vars/valid/type-def.vue @@ -0,0 +1,14 @@ + + + \ No newline at end of file diff --git a/test/fixtures/integrations/script-setup-with-typescript-eslint/output.json b/test/fixtures/integrations/script-setup-with-typescript-eslint/output.json new file mode 100644 index 00000000..af72fcf4 --- /dev/null +++ b/test/fixtures/integrations/script-setup-with-typescript-eslint/output.json @@ -0,0 +1,37 @@ +[ + { + "filePath": "/no-undef/invalid/generic.vue", + "messages": [ + { + "ruleId": "no-undef", + "line": 6, + "message": "'U' is not defined." + } + ] + }, + { + "filePath": "/no-undef/invalid/with-defaults.vue", + "messages": [ + { + "ruleId": "no-undef", + "line": 8, + "message": "'withDefaults' is not defined." + }, + { + "ruleId": "no-undef", + "line": 8, + "message": "'defineProps' is not defined." + } + ] + }, + { + "filePath": "/ts-no-unused-vars/invalid/generic.vue", + "messages": [ + { + "ruleId": "@typescript-eslint/no-unused-vars", + "line": 4, + "message": "'Baz' is defined but never used." + } + ] + } +] diff --git a/test/fixtures/integrations/script-setup-with-typescript-eslint/package.json b/test/fixtures/integrations/script-setup-with-typescript-eslint/package.json new file mode 100644 index 00000000..d9d36dfe --- /dev/null +++ b/test/fixtures/integrations/script-setup-with-typescript-eslint/package.json @@ -0,0 +1,9 @@ +{ + "devDependencies": { + "eslint": "^8.8.0", + "@typescript-eslint/parser": "^5.57.0", + "@typescript-eslint/eslint-plugin": "^5.57.0", + "vue": "^3.4.0", + "typescript": "^5.0.2" + } +} diff --git a/test/fixtures/integrations/script-setup-with-typescript-eslint/ts-no-unsafe-assignment/.eslintrc.json b/test/fixtures/integrations/script-setup-with-typescript-eslint/ts-no-unsafe-assignment/.eslintrc.json new file mode 100644 index 00000000..3b7392e3 --- /dev/null +++ b/test/fixtures/integrations/script-setup-with-typescript-eslint/ts-no-unsafe-assignment/.eslintrc.json @@ -0,0 +1,5 @@ +{ + "rules": { + "@typescript-eslint/no-unsafe-assignment": "error" + } +} diff --git a/test/fixtures/integrations/script-setup-with-typescript-eslint/ts-no-unsafe-assignment/valid-generic1.vue b/test/fixtures/integrations/script-setup-with-typescript-eslint/ts-no-unsafe-assignment/valid-generic1.vue new file mode 100644 index 00000000..1f064003 --- /dev/null +++ b/test/fixtures/integrations/script-setup-with-typescript-eslint/ts-no-unsafe-assignment/valid-generic1.vue @@ -0,0 +1,9 @@ + diff --git a/test/fixtures/integrations/script-setup-with-typescript-eslint/ts-no-unsafe-assignment/valid-generic2.vue b/test/fixtures/integrations/script-setup-with-typescript-eslint/ts-no-unsafe-assignment/valid-generic2.vue new file mode 100644 index 00000000..0937cd44 --- /dev/null +++ b/test/fixtures/integrations/script-setup-with-typescript-eslint/ts-no-unsafe-assignment/valid-generic2.vue @@ -0,0 +1,9 @@ + diff --git a/test/fixtures/integrations/script-setup-with-typescript-eslint/ts-no-unsafe-assignment/valid-generic3.vue b/test/fixtures/integrations/script-setup-with-typescript-eslint/ts-no-unsafe-assignment/valid-generic3.vue new file mode 100644 index 00000000..d440fe0c --- /dev/null +++ b/test/fixtures/integrations/script-setup-with-typescript-eslint/ts-no-unsafe-assignment/valid-generic3.vue @@ -0,0 +1,12 @@ + diff --git a/test/fixtures/integrations/script-setup-with-typescript-eslint/ts-no-unused-vars/.eslintrc.json b/test/fixtures/integrations/script-setup-with-typescript-eslint/ts-no-unused-vars/.eslintrc.json new file mode 100644 index 00000000..7592b0b5 --- /dev/null +++ b/test/fixtures/integrations/script-setup-with-typescript-eslint/ts-no-unused-vars/.eslintrc.json @@ -0,0 +1,5 @@ +{ + "rules": { + "@typescript-eslint/no-unused-vars": "error" + } +} diff --git a/test/fixtures/integrations/script-setup-with-typescript-eslint/ts-no-unused-vars/invalid/generic.vue b/test/fixtures/integrations/script-setup-with-typescript-eslint/ts-no-unused-vars/invalid/generic.vue new file mode 100644 index 00000000..5449949b --- /dev/null +++ b/test/fixtures/integrations/script-setup-with-typescript-eslint/ts-no-unused-vars/invalid/generic.vue @@ -0,0 +1,11 @@ + diff --git a/test/fixtures/integrations/script-setup-with-typescript-eslint/ts-no-unused-vars/valid/generic.vue b/test/fixtures/integrations/script-setup-with-typescript-eslint/ts-no-unused-vars/valid/generic.vue new file mode 100644 index 00000000..fce7db53 --- /dev/null +++ b/test/fixtures/integrations/script-setup-with-typescript-eslint/ts-no-unused-vars/valid/generic.vue @@ -0,0 +1,10 @@ + diff --git a/test/fixtures/integrations/script-setup-with-typescript-eslint/tsconfig.test.json b/test/fixtures/integrations/script-setup-with-typescript-eslint/tsconfig.test.json new file mode 100644 index 00000000..eed31ea8 --- /dev/null +++ b/test/fixtures/integrations/script-setup-with-typescript-eslint/tsconfig.test.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "target": "ESNext", + "useDefineForClassFields": true, + "module": "ESNext", + "moduleResolution": "Node", + "strict": true, + "jsx": "preserve", + "resolveJsonModule": true, + "isolatedModules": true, + "esModuleInterop": true, + "lib": ["ESNext", "DOM"], + "skipLibCheck": true, + "noEmit": true, + "checkJs": true, + "allowJs": true + }, + "include": ["./vue.d.ts", "**/*.ts", "**/*.vue"] +} diff --git a/test/fixtures/integrations/script-setup-with-typescript-eslint/vue.d.ts b/test/fixtures/integrations/script-setup-with-typescript-eslint/vue.d.ts new file mode 100644 index 00000000..cf5931b6 --- /dev/null +++ b/test/fixtures/integrations/script-setup-with-typescript-eslint/vue.d.ts @@ -0,0 +1 @@ +/// \ No newline at end of file diff --git a/test/fixtures/integrations/script-setup/.eslintrc.json b/test/fixtures/integrations/script-setup/.eslintrc.json new file mode 100644 index 00000000..7815413c --- /dev/null +++ b/test/fixtures/integrations/script-setup/.eslintrc.json @@ -0,0 +1,11 @@ +{ + "root": true, + "parser": "../../../../src/index.ts", + "parserOptions": { + "ecmaVersion": 2022, + "sourceType": "module" + }, + "env": { + "browser": true + } +} diff --git a/test/fixtures/integrations/script-setup/.npmrc b/test/fixtures/integrations/script-setup/.npmrc new file mode 100644 index 00000000..c1ca392f --- /dev/null +++ b/test/fixtures/integrations/script-setup/.npmrc @@ -0,0 +1 @@ +package-lock = false diff --git a/test/fixtures/integrations/script-setup/no-undef/.eslintrc.json b/test/fixtures/integrations/script-setup/no-undef/.eslintrc.json new file mode 100644 index 00000000..8ac40848 --- /dev/null +++ b/test/fixtures/integrations/script-setup/no-undef/.eslintrc.json @@ -0,0 +1,13 @@ +{ + "rules": { + "no-undef": "error" + }, + "parserOptions": { + "parser": { + "ts": "@typescript-eslint/parser" + }, + "vueFeatures": { + "customMacros": ["userMacro"] + } + } +} diff --git a/test/fixtures/integrations/script-setup/no-undef/invalid/define-expose.vue b/test/fixtures/integrations/script-setup/no-undef/invalid/define-expose.vue new file mode 100644 index 00000000..aa6d6193 --- /dev/null +++ b/test/fixtures/integrations/script-setup/no-undef/invalid/define-expose.vue @@ -0,0 +1,13 @@ + diff --git a/test/fixtures/integrations/script-setup/no-undef/invalid/define-options.vue b/test/fixtures/integrations/script-setup/no-undef/invalid/define-options.vue new file mode 100644 index 00000000..65c75093 --- /dev/null +++ b/test/fixtures/integrations/script-setup/no-undef/invalid/define-options.vue @@ -0,0 +1,10 @@ + diff --git a/test/fixtures/integrations/script-setup/no-undef/invalid/define-props-and-emits.vue b/test/fixtures/integrations/script-setup/no-undef/invalid/define-props-and-emits.vue new file mode 100644 index 00000000..c94cc8dc --- /dev/null +++ b/test/fixtures/integrations/script-setup/no-undef/invalid/define-props-and-emits.vue @@ -0,0 +1,9 @@ + diff --git a/test/fixtures/integrations/script-setup/no-undef/invalid/define-slots.vue b/test/fixtures/integrations/script-setup/no-undef/invalid/define-slots.vue new file mode 100644 index 00000000..900e01c6 --- /dev/null +++ b/test/fixtures/integrations/script-setup/no-undef/invalid/define-slots.vue @@ -0,0 +1,7 @@ + diff --git a/test/fixtures/integrations/script-setup/no-undef/invalid/user-macro.vue b/test/fixtures/integrations/script-setup/no-undef/invalid/user-macro.vue new file mode 100644 index 00000000..ad8d3f30 --- /dev/null +++ b/test/fixtures/integrations/script-setup/no-undef/invalid/user-macro.vue @@ -0,0 +1,3 @@ + diff --git a/test/fixtures/integrations/script-setup/no-undef/valid/define-expose.vue b/test/fixtures/integrations/script-setup/no-undef/valid/define-expose.vue new file mode 100644 index 00000000..9a34c335 --- /dev/null +++ b/test/fixtures/integrations/script-setup/no-undef/valid/define-expose.vue @@ -0,0 +1,11 @@ + diff --git a/test/fixtures/integrations/script-setup/no-undef/valid/define-options.vue b/test/fixtures/integrations/script-setup/no-undef/valid/define-options.vue new file mode 100644 index 00000000..39ae2bbf --- /dev/null +++ b/test/fixtures/integrations/script-setup/no-undef/valid/define-options.vue @@ -0,0 +1,8 @@ + diff --git a/test/fixtures/integrations/script-setup/no-undef/valid/define-props-and-emits-with-import.vue b/test/fixtures/integrations/script-setup/no-undef/valid/define-props-and-emits-with-import.vue new file mode 100644 index 00000000..526aa2a7 --- /dev/null +++ b/test/fixtures/integrations/script-setup/no-undef/valid/define-props-and-emits-with-import.vue @@ -0,0 +1,9 @@ + diff --git a/test/fixtures/integrations/script-setup/no-undef/valid/define-props-and-emits.vue b/test/fixtures/integrations/script-setup/no-undef/valid/define-props-and-emits.vue new file mode 100644 index 00000000..d436665f --- /dev/null +++ b/test/fixtures/integrations/script-setup/no-undef/valid/define-props-and-emits.vue @@ -0,0 +1,8 @@ + diff --git a/test/fixtures/integrations/script-setup/no-undef/valid/define-slots-wthout-ts.vue b/test/fixtures/integrations/script-setup/no-undef/valid/define-slots-wthout-ts.vue new file mode 100644 index 00000000..6b367c16 --- /dev/null +++ b/test/fixtures/integrations/script-setup/no-undef/valid/define-slots-wthout-ts.vue @@ -0,0 +1,3 @@ + diff --git a/test/fixtures/integrations/script-setup/no-undef/valid/define-slots.vue b/test/fixtures/integrations/script-setup/no-undef/valid/define-slots.vue new file mode 100644 index 00000000..b28db98b --- /dev/null +++ b/test/fixtures/integrations/script-setup/no-undef/valid/define-slots.vue @@ -0,0 +1,5 @@ + diff --git a/test/fixtures/integrations/script-setup/no-undef/valid/user-macro.vue b/test/fixtures/integrations/script-setup/no-undef/valid/user-macro.vue new file mode 100644 index 00000000..9990d5a3 --- /dev/null +++ b/test/fixtures/integrations/script-setup/no-undef/valid/user-macro.vue @@ -0,0 +1,3 @@ + diff --git a/test/fixtures/integrations/script-setup/no-unused-vars/.eslintrc.json b/test/fixtures/integrations/script-setup/no-unused-vars/.eslintrc.json new file mode 100644 index 00000000..da817b4c --- /dev/null +++ b/test/fixtures/integrations/script-setup/no-unused-vars/.eslintrc.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-unused-vars": "error" + } +} diff --git a/test/fixtures/integrations/script-setup/no-unused-vars/invalid/component-names.vue b/test/fixtures/integrations/script-setup/no-unused-vars/invalid/component-names.vue new file mode 100644 index 00000000..63792e58 --- /dev/null +++ b/test/fixtures/integrations/script-setup/no-unused-vars/invalid/component-names.vue @@ -0,0 +1,7 @@ + + + diff --git a/test/fixtures/integrations/script-setup/no-unused-vars/invalid/css-v-bind.vue b/test/fixtures/integrations/script-setup/no-unused-vars/invalid/css-v-bind.vue new file mode 100644 index 00000000..43f25387 --- /dev/null +++ b/test/fixtures/integrations/script-setup/no-unused-vars/invalid/css-v-bind.vue @@ -0,0 +1,12 @@ + + + diff --git a/test/fixtures/integrations/script-setup/no-unused-vars/invalid/invalid-scope.vue b/test/fixtures/integrations/script-setup/no-unused-vars/invalid/invalid-scope.vue new file mode 100644 index 00000000..2943f78c --- /dev/null +++ b/test/fixtures/integrations/script-setup/no-unused-vars/invalid/invalid-scope.vue @@ -0,0 +1,9 @@ + + + diff --git a/test/fixtures/integrations/script-setup/no-unused-vars/invalid/sample.vue b/test/fixtures/integrations/script-setup/no-unused-vars/invalid/sample.vue new file mode 100644 index 00000000..92024d49 --- /dev/null +++ b/test/fixtures/integrations/script-setup/no-unused-vars/invalid/sample.vue @@ -0,0 +1,22 @@ + + + diff --git a/test/fixtures/integrations/script-setup/no-unused-vars/invalid/with-v-for.vue b/test/fixtures/integrations/script-setup/no-unused-vars/invalid/with-v-for.vue new file mode 100644 index 00000000..213f418b --- /dev/null +++ b/test/fixtures/integrations/script-setup/no-unused-vars/invalid/with-v-for.vue @@ -0,0 +1,8 @@ + + + diff --git a/test/fixtures/integrations/script-setup/no-unused-vars/invalid/without-script-setup.vue b/test/fixtures/integrations/script-setup/no-unused-vars/invalid/without-script-setup.vue new file mode 100644 index 00000000..bb67fbb1 --- /dev/null +++ b/test/fixtures/integrations/script-setup/no-unused-vars/invalid/without-script-setup.vue @@ -0,0 +1,7 @@ + + + diff --git a/test/fixtures/integrations/script-setup/no-unused-vars/valid/component-is.vue b/test/fixtures/integrations/script-setup/no-unused-vars/valid/component-is.vue new file mode 100644 index 00000000..a08343d2 --- /dev/null +++ b/test/fixtures/integrations/script-setup/no-unused-vars/valid/component-is.vue @@ -0,0 +1,9 @@ + + + diff --git a/test/fixtures/integrations/script-setup/no-unused-vars/valid/component-names1.vue b/test/fixtures/integrations/script-setup/no-unused-vars/valid/component-names1.vue new file mode 100644 index 00000000..26196fd1 --- /dev/null +++ b/test/fixtures/integrations/script-setup/no-unused-vars/valid/component-names1.vue @@ -0,0 +1,11 @@ + + + diff --git a/test/fixtures/integrations/script-setup/no-unused-vars/valid/component-names2.vue b/test/fixtures/integrations/script-setup/no-unused-vars/valid/component-names2.vue new file mode 100644 index 00000000..a75da9e9 --- /dev/null +++ b/test/fixtures/integrations/script-setup/no-unused-vars/valid/component-names2.vue @@ -0,0 +1,9 @@ + + + diff --git a/test/fixtures/integrations/script-setup/no-unused-vars/valid/css-v-bind.vue b/test/fixtures/integrations/script-setup/no-unused-vars/valid/css-v-bind.vue new file mode 100644 index 00000000..822b035c --- /dev/null +++ b/test/fixtures/integrations/script-setup/no-unused-vars/valid/css-v-bind.vue @@ -0,0 +1,11 @@ + + + diff --git a/test/fixtures/integrations/script-setup/no-unused-vars/valid/directive.vue b/test/fixtures/integrations/script-setup/no-unused-vars/valid/directive.vue new file mode 100644 index 00000000..bff5a052 --- /dev/null +++ b/test/fixtures/integrations/script-setup/no-unused-vars/valid/directive.vue @@ -0,0 +1,7 @@ + + + diff --git a/test/fixtures/integrations/script-setup/no-unused-vars/valid/kebab-case-component.vue b/test/fixtures/integrations/script-setup/no-unused-vars/valid/kebab-case-component.vue new file mode 100644 index 00000000..b4d26cd4 --- /dev/null +++ b/test/fixtures/integrations/script-setup/no-unused-vars/valid/kebab-case-component.vue @@ -0,0 +1,10 @@ + + + diff --git a/test/fixtures/integrations/script-setup/no-unused-vars/valid/mustash.vue b/test/fixtures/integrations/script-setup/no-unused-vars/valid/mustash.vue new file mode 100644 index 00000000..c7c27a17 --- /dev/null +++ b/test/fixtures/integrations/script-setup/no-unused-vars/valid/mustash.vue @@ -0,0 +1,7 @@ + + + diff --git a/test/fixtures/integrations/script-setup/no-unused-vars/valid/ns-component.vue b/test/fixtures/integrations/script-setup/no-unused-vars/valid/ns-component.vue new file mode 100644 index 00000000..84fcdcac --- /dev/null +++ b/test/fixtures/integrations/script-setup/no-unused-vars/valid/ns-component.vue @@ -0,0 +1,9 @@ + + + diff --git a/test/fixtures/integrations/script-setup/no-unused-vars/valid/ref.vue b/test/fixtures/integrations/script-setup/no-unused-vars/valid/ref.vue new file mode 100644 index 00000000..b2a58120 --- /dev/null +++ b/test/fixtures/integrations/script-setup/no-unused-vars/valid/ref.vue @@ -0,0 +1,8 @@ + + + diff --git a/test/fixtures/integrations/script-setup/no-unused-vars/valid/sample.vue b/test/fixtures/integrations/script-setup/no-unused-vars/valid/sample.vue new file mode 100644 index 00000000..7c5b2f53 --- /dev/null +++ b/test/fixtures/integrations/script-setup/no-unused-vars/valid/sample.vue @@ -0,0 +1,16 @@ + + + diff --git a/test/fixtures/integrations/script-setup/no-unused-vars/valid/top-level-await.vue b/test/fixtures/integrations/script-setup/no-unused-vars/valid/top-level-await.vue new file mode 100644 index 00000000..be6f803a --- /dev/null +++ b/test/fixtures/integrations/script-setup/no-unused-vars/valid/top-level-await.vue @@ -0,0 +1,7 @@ + + + diff --git a/test/fixtures/integrations/script-setup/output.json b/test/fixtures/integrations/script-setup/output.json new file mode 100644 index 00000000..ab872a06 --- /dev/null +++ b/test/fixtures/integrations/script-setup/output.json @@ -0,0 +1,122 @@ +[ + { + "filePath": "/no-undef/invalid/define-expose.vue", + "messages": [ + { + "ruleId": "no-undef", + "line": 8, + "message": "'defineExpose' is not defined." + } + ] + }, + { + "filePath": "/no-undef/invalid/define-options.vue", + "messages": [ + { + "ruleId": "no-undef", + "line": 3, + "message": "'defineOptions' is not defined." + } + ] + }, + { + "filePath": "/no-undef/invalid/define-props-and-emits.vue", + "messages": [ + { + "ruleId": "no-undef", + "line": 3, + "message": "'defineProps' is not defined." + }, + { + "ruleId": "no-undef", + "line": 7, + "message": "'defineEmits' is not defined." + } + ] + }, + { + "filePath": "/no-undef/invalid/define-slots.vue", + "messages": [ + { + "ruleId": "no-undef", + "line": 3, + "message": "'defineSlots' is not defined." + } + ] + }, + { + "filePath": "/no-undef/invalid/user-macro.vue", + "messages": [ + { + "ruleId": "no-undef", + "line": 2, + "message": "'unknown' is not defined." + } + ] + }, + { + "filePath": "/no-unused-vars/invalid/component-names.vue", + "messages": [ + { + "ruleId": "no-unused-vars", + "line": 2, + "message": "'camelCase' is defined but never used." + } + ] + }, + { + "filePath": "/no-unused-vars/invalid/css-v-bind.vue", + "messages": [ + { + "ruleId": "no-unused-vars", + "line": 2, + "message": "'color' is assigned a value but never used." + } + ] + }, + { + "filePath": "/no-unused-vars/invalid/invalid-scope.vue", + "messages": [ + { + "ruleId": "no-unused-vars", + "line": 3, + "message": "'msg' is assigned a value but never used." + } + ] + }, + { + "filePath": "/no-unused-vars/invalid/sample.vue", + "messages": [ + { + "ruleId": "no-unused-vars", + "line": 4, + "message": "'Bar' is defined but never used." + }, + { + "ruleId": "no-unused-vars", + "line": 17, + "message": "'baz' is assigned a value but never used." + } + ] + }, + { + "filePath": "/no-unused-vars/invalid/with-v-for.vue", + "messages": [ + { + "ruleId": "no-unused-vars", + "line": 2, + "message": "'i' is assigned a value but never used." + } + ] + }, + { + "filePath": "/no-unused-vars/invalid/without-script-setup.vue", + "messages": [ + { + "ruleId": "no-unused-vars", + "line": 2, + "message": "'msg' is assigned a value but never used." + } + ] + } +] diff --git a/test/fixtures/integrations/script-setup/package.json b/test/fixtures/integrations/script-setup/package.json new file mode 100644 index 00000000..75604bef --- /dev/null +++ b/test/fixtures/integrations/script-setup/package.json @@ -0,0 +1,5 @@ +{ + "devDependencies": { + "eslint": "^8.8.0" + } +} diff --git a/test/index.js b/test/index.js index 9fdb3c49..e4d898b3 100644 --- a/test/index.js +++ b/test/index.js @@ -12,12 +12,9 @@ const assert = require("assert") const path = require("path") const fs = require("fs-extra") -const semver = require("semver") const parse = require("../src").parse const parseForESLint = require("../src").parseForESLint -const eslint = require("./lib/eslint-compat")(require("./fixtures/eslint")) -const ESLint = eslint.ESLint -const Linter = eslint.Linter +const eslint = require("eslint") //------------------------------------------------------------------------------ // Helpers @@ -25,7 +22,7 @@ const Linter = eslint.Linter const ORIGINAL_FIXTURE_DIR = path.join(__dirname, "fixtures") const FIXTURE_DIR = path.join(__dirname, "temp") -const PARSER_PATH = path.resolve(__dirname, "../src/index.ts") +const parser = require("../src/index.ts") const BABEL_PARSER_OPTIONS = { parser: "@babel/eslint-parser", @@ -46,7 +43,13 @@ const BABEL_PARSER_OPTIONS = { // Tests //------------------------------------------------------------------------------ -describe("Basic tests", () => { +describe("Basic tests", async () => { + const ESLint = await eslint.loadESLint({ useFlatConfig: true }) + const Linter = class extends eslint.Linter { + constructor() { + super({ configType: "flat" }) + } + } beforeEach(() => { fs.emptyDirSync(FIXTURE_DIR) for (const fileName of fs.readdirSync(ORIGINAL_FIXTURE_DIR)) { @@ -67,11 +70,14 @@ describe("Basic tests", () => { const cli = new ESLint({ cwd: FIXTURE_DIR, overrideConfig: { - env: { es6: true, node: true }, - parser: PARSER_PATH, + files: ["*.vue"], + languageOptions: { + parser, + globals: {}, + }, rules: { semi: "error" }, }, - useEslintrc: false, + overrideConfigFile: true, }) const report = await cli.lintFiles(["hello.vue"]) const messages = report[0].messages @@ -90,11 +96,14 @@ describe("Basic tests", () => { cwd: FIXTURE_DIR, fix: true, overrideConfig: { - env: { es6: true, node: true }, - parser: PARSER_PATH, + files: ["*.vue"], + languageOptions: { + parser, + globals: {}, + }, rules: { semi: "error" }, }, - useEslintrc: false, + overrideConfigFile: true, }) await ESLint.outputFixes(await cli.lintFiles(["hello.vue"])) @@ -116,11 +125,14 @@ describe("Basic tests", () => { const cli = new ESLint({ cwd: FIXTURE_DIR, overrideConfig: { - env: { es6: true, node: true }, - parser: PARSER_PATH, + files: ["*.vue"], + languageOptions: { + parser, + globals: {}, + }, rules: { semi: "error" }, }, - useEslintrc: false, + overrideConfigFile: true, }) const report = await cli.lintFiles(["empty.vue"]) const messages = report[0].messages @@ -134,11 +146,14 @@ describe("Basic tests", () => { const cli = new ESLint({ cwd: FIXTURE_DIR, overrideConfig: { - env: { es6: true, node: true }, - parser: PARSER_PATH, + files: ["*.vue"], + languageOptions: { + parser, + globals: {}, + }, rules: { semi: "error" }, }, - useEslintrc: false, + overrideConfigFile: true, }) const report = await cli.lintFiles(["no-script.vue"]) const messages = report[0].messages @@ -152,11 +167,14 @@ describe("Basic tests", () => { const cli = new ESLint({ cwd: FIXTURE_DIR, overrideConfig: { - env: { es6: true, node: true }, - parser: PARSER_PATH, + files: ["*.vue"], + languageOptions: { + parser, + globals: {}, + }, rules: { semi: "error" }, }, - useEslintrc: false, + overrideConfigFile: true, }) const report = await cli.lintFiles(["empty-script.vue"]) const messages = report[0].messages @@ -170,11 +188,14 @@ describe("Basic tests", () => { const cli = new ESLint({ cwd: FIXTURE_DIR, overrideConfig: { - env: { es6: true, node: true }, - parser: PARSER_PATH, + files: ["*.vue"], + languageOptions: { + parser, + globals: {}, + }, rules: { semi: "error" }, }, - useEslintrc: false, + overrideConfigFile: true, }) const report = await cli.lintFiles(["no-end-script-tag.vue"]) const messages = report[0].messages @@ -188,11 +209,14 @@ describe("Basic tests", () => { const cli = new ESLint({ cwd: FIXTURE_DIR, overrideConfig: { - env: { es6: true, node: true }, - parser: PARSER_PATH, + files: ["*.js"], + languageOptions: { + parser, + globals: {}, + }, rules: { semi: "error" }, }, - useEslintrc: false, + overrideConfigFile: true, }) const report = await cli.lintFiles(["notvue.js"]) const messages = report[0].messages @@ -208,11 +232,14 @@ describe("Basic tests", () => { cwd: FIXTURE_DIR, fix: true, overrideConfig: { - env: { es6: true, node: true }, - parser: PARSER_PATH, + files: ["*.js"], + languageOptions: { + parser, + globals: {}, + }, rules: { semi: "error" }, }, - useEslintrc: false, + overrideConfigFile: true, }) await ESLint.outputFixes(await cli.lintFiles(["notvue.js"])) @@ -225,7 +252,7 @@ describe("Basic tests", () => { "utf8", ) - assert(actual === expected) + assert.strictEqual(actual, expected) }) }) @@ -234,11 +261,14 @@ describe("Basic tests", () => { const cli = new ESLint({ cwd: FIXTURE_DIR, overrideConfig: { - env: { es6: true, node: true }, - parser: PARSER_PATH, + files: ["*.vue"], + languageOptions: { + parser, + globals: {}, + }, rules: { indent: "error" }, }, - useEslintrc: false, + overrideConfigFile: true, }) const report = await cli.lintFiles(["crlf.vue"]) const messages = report[0].messages @@ -252,15 +282,18 @@ describe("Basic tests", () => { const cli = new ESLint({ cwd: FIXTURE_DIR, overrideConfig: { - env: { es6: true, node: true }, - parser: PARSER_PATH, - parserOptions: { - ...BABEL_PARSER_OPTIONS, - sourceType: "module", + files: ["*.js"], + languageOptions: { + parser, + globals: {}, + parserOptions: { + ...BABEL_PARSER_OPTIONS, + sourceType: "module", + }, }, rules: { semi: ["error", "never"] }, }, - useEslintrc: false, + overrideConfigFile: true, }) const report = await cli.lintFiles(["typed.js"]) const messages = report[0].messages @@ -268,47 +301,97 @@ describe("Basic tests", () => { assert.deepStrictEqual(messages, []) }) - if (semver.gte(process.version, "10.0.0")) { - it("should notify no error with '@typescript-eslint/parser'", async () => { - const cli = new ESLint({ - cwd: FIXTURE_DIR, - overrideConfig: { - env: { es6: true, node: true }, - parser: PARSER_PATH, + it("should notify no error with '@typescript-eslint/parser'", async () => { + const cli = new ESLint({ + cwd: FIXTURE_DIR, + overrideConfig: { + files: ["*.js"], + languageOptions: { + parser, + globals: {}, parserOptions: { parser: "@typescript-eslint/parser", }, - rules: { semi: ["error", "never"] }, }, - useEslintrc: false, - }) - const report = await cli.lintFiles(["typed.js"]) - const messages = report[0].messages - - assert.deepStrictEqual(messages, []) + rules: { semi: ["error", "never"] }, + }, + overrideConfigFile: true, }) + const report = await cli.lintFiles(["typed.js"]) + const messages = report[0].messages - it("should notify no error with multiple parser with '@typescript-eslint/parser'", async () => { - const cli = new ESLint({ - cwd: FIXTURE_DIR, - overrideConfig: { - env: { es6: true, node: true }, - parser: PARSER_PATH, + assert.deepStrictEqual(messages, []) + }) + + it("should notify no error with multiple parser with '@typescript-eslint/parser'", async () => { + const cli = new ESLint({ + cwd: FIXTURE_DIR, + overrideConfig: { + files: ["*.ts", "*.tsx"], + languageOptions: { + parser, + globals: {}, parserOptions: { parser: { ts: "@typescript-eslint/parser", }, }, - rules: { semi: ["error", "never"] }, }, - useEslintrc: false, - }) - const report = await cli.lintFiles(["typed.ts", "typed.tsx"]) + rules: { semi: ["error", "never"] }, + }, + overrideConfigFile: true, + }) + const report = await cli.lintFiles(["typed.ts", "typed.tsx"]) + + assert.deepStrictEqual(report[0].messages, []) + assert.deepStrictEqual(report[1].messages, []) + }) + + it("should notify no error with parser object with '@typescript-eslint/parser'", async () => { + const cli = new ESLint({ + cwd: FIXTURE_DIR, + overrideConfig: { + files: ["*.js"], + languageOptions: { + parser, + globals: {}, + parserOptions: { + parser: require("@typescript-eslint/parser"), + }, + }, + rules: { semi: ["error", "never"] }, + }, + overrideConfigFile: true, + }) + const report = await cli.lintFiles(["typed.js"]) + const messages = report[0].messages - assert.deepStrictEqual(report[0].messages, []) - assert.deepStrictEqual(report[1].messages, []) + assert.deepStrictEqual(messages, []) + }) + + it("should notify no error with multiple parser object with '@typescript-eslint/parser'", async () => { + const cli = new ESLint({ + cwd: FIXTURE_DIR, + overrideConfig: { + files: ["*.ts", "*.tsx"], + languageOptions: { + parser, + globals: {}, + parserOptions: { + parser: { + ts: require("@typescript-eslint/parser"), + }, + }, + }, + rules: { semi: ["error", "never"] }, + }, + overrideConfigFile: true, }) - } + const report = await cli.lintFiles(["typed.ts", "typed.tsx"]) + + assert.deepStrictEqual(report[0].messages, []) + assert.deepStrictEqual(report[1].messages, []) + }) }) describe("About fixtures/typed.vue", () => { @@ -316,15 +399,17 @@ describe("Basic tests", () => { const cli = new ESLint({ cwd: FIXTURE_DIR, overrideConfig: { - env: { es6: true, node: true }, - parser: PARSER_PATH, - parserOptions: { - ...BABEL_PARSER_OPTIONS, - sourceType: "module", + files: ["*.vue"], + languageOptions: { + parser, + globals: {}, + parserOptions: { + ...BABEL_PARSER_OPTIONS, + }, }, rules: { semi: ["error", "never"] }, }, - useEslintrc: false, + overrideConfigFile: true, }) const report = await cli.lintFiles(["typed.vue"]) const messages = report[0].messages @@ -332,41 +417,44 @@ describe("Basic tests", () => { assert.deepStrictEqual(messages, []) }) - if (semver.gte(process.version, "10.0.0")) { - it("should notify no error with '@typescript-eslint/parser'", async () => { - const cli = new ESLint({ - cwd: FIXTURE_DIR, - overrideConfig: { - env: { es6: true, node: true }, - parser: PARSER_PATH, + it("should notify no error with '@typescript-eslint/parser'", async () => { + const cli = new ESLint({ + cwd: FIXTURE_DIR, + overrideConfig: { + files: ["*.vue"], + languageOptions: { + parser, + globals: {}, parserOptions: { parser: "@typescript-eslint/parser", }, - rules: { semi: ["error", "never"] }, }, - useEslintrc: false, - }) - const report = await cli.lintFiles(["typed.vue"]) - const messages = report[0].messages - - assert.deepStrictEqual(messages, []) + rules: { semi: ["error", "never"] }, + }, + overrideConfigFile: true, }) - } + const report = await cli.lintFiles(["typed.vue"]) + const messages = report[0].messages + + assert.deepStrictEqual(messages, []) + }) it("should fix 'semi' errors with --fix option with '@babel/eslint-parser'", async () => { const cli = new ESLint({ cwd: FIXTURE_DIR, fix: true, overrideConfig: { - env: { es6: true, node: true }, - parser: PARSER_PATH, - parserOptions: { - ...BABEL_PARSER_OPTIONS, - sourceType: "module", + files: ["*.vue"], + languageOptions: { + parser, + globals: {}, + parserOptions: { + ...BABEL_PARSER_OPTIONS, + }, }, rules: { semi: ["error", "always"] }, }, - useEslintrc: false, + overrideConfigFile: true, }) await ESLint.outputFixes(await cli.lintFiles(["typed.vue"])) @@ -382,73 +470,78 @@ describe("Basic tests", () => { assert(actual === expected) }) - if (semver.gte(process.version, "10.0.0")) { - it("should fix 'semi' errors with --fix option with '@typescript-eslint/parser'", async () => { - const cli = new ESLint({ - cwd: FIXTURE_DIR, - fix: true, - overrideConfig: { - env: { es6: true, node: true }, - parser: PARSER_PATH, + it("should fix 'semi' errors with --fix option with '@typescript-eslint/parser'", async () => { + const cli = new ESLint({ + cwd: FIXTURE_DIR, + fix: true, + overrideConfig: { + files: ["*.vue"], + languageOptions: { + parser, + globals: {}, parserOptions: { parser: "@typescript-eslint/parser", }, - rules: { semi: ["error", "always"] }, }, - useEslintrc: false, - }) - await ESLint.outputFixes(await cli.lintFiles(["typed.vue"])) - - const actual = fs.readFileSync( - path.join(FIXTURE_DIR, "typed.vue"), - "utf8", - ) - const expected = fs.readFileSync( - path.join(FIXTURE_DIR, "typed.vue.fixed"), - "utf8", - ) - - assert(actual === expected) + rules: { semi: ["error", "always"] }, + }, + overrideConfigFile: true, }) - } + await ESLint.outputFixes(await cli.lintFiles(["typed.vue"])) + + const actual = fs.readFileSync( + path.join(FIXTURE_DIR, "typed.vue"), + "utf8", + ) + const expected = fs.readFileSync( + path.join(FIXTURE_DIR, "typed.vue.fixed"), + "utf8", + ) + + assert.strictEqual(actual, expected) + }) }) - if (semver.gte(process.version, "10.0.0")) { - describe("About fixtures/ts-scope-manager.vue", () => { - it("should calculate the correct location with '@typescript-eslint/parser'", async () => { - const cli = new ESLint({ - cwd: FIXTURE_DIR, - overrideConfig: { - env: { es6: true, node: true }, - parser: PARSER_PATH, + describe("About fixtures/ts-scope-manager.vue", () => { + it("should calculate the correct location with '@typescript-eslint/parser'", async () => { + const cli = new ESLint({ + cwd: FIXTURE_DIR, + overrideConfig: { + files: ["*.vue"], + languageOptions: { + parser, + globals: {}, parserOptions: { parser: "@typescript-eslint/parser", }, - rules: { "no-unused-vars": ["error"] }, }, - useEslintrc: false, - }) - const report = await cli.lintFiles(["ts-scope-manager.vue"]) - const messages = report[0].messages - - assert.strictEqual(messages.length, 1) - assert.deepStrictEqual(messages[0].line, 8) - assert.deepStrictEqual(messages[0].column, 8) - assert.deepStrictEqual(messages[0].endLine, 8) - assert.deepStrictEqual(messages[0].endColumn, 14) + rules: { "no-unused-vars": ["error"] }, + }, + overrideConfigFile: true, }) + const report = await cli.lintFiles(["ts-scope-manager.vue"]) + const messages = report[0].messages + + assert.strictEqual(messages.length, 1) + assert.deepStrictEqual(messages[0].line, 8) + assert.deepStrictEqual(messages[0].column, 8) + assert.deepStrictEqual(messages[0].endLine, 8) + assert.deepStrictEqual(messages[0].endColumn, 14) }) - } + }) describe("About fixtures/svg-attrs.vue", () => { it("parses attributes with colons", async () => { const cli = new ESLint({ cwd: FIXTURE_DIR, overrideConfig: { - env: { es6: true, node: true }, - parser: PARSER_PATH, + files: ["*.vue"], + languageOptions: { + parser, + globals: {}, + }, }, - useEslintrc: false, + overrideConfigFile: true, }) const report = await cli.lintFiles(["svg-attrs-colon.vue"]) const messages = report[0].messages @@ -460,10 +553,13 @@ describe("Basic tests", () => { const cli = new ESLint({ cwd: FIXTURE_DIR, overrideConfig: { - env: { es6: true, node: true }, - parser: PARSER_PATH, + files: ["*.vue"], + languageOptions: { + parser, + globals: {}, + }, }, - useEslintrc: false, + overrideConfigFile: true, }) const report = await cli.lintFiles(["svg-attrs-camel-case.vue"]) const messages = report[0].messages @@ -477,18 +573,21 @@ describe("Basic tests", () => { const cli = new ESLint({ cwd: FIXTURE_DIR, overrideConfig: { - env: { browser: true, node: true }, - parser: PARSER_PATH, - parserOptions: { - ...BABEL_PARSER_OPTIONS, - sourceType: "module", - ecmaVersion: 2017, + files: ["*.vue"], + languageOptions: { + parser, + parserOptions: { + ...BABEL_PARSER_OPTIONS, + sourceType: "module", + ecmaVersion: "latest", + }, + globals: {}, }, rules: { "no-use-before-define": "error", }, }, - useEslintrc: false, + overrideConfigFile: true, }) const report = await cli.lintFiles([ "location-issue-with-babel-eslint.vue", @@ -644,7 +743,7 @@ describe("Basic tests", () => { const indexOfDecorator = code.indexOf("@Component") const ast = parse(code, { ...BABEL_PARSER_OPTIONS, - ecmaVersion: 2017, + ecmaVersion: "latest", sourceType: "module", // Implicit parserOptions to detect whether the current ESLint supports `result.scopeManager` and `result.visitorKeys`. @@ -664,22 +763,25 @@ describe("Basic tests", () => { it("should work even if AST object was reused.", () => { const code = "" const config = { - parser: PARSER_PATH, + languageOptions: { + parser, + }, + plugins: buildPlugins({ + create(context) { + return context.sourceCode.parserServices.defineTemplateBodyVisitor( + { + "VElement[name='div']"(node) { + context.report({ node, message: "OK" }) + }, + }, + ) + }, + }), rules: { - "test-rule": "error", + "test/test-rule": "error", }, } const linter = new Linter() - - linter.defineParser(PARSER_PATH, require(PARSER_PATH)) - linter.defineRule("test-rule", (context) => - context.parserServices.defineTemplateBodyVisitor({ - "VElement[name='div']"(node) { - context.report({ node, message: "OK" }) - }, - }), - ) - const messages1 = linter.verify(code, config) const messages2 = linter.verify(linter.getSourceCode(), config) @@ -692,22 +794,28 @@ describe("Basic tests", () => { it("should work even if used sibling selector.", () => { const code = "" const config = { - parser: PARSER_PATH, + languageOptions: { + parser, + }, + plugins: buildPlugins({ + create(context) { + return context.sourceCode.parserServices.defineTemplateBodyVisitor( + { + "* ~ *"(node) { + context.report({ + node, + message: "OK", + }) + }, + }, + ) + }, + }), rules: { - "test-rule": "error", + "test/test-rule": "error", }, } const linter = new Linter() - - linter.defineParser(PARSER_PATH, require(PARSER_PATH)) - linter.defineRule("test-rule", (context) => - context.parserServices.defineTemplateBodyVisitor({ - "* ~ *"(node) { - context.report({ node, message: "OK" }) - }, - }), - ) - const messages1 = linter.verify(code, config) const messages2 = linter.verify(linter.getSourceCode(), config) @@ -723,12 +831,11 @@ describe("Basic tests", () => { const code = '' const config = { - parser: PARSER_PATH, + languageOptions: { + parser, + }, } const linter = new Linter() - - linter.defineParser(PARSER_PATH, require(PARSER_PATH)) - const messages = linter.verify(code, config) assert.strictEqual(messages.length, 1) @@ -740,15 +847,14 @@ describe("Basic tests", () => { it("should notify parsing error #2", () => { const code = "" const config = { - parser: PARSER_PATH, - parserOptions: { - ecmaVersion: 2015, + languageOptions: { + parser, + parserOptions: { + ecmaVersion: "latest", + }, }, } const linter = new Linter() - - linter.defineParser(PARSER_PATH, require(PARSER_PATH)) - const messages = linter.verify(code, config) assert.strictEqual(messages.length, 1) @@ -760,12 +866,11 @@ describe("Basic tests", () => { it("should notify parsing error #3", () => { const code = '' const config = { - parser: PARSER_PATH, + languageOptions: { + parser, + }, } const linter = new Linter() - - linter.defineParser(PARSER_PATH, require(PARSER_PATH)) - const messages = linter.verify(code, config) assert.strictEqual(messages.length, 1) @@ -778,15 +883,14 @@ describe("Basic tests", () => { const code = "" const config = { - parser: PARSER_PATH, + languageOptions: { + parser, + }, rules: { "no-undef": "error", }, } const linter = new Linter() - - linter.defineParser(PARSER_PATH, require(PARSER_PATH)) - const messages = linter.verify(code, config) assert.strictEqual(messages.length, 1) @@ -794,3 +898,13 @@ describe("Basic tests", () => { }) }) }) + +function buildPlugins(rule) { + return { + test: { + rules: { + "test-rule": rule, + }, + }, + } +} diff --git a/test/integrations.js b/test/integrations.js new file mode 100644 index 00000000..88e9c501 --- /dev/null +++ b/test/integrations.js @@ -0,0 +1,101 @@ +//------------------------------------------------------------------------------ +// Requirements +//------------------------------------------------------------------------------ + +const assert = require("assert") +const path = require("path") +const fs = require("fs-extra") +const cp = require("child_process") +const eslintCompat = require("./lib/eslint-compat") + +//------------------------------------------------------------------------------ +// Helpers +//------------------------------------------------------------------------------ + +const FIXTURE_DIR = path.join(__dirname, "fixtures/integrations") + +//------------------------------------------------------------------------------ +// Tests +//------------------------------------------------------------------------------ + +describe("Integration tests", () => { + for (const target of fs.readdirSync(FIXTURE_DIR)) { + it(target, async () => { + let ESLint = eslintCompat(require("eslint")).ESLint + if (fs.existsSync(path.join(FIXTURE_DIR, target, "package.json"))) { + const originalCwd = process.cwd() + try { + process.chdir(path.join(FIXTURE_DIR, target)) + cp.execSync("npm i", { stdio: "inherit" }) + ESLint = eslintCompat( + require( + path.join( + FIXTURE_DIR, + target, + "node_modules/eslint", + ), + ), + ).ESLint + } finally { + process.chdir(originalCwd) + } + } + const cwd = path.join(FIXTURE_DIR, target) + const cli = new ESLint({ + cwd, + }) + const report = await cli.lintFiles(["**/*.vue"]) + + const outputPath = path.join(FIXTURE_DIR, target, `output.json`) + const expected = JSON.parse(fs.readFileSync(outputPath, "utf8")) + try { + assert.deepStrictEqual( + normalizeReport(report, { withoutMessage: true }), + normalizeReport(expected, { + withoutMessage: true, + }), + ) + } catch (e) { + const actualPath = path.join( + FIXTURE_DIR, + target, + `_actual.json`, + ) + fs.writeFileSync( + actualPath, + JSON.stringify(normalizeReport(report), null, 4), + "utf8", + ) + throw e + } + + function normalizeReport(report, option = {}) { + return report + .filter((res) => res.messages.length) + .map((res) => { + return { + filePath: res.filePath + .replace(cwd, "") + .replace(/\\/gu, "/"), + messages: res.messages.map((msg) => { + return { + ruleId: msg.ruleId, + line: msg.line, + ...(option.withoutMessage + ? {} + : { message: msg.message }), + } + }), + } + }) + .sort((a, b) => + a.filePath < b.filePath + ? -1 + : a.filePath < b.filePath + ? 1 + : 0, + ) + } + }) + } +}) diff --git a/test/lib/eslint-compat.js b/test/lib/eslint-compat.js index 041807f3..9077ec55 100644 --- a/test/lib/eslint-compat.js +++ b/test/lib/eslint-compat.js @@ -80,7 +80,6 @@ function getESLintClassForV6(eslint) { * @param {Parameters} params * @returns {ReturnType} */ - // eslint-disable-next-line require-await -- ignore async lintText(...params) { const result = this.engine.executeOnText( params[0], @@ -93,7 +92,6 @@ function getESLintClassForV6(eslint) { * @param {Parameters} params * @returns {ReturnType} */ - // eslint-disable-next-line require-await -- ignore async lintFiles(...params) { const result = this.engine.executeOnFiles( Array.isArray(params[0]) ? params[0] : [params[0]], @@ -105,7 +103,6 @@ function getESLintClassForV6(eslint) { * @param {Parameters} params * @returns {ReturnType} */ - // eslint-disable-next-line require-await -- ignore static async outputFixes(...params) { return eslint.CLIEngine.outputFixes({ results: params[0], diff --git a/test/parser-options-project.js b/test/parser-options-project.js new file mode 100644 index 00000000..1fc3b12a --- /dev/null +++ b/test/parser-options-project.js @@ -0,0 +1,134 @@ +"use strict" + +const assert = require("assert") +const { parseForESLint } = require("../src") +const espree = require("espree") + +describe("use `project: undefined` when parsing template script-let", () => { + it("should be the project option is defined only once in Simple SFC.", () => { + let projectCount = 0 + parseForESLint( + ` + + `, + { + project: true, + sourceType: "module", + ecmaVersion: "latest", + parser: { + parseForESLint(code, options) { + if (options.project) { + projectCount++ + } + + return { + ast: espree.parse(code, options), + } + }, + }, + }, + ) + assert.strictEqual(projectCount, 1) + }) + it("should be the project option is defined only once in + + + `, + { + project: true, + sourceType: "module", + ecmaVersion: "latest", + parser: { + parseForESLint(code, options) { + if (options.project) { + projectCount++ + } + + return { + ast: espree.parse(code, options), + } + }, + }, + }, + ) + assert.strictEqual(projectCount, 1) + }) + + it("should be the project option is defined only once in + + + `, + { + project: true, + sourceType: "module", + ecmaVersion: "latest", + parser: { + parseForESLint(code, options) { + if (options.project) { + projectCount++ + } + + return { + ast: espree.parse(code, options), + } + }, + }, + }, + ) + assert.strictEqual(projectCount, 1) + }) +}) diff --git a/test/parser-options.js b/test/parser-options.js index 2c7f26eb..3c7e4e1b 100644 --- a/test/parser-options.js +++ b/test/parser-options.js @@ -6,33 +6,43 @@ const assert = require("assert") const { parseForESLint } = require("../src") -const eslint = require("./fixtures/eslint") +const eslint = require("eslint") const Linter = eslint.Linter describe("parserOptions", () => { describe("parser", () => { - const linter = new Linter() - linter.defineParser("vue-eslint-parser", { parseForESLint }) - linter.defineRule("vue/template-test", { - create(context) { - return { - Program(node) { - const element = node.templateBody - if (element != null) { - context.report({ node, message: "test" }) + const linter = new Linter({ configType: "flat" }) + const parser = { parseForESLint } + const plugin = { + rules: { + "template-test": { + create(context) { + return { + Program(node) { + const element = node.templateBody + if (element != null) { + context.report({ node, message: "test" }) + } + }, } }, - } + }, }, - }) + } it("false then skip parsing '` const config = { - parser: "vue-eslint-parser", - parserOptions: { - parser: false, + files: ["*.vue"], + plugins: { + vue: plugin, + }, + languageOptions: { + parser, + parserOptions: { + parser: false, + }, }, rules: { "vue/template-test": "error", @@ -44,12 +54,19 @@ describe("parserOptions", () => { assert.strictEqual(messages[0].ruleId, "vue/template-test") }) - it("Fail in ` const config = { - parser: "vue-eslint-parser", - parserOptions: {}, + files: ["*.vue"], + plugins: { + vue: plugin, + }, + languageOptions: { + parser, + sourceType: "script", + parserOptions: {}, + }, rules: {}, } const messages = linter.verify(code, config, "test.vue") diff --git a/test/test-utils.js b/test/test-utils.js new file mode 100644 index 00000000..8ea0b760 --- /dev/null +++ b/test/test-utils.js @@ -0,0 +1,140 @@ +const escope = require("eslint-scope") + +module.exports = { replacer, getAllTokens, scopeToJSON, analyze } + +/** + * Remove `parent` properties from the given AST. + * @param {string} key The key. + * @param {any} value The value of the key. + * @returns {any} The value of the key to output. + */ +function replacer(key, value) { + if (key === "parent") { + return undefined + } + if (key === "errors" && Array.isArray(value)) { + return value.map((e) => ({ + message: e.message, + index: e.index, + lineNumber: e.lineNumber, + column: e.column, + })) + } + return value +} + +/** + * Get all tokens of the given AST. + * @param {ASTNode} ast The root node of AST. + * @returns {Token[]} Tokens. + */ +function getAllTokens(ast) { + const tokenArrays = [ast.tokens, ast.comments] + if (ast.templateBody != null) { + tokenArrays.push(ast.templateBody.tokens, ast.templateBody.comments) + } + return Array.prototype.concat.apply([], tokenArrays) +} + +function scopeToJSON(scopeManager) { + return JSON.stringify(normalizeScope(scopeManager.globalScope), replacer, 4) + + function normalizeScope(scope) { + return { + type: scope.type, + variables: scope.variables.map(normalizeVar), + references: scope.references.map(normalizeReference), + childScopes: scope.childScopes.map(normalizeScope), + through: scope.through.map(normalizeReference), + } + } + + function normalizeVar(v) { + return { + name: v.name, + identifiers: v.identifiers.map(normalizeId), + defs: v.defs.map(normalizeDef), + references: v.references.map(normalizeReference), + } + } + + function normalizeReference(reference) { + return { + identifier: normalizeId(reference.identifier), + from: reference.from.type, + resolved: normalizeId( + reference.resolved && + reference.resolved.defs && + reference.resolved.defs[0] && + reference.resolved.defs[0].name, + ), + init: reference.init ?? null, + vueUsedInTemplate: reference.vueUsedInTemplate + ? reference.vueUsedInTemplate + : undefined, + } + } + + function normalizeDef(def) { + return { + type: def.type, + node: normalizeDefNode(def.node), + name: def.name.name, + } + } + + function normalizeId(identifier) { + return ( + identifier && { + type: identifier.type, + name: identifier.name, + loc: identifier.loc, + } + ) + } + + function normalizeDefNode(node) { + return { + type: node.type, + loc: node.loc, + } + } +} + +/** + * Analyze scope + */ +function analyze(ast, parserOptions) { + const ecmaVersion = parserOptions.ecmaVersion ?? 2022 + const ecmaFeatures = parserOptions.ecmaFeatures ?? {} + const sourceType = parserOptions.sourceType ?? "script" + const result = escope.analyze(ast, { + ignoreEval: true, + nodejsScope: false, + impliedStrict: ecmaFeatures.impliedStrict, + ecmaVersion, + sourceType, + fallback: getFallbackKeys, + }) + + return result + + function getFallbackKeys(node) { + return Object.keys(node).filter(fallbackKeysFilter, node) + } + + function fallbackKeysFilter(key) { + const value = null + return ( + key !== "comments" && + key !== "leadingComments" && + key !== "loc" && + key !== "parent" && + key !== "range" && + key !== "tokens" && + key !== "trailingComments" && + typeof value === "object" && + (typeof value.type === "string" || Array.isArray(value)) + ) + } +} diff --git a/test/tokens.js b/test/tokens.js index 09cc4a2c..de370298 100644 --- a/test/tokens.js +++ b/test/tokens.js @@ -52,10 +52,7 @@ describe("services.getTemplateBodyTokenStore", () => { let tokens = null before(() => { - const result = parse( - code, - Object.assign({ filePath: "test.vue" }, PARSER_OPTIONS), - ) + const result = parse(code, { filePath: "test.vue", ...PARSER_OPTIONS }) ast = result.ast tokens = result.services.getTemplateBodyTokenStore() }) @@ -288,4 +285,19 @@ describe("services.getTemplateBodyTokenStore", () => { assert.deepStrictEqual(actual, ["div", ">"]) }) }) + + describe("TokenStore#get{Range,Loc}()", () => { + it("should return loc and range.", () => { + const { + templateBody: { + children: [node], + tokens: [token], + }, + } = ast + assert.equal(typeof tokens.getRange(node)[0], "number") + assert.equal(typeof tokens.getRange(token)[1], "number") + assert.equal(typeof tokens.getLoc(node).start.line, "number") + assert.equal(typeof tokens.getLoc(node).end.column, "number") + }) + }) }) diff --git a/test/variables-references.js b/test/variables-references.js index 8bd41148..4e6a590b 100644 --- a/test/variables-references.js +++ b/test/variables-references.js @@ -34,10 +34,7 @@ describe("[references] expression containers", () => { let ast = null before(() => { - ast = parse( - code, - Object.assign({ filePath: "test.vue" }, PARSER_OPTIONS), - ).ast + ast = parse(code, { filePath: "test.vue", ...PARSER_OPTIONS }).ast }) it("should have references", () => { @@ -62,10 +59,7 @@ describe("[references] expression containers", () => { let ast = null before(() => { - ast = parse( - code, - Object.assign({ filePath: "test.vue" }, PARSER_OPTIONS), - ).ast + ast = parse(code, { filePath: "test.vue", ...PARSER_OPTIONS }).ast }) it("should have references", () => { @@ -83,10 +77,7 @@ describe("[references] expression containers", () => { let ast = null before(() => { - ast = parse( - code, - Object.assign({ filePath: "test.vue" }, PARSER_OPTIONS), - ).ast + ast = parse(code, { filePath: "test.vue", ...PARSER_OPTIONS }).ast }) it("should not include $event references.", () => { @@ -110,10 +101,7 @@ describe("[variables] elements", () => { let ast = null before(() => { - ast = parse( - code, - Object.assign({ filePath: "test.vue" }, PARSER_OPTIONS), - ).ast + ast = parse(code, { filePath: "test.vue", ...PARSER_OPTIONS }).ast }) it("should have references", () => { @@ -138,10 +126,7 @@ describe("[variables] elements", () => { let ast = null before(() => { - ast = parse( - code, - Object.assign({ filePath: "test.vue" }, PARSER_OPTIONS), - ).ast + ast = parse(code, { filePath: "test.vue", ...PARSER_OPTIONS }).ast }) it("should have references", () => { @@ -169,10 +154,7 @@ describe("[variables] elements", () => { let ast = null before(() => { - ast = parse( - code, - Object.assign({ filePath: "test.vue" }, PARSER_OPTIONS), - ).ast + ast = parse(code, { filePath: "test.vue", ...PARSER_OPTIONS }).ast }) it("should have variables", () => { @@ -204,10 +186,7 @@ describe("Variables of v-for and references", () => { let mustacheReferences3 = null before(() => { - const ast = parse( - code, - Object.assign({ filePath: "test.vue" }, PARSER_OPTIONS), - ).ast + const ast = parse(code, { filePath: "test.vue", ...PARSER_OPTIONS }).ast variables = ast.templateBody.children[0].variables vForReferences = ast.templateBody.children[0].startTag.attributes[0].value.references @@ -274,10 +253,7 @@ describe("Variables of template-scope and references", () => { let mustacheReferences3 = null before(() => { - const ast = parse( - code, - Object.assign({ filePath: "test.vue" }, PARSER_OPTIONS), - ).ast + const ast = parse(code, { filePath: "test.vue", ...PARSER_OPTIONS }).ast variables = ast.templateBody.children[0].variables vBindKeyReferences = ast.templateBody.children[0].startTag.attributes[1].value.references @@ -336,10 +312,7 @@ describe("Variables of v-for and references of dynamic arguments", () => { let vBindKeyReferences = null before(() => { - const ast = parse( - code, - Object.assign({ filePath: "test.vue" }, PARSER_OPTIONS), - ).ast + const ast = parse(code, { filePath: "test.vue", ...PARSER_OPTIONS }).ast variables = ast.templateBody.children[0].variables vForReferences = ast.templateBody.children[0].startTag.attributes[0].value.references @@ -358,3 +331,55 @@ describe("Variables of v-for and references of dynamic arguments", () => { assert(vBindKeyReferences[0].variable === variables[0]) }) }) + +describe("Variables of v-for and references of v-bind same-name shorthand", () => { + const code = '' + let variables = null + let vForReferences = null + let vBindReferences = null + + before(() => { + const ast = parse(code, { filePath: "test.vue", ...PARSER_OPTIONS }).ast + variables = ast.templateBody.children[0].variables + vForReferences = + ast.templateBody.children[0].startTag.attributes[0].value.references + vBindReferences = + ast.templateBody.children[0].startTag.attributes[1].value.references + }) + + it("should have relationship each other", () => { + assert(variables.length === 1) + assert(vForReferences.length === 1) + assert(vBindReferences.length === 1) + assert(variables[0].references.length === 1) + assert(variables[0].references[0] === vBindReferences[0]) + assert(vForReferences[0].variable === null) + assert(vBindReferences[0].variable === variables[0]) + }) +}) + +describe("Variables of v-for and references of v-bind same-name shorthand with kebab-case", () => { + const code = '' + let variables = null + let vForReferences = null + let vBindReferences = null + + before(() => { + const ast = parse(code, { filePath: "test.vue", ...PARSER_OPTIONS }).ast + variables = ast.templateBody.children[0].variables + vForReferences = + ast.templateBody.children[0].startTag.attributes[0].value.references + vBindReferences = + ast.templateBody.children[0].startTag.attributes[1].value.references + }) + + it("should have relationship each other", () => { + assert(variables.length === 1) + assert(vForReferences.length === 1) + assert(vBindReferences.length === 1) + assert(variables[0].references.length === 1) + assert(variables[0].references[0] === vBindReferences[0]) + assert(vForReferences[0].variable === null) + assert(vBindReferences[0].variable === variables[0]) + }) +}) diff --git a/tsconfig.json b/tsconfig.json index 189d89e2..e4cbfcc2 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,39 +1,41 @@ { - "compileOnSave": true, - "compilerOptions": { - "allowJs": false, - "allowSyntheticDefaultImports": true, - "allowUnreachableCode": false, - "allowUnusedLabels": false, - "alwaysStrict": true, - "baseUrl": ".", - "checkJs": false, - "declaration": true, - "esModuleInterop": true, - "forceConsistentCasingInFileNames": true, - "inlineSources": true, - "lib": ["es2015"], - "module": "commonjs", - "moduleResolution": "node", - "newLine": "LF", - "noEmitOnError": true, - "noFallthroughCasesInSwitch": true, - "noImplicitAny": true, - "noImplicitReturns": true, - "noImplicitThis": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "outDir": ".temp", - "paths": { - "*": ["typings/*"] - }, - "pretty": true, - "removeComments": true, - "sourceMap": true, - "sourceRoot": "src", - "strict": true, - "strictNullChecks": true, - "target": "es2015" + "compileOnSave": true, + "compilerOptions": { + "allowJs": false, + "allowSyntheticDefaultImports": true, + "allowUnreachableCode": false, + "allowUnusedLabels": false, + "alwaysStrict": true, + "baseUrl": ".", + "checkJs": false, + "declaration": true, + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "inlineSources": true, + "lib": ["es2015"], + "module": "commonjs", + "moduleResolution": "node", + "newLine": "LF", + "noEmitOnError": true, + "noFallthroughCasesInSwitch": true, + "noImplicitAny": true, + "noImplicitReturns": true, + "noImplicitThis": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "outDir": ".temp", + "paths": { + "*": ["typings/*"] }, - "include": ["src/**/*.ts"] + "pretty": true, + "removeComments": true, + "sourceMap": true, + "sourceRoot": "src", + "strict": true, + "strictNullChecks": true, + "target": "ES2024", + + "skipLibCheck": true + }, + "include": ["src/**/*.ts"] } diff --git a/typings/eslint-scope/index.d.ts b/typings/eslint-scope/index.d.ts index 61228932..6d14afcf 100644 --- a/typings/eslint-scope/index.d.ts +++ b/typings/eslint-scope/index.d.ts @@ -43,13 +43,13 @@ export interface Scope { variableScope: Scope } -export interface Variable { - defs: VariableDefinition[] - identifiers: estree.Identifier[] - name: string - references: Reference[] - scope: Scope - stack: boolean +export class Variable { + public defs: VariableDefinition[] + public identifiers: estree.Identifier[] + public name: string + public references: Reference[] + public scope: Scope + public stack: boolean } export interface VariableDefinition { @@ -59,20 +59,24 @@ export interface VariableDefinition { parent?: estree.Node } -export interface Reference { - from: Scope - identifier: estree.Identifier - partial: boolean - resolved: Variable | null - tainted: boolean - writeExpr: estree.Expression +export class Reference { + public from: Scope + public identifier: estree.Identifier + public partial: boolean + public resolved: Variable | null + public tainted: boolean + public writeExpr: estree.Expression + + public isRead(): boolean + public isReadOnly(): boolean + public isReadWrite(): boolean + public isStatic(): boolean + public isWrite(): boolean + public isWriteOnly(): boolean - isRead(): boolean - isReadOnly(): boolean - isReadWrite(): boolean - isStatic(): boolean - isWrite(): boolean - isWriteOnly(): boolean + // For typescript-eslint + public isTypeReference?: boolean + public isValueReference?: boolean } export declare const analyze: ( diff --git a/typings/esquery/index.d.ts b/typings/esquery/index.d.ts index 2e4d0fac..1861f0bb 100644 --- a/typings/esquery/index.d.ts +++ b/typings/esquery/index.d.ts @@ -4,9 +4,8 @@ * See LICENSE file in root directory for full license. */ -import type { Node } from "../../src/ast" -// eslint-disable-next-line @mysticatea/node/no-missing-import -import type { VisitorKeys } from "../eslint-visitor-keys" +import type { Node } from "../../src/ast/index" +import type { VisitorKeys } from "eslint-visitor-keys" export type Selector = | AdjacentSelector