diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 537f1533..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/workflows/CI.yml b/.github/workflows/CI.yml index ffe41eed..cdd408e3 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@v3 + uses: actions/checkout@v4 - name: Checkout submodules run: git submodule update --init - name: Install Node.js - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: - node-version: 16 + 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,65 +29,77 @@ jobs: name: Test strategy: matrix: - eslint: [7, 8] - node: [16, 17] + eslint: [9] + node: [18, 20, 21, 'lts/*'] os: [ubuntu-latest] include: # On other platforms - - eslint: 7 - node: 16 + - eslint: 9 + node: 'lts/*' os: windows-latest - - eslint: 7 - node: 16 - os: macos-12 - # On old Node.js versions - - eslint: 7 - node: 14 - os: ubuntu-latest - # On old ESLint versions - - eslint: 6 - node: 16 - os: ubuntu-latest - # On the minimum supported ESLint/Node.js version - - eslint: 6 - node: 14 - os: ubuntu-latest + - eslint: 9 + node: 'lts/*' + os: macos-latest runs-on: ${{ matrix.os }} steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Checkout submodules run: git submodule update --init - name: Install Node.js v${{ matrix.node }} - uses: actions/setup-node@v3 + 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] + + runs-on: ${{ matrix.os }} + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Checkout submodules + run: git submodule update --init + - name: Install Node.js v${{ matrix.node }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node }} + - name: Install Packages + run: npm install -f + - name: Install ESLint v${{ matrix.eslint }} + run: node scripts/ci-install-eslint ${{ matrix.eslint }} + - name: Test + run: npm run -s test:debug test-cov: name: Test and Send Coverage runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Checkout submodules run: git submodule update --init - - name: Install Node.js v16 - uses: actions/setup-node@v3 + - name: Install Node.js + uses: actions/setup-node@v4 with: - node-version: 16 + node-version: 'lts/*' - name: Install Packages run: npm install - - name: Install ESLint v8 - run: node scripts/ci-install-eslint 8.12.0 + - name: Install ESLint v9 + run: node scripts/ci-install-eslint 9 - name: Build run: npm run -s build - name: Test 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 c0f76f2f..b4d1a580 100644 --- a/README.md +++ b/README.md @@ -17,25 +17,21 @@ This parser allows us to lint the `<template>` of `.vue` files. We can make mist npm install --save-dev eslint vue-eslint-parser ``` -- Requires Node.js ^14.17.0, 16.0.0 or later. -- Requires ESLint 6.0.0 or later. - ## 📖 Usage -1. Write `parser` option into your `.eslintrc.*` file. -2. Use glob patterns or `--ext .vue` CLI option. +Write `parser` option into your `eslint.config.*` file. -```json -{ - "extends": "eslint:recommended", - "parser": "vue-eslint-parser" -} -``` - -```console -$ eslint "src/**/*.{js,vue}" -# or -$ eslint src --ext .vue +```js +import vueParser from "vue-eslint-parser" +export default [ + js.configs.recommended, + { + files: ["*.vue", "**/*.vue"], + languageOptions: { + parser: vueParser, + }, + } +] ``` ## 🔧 Options @@ -43,19 +39,25 @@ $ eslint src --ext .vue `parserOptions` has the same properties as what [espree](https://github.com/eslint/espree#usage), the default parser of ESLint, is supporting. For example: -```json -{ - "parser": "vue-eslint-parser", - "parserOptions": { - "sourceType": "module", - "ecmaVersion": 2018, - "ecmaFeatures": { - "globalReturn": false, - "impliedStrict": false, - "jsx": false - } +```js +import vueParser from "vue-eslint-parser" +export default [ + { + files: ["*.vue", "**/*.vue"], + languageOptions: { + parser: vueParser, + sourceType: "module", + ecmaVersion: "latest", + parserOptions: { + ecmaFeatures: { + globalReturn: false, + impliedStrict: false, + jsx: false + } + } + }, } -} +] ``` ### parserOptions.parser @@ -64,66 +66,65 @@ You can use `parserOptions.parser` property to specify a custom parser to parse Other properties than parser would be given to the specified parser. For example: -```json -{ - "parser": "vue-eslint-parser", - "parserOptions": { - "parser": "@babel/eslint-parser", - "sourceType": "module" +```js +import vueParser from "vue-eslint-parser" +import babelParser from "@babel/eslint-parser" +export default [ + { + files: ["*.vue", "**/*.vue"], + languageOptions: { + parser: vueParser, + parserOptions: { + parser: babelParser, + } + }, } -} +] ``` -```json -{ - "parser": "vue-eslint-parser", - "parserOptions": { - "parser": "@typescript-eslint/parser", - "sourceType": "module" +```js +import vueParser from "vue-eslint-parser" +import tsParser from "@typescript-eslint/parser" +export default [ + { + files: ["*.vue", "**/*.vue"], + languageOptions: { + parser: vueParser, + parserOptions: { + parser: tsParser, + } + }, } -} +] ``` You can also specify an object and change the parser separately for `<script lang="...">`. -```jsonc -{ - "parser": "vue-eslint-parser", - "parserOptions": { - "parser": { - // Script parser for `<script>` - "js": "espree", - - // Script parser for `<script lang="ts">` - "ts": "@typescript-eslint/parser", - - // Script parser for vue directives (e.g. `v-if=` or `:attribute=`) - // and vue interpolations (e.g. `{{variable}}`). - // If not specified, the parser determined by `<script lang ="...">` is used. - "<template>": "espree", - } - } -} -``` - -When using JavaScript configuration (`.eslintrc.js`), you can also give the parser object directly. - ```js -const tsParser = require("@typescript-eslint/parser") -const espree = require("espree") - -module.exports = { - parser: "vue-eslint-parser", - parserOptions: { - // Single parser - parser: tsParser, - // Multiple parser - parser: { - js: espree, - ts: tsParser, - } - }, -} +import vueParser from "vue-eslint-parser" +import tsParser from "@typescript-eslint/parser" +export default [ + { + files: ["*.vue", "**/*.vue"], + languageOptions: { + parser: vueParser, + parserOptions: { + "parser": { + // Script parser for `<script>` + "js": "espree", + + // Script parser for `<script lang="ts">` + "ts": tsParser, + + // Script parser for vue directives (e.g. `v-if=` or `:attribute=`) + // and vue interpolations (e.g. `{{variable}}`). + // If not specified, the parser determined by `<script lang ="...">` is used. + "<template>": "espree", + } + } + }, + } +] ``` If the `parserOptions.parser` is `false`, the `vue-eslint-parser` skips parsing `<script>` tags completely. @@ -134,18 +135,24 @@ This is useful for people who use the language ESLint community doesn't provide You can use `parserOptions.vueFeatures` property to specify how to parse related to Vue features. For example: -```json -{ - "parser": "vue-eslint-parser", - "parserOptions": { - "vueFeatures": { - "filter": true, - "interpolationAsNonHTML": true, - "styleCSSVariableInjection": true, - "customMacros": [] - } +```js +import vueParser from "vue-eslint-parser" +export default [ + { + files: ["*.vue", "**/*.vue"], + languageOptions: { + parser: vueParser, + parserOptions: { + vueFeatures: { + filter: true, + interpolationAsNonHTML: true, + styleCSSVariableInjection: true, + customMacros: [] + } + } + }, } -} +] ``` ### parserOptions.vueFeatures.filter @@ -155,7 +162,6 @@ For example: ```json { - "parser": "vue-eslint-parser", "parserOptions": { "vueFeatures": { "filter": false @@ -188,7 +194,6 @@ For example: ```json { - "parser": "vue-eslint-parser", "parserOptions": { "vueFeatures": { "interpolationAsNonHTML": true @@ -231,7 +236,6 @@ For example to enable parsing of pug templates: ```jsonc { - "parser": "vue-eslint-parser", "parserOptions": { "templateTokenizer": { // template tokenizer for `<template lang="pug">` @@ -314,9 +318,8 @@ Welcome contributing! Please use GitHub's Issues/PRs. -If you want to write code, please execute `npm install && npm run setup` after you cloned this repository. +If you want to write code, please execute `npm install` after you cloned this repository. The `npm install` command installs dependencies. -The `npm run setup` command initializes ESLint as git submodules for tests. ### Development Tools @@ -325,6 +328,5 @@ The `npm run setup` command initializes ESLint as git submodules for tests. - `npm run coverage` shows the coverage result of `npm test` command with the default browser. - `npm run clean` removes the temporary files which are created by `npm test` and `npm run build`. - `npm run lint` runs ESLint. -- `npm run setup` setups submodules to develop. - `npm run update-fixtures` updates files in `test/fixtures/ast` directory based on `test/fixtures/ast/*/source.vue` files. - `npm run watch` runs `build`, `update-fixtures`, and tests with `--watch` option. diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 00000000..5e81622f --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,800 @@ +import prettier from "eslint-plugin-prettier" +import typescriptEslint from "@typescript-eslint/eslint-plugin" +import eslintComments from "eslint-plugin-eslint-comments" +import node from "eslint-plugin-n" +import nodeDeps from "eslint-plugin-node-dependencies" +import unicorn from "eslint-plugin-unicorn" +import tsParser from "@typescript-eslint/parser" +import jsonParser from "jsonc-eslint-parser" +import path from "node:path" +import { fileURLToPath } from "node:url" +import js from "@eslint/js" +import { FlatCompat } from "@eslint/eslintrc" + +const __filename = fileURLToPath(import.meta.url) +const __dirname = path.dirname(__filename) +const compat = new FlatCompat({ + baseDirectory: __dirname, + recommendedConfig: js.configs.recommended, + allConfig: js.configs.all, +}) + +export default [ + { + ignores: [ + ".nyc_output", + ".temp", + "coverage", + "**/node_modules", + "src/html/util/alternative-cr.ts", + "src/html/util/attribute-names.ts", + "src/html/util/entities.ts", + "src/html/util/tag-names.ts", + "test/fixtures", + "test/temp", + "index.d.ts", + "index.js", + ], + }, + ...nodeDeps.configs["flat/recommended"], + ...compat.extends( + "plugin:node-dependencies/recommended", + "plugin:jsonc/recommended-with-jsonc", + ), + { + files: ["js", "mjs", "ts", "json"].flatMap((ext) => [ + "*." + ext, + "**/*." + ext, + ]), + plugins: { + prettier, + }, + + languageOptions: { + globals: { + root: "off", + }, + + ecmaVersion: "latest", + sourceType: "module", + + parserOptions: { + ecmaFeatures: { + globalReturn: false, + }, + + loggerFn: false, + project: "tsconfig.json", + }, + }, + + settings: { + node: { + tryExtensions: [".ts", ".js", ".json"], + }, + }, + + rules: { + "prettier/prettier": [ + "error", + { + tabWidth: 4, + semi: false, + trailingComma: "all", + }, + { + usePrettierrc: false, + }, + ], + }, + }, + { + files: ["*.json", "**/*.json"], + languageOptions: { + parser: jsonParser, + }, + + rules: { + "prettier/prettier": [ + "error", + { + tabWidth: 2, + semi: false, + trailingComma: "all", + }, + { + usePrettierrc: false, + }, + ], + }, + }, + { + files: ["**/*.ts"], + + plugins: { + "@typescript-eslint": typescriptEslint, + "eslint-comments": eslintComments, + node, + unicorn, + }, + + languageOptions: { + parser: tsParser, + globals: { + process: "readonly", + require: "readonly", + }, + }, + + 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": ["off"], + + "node/no-missing-import": ["off"], + "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/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": [ + "error", + { + typeof: true, + }, + ], + + "@typescript-eslint/no-unused-vars": [ + "error", + { + 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-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", + ], + }, + ], + + "unicorn/no-useless-fallback-in-spread": ["error"], + "unicorn/no-useless-spread": ["error"], + }, + }, + { + files: ["typings/**"], + + rules: { + "node/no-missing-import": [ + "error", + { + allowModules: ["estree"], + }, + ], + }, + }, + { + files: ["**/package.json"], + + rules: { + "@mysticatea/prettier": "off", + }, + }, +] diff --git a/package.json b/package.json index 12f2dfb8..6f45d9be 100644 --- a/package.json +++ b/package.json @@ -1,65 +1,67 @@ { "name": "vue-eslint-parser", - "version": "9.4.3", + "version": "10.0.0", "description": "The ESLint custom parser for `.vue` files.", - "engines": { - "node": "^14.17.0 || >=16.0.0" - }, "main": "index.js", "files": [ "index.*" ], + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, "peerDependencies": { - "eslint": ">=6.0.0" + "eslint": "^8.57.0 || ^9.0.0" }, "dependencies": { - "debug": "^4.3.4", - "eslint-scope": "^7.1.1", - "eslint-visitor-keys": "^3.3.0", - "espree": "^9.3.1", - "esquery": "^1.4.0", + "debug": "^4.4.0", + "eslint-scope": "^8.2.0", + "eslint-visitor-keys": "^4.2.0", + "espree": "^10.3.0", + "esquery": "^1.6.0", "lodash": "^4.17.21", - "semver": "^7.3.6" + "semver": "^7.6.3" }, "devDependencies": { - "@babel/core": "^7.16.0", - "@babel/eslint-parser": "^7.16.3", - "@babel/plugin-syntax-decorators": "^7.16.0", - "@babel/plugin-syntax-pipeline-operator": "^7.16.0", - "@babel/plugin-syntax-typescript": "^7.16.0", + "@babel/core": "^7.26.7", + "@babel/eslint-parser": "^7.26.5", + "@babel/plugin-syntax-decorators": "^7.25.9", + "@babel/plugin-syntax-pipeline-operator": "^7.26.7", + "@babel/plugin-syntax-typescript": "^7.25.9", + "@eslint/eslintrc": "^3.2.0", + "@eslint/js": "^9.19.0", "@types/debug": "^4.1.7", - "@types/eslint": "^8.4.6", "@types/estree": "^1.0.0", "@types/lodash": "^4.14.186", "@types/mocha": "^9.0.0", "@types/node": "^18.8.4", "@types/semver": "^7.3.12", - "@typescript-eslint/eslint-plugin": "^5.18.0", - "@typescript-eslint/parser": "^5.18.0", + "@typescript-eslint/eslint-plugin": "^8.22.0", + "@typescript-eslint/parser": "^8.22.0", "chokidar": "^3.5.2", "codecov": "^3.8.3", "cross-spawn": "^7.0.3", "dts-bundle": "^0.7.3", - "eslint": "^8.12.0", + "eslint": "^9.19.0", "eslint-plugin-eslint-comments": "^3.2.0", - "eslint-plugin-jsonc": "^2.2.1", - "eslint-plugin-node": "^11.1.0", - "eslint-plugin-node-dependencies": "^0.8.0", - "eslint-plugin-prettier": "^4.0.0", + "eslint-plugin-jsonc": "^2.19.1", + "eslint-plugin-n": "^17.15.1", + "eslint-plugin-node-dependencies": "^0.12.0", + "eslint-plugin-prettier": "^5.2.3", + "eslint-plugin-unicorn": "^57.0.0", "fs-extra": "^10.0.0", "jsonc-eslint-parser": "^2.0.3", "mocha": "^9.1.3", "npm-run-all": "^4.1.5", "nyc": "^15.1.0", "opener": "^1.5.2", - "prettier": "^2.4.1", + "prettier": "^3.4.2", "rimraf": "^3.0.2", "rollup": "^2.60.0", "rollup-plugin-node-resolve": "^5.2.0", "rollup-plugin-replace": "^2.2.0", "rollup-plugin-sourcemaps": "^0.6.3", - "ts-node": "^10.4.0", - "typescript": "~4.8.4", + "ts-node": "^10.9.2", + "typescript": "~5.7.3", "wait-on": "^6.0.0", "warun": "^1.0.0" }, @@ -69,8 +71,7 @@ "clean": "rimraf .nyc_output .temp coverage index.*", "codecov": "codecov", "coverage": "opener ./coverage/lcov-report/index.html", - "lint": "eslint src test package.json --ext .js,.ts", - "setup": "git submodule update --init && cd test/fixtures/eslint && npm install", + "lint": "eslint src test package.json", "pretest": "run-s build lint", "test": "npm run -s test:mocha", "test:mocha": "mocha --require ts-node/register \"test/*.js\" --reporter dot --timeout 60000", diff --git a/scripts/ci-install-eslint.js b/scripts/ci-install-eslint.js index 11905a72..c3626692 100644 --- a/scripts/ci-install-eslint.js +++ b/scripts/ci-install-eslint.js @@ -29,18 +29,18 @@ function sh(command) { : `^${requestedVersion}` // Install ESLint of the requested version - await sh(`npm install eslint@${requestedVersionSpec} --legacy-peer-deps`) + await sh(`npm install eslint@${requestedVersionSpec} -f`) // Install ESLint submodule of the requested version - const installedVersion = require("eslint/package.json").version - cd("test/fixtures/eslint") - if (!installedVersion.startsWith("8.")) { - await sh(`git checkout v${installedVersion}`) - } - if (installedVersion.startsWith("5.")) { - await sh("npm install eslint-utils@1.4.0") - } - await sh("npm install --legacy-peer-deps") + // const installedVersion = require("eslint/package.json").version + // cd("test/fixtures/eslint") + // if (!installedVersion.startsWith("8.")) { + // await sh(`git checkout v${installedVersion}`) + // } + // if (installedVersion.startsWith("5.")) { + // await sh("npm install eslint-utils@1.4.0") + // } + // await sh("npm install -f") })().catch((error) => { console.error(error) process.exitCode = 1 diff --git a/scripts/update-fixtures-ast.js b/scripts/update-fixtures-ast.js index cb32843c..6f6e780b 100644 --- a/scripts/update-fixtures-ast.js +++ b/scripts/update-fixtures-ast.js @@ -28,7 +28,8 @@ const ROOT = path.join(__dirname, "../test/fixtures/ast") const TARGETS = fs.readdirSync(ROOT) const PARSER_OPTIONS = { comment: true, - ecmaVersion: 2020, + ecmaVersion: "latest", + sourceType: "module", loc: true, range: true, tokens: true, @@ -101,11 +102,11 @@ for (const name of TARGETS) { const servicesPath = path.join(ROOT, `${name}/services.json`) const source = fs.readFileSync(sourcePath, "utf8") const parserOptions = optionsPath ? require(optionsPath) : {} - const options = Object.assign( - { filePath: sourcePath }, - PARSER_OPTIONS, - parserOptions, - ) + const options = { + filePath: sourcePath, + ...PARSER_OPTIONS, + ...parserOptions, + } // console.log("Start:", name) const actual = parser.parseForESLint(source, options) const tokenRanges = getAllTokens(actual.ast).map((t) => diff --git a/scripts/update-fixtures-document-fragment.js b/scripts/update-fixtures-document-fragment.js index ef8c4110..470bc262 100644 --- a/scripts/update-fixtures-document-fragment.js +++ b/scripts/update-fixtures-document-fragment.js @@ -16,11 +16,11 @@ const ROOT = path.join(__dirname, "../test/fixtures/document-fragment") const TARGETS = fs.readdirSync(ROOT) const PARSER_OPTIONS = { comment: true, - ecmaVersion: 6, + ecmaVersion: "latest", + sourceType: "module", loc: true, range: true, tokens: true, - sourceType: "module", } /** @@ -58,11 +58,12 @@ for (const name of TARGETS) { path.join(ROOT, `${name}/parser-options.js`), ].find((fp) => fs.existsSync(fp)) const source = fs.readFileSync(sourcePath, "utf8") - const options = Object.assign( - { filePath: sourcePath }, - PARSER_OPTIONS, - optionsPath ? require(optionsPath) : {}, - ) + const options = { + filePath: sourcePath, + ...PARSER_OPTIONS, + ...(optionsPath ? require(optionsPath) : {}), + } + const result = parser.parseForESLint(source, options) const actual = result.services.getDocumentFragment() diff --git a/src/ast/traverse.ts b/src/ast/traverse.ts index 448f210a..e9395072 100644 --- a/src/ast/traverse.ts +++ b/src/ast/traverse.ts @@ -27,6 +27,7 @@ export const KEYS = Evk.unionWith({ VSlotScopeExpression: ["params"], VStartTag: ["attributes"], VText: [], + VGenericExpression: ["params"], }) /** @@ -82,7 +83,7 @@ function traverse(node: Node, parent: Node | null, visitor: Visitor): void { visitor.enterNode(node, parent) const keys = - (visitor.visitorKeys || KEYS)[node.type] || getFallbackKeys(node) + (visitor.visitorKeys ?? KEYS)[node.type] ?? getFallbackKeys(node) for (i = 0; i < keys.length; ++i) { const child = (node as any)[keys[i]] diff --git a/src/common/ast-utils.ts b/src/common/ast-utils.ts index e87b8365..ae541bc6 100644 --- a/src/common/ast-utils.ts +++ b/src/common/ast-utils.ts @@ -6,7 +6,7 @@ import type { VExpressionContainer, VGenericExpression, VNode, -} from "../ast" +} from "../ast/index" /** * Check whether the node is a `<script>` element. @@ -78,8 +78,8 @@ export function isLang( * @returns The `lang` attribute value. */ export function getLang(element: VElement | undefined): string | null { - const langAttr = element && element.startTag.attributes.find(isLang) - const lang = langAttr && langAttr.value && langAttr.value.value + const langAttr = element?.startTag.attributes.find(isLang) + const lang = langAttr?.value?.value return lang || null } /** diff --git a/src/common/create-require.ts b/src/common/create-require.ts deleted file mode 100644 index 6c536680..00000000 --- a/src/common/create-require.ts +++ /dev/null @@ -1,17 +0,0 @@ -import Module from "module" -import path from "path" -export const createRequire: (filename: string) => (modname: string) => any = - // Added in v12.2.0 - (Module as any).createRequire || - // Added in v10.12.0, but deprecated in v12.2.0. - (Module as any).createRequireFromPath || - // Polyfill - This is not executed on the tests on node@>=10. - /* istanbul ignore next */ - ((modname) => { - const mod = new Module(modname) - - mod.filename = modname - mod.paths = (Module as any)._nodeModulePaths(path.dirname(modname)) - ;(mod as any)._compile("module.exports = require;", modname) - return mod.exports - }) diff --git a/src/common/error-utils.ts b/src/common/error-utils.ts index 2aad6de4..378aacba 100644 --- a/src/common/error-utils.ts +++ b/src/common/error-utils.ts @@ -1,4 +1,4 @@ -import type { ParseError, VDocumentFragment } from "../ast" +import type { ParseError, VDocumentFragment } from "../ast/index" import sortedIndexBy from "lodash/sortedIndexBy" /** * Insert the given error. diff --git a/src/common/eslint-scope.ts b/src/common/eslint-scope.ts index 22209f52..d5a0db21 100644 --- a/src/common/eslint-scope.ts +++ b/src/common/eslint-scope.ts @@ -1,25 +1,41 @@ import * as escope from "eslint-scope" -import { getLinterRequire } from "./linter-require" import { lte } from "semver" +import path from "path" +import { createRequire } from "module" -let escopeCache: typeof escope | null = null +type ESLintScope = typeof escope & { + version: string +} +let escopeCache: ESLintScope | null = null /** * Load the newest `eslint-scope` from the loaded ESLint or dependency. */ -export function getEslintScope(): typeof escope & { - version: string -} { - if (!escopeCache) { - escopeCache = getLinterRequire()?.("eslint-scope") - if ( - !escopeCache || - escopeCache.version == null || - lte(escopeCache.version, escope.version) - ) { - escopeCache = escope - } +export function getEslintScope(): ESLintScope { + return escopeCache ?? (escopeCache = getNewest()) +} + +/** + * Load the newest `eslint-scope` from the dependency. + */ +function getNewest(): ESLintScope { + let newest = escope + const userEscope = getEslintScopeFromUser() + if (userEscope.version != null && lte(newest.version, userEscope.version)) { + newest = userEscope } + return newest +} - return escopeCache +/** + * Load `eslint-scope` from the user dir. + */ +function getEslintScopeFromUser(): ESLintScope { + try { + const cwd = process.cwd() + const relativeTo = path.join(cwd, "__placeholder__.js") + return createRequire(relativeTo)("eslint-scope") + } catch { + return escope + } } diff --git a/src/common/espree.ts b/src/common/espree.ts index 3f904f39..8622ff32 100644 --- a/src/common/espree.ts +++ b/src/common/espree.ts @@ -1,14 +1,13 @@ import type { ParserOptions } from "../common/parser-options" -import { getLinterRequire } from "./linter-require" // @ts-expect-error -- ignore import * as dependencyEspree from "espree" -import { lte, lt } from "semver" -import { createRequire } from "./create-require" +import { lte } from "semver" import path from "path" import type { BasicParserObject } from "./parser-object" +import { createRequire } from "module" type Espree = BasicParserObject & { - latestEcmaVersion?: number + latestEcmaVersion: number version: string } let espreeCache: Espree | null = null @@ -16,68 +15,44 @@ let espreeCache: Espree | null = null /** * Gets the espree that the given ecmaVersion can parse. */ -export function getEspreeFromEcmaVersion( - ecmaVersion: ParserOptions["ecmaVersion"], -): Espree { - const linterEspree = getEspreeFromLinter() - if (ecmaVersion == null) { - return linterEspree - } - if (ecmaVersion === "latest") { - return getNewestEspree() +export function getEspree(): Espree { + return espreeCache ?? (espreeCache = getNewestEspree()) +} + +export function getEcmaVersionIfUseEspree( + parserOptions: ParserOptions, +): number | undefined { + if (parserOptions.parser != null && parserOptions.parser !== "espree") { + return undefined } + if ( - normalizeEcmaVersion(ecmaVersion) <= getLatestEcmaVersion(linterEspree) + parserOptions.ecmaVersion === "latest" || + parserOptions.ecmaVersion == null ) { - return linterEspree + return getDefaultEcmaVersion() } - const userEspree = getEspreeFromUser() - if (normalizeEcmaVersion(ecmaVersion) <= getLatestEcmaVersion(userEspree)) { - return userEspree - } - return linterEspree + return normalizeEcmaVersion(parserOptions.ecmaVersion) } /** * Load `espree` from the user dir. */ -export function getEspreeFromUser(): Espree { +function getEspreeFromUser(): Espree { try { const cwd = process.cwd() const relativeTo = path.join(cwd, "__placeholder__.js") return createRequire(relativeTo)("espree") } catch { - return getEspreeFromLinter() + return dependencyEspree } } /** - * Load `espree` from the loaded ESLint. - * If the loaded ESLint was not found, just returns `require("espree")`. - */ -export function getEspreeFromLinter(): Espree { - if (!espreeCache) { - espreeCache = getLinterRequire()?.("espree") - if (!espreeCache) { - espreeCache = dependencyEspree - } - } - - return espreeCache! -} - -/** - * Load the newest `espree` from the loaded ESLint or dependency. + * Load the newest `espree` from the dependency. */ function getNewestEspree(): Espree { let newest = dependencyEspree - const linterEspree = getEspreeFromLinter() - if ( - linterEspree.version != null && - lte(newest.version, linterEspree.version) - ) { - newest = linterEspree - } const userEspree = getEspreeFromUser() if (userEspree.version != null && lte(newest.version, userEspree.version)) { newest = userEspree @@ -85,30 +60,8 @@ function getNewestEspree(): Espree { return newest } -export function getEcmaVersionIfUseEspree( - parserOptions: ParserOptions, - getDefault?: (defaultVer: number) => number, -): number | undefined { - if (parserOptions.parser != null && parserOptions.parser !== "espree") { - return undefined - } - - if (parserOptions.ecmaVersion === "latest") { - return normalizeEcmaVersion(getLatestEcmaVersion(getNewestEspree())) - } - if (parserOptions.ecmaVersion == null) { - const defVer = getDefaultEcmaVersion() - return getDefault?.(defVer) ?? defVer - } - return normalizeEcmaVersion(parserOptions.ecmaVersion) -} - function getDefaultEcmaVersion(): number { - if (lt(getEspreeFromLinter().version, "9.0.0")) { - return 5 - } - // Perhaps the version 9 will change the default to "latest". - return normalizeEcmaVersion(getLatestEcmaVersion(getNewestEspree())) + return getLatestEcmaVersion(getEspree()) } /** @@ -122,16 +75,5 @@ function normalizeEcmaVersion(version: number) { } function getLatestEcmaVersion(espree: Espree) { - if (espree.latestEcmaVersion == null) { - for (const { v, latest } of [ - { v: "6.1.0", latest: 2020 }, - { v: "4.0.0", latest: 2019 }, - ]) { - if (lte(v, espree.version)) { - return latest - } - } - return 2018 - } return normalizeEcmaVersion(espree.latestEcmaVersion) } diff --git a/src/common/fix-locations.ts b/src/common/fix-locations.ts index f92e7598..6bdbdb06 100644 --- a/src/common/fix-locations.ts +++ b/src/common/fix-locations.ts @@ -5,8 +5,8 @@ import type { LocationRange, Node, ParseError, -} from "../ast" -import { traverseNodes } from "../ast" +} from "../ast/index" +import { traverseNodes } from "../ast/index" import type { LocationCalculator } from "./location-calculator" /** @@ -24,10 +24,10 @@ export function fixLocations( ): void { fixNodeLocations(result.ast, result.visitorKeys, locationCalculator) - for (const token of result.ast.tokens || []) { + for (const token of result.ast.tokens ?? []) { fixLocation(token, locationCalculator) } - for (const comment of result.ast.comments || []) { + for (const comment of result.ast.comments ?? []) { fixLocation(comment, locationCalculator) } } diff --git a/src/common/lines-and-columns.ts b/src/common/lines-and-columns.ts index ff1feef5..c62d781a 100644 --- a/src/common/lines-and-columns.ts +++ b/src/common/lines-and-columns.ts @@ -1,5 +1,5 @@ import sortedLastIndex from "lodash/sortedLastIndex" -import type { Location } from "../ast" +import type { Location } from "../ast/index" import type { LocationCalculator } from "./location-calculator" /** * A class for getting lines and columns location. diff --git a/src/common/linter-require.ts b/src/common/linter-require.ts deleted file mode 100644 index 54fecba1..00000000 --- a/src/common/linter-require.ts +++ /dev/null @@ -1,26 +0,0 @@ -import path from "path" -import { createRequire } from "./create-require" - -function isLinterPath(p: string): boolean { - return ( - // ESLint 6 and above - p.includes( - `eslint${path.sep}lib${path.sep}linter${path.sep}linter.js`, - ) || - // ESLint 5 - p.includes(`eslint${path.sep}lib${path.sep}linter.js`) - ) -} - -export function getLinterRequire() { - // Lookup the loaded eslint - const linterPath = Object.keys(require.cache).find(isLinterPath) - if (linterPath) { - try { - return createRequire(linterPath) - } catch { - // ignore - } - } - return null -} diff --git a/src/common/location-calculator.ts b/src/common/location-calculator.ts index 987d5bf4..8c8cf344 100644 --- a/src/common/location-calculator.ts +++ b/src/common/location-calculator.ts @@ -4,7 +4,7 @@ * See LICENSE file in root directory for full license. */ import sortedLastIndex from "lodash/sortedLastIndex" -import type { Location } from "../ast" +import type { Location } from "../ast/index" import { LinesAndColumns } from "./lines-and-columns" /** @@ -62,7 +62,7 @@ export class LocationCalculatorForHtml super(ltOffsets) this.gapOffsets = gapOffsets this.ltOffsets = ltOffsets - this.baseOffset = baseOffset || 0 + this.baseOffset = baseOffset ?? 0 this.baseIndexOfGap = this.baseOffset === 0 ? 0 diff --git a/src/common/parser-object.ts b/src/common/parser-object.ts index c3d44ac9..95a66ec2 100644 --- a/src/common/parser-object.ts +++ b/src/common/parser-object.ts @@ -1,4 +1,4 @@ -import type { ESLintExtendedProgram, ESLintProgram } from "../ast" +import type { ESLintExtendedProgram, ESLintProgram } from "../ast/index" /** * The type of basic ESLint custom parser. diff --git a/src/common/parser-options.ts b/src/common/parser-options.ts index f23a1dd5..25656ab5 100644 --- a/src/common/parser-options.ts +++ b/src/common/parser-options.ts @@ -1,5 +1,5 @@ import * as path from "path" -import type { VDocumentFragment } from "../ast" +import type { VDocumentFragment } from "../ast/index" import type { CustomTemplateTokenizerConstructor } from "../html/custom-tokenizer" import { getLang, isScriptElement, isScriptSetupElement } from "./ast-utils" import type { ParserObject } from "./parser-object" @@ -30,6 +30,7 @@ export interface ParserOptions { lib?: string[] project?: string | string[] + projectService?: boolean | ProjectServiceOptions projectFolderIgnoreList?: string[] tsconfigRootDir?: string extraFileExtensions?: string[] @@ -55,6 +56,13 @@ export interface ParserOptions { > } +interface ProjectServiceOptions { + allowDefaultProject?: string[] + defaultProject?: string + loadTypeScriptPlugins?: boolean + maximumDefaultProjectFileMatchCount_THIS_WILL_SLOW_DOWN_LINTING?: number +} + export function isSFCFile(parserOptions: ParserOptions) { if (parserOptions.filePath === "<input>") { return true @@ -83,8 +91,8 @@ export function getScriptParser( parserLang == null ? [] : typeof parserLang === "string" - ? [parserLang] - : parserLang + ? [parserLang] + : parserLang for (const lang of parserLangs) { const parserForLang = lang && parser[lang] if ( diff --git a/src/common/token-utils.ts b/src/common/token-utils.ts index 4ce11d19..3013061d 100644 --- a/src/common/token-utils.ts +++ b/src/common/token-utils.ts @@ -1,6 +1,6 @@ import sortedIndexBy from "lodash/sortedIndexBy" import sortedLastIndexBy from "lodash/sortedLastIndexBy" -import type { LocationRange, Token, VDocumentFragment } from "../ast" +import type { LocationRange, Token, VDocumentFragment } from "../ast/index" import type { LinesAndColumns } from "./lines-and-columns" interface HasRange { diff --git a/src/external/node-event-generator.ts b/src/external/node-event-generator.ts index 7c74c54a..b8eb78dc 100644 --- a/src/external/node-event-generator.ts +++ b/src/external/node-event-generator.ts @@ -1,12 +1,13 @@ /** * This file is copied from `eslint/lib/util/node-event-generator.js` */ -import EventEmitter from "events" -import esquery, {ESQueryOptions, Selector} from "esquery" +import type EventEmitter from "events" +import type { ESQueryOptions, Selector } from "esquery" +import esquery from "esquery" import union from "lodash/union" import intersection from "lodash/intersection" import memoize from "lodash/memoize" -import {Node} from "../ast" +import type { Node } from "../ast/index" interface NodeSelector { rawSelector: string @@ -18,17 +19,18 @@ interface NodeSelector { } /** -* Gets the possible types of a selector -* @param parsedSelector An object (from esquery) describing the matching behavior of the selector -* @returns The node types that could possibly trigger this selector, or `null` if all node types could trigger it -*/ + * Gets the possible types of a selector + * @param parsedSelector An object (from esquery) describing the matching behavior of the selector + * @returns The node types that could possibly trigger this selector, or `null` if all node types could trigger it + */ function getPossibleTypes(parsedSelector: Selector): string[] | null { switch (parsedSelector.type) { case "identifier": return [parsedSelector.value] case "matches": { - const typesForComponents = parsedSelector.selectors.map(getPossibleTypes) + const typesForComponents = + parsedSelector.selectors.map(getPossibleTypes) if (typesForComponents.every(Boolean)) { return union(...(typesForComponents as string[][])) @@ -37,17 +39,17 @@ function getPossibleTypes(parsedSelector: Selector): string[] | null { } case "compound": { - const typesForComponents = parsedSelector.selectors.map(getPossibleTypes).filter(Boolean) as string[][] + const typesForComponents = parsedSelector.selectors + .map(getPossibleTypes) + .filter(Boolean) as string[][] // If all of the components could match any type, then the compound could also match any type. if (!typesForComponents.length) { return null } - /* - * If at least one of the components could only match a particular type, the compound could only match - * the intersection of those types. - */ + // If at least one of the components could only match a particular type, the compound could only match + // the intersection of those types. return intersection(...typesForComponents) } @@ -73,12 +75,19 @@ function countClassAttributes(parsedSelector: Selector): number { case "descendant": case "sibling": case "adjacent": - return countClassAttributes(parsedSelector.left) + countClassAttributes(parsedSelector.right) + return ( + countClassAttributes(parsedSelector.left) + + countClassAttributes(parsedSelector.right) + ) case "compound": case "not": case "matches": - return parsedSelector.selectors.reduce((sum, childSelector) => sum + countClassAttributes(childSelector), 0) + return parsedSelector.selectors.reduce( + (sum, childSelector) => + sum + countClassAttributes(childSelector), + 0, + ) case "attribute": case "field": @@ -102,12 +111,18 @@ function countIdentifiers(parsedSelector: Selector): number { case "descendant": case "sibling": case "adjacent": - return countIdentifiers(parsedSelector.left) + countIdentifiers(parsedSelector.right) + return ( + countIdentifiers(parsedSelector.left) + + countIdentifiers(parsedSelector.right) + ) case "compound": case "not": case "matches": - return parsedSelector.selectors.reduce((sum, childSelector) => sum + countIdentifiers(childSelector), 0) + return parsedSelector.selectors.reduce( + (sum, childSelector) => sum + countIdentifiers(childSelector), + 0, + ) case "identifier": return 1 @@ -127,10 +142,15 @@ function countIdentifiers(parsedSelector: Selector): number { * a value less than 0 if selectorA and selectorB have the same specificity, and selectorA <= selectorB alphabetically * a value greater than 0 if selectorA and selectorB have the same specificity, and selectorA > selectorB alphabetically */ -function compareSpecificity(selectorA: NodeSelector, selectorB: NodeSelector): number { - return selectorA.attributeCount - selectorB.attributeCount || +function compareSpecificity( + selectorA: NodeSelector, + selectorB: NodeSelector, +): number { + return ( + selectorA.attributeCount - selectorB.attributeCount || selectorA.identifierCount - selectorB.identifierCount || (selectorA.rawSelector <= selectorB.rawSelector ? -1 : 1) + ) } /** @@ -141,11 +161,12 @@ function compareSpecificity(selectorA: NodeSelector, selectorB: NodeSelector): n */ function tryParseSelector(rawSelector: string): Selector { try { - return esquery.parse(rawSelector.replace(/:exit$/, "")) - } - catch (err: any) { + return esquery.parse(rawSelector.replace(/:exit$/u, "")) + } catch (err: any) { if (typeof err.offset === "number") { - throw new Error(`Syntax error in selector "${rawSelector}" at position ${err.offset}: ${err.message}`) + throw new Error( + `Syntax error in selector "${rawSelector}" at position ${err.offset}: ${err.message}`, + ) } throw err } @@ -156,18 +177,20 @@ function tryParseSelector(rawSelector: string): Selector { * @param {string} rawSelector A raw AST selector * @returns {ASTSelector} A selector descriptor */ -const parseSelector = memoize<(rawSelector: string) => NodeSelector>(rawSelector => { - const parsedSelector = tryParseSelector(rawSelector) - - return { - rawSelector, - isExit: rawSelector.endsWith(":exit"), - parsedSelector, - listenerTypes: getPossibleTypes(parsedSelector), - attributeCount: countClassAttributes(parsedSelector), - identifierCount: countIdentifiers(parsedSelector), - } -}) +const parseSelector = memoize<(rawSelector: string) => NodeSelector>( + (rawSelector) => { + const parsedSelector = tryParseSelector(rawSelector) + + return { + rawSelector, + isExit: rawSelector.endsWith(":exit"), + parsedSelector, + listenerTypes: getPossibleTypes(parsedSelector), + attributeCount: countClassAttributes(parsedSelector), + identifierCount: countIdentifiers(parsedSelector), + } + }, +) //------------------------------------------------------------------------------ // Public Interface @@ -186,8 +209,8 @@ const parseSelector = memoize<(rawSelector: string) => NodeSelector>(rawSelector * ``` */ export default class NodeEventGenerator { - emitter: EventEmitter - esqueryOptions: ESQueryOptions + public emitter: EventEmitter + public esqueryOptions: ESQueryOptions private currentAncestry: Node[] private enterSelectorsByNodeType: Map<string, NodeSelector[]> @@ -196,10 +219,10 @@ export default class NodeEventGenerator { private anyTypeExitSelectors: NodeSelector[] /** - * @param emitter - An event emitter which is the destination of events. This emitter must already - * have registered listeners for all of the events that it needs to listen for. - */ - constructor(emitter: EventEmitter, esqueryOptions: ESQueryOptions) { + * @param emitter - An event emitter which is the destination of events. This emitter must already + * have registered listeners for all of the events that it needs to listen for. + */ + public constructor(emitter: EventEmitter, esqueryOptions: ESQueryOptions) { this.emitter = emitter this.esqueryOptions = esqueryOptions this.currentAncestry = [] @@ -208,21 +231,20 @@ export default class NodeEventGenerator { this.anyTypeEnterSelectors = [] this.anyTypeExitSelectors = [] - const eventNames = typeof emitter.eventNames === "function" - - // Use the built-in eventNames() function if available (Node 6+) - ? emitter.eventNames() - - /* - * Otherwise, use the private _events property. - * Using a private property isn't ideal here, but this seems to - * be the best way to get a list of event names without overriding - * addEventListener, which would hurt performance. This property - * is widely used and unlikely to be removed in a future version - * (see https://github.com/nodejs/node/issues/1817). Also, future - * node versions will have eventNames() anyway. - */ - : Object.keys((emitter as any)._events) + const eventNames = + typeof emitter.eventNames === "function" + ? // Use the built-in eventNames() function if available (Node 6+) + emitter.eventNames() + : /* + * Otherwise, use the private _events property. + * Using a private property isn't ideal here, but this seems to + * be the best way to get a list of event names without overriding + * addEventListener, which would hurt performance. This property + * is widely used and unlikely to be removed in a future version + * (see https://github.com/nodejs/node/issues/1817). Also, future + * node versions will have eventNames() anyway. + */ + Object.keys((emitter as any)._events) for (const rawSelector of eventNames) { if (typeof rawSelector === "symbol") { @@ -232,7 +254,9 @@ export default class NodeEventGenerator { if (selector.listenerTypes) { for (const nodeType of selector.listenerTypes) { - const typeMap = selector.isExit ? this.exitSelectorsByNodeType : this.enterSelectorsByNodeType + const typeMap = selector.isExit + ? this.exitSelectorsByNodeType + : this.enterSelectorsByNodeType let selectors = typeMap.get(nodeType) if (selectors == null) { @@ -240,9 +264,11 @@ export default class NodeEventGenerator { } selectors.push(selector) } - } - else { - (selector.isExit ? this.anyTypeExitSelectors : this.anyTypeEnterSelectors).push(selector) + } else { + ;(selector.isExit + ? this.anyTypeExitSelectors + : this.anyTypeEnterSelectors + ).push(selector) } } @@ -262,7 +288,14 @@ export default class NodeEventGenerator { * @param selector An AST selector descriptor */ private applySelector(node: Node, selector: NodeSelector): void { - if (esquery.matches(node, selector.parsedSelector, this.currentAncestry, this.esqueryOptions)) { + if ( + esquery.matches( + node, + selector.parsedSelector, + this.currentAncestry, + this.esqueryOptions, + ) + ) { this.emitter.emit(selector.rawSelector, node) } } @@ -273,25 +306,41 @@ export default class NodeEventGenerator { * @param isExit `false` if the node is currently being entered, `true` if it's currently being exited */ private applySelectors(node: Node, isExit: boolean): void { - const selectorsByNodeType = (isExit ? this.exitSelectorsByNodeType : this.enterSelectorsByNodeType).get(node.type) || [] - const anyTypeSelectors = isExit ? this.anyTypeExitSelectors : this.anyTypeEnterSelectors - - /* - * selectorsByNodeType and anyTypeSelectors were already sorted by specificity in the constructor. - * Iterate through each of them, applying selectors in the right order. - */ + const selectorsByNodeType = + (isExit + ? this.exitSelectorsByNodeType + : this.enterSelectorsByNodeType + ).get(node.type) || [] + const anyTypeSelectors = isExit + ? this.anyTypeExitSelectors + : this.anyTypeEnterSelectors + + // selectorsByNodeType and anyTypeSelectors were already sorted by specificity in the constructor. + // Iterate through each of them, applying selectors in the right order. let selectorsByTypeIndex = 0 let anyTypeSelectorsIndex = 0 - while (selectorsByTypeIndex < selectorsByNodeType.length || anyTypeSelectorsIndex < anyTypeSelectors.length) { + while ( + selectorsByTypeIndex < selectorsByNodeType.length || + anyTypeSelectorsIndex < anyTypeSelectors.length + ) { if ( selectorsByTypeIndex >= selectorsByNodeType.length || - (anyTypeSelectorsIndex < anyTypeSelectors.length && compareSpecificity(anyTypeSelectors[anyTypeSelectorsIndex], selectorsByNodeType[selectorsByTypeIndex]) < 0) + (anyTypeSelectorsIndex < anyTypeSelectors.length && + compareSpecificity( + anyTypeSelectors[anyTypeSelectorsIndex], + selectorsByNodeType[selectorsByTypeIndex], + ) < 0) ) { - this.applySelector(node, anyTypeSelectors[anyTypeSelectorsIndex++]) - } - else { - this.applySelector(node, selectorsByNodeType[selectorsByTypeIndex++]) + this.applySelector( + node, + anyTypeSelectors[anyTypeSelectorsIndex++], + ) + } else { + this.applySelector( + node, + selectorsByNodeType[selectorsByTypeIndex++], + ) } } } @@ -300,7 +349,7 @@ export default class NodeEventGenerator { * Emits an event of entering AST node. * @param node - A node which was entered. */ - enterNode(node: Node): void { + public enterNode(node: Node): void { if (node.parent) { this.currentAncestry.unshift(node.parent) } @@ -311,7 +360,7 @@ export default class NodeEventGenerator { * Emits an event of leaving AST node. * @param node - A node which was left. */ - leaveNode(node: Node): void { + public leaveNode(node: Node): void { this.applySelectors(node, true) this.currentAncestry.shift() } diff --git a/src/external/token-store/cursors/backward-token-comment-cursor.ts b/src/external/token-store/cursors/backward-token-comment-cursor.ts index 2659aabb..a1224329 100644 --- a/src/external/token-store/cursors/backward-token-comment-cursor.ts +++ b/src/external/token-store/cursors/backward-token-comment-cursor.ts @@ -2,8 +2,8 @@ * @fileoverview Define the cursor which iterates tokens and comments in reverse. * @author Toru Nagashima */ -import {Token} from "../../../ast" -import {getLastIndex, search} from "../utils" +import type { Token } from "../../../ast/index" +import { getLastIndex, search } from "../utils" import Cursor from "./cursor" /** @@ -24,7 +24,13 @@ export default class BackwardTokenCommentCursor extends Cursor { * @param startLoc - The start location of the iteration range. * @param endLoc - The end location of the iteration range. */ - constructor(tokens: Token[], comments: Token[], indexMap: { [key: number]: number }, startLoc: number, endLoc: number) { + public constructor( + tokens: Token[], + comments: Token[], + indexMap: { [key: number]: number }, + startLoc: number, + endLoc: number, + ) { super() this.tokens = tokens this.comments = comments @@ -34,22 +40,24 @@ export default class BackwardTokenCommentCursor extends Cursor { } /** @inheritdoc */ - moveNext(): boolean { - const token = (this.tokenIndex >= 0) ? this.tokens[this.tokenIndex] : null - const comment = (this.commentIndex >= 0) ? this.comments[this.commentIndex] : null + public moveNext(): boolean { + const token = this.tokenIndex >= 0 ? this.tokens[this.tokenIndex] : null + const comment = + this.commentIndex >= 0 ? this.comments[this.commentIndex] : null if (token && (!comment || token.range[1] > comment.range[1])) { this.current = token this.tokenIndex -= 1 - } - else if (comment) { + } else if (comment) { this.current = comment this.commentIndex -= 1 - } - else { + } else { this.current = null } - return this.current != null && (this.border === -1 || this.current.range[0] >= this.border) + return ( + this.current != null && + (this.border === -1 || this.current.range[0] >= this.border) + ) } } diff --git a/src/external/token-store/cursors/backward-token-cursor.ts b/src/external/token-store/cursors/backward-token-cursor.ts index 7f8742f3..ae7871d4 100644 --- a/src/external/token-store/cursors/backward-token-cursor.ts +++ b/src/external/token-store/cursors/backward-token-cursor.ts @@ -2,8 +2,8 @@ * @fileoverview Define the cursor which iterates tokens only in reverse. * @author Toru Nagashima */ -import {Token} from "../../../ast" -import {getFirstIndex, getLastIndex} from "../utils" +import type { Token } from "../../../ast/index" +import { getFirstIndex, getLastIndex } from "../utils" import Cursor from "./cursor" /** @@ -22,7 +22,13 @@ export default class BackwardTokenCursor extends Cursor { * @param startLoc - The start location of the iteration range. * @param endLoc - The end location of the iteration range. */ - constructor(tokens: Token[], _comments: Token[], indexMap: { [key: number]: number }, startLoc: number, endLoc: number) { + public constructor( + tokens: Token[], + _comments: Token[], + indexMap: { [key: number]: number }, + startLoc: number, + endLoc: number, + ) { super() this.tokens = tokens this.index = getLastIndex(tokens, indexMap, endLoc) @@ -30,7 +36,7 @@ export default class BackwardTokenCursor extends Cursor { } /** @inheritdoc */ - moveNext(): boolean { + public moveNext(): boolean { if (this.index >= this.indexEnd) { this.current = this.tokens[this.index] this.index -= 1 @@ -44,7 +50,7 @@ export default class BackwardTokenCursor extends Cursor { // /** @inheritdoc */ - getOneToken(): Token | null { - return (this.index >= this.indexEnd) ? this.tokens[this.index] : null + public getOneToken(): Token | null { + return this.index >= this.indexEnd ? this.tokens[this.index] : null } } diff --git a/src/external/token-store/cursors/cursor.ts b/src/external/token-store/cursors/cursor.ts index a3a0b8ee..8c6c247e 100644 --- a/src/external/token-store/cursors/cursor.ts +++ b/src/external/token-store/cursors/cursor.ts @@ -2,7 +2,7 @@ * @fileoverview Define the abstract class about cursors which iterate tokens. * @author Toru Nagashima */ -import {Token} from "../../../ast" +import type { Token } from "../../../ast/index" /** * The abstract class about cursors which iterate tokens. @@ -28,12 +28,12 @@ import {Token} from "../../../ast" * */ export default abstract class Cursor { - current: Token | null + public current: Token | null /** * Initializes this cursor. */ - constructor() { + public constructor() { this.current = null } @@ -42,7 +42,7 @@ export default abstract class Cursor { * This consumes this cursor. * @returns The first token or null. */ - getOneToken(): Token | null { + public getOneToken(): Token | null { return this.moveNext() ? this.current : null } @@ -51,7 +51,7 @@ export default abstract class Cursor { * This consumes this cursor. * @returns All tokens. */ - getAllTokens(): Token[] { + public getAllTokens(): Token[] { const tokens: Token[] = [] while (this.moveNext()) { @@ -66,5 +66,5 @@ export default abstract class Cursor { * @returns {boolean} `true` if the next token exists. * @abstract */ - abstract moveNext(): boolean + public abstract moveNext(): boolean } diff --git a/src/external/token-store/cursors/decorative-cursor.ts b/src/external/token-store/cursors/decorative-cursor.ts index 6e5658a2..c132f81f 100644 --- a/src/external/token-store/cursors/decorative-cursor.ts +++ b/src/external/token-store/cursors/decorative-cursor.ts @@ -18,13 +18,13 @@ export default class DecorativeCursor extends Cursor { * Initializes this cursor. * @param cursor - The cursor to be decorated. */ - constructor(cursor: Cursor) { + public constructor(cursor: Cursor) { super() this.cursor = cursor } /** @inheritdoc */ - moveNext(): boolean { + public moveNext(): boolean { const retv = this.cursor.moveNext() this.current = this.cursor.current diff --git a/src/external/token-store/cursors/filter-cursor.ts b/src/external/token-store/cursors/filter-cursor.ts index fa7ac154..23f453aa 100644 --- a/src/external/token-store/cursors/filter-cursor.ts +++ b/src/external/token-store/cursors/filter-cursor.ts @@ -2,8 +2,8 @@ * @fileoverview Define the cursor which ignores specified tokens. * @author Toru Nagashima */ -import {Token} from "../../../ast" -import Cursor from "./cursor" +import type { Token } from "../../../ast/index" +import type Cursor from "./cursor" import DecorativeCursor from "./decorative-cursor" /** @@ -17,13 +17,13 @@ export default class FilterCursor extends DecorativeCursor { * @param cursor - The cursor to be decorated. * @param predicate - The predicate function to decide tokens this cursor iterates. */ - constructor(cursor: Cursor, predicate: (token: Token) => boolean) { + public constructor(cursor: Cursor, predicate: (token: Token) => boolean) { super(cursor) this.predicate = predicate } /** @inheritdoc */ - moveNext(): boolean { + public moveNext(): boolean { const predicate = this.predicate while (super.moveNext()) { diff --git a/src/external/token-store/cursors/forward-token-comment-cursor.ts b/src/external/token-store/cursors/forward-token-comment-cursor.ts index 5ce99b0d..07cc49f2 100644 --- a/src/external/token-store/cursors/forward-token-comment-cursor.ts +++ b/src/external/token-store/cursors/forward-token-comment-cursor.ts @@ -2,8 +2,8 @@ * @fileoverview Define the cursor which iterates tokens and comments. * @author Toru Nagashima */ -import {Token} from "../../../ast" -import {getFirstIndex, search} from "../utils" +import type { Token } from "../../../ast/index" +import { getFirstIndex, search } from "../utils" import Cursor from "./cursor" /** @@ -24,7 +24,13 @@ export default class ForwardTokenCommentCursor extends Cursor { * @param startLoc - The start location of the iteration range. * @param endLoc - The end location of the iteration range. */ - constructor(tokens: Token[], comments: Token[], indexMap: { [key: number]: number }, startLoc: number, endLoc: number) { + public constructor( + tokens: Token[], + comments: Token[], + indexMap: { [key: number]: number }, + startLoc: number, + endLoc: number, + ) { super() this.tokens = tokens this.comments = comments @@ -34,22 +40,29 @@ export default class ForwardTokenCommentCursor extends Cursor { } /** @inheritdoc */ - moveNext(): boolean { - const token = (this.tokenIndex < this.tokens.length) ? this.tokens[this.tokenIndex] : null - const comment = (this.commentIndex < this.comments.length) ? this.comments[this.commentIndex] : null + public moveNext(): boolean { + const token = + this.tokenIndex < this.tokens.length + ? this.tokens[this.tokenIndex] + : null + const comment = + this.commentIndex < this.comments.length + ? this.comments[this.commentIndex] + : null if (token && (!comment || token.range[0] < comment.range[0])) { this.current = token this.tokenIndex += 1 - } - else if (comment) { + } else if (comment) { this.current = comment this.commentIndex += 1 - } - else { + } else { this.current = null } - return this.current != null && (this.border === -1 || this.current.range[1] <= this.border) + return ( + this.current != null && + (this.border === -1 || this.current.range[1] <= this.border) + ) } } diff --git a/src/external/token-store/cursors/forward-token-cursor.ts b/src/external/token-store/cursors/forward-token-cursor.ts index ea682011..e56010c8 100644 --- a/src/external/token-store/cursors/forward-token-cursor.ts +++ b/src/external/token-store/cursors/forward-token-cursor.ts @@ -2,8 +2,8 @@ * @fileoverview Define the cursor which iterates tokens only. * @author Toru Nagashima */ -import {Token} from "../../../ast" -import {getFirstIndex, getLastIndex} from "../utils" +import type { Token } from "../../../ast/index" +import { getFirstIndex, getLastIndex } from "../utils" import Cursor from "./cursor" /** @@ -22,7 +22,13 @@ export default class ForwardTokenCursor extends Cursor { * @param startLoc - The start location of the iteration range. * @param endLoc - The end location of the iteration range. */ - constructor(tokens: Token[], _comments: Token[], indexMap: { [key: number]: number }, startLoc: number, endLoc: number) { + public constructor( + tokens: Token[], + _comments: Token[], + indexMap: { [key: number]: number }, + startLoc: number, + endLoc: number, + ) { super() this.tokens = tokens this.index = getFirstIndex(tokens, indexMap, startLoc) @@ -30,7 +36,7 @@ export default class ForwardTokenCursor extends Cursor { } /** @inheritdoc */ - moveNext(): boolean { + public moveNext(): boolean { if (this.index <= this.indexEnd) { this.current = this.tokens[this.index] this.index += 1 @@ -44,12 +50,12 @@ export default class ForwardTokenCursor extends Cursor { // /** @inheritdoc */ - getOneToken(): Token | null { - return (this.index <= this.indexEnd) ? this.tokens[this.index] : null + public getOneToken(): Token | null { + return this.index <= this.indexEnd ? this.tokens[this.index] : null } /** @inheritdoc */ - getAllTokens(): Token[] { + public getAllTokens(): Token[] { return this.tokens.slice(this.index, this.indexEnd + 1) } } diff --git a/src/external/token-store/cursors/index.ts b/src/external/token-store/cursors/index.ts index e828d04f..0149a26a 100644 --- a/src/external/token-store/cursors/index.ts +++ b/src/external/token-store/cursors/index.ts @@ -2,10 +2,10 @@ * @fileoverview Define 2 token factories; forward and backward. * @author Toru Nagashima */ -import {Token} from "../../../ast" +import type { Token } from "../../../ast/index" import BackwardTokenCommentCursor from "./backward-token-comment-cursor" import BackwardTokenCursor from "./backward-token-cursor" -import Cursor from "./cursor" +import type Cursor from "./cursor" import FilterCursor from "./filter-cursor" import ForwardTokenCommentCursor from "./forward-token-comment-cursor" import ForwardTokenCursor from "./forward-token-cursor" @@ -18,14 +18,21 @@ import SkipCursor from "./skip-cursor" */ export class CursorFactory { private TokenCursor: typeof BackwardTokenCursor | typeof ForwardTokenCursor - private TokenCommentCursor: typeof BackwardTokenCommentCursor | typeof ForwardTokenCommentCursor + private TokenCommentCursor: + | typeof BackwardTokenCommentCursor + | typeof ForwardTokenCommentCursor /** * Initializes this cursor. * @param TokenCursor - The class of the cursor which iterates tokens only. * @param TokenCommentCursor - The class of the cursor which iterates the mix of tokens and comments. */ - constructor(TokenCursor: typeof BackwardTokenCursor | typeof ForwardTokenCursor, TokenCommentCursor: typeof BackwardTokenCommentCursor | typeof ForwardTokenCommentCursor) { + public constructor( + TokenCursor: typeof BackwardTokenCursor | typeof ForwardTokenCursor, + TokenCommentCursor: + | typeof BackwardTokenCommentCursor + | typeof ForwardTokenCommentCursor, + ) { this.TokenCursor = TokenCursor this.TokenCommentCursor = TokenCommentCursor } @@ -41,8 +48,17 @@ export class CursorFactory { * @param includeComments - The flag to iterate comments as well. * @returns The created base cursor. */ - createBaseCursor(tokens: Token[], comments: Token[], indexMap: { [key: number]: number }, startLoc: number, endLoc: number, includeComments: boolean): Cursor { - const TokenCursor = includeComments ? this.TokenCommentCursor : this.TokenCursor + public createBaseCursor( + tokens: Token[], + comments: Token[], + indexMap: { [key: number]: number }, + startLoc: number, + endLoc: number, + includeComments: boolean, + ): Cursor { + const TokenCursor = includeComments + ? this.TokenCommentCursor + : this.TokenCursor return new TokenCursor(tokens, comments, indexMap, startLoc, endLoc) } @@ -60,8 +76,26 @@ export class CursorFactory { * @param count - The maximum count of tokens the cursor iterates. Zero is no iteration for backward compatibility. * @returns The created cursor. */ - createCursor(tokens: Token[], comments: Token[], indexMap: { [key: number]: number }, startLoc: number, endLoc: number, includeComments: boolean, filter: ((token: Token) => boolean) | null, skip: number, count: number): Cursor { - let cursor = this.createBaseCursor(tokens, comments, indexMap, startLoc, endLoc, includeComments) + // eslint-disable-next-line max-params + public createCursor( + tokens: Token[], + comments: Token[], + indexMap: { [key: number]: number }, + startLoc: number, + endLoc: number, + includeComments: boolean, + filter: ((token: Token) => boolean) | null, + skip: number, + count: number, + ): Cursor { + let cursor = this.createBaseCursor( + tokens, + comments, + indexMap, + startLoc, + endLoc, + includeComments, + ) if (filter) { cursor = new FilterCursor(cursor, filter) @@ -77,5 +111,11 @@ export class CursorFactory { } } -export const forward = new CursorFactory(ForwardTokenCursor, ForwardTokenCommentCursor) -export const backward = new CursorFactory(BackwardTokenCursor, BackwardTokenCommentCursor) +export const forward = new CursorFactory( + ForwardTokenCursor, + ForwardTokenCommentCursor, +) +export const backward = new CursorFactory( + BackwardTokenCursor, + BackwardTokenCommentCursor, +) diff --git a/src/external/token-store/cursors/limit-cursor.ts b/src/external/token-store/cursors/limit-cursor.ts index 9f01227b..bd696b31 100644 --- a/src/external/token-store/cursors/limit-cursor.ts +++ b/src/external/token-store/cursors/limit-cursor.ts @@ -2,7 +2,7 @@ * @fileoverview Define the cursor which limits the number of tokens. * @author Toru Nagashima */ -import Cursor from "./cursor" +import type Cursor from "./cursor" import DecorativeCursor from "./decorative-cursor" /** @@ -16,13 +16,13 @@ export default class LimitCursor extends DecorativeCursor { * @param cursor - The cursor to be decorated. * @param count - The count of tokens this cursor iterates. */ - constructor(cursor: Cursor, count: number) { + public constructor(cursor: Cursor, count: number) { super(cursor) this.count = count } /** @inheritdoc */ - moveNext(): boolean { + public moveNext(): boolean { if (this.count > 0) { this.count -= 1 return super.moveNext() diff --git a/src/external/token-store/cursors/padded-token-cursor.ts b/src/external/token-store/cursors/padded-token-cursor.ts index fae24e1f..ab58c95b 100644 --- a/src/external/token-store/cursors/padded-token-cursor.ts +++ b/src/external/token-store/cursors/padded-token-cursor.ts @@ -2,7 +2,7 @@ * @fileoverview Define the cursor which iterates tokens only, with inflated range. * @author Toru Nagashima */ -import {Token} from "../../../ast" +import type { Token } from "../../../ast/index" import ForwardTokenCursor from "./forward-token-cursor" /** @@ -20,7 +20,15 @@ export default class PaddedTokenCursor extends ForwardTokenCursor { * @param beforeCount - The number of tokens this cursor iterates before start. * @param afterCount - The number of tokens this cursor iterates after end. */ - constructor(tokens: Token[], comments: Token[], indexMap: { [key: number]: number }, startLoc: number, endLoc: number, beforeCount: number, afterCount: number) { + public constructor( + tokens: Token[], + comments: Token[], + indexMap: { [key: number]: number }, + startLoc: number, + endLoc: number, + beforeCount: number, + afterCount: number, + ) { super(tokens, comments, indexMap, startLoc, endLoc) this.index = Math.max(0, this.index - beforeCount) this.indexEnd = Math.min(tokens.length - 1, this.indexEnd + afterCount) diff --git a/src/external/token-store/cursors/skip-cursor.ts b/src/external/token-store/cursors/skip-cursor.ts index b3df68a7..62016be1 100644 --- a/src/external/token-store/cursors/skip-cursor.ts +++ b/src/external/token-store/cursors/skip-cursor.ts @@ -2,7 +2,7 @@ * @fileoverview Define the cursor which ignores the first few tokens. * @author Toru Nagashima */ -import Cursor from "./cursor" +import type Cursor from "./cursor" import DecorativeCursor from "./decorative-cursor" /** @@ -16,13 +16,13 @@ export default class SkipCursor extends DecorativeCursor { * @param cursor - The cursor to be decorated. * @param count - The count of tokens this cursor skips. */ - constructor(cursor: Cursor, count: number) { + public constructor(cursor: Cursor, count: number) { super(cursor) this.count = count } /** @inheritdoc */ - moveNext(): boolean { + public moveNext(): boolean { while (this.count > 0) { this.count -= 1 if (!super.moveNext()) { diff --git a/src/external/token-store/index.ts b/src/external/token-store/index.ts index 8e3ae9ff..a0bdabbe 100644 --- a/src/external/token-store/index.ts +++ b/src/external/token-store/index.ts @@ -3,23 +3,29 @@ * @author Brandon Mills */ import assert from "assert" -import {HasLocation, Token} from "../../ast" -import * as cursors from "./cursors" -import Cursor from "./cursors/cursor" +import type { HasLocation, Token } from "../../ast/index" +import * as cursors from "./cursors/index" +import type Cursor from "./cursors/cursor" import ForwardTokenCursor from "./cursors/forward-token-cursor" import PaddedTokenCursor from "./cursors/padded-token-cursor" -import {search} from "./utils" - -export type SkipOptions = number | ((token: Token) => boolean) | { - includeComments?: boolean - filter?: (token: Token) => boolean - skip?: number -} -export type CountOptions = number | ((token: Token) => boolean) | { - includeComments?: boolean - filter?: (token: Token) => boolean - count?: number -} +import { search } from "./utils" + +export type SkipOptions = + | number + | ((token: Token) => boolean) + | { + includeComments?: boolean + filter?: (token: Token) => boolean + skip?: number + } +export type CountOptions = + | number + | ((token: Token) => boolean) + | { + includeComments?: boolean + filter?: (token: Token) => boolean + count?: number + } /** * Check whether the given token is a comment token or not. @@ -27,7 +33,11 @@ export type CountOptions = number | ((token: Token) => boolean) | { * @returns `true` if the token is a comment token. */ function isCommentToken(token: Token): boolean { - return token.type === "Line" || token.type === "Block" || token.type === "Shebang" + return ( + token.type === "Line" || + token.type === "Block" || + token.type === "Shebang" + ) } /** @@ -41,7 +51,10 @@ function isCommentToken(token: Token): boolean { * @returns The map from locations to indices in `tokens`. * @private */ -function createIndexMap(tokens: Token[], comments: Token[]): { [key: number]: number } { +function createIndexMap( + tokens: Token[], + comments: Token[], +): { [key: number]: number } { const map = Object.create(null) let tokenIndex = 0 let commentIndex = 0 @@ -49,15 +62,27 @@ function createIndexMap(tokens: Token[], comments: Token[]): { [key: number]: nu let range: [number, number] | null = null while (tokenIndex < tokens.length || commentIndex < comments.length) { - nextStart = (commentIndex < comments.length) ? comments[commentIndex].range[0] : Number.MAX_SAFE_INTEGER - while (tokenIndex < tokens.length && (range = tokens[tokenIndex].range)[0] < nextStart) { + nextStart = + commentIndex < comments.length + ? comments[commentIndex].range[0] + : Number.MAX_SAFE_INTEGER + while ( + tokenIndex < tokens.length && + (range = tokens[tokenIndex].range)[0] < nextStart + ) { map[range[0]] = tokenIndex map[range[1] - 1] = tokenIndex tokenIndex += 1 } - nextStart = (tokenIndex < tokens.length) ? tokens[tokenIndex].range[0] : Number.MAX_SAFE_INTEGER - while (commentIndex < comments.length && (range = comments[commentIndex].range)[0] < nextStart) { + nextStart = + tokenIndex < tokens.length + ? tokens[tokenIndex].range[0] + : Number.MAX_SAFE_INTEGER + while ( + commentIndex < comments.length && + (range = comments[commentIndex].range)[0] < nextStart + ) { map[range[0]] = tokenIndex map[range[1] - 1] = tokenIndex commentIndex += 1 @@ -80,26 +105,45 @@ function createIndexMap(tokens: Token[], comments: Token[]): { [key: number]: nu * @returns The created cursor. * @private */ -function createCursorWithSkip(factory: cursors.CursorFactory, tokens: Token[], comments: Token[], indexMap: { [key: number]: number }, startLoc: number, endLoc: number, opts?: SkipOptions): Cursor { +function createCursorWithSkip( + factory: cursors.CursorFactory, + tokens: Token[], + comments: Token[], + indexMap: { [key: number]: number }, + startLoc: number, + endLoc: number, + opts?: SkipOptions, +): Cursor { let includeComments = false let skip = 0 let filter: ((token: Token) => boolean) | null = null if (typeof opts === "number") { skip = opts | 0 - } - else if (typeof opts === "function") { + } else if (typeof opts === "function") { filter = opts - } - else if (opts) { + } else if (opts) { includeComments = Boolean(opts.includeComments) skip = opts.skip || 0 filter = opts.filter || null } assert(skip >= 0, "options.skip should be zero or a positive integer.") - assert(!filter || typeof filter === "function", "options.filter should be a function.") - - return factory.createCursor(tokens, comments, indexMap, startLoc, endLoc, includeComments, filter, skip, -1) + assert( + !filter || typeof filter === "function", + "options.filter should be a function.", + ) + + return factory.createCursor( + tokens, + comments, + indexMap, + startLoc, + endLoc, + includeComments, + filter, + skip, + -1, + ) } /** @@ -115,7 +159,15 @@ function createCursorWithSkip(factory: cursors.CursorFactory, tokens: Token[], c * @returns The created cursor. * @private */ -function createCursorWithCount(factory: cursors.CursorFactory, tokens: Token[], comments: Token[], indexMap: { [key: number]: number }, startLoc: number, endLoc: number, opts?: CountOptions): Cursor { +function createCursorWithCount( + factory: cursors.CursorFactory, + tokens: Token[], + comments: Token[], + indexMap: { [key: number]: number }, + startLoc: number, + endLoc: number, + opts?: CountOptions, +): Cursor { let includeComments = false let count = 0 let countExists = false @@ -124,20 +176,31 @@ function createCursorWithCount(factory: cursors.CursorFactory, tokens: Token[], if (typeof opts === "number") { count = opts | 0 countExists = true - } - else if (typeof opts === "function") { + } else if (typeof opts === "function") { filter = opts - } - else if (opts) { + } else if (opts) { includeComments = Boolean(opts.includeComments) count = opts.count || 0 countExists = typeof opts.count === "number" filter = opts.filter || null } assert(count >= 0, "options.count should be zero or a positive integer.") - assert(!filter || typeof filter === "function", "options.filter should be a function.") - - return factory.createCursor(tokens, comments, indexMap, startLoc, endLoc, includeComments, filter, 0, countExists ? count : -1) + assert( + !filter || typeof filter === "function", + "options.filter should be a function.", + ) + + return factory.createCursor( + tokens, + comments, + indexMap, + startLoc, + endLoc, + includeComments, + filter, + 0, + countExists ? count : -1, + ) } /** @@ -153,14 +216,47 @@ function createCursorWithCount(factory: cursors.CursorFactory, tokens: Token[], * @returns The created cursor. * @private */ -function createCursorWithPadding(tokens: Token[], comments: Token[], indexMap: { [key: number]: number }, startLoc: number, endLoc: number, beforeCount?: CountOptions, afterCount?: number): Cursor { - if (typeof beforeCount === "undefined" && typeof afterCount === "undefined") { - return new ForwardTokenCursor(tokens, comments, indexMap, startLoc, endLoc) +function createCursorWithPadding( + tokens: Token[], + comments: Token[], + indexMap: { [key: number]: number }, + startLoc: number, + endLoc: number, + beforeCount?: CountOptions, + afterCount?: number, +): Cursor { + if ( + typeof beforeCount === "undefined" && + typeof afterCount === "undefined" + ) { + return new ForwardTokenCursor( + tokens, + comments, + indexMap, + startLoc, + endLoc, + ) } if (typeof beforeCount === "number" || typeof beforeCount === "undefined") { - return new PaddedTokenCursor(tokens, comments, indexMap, startLoc, endLoc, beforeCount || 0, afterCount || 0) + return new PaddedTokenCursor( + tokens, + comments, + indexMap, + startLoc, + endLoc, + beforeCount || 0, + afterCount || 0, + ) } - return createCursorWithCount(cursors.forward, tokens, comments, indexMap, startLoc, endLoc, beforeCount) + return createCursorWithCount( + cursors.forward, + tokens, + comments, + indexMap, + startLoc, + endLoc, + beforeCount, + ) } /** @@ -206,7 +302,7 @@ export default class TokenStore { * @param tokens - The array of tokens. * @param comments - The array of comments. */ - constructor(tokens: Token[], comments: Token[]) { + public constructor(tokens: Token[], comments: Token[]) { this._tokens = tokens this._comments = comments this._indexMap = createIndexMap(tokens, comments) @@ -222,18 +318,23 @@ export default class TokenStore { * @param options - The option object. * @returns The token starting at index, or null if no such token. */ - getTokenByRangeStart(offset: number, options?: { includeComments: boolean }): Token | null { + public getTokenByRangeStart( + offset: number, + options?: { includeComments: boolean }, + ): Token | null { const includeComments = Boolean(options && options.includeComments) - const token = cursors.forward.createBaseCursor( - this._tokens, - this._comments, - this._indexMap, - offset, - -1, - includeComments - ).getOneToken() - - if (token && token.range[0] === offset) { + const token = cursors.forward + .createBaseCursor( + this._tokens, + this._comments, + this._indexMap, + offset, + -1, + includeComments, + ) + .getOneToken() + + if (token?.range[0] === offset) { return token } return null @@ -245,7 +346,10 @@ export default class TokenStore { * @param options - The option object. * @returns An object representing the token. */ - getFirstToken(node: HasLocation, options?: SkipOptions): Token | null { + public getFirstToken( + node: HasLocation, + options?: SkipOptions, + ): Token | null { return createCursorWithSkip( cursors.forward, this._tokens, @@ -253,7 +357,7 @@ export default class TokenStore { this._indexMap, node.range[0], node.range[1], - options + options, ).getOneToken() } @@ -263,7 +367,10 @@ export default class TokenStore { * @param options - The option object. * @returns An object representing the token. */ - getLastToken(node: HasLocation, options?: SkipOptions): Token | null { + public getLastToken( + node: HasLocation, + options?: SkipOptions, + ): Token | null { return createCursorWithSkip( cursors.backward, this._tokens, @@ -271,7 +378,7 @@ export default class TokenStore { this._indexMap, node.range[0], node.range[1], - options + options, ).getOneToken() } @@ -281,7 +388,10 @@ export default class TokenStore { * @param options - The option object. * @returns An object representing the token. */ - getTokenBefore(node: HasLocation, options?: SkipOptions): Token | null { + public getTokenBefore( + node: HasLocation, + options?: SkipOptions, + ): Token | null { return createCursorWithSkip( cursors.backward, this._tokens, @@ -289,7 +399,7 @@ export default class TokenStore { this._indexMap, -1, node.range[0], - options + options, ).getOneToken() } @@ -299,7 +409,10 @@ export default class TokenStore { * @param options - The option object. * @returns An object representing the token. */ - getTokenAfter(node: HasLocation, options?: SkipOptions): Token | null { + public getTokenAfter( + node: HasLocation, + options?: SkipOptions, + ): Token | null { return createCursorWithSkip( cursors.forward, this._tokens, @@ -307,7 +420,7 @@ export default class TokenStore { this._indexMap, node.range[1], -1, - options + options, ).getOneToken() } @@ -318,7 +431,11 @@ export default class TokenStore { * @param options - The option object. * @returns An object representing the token. */ - getFirstTokenBetween(left: HasLocation, right: HasLocation, options?: SkipOptions): Token | null { + public getFirstTokenBetween( + left: HasLocation, + right: HasLocation, + options?: SkipOptions, + ): Token | null { return createCursorWithSkip( cursors.forward, this._tokens, @@ -326,7 +443,7 @@ export default class TokenStore { this._indexMap, left.range[1], right.range[0], - options + options, ).getOneToken() } @@ -337,7 +454,11 @@ export default class TokenStore { * @param options - The option object. * @returns An object representing the token. */ - getLastTokenBetween(left: HasLocation, right: HasLocation, options?: SkipOptions): Token | null { + public getLastTokenBetween( + left: HasLocation, + right: HasLocation, + options?: SkipOptions, + ): Token | null { return createCursorWithSkip( cursors.backward, this._tokens, @@ -345,7 +466,7 @@ export default class TokenStore { this._indexMap, left.range[1], right.range[0], - options + options, ).getOneToken() } @@ -358,8 +479,11 @@ export default class TokenStore { * @returns An object representing the token. * @deprecated */ - getTokenOrCommentBefore(node: HasLocation, skip?: number): Token | null { - return this.getTokenBefore(node, {includeComments: true, skip}) + public getTokenOrCommentBefore( + node: HasLocation, + skip?: number, + ): Token | null { + return this.getTokenBefore(node, { includeComments: true, skip }) } /** @@ -371,8 +495,11 @@ export default class TokenStore { * @returns An object representing the token. * @deprecated */ - getTokenOrCommentAfter(node: HasLocation, skip?: number): Token | null { - return this.getTokenAfter(node, {includeComments: true, skip}) + public getTokenOrCommentAfter( + node: HasLocation, + skip?: number, + ): Token | null { + return this.getTokenAfter(node, { includeComments: true, skip }) } //-------------------------------------------------------------------------- @@ -388,7 +515,7 @@ export default class TokenStore { * @param [options.count=0] - The maximum count of tokens the cursor iterates. * @returns Tokens. */ - getFirstTokens(node: HasLocation, options?: CountOptions): Token[] { + public getFirstTokens(node: HasLocation, options?: CountOptions): Token[] { return createCursorWithCount( cursors.forward, this._tokens, @@ -396,7 +523,7 @@ export default class TokenStore { this._indexMap, node.range[0], node.range[1], - options + options, ).getAllTokens() } @@ -406,7 +533,7 @@ export default class TokenStore { * @param [options=0] - The option object. Same options as getFirstTokens() * @returns Tokens. */ - getLastTokens(node: HasLocation, options?: CountOptions) { + public getLastTokens(node: HasLocation, options?: CountOptions) { return createCursorWithCount( cursors.backward, this._tokens, @@ -414,8 +541,10 @@ export default class TokenStore { this._indexMap, node.range[0], node.range[1], - options - ).getAllTokens().reverse() + options, + ) + .getAllTokens() + .reverse() } /** @@ -424,7 +553,7 @@ export default class TokenStore { * @param [options=0] - The option object. Same options as getFirstTokens() * @returns Tokens. */ - getTokensBefore(node: HasLocation, options?: CountOptions): Token[] { + public getTokensBefore(node: HasLocation, options?: CountOptions): Token[] { return createCursorWithCount( cursors.backward, this._tokens, @@ -432,8 +561,10 @@ export default class TokenStore { this._indexMap, -1, node.range[0], - options - ).getAllTokens().reverse() + options, + ) + .getAllTokens() + .reverse() } /** @@ -442,7 +573,7 @@ export default class TokenStore { * @param [options=0] - The option object. Same options as getFirstTokens() * @returns Tokens. */ - getTokensAfter(node: HasLocation, options?: CountOptions): Token[] { + public getTokensAfter(node: HasLocation, options?: CountOptions): Token[] { return createCursorWithCount( cursors.forward, this._tokens, @@ -450,7 +581,7 @@ export default class TokenStore { this._indexMap, node.range[1], -1, - options + options, ).getAllTokens() } @@ -461,7 +592,11 @@ export default class TokenStore { * @param [options=0] - The option object. Same options as getFirstTokens() * @returns Tokens between left and right. */ - getFirstTokensBetween(left: HasLocation, right: HasLocation, options?: CountOptions): Token[] { + public getFirstTokensBetween( + left: HasLocation, + right: HasLocation, + options?: CountOptions, + ): Token[] { return createCursorWithCount( cursors.forward, this._tokens, @@ -469,7 +604,7 @@ export default class TokenStore { this._indexMap, left.range[1], right.range[0], - options + options, ).getAllTokens() } @@ -480,7 +615,11 @@ export default class TokenStore { * @param [options=0] - The option object. Same options as getFirstTokens() * @returns Tokens between left and right. */ - getLastTokensBetween(left: HasLocation, right: HasLocation, options?: CountOptions): Token[] { + public getLastTokensBetween( + left: HasLocation, + right: HasLocation, + options?: CountOptions, + ): Token[] { return createCursorWithCount( cursors.backward, this._tokens, @@ -488,8 +627,10 @@ export default class TokenStore { this._indexMap, left.range[1], right.range[0], - options - ).getAllTokens().reverse() + options, + ) + .getAllTokens() + .reverse() } /** @@ -499,7 +640,11 @@ export default class TokenStore { * @param afterCount - The number of tokens after the node to retrieve. * @returns Array of objects representing tokens. */ - getTokens(node: HasLocation, beforeCount?: CountOptions, afterCount?: number): Token[] { + public getTokens( + node: HasLocation, + beforeCount?: CountOptions, + afterCount?: number, + ): Token[] { return createCursorWithPadding( this._tokens, this._comments, @@ -507,7 +652,7 @@ export default class TokenStore { node.range[0], node.range[1], beforeCount, - afterCount + afterCount, ).getAllTokens() } @@ -518,7 +663,11 @@ export default class TokenStore { * @param padding Number of extra tokens on either side of center. * @returns Tokens between left and right. */ - getTokensBetween(left: HasLocation, right: HasLocation, padding?: CountOptions): Token[] { + public getTokensBetween( + left: HasLocation, + right: HasLocation, + padding?: CountOptions, + ): Token[] { return createCursorWithPadding( this._tokens, this._comments, @@ -526,7 +675,7 @@ export default class TokenStore { left.range[1], right.range[0], padding, - typeof padding === "number" ? padding : undefined + typeof padding === "number" ? padding : undefined, ).getAllTokens() } @@ -541,7 +690,10 @@ export default class TokenStore { * @param right - The node to check. * @returns `true` if one or more comments exist. */ - commentsExistBetween(left: HasLocation, right: HasLocation): boolean { + public commentsExistBetween( + left: HasLocation, + right: HasLocation, + ): boolean { const index = search(this._comments, left.range[1]) return ( @@ -555,7 +707,7 @@ export default class TokenStore { * @param nodeOrToken The AST node or token to check for adjacent comment tokens. * @returns An array of comments in occurrence order. */ - getCommentsBefore(nodeOrToken: HasLocation): Token[] { + public getCommentsBefore(nodeOrToken: HasLocation): Token[] { const cursor = createCursorWithCount( cursors.backward, this._tokens, @@ -563,7 +715,7 @@ export default class TokenStore { this._indexMap, -1, nodeOrToken.range[0], - {includeComments: true} + { includeComments: true }, ) return getAdjacentCommentTokensFromCursor(cursor).reverse() @@ -574,7 +726,7 @@ export default class TokenStore { * @param nodeOrToken The AST node or token to check for adjacent comment tokens. * @returns An array of comments in occurrence order. */ - getCommentsAfter(nodeOrToken: HasLocation): Token[] { + public getCommentsAfter(nodeOrToken: HasLocation): Token[] { const cursor = createCursorWithCount( cursors.forward, this._tokens, @@ -582,7 +734,7 @@ export default class TokenStore { this._indexMap, nodeOrToken.range[1], -1, - {includeComments: true} + { includeComments: true }, ) return getAdjacentCommentTokensFromCursor(cursor) @@ -593,7 +745,7 @@ export default class TokenStore { * @param node The AST node to get the comments for. * @returns An array of comments in occurrence order. */ - getCommentsInside(node: HasLocation): Token[] { + public getCommentsInside(node: HasLocation): Token[] { return this.getTokens(node, { includeComments: true, filter: isCommentToken, diff --git a/src/external/token-store/utils.ts b/src/external/token-store/utils.ts index d8e35831..64cc8690 100644 --- a/src/external/token-store/utils.ts +++ b/src/external/token-store/utils.ts @@ -3,7 +3,7 @@ * @author Toru Nagashima */ import sortedIndexBy from "lodash/sortedIndexBy" -import {HasLocation} from "../../ast" +import type { HasLocation } from "../../ast/index" /** * Gets `token.range[0]` from the given token. @@ -41,13 +41,17 @@ export function search(tokens: HasLocation[], location: number): number { * @param startLoc - The location to get an index. * @returns The index. */ -export function getFirstIndex(tokens: HasLocation[], indexMap: { [key: number]: number }, startLoc: number): number { +export function getFirstIndex( + tokens: HasLocation[], + indexMap: { [key: number]: number }, + startLoc: number, +): number { if (startLoc in indexMap) { return indexMap[startLoc] } - if ((startLoc - 1) in indexMap) { + if (startLoc - 1 in indexMap) { const index = indexMap[startLoc - 1] - const token = (index >= 0 && index < tokens.length) ? tokens[index] : null + const token = index >= 0 && index < tokens.length ? tokens[index] : null // For the map of "comment's location -> token's index", it points the next token of a comment. // In that case, +1 is unnecessary. @@ -68,13 +72,17 @@ export function getFirstIndex(tokens: HasLocation[], indexMap: { [key: number]: * @param endLoc - The location to get an index. * @returns The index. */ -export function getLastIndex(tokens: HasLocation[], indexMap: { [key: number]: number }, endLoc: number): number { +export function getLastIndex( + tokens: HasLocation[], + indexMap: { [key: number]: number }, + endLoc: number, +): number { if (endLoc in indexMap) { return indexMap[endLoc] - 1 } - if ((endLoc - 1) in indexMap) { + if (endLoc - 1 in indexMap) { const index = indexMap[endLoc - 1] - const token = (index >= 0 && index < tokens.length) ? tokens[index] : null + const token = index >= 0 && index < tokens.length ? tokens[index] : null // For the map of "comment's location -> token's index", it points the next token of a comment. // In that case, -1 is necessary. diff --git a/src/html/custom-tokenizer.ts b/src/html/custom-tokenizer.ts index 6b11b1eb..e863506a 100644 --- a/src/html/custom-tokenizer.ts +++ b/src/html/custom-tokenizer.ts @@ -1,4 +1,4 @@ -import type { Namespace, ParseError, Token } from "../ast" +import type { Namespace, ParseError, Token } from "../ast/index" import type { IntermediateToken } from "./intermediate-tokenizer" import type { TokenizerState } from "./tokenizer" diff --git a/src/html/intermediate-tokenizer.ts b/src/html/intermediate-tokenizer.ts index 9ba22236..62d4ca90 100644 --- a/src/html/intermediate-tokenizer.ts +++ b/src/html/intermediate-tokenizer.ts @@ -11,8 +11,8 @@ import type { Namespace, Token, VAttribute, -} from "../ast" -import { ParseError } from "../ast" +} from "../ast/index" +import { ParseError } from "../ast/index" import { debug } from "../common/debug" import type { Tokenizer, TokenizerState, TokenType } from "./tokenizer" @@ -222,7 +222,7 @@ export class IntermediateTokenizer { private processComment(token: Token): IntermediateToken | null { this.comments.push(token) - if (this.currentToken != null && this.currentToken.type === "Text") { + if (this.currentToken?.type === "Text") { return this.commit() } return null diff --git a/src/html/parser.ts b/src/html/parser.ts index 9a6c1bef..ed155e9a 100644 --- a/src/html/parser.ts +++ b/src/html/parser.ts @@ -16,15 +16,15 @@ import type { VElement, VExpressionContainer, VLiteral, -} from "../ast" -import { NS, ParseError } from "../ast" +} from "../ast/index" +import { NS, ParseError } from "../ast/index" import { debug } from "../common/debug" import { LocationCalculatorForHtml } from "../common/location-calculator" import { convertToDirective, processMustache, resolveReferences, -} from "../template" +} from "../template/index" import { MATHML_ATTRIBUTE_NAME_MAP, SVG_ATTRIBUTE_NAME_MAP, @@ -302,6 +302,8 @@ export class Parser { yield getParserLangFromSFC(doc) }, ), + project: undefined, + projectService: undefined, } const scriptParserOptions = { ...this.baseParserOptions, @@ -419,7 +421,7 @@ export class Parser { if (name === "template") { const xmlns = token.attributes.find((a) => a.key.name === "xmlns") - const value = xmlns && xmlns.value && xmlns.value.value + const value = xmlns?.value?.value if (value === NS.HTML || value === NS.MathML || value === NS.SVG) { return value @@ -475,7 +477,7 @@ export class Parser { node.key.name = adjustAttributeName(node.key.name, namespace) const key = this.getTagName(node.key) - const value = node.value && node.value.value + const value = node.value?.value if (key === "xmlns" && value !== namespace) { this.reportParseError(node, "x-invalid-namespace") @@ -614,8 +616,7 @@ export class Parser { for (const attribute of element.startTag.attributes) { if (attribute.directive) { if ( - attribute.key.argument != null && - attribute.key.argument.type === "VExpressionContainer" + attribute.key.argument?.type === "VExpressionContainer" ) { resolveReferences(attribute.key.argument) } diff --git a/src/html/tokenizer.ts b/src/html/tokenizer.ts index af777f78..6285cdfa 100644 --- a/src/html/tokenizer.ts +++ b/src/html/tokenizer.ts @@ -4,12 +4,12 @@ * See LICENSE file in root directory for full license. */ -/*eslint-disable no-constant-condition, no-param-reassign */ +/*eslint-disable no-param-reassign */ import assert from "assert" import { debug } from "../common/debug" -import type { ErrorCode, Namespace, Token } from "../ast" -import { NS, ParseError } from "../ast" +import type { ErrorCode, Namespace, Token } from "../ast/index" +import { NS, ParseError } from "../ast/index" import { alternativeCR } from "./util/alternative-cr" import { entitySets } from "./util/entities" import { @@ -980,8 +980,7 @@ export class Tokenizer { function maybeValidCustomBlock(this: Tokenizer, nextCp: number) { return ( this.currentToken && - this.lastTagOpenToken && - this.lastTagOpenToken.value.startsWith( + this.lastTagOpenToken?.value.startsWith( this.currentToken.value + String.fromCodePoint(nextCp), ) ) @@ -1893,10 +1892,10 @@ export class Tokenizer { const type = isWhitespace(cp) ? "HTMLWhitespace" : state === "RCDATA" - ? "HTMLRawText" - : state === "RAWTEXT" - ? "HTMLRCDataText" - : "HTMLText" + ? "HTMLRawText" + : state === "RAWTEXT" + ? "HTMLRCDataText" + : "HTMLText" if (this.currentToken != null && this.currentToken.type !== type) { this.endToken() return this.reconsumeAs(this.state) @@ -1953,4 +1952,4 @@ export class Tokenizer { } } -/*eslint-enable no-constant-condition, no-param-reassign */ +/*eslint-enable no-param-reassign */ diff --git a/src/html/util/unicode.ts b/src/html/util/unicode.ts index 3087de54..7ec22f8e 100644 --- a/src/html/util/unicode.ts +++ b/src/html/util/unicode.ts @@ -7,9 +7,9 @@ export const EOF = -1 export const NULL = 0x00 export const TABULATION = 0x09 -export const CARRIAGE_RETURN = 0x0D -export const LINE_FEED = 0x0A -export const FORM_FEED = 0x0C +export const CARRIAGE_RETURN = 0x0d +export const LINE_FEED = 0x0a +export const FORM_FEED = 0x0c export const SPACE = 0x20 export const EXCLAMATION_MARK = 0x21 // ! export const QUOTATION_MARK = 0x22 // " @@ -18,33 +18,33 @@ export const AMPERSAND = 0x26 // & export const APOSTROPHE = 0x27 // ' export const LEFT_PARENTHESIS = 0x28 // ( export const RIGHT_PARENTHESIS = 0x29 // ) -export const ASTERISK = 0x2A // * -export const HYPHEN_MINUS = 0x2D // - -export const SOLIDUS = 0x2F // / +export const ASTERISK = 0x2a // * +export const HYPHEN_MINUS = 0x2d // - +export const SOLIDUS = 0x2f // / export const DIGIT_0 = 0x30 export const DIGIT_9 = 0x39 export const COLON = 0x3a // : -export const SEMICOLON = 0x3B // ; -export const LESS_THAN_SIGN = 0x3C // < -export const EQUALS_SIGN = 0x3D // = -export const GREATER_THAN_SIGN = 0x3E // > -export const QUESTION_MARK = 0x3F // ? +export const SEMICOLON = 0x3b // ; +export const LESS_THAN_SIGN = 0x3c // < +export const EQUALS_SIGN = 0x3d // = +export const GREATER_THAN_SIGN = 0x3e // > +export const QUESTION_MARK = 0x3f // ? export const LATIN_CAPITAL_A = 0x41 export const LATIN_CAPITAL_D = 0x44 export const LATIN_CAPITAL_F = 0x46 export const LATIN_CAPITAL_X = 0x58 -export const LATIN_CAPITAL_Z = 0x5A -export const LEFT_SQUARE_BRACKET = 0x5B // [ -export const REVERSE_SOLIDUS = 0x5C // \ -export const RIGHT_SQUARE_BRACKET = 0x5D // ] +export const LATIN_CAPITAL_Z = 0x5a +export const LEFT_SQUARE_BRACKET = 0x5b // [ +export const REVERSE_SOLIDUS = 0x5c // \ +export const RIGHT_SQUARE_BRACKET = 0x5d // ] export const GRAVE_ACCENT = 0x60 // ` export const LATIN_SMALL_A = 0x61 export const LATIN_SMALL_F = 0x66 export const LATIN_SMALL_X = 0x78 -export const LATIN_SMALL_Z = 0x7A -export const LEFT_CURLY_BRACKET = 0x7B // { -export const RIGHT_CURLY_BRACKET = 0x7D // } -export const NULL_REPLACEMENT = 0xFFFD +export const LATIN_SMALL_Z = 0x7a +export const LEFT_CURLY_BRACKET = 0x7b // { +export const RIGHT_CURLY_BRACKET = 0x7d // } +export const NULL_REPLACEMENT = 0xfffd /** * Check whether the code point is a whitespace. @@ -52,7 +52,13 @@ export const NULL_REPLACEMENT = 0xFFFD * @returns `true` if the code point is a whitespace. */ export function isWhitespace(cp: number): boolean { - return cp === TABULATION || cp === LINE_FEED || cp === FORM_FEED || cp === CARRIAGE_RETURN || cp === SPACE + return ( + cp === TABULATION || + cp === LINE_FEED || + cp === FORM_FEED || + cp === CARRIAGE_RETURN || + cp === SPACE + ) } /** @@ -124,7 +130,7 @@ export function isHexDigit(cp: number): boolean { * @returns `true` if the code point is a control character. */ export function isControl(cp: number): boolean { - return (cp >= 0 && cp <= 0x1F) || (cp >= 0x7F && cp <= 0x9F) + return (cp >= 0 && cp <= 0x1f) || (cp >= 0x7f && cp <= 0x9f) } /** @@ -133,7 +139,7 @@ export function isControl(cp: number): boolean { * @returns `true` if the code point is a surrogate character. */ export function isSurrogate(cp: number): boolean { - return cp >= 0xD800 && cp <= 0xDFFF + return cp >= 0xd800 && cp <= 0xdfff } /** @@ -142,7 +148,7 @@ export function isSurrogate(cp: number): boolean { * @returns `true` if the code point is a surrogate pair character. */ export function isSurrogatePair(cp: number): boolean { - return cp >= 0xDC00 && cp <= 0xDFFF + return cp >= 0xdc00 && cp <= 0xdfff } /** @@ -152,8 +158,8 @@ export function isSurrogatePair(cp: number): boolean { */ export function isNonCharacter(cp: number): boolean { return ( - (cp >= 0xFDD0 && cp <= 0xFDEF) || - ((cp & 0xFFFE) === 0xFFFE && cp <= 0x10FFFF) + (cp >= 0xfdd0 && cp <= 0xfdef) || + ((cp & 0xfffe) === 0xfffe && cp <= 0x10ffff) ) } diff --git a/src/index.ts b/src/index.ts index 20a067fd..13cb5300 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,16 +4,16 @@ * See LICENSE file in root directory for full license. */ import * as path from "path" -import * as AST from "./ast" +import * as AST from "./ast/index" import { LocationCalculatorForHtml } from "./common/location-calculator" -import { HTMLParser, HTMLTokenizer } from "./html" -import { parseScript, parseScriptElement } from "./script" +import { HTMLParser, HTMLTokenizer } from "./html/index" +import { parseScript, parseScriptElement } from "./script/index" import * as services from "./parser-services" import type { ParserOptions } from "./common/parser-options" import { getScriptParser, getParserLangFromSFC } from "./common/parser-options" -import { parseScriptSetupElements } from "./script-setup" +import { parseScriptSetupElements } from "./script-setup/index" import { LinesAndColumns } from "./common/lines-and-columns" -import type { VElement } from "./ast" +import type { VElement } from "./ast/index" import { DEFAULT_ECMA_VERSION } from "./script-setup/parser-options" import { getLang, @@ -22,7 +22,7 @@ import { isStyleElement, isTemplateElement, } from "./common/ast-utils" -import { parseStyleElements } from "./style" +import { parseStyleElements } from "./style/index" import { analyzeScope } from "./script/scope-analyzer" import { analyzeScriptSetupScope } from "./script-setup/scope-analyzer" @@ -49,15 +49,13 @@ export function parseForESLint( code: string, parserOptions: any, ): AST.ESLintExtendedProgram { - const options: ParserOptions = Object.assign( - { - comment: true, - loc: true, - range: true, - tokens: true, - }, - parserOptions || {}, - ) + const options: ParserOptions = { + comment: true, + loc: true, + range: true, + tokens: true, + ...parserOptions, + } let result: AST.ESLintExtendedProgram let document: AST.VDocumentFragment | null @@ -70,12 +68,12 @@ export function parseForESLint( ;({ result, document, locationCalculator } = parseAsSFC(code, options)) } - result.services = Object.assign( - result.services || {}, - services.define(code, result.ast, document, locationCalculator, { + result.services = { + ...result.services, + ...services.define(code, result.ast, document, locationCalculator, { parserOptions: options, }), - ) + } return result } @@ -92,10 +90,11 @@ export function parse(code: string, options: any): AST.ESLintProgram { export { AST } +// eslint-disable-next-line complexity -- ignore function parseAsSFC(code: string, options: ParserOptions) { const optionsForTemplate = { ...options, - ecmaVersion: options.ecmaVersion || DEFAULT_ECMA_VERSION, + ecmaVersion: options.ecmaVersion ?? DEFAULT_ECMA_VERSION, } const skipParsingScript = options.parser === false const tokenizer = new HTMLTokenizer(code, optionsForTemplate) @@ -127,7 +126,7 @@ function parseAsSFC(code: string, options: ParserOptions) { if (skipParsingScript || !scripts.length) { result = parseScript("", { ...options, - ecmaVersion: options.ecmaVersion || DEFAULT_ECMA_VERSION, + ecmaVersion: options.ecmaVersion ?? DEFAULT_ECMA_VERSION, parser: scriptParser, }) } else if ( @@ -164,6 +163,8 @@ function parseAsSFC(code: string, options: ParserOptions) { yield "<template>" yield getParserLangFromSFC(rootAST) }), + project: undefined, + projectService: undefined, }) } result.ast.templateBody = templateBody @@ -192,7 +193,7 @@ function parseAsSFC(code: string, options: ParserOptions) { function parseAsScript(code: string, options: ParserOptions) { return parseScript(code, { ...options, - ecmaVersion: options.ecmaVersion || DEFAULT_ECMA_VERSION, + ecmaVersion: options.ecmaVersion ?? DEFAULT_ECMA_VERSION, parser: getScriptParser(options.parser, () => { const ext = ( path.extname(options.filePath || "unknown.js").toLowerCase() || diff --git a/src/parser-services.ts b/src/parser-services.ts index 0fef3c45..3b830c41 100644 --- a/src/parser-services.ts +++ b/src/parser-services.ts @@ -6,24 +6,24 @@ import type { Rule } from "eslint" import EventEmitter from "events" import NodeEventGenerator from "./external/node-event-generator" -import TokenStore from "./external/token-store" +import TokenStore from "./external/token-store/index" import type { ESLintProgram, VElement, VDocumentFragment, VAttribute, -} from "./ast" +} from "./ast/index" import { getFallbackKeys, KEYS, traverseNodes } from "./ast/traverse" import type { LocationCalculatorForHtml } from "./common/location-calculator" import type { CustomBlockContext, ESLintCustomBlockParser, -} from "./sfc/custom-block" +} from "./sfc/custom-block/index" import { createCustomBlockSharedContext, getCustomBlocks, parseCustomBlockElement, -} from "./sfc/custom-block" +} from "./sfc/custom-block/index" import type { ParserOptions } from "./common/parser-options" import { isSFCFile } from "./common/parser-options" import { getLang } from "./common/ast-utils" @@ -175,7 +175,6 @@ export function define( generator, ) } finally { - // @ts-expect-error -- ignore scriptVisitor[templateBodyTriggerSelector] = programExitHandler templateBodyEmitters.delete(templateBodyTriggerSelector) @@ -342,7 +341,7 @@ export function define( ) // Register handlers into the intermediate event emitter. for (const selector of Object.keys( - visitor || {}, + visitor ?? {}, )) { emitter.on(selector, visitor![selector]) } @@ -377,9 +376,9 @@ export function define( typeof target === "function" ? target : Array.isArray(target) - ? (lang: string | null) => - Boolean(lang && target.includes(lang)) - : (lang: string | null) => target === lang + ? (lang: string | null) => + Boolean(lang && target.includes(lang)) + : (lang: string | null) => target === lang factories.push({ context, test, diff --git a/src/script-setup/index.ts b/src/script-setup/index.ts index e820bdcf..671a2bc5 100644 --- a/src/script-setup/index.ts +++ b/src/script-setup/index.ts @@ -15,8 +15,8 @@ import type { ESLintStatement, Token, VElement, -} from "../ast" -import { ParseError, traverseNodes } from "../ast" +} from "../ast/index" +import { ParseError, traverseNodes } from "../ast/index" import { fixErrorLocation, fixLocation, @@ -26,9 +26,12 @@ import { import type { LinesAndColumns } from "../common/lines-and-columns" import type { LocationCalculator } from "../common/location-calculator" import type { ParserOptions } from "../common/parser-options" -import { parseScript as parseScriptBase, parseScriptFragment } from "../script" +import { + parseScript as parseScriptBase, + parseScriptFragment, +} from "../script/index" import { extractGeneric } from "../script/generic" -import { getScriptSetupParserOptions } from "./parser-options" +import { DEFAULT_ECMA_VERSION } from "./parser-options" type RemapBlock = { range: [number, number] @@ -211,9 +214,10 @@ export function parseScriptSetupElements( linesAndColumns: LinesAndColumns, originalParserOptions: ParserOptions, ): ESLintExtendedProgram { - const parserOptions: ParserOptions = getScriptSetupParserOptions( - originalParserOptions, - ) + const parserOptions: ParserOptions = { + ...originalParserOptions, + ecmaVersion: originalParserOptions.ecmaVersion ?? DEFAULT_ECMA_VERSION, + } const scriptSetupModuleCodeBlocks = getScriptSetupModuleCodeBlocks( scriptSetupElement, scriptElement, @@ -319,7 +323,7 @@ export function parseScriptSetupElements( const textNode = node.children[0] return Math.min( start, - textNode != null && textNode.type === "VText" + textNode?.type === "VText" ? textNode.range[0] : node.startTag.range[1], ) @@ -340,9 +344,9 @@ export function parseScriptSetupElements( const textNode = node.children[0] return Math.max( end, - textNode != null && textNode.type === "VText" + textNode?.type === "VText" ? textNode.range[1] - : node.endTag?.range[0] ?? node.range[1], + : (node.endTag?.range[0] ?? node.range[1]), ) }, 0, @@ -513,14 +517,12 @@ function getScriptSetupCodeBlocks( const offsetLocationCalculator = linesAndColumns.createOffsetLocationCalculator(scriptSetupStartOffset) - const result = parseScript( + const { ast, visitorKeys } = parseScript( scriptCode, - parserOptions, + { ...parserOptions, project: undefined, projectService: undefined }, offsetLocationCalculator, ) - const { ast } = result - // Holds the `import` and re-`export` statements. // All import and re-`export` statements are hoisted to the top. const importCodeBlocks = new CodeBlocks() @@ -573,7 +575,7 @@ function getScriptSetupCodeBlocks( (t) => t.range[0] === body.range[0], ) const exportToken = tokens[exportTokenIndex] - if (exportToken && exportToken.value === "export") { + if (exportToken?.value === "export") { // Consume code up to the start position of `export`. // The code may contain legacy decorators. append(statementCodeBlocks, usedOffset, exportToken.range[0]) @@ -594,7 +596,7 @@ function getScriptSetupCodeBlocks( } fixNodeLocations( body, - result.visitorKeys, + visitorKeys, offsetLocationCalculator, ) fixLocation(exportToken, offsetLocationCalculator) @@ -692,7 +694,7 @@ function getScriptSetupCodeBlocks( // restore fixNodeLocations( body, - result.visitorKeys, + visitorKeys, offsetLocationCalculator, ) for (const token of restoreTokens) { @@ -823,7 +825,7 @@ function getScriptSetupCodeBlocks( let start = n.range[0] let end = n.range[1] traverseNodes(n, { - visitorKeys: result.visitorKeys, + visitorKeys, enterNode(c) { start = Math.min(start, c.range[0]) end = Math.max(end, c.range[1]) @@ -956,7 +958,7 @@ function remapLocationAndTokens( { codeBlocks }: ScriptSetupModuleCodeBlocks, locationCalculator: LocationCalculator, ) { - const tokens = result.ast.tokens || [] + const tokens = result.ast.tokens ?? [] const endMap = new Map<number, number>() const buffer: number[] = [] diff --git a/src/script-setup/parser-options.ts b/src/script-setup/parser-options.ts index 4dc263fb..bdcf54a4 100644 --- a/src/script-setup/parser-options.ts +++ b/src/script-setup/parser-options.ts @@ -1,30 +1,3 @@ -import { lte } from "semver" -import { getEcmaVersionIfUseEspree, getEspreeFromUser } from "../common/espree" -import type { ParserOptions } from "../common/parser-options" +export const DEFAULT_ECMA_VERSION = "latest" -export const DEFAULT_ECMA_VERSION = 2017 - -/** - * Get parser options for <script setup> - */ -export function getScriptSetupParserOptions( - parserOptions: ParserOptions, -): ParserOptions { - const espreeEcmaVersion = getEcmaVersionIfUseEspree( - parserOptions, - getDefaultEcmaVersion, - ) - - return { - ...parserOptions, - ecmaVersion: espreeEcmaVersion, - } -} - -function getDefaultEcmaVersion(def: number) { - if (lte("8.0.0", getEspreeFromUser().version)) { - // Script setup requires top level await support, so default the ecma version to 2022. - return getEspreeFromUser().latestEcmaVersion! - } - return Math.max(def, DEFAULT_ECMA_VERSION) -} +export const ANALYZE_SCOPE_DEFAULT_ECMA_VERSION = 2022 diff --git a/src/script-setup/scope-analyzer.ts b/src/script-setup/scope-analyzer.ts index fbb5b7fa..0016b991 100644 --- a/src/script-setup/scope-analyzer.ts +++ b/src/script-setup/scope-analyzer.ts @@ -7,8 +7,8 @@ import type { VDocumentFragment, VElement, VExpressionContainer, -} from "../ast" -import { traverseNodes } from "../ast" +} from "../ast/index" +import { traverseNodes } from "../ast/index" import { getEslintScope } from "../common/eslint-scope" import { findGenericDirective, @@ -131,7 +131,7 @@ function extractVariables(scopeManager: escopeTypes.ScopeManager) { const moduleScope = globalScope.childScopes.find( (scope) => scope.type === "module", ) - for (const variable of (moduleScope && moduleScope.variables) || []) { + for (const variable of moduleScope?.variables ?? []) { scriptVariables.set(variable.name, variable) } return scriptVariables diff --git a/src/script/generic.ts b/src/script/generic.ts index 822c26c0..baf96955 100644 --- a/src/script/generic.ts +++ b/src/script/generic.ts @@ -5,8 +5,7 @@ import type { Token, VElement, VGenericExpression, -} from "../ast" -// eslint-disable-next-line node/no-extraneous-import -- ignore +} from "../ast/index" import type { TSESTree } from "@typescript-eslint/utils" import type { Reference, @@ -95,7 +94,7 @@ export function extractGeneric(element: VElement): GenericProcessInfo | null { typeDefScope: Scope, isRemoveTarget: (nodeOrToken: HasLocation) => boolean, ) { - for (const variable of [...typeDefScope.variables]) { + for (const variable of typeDefScope.variables) { let def = variable.defs.find((d) => isRemoveTarget(d.name as HasLocation), ) @@ -106,13 +105,13 @@ export function extractGeneric(element: VElement): GenericProcessInfo | null { ) } } - for (const reference of [...typeDefScope.references]) { + for (const reference of typeDefScope.references) { if (isRemoveTarget(reference.identifier as HasLocation)) { removeReference(reference, typeDefScope) } } - for (const scope of [...scopeManager.scopes]) { + for (const scope of scopeManager.scopes) { if (isRemoveTarget(scope.block as HasLocation)) { removeScope(scopeManager, scope) } diff --git a/src/script/index.ts b/src/script/index.ts index 262c4bd3..18f67d13 100644 --- a/src/script/index.ts +++ b/src/script/index.ts @@ -32,8 +32,8 @@ import type { VSlotScopeExpression, OffsetRange, VGenericExpression, -} from "../ast" -import { ParseError } from "../ast" +} from "../ast/index" +import { ParseError } from "../ast/index" import { debug } from "../common/debug" import type { LocationCalculator, @@ -43,26 +43,17 @@ import { analyzeExternalReferences, analyzeVariablesAndExternalReferences, } from "./scope-analyzer" -import { - getEcmaVersionIfUseEspree, - getEspreeFromUser, - getEspreeFromEcmaVersion, -} from "../common/espree" +import { getEcmaVersionIfUseEspree, getEspree } from "../common/espree" import type { ParserOptions } from "../common/parser-options" import { fixErrorLocation, fixLocation, fixLocations, } from "../common/fix-locations" -import { - DEFAULT_ECMA_VERSION, - getScriptSetupParserOptions, -} from "../script-setup/parser-options" -import { isScriptSetupElement } from "../common/ast-utils" +import { DEFAULT_ECMA_VERSION } from "../script-setup/parser-options" import type { LinesAndColumns } from "../common/lines-and-columns" import type { ParserObject } from "../common/parser-object" import { isEnhancedParserObject, isParserObject } from "../common/parser-object" -// eslint-disable-next-line node/no-extraneous-import -- ignore import type { TSESTree } from "@typescript-eslint/utils" import type { GenericProcessInfo } from "./generic" import { extractGeneric } from "./generic" @@ -383,8 +374,8 @@ function parseExpressionBody( parserOptions, ) const { ast } = result - const tokens = ast.tokens || [] - const comments = ast.comments || [] + const tokens = ast.tokens ?? [] + const comments = ast.comments ?? [] const references = analyzeExternalReferences(result, parserOptions) const statement = ast.body[0] as ESLintExpressionStatement const callExpression = statement.expression as ESLintCallExpression @@ -393,7 +384,7 @@ function parseExpressionBody( if (!allowEmpty && !expression) { return throwEmptyError(locationCalculator, "an expression") } - if (expression && expression.type === "SpreadElement") { + if (expression?.type === "SpreadElement") { return throwUnexpectedTokenError("...", expression) } if (callExpression.arguments[1]) { @@ -571,7 +562,7 @@ function loadParser(parser: string) { // eslint-disable-next-line @typescript-eslint/no-require-imports return require(parser) } - return getEspreeFromUser() + return getEspree() } /** @@ -589,8 +580,8 @@ export function parseScript( typeof parserOptions.parser === "string" ? loadParser(parserOptions.parser) : isParserObject(parserOptions.parser) - ? parserOptions.parser - : getEspreeFromEcmaVersion(parserOptions.ecmaVersion) + ? parserOptions.parser + : getEspree() const result: any = isEnhancedParserObject(parser) ? parser.parseForESLint(code, parserOptions) @@ -616,19 +607,16 @@ export function parseScriptElement( linesAndColumns: LinesAndColumns, originalParserOptions: ParserOptions, ): ESLintExtendedProgram { - const parserOptions: ParserOptions = isScriptSetupElement(node) - ? getScriptSetupParserOptions(originalParserOptions) - : { - ...originalParserOptions, - ecmaVersion: - originalParserOptions.ecmaVersion || DEFAULT_ECMA_VERSION, - } + const parserOptions: ParserOptions = { + ...originalParserOptions, + ecmaVersion: originalParserOptions.ecmaVersion ?? DEFAULT_ECMA_VERSION, + } let generic: GenericProcessInfo | null = null let code: string let offset: number const textNode = node.children[0] - if (textNode != null && textNode.type === "VText") { + if (textNode?.type === "VText") { const [scriptStartOffset, scriptEndOffset] = textNode.range code = sfcCode.slice(scriptStartOffset, scriptEndOffset) offset = scriptStartOffset @@ -749,8 +737,8 @@ export function parseExpression( parent: null as any, expression: retB.expression, filters: [], - range: retB.expression.range.slice(0) as [number, number], - loc: Object.assign({}, retB.expression.loc), + range: [...retB.expression.range] as const, + loc: { ...retB.expression.loc }, } ret.expression.expression.parent = ret.expression @@ -842,8 +830,8 @@ export function parseVForExpression( parserOptions, ) const { ast } = result - const tokens = ast.tokens || [] - const comments = ast.comments || [] + const tokens = ast.tokens ?? [] + const comments = ast.comments ?? [] const scope = analyzeVariablesAndExternalReferences( result, "v-for", @@ -1024,8 +1012,8 @@ function parseVForAliasesForEcmaVersion5( parserOptions, ) const { ast } = result - const tokens = ast.tokens || [] - const comments = ast.comments || [] + const tokens = ast.tokens ?? [] + const comments = ast.comments ?? [] const variables = analyzeExternalReferences(result, parserOptions).map( transformVariable, ) @@ -1075,8 +1063,8 @@ function parseVForIteratorForEcmaVersion5( parserOptions, ) const { ast } = result - const tokens = ast.tokens || [] - const comments = ast.comments || [] + const tokens = ast.tokens ?? [] + const comments = ast.comments ?? [] const references = analyzeExternalReferences(result, parserOptions) const statement = ast.body[0] as ESLintExpressionStatement @@ -1086,7 +1074,7 @@ function parseVForIteratorForEcmaVersion5( if (!expression) { return throwEmptyError(locationCalculator, "an expression") } - if (expression && expression.type === "SpreadElement") { + if (expression?.type === "SpreadElement") { return throwUnexpectedTokenError("...", expression) } const right = expression @@ -1173,8 +1161,8 @@ function parseVOnExpressionBody( parent: DUMMY_PARENT, body, } - const tokens = ast.tokens || [] - const comments = ast.comments || [] + const tokens = ast.tokens ?? [] + const comments = ast.comments ?? [] // Modify parent. for (const b of body) { @@ -1234,8 +1222,8 @@ export function parseSlotScopeExpression( } } - const tokens = ast.tokens || [] - const comments = ast.comments || [] + const tokens = ast.tokens ?? [] + const comments = ast.comments ?? [] const scope = analyzeVariablesAndExternalReferences( result, "scope", @@ -1306,7 +1294,7 @@ export function parseGenericExpression( const result = parseScriptFragmentWithOption( scriptLet, locationCalculator.getSubCalculatorShift(-14), - { ...parserOptions, project: undefined }, + { ...parserOptions, project: undefined, projectService: undefined }, { preFixLocationProcess(preResult) { const params = getParams(preResult) @@ -1333,8 +1321,8 @@ export function parseGenericExpression( } } - const tokens = ast.tokens || [] - const comments = ast.comments || [] + const tokens = ast.tokens ?? [] + const comments = ast.comments ?? [] const scope = analyzeVariablesAndExternalReferences( result, "generic", diff --git a/src/script/scope-analyzer.ts b/src/script/scope-analyzer.ts index 261e664a..309bc682 100644 --- a/src/script/scope-analyzer.ts +++ b/src/script/scope-analyzer.ts @@ -10,10 +10,11 @@ import type { ESLintProgram, Reference, Variable, -} from "../ast" -import { getFallbackKeys } from "../ast" +} from "../ast/index" +import { getFallbackKeys } from "../ast/index" import { getEslintScope } from "../common/eslint-scope" import { getEcmaVersionIfUseEspree } from "../common/espree" +import { ANALYZE_SCOPE_DEFAULT_ECMA_VERSION } from "../script-setup/parser-options" type ParserResult = { ast: ESLintProgram @@ -56,8 +57,8 @@ function transformReference(reference: escopeTypes.Reference): Reference { mode: reference.isReadOnly() ? "r" : reference.isWriteOnly() - ? "w" - : /* otherwise */ "rw", + ? "w" + : /* otherwise */ "rw", variable: null, isValueReference: reference.isValueReference, isTypeReference: reference.isTypeReference, @@ -100,9 +101,11 @@ export function analyzeScope( ast: ESLintProgram, parserOptions: ParserOptions, ): escopeTypes.ScopeManager { - const ecmaVersion = getEcmaVersionIfUseEspree(parserOptions) || 2022 - const ecmaFeatures = parserOptions.ecmaFeatures || {} - const sourceType = parserOptions.sourceType || "script" + const ecmaVersion = + getEcmaVersionIfUseEspree(parserOptions) ?? + ANALYZE_SCOPE_DEFAULT_ECMA_VERSION + const ecmaFeatures = parserOptions.ecmaFeatures ?? {} + const sourceType = parserOptions.sourceType ?? "script" const result = getEslintScope().analyze(ast, { ignoreEval: true, nodejsScope: false, diff --git a/src/sfc/custom-block/index.ts b/src/sfc/custom-block/index.ts index 2311c5ab..7f672a00 100644 --- a/src/sfc/custom-block/index.ts +++ b/src/sfc/custom-block/index.ts @@ -8,8 +8,8 @@ import type { VElement, VExpressionContainer, VText, -} from "../../ast" -import { getFallbackKeys, ParseError } from "../../ast" +} from "../../ast/index" +import { getFallbackKeys, ParseError } from "../../ast/index" import { getEslintScope } from "../../common/eslint-scope" import { getEcmaVersionIfUseEspree } from "../../common/espree" import { fixErrorLocation, fixLocations } from "../../common/fix-locations" @@ -17,7 +17,10 @@ import type { LocationCalculatorForHtml } from "../../common/location-calculator import type { ParserObject } from "../../common/parser-object" import { isEnhancedParserObject } from "../../common/parser-object" import type { ParserOptions } from "../../common/parser-options" -import { DEFAULT_ECMA_VERSION } from "../../script-setup/parser-options" +import { + ANALYZE_SCOPE_DEFAULT_ECMA_VERSION, + DEFAULT_ECMA_VERSION, +} from "../../script-setup/parser-options" export type ESLintCustomBlockParser = ParserObject<any, any> @@ -84,7 +87,7 @@ export function parseCustomBlockElement( ): ESLintExtendedProgram & { error?: ParseError | Error } { const text = node.children[0] const { code, range, loc } = - text != null && text.type === "VText" + text?.type === "VText" ? { code: text.value, range: text.range, @@ -260,7 +263,7 @@ export function createCustomBlockSharedContext({ { ...parserOptions, ...options }, ) }, - ...(parsedResult.services || {}), + ...parsedResult.services, ...(parsedResult.error ? { parseError: parsedResult.error } : {}), @@ -291,9 +294,11 @@ export function createCustomBlockSharedContext({ return parsedResult.scopeManager } - const ecmaVersion = getEcmaVersionIfUseEspree(parserOptions) || 2022 - const ecmaFeatures = parserOptions.ecmaFeatures || {} - const sourceType = parserOptions.sourceType || "script" + const ecmaVersion = + getEcmaVersionIfUseEspree(parserOptions) ?? + ANALYZE_SCOPE_DEFAULT_ECMA_VERSION + const ecmaFeatures = parserOptions.ecmaFeatures ?? {} + const sourceType = parserOptions.sourceType ?? "script" return getEslintScope().analyze(parsedResult.ast, { ignoreEval: true, nodejsScope: false, @@ -336,7 +341,7 @@ function getScope(scopeManager: ScopeManager, currentNode: Node) { for ( let node: Node | null = currentNode; node; - node = node.parent || null + node = node.parent ?? null ) { const scope = scopeManager.acquire(node as any, inner) diff --git a/src/style/index.ts b/src/style/index.ts index da81c040..bcc01dcd 100644 --- a/src/style/index.ts +++ b/src/style/index.ts @@ -6,8 +6,8 @@ import type { VExpressionContainer, VStyleElement, VText, -} from "../ast" -import { ParseError } from "../ast" +} from "../ast/index" +import { ParseError } from "../ast/index" import { getLang, getOwnerDocument } from "../common/ast-utils" import { debug } from "../common/debug" import { insertError } from "../common/error-utils" @@ -18,9 +18,9 @@ import { insertComments, replaceAndSplitTokens, } from "../common/token-utils" -import { parseExpression } from "../script" +import { parseExpression } from "../script/index" import { DEFAULT_ECMA_VERSION } from "../script-setup/parser-options" -import { resolveReferences } from "../template" +import { resolveReferences } from "../template/index" import type { CSSCommentToken, CSSPunctuatorToken, @@ -36,7 +36,7 @@ class CSSTokenScanner { this.tokenizer = new CSSTokenizer(text, 0, options) } public nextToken(): CSSToken | null { - return this.reconsuming.shift() || this.tokenizer.nextToken() + return this.reconsuming.shift() ?? this.tokenizer.nextToken() } public reconsume(...tokens: CSSToken[]) { this.reconsuming.push(...tokens) @@ -57,7 +57,7 @@ export function parseStyleElements( ): void { const parserOptions: ParserOptions = { ...originalParserOptions, - ecmaVersion: originalParserOptions.ecmaVersion || DEFAULT_ECMA_VERSION, + ecmaVersion: originalParserOptions.ecmaVersion ?? DEFAULT_ECMA_VERSION, } for (const style of elements) { @@ -372,7 +372,7 @@ function parseVBindArg(tokenizer: CSSTokenScanner): { comments, } } - const startToken = tokensBuffer[0] || token + const startToken = tokensBuffer[0] ?? token return { exprRange: [startToken.range[0], token.range[0]], quote: null, diff --git a/src/style/tokenizer.ts b/src/style/tokenizer.ts index b01e9a38..fd58d257 100644 --- a/src/style/tokenizer.ts +++ b/src/style/tokenizer.ts @@ -1,5 +1,5 @@ import { debug } from "../common/debug" -import type { OffsetRange } from "../ast" +import type { OffsetRange } from "../ast/index" import { APOSTROPHE, ASTERISK, diff --git a/src/template/index.ts b/src/template/index.ts index cdb8265e..80c3f766 100644 --- a/src/template/index.ts +++ b/src/template/index.ts @@ -25,11 +25,11 @@ import type { VNode, VOnExpression, VSlotScopeExpression, -} from "../ast" -import { ParseError } from "../ast" +} from "../ast/index" +import { ParseError } from "../ast/index" import { debug } from "../common/debug" import type { LocationCalculatorForHtml } from "../common/location-calculator" -import type { ExpressionParseResult } from "../script" +import type { ExpressionParseResult } from "../script/index" import { parseExpression, parseVForExpression, @@ -37,7 +37,7 @@ import { parseSlotScopeExpression, parseGenericExpression, parseScriptFragment, -} from "../script" +} from "../script/index" import { createSimpleToken, insertComments, @@ -159,7 +159,7 @@ function parseDirectiveKeyStatically( if (directiveKey.name == null) { directiveKey.name = modifiers.shift()! } else if (directiveKey.argument == null && modifiers[0].name !== "") { - directiveKey.argument = modifiers.shift() || null + directiveKey.argument = modifiers.shift() ?? null } directiveKey.modifiers = modifiers.filter(isNotEmptyModifier) @@ -553,7 +553,7 @@ function resolveReference(referene: Reference, element: VElement): void { let node: VNode | null = element // Find the variable of this reference. - while (node != null && node.type === "VElement") { + while (node?.type === "VElement") { for (const variable of node.variables) { if (variable.id.name === referene.id.name) { referene.variable = variable @@ -592,7 +592,7 @@ export function convertToDirective( debug( '[template] convert to directive: %s="%s" %j', node.key.name, - node.value && node.value.value, + node.value?.value, node.range, ) @@ -607,11 +607,7 @@ export function convertToDirective( ) const { argument } = directive.key - if ( - argument && - argument.type === "VIdentifier" && - argument.name.startsWith("[") - ) { + if (argument?.type === "VIdentifier" && argument.name.startsWith("[")) { const nextChar = code[argument.range[1]] if (nextChar == null || invalidDynamicArgumentNextChar.test(nextChar)) { const char = @@ -778,7 +774,7 @@ export function processMustache( { allowEmpty: true, allowFilters: true }, ) - node.expression = ret.expression || null + node.expression = ret.expression ?? null node.references = ret.references if (ret.expression != null) { ret.expression.parent = node diff --git a/test/ast.js b/test/ast.js index 31bc8e36..c033c807 100644 --- a/test/ast.js +++ b/test/ast.js @@ -14,20 +14,20 @@ const fs = require("fs") const path = require("path") const lodash = require("lodash") const parser = require("../src") -const Linter = require("./fixtures/eslint").Linter +const eslint = require("eslint") const semver = require("semver") const { scopeToJSON, analyze, replacer, getAllTokens } = require("./test-utils") //------------------------------------------------------------------------------ // Helpers //------------------------------------------------------------------------------ - -const PARSER = path.resolve(__dirname, "../src/index.ts") +const Linter = eslint.Linter const ROOT = path.join(__dirname, "fixtures/ast") const TARGETS = fs.readdirSync(ROOT) const PARSER_OPTIONS = { comment: true, - ecmaVersion: 2020, + ecmaVersion: "latest", + sourceType: "module", loc: true, range: true, tokens: true, @@ -41,39 +41,52 @@ const PARSER_OPTIONS = { * @returns {object} Simple tree. */ function getTree(source, parserOptions) { - const linter = new Linter() + const linter = new Linter({ configType: "flat" }) const stack = [] const root = { children: [] } let current = root - linter.defineParser(PARSER, require(PARSER)) - linter.defineRule("maketree", (ruleContext) => - ruleContext.parserServices.defineTemplateBodyVisitor({ - "*"(node) { - stack.push(current) - current.children.push( - (current = { - type: node.type, - text: source.slice(node.range[0], node.range[1]), - children: [], - }), - ) - }, - "*:exit"() { - current = stack.pop() - }, - }), - ) - linter.verify( + const maketree = { + create: (ruleContext) => + ruleContext.sourceCode.parserServices.defineTemplateBodyVisitor({ + "*"(node) { + stack.push(current) + current.children.push( + (current = { + type: node.type, + text: source.slice(node.range[0], node.range[1]), + children: [], + }), + ) + }, + "*:exit"() { + current = stack.pop() + }, + }), + } + const result = linter.verify( source, { - parser: PARSER, - parserOptions: Object.assign({ ecmaVersion: 2020 }, parserOptions), - rules: { maketree: "error" }, + files: ["**"], + plugins: { + test: { + rules: { + maketree, + }, + }, + }, + languageOptions: { + parser: parser, + ecmaVersion: parserOptions.ecmaVersion ?? "latest", + sourceType: parserOptions.sourceType ?? "module", + parserOptions: parserOptions, + }, + rules: { "test/maketree": "error" }, }, undefined, true, ) + assert.deepStrictEqual(result, []) return root.children } @@ -95,43 +108,56 @@ function nodeToString(node, source) { * @returns {void} */ function validateParent(source, parserOptions) { - const linter = new Linter() + const linter = new Linter({ configType: "flat" }) const stack = [] - linter.defineParser(PARSER, require(PARSER)) - linter.defineRule("validateparent", (ruleContext) => - ruleContext.parserServices.defineTemplateBodyVisitor({ - "*"(node) { - if (stack.length >= 1) { - const parent = lodash.last(stack) - assert( - node.parent === parent, - `The parent of ${nodeToString( - node, - source, - )} should be ${nodeToString( - parent, - source, - )}, but got ${nodeToString(node.parent, source)}`, - ) - } - stack.push(node) - }, - "*:exit"() { - stack.pop() - }, - }), - ) - linter.verify( + const validateparent = { + create: (ruleContext) => + ruleContext.sourceCode.parserServices.defineTemplateBodyVisitor({ + "*"(node) { + if (stack.length >= 1) { + const parent = lodash.last(stack) + assert( + node.parent === parent, + `The parent of ${nodeToString( + node, + source, + )} should be ${nodeToString( + parent, + source, + )}, but got ${nodeToString(node.parent, source)}`, + ) + } + stack.push(node) + }, + "*:exit"() { + stack.pop() + }, + }), + } + const result = linter.verify( source, { - parser: PARSER, - parserOptions: Object.assign({ ecmaVersion: 2017 }, parserOptions), - rules: { validateparent: "error" }, + files: ["**"], + plugins: { + test: { + rules: { + validateparent, + }, + }, + }, + languageOptions: { + parser, + ecmaVersion: parserOptions.ecmaVersion ?? "latest", + sourceType: parserOptions.sourceType ?? "module", + parserOptions: parserOptions, + }, + rules: { "test/validateparent": "error" }, }, undefined, true, ) + assert.deepStrictEqual(result, []) } //------------------------------------------------------------------------------ @@ -165,11 +191,11 @@ describe("Template AST", () => { ), ) } - const options = Object.assign( - { filePath: sourcePath }, - PARSER_OPTIONS, - parserOptions, - ) + const options = { + filePath: sourcePath, + ...PARSER_OPTIONS, + ...parserOptions, + } if ( Object.entries(requirements).some(([pkgName, pkgVersion]) => { @@ -227,7 +253,7 @@ describe("Template AST", () => { }) it("should have correct location.", () => { - const lines = source.match(/[^\r\n]*(?:\r?\n|$)/gu) || [] + const lines = source.match(/[^\r\n]*(?:\r?\n|$)/gu) ?? [] lines.push(String.fromCodePoint(0)) for (const token of getAllTokens(actual.ast)) { const line0 = token.loc.start.line - 1 @@ -274,10 +300,6 @@ describe("Template AST", () => { }) it("should scope in the correct.", () => { - const version = require(`eslint/package.json`).version - if (!semver.satisfies(version, ">=8")) { - return - } const resultPath = path.join(ROOT, `${name}/scope.json`) if (!fs.existsSync(resultPath)) { return diff --git a/test/core-rules.js b/test/core-rules.js deleted file mode 100644 index e4c6fc19..00000000 --- a/test/core-rules.js +++ /dev/null @@ -1,239 +0,0 @@ -/** - * @author Toru Nagashima <https://github.com/mysticatea> - * @copyright 2016 Toru Nagashima. All rights reserved. - * See LICENSE file in root directory for full license. - */ -"use strict" - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const path = require("path") -const fs = require("fs-extra") -const { RuleTester } = require("./fixtures/eslint") - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -const RULE_DEFS_ROOT = path.join(__dirname, "fixtures/eslint/lib/rules") -const RULE_TESTS_ROOT = path.join(__dirname, "fixtures/eslint/tests/lib/rules") -const PARSER_PATH = path.resolve(__dirname, "../src/index.ts") -const EXCEPTIONS = new Set([ - // Those rules check outside `<script>` tag as well. - // It cannot fix the behavior in vue-eslint-parser side. - "eol-last", - "max-len", - "max-lines", - - // Wrapper includes line-breaks, so it changed the number of errors. - // It cannot test this rule correctly. - "linebreak-style", - - // Tests about the head/last of source code failed because "<script>" tokens - // are added. - // It cannot test this rule correctly. - "lines-around-comment", - "no-multiple-empty-lines", - "semi-style", - - // The inside of "<script>" tags is not related to Unicode BOM. - "unicode-bom", -]) -const originalRun = RuleTester.prototype.run -const processed = new Set() - -/** - * Check if the code should be skipped or not. - * The following code should be skipped. - * - includes shebang - * - includes syntax error -- some tests in old ESLint contains syntax error. - * Acorn has fixed to catch the syntax errors in a minor release, so those - * tests go to fail. - * @param {string} code The test code. - */ -function codeShouldBeSkipped(code) { - return code.startsWith("#!") || code.includes("await async") -} - -/** - * Wrap the given code with a `<script>` tag. - * - * @param {string} ruleId The rule ID. - * @param {string} code - The code to be wrapped. - * @returns {string} The wrapped code. - */ -function wrapCode(ruleId, code) { - const eol = "\n" - - if (code.charCodeAt(0) === 0xfeff) { - return `\uFEFF<script>${eol}${code.slice(1)}${eol}</script>` - } - if (ruleId === "prefer-regex-literals") { - return `<script>;${eol}${code}${eol}</script>` - } - return `<script>${eol}${code}${eol}</script>` -} - -/** - * Modify the given test pattern to test with vue-eslint-parser. - * - * @param {string} ruleId The rule ID. - * @param {string|object} pattern - The test pattern to be modified. - * @returns {object|null} The modified pattern. - */ -//eslint-disable-next-line complexity -function modifyPattern(ruleId, pattern) { - if (typeof pattern === "string") { - if (codeShouldBeSkipped(pattern)) { - return null - } - return { - code: wrapCode(ruleId, pattern), - filename: "test.vue", - parser: PARSER_PATH, - } - } - - // If a test case depends on filename or special parser (returns constant AST - // object), we cannot rewrite the test case with `vue-eslint-parser`. - if ( - pattern.parser != null || - pattern.filename != null || - codeShouldBeSkipped(pattern.code) - ) { - return null - } - - // Ignore for now - if ( - (ruleId === "newline-per-chained-call" && - pattern.code === "foo.bar()['foo' + \u2029 + 'bar']()") || - (ruleId === "no-nonoctal-decimal-escape" && - pattern.code === "'\\\r\n\\9'") || - // The location is reported as a fixed value: { line: 1, column: 0 }. - (ruleId === "consistent-return" && - pattern.parserOptions && - pattern.parserOptions.ecmaFeatures && - pattern.parserOptions.ecmaFeatures.globalReturn === true) - ) { - return null - } - - // Wrap the code by `<script>` tag. - pattern.filename = "test.vue" - pattern.parser = PARSER_PATH - pattern.code = wrapCode(ruleId, pattern.code) - if (pattern.output != null) { - pattern.output = wrapCode(ruleId, pattern.output) - } - - if (Array.isArray(pattern.errors)) { - for (const error of pattern.errors) { - if (typeof error === "object" && !processed.has(error)) { - processed.add(error) - - // The line number +1 because `<script>\n` is inserted. - if (typeof error.line === "number") { - error.line += 1 - } - if (typeof error.endLine === "number") { - error.endLine += 1 - } - - // `semi` rule is special a bit. - // The `endLine` is explicitly undefined if it inserts semi into EOF. - // The `endColumn` is explicitly undefined if it inserts semi into EOF. - // Those becomes non-EOF because `\n</script>` is inserted. - if (ruleId === "semi") { - if ( - Object.hasOwnProperty.call(error, "endLine") && - error.endLine === undefined - ) { - const lines = pattern.code.split(/\r\n|[\r\n]/gu) - error.endLine = lines.length - } - if ( - Object.hasOwnProperty.call(error, "endColumn") && - error.endColumn === undefined - ) { - error.endColumn = 1 - } - } - - // `no-shadow` rule is special a bit. - if (ruleId === "no-shadow") { - // The data that the rule gives to the message contains the location. - if ( - error.data && - error.data && - Object.hasOwnProperty.call( - error.data, - "shadowedLine", - ) && - typeof error.data.shadowedLine === "number" - ) { - error.data.shadowedLine++ - } - } - - // Wrap the code by `<script>` tag. - if (Array.isArray(error.suggestions)) { - for (const suggestion of error.suggestions) { - suggestion.output = wrapCode(ruleId, suggestion.output) - } - } - } - } - } - - return pattern -} - -/** - * Run the given tests. - * This is used to replace `RuleTester.prototype.run`. - * - * @this {RuleTester} - * @param {string} ruleId - The rule ID. - * @param {object} impl - The rule implementation to be tested. - * @param {object} patterns - The test patterns. - * @returns {void} - */ -function overrideRun(ruleId, impl, patterns) { - return originalRun.call(this, ruleId, impl, { - valid: patterns.valid - .map((pattern) => modifyPattern(ruleId, pattern)) - .filter(Boolean), - invalid: patterns.invalid - .map((pattern) => modifyPattern(ruleId, pattern)) - .filter(Boolean), - }) -} - -//------------------------------------------------------------------------------ -// Tests -//------------------------------------------------------------------------------ - -RuleTester.prototype.run = overrideRun -try { - describe("Tests of ESLint core rules", () => { - for (const fileName of fs.readdirSync(RULE_TESTS_ROOT)) { - if (path.extname(fileName) !== ".js" || fileName.startsWith("_")) { - continue - } - if (require(path.join(RULE_DEFS_ROOT, fileName)).meta.deprecated) { - continue - } - if (EXCEPTIONS.has(path.basename(fileName, ".js"))) { - continue - } - - require(path.join(RULE_TESTS_ROOT, fileName)) - } - }) -} finally { - RuleTester.prototype.run = originalRun - processed.clear() -} diff --git a/test/define-custom-blocks-visitor.js b/test/define-custom-blocks-visitor.js index 9b3047b0..79bd5332 100644 --- a/test/define-custom-blocks-visitor.js +++ b/test/define-custom-blocks-visitor.js @@ -12,26 +12,14 @@ const path = require("path") const eslint = require("eslint") const jsonParser = require("jsonc-eslint-parser") const espree = require("espree") -const Linter = eslint.Linter //------------------------------------------------------------------------------ // Helpers //------------------------------------------------------------------------------ +const Linter = eslint.Linter -const PARSER_PATH = path.resolve(__dirname, "../src/index.ts") +const parser = require("../src/index.ts") -const LINTER_CONFIG = { - parser: PARSER_PATH, - parserOptions: { - ecmaVersion: 2015, - }, - rules: { - "test-no-number-literal": "error", - "test-no-forbidden-key": "error", - "test-no-parsing-error": "error", - "test-no-parsing-error2": "error", - }, -} const noNumberLiteralRule = { create(context) { let count = 0 @@ -134,45 +122,230 @@ const siblingSelectorRule = { }, } -function createLinter(target = "json") { - const linter = new Linter() - - linter.defineParser(PARSER_PATH, require(PARSER_PATH)) - linter.defineRule("test-no-number-literal", (context) => - context.parserServices.defineCustomBlocksVisitor(context, jsonParser, { - target, - ...noNumberLiteralRule, - }), - ) - linter.defineRule("test-no-forbidden-key", (context) => - context.parserServices.defineCustomBlocksVisitor(context, jsonParser, { - target, - ...noNoForbiddenKeyRule, - }), - ) - linter.defineRule("test-no-parsing-error", (context) => - context.parserServices.defineCustomBlocksVisitor(context, jsonParser, { - target, - ...noParsingErrorRule, - }), - ) - linter.defineRule("test-no-parsing-error2", (context) => - context.parserServices.defineCustomBlocksVisitor(context, jsonParser, { - target, - ...noParsingErrorRule2, - }), - ) - linter.defineRule("test-no-program-exit", (context) => - context.parserServices.defineCustomBlocksVisitor( - context, - jsonParser, - { - target, - ...noProgramExitRule, +function getConfig(target = "json") { + const spaceUnaryOps = + require("eslint/use-at-your-own-risk").builtinRules.get( + "space-unary-ops", + ) + const noParamReassign = + require("eslint/use-at-your-own-risk").builtinRules.get( + "no-param-reassign", + ) + const noUnusedVars = + require("eslint/use-at-your-own-risk").builtinRules.get( + "no-unused-vars", + ) + + return { + files: ["**"], + plugins: { + test: { + rules: { + "test-no-number-literal": { + create: (context) => + context.sourceCode.parserServices.defineCustomBlocksVisitor( + context, + jsonParser, + { + target, + ...noNumberLiteralRule, + }, + ), + }, + "test-no-forbidden-key": { + create: (context) => + context.sourceCode.parserServices.defineCustomBlocksVisitor( + context, + jsonParser, + { + target, + ...noNoForbiddenKeyRule, + }, + ), + }, + "test-no-parsing-error": { + create: (context) => + context.sourceCode.parserServices.defineCustomBlocksVisitor( + context, + jsonParser, + { + target, + ...noParsingErrorRule, + }, + ), + }, + "test-no-parsing-error2": { + create: (context) => + context.sourceCode.parserServices.defineCustomBlocksVisitor( + context, + jsonParser, + { + target, + ...noParsingErrorRule2, + }, + ), + }, + "test-no-program-exit": { + create: (context) => + context.sourceCode.parserServices.defineCustomBlocksVisitor( + context, + jsonParser, + { + target, + ...noProgramExitRule, + }, + noProgramExitRule.create(context), + ), + }, + "test-no-yml-parsing-error": { + create: (context) => + context.sourceCode.parserServices.defineCustomBlocksVisitor( + context, + { + parse() { + throw new Error("Foo") + }, + }, + { + target: "yaml", + ...noParsingErrorRule, + }, + ), + }, + + "test-for-sibling-selector": { + create: (context) => + context.sourceCode.parserServices.defineCustomBlocksVisitor( + context, + jsonParser, + { + target: "json", + create: siblingSelectorRule.create, + }, + ), + }, + "test-for-parse-custom-block-element": { + create: (context) => + context.sourceCode.parserServices.defineCustomBlocksVisitor( + context, + jsonParser, + { + target: "json", + create(ctx) { + return { + Program(node) { + const error = + ctx.sourceCode.parserServices.parseCustomBlockElement( + jsonParser, + { jsonSyntax: "json" }, + ).error + ctx.report({ + node, + message: JSON.stringify({ + lineNumber: + error.lineNumber, + column: error.column, + message: error.message, + }), + }) + }, + } + }, + }, + ), + }, + "test-mark-vars": { + create(context) { + return context.sourceCode.parserServices.defineCustomBlocksVisitor( + context, + espree, + { + target: "js", + create(customBlockContext) { + return { + Literal() { + customBlockContext.markVariableAsUsed( + "a", + ) + customBlockContext.markVariableAsUsed( + "b", + ) + }, + } + }, + }, + ) + }, + }, + + "test-space-unary-ops": { + ...spaceUnaryOps, + create(context) { + return context.sourceCode.parserServices.defineCustomBlocksVisitor( + context, + espree, + { + target: "js", + create(customBlockContext) { + return spaceUnaryOps.create( + customBlockContext, + ) + }, + }, + ) + }, + }, + "test-no-param-reassign": { + ...noParamReassign, + create(context) { + return context.sourceCode.parserServices.defineCustomBlocksVisitor( + context, + espree, + { + target: "js", + create(customBlockContext) { + return noParamReassign.create( + customBlockContext, + ) + }, + }, + ) + }, + }, + "test-no-unused-vars": { + ...noUnusedVars, + create(context) { + return context.sourceCode.parserServices.defineCustomBlocksVisitor( + context, + espree, + { + target: "js", + create(customBlockContext) { + return noUnusedVars.create( + customBlockContext, + ) + }, + }, + ) + }, + }, + }, }, - noProgramExitRule.create(context), - ), - ) + }, + languageOptions: { + parser, + }, + rules: { + "test/test-no-number-literal": "error", + "test/test-no-forbidden-key": "error", + "test/test-no-parsing-error": "error", + "test/test-no-parsing-error2": "error", + }, + } +} + +function createLinter() { + const linter = new Linter({ configType: "flat" }) return linter } @@ -189,8 +362,8 @@ describe("parserServices.defineCustomBlocksVisitor tests", () => { </i18n>` const linter = createLinter() - const messages1 = linter.verify(code, LINTER_CONFIG) - const messages2 = linter.verify(linter.getSourceCode(), LINTER_CONFIG) + const messages1 = linter.verify(code, getConfig()) + const messages2 = linter.verify(linter.getSourceCode(), getConfig()) assert.strictEqual(messages1.length, 2) assert.strictEqual(messages1[0].message, 'no "forbidden" key') @@ -212,9 +385,9 @@ describe("parserServices.defineCustomBlocksVisitor tests", () => { {"foo": 123} </i18n> ` - const linter = createLinter(["json", "json5"]) + const linter = createLinter() - const messages = linter.verify(code, LINTER_CONFIG) + const messages = linter.verify(code, getConfig(["json", "json5"])) assert.strictEqual(messages.length, 2) assert.strictEqual(messages[0].message, "OK 42@count:1") @@ -238,7 +411,7 @@ describe("parserServices.defineCustomBlocksVisitor tests", () => { ` const linter = createLinter() - const messages = linter.verify(code, LINTER_CONFIG) + const messages = linter.verify(code, getConfig()) assert.strictEqual(messages.length, 0) }) @@ -251,7 +424,7 @@ describe("parserServices.defineCustomBlocksVisitor tests", () => { ` const linter = createLinter() - const messages = linter.verify(code, LINTER_CONFIG) + const messages = linter.verify(code, getConfig()) assert.strictEqual(messages.length, 0) }) @@ -262,7 +435,7 @@ describe("parserServices.defineCustomBlocksVisitor tests", () => { ` const linter = createLinter() - const messages = linter.verify(code, LINTER_CONFIG) + const messages = linter.verify(code, getConfig()) assert.strictEqual(messages.length, 0) }) @@ -279,19 +452,17 @@ describe("parserServices.defineCustomBlocksVisitor tests", () => { "foo": 42 </docs> ` - const linter = createLinter( + const linter = createLinter() + const config = getConfig( (lang, block) => (lang === "json" && lang === "json5") || (!lang && block.name === "i18n"), ) - const messages1 = linter.verify(code, LINTER_CONFIG) + const messages1 = linter.verify(code, config) assert.strictEqual(messages1.length, 0) - const messages2 = linter.verify( - `${code}<i18n>123</i18n>`, - LINTER_CONFIG, - ) + const messages2 = linter.verify(`${code}<i18n>123</i18n>`, config) assert.strictEqual(messages2.length, 1) }) @@ -304,7 +475,7 @@ describe("parserServices.defineCustomBlocksVisitor tests", () => { ` const linter = createLinter() - const messages = linter.verify(code, LINTER_CONFIG, "test.html") + const messages = linter.verify(code, getConfig(), "test.html") assert.strictEqual(messages.length, 0) }) @@ -320,7 +491,7 @@ describe("parserServices.defineCustomBlocksVisitor tests", () => { ` const linter = createLinter() - const messages = linter.verify(code, LINTER_CONFIG) + const messages = linter.verify(code, getConfig()) assert.strictEqual(messages.length, 6) assert.strictEqual(messages[0].message, "Unexpected token ':'.") @@ -365,26 +536,13 @@ describe("parserServices.defineCustomBlocksVisitor tests", () => { </i18n> ` const linter = createLinter() - linter.defineRule("test-no-yml-parsing-error", (context) => - context.parserServices.defineCustomBlocksVisitor( - context, - { - parse() { - throw new Error("Foo") - }, - }, - { - target: "yaml", - ...noParsingErrorRule, - }, - ), - ) + const baseConfig = getConfig() const messages = linter.verify(code, { - ...LINTER_CONFIG, + ...baseConfig, rules: { - ...LINTER_CONFIG.rules, - "test-no-yml-parsing-error": "error", + ...baseConfig.rules, + "test/test-no-yml-parsing-error": "error", }, }) @@ -404,12 +562,13 @@ describe("parserServices.defineCustomBlocksVisitor tests", () => { </i18n> ` const linter = createLinter() + const baseConfig = getConfig() const messages = linter.verify(code, { - ...LINTER_CONFIG, + ...baseConfig, rules: { - "test-no-program-exit": "error", - ...LINTER_CONFIG.rules, + "test/test-no-program-exit": "error", + ...baseConfig.rules, }, }) @@ -429,40 +588,13 @@ describe("parserServices.defineCustomBlocksVisitor tests", () => { </i18n> ` const linter = createLinter() - linter.defineRule("test-for-parse-custom-block-element", (context) => - context.parserServices.defineCustomBlocksVisitor( - context, - jsonParser, - { - target: "json", - create(ctx) { - return { - Program(node) { - const error = - ctx.parserServices.parseCustomBlockElement( - jsonParser, - { jsonSyntax: "json" }, - ).error - ctx.report({ - node, - message: JSON.stringify({ - lineNumber: error.lineNumber, - column: error.column, - message: error.message, - }), - }) - }, - } - }, - }, - ), - ) + const baseConfig = getConfig() const messages = linter.verify(code, { - ...LINTER_CONFIG, + ...baseConfig, rules: { - "test-for-parse-custom-block-element": "error", - ...LINTER_CONFIG.rules, + "test/test-for-parse-custom-block-element": "error", + ...baseConfig.rules, }, }) @@ -480,20 +612,12 @@ describe("parserServices.defineCustomBlocksVisitor tests", () => { </i18n> ` const linter = createLinter() - linter.defineRule("test-for-sibling-selector", (context) => - context.parserServices.defineCustomBlocksVisitor( - context, - jsonParser, - { - target: "json", - create: siblingSelectorRule.create, - }, - ), - ) + const baseConfig = getConfig() + const messages = linter.verify(code, { - ...LINTER_CONFIG, + ...baseConfig, rules: { - "test-for-sibling-selector": "error", + "test/test-for-sibling-selector": "error", }, }) @@ -511,37 +635,51 @@ describe("parserServices.defineCustomBlocksVisitor tests", () => { </i18n> ` const linter = createLinter() - linter.defineRule("test", (context) => - context.parserServices.defineCustomBlocksVisitor( - context, - jsonParser, - { - target: "json", - create(customBlockContext) { - return { - "JSONLiteral[value='target']"(node) { - customBlockContext.report({ - node, - message: JSON.stringify( - customBlockContext - .getAncestors() - .map((n) => n.type), - ), - }) + const baseConfig = getConfig() + + const plugin = { + rules: { + test: { + create: (context) => + context.sourceCode.parserServices.defineCustomBlocksVisitor( + context, + jsonParser, + { + target: "json", + create(customBlockContext) { + return { + "JSONLiteral[value='target']"( + node, + ) { + customBlockContext.report({ + node, + message: JSON.stringify( + customBlockContext + .getAncestors() + .map((n) => n.type), + ), + }) + }, + } + }, }, - } - }, + ), }, - ), - ) + }, + } - const messages = linter.verify(code, { - ...LINTER_CONFIG, - rules: { - ...LINTER_CONFIG.rules, - test: "error", + const messages = linter.verify(code, [ + baseConfig, + { + files: ["**"], + plugins: { + t: plugin, + }, + rules: { + "t/test": "error", + }, }, - }) + ]) assert.strictEqual(messages.length, 1) assert.strictEqual( @@ -556,37 +694,53 @@ describe("parserServices.defineCustomBlocksVisitor tests", () => { </i18n> ` const linter = createLinter() - linter.defineRule("test", (context) => - context.parserServices.defineCustomBlocksVisitor( - context, - jsonParser, - { - target: "json", - create(customBlockContext) { - return { - "JSONLiteral[value='target']"(node) { - customBlockContext.report({ - node, - message: JSON.stringify( - customBlockContext - .getSourceCode() - .getLocFromIndex(node.range[0]), - ), - }) + const baseConfig = getConfig() + + const plugin = { + rules: { + test: { + create: (context) => + context.sourceCode.parserServices.defineCustomBlocksVisitor( + context, + jsonParser, + { + target: "json", + create(customBlockContext) { + return { + "JSONLiteral[value='target']"( + node, + ) { + customBlockContext.report({ + node, + message: JSON.stringify( + customBlockContext + .getSourceCode() + .getLocFromIndex( + node.range[0], + ), + ), + }) + }, + } + }, }, - } - }, + ), }, - ), - ) + }, + } - const messages = linter.verify(code, { - ...LINTER_CONFIG, - rules: { - ...LINTER_CONFIG.rules, - test: "error", + const messages = linter.verify(code, [ + baseConfig, + { + files: ["**"], + plugins: { + t: plugin, + }, + rules: { + "t/test": "error", + }, }, - }) + ]) assert.strictEqual(messages.length, 1) assert.strictEqual(messages[0].message, '{"line":3,"column":18}') @@ -601,51 +755,13 @@ let a = 42; </js> ` const linter = createLinter() - const rule = linter.getRules().get("no-unused-vars") - linter.defineRule("test-no-unused-vars", { - ...rule, - create(context) { - return context.parserServices.defineCustomBlocksVisitor( - context, - espree, - { - target: "js", - create(customBlockContext) { - return rule.create(customBlockContext) - }, - }, - ) - }, - }) - linter.defineRule("test-mark-vars", { - create(context) { - return context.parserServices.defineCustomBlocksVisitor( - context, - espree, - { - target: "js", - create(customBlockContext) { - return { - Literal() { - customBlockContext.markVariableAsUsed( - "a", - ) - customBlockContext.markVariableAsUsed( - "b", - ) - }, - } - }, - }, - ) - }, - }) + const baseConfig = getConfig() const messages1 = linter.verify(code, { - ...LINTER_CONFIG, + ...baseConfig, rules: { - ...LINTER_CONFIG.rules, - "test-no-unused-vars": "error", + ...baseConfig.rules, + "test/test-no-unused-vars": "error", }, }) @@ -656,11 +772,11 @@ let a = 42; ) const messages2 = linter.verify(code, { - ...LINTER_CONFIG, + ...baseConfig, rules: { - ...LINTER_CONFIG.rules, - "test-no-unused-vars": "error", - "test-mark-vars": "error", + ...baseConfig.rules, + "test/test-no-unused-vars": "error", + "test/test-mark-vars": "error", }, }) @@ -676,28 +792,13 @@ function a(arg) { </js> ` const linter = createLinter() - const rule = linter.getRules().get("no-param-reassign") - linter.defineRule("test-no-param-reassign", { - ...rule, - create(context) { - return context.parserServices.defineCustomBlocksVisitor( - context, - espree, - { - target: "js", - create(customBlockContext) { - return rule.create(customBlockContext) - }, - }, - ) - }, - }) + const baseConfig = getConfig() const messages1 = linter.verify(code, { - ...LINTER_CONFIG, + ...baseConfig, rules: { - ...LINTER_CONFIG.rules, - "test-no-param-reassign": "error", + ...baseConfig.rules, + "test/test-no-param-reassign": "error", }, }) @@ -715,28 +816,13 @@ var v = + 42 </js> ` const linter = createLinter() - const rule = linter.getRules().get("space-unary-ops") - linter.defineRule("test-space-unary-ops", { - ...rule, - create(context) { - return context.parserServices.defineCustomBlocksVisitor( - context, - espree, - { - target: "js", - create(customBlockContext) { - return rule.create(customBlockContext) - }, - }, - ) - }, - }) + const baseConfig = getConfig() const messages1 = linter.verify(code, { - ...LINTER_CONFIG, + ...baseConfig, rules: { - ...LINTER_CONFIG.rules, - "test-space-unary-ops": "error", + ...baseConfig.rules, + "test/test-space-unary-ops": "error", }, }) diff --git a/test/define-document-visitor.js b/test/define-document-visitor.js index 64c80ea2..049c51a2 100644 --- a/test/define-document-visitor.js +++ b/test/define-document-visitor.js @@ -10,13 +10,13 @@ const assert = require("assert") const path = require("path") const eslint = require("eslint") -const Linter = eslint.Linter +const parser = require("../src/index.ts") //------------------------------------------------------------------------------ // Helpers //------------------------------------------------------------------------------ -const PARSER_PATH = path.resolve(__dirname, "../src/index.ts") +const Linter = eslint.Linter //------------------------------------------------------------------------------ // Tests @@ -42,41 +42,50 @@ describe("parserServices.defineDocumentVisitor tests", () => { } </style>` - const linter = new Linter() + const linter = new Linter({ configType: "flat" }) - linter.defineParser(PARSER_PATH, require(PARSER_PATH)) - linter.defineRule("test-no-forbidden", { - create(context) { - return context.parserServices.defineDocumentVisitor({ - 'Identifier[name="forbidden"]'(node) { - context.report({ - node, - message: 'no "forbidden"', - }) - }, - }) + const rules = { + "test-no-forbidden": { + create(context) { + return context.sourceCode.parserServices.defineDocumentVisitor( + { + 'Identifier[name="forbidden"]'(node) { + context.report({ + node, + message: 'no "forbidden"', + }) + }, + }, + ) + }, }, - }) - linter.defineRule("test-no-call", { - create(context) { - return context.parserServices.defineDocumentVisitor({ - CallExpression(node) { - context.report({ - node, - message: "no call", - }) - }, - }) + "test-no-call": { + create(context) { + return context.sourceCode.parserServices.defineDocumentVisitor( + { + CallExpression(node) { + context.report({ + node, + message: "no call", + }) + }, + }, + ) + }, }, - }) + } const messages = linter.verify(code, { - parser: PARSER_PATH, - parserOptions: { - ecmaVersion: 2018, + plugins: { + test: { + rules, + }, + }, + languageOptions: { + parser, }, rules: { - "test-no-forbidden": "error", - "test-no-call": "error", + "test/test-no-forbidden": "error", + "test/test-no-call": "error", }, }) assert.strictEqual(messages.length, 4) diff --git a/test/document-fragment.js b/test/document-fragment.js index b8f95f09..9204ce7d 100644 --- a/test/document-fragment.js +++ b/test/document-fragment.js @@ -17,7 +17,7 @@ const ROOT = path.join(__dirname, "fixtures/document-fragment") const TARGETS = fs.readdirSync(ROOT) const PARSER_OPTIONS = { comment: true, - ecmaVersion: 6, + ecmaVersion: "latest", loc: true, range: true, tokens: true, @@ -61,11 +61,11 @@ describe("services.getDocumentFragment", () => { ].find((fp) => fs.existsSync(fp)) const source = fs.readFileSync(sourcePath, "utf8") const parserOptions = optionsPath ? require(optionsPath) : {} - const options = Object.assign( - { filePath: sourcePath }, - PARSER_OPTIONS, - parserOptions, - ) + const options = { + filePath: sourcePath, + ...PARSER_OPTIONS, + ...parserOptions, + } const result = parser.parseForESLint(source, options) const actual = result.services.getDocumentFragment() diff --git a/test/espree.js b/test/espree.js deleted file mode 100644 index 5b1d1cca..00000000 --- a/test/espree.js +++ /dev/null @@ -1,133 +0,0 @@ -"use strict" - -const path = require("path") - -/** - * Spawn a child process to run `childMain()`. - */ -function parentMain() { - const { spawn, execSync } = require("child_process") - - describe("Loading espree from ESLint", () => { - it("should load espree from the ESLint location.", (done) => { - spawn( - process.execPath, - ["--require", "ts-node/register", __filename, "--child1"], - { - stdio: "inherit", - }, - ) - .on("error", done) - .on("exit", (code) => - code - ? done(new Error(`Exited with non-zero: ${code}`)) - : done(), - ) - }) - it("should load espree from the ESLint location.", (done) => { - spawn( - process.execPath, - ["--require", "ts-node/register", __filename, "--child1"], - { - stdio: "inherit", - }, - ) - .on("error", done) - .on("exit", (code) => - code - ? done(new Error(`Exited with non-zero: ${code}`)) - : done(), - ) - }) - it("should load espree from the user location.", (done) => { - const originalCwd = process.cwd() - try { - process.chdir(path.join(__dirname, "./fixtures/espree-v8")) - execSync("npm i", { - stdio: "inherit", - }) - spawn( - process.execPath, - ["--require", "ts-node/register", __filename, "--child2"], - { - stdio: "inherit", - }, - ) - .on("error", done) - .on("exit", (code) => - code - ? done(new Error(`Exited with non-zero: ${code}`)) - : done(), - ) - } finally { - process.chdir(originalCwd) - } - }) - }) -} - -/** - * Check this parser loads the `espree` from the location of the loaded ESLint. - */ -function childMain1() { - const assert = require("assert") - const { Linter } = require("./fixtures/eslint") - const linter = new Linter() - linter.defineParser("vue-eslint-parser", require("../src")) - - const beforeEsprees = Object.keys(require.cache).filter(isEspreePath) - - linter.verify( - "<script>'hello'</script>", - { parser: "vue-eslint-parser" }, - { filename: "a.vue" }, - ) - - const afterEsprees = Object.keys(require.cache).filter(isEspreePath) - - assert.strictEqual( - afterEsprees.length, - beforeEsprees.length, - "espree should be loaded from the expected place", - ) -} - -/** - * Check this parser loads the `espree` from the location of the user dir. - */ -function childMain2() { - const assert = require("assert") - const { Linter } = require("./fixtures/eslint") - const linter = new Linter() - linter.defineParser("vue-eslint-parser", require("../src")) - - const result = linter.verify( - "<script>await foo;</script>", - { - parser: "vue-eslint-parser", - parserOptions: { - parser: "espree", - ecmaVersion: 2022, - sourceType: "module", - }, - }, - { filename: "a.vue" }, - ) - assert.strictEqual( - result.length, - 0, - "espree should be loaded from the fixtures/espree-v8", - ) -} - -function isEspreePath(p) { - return p.includes(`${path.sep}node_modules${path.sep}espree${path.sep}`) -} - -if (process.argv.includes("--child1")) { - childMain1() -} else if (process.argv.includes("--child2")) { - childMain2() -} else { - parentMain() -} diff --git a/test/fixtures/ast/address-component/ast.json b/test/fixtures/ast/address-component/ast.json index 7a2e1259..9aa8a9fb 100644 --- a/test/fixtures/ast/address-component/ast.json +++ b/test/fixtures/ast/address-component/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/attributes-linebreak/ast.json b/test/fixtures/ast/attributes-linebreak/ast.json index 5046b313..ed9be113 100644 --- a/test/fixtures/ast/attributes-linebreak/ast.json +++ b/test/fixtures/ast/attributes-linebreak/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/attributes/ast.json b/test/fixtures/ast/attributes/ast.json index 36033fe3..ff1b8f02 100644 --- a/test/fixtures/ast/attributes/ast.json +++ b/test/fixtures/ast/attributes/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/auto-closing-dt-dd/ast.json b/test/fixtures/ast/auto-closing-dt-dd/ast.json index 1b6ee98a..8f432dbc 100644 --- a/test/fixtures/ast/auto-closing-dt-dd/ast.json +++ b/test/fixtures/ast/auto-closing-dt-dd/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/auto-closing-p/ast.json b/test/fixtures/ast/auto-closing-p/ast.json index 6c02afe0..01d28fea 100644 --- a/test/fixtures/ast/auto-closing-p/ast.json +++ b/test/fixtures/ast/auto-closing-p/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/bogus-comments/ast.json b/test/fixtures/ast/bogus-comments/ast.json index df818408..78fd74f0 100644 --- a/test/fixtures/ast/bogus-comments/ast.json +++ b/test/fixtures/ast/bogus-comments/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/cdata/ast.json b/test/fixtures/ast/cdata/ast.json index 9e6cfa76..e2fb0d92 100644 --- a/test/fixtures/ast/cdata/ast.json +++ b/test/fixtures/ast/cdata/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/comments-2/ast.json b/test/fixtures/ast/comments-2/ast.json index e9039ec2..72d1aa98 100644 --- a/test/fixtures/ast/comments-2/ast.json +++ b/test/fixtures/ast/comments-2/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/comments-3/ast.json b/test/fixtures/ast/comments-3/ast.json index 5d4e705e..9af27f07 100644 --- a/test/fixtures/ast/comments-3/ast.json +++ b/test/fixtures/ast/comments-3/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/comments/ast.json b/test/fixtures/ast/comments/ast.json index 0c735c09..449c1d88 100644 --- a/test/fixtures/ast/comments/ast.json +++ b/test/fixtures/ast/comments/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/custom-template-tokenizer/ast.json b/test/fixtures/ast/custom-template-tokenizer/ast.json index d82bb8c4..bca7698c 100644 --- a/test/fixtures/ast/custom-template-tokenizer/ast.json +++ b/test/fixtures/ast/custom-template-tokenizer/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/custom-thead/ast.json b/test/fixtures/ast/custom-thead/ast.json index 52ec1866..3bed997e 100644 --- a/test/fixtures/ast/custom-thead/ast.json +++ b/test/fixtures/ast/custom-thead/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/define-model06-with-ts/ast.json b/test/fixtures/ast/define-model06-with-ts/ast.json index cde9a60a..3e647bdd 100644 --- a/test/fixtures/ast/define-model06-with-ts/ast.json +++ b/test/fixtures/ast/define-model06-with-ts/ast.json @@ -1,66 +1,61 @@ { "type": "Program", + "range": [ + 25, + 66 + ], "body": [ { "type": "VariableDeclaration", "declarations": [ { "type": "VariableDeclarator", + "definite": false, "id": { "type": "Identifier", + "decorators": [], "name": "modelValue", + "optional": false, "range": [ 31, 41 ], "loc": { - "start": { - "line": 2, - "column": 6 - }, "end": { "line": 2, "column": 16 + }, + "start": { + "line": 2, + "column": 6 } } }, "init": { "type": "CallExpression", + "arguments": [], "callee": { "type": "Identifier", + "decorators": [], "name": "defineModel", + "optional": false, "range": [ 44, 55 ], "loc": { - "start": { - "line": 2, - "column": 19 - }, "end": { "line": 2, "column": 30 + }, + "start": { + "line": 2, + "column": 19 } } }, - "arguments": [], "optional": false, - "range": [ - 44, - 65 - ], - "loc": { - "start": { - "line": 2, - "column": 19 - }, - "end": { - "line": 2, - "column": 40 - } - }, - "typeParameters": { + "typeArguments": { "type": "TSTypeParameterInstantiation", "range": [ 55, @@ -74,27 +69,41 @@ 62 ], "loc": { - "start": { - "line": 2, - "column": 31 - }, "end": { "line": 2, "column": 37 + }, + "start": { + "line": 2, + "column": 31 } } } ], "loc": { - "start": { - "line": 2, - "column": 30 - }, "end": { "line": 2, "column": 38 + }, + "start": { + "line": 2, + "column": 30 } } + }, + "range": [ + 44, + 65 + ], + "loc": { + "end": { + "line": 2, + "column": 40 + }, + "start": { + "line": 2, + "column": 19 + } } }, "range": [ @@ -102,49 +111,37 @@ 65 ], "loc": { - "start": { - "line": 2, - "column": 6 - }, "end": { "line": 2, "column": 40 + }, + "start": { + "line": 2, + "column": 6 } } } ], + "declare": false, "kind": "const", "range": [ 25, 65 ], "loc": { - "start": { - "line": 2, - "column": 0 - }, "end": { "line": 2, "column": 40 + }, + "start": { + "line": 2, + "column": 0 } } } ], + "comments": [], "sourceType": "module", - "range": [ - 25, - 66 - ], - "loc": { - "start": { - "line": 2, - "column": 0 - }, - "end": { - "line": 3, - "column": 0 - } - }, "tokens": [ { "type": "Punctuator", @@ -166,165 +163,165 @@ }, { "type": "Keyword", - "value": "const", + "loc": { + "end": { + "line": 2, + "column": 5 + }, + "start": { + "line": 2, + "column": 0 + } + }, "range": [ 25, 30 ], + "value": "const" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 2, - "column": 0 + "column": 16 }, - "end": { + "start": { "line": 2, - "column": 5 + "column": 6 } - } - }, - { - "type": "Identifier", - "value": "modelValue", + }, "range": [ 31, 41 ], + "value": "modelValue" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 6 + "column": 18 }, - "end": { + "start": { "line": 2, - "column": 16 + "column": 17 } - } - }, - { - "type": "Punctuator", - "value": "=", + }, "range": [ 42, 43 ], + "value": "=" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 2, - "column": 17 + "column": 30 }, - "end": { + "start": { "line": 2, - "column": 18 + "column": 19 } - } - }, - { - "type": "Identifier", - "value": "defineModel", + }, "range": [ 44, 55 ], + "value": "defineModel" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 19 + "column": 31 }, - "end": { + "start": { "line": 2, "column": 30 } - } - }, - { - "type": "Punctuator", - "value": "<", + }, "range": [ 55, 56 ], + "value": "<" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 2, - "column": 30 + "column": 37 }, - "end": { + "start": { "line": 2, "column": 31 } - } - }, - { - "type": "Identifier", - "value": "string", + }, "range": [ 56, 62 ], + "value": "string" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 31 + "column": 38 }, - "end": { + "start": { "line": 2, "column": 37 } - } - }, - { - "type": "Punctuator", - "value": ">", + }, "range": [ 62, 63 ], + "value": ">" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 37 + "column": 39 }, - "end": { + "start": { "line": 2, "column": 38 } - } - }, - { - "type": "Punctuator", - "value": "(", + }, "range": [ 63, 64 ], + "value": "(" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 38 + "column": 40 }, - "end": { + "start": { "line": 2, "column": 39 } - } - }, - { - "type": "Punctuator", - "value": ")", + }, "range": [ 64, 65 ], - "loc": { - "start": { - "line": 2, - "column": 39 - }, - "end": { - "line": 2, - "column": 40 - } - } + "value": ")" }, { "type": "Punctuator", @@ -345,7 +342,16 @@ "value": "</script>" } ], - "comments": [], + "loc": { + "end": { + "line": 3, + "column": 0 + }, + "start": { + "line": 2, + "column": 0 + } + }, "templateBody": { "type": "VElement", "range": [ @@ -513,19 +519,21 @@ }, "expression": { "type": "Identifier", + "decorators": [], "name": "modelValue", + "optional": false, "range": [ 106, 116 ], "loc": { - "start": { - "line": 6, - "column": 18 - }, "end": { "line": 6, "column": 28 + }, + "start": { + "line": 6, + "column": 18 } } }, @@ -533,19 +541,21 @@ { "id": { "type": "Identifier", + "decorators": [], "name": "modelValue", + "optional": false, "range": [ 106, 116 ], "loc": { - "start": { - "line": 6, - "column": 18 - }, "end": { "line": 6, "column": 28 + }, + "start": { + "line": 6, + "column": 18 } } }, @@ -1052,21 +1062,21 @@ }, { "type": "Identifier", - "value": "modelValue", - "range": [ - 106, - 116 - ], "loc": { - "start": { - "line": 6, - "column": 18 - }, "end": { "line": 6, "column": 28 + }, + "start": { + "line": 6, + "column": 18 } - } + }, + "range": [ + 106, + 116 + ], + "value": "modelValue" }, { "type": "Punctuator", diff --git a/test/fixtures/ast/define-model06-with-ts/scope.json b/test/fixtures/ast/define-model06-with-ts/scope.json index ce177e84..fbcb890d 100644 --- a/test/fixtures/ast/define-model06-with-ts/scope.json +++ b/test/fixtures/ast/define-model06-with-ts/scope.json @@ -2,904 +2,1180 @@ "type": "global", "variables": [ { - "name": "ClassMemberDecoratorContext", + "name": "Intl", "identifiers": [], "defs": [], "references": [] }, { - "name": "DecoratorContext", + "name": "SymbolConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassDecoratorContext", + "name": "Function", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassMethodDecoratorContext", + "name": "Disposable", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassGetterDecoratorContext", + "name": "AsyncDisposable", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassSetterDecoratorContext", + "name": "SuppressedError", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassAccessorDecoratorContext", + "name": "SuppressedErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassAccessorDecoratorTarget", + "name": "DisposableStack", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassAccessorDecoratorResult", + "name": "DisposableStackConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassFieldDecoratorContext", + "name": "AsyncDisposableStack", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassDecorator", + "name": "AsyncDisposableStackConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "PropertyDecorator", + "name": "IteratorObject", "identifiers": [], "defs": [], "references": [] }, { - "name": "MethodDecorator", + "name": "AsyncIteratorObject", "identifiers": [], "defs": [], "references": [] }, { - "name": "ParameterDecorator", + "name": "ReadonlySetLike", "identifiers": [], "defs": [], "references": [] }, { - "name": "Symbol", + "name": "Set", "identifiers": [], "defs": [], "references": [] }, { - "name": "PropertyKey", + "name": "ReadonlySet", "identifiers": [], "defs": [], "references": [] }, { - "name": "PropertyDescriptor", + "name": "ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "PropertyDescriptorMap", + "name": "Iterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "Object", + "name": "IteratorObjectConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ObjectConstructor", + "name": "PromiseConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Function", + "name": "Float16Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "FunctionConstructor", + "name": "Float16ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ThisParameterType", + "name": "Math", "identifiers": [], "defs": [], "references": [] }, { - "name": "OmitThisParameter", + "name": "DataView", "identifiers": [], "defs": [], "references": [] }, { - "name": "CallableFunction", + "name": "ArrayBuffer", "identifiers": [], "defs": [], "references": [] }, { - "name": "NewableFunction", + "name": "ArrayBufferConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "IArguments", + "name": "MapConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "String", + "name": "ObjectConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "StringConstructor", + "name": "PromiseWithResolvers", "identifiers": [], "defs": [], "references": [] }, { - "name": "Boolean", + "name": "RegExp", "identifiers": [], "defs": [], "references": [] }, { - "name": "BooleanConstructor", + "name": "Atomics", "identifiers": [], "defs": [], "references": [] }, { - "name": "Number", + "name": "SharedArrayBuffer", "identifiers": [], "defs": [], "references": [] }, { - "name": "NumberConstructor", + "name": "SharedArrayBufferConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "TemplateStringsArray", + "name": "String", "identifiers": [], "defs": [], "references": [] }, { - "name": "ImportMeta", + "name": "ClassMemberDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "ImportCallOptions", + "name": "DecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "ImportAssertions", + "name": "DecoratorMetadataObject", "identifiers": [], "defs": [], "references": [] }, { - "name": "Math", + "name": "DecoratorMetadata", "identifiers": [], "defs": [], "references": [] }, { - "name": "Date", + "name": "ClassDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "DateConstructor", + "name": "ClassMethodDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "RegExpMatchArray", + "name": "ClassGetterDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "RegExpExecArray", + "name": "ClassSetterDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "RegExp", + "name": "ClassAccessorDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "RegExpConstructor", + "name": "ClassAccessorDecoratorTarget", "identifiers": [], "defs": [], "references": [] }, { - "name": "Error", + "name": "ClassAccessorDecoratorResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "ErrorConstructor", + "name": "ClassFieldDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "EvalError", + "name": "IteratorYieldResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "EvalErrorConstructor", + "name": "IteratorReturnResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "RangeError", + "name": "IteratorResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "RangeErrorConstructor", + "name": "Iterable", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReferenceError", + "name": "IterableIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReferenceErrorConstructor", + "name": "BuiltinIteratorReturn", "identifiers": [], "defs": [], "references": [] }, { - "name": "SyntaxError", + "name": "ArrayIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "SyntaxErrorConstructor", + "name": "Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "TypeError", + "name": "ReadonlyArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "TypeErrorConstructor", + "name": "IArguments", "identifiers": [], "defs": [], "references": [] }, { - "name": "URIError", + "name": "MapIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "URIErrorConstructor", + "name": "Map", "identifiers": [], "defs": [], "references": [] }, { - "name": "JSON", + "name": "ReadonlyMap", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReadonlyArray", + "name": "WeakMap", "identifiers": [], "defs": [], "references": [] }, { - "name": "ConcatArray", + "name": "WeakMapConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Array", + "name": "SetIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayConstructor", + "name": "SetConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "TypedPropertyDescriptor", + "name": "WeakSet", "identifiers": [], "defs": [], "references": [] }, { - "name": "PromiseConstructorLike", + "name": "WeakSetConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "PromiseLike", + "name": "Promise", "identifiers": [], "defs": [], "references": [] }, { - "name": "Promise", + "name": "StringIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "Awaited", + "name": "Int8Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayLike", + "name": "Int8ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Partial", + "name": "Uint8Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Required", + "name": "Uint8ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Readonly", + "name": "Uint8ClampedArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "Pick", + "name": "Uint8ClampedArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Record", + "name": "Int16Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Exclude", + "name": "Int16ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Extract", + "name": "Uint16Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Omit", + "name": "Uint16ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "NonNullable", + "name": "Int32Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Parameters", + "name": "Int32ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ConstructorParameters", + "name": "Uint32Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReturnType", + "name": "Uint32ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "InstanceType", + "name": "Float32Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uppercase", + "name": "Float32ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Lowercase", + "name": "Float64Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Capitalize", + "name": "Float64ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uncapitalize", + "name": "AsyncIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "ThisType", + "name": "AsyncIterable", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayBuffer", + "name": "AsyncIterableIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayBufferTypes", + "name": "BigInt64Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayBufferLike", + "name": "BigUint64Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayBufferConstructor", + "name": "WeakKeyTypes", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayBufferView", + "name": "BigIntToLocaleStringOptions", "identifiers": [], "defs": [], "references": [] }, { - "name": "DataView", + "name": "BigInt", "identifiers": [], "defs": [], "references": [] }, { - "name": "DataViewConstructor", + "name": "BigIntConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int8Array", + "name": "BigInt64ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int8ArrayConstructor", + "name": "BigUint64ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint8Array", + "name": "ErrorOptions", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint8ArrayConstructor", + "name": "Error", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint8ClampedArray", + "name": "ErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint8ClampedArrayConstructor", + "name": "EvalErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int16Array", + "name": "RangeErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int16ArrayConstructor", + "name": "ReferenceErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint16Array", + "name": "SyntaxErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint16ArrayConstructor", + "name": "TypeErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int32Array", + "name": "URIErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int32ArrayConstructor", + "name": "AggregateErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint32Array", + "name": "RegExpMatchArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint32ArrayConstructor", + "name": "RegExpExecArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "Float32Array", + "name": "RegExpIndicesArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "Float32ArrayConstructor", + "name": "AggregateError", "identifiers": [], "defs": [], "references": [] }, { - "name": "Float64Array", + "name": "WeakRef", "identifiers": [], "defs": [], "references": [] }, { - "name": "Float64ArrayConstructor", + "name": "WeakRefConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Intl", + "name": "FinalizationRegistry", "identifiers": [], "defs": [], "references": [] }, { - "name": "Map", + "name": "FinalizationRegistryConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "MapConstructor", + "name": "Date", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReadonlyMap", + "name": "Number", "identifiers": [], "defs": [], "references": [] }, { - "name": "WeakMap", + "name": "PromiseFulfilledResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "WeakMapConstructor", + "name": "PromiseRejectedResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "Set", + "name": "PromiseSettledResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "SetConstructor", + "name": "RegExpStringIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReadonlySet", + "name": "Symbol", "identifiers": [], "defs": [], "references": [] }, { - "name": "WeakSet", + "name": "JSON", "identifiers": [], "defs": [], "references": [] }, { - "name": "WeakSetConstructor", + "name": "GeneratorFunction", "identifiers": [], "defs": [], "references": [] }, { - "name": "SymbolConstructor", + "name": "RegExpConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "IteratorYieldResult", + "name": "FlatArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "IteratorReturnResult", + "name": "AsyncGenerator", "identifiers": [], "defs": [], "references": [] }, { - "name": "IteratorResult", + "name": "AsyncGeneratorFunction", "identifiers": [], "defs": [], "references": [] }, { - "name": "Iterator", + "name": "AsyncGeneratorFunctionConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Iterable", + "name": "DateConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "IterableIterator", + "name": "ArrayBufferTypes", "identifiers": [], "defs": [], "references": [] }, { - "name": "PromiseConstructor", + "name": "PropertyKey", "identifiers": [], "defs": [], "references": [] }, { - "name": "Generator", + "name": "PropertyDescriptor", "identifiers": [], "defs": [], "references": [] }, { - "name": "GeneratorFunction", + "name": "PropertyDescriptorMap", "identifiers": [], "defs": [], "references": [] }, { - "name": "GeneratorFunctionConstructor", + "name": "Object", "identifiers": [], "defs": [], "references": [] }, { - "name": "ProxyHandler", + "name": "FunctionConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ProxyConstructor", + "name": "ThisParameterType", "identifiers": [], "defs": [], "references": [] }, { - "name": "Reflect", + "name": "OmitThisParameter", "identifiers": [], "defs": [], "references": [] }, { - "name": "SharedArrayBuffer", + "name": "CallableFunction", "identifiers": [], "defs": [], "references": [] }, { - "name": "SharedArrayBufferConstructor", + "name": "NewableFunction", "identifiers": [], "defs": [], "references": [] }, { - "name": "Atomics", + "name": "StringConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncIterator", + "name": "Boolean", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncIterable", + "name": "BooleanConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncIterableIterator", + "name": "NumberConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncGenerator", + "name": "TemplateStringsArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncGeneratorFunction", + "name": "ImportMeta", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncGeneratorFunctionConstructor", + "name": "ImportCallOptions", "identifiers": [], "defs": [], "references": [] }, { - "name": "const", + "name": "ImportAssertions", "identifiers": [], "defs": [], "references": [] }, { - "name": "defineModel", + "name": "ImportAttributes", "identifiers": [], "defs": [], - "references": [ - { - "identifier": { - "type": "Identifier", + "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": "defineModel", + "identifiers": [], + "defs": [], + "references": [ + { + "identifier": { + "type": "Identifier", "name": "defineModel", "loc": { - "start": { - "line": 2, - "column": 19 - }, "end": { "line": 2, "column": 30 + }, + "start": { + "line": 2, + "column": 19 } } }, @@ -921,13 +1197,13 @@ "type": "Identifier", "name": "modelValue", "loc": { - "start": { - "line": 2, - "column": 6 - }, "end": { "line": 2, "column": 16 + }, + "start": { + "line": 2, + "column": 6 } } } @@ -938,13 +1214,13 @@ "node": { "type": "VariableDeclarator", "loc": { - "start": { - "line": 2, - "column": 6 - }, "end": { "line": 2, "column": 40 + }, + "start": { + "line": 2, + "column": 6 } } }, @@ -957,13 +1233,13 @@ "type": "Identifier", "name": "modelValue", "loc": { - "start": { - "line": 2, - "column": 6 - }, "end": { "line": 2, "column": 16 + }, + "start": { + "line": 2, + "column": 6 } } }, @@ -972,13 +1248,13 @@ "type": "Identifier", "name": "modelValue", "loc": { - "start": { - "line": 2, - "column": 6 - }, "end": { "line": 2, "column": 16 + }, + "start": { + "line": 2, + "column": 6 } } }, @@ -989,13 +1265,13 @@ "type": "Identifier", "name": "modelValue", "loc": { - "start": { - "line": 2, - "column": 6 - }, "end": { "line": 2, "column": 16 + }, + "start": { + "line": 2, + "column": 6 } } }, @@ -1004,13 +1280,13 @@ "type": "Identifier", "name": "modelValue", "loc": { - "start": { - "line": 2, - "column": 6 - }, "end": { "line": 2, "column": 16 + }, + "start": { + "line": 2, + "column": 6 } } }, @@ -1026,13 +1302,13 @@ "type": "Identifier", "name": "modelValue", "loc": { - "start": { - "line": 2, - "column": 6 - }, "end": { "line": 2, "column": 16 + }, + "start": { + "line": 2, + "column": 6 } } }, @@ -1041,13 +1317,13 @@ "type": "Identifier", "name": "modelValue", "loc": { - "start": { - "line": 2, - "column": 6 - }, "end": { "line": 2, "column": 16 + }, + "start": { + "line": 2, + "column": 6 } } }, @@ -1058,13 +1334,13 @@ "type": "Identifier", "name": "defineModel", "loc": { - "start": { - "line": 2, - "column": 19 - }, "end": { "line": 2, "column": 30 + }, + "start": { + "line": 2, + "column": 19 } } }, @@ -1079,13 +1355,13 @@ "type": "Identifier", "name": "defineModel", "loc": { - "start": { - "line": 2, - "column": 19 - }, "end": { "line": 2, "column": 30 + }, + "start": { + "line": 2, + "column": 19 } } }, diff --git a/test/fixtures/ast/define-model07-with-ts/ast.json b/test/fixtures/ast/define-model07-with-ts/ast.json index 6c22d6dd..8ca432de 100644 --- a/test/fixtures/ast/define-model07-with-ts/ast.json +++ b/test/fixtures/ast/define-model07-with-ts/ast.json @@ -1,108 +1,100 @@ { "type": "Program", + "range": [ + 25, + 84 + ], "body": [ { "type": "VariableDeclaration", "declarations": [ { "type": "VariableDeclarator", + "definite": false, "id": { "type": "Identifier", + "decorators": [], "name": "modelValue", + "optional": false, "range": [ 31, 41 ], "loc": { - "start": { - "line": 2, - "column": 6 - }, "end": { "line": 2, "column": 16 + }, + "start": { + "line": 2, + "column": 6 } } }, "init": { "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "defineModel", - "range": [ - 44, - 55 - ], - "loc": { - "start": { - "line": 2, - "column": 19 - }, - "end": { - "line": 2, - "column": 30 - } - } - }, "arguments": [ { "type": "ObjectExpression", "properties": [ { "type": "Property", + "computed": false, "key": { "type": "Identifier", + "decorators": [], "name": "required", + "optional": false, "range": [ 66, 74 ], "loc": { - "start": { - "line": 2, - "column": 41 - }, "end": { "line": 2, "column": 49 + }, + "start": { + "line": 2, + "column": 41 } } }, + "kind": "init", + "method": false, + "optional": false, + "shorthand": false, "value": { "type": "Literal", - "value": true, "raw": "true", + "value": true, "range": [ 76, 80 ], "loc": { - "start": { - "line": 2, - "column": 51 - }, "end": { "line": 2, "column": 55 + }, + "start": { + "line": 2, + "column": 51 } } }, - "computed": false, - "method": false, - "shorthand": false, - "kind": "init", "range": [ 66, 80 ], "loc": { - "start": { - "line": 2, - "column": 41 - }, "end": { "line": 2, "column": 55 + }, + "start": { + "line": 2, + "column": 41 } } } @@ -112,33 +104,39 @@ 82 ], "loc": { - "start": { - "line": 2, - "column": 39 - }, "end": { "line": 2, "column": 57 + }, + "start": { + "line": 2, + "column": 39 } } } ], - "optional": false, - "range": [ - 44, - 83 - ], - "loc": { - "start": { - "line": 2, - "column": 19 - }, - "end": { - "line": 2, - "column": 58 + "callee": { + "type": "Identifier", + "decorators": [], + "name": "defineModel", + "optional": false, + "range": [ + 44, + 55 + ], + "loc": { + "end": { + "line": 2, + "column": 30 + }, + "start": { + "line": 2, + "column": 19 + } } }, - "typeParameters": { + "optional": false, + "typeArguments": { "type": "TSTypeParameterInstantiation", "range": [ 55, @@ -152,27 +150,41 @@ 62 ], "loc": { - "start": { - "line": 2, - "column": 31 - }, "end": { "line": 2, "column": 37 + }, + "start": { + "line": 2, + "column": 31 } } } ], "loc": { - "start": { - "line": 2, - "column": 30 - }, "end": { "line": 2, "column": 38 + }, + "start": { + "line": 2, + "column": 30 } } + }, + "range": [ + 44, + 83 + ], + "loc": { + "end": { + "line": 2, + "column": 58 + }, + "start": { + "line": 2, + "column": 19 + } } }, "range": [ @@ -180,49 +192,37 @@ 83 ], "loc": { - "start": { - "line": 2, - "column": 6 - }, "end": { "line": 2, "column": 58 + }, + "start": { + "line": 2, + "column": 6 } } } ], + "declare": false, "kind": "const", "range": [ 25, 83 ], "loc": { - "start": { - "line": 2, - "column": 0 - }, "end": { "line": 2, "column": 58 + }, + "start": { + "line": 2, + "column": 0 } } } ], + "comments": [], "sourceType": "module", - "range": [ - 25, - 84 - ], - "loc": { - "start": { - "line": 2, - "column": 0 - }, - "end": { - "line": 3, - "column": 0 - } - }, "tokens": [ { "type": "Punctuator", @@ -244,255 +244,255 @@ }, { "type": "Keyword", - "value": "const", + "loc": { + "end": { + "line": 2, + "column": 5 + }, + "start": { + "line": 2, + "column": 0 + } + }, "range": [ 25, 30 ], + "value": "const" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 2, - "column": 0 + "column": 16 }, - "end": { + "start": { "line": 2, - "column": 5 + "column": 6 } - } - }, - { - "type": "Identifier", - "value": "modelValue", + }, "range": [ 31, 41 ], + "value": "modelValue" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 6 + "column": 18 }, - "end": { + "start": { "line": 2, - "column": 16 + "column": 17 } - } - }, - { - "type": "Punctuator", - "value": "=", + }, "range": [ 42, 43 ], + "value": "=" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 2, - "column": 17 + "column": 30 }, - "end": { + "start": { "line": 2, - "column": 18 + "column": 19 } - } - }, - { - "type": "Identifier", - "value": "defineModel", + }, "range": [ 44, 55 ], + "value": "defineModel" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 19 + "column": 31 }, - "end": { + "start": { "line": 2, "column": 30 } - } - }, - { - "type": "Punctuator", - "value": "<", + }, "range": [ 55, 56 ], + "value": "<" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 2, - "column": 30 + "column": 37 }, - "end": { + "start": { "line": 2, "column": 31 } - } - }, - { - "type": "Identifier", - "value": "string", + }, "range": [ 56, 62 ], + "value": "string" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 31 + "column": 38 }, - "end": { + "start": { "line": 2, "column": 37 } - } - }, - { - "type": "Punctuator", - "value": ">", + }, "range": [ 62, 63 ], + "value": ">" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 37 + "column": 39 }, - "end": { + "start": { "line": 2, "column": 38 } - } - }, - { - "type": "Punctuator", - "value": "(", + }, "range": [ 63, 64 ], + "value": "(" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 38 + "column": 40 }, - "end": { + "start": { "line": 2, "column": 39 } - } - }, - { - "type": "Punctuator", - "value": "{", + }, "range": [ 64, 65 ], + "value": "{" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 2, - "column": 39 + "column": 49 }, - "end": { + "start": { "line": 2, - "column": 40 + "column": 41 } - } - }, - { - "type": "Identifier", - "value": "required", + }, "range": [ 66, 74 ], + "value": "required" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 41 + "column": 50 }, - "end": { + "start": { "line": 2, "column": 49 } - } - }, - { - "type": "Punctuator", - "value": ":", + }, "range": [ 74, 75 ], + "value": ":" + }, + { + "type": "Boolean", "loc": { - "start": { + "end": { "line": 2, - "column": 49 + "column": 55 }, - "end": { + "start": { "line": 2, - "column": 50 + "column": 51 } - } - }, - { - "type": "Boolean", - "value": "true", + }, "range": [ 76, 80 ], + "value": "true" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 51 + "column": 57 }, - "end": { + "start": { "line": 2, - "column": 55 + "column": 56 } - } - }, - { - "type": "Punctuator", - "value": "}", + }, "range": [ 81, 82 ], + "value": "}" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 56 + "column": 58 }, - "end": { + "start": { "line": 2, "column": 57 } - } - }, - { - "type": "Punctuator", - "value": ")", + }, "range": [ 82, 83 ], - "loc": { - "start": { - "line": 2, - "column": 57 - }, - "end": { - "line": 2, - "column": 58 - } - } + "value": ")" }, { "type": "Punctuator", @@ -513,7 +513,16 @@ "value": "</script>" } ], - "comments": [], + "loc": { + "end": { + "line": 3, + "column": 0 + }, + "start": { + "line": 2, + "column": 0 + } + }, "templateBody": { "type": "VElement", "range": [ @@ -681,19 +690,21 @@ }, "expression": { "type": "Identifier", + "decorators": [], "name": "modelValue", + "optional": false, "range": [ 124, 134 ], "loc": { - "start": { - "line": 6, - "column": 18 - }, "end": { "line": 6, "column": 28 + }, + "start": { + "line": 6, + "column": 18 } } }, @@ -701,19 +712,21 @@ { "id": { "type": "Identifier", + "decorators": [], "name": "modelValue", + "optional": false, "range": [ 124, 134 ], "loc": { - "start": { - "line": 6, - "column": 18 - }, "end": { "line": 6, "column": 28 + }, + "start": { + "line": 6, + "column": 18 } } }, @@ -1328,21 +1341,21 @@ }, { "type": "Identifier", - "value": "modelValue", - "range": [ - 124, - 134 - ], "loc": { - "start": { - "line": 6, - "column": 18 - }, "end": { "line": 6, "column": 28 + }, + "start": { + "line": 6, + "column": 18 } - } + }, + "range": [ + 124, + 134 + ], + "value": "modelValue" }, { "type": "Punctuator", diff --git a/test/fixtures/ast/define-model07-with-ts/scope.json b/test/fixtures/ast/define-model07-with-ts/scope.json index d15f8bef..79855963 100644 --- a/test/fixtures/ast/define-model07-with-ts/scope.json +++ b/test/fixtures/ast/define-model07-with-ts/scope.json @@ -2,904 +2,1180 @@ "type": "global", "variables": [ { - "name": "ClassMemberDecoratorContext", + "name": "Intl", "identifiers": [], "defs": [], "references": [] }, { - "name": "DecoratorContext", + "name": "SymbolConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassDecoratorContext", + "name": "Function", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassMethodDecoratorContext", + "name": "Disposable", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassGetterDecoratorContext", + "name": "AsyncDisposable", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassSetterDecoratorContext", + "name": "SuppressedError", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassAccessorDecoratorContext", + "name": "SuppressedErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassAccessorDecoratorTarget", + "name": "DisposableStack", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassAccessorDecoratorResult", + "name": "DisposableStackConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassFieldDecoratorContext", + "name": "AsyncDisposableStack", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassDecorator", + "name": "AsyncDisposableStackConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "PropertyDecorator", + "name": "IteratorObject", "identifiers": [], "defs": [], "references": [] }, { - "name": "MethodDecorator", + "name": "AsyncIteratorObject", "identifiers": [], "defs": [], "references": [] }, { - "name": "ParameterDecorator", + "name": "ReadonlySetLike", "identifiers": [], "defs": [], "references": [] }, { - "name": "Symbol", + "name": "Set", "identifiers": [], "defs": [], "references": [] }, { - "name": "PropertyKey", + "name": "ReadonlySet", "identifiers": [], "defs": [], "references": [] }, { - "name": "PropertyDescriptor", + "name": "ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "PropertyDescriptorMap", + "name": "Iterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "Object", + "name": "IteratorObjectConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ObjectConstructor", + "name": "PromiseConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Function", + "name": "Float16Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "FunctionConstructor", + "name": "Float16ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ThisParameterType", + "name": "Math", "identifiers": [], "defs": [], "references": [] }, { - "name": "OmitThisParameter", + "name": "DataView", "identifiers": [], "defs": [], "references": [] }, { - "name": "CallableFunction", + "name": "ArrayBuffer", "identifiers": [], "defs": [], "references": [] }, { - "name": "NewableFunction", + "name": "ArrayBufferConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "IArguments", + "name": "MapConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "String", + "name": "ObjectConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "StringConstructor", + "name": "PromiseWithResolvers", "identifiers": [], "defs": [], "references": [] }, { - "name": "Boolean", + "name": "RegExp", "identifiers": [], "defs": [], "references": [] }, { - "name": "BooleanConstructor", + "name": "Atomics", "identifiers": [], "defs": [], "references": [] }, { - "name": "Number", + "name": "SharedArrayBuffer", "identifiers": [], "defs": [], "references": [] }, { - "name": "NumberConstructor", + "name": "SharedArrayBufferConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "TemplateStringsArray", + "name": "String", "identifiers": [], "defs": [], "references": [] }, { - "name": "ImportMeta", + "name": "ClassMemberDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "ImportCallOptions", + "name": "DecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "ImportAssertions", + "name": "DecoratorMetadataObject", "identifiers": [], "defs": [], "references": [] }, { - "name": "Math", + "name": "DecoratorMetadata", "identifiers": [], "defs": [], "references": [] }, { - "name": "Date", + "name": "ClassDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "DateConstructor", + "name": "ClassMethodDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "RegExpMatchArray", + "name": "ClassGetterDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "RegExpExecArray", + "name": "ClassSetterDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "RegExp", + "name": "ClassAccessorDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "RegExpConstructor", + "name": "ClassAccessorDecoratorTarget", "identifiers": [], "defs": [], "references": [] }, { - "name": "Error", + "name": "ClassAccessorDecoratorResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "ErrorConstructor", + "name": "ClassFieldDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "EvalError", + "name": "IteratorYieldResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "EvalErrorConstructor", + "name": "IteratorReturnResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "RangeError", + "name": "IteratorResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "RangeErrorConstructor", + "name": "Iterable", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReferenceError", + "name": "IterableIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReferenceErrorConstructor", + "name": "BuiltinIteratorReturn", "identifiers": [], "defs": [], "references": [] }, { - "name": "SyntaxError", + "name": "ArrayIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "SyntaxErrorConstructor", + "name": "Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "TypeError", + "name": "ReadonlyArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "TypeErrorConstructor", + "name": "IArguments", "identifiers": [], "defs": [], "references": [] }, { - "name": "URIError", + "name": "MapIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "URIErrorConstructor", + "name": "Map", "identifiers": [], "defs": [], "references": [] }, { - "name": "JSON", + "name": "ReadonlyMap", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReadonlyArray", + "name": "WeakMap", "identifiers": [], "defs": [], "references": [] }, { - "name": "ConcatArray", + "name": "WeakMapConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Array", + "name": "SetIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayConstructor", + "name": "SetConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "TypedPropertyDescriptor", + "name": "WeakSet", "identifiers": [], "defs": [], "references": [] }, { - "name": "PromiseConstructorLike", + "name": "WeakSetConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "PromiseLike", + "name": "Promise", "identifiers": [], "defs": [], "references": [] }, { - "name": "Promise", + "name": "StringIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "Awaited", + "name": "Int8Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayLike", + "name": "Int8ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Partial", + "name": "Uint8Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Required", + "name": "Uint8ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Readonly", + "name": "Uint8ClampedArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "Pick", + "name": "Uint8ClampedArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Record", + "name": "Int16Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Exclude", + "name": "Int16ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Extract", + "name": "Uint16Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Omit", + "name": "Uint16ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "NonNullable", + "name": "Int32Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Parameters", + "name": "Int32ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ConstructorParameters", + "name": "Uint32Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReturnType", + "name": "Uint32ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "InstanceType", + "name": "Float32Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uppercase", + "name": "Float32ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Lowercase", + "name": "Float64Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Capitalize", + "name": "Float64ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uncapitalize", + "name": "AsyncIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "ThisType", + "name": "AsyncIterable", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayBuffer", + "name": "AsyncIterableIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayBufferTypes", + "name": "BigInt64Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayBufferLike", + "name": "BigUint64Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayBufferConstructor", + "name": "WeakKeyTypes", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayBufferView", + "name": "BigIntToLocaleStringOptions", "identifiers": [], "defs": [], "references": [] }, { - "name": "DataView", + "name": "BigInt", "identifiers": [], "defs": [], "references": [] }, { - "name": "DataViewConstructor", + "name": "BigIntConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int8Array", + "name": "BigInt64ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int8ArrayConstructor", + "name": "BigUint64ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint8Array", + "name": "ErrorOptions", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint8ArrayConstructor", + "name": "Error", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint8ClampedArray", + "name": "ErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint8ClampedArrayConstructor", + "name": "EvalErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int16Array", + "name": "RangeErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int16ArrayConstructor", + "name": "ReferenceErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint16Array", + "name": "SyntaxErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint16ArrayConstructor", + "name": "TypeErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int32Array", + "name": "URIErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int32ArrayConstructor", + "name": "AggregateErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint32Array", + "name": "RegExpMatchArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint32ArrayConstructor", + "name": "RegExpExecArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "Float32Array", + "name": "RegExpIndicesArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "Float32ArrayConstructor", + "name": "AggregateError", "identifiers": [], "defs": [], "references": [] }, { - "name": "Float64Array", + "name": "WeakRef", "identifiers": [], "defs": [], "references": [] }, { - "name": "Float64ArrayConstructor", + "name": "WeakRefConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Intl", + "name": "FinalizationRegistry", "identifiers": [], "defs": [], "references": [] }, { - "name": "Map", + "name": "FinalizationRegistryConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "MapConstructor", + "name": "Date", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReadonlyMap", + "name": "Number", "identifiers": [], "defs": [], "references": [] }, { - "name": "WeakMap", + "name": "PromiseFulfilledResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "WeakMapConstructor", + "name": "PromiseRejectedResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "Set", + "name": "PromiseSettledResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "SetConstructor", + "name": "RegExpStringIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReadonlySet", + "name": "Symbol", "identifiers": [], "defs": [], "references": [] }, { - "name": "WeakSet", + "name": "JSON", "identifiers": [], "defs": [], "references": [] }, { - "name": "WeakSetConstructor", + "name": "GeneratorFunction", "identifiers": [], "defs": [], "references": [] }, { - "name": "SymbolConstructor", + "name": "RegExpConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "IteratorYieldResult", + "name": "FlatArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "IteratorReturnResult", + "name": "AsyncGenerator", "identifiers": [], "defs": [], "references": [] }, { - "name": "IteratorResult", + "name": "AsyncGeneratorFunction", "identifiers": [], "defs": [], "references": [] }, { - "name": "Iterator", + "name": "AsyncGeneratorFunctionConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Iterable", + "name": "DateConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "IterableIterator", + "name": "ArrayBufferTypes", "identifiers": [], "defs": [], "references": [] }, { - "name": "PromiseConstructor", + "name": "PropertyKey", "identifiers": [], "defs": [], "references": [] }, { - "name": "Generator", + "name": "PropertyDescriptor", "identifiers": [], "defs": [], "references": [] }, { - "name": "GeneratorFunction", + "name": "PropertyDescriptorMap", "identifiers": [], "defs": [], "references": [] }, { - "name": "GeneratorFunctionConstructor", + "name": "Object", "identifiers": [], "defs": [], "references": [] }, { - "name": "ProxyHandler", + "name": "FunctionConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ProxyConstructor", + "name": "ThisParameterType", "identifiers": [], "defs": [], "references": [] }, { - "name": "Reflect", + "name": "OmitThisParameter", "identifiers": [], "defs": [], "references": [] }, { - "name": "SharedArrayBuffer", + "name": "CallableFunction", "identifiers": [], "defs": [], "references": [] }, { - "name": "SharedArrayBufferConstructor", + "name": "NewableFunction", "identifiers": [], "defs": [], "references": [] }, { - "name": "Atomics", + "name": "StringConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncIterator", + "name": "Boolean", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncIterable", + "name": "BooleanConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncIterableIterator", + "name": "NumberConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncGenerator", + "name": "TemplateStringsArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncGeneratorFunction", + "name": "ImportMeta", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncGeneratorFunctionConstructor", + "name": "ImportCallOptions", "identifiers": [], "defs": [], "references": [] }, { - "name": "const", + "name": "ImportAssertions", "identifiers": [], "defs": [], "references": [] }, { - "name": "defineModel", + "name": "ImportAttributes", "identifiers": [], "defs": [], - "references": [ - { - "identifier": { - "type": "Identifier", + "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": "defineModel", + "identifiers": [], + "defs": [], + "references": [ + { + "identifier": { + "type": "Identifier", "name": "defineModel", "loc": { - "start": { - "line": 2, - "column": 19 - }, "end": { "line": 2, "column": 30 + }, + "start": { + "line": 2, + "column": 19 } } }, @@ -921,13 +1197,13 @@ "type": "Identifier", "name": "modelValue", "loc": { - "start": { - "line": 2, - "column": 6 - }, "end": { "line": 2, "column": 16 + }, + "start": { + "line": 2, + "column": 6 } } } @@ -938,13 +1214,13 @@ "node": { "type": "VariableDeclarator", "loc": { - "start": { - "line": 2, - "column": 6 - }, "end": { "line": 2, "column": 58 + }, + "start": { + "line": 2, + "column": 6 } } }, @@ -957,13 +1233,13 @@ "type": "Identifier", "name": "modelValue", "loc": { - "start": { - "line": 2, - "column": 6 - }, "end": { "line": 2, "column": 16 + }, + "start": { + "line": 2, + "column": 6 } } }, @@ -972,13 +1248,13 @@ "type": "Identifier", "name": "modelValue", "loc": { - "start": { - "line": 2, - "column": 6 - }, "end": { "line": 2, "column": 16 + }, + "start": { + "line": 2, + "column": 6 } } }, @@ -989,13 +1265,13 @@ "type": "Identifier", "name": "modelValue", "loc": { - "start": { - "line": 2, - "column": 6 - }, "end": { "line": 2, "column": 16 + }, + "start": { + "line": 2, + "column": 6 } } }, @@ -1004,13 +1280,13 @@ "type": "Identifier", "name": "modelValue", "loc": { - "start": { - "line": 2, - "column": 6 - }, "end": { "line": 2, "column": 16 + }, + "start": { + "line": 2, + "column": 6 } } }, @@ -1026,13 +1302,13 @@ "type": "Identifier", "name": "modelValue", "loc": { - "start": { - "line": 2, - "column": 6 - }, "end": { "line": 2, "column": 16 + }, + "start": { + "line": 2, + "column": 6 } } }, @@ -1041,13 +1317,13 @@ "type": "Identifier", "name": "modelValue", "loc": { - "start": { - "line": 2, - "column": 6 - }, "end": { "line": 2, "column": 16 + }, + "start": { + "line": 2, + "column": 6 } } }, @@ -1058,13 +1334,13 @@ "type": "Identifier", "name": "defineModel", "loc": { - "start": { - "line": 2, - "column": 19 - }, "end": { "line": 2, "column": 30 + }, + "start": { + "line": 2, + "column": 19 } } }, @@ -1079,13 +1355,13 @@ "type": "Identifier", "name": "defineModel", "loc": { - "start": { - "line": 2, - "column": 19 - }, "end": { "line": 2, "column": 30 + }, + "start": { + "line": 2, + "column": 19 } } }, diff --git a/test/fixtures/ast/define-model08-with-ts-and-modifiers/ast.json b/test/fixtures/ast/define-model08-with-ts-and-modifiers/ast.json index b8d7ba48..ffde6fc7 100644 --- a/test/fixtures/ast/define-model08-with-ts-and-modifiers/ast.json +++ b/test/fixtures/ast/define-model08-with-ts-and-modifiers/ast.json @@ -1,176 +1,123 @@ { "type": "Program", + "range": [ + 25, + 198 + ], "body": [ { "type": "VariableDeclaration", "declarations": [ { "type": "VariableDeclarator", + "definite": false, "id": { "type": "ArrayPattern", + "decorators": [], "elements": [ { "type": "Identifier", + "decorators": [], "name": "modelValue", + "optional": false, "range": [ 32, 42 ], "loc": { - "start": { - "line": 2, - "column": 7 - }, "end": { "line": 2, "column": 17 + }, + "start": { + "line": 2, + "column": 7 } } }, { "type": "Identifier", + "decorators": [], "name": "modifiers", + "optional": false, "range": [ 44, 53 ], "loc": { - "start": { - "line": 2, - "column": 19 - }, "end": { "line": 2, "column": 28 + }, + "start": { + "line": 2, + "column": 19 } } } ], + "optional": false, "range": [ 31, 54 ], "loc": { - "start": { - "line": 2, - "column": 6 - }, "end": { "line": 2, "column": 29 + }, + "start": { + "line": 2, + "column": 6 } } }, "init": { "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "defineModel", - "range": [ - 57, - 68 - ], - "loc": { - "start": { - "line": 2, - "column": 32 - }, - "end": { - "line": 2, - "column": 43 - } - } - }, "arguments": [ { "type": "ObjectExpression", "properties": [ { "type": "Property", + "computed": false, "key": { "type": "Identifier", + "decorators": [], "name": "set", + "optional": false, "range": [ 103, 106 ], "loc": { - "start": { - "line": 3, - "column": 2 - }, "end": { "line": 3, "column": 5 + }, + "start": { + "line": 3, + "column": 2 } } }, + "kind": "init", + "method": true, + "optional": false, + "shorthand": false, "value": { "type": "FunctionExpression", - "id": null, - "generator": false, - "expression": false, + "range": [ + 106, + 194 + ], "async": false, "body": { "type": "BlockStatement", "body": [ { "type": "IfStatement", - "test": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "modifiers", - "range": [ - 124, - 133 - ], - "loc": { - "start": { - "line": 4, - "column": 8 - }, - "end": { - "line": 4, - "column": 17 - } - } - }, - "property": { - "type": "Identifier", - "name": "trim", - "range": [ - 134, - 138 - ], - "loc": { - "start": { - "line": 4, - "column": 18 - }, - "end": { - "line": 4, - "column": 22 - } - } - }, - "computed": false, - "optional": false, - "range": [ - 124, - 138 - ], - "loc": { - "start": { - "line": 4, - "column": 8 - }, - "end": { - "line": 4, - "column": 22 - } - } - }, + "alternate": null, "consequent": { "type": "BlockStatement", "body": [ @@ -178,75 +125,79 @@ "type": "ReturnStatement", "argument": { "type": "CallExpression", + "arguments": [], "callee": { "type": "MemberExpression", + "computed": false, "object": { "type": "Identifier", + "decorators": [], "name": "value", + "optional": false, "range": [ 155, 160 ], "loc": { - "start": { - "line": 5, - "column": 13 - }, "end": { "line": 5, "column": 18 + }, + "start": { + "line": 5, + "column": 13 } } }, + "optional": false, "property": { "type": "Identifier", + "decorators": [], "name": "trim", + "optional": false, "range": [ 161, 165 ], "loc": { - "start": { - "line": 5, - "column": 19 - }, "end": { "line": 5, "column": 23 + }, + "start": { + "line": 5, + "column": 19 } } }, - "computed": false, - "optional": false, "range": [ 155, 165 ], "loc": { - "start": { - "line": 5, - "column": 13 - }, "end": { "line": 5, "column": 23 + }, + "start": { + "line": 5, + "column": 13 } } }, - "arguments": [], "optional": false, "range": [ 155, 167 ], "loc": { - "start": { - "line": 5, - "column": 13 - }, "end": { "line": 5, "column": 25 + }, + "start": { + "line": 5, + "column": 13 } } }, @@ -255,13 +206,13 @@ 167 ], "loc": { - "start": { - "line": 5, - "column": 6 - }, "end": { "line": 5, "column": 25 + }, + "start": { + "line": 5, + "column": 6 } } } @@ -271,29 +222,87 @@ 173 ], "loc": { + "end": { + "line": 6, + "column": 5 + }, "start": { "line": 4, "column": 24 - }, + } + } + }, + "test": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "decorators": [], + "name": "modifiers", + "optional": false, + "range": [ + 124, + 133 + ], + "loc": { + "end": { + "line": 4, + "column": 17 + }, + "start": { + "line": 4, + "column": 8 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "decorators": [], + "name": "trim", + "optional": false, + "range": [ + 134, + 138 + ], + "loc": { + "end": { + "line": 4, + "column": 22 + }, + "start": { + "line": 4, + "column": 18 + } + } + }, + "range": [ + 124, + 138 + ], + "loc": { "end": { - "line": 6, - "column": 5 + "line": 4, + "column": 22 + }, + "start": { + "line": 4, + "column": 8 } } }, - "alternate": null, "range": [ 120, 173 ], "loc": { - "start": { - "line": 4, - "column": 4 - }, "end": { "line": 6, "column": 5 + }, + "start": { + "line": 4, + "column": 4 } } }, @@ -301,19 +310,21 @@ "type": "ReturnStatement", "argument": { "type": "Identifier", + "decorators": [], "name": "value", + "optional": false, "range": [ 185, 190 ], "loc": { - "start": { - "line": 7, - "column": 11 - }, "end": { "line": 7, "column": 16 + }, + "start": { + "line": 7, + "column": 11 } } }, @@ -322,13 +333,13 @@ 190 ], "loc": { - "start": { - "line": 7, - "column": 4 - }, "end": { "line": 7, "column": 16 + }, + "start": { + "line": 7, + "column": 4 } } } @@ -338,67 +349,65 @@ 194 ], "loc": { - "start": { - "line": 3, - "column": 13 - }, "end": { "line": 8, "column": 3 + }, + "start": { + "line": 3, + "column": 13 } } }, - "range": [ - 106, - 194 - ], + "declare": false, + "expression": false, + "generator": false, + "id": null, "params": [ { "type": "Identifier", + "decorators": [], "name": "value", + "optional": false, "range": [ 107, 112 ], "loc": { - "start": { - "line": 3, - "column": 6 - }, "end": { "line": 3, "column": 11 + }, + "start": { + "line": 3, + "column": 6 } } } ], "loc": { - "start": { - "line": 3, - "column": 5 - }, "end": { "line": 8, "column": 3 + }, + "start": { + "line": 3, + "column": 5 } } }, - "computed": false, - "method": true, - "shorthand": false, - "kind": "init", "range": [ 103, 194 ], "loc": { - "start": { - "line": 3, - "column": 2 - }, "end": { "line": 8, "column": 3 + }, + "start": { + "line": 3, + "column": 2 } } } @@ -408,33 +417,39 @@ 196 ], "loc": { - "start": { - "line": 2, - "column": 74 - }, "end": { "line": 9, "column": 1 + }, + "start": { + "line": 2, + "column": 74 } } } ], - "optional": false, - "range": [ - 57, - 197 - ], - "loc": { - "start": { - "line": 2, - "column": 32 - }, - "end": { - "line": 9, - "column": 2 + "callee": { + "type": "Identifier", + "decorators": [], + "name": "defineModel", + "optional": false, + "range": [ + 57, + 68 + ], + "loc": { + "end": { + "line": 2, + "column": 43 + }, + "start": { + "line": 2, + "column": 32 + } } }, - "typeParameters": { + "optional": false, + "typeArguments": { "type": "TSTypeParameterInstantiation", "range": [ 68, @@ -448,13 +463,13 @@ 75 ], "loc": { - "start": { - "line": 2, - "column": 44 - }, "end": { "line": 2, "column": 50 + }, + "start": { + "line": 2, + "column": 44 } } }, @@ -465,20 +480,20 @@ "type": "TSLiteralType", "literal": { "type": "Literal", - "value": "trim", "raw": "'trim'", + "value": "trim", "range": [ 77, 83 ], "loc": { - "start": { - "line": 2, - "column": 52 - }, "end": { "line": 2, "column": 58 + }, + "start": { + "line": 2, + "column": 52 } } }, @@ -487,13 +502,13 @@ 83 ], "loc": { - "start": { - "line": 2, - "column": 52 - }, "end": { "line": 2, "column": 58 + }, + "start": { + "line": 2, + "column": 52 } } }, @@ -501,20 +516,20 @@ "type": "TSLiteralType", "literal": { "type": "Literal", - "value": "uppercase", "raw": "'uppercase'", + "value": "uppercase", "range": [ 86, 97 ], "loc": { - "start": { - "line": 2, - "column": 61 - }, "end": { "line": 2, "column": 72 + }, + "start": { + "line": 2, + "column": 61 } } }, @@ -523,13 +538,13 @@ 97 ], "loc": { - "start": { - "line": 2, - "column": 61 - }, "end": { "line": 2, "column": 72 + }, + "start": { + "line": 2, + "column": 61 } } } @@ -539,27 +554,41 @@ 97 ], "loc": { - "start": { - "line": 2, - "column": 52 - }, "end": { "line": 2, "column": 72 + }, + "start": { + "line": 2, + "column": 52 } } } ], "loc": { - "start": { - "line": 2, - "column": 43 - }, "end": { "line": 2, "column": 73 + }, + "start": { + "line": 2, + "column": 43 } } + }, + "range": [ + 57, + 197 + ], + "loc": { + "end": { + "line": 9, + "column": 2 + }, + "start": { + "line": 2, + "column": 32 + } } }, "range": [ @@ -567,49 +596,37 @@ 197 ], "loc": { - "start": { - "line": 2, - "column": 6 - }, "end": { "line": 9, "column": 2 + }, + "start": { + "line": 2, + "column": 6 } } } ], + "declare": false, "kind": "const", "range": [ 25, 197 ], "loc": { - "start": { - "line": 2, - "column": 0 - }, "end": { "line": 9, "column": 2 + }, + "start": { + "line": 2, + "column": 0 } } } ], + "comments": [], "sourceType": "module", - "range": [ - 25, - 198 - ], - "loc": { - "start": { - "line": 2, - "column": 0 - }, - "end": { - "line": 10, - "column": 0 - } - }, "tokens": [ { "type": "Punctuator", @@ -631,741 +648,741 @@ }, { "type": "Keyword", - "value": "const", + "loc": { + "end": { + "line": 2, + "column": 5 + }, + "start": { + "line": 2, + "column": 0 + } + }, "range": [ 25, 30 ], + "value": "const" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 0 + "column": 7 }, - "end": { + "start": { "line": 2, - "column": 5 + "column": 6 } - } - }, - { - "type": "Punctuator", - "value": "[", + }, "range": [ 31, 32 ], + "value": "[" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 2, - "column": 6 + "column": 17 }, - "end": { + "start": { "line": 2, "column": 7 } - } - }, - { - "type": "Identifier", - "value": "modelValue", + }, "range": [ 32, 42 ], + "value": "modelValue" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 7 + "column": 18 }, - "end": { + "start": { "line": 2, "column": 17 } - } - }, - { - "type": "Punctuator", - "value": ",", + }, "range": [ 42, 43 ], + "value": "," + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 2, - "column": 17 + "column": 28 }, - "end": { + "start": { "line": 2, - "column": 18 + "column": 19 } - } - }, - { - "type": "Identifier", - "value": "modifiers", + }, "range": [ 44, 53 ], - "loc": { - "start": { + "value": "modifiers" + }, + { + "type": "Punctuator", + "loc": { + "end": { "line": 2, - "column": 19 + "column": 29 }, - "end": { + "start": { "line": 2, "column": 28 } - } - }, - { - "type": "Punctuator", - "value": "]", + }, "range": [ 53, 54 ], + "value": "]" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 28 + "column": 31 }, - "end": { + "start": { "line": 2, - "column": 29 + "column": 30 } - } - }, - { - "type": "Punctuator", - "value": "=", + }, "range": [ 55, 56 ], + "value": "=" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 2, - "column": 30 + "column": 43 }, - "end": { + "start": { "line": 2, - "column": 31 + "column": 32 } - } - }, - { - "type": "Identifier", - "value": "defineModel", + }, "range": [ 57, 68 ], + "value": "defineModel" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 32 + "column": 44 }, - "end": { + "start": { "line": 2, "column": 43 } - } - }, - { - "type": "Punctuator", - "value": "<", + }, "range": [ 68, 69 ], + "value": "<" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 2, - "column": 43 + "column": 50 }, - "end": { + "start": { "line": 2, "column": 44 } - } - }, - { - "type": "Identifier", - "value": "string", + }, "range": [ 69, 75 ], + "value": "string" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 44 + "column": 51 }, - "end": { + "start": { "line": 2, "column": 50 } - } - }, - { - "type": "Punctuator", - "value": ",", + }, "range": [ 75, 76 ], + "value": "," + }, + { + "type": "String", "loc": { - "start": { + "end": { "line": 2, - "column": 50 + "column": 58 }, - "end": { + "start": { "line": 2, - "column": 51 + "column": 52 } - } - }, - { - "type": "String", - "value": "'trim'", + }, "range": [ 77, 83 ], + "value": "'trim'" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 52 + "column": 60 }, - "end": { + "start": { "line": 2, - "column": 58 + "column": 59 } - } - }, - { - "type": "Punctuator", - "value": "|", + }, "range": [ 84, 85 ], + "value": "|" + }, + { + "type": "String", "loc": { - "start": { + "end": { "line": 2, - "column": 59 + "column": 72 }, - "end": { + "start": { "line": 2, - "column": 60 + "column": 61 } - } - }, - { - "type": "String", - "value": "'uppercase'", + }, "range": [ 86, 97 ], + "value": "'uppercase'" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 61 + "column": 73 }, - "end": { + "start": { "line": 2, "column": 72 } - } - }, - { - "type": "Punctuator", - "value": ">", + }, "range": [ 97, 98 ], + "value": ">" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 72 + "column": 74 }, - "end": { + "start": { "line": 2, "column": 73 } - } - }, - { - "type": "Punctuator", - "value": "(", + }, "range": [ 98, 99 ], + "value": "(" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 73 + "column": 75 }, - "end": { + "start": { "line": 2, "column": 74 } - } - }, - { - "type": "Punctuator", - "value": "{", + }, "range": [ 99, 100 ], - "loc": { - "start": { - "line": 2, - "column": 74 - }, - "end": { - "line": 2, - "column": 75 - } - } + "value": "{" }, { "type": "Identifier", - "value": "set", + "loc": { + "end": { + "line": 3, + "column": 5 + }, + "start": { + "line": 3, + "column": 2 + } + }, "range": [ 103, 106 ], + "value": "set" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 3, - "column": 2 + "column": 6 }, - "end": { + "start": { "line": 3, "column": 5 } - } - }, - { - "type": "Punctuator", - "value": "(", + }, "range": [ 106, 107 ], + "value": "(" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 3, - "column": 5 + "column": 11 }, - "end": { + "start": { "line": 3, "column": 6 } - } - }, - { - "type": "Identifier", - "value": "value", + }, "range": [ 107, 112 ], + "value": "value" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 3, - "column": 6 + "column": 12 }, - "end": { + "start": { "line": 3, "column": 11 } - } - }, - { - "type": "Punctuator", - "value": ")", + }, "range": [ 112, 113 ], + "value": ")" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 3, - "column": 11 + "column": 14 }, - "end": { + "start": { "line": 3, - "column": 12 + "column": 13 } - } - }, - { - "type": "Punctuator", - "value": "{", + }, "range": [ 114, 115 ], - "loc": { - "start": { - "line": 3, - "column": 13 - }, - "end": { - "line": 3, - "column": 14 - } - } + "value": "{" }, { "type": "Keyword", - "value": "if", + "loc": { + "end": { + "line": 4, + "column": 6 + }, + "start": { + "line": 4, + "column": 4 + } + }, "range": [ 120, 122 ], + "value": "if" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 4, - "column": 4 + "column": 8 }, - "end": { + "start": { "line": 4, - "column": 6 + "column": 7 } - } - }, - { - "type": "Punctuator", - "value": "(", + }, "range": [ 123, 124 ], + "value": "(" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 4, - "column": 7 + "column": 17 }, - "end": { + "start": { "line": 4, "column": 8 } - } - }, - { - "type": "Identifier", - "value": "modifiers", + }, "range": [ 124, 133 ], + "value": "modifiers" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 4, - "column": 8 + "column": 18 }, - "end": { + "start": { "line": 4, "column": 17 } - } - }, - { - "type": "Punctuator", - "value": ".", + }, "range": [ 133, 134 ], + "value": "." + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 4, - "column": 17 + "column": 22 }, - "end": { + "start": { "line": 4, "column": 18 } - } - }, - { - "type": "Identifier", - "value": "trim", + }, "range": [ 134, 138 ], + "value": "trim" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 4, - "column": 18 + "column": 23 }, - "end": { + "start": { "line": 4, "column": 22 } - } - }, - { - "type": "Punctuator", - "value": ")", + }, "range": [ 138, 139 ], - "loc": { - "start": { - "line": 4, - "column": 22 - }, - "end": { - "line": 4, - "column": 23 - } - } + "value": ")" }, - { - "type": "Punctuator", - "value": "{", - "range": [ - 140, - 141 - ], - "loc": { - "start": { - "line": 4, - "column": 24 - }, + { + "type": "Punctuator", + "loc": { "end": { "line": 4, "column": 25 + }, + "start": { + "line": 4, + "column": 24 } - } + }, + "range": [ + 140, + 141 + ], + "value": "{" }, { "type": "Keyword", - "value": "return", + "loc": { + "end": { + "line": 5, + "column": 12 + }, + "start": { + "line": 5, + "column": 6 + } + }, "range": [ 148, 154 ], + "value": "return" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 5, - "column": 6 + "column": 18 }, - "end": { + "start": { "line": 5, - "column": 12 + "column": 13 } - } - }, - { - "type": "Identifier", - "value": "value", + }, "range": [ 155, 160 ], + "value": "value" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 13 + "column": 19 }, - "end": { + "start": { "line": 5, "column": 18 } - } - }, - { - "type": "Punctuator", - "value": ".", + }, "range": [ 160, 161 ], + "value": "." + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 5, - "column": 18 + "column": 23 }, - "end": { + "start": { "line": 5, "column": 19 } - } - }, - { - "type": "Identifier", - "value": "trim", + }, "range": [ 161, 165 ], + "value": "trim" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 19 + "column": 24 }, - "end": { + "start": { "line": 5, "column": 23 } - } - }, - { - "type": "Punctuator", - "value": "(", + }, "range": [ 165, 166 ], + "value": "(" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 23 + "column": 25 }, - "end": { + "start": { "line": 5, "column": 24 } - } - }, - { - "type": "Punctuator", - "value": ")", + }, "range": [ 166, 167 ], - "loc": { - "start": { - "line": 5, - "column": 24 - }, - "end": { - "line": 5, - "column": 25 - } - } + "value": ")" }, { "type": "Punctuator", - "value": "}", - "range": [ - 172, - 173 - ], "loc": { - "start": { - "line": 6, - "column": 4 - }, "end": { "line": 6, "column": 5 + }, + "start": { + "line": 6, + "column": 4 } - } + }, + "range": [ + 172, + 173 + ], + "value": "}" }, { "type": "Keyword", - "value": "return", - "range": [ - 178, - 184 - ], "loc": { - "start": { - "line": 7, - "column": 4 - }, "end": { "line": 7, "column": 10 + }, + "start": { + "line": 7, + "column": 4 } - } + }, + "range": [ + 178, + 184 + ], + "value": "return" }, { "type": "Identifier", - "value": "value", - "range": [ - 185, - 190 - ], "loc": { - "start": { - "line": 7, - "column": 11 - }, "end": { "line": 7, "column": 16 + }, + "start": { + "line": 7, + "column": 11 } - } + }, + "range": [ + 185, + 190 + ], + "value": "value" }, { "type": "Punctuator", - "value": "}", - "range": [ - 193, - 194 - ], "loc": { - "start": { - "line": 8, - "column": 2 - }, "end": { "line": 8, "column": 3 + }, + "start": { + "line": 8, + "column": 2 } - } + }, + "range": [ + 193, + 194 + ], + "value": "}" }, { "type": "Punctuator", - "value": "}", + "loc": { + "end": { + "line": 9, + "column": 1 + }, + "start": { + "line": 9, + "column": 0 + } + }, "range": [ 195, 196 ], + "value": "}" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 9, - "column": 0 + "column": 2 }, - "end": { + "start": { "line": 9, "column": 1 } - } - }, - { - "type": "Punctuator", - "value": ")", + }, "range": [ 196, 197 ], - "loc": { - "start": { - "line": 9, - "column": 1 - }, - "end": { - "line": 9, - "column": 2 - } - } + "value": ")" }, { "type": "Punctuator", @@ -1386,7 +1403,16 @@ "value": "</script>" } ], - "comments": [], + "loc": { + "end": { + "line": 10, + "column": 0 + }, + "start": { + "line": 2, + "column": 0 + } + }, "templateBody": { "type": "VElement", "range": [ @@ -1554,19 +1580,21 @@ }, "expression": { "type": "Identifier", + "decorators": [], "name": "modelValue", + "optional": false, "range": [ 238, 248 ], "loc": { - "start": { - "line": 13, - "column": 18 - }, "end": { "line": 13, "column": 28 + }, + "start": { + "line": 13, + "column": 18 } } }, @@ -1574,19 +1602,21 @@ { "id": { "type": "Identifier", + "decorators": [], "name": "modelValue", + "optional": false, "range": [ 238, 248 ], "loc": { - "start": { - "line": 13, - "column": 18 - }, "end": { "line": 13, "column": 28 + }, + "start": { + "line": 13, + "column": 18 } } }, @@ -2669,21 +2699,21 @@ }, { "type": "Identifier", - "value": "modelValue", - "range": [ - 238, - 248 - ], "loc": { - "start": { - "line": 13, - "column": 18 - }, "end": { "line": 13, "column": 28 + }, + "start": { + "line": 13, + "column": 18 } - } + }, + "range": [ + 238, + 248 + ], + "value": "modelValue" }, { "type": "Punctuator", diff --git a/test/fixtures/ast/define-model08-with-ts-and-modifiers/scope.json b/test/fixtures/ast/define-model08-with-ts-and-modifiers/scope.json index 43e387c4..501546f5 100644 --- a/test/fixtures/ast/define-model08-with-ts-and-modifiers/scope.json +++ b/test/fixtures/ast/define-model08-with-ts-and-modifiers/scope.json @@ -2,904 +2,1180 @@ "type": "global", "variables": [ { - "name": "ClassMemberDecoratorContext", + "name": "Intl", "identifiers": [], "defs": [], "references": [] }, { - "name": "DecoratorContext", + "name": "SymbolConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassDecoratorContext", + "name": "Function", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassMethodDecoratorContext", + "name": "Disposable", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassGetterDecoratorContext", + "name": "AsyncDisposable", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassSetterDecoratorContext", + "name": "SuppressedError", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassAccessorDecoratorContext", + "name": "SuppressedErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassAccessorDecoratorTarget", + "name": "DisposableStack", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassAccessorDecoratorResult", + "name": "DisposableStackConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassFieldDecoratorContext", + "name": "AsyncDisposableStack", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassDecorator", + "name": "AsyncDisposableStackConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "PropertyDecorator", + "name": "IteratorObject", "identifiers": [], "defs": [], "references": [] }, { - "name": "MethodDecorator", + "name": "AsyncIteratorObject", "identifiers": [], "defs": [], "references": [] }, { - "name": "ParameterDecorator", + "name": "ReadonlySetLike", "identifiers": [], "defs": [], "references": [] }, { - "name": "Symbol", + "name": "Set", "identifiers": [], "defs": [], "references": [] }, { - "name": "PropertyKey", + "name": "ReadonlySet", "identifiers": [], "defs": [], "references": [] }, { - "name": "PropertyDescriptor", + "name": "ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "PropertyDescriptorMap", + "name": "Iterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "Object", + "name": "IteratorObjectConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ObjectConstructor", + "name": "PromiseConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Function", + "name": "Float16Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "FunctionConstructor", + "name": "Float16ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ThisParameterType", + "name": "Math", "identifiers": [], "defs": [], "references": [] }, { - "name": "OmitThisParameter", + "name": "DataView", "identifiers": [], "defs": [], "references": [] }, { - "name": "CallableFunction", + "name": "ArrayBuffer", "identifiers": [], "defs": [], "references": [] }, { - "name": "NewableFunction", + "name": "ArrayBufferConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "IArguments", + "name": "MapConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "String", + "name": "ObjectConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "StringConstructor", + "name": "PromiseWithResolvers", "identifiers": [], "defs": [], "references": [] }, { - "name": "Boolean", + "name": "RegExp", "identifiers": [], "defs": [], "references": [] }, { - "name": "BooleanConstructor", + "name": "Atomics", "identifiers": [], "defs": [], "references": [] }, { - "name": "Number", + "name": "SharedArrayBuffer", "identifiers": [], "defs": [], "references": [] }, { - "name": "NumberConstructor", + "name": "SharedArrayBufferConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "TemplateStringsArray", + "name": "String", "identifiers": [], "defs": [], "references": [] }, { - "name": "ImportMeta", + "name": "ClassMemberDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "ImportCallOptions", + "name": "DecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "ImportAssertions", + "name": "DecoratorMetadataObject", "identifiers": [], "defs": [], "references": [] }, { - "name": "Math", + "name": "DecoratorMetadata", "identifiers": [], "defs": [], "references": [] }, { - "name": "Date", + "name": "ClassDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "DateConstructor", + "name": "ClassMethodDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "RegExpMatchArray", + "name": "ClassGetterDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "RegExpExecArray", + "name": "ClassSetterDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "RegExp", + "name": "ClassAccessorDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "RegExpConstructor", + "name": "ClassAccessorDecoratorTarget", "identifiers": [], "defs": [], "references": [] }, { - "name": "Error", + "name": "ClassAccessorDecoratorResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "ErrorConstructor", + "name": "ClassFieldDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "EvalError", + "name": "IteratorYieldResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "EvalErrorConstructor", + "name": "IteratorReturnResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "RangeError", + "name": "IteratorResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "RangeErrorConstructor", + "name": "Iterable", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReferenceError", + "name": "IterableIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReferenceErrorConstructor", + "name": "BuiltinIteratorReturn", "identifiers": [], "defs": [], "references": [] }, { - "name": "SyntaxError", + "name": "ArrayIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "SyntaxErrorConstructor", + "name": "Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "TypeError", + "name": "ReadonlyArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "TypeErrorConstructor", + "name": "IArguments", "identifiers": [], "defs": [], "references": [] }, { - "name": "URIError", + "name": "MapIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "URIErrorConstructor", + "name": "Map", "identifiers": [], "defs": [], "references": [] }, { - "name": "JSON", + "name": "ReadonlyMap", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReadonlyArray", + "name": "WeakMap", "identifiers": [], "defs": [], "references": [] }, { - "name": "ConcatArray", + "name": "WeakMapConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Array", + "name": "SetIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayConstructor", + "name": "SetConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "TypedPropertyDescriptor", + "name": "WeakSet", "identifiers": [], "defs": [], "references": [] }, { - "name": "PromiseConstructorLike", + "name": "WeakSetConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "PromiseLike", + "name": "Promise", "identifiers": [], "defs": [], "references": [] }, { - "name": "Promise", + "name": "StringIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "Awaited", + "name": "Int8Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayLike", + "name": "Int8ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Partial", + "name": "Uint8Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Required", + "name": "Uint8ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Readonly", + "name": "Uint8ClampedArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "Pick", + "name": "Uint8ClampedArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Record", + "name": "Int16Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Exclude", + "name": "Int16ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Extract", + "name": "Uint16Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Omit", + "name": "Uint16ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "NonNullable", + "name": "Int32Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Parameters", + "name": "Int32ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ConstructorParameters", + "name": "Uint32Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReturnType", + "name": "Uint32ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "InstanceType", + "name": "Float32Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uppercase", + "name": "Float32ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Lowercase", + "name": "Float64Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Capitalize", + "name": "Float64ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uncapitalize", + "name": "AsyncIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "ThisType", + "name": "AsyncIterable", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayBuffer", + "name": "AsyncIterableIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayBufferTypes", + "name": "BigInt64Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayBufferLike", + "name": "BigUint64Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayBufferConstructor", + "name": "WeakKeyTypes", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayBufferView", + "name": "BigIntToLocaleStringOptions", "identifiers": [], "defs": [], "references": [] }, { - "name": "DataView", + "name": "BigInt", "identifiers": [], "defs": [], "references": [] }, { - "name": "DataViewConstructor", + "name": "BigIntConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int8Array", + "name": "BigInt64ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int8ArrayConstructor", + "name": "BigUint64ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint8Array", + "name": "ErrorOptions", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint8ArrayConstructor", + "name": "Error", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint8ClampedArray", + "name": "ErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint8ClampedArrayConstructor", + "name": "EvalErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int16Array", + "name": "RangeErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int16ArrayConstructor", + "name": "ReferenceErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint16Array", + "name": "SyntaxErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint16ArrayConstructor", + "name": "TypeErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int32Array", + "name": "URIErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int32ArrayConstructor", + "name": "AggregateErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint32Array", + "name": "RegExpMatchArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint32ArrayConstructor", + "name": "RegExpExecArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "Float32Array", + "name": "RegExpIndicesArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "Float32ArrayConstructor", + "name": "AggregateError", "identifiers": [], "defs": [], "references": [] }, { - "name": "Float64Array", + "name": "WeakRef", "identifiers": [], "defs": [], "references": [] }, { - "name": "Float64ArrayConstructor", + "name": "WeakRefConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Intl", + "name": "FinalizationRegistry", "identifiers": [], "defs": [], "references": [] }, { - "name": "Map", + "name": "FinalizationRegistryConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "MapConstructor", + "name": "Date", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReadonlyMap", + "name": "Number", "identifiers": [], "defs": [], "references": [] }, { - "name": "WeakMap", + "name": "PromiseFulfilledResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "WeakMapConstructor", + "name": "PromiseRejectedResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "Set", + "name": "PromiseSettledResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "SetConstructor", + "name": "RegExpStringIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReadonlySet", + "name": "Symbol", "identifiers": [], "defs": [], "references": [] }, { - "name": "WeakSet", + "name": "JSON", "identifiers": [], "defs": [], "references": [] }, { - "name": "WeakSetConstructor", + "name": "GeneratorFunction", "identifiers": [], "defs": [], "references": [] }, { - "name": "SymbolConstructor", + "name": "RegExpConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "IteratorYieldResult", + "name": "FlatArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "IteratorReturnResult", + "name": "AsyncGenerator", "identifiers": [], "defs": [], "references": [] }, { - "name": "IteratorResult", + "name": "AsyncGeneratorFunction", "identifiers": [], "defs": [], "references": [] }, { - "name": "Iterator", + "name": "AsyncGeneratorFunctionConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Iterable", + "name": "DateConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "IterableIterator", + "name": "ArrayBufferTypes", "identifiers": [], "defs": [], "references": [] }, { - "name": "PromiseConstructor", + "name": "PropertyKey", "identifiers": [], "defs": [], "references": [] }, { - "name": "Generator", + "name": "PropertyDescriptor", "identifiers": [], "defs": [], "references": [] }, { - "name": "GeneratorFunction", + "name": "PropertyDescriptorMap", "identifiers": [], "defs": [], "references": [] }, { - "name": "GeneratorFunctionConstructor", + "name": "Object", "identifiers": [], "defs": [], "references": [] }, { - "name": "ProxyHandler", + "name": "FunctionConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ProxyConstructor", + "name": "ThisParameterType", "identifiers": [], "defs": [], "references": [] }, { - "name": "Reflect", + "name": "OmitThisParameter", "identifiers": [], "defs": [], "references": [] }, { - "name": "SharedArrayBuffer", + "name": "CallableFunction", "identifiers": [], "defs": [], "references": [] }, { - "name": "SharedArrayBufferConstructor", + "name": "NewableFunction", "identifiers": [], "defs": [], "references": [] }, { - "name": "Atomics", + "name": "StringConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncIterator", + "name": "Boolean", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncIterable", + "name": "BooleanConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncIterableIterator", + "name": "NumberConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncGenerator", + "name": "TemplateStringsArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncGeneratorFunction", + "name": "ImportMeta", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncGeneratorFunctionConstructor", + "name": "ImportCallOptions", "identifiers": [], "defs": [], "references": [] }, { - "name": "const", + "name": "ImportAssertions", "identifiers": [], "defs": [], "references": [] }, { - "name": "defineModel", + "name": "ImportAttributes", "identifiers": [], "defs": [], - "references": [ - { - "identifier": { - "type": "Identifier", + "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": "defineModel", + "identifiers": [], + "defs": [], + "references": [ + { + "identifier": { + "type": "Identifier", "name": "defineModel", "loc": { - "start": { - "line": 2, - "column": 32 - }, "end": { "line": 2, "column": 43 + }, + "start": { + "line": 2, + "column": 32 } } }, @@ -921,13 +1197,13 @@ "type": "Identifier", "name": "modelValue", "loc": { - "start": { - "line": 2, - "column": 7 - }, "end": { "line": 2, "column": 17 + }, + "start": { + "line": 2, + "column": 7 } } } @@ -938,13 +1214,13 @@ "node": { "type": "VariableDeclarator", "loc": { - "start": { - "line": 2, - "column": 6 - }, "end": { "line": 9, "column": 2 + }, + "start": { + "line": 2, + "column": 6 } } }, @@ -957,13 +1233,13 @@ "type": "Identifier", "name": "modelValue", "loc": { - "start": { - "line": 2, - "column": 7 - }, "end": { "line": 2, "column": 17 + }, + "start": { + "line": 2, + "column": 7 } } }, @@ -972,13 +1248,13 @@ "type": "Identifier", "name": "modelValue", "loc": { - "start": { - "line": 2, - "column": 7 - }, "end": { "line": 2, "column": 17 + }, + "start": { + "line": 2, + "column": 7 } } }, @@ -989,13 +1265,13 @@ "type": "Identifier", "name": "modelValue", "loc": { - "start": { - "line": 2, - "column": 7 - }, "end": { "line": 2, "column": 17 + }, + "start": { + "line": 2, + "column": 7 } } }, @@ -1004,13 +1280,13 @@ "type": "Identifier", "name": "modelValue", "loc": { - "start": { - "line": 2, - "column": 7 - }, "end": { "line": 2, "column": 17 + }, + "start": { + "line": 2, + "column": 7 } } }, @@ -1026,13 +1302,13 @@ "type": "Identifier", "name": "modifiers", "loc": { - "start": { - "line": 2, - "column": 19 - }, "end": { "line": 2, "column": 28 + }, + "start": { + "line": 2, + "column": 19 } } } @@ -1043,13 +1319,13 @@ "node": { "type": "VariableDeclarator", "loc": { - "start": { - "line": 2, - "column": 6 - }, "end": { "line": 9, "column": 2 + }, + "start": { + "line": 2, + "column": 6 } } }, @@ -1062,13 +1338,13 @@ "type": "Identifier", "name": "modifiers", "loc": { - "start": { - "line": 2, - "column": 19 - }, "end": { "line": 2, "column": 28 + }, + "start": { + "line": 2, + "column": 19 } } }, @@ -1077,13 +1353,13 @@ "type": "Identifier", "name": "modifiers", "loc": { - "start": { - "line": 2, - "column": 19 - }, "end": { "line": 2, "column": 28 + }, + "start": { + "line": 2, + "column": 19 } } }, @@ -1094,13 +1370,13 @@ "type": "Identifier", "name": "modifiers", "loc": { - "start": { - "line": 4, - "column": 8 - }, "end": { "line": 4, "column": 17 + }, + "start": { + "line": 4, + "column": 8 } } }, @@ -1109,13 +1385,13 @@ "type": "Identifier", "name": "modifiers", "loc": { - "start": { - "line": 2, - "column": 19 - }, "end": { "line": 2, "column": 28 + }, + "start": { + "line": 2, + "column": 19 } } }, @@ -1130,13 +1406,13 @@ "type": "Identifier", "name": "modelValue", "loc": { - "start": { - "line": 2, - "column": 7 - }, "end": { "line": 2, "column": 17 + }, + "start": { + "line": 2, + "column": 7 } } }, @@ -1145,13 +1421,13 @@ "type": "Identifier", "name": "modelValue", "loc": { - "start": { - "line": 2, - "column": 7 - }, "end": { "line": 2, "column": 17 + }, + "start": { + "line": 2, + "column": 7 } } }, @@ -1162,13 +1438,13 @@ "type": "Identifier", "name": "modifiers", "loc": { - "start": { - "line": 2, - "column": 19 - }, "end": { "line": 2, "column": 28 + }, + "start": { + "line": 2, + "column": 19 } } }, @@ -1177,13 +1453,13 @@ "type": "Identifier", "name": "modifiers", "loc": { - "start": { - "line": 2, - "column": 19 - }, "end": { "line": 2, "column": 28 + }, + "start": { + "line": 2, + "column": 19 } } }, @@ -1194,13 +1470,13 @@ "type": "Identifier", "name": "defineModel", "loc": { - "start": { - "line": 2, - "column": 32 - }, "end": { "line": 2, "column": 43 + }, + "start": { + "line": 2, + "column": 32 } } }, @@ -1225,13 +1501,13 @@ "type": "Identifier", "name": "value", "loc": { - "start": { - "line": 3, - "column": 6 - }, "end": { "line": 3, "column": 11 + }, + "start": { + "line": 3, + "column": 6 } } } @@ -1242,13 +1518,13 @@ "node": { "type": "FunctionExpression", "loc": { - "start": { - "line": 3, - "column": 5 - }, "end": { "line": 8, "column": 3 + }, + "start": { + "line": 3, + "column": 5 } } }, @@ -1261,13 +1537,13 @@ "type": "Identifier", "name": "value", "loc": { - "start": { - "line": 5, - "column": 13 - }, "end": { "line": 5, "column": 18 + }, + "start": { + "line": 5, + "column": 13 } } }, @@ -1276,13 +1552,13 @@ "type": "Identifier", "name": "value", "loc": { - "start": { - "line": 3, - "column": 6 - }, "end": { "line": 3, "column": 11 + }, + "start": { + "line": 3, + "column": 6 } } }, @@ -1293,13 +1569,13 @@ "type": "Identifier", "name": "value", "loc": { - "start": { - "line": 7, - "column": 11 - }, "end": { "line": 7, "column": 16 + }, + "start": { + "line": 7, + "column": 11 } } }, @@ -1308,13 +1584,13 @@ "type": "Identifier", "name": "value", "loc": { - "start": { - "line": 3, - "column": 6 - }, "end": { "line": 3, "column": 11 + }, + "start": { + "line": 3, + "column": 6 } } }, @@ -1329,13 +1605,13 @@ "type": "Identifier", "name": "modifiers", "loc": { - "start": { - "line": 4, - "column": 8 - }, "end": { "line": 4, "column": 17 + }, + "start": { + "line": 4, + "column": 8 } } }, @@ -1344,13 +1620,13 @@ "type": "Identifier", "name": "modifiers", "loc": { - "start": { - "line": 2, - "column": 19 - }, "end": { "line": 2, "column": 28 + }, + "start": { + "line": 2, + "column": 19 } } }, @@ -1361,13 +1637,13 @@ "type": "Identifier", "name": "value", "loc": { - "start": { - "line": 7, - "column": 11 - }, "end": { "line": 7, "column": 16 + }, + "start": { + "line": 7, + "column": 11 } } }, @@ -1376,13 +1652,13 @@ "type": "Identifier", "name": "value", "loc": { - "start": { - "line": 3, - "column": 6 - }, "end": { "line": 3, "column": 11 + }, + "start": { + "line": 3, + "column": 6 } } }, @@ -1399,13 +1675,13 @@ "type": "Identifier", "name": "value", "loc": { - "start": { - "line": 5, - "column": 13 - }, "end": { "line": 5, "column": 18 + }, + "start": { + "line": 5, + "column": 13 } } }, @@ -1414,13 +1690,13 @@ "type": "Identifier", "name": "value", "loc": { - "start": { - "line": 3, - "column": 6 - }, "end": { "line": 3, "column": 11 + }, + "start": { + "line": 3, + "column": 6 } } }, @@ -1434,13 +1710,13 @@ "type": "Identifier", "name": "value", "loc": { - "start": { - "line": 5, - "column": 13 - }, "end": { "line": 5, "column": 18 + }, + "start": { + "line": 5, + "column": 13 } } }, @@ -1449,13 +1725,13 @@ "type": "Identifier", "name": "value", "loc": { - "start": { - "line": 3, - "column": 6 - }, "end": { "line": 3, "column": 11 + }, + "start": { + "line": 3, + "column": 6 } } }, @@ -1470,13 +1746,13 @@ "type": "Identifier", "name": "modifiers", "loc": { - "start": { - "line": 4, - "column": 8 - }, "end": { "line": 4, "column": 17 + }, + "start": { + "line": 4, + "column": 8 } } }, @@ -1485,13 +1761,13 @@ "type": "Identifier", "name": "modifiers", "loc": { - "start": { - "line": 2, - "column": 19 - }, "end": { "line": 2, "column": 28 + }, + "start": { + "line": 2, + "column": 19 } } }, @@ -1506,13 +1782,13 @@ "type": "Identifier", "name": "defineModel", "loc": { - "start": { - "line": 2, - "column": 32 - }, "end": { "line": 2, "column": 43 + }, + "start": { + "line": 2, + "column": 32 } } }, diff --git a/test/fixtures/ast/define-slots01/ast.json b/test/fixtures/ast/define-slots01/ast.json index 1dd238e5..e6d06d60 100644 --- a/test/fixtures/ast/define-slots01/ast.json +++ b/test/fixtures/ast/define-slots01/ast.json @@ -1,66 +1,61 @@ { "type": "Program", + "range": [ + 25, + 97 + ], "body": [ { "type": "VariableDeclaration", "declarations": [ { "type": "VariableDeclarator", + "definite": false, "id": { "type": "Identifier", + "decorators": [], "name": "slots", + "optional": false, "range": [ 31, 36 ], "loc": { - "start": { - "line": 2, - "column": 6 - }, "end": { "line": 2, "column": 11 + }, + "start": { + "line": 2, + "column": 6 } } }, "init": { "type": "CallExpression", + "arguments": [], "callee": { "type": "Identifier", + "decorators": [], "name": "defineSlots", + "optional": false, "range": [ 39, 50 ], "loc": { - "start": { - "line": 2, - "column": 14 - }, "end": { "line": 2, "column": 25 + }, + "start": { + "line": 2, + "column": 14 } } }, - "arguments": [], "optional": false, - "range": [ - 39, - 96 - ], - "loc": { - "start": { - "line": 2, - "column": 14 - }, - "end": { - "line": 4, - "column": 4 - } - }, - "typeParameters": { + "typeArguments": { "type": "TSTypeParameterInstantiation", "range": [ 50, @@ -75,50 +70,42 @@ "computed": false, "key": { "type": "Identifier", + "decorators": [], "name": "default", + "optional": false, "range": [ 55, 62 ], "loc": { - "start": { - "line": 3, - "column": 2 - }, "end": { "line": 3, "column": 9 + }, + "start": { + "line": 3, + "column": 2 } } }, + "kind": "method", + "optional": false, "params": [ { "type": "Identifier", + "decorators": [], "name": "props", - "range": [ - 63, - 85 - ], - "loc": { - "start": { - "line": 3, - "column": 10 - }, - "end": { - "line": 3, - "column": 32 - } - }, + "optional": false, "typeAnnotation": { "type": "TSTypeAnnotation", "loc": { - "start": { - "line": 3, - "column": 15 - }, "end": { "line": 3, "column": 32 + }, + "start": { + "line": 3, + "column": 15 } }, "range": [ @@ -133,32 +120,37 @@ "computed": false, "key": { "type": "Identifier", + "decorators": [], "name": "msg", + "optional": false, "range": [ 72, 75 ], "loc": { - "start": { - "line": 3, - "column": 19 - }, "end": { "line": 3, "column": 22 + }, + "start": { + "line": 3, + "column": 19 } } }, + "optional": false, + "readonly": false, + "static": false, "typeAnnotation": { "type": "TSTypeAnnotation", "loc": { - "start": { - "line": 3, - "column": 22 - }, "end": { "line": 3, "column": 30 + }, + "start": { + "line": 3, + "column": 22 } }, "range": [ @@ -172,13 +164,13 @@ 83 ], "loc": { - "start": { - "line": 3, - "column": 24 - }, "end": { "line": 3, "column": 30 + }, + "start": { + "line": 3, + "column": 24 } } } @@ -188,13 +180,13 @@ 83 ], "loc": { - "start": { - "line": 3, - "column": 19 - }, "end": { "line": 3, "column": 30 + }, + "start": { + "line": 3, + "column": 19 } } } @@ -204,44 +196,44 @@ 85 ], "loc": { - "start": { - "line": 3, - "column": 17 - }, "end": { "line": 3, "column": 32 + }, + "start": { + "line": 3, + "column": 17 } } } + }, + "range": [ + 63, + 85 + ], + "loc": { + "end": { + "line": 3, + "column": 32 + }, + "start": { + "line": 3, + "column": 10 + } } } ], - "kind": "method", - "range": [ - 55, - 91 - ], - "loc": { - "start": { - "line": 3, - "column": 2 - }, - "end": { - "line": 3, - "column": 38 - } - }, + "readonly": false, "returnType": { "type": "TSTypeAnnotation", "loc": { - "start": { - "line": 3, - "column": 33 - }, "end": { "line": 3, "column": 38 + }, + "start": { + "line": 3, + "column": 33 } }, "range": [ @@ -255,16 +247,31 @@ 91 ], "loc": { - "start": { - "line": 3, - "column": 35 - }, "end": { "line": 3, "column": 38 + }, + "start": { + "line": 3, + "column": 35 } } } + }, + "static": false, + "range": [ + 55, + 91 + ], + "loc": { + "end": { + "line": 3, + "column": 38 + }, + "start": { + "line": 3, + "column": 2 + } } } ], @@ -273,27 +280,41 @@ 93 ], "loc": { - "start": { - "line": 2, - "column": 26 - }, "end": { "line": 4, "column": 1 + }, + "start": { + "line": 2, + "column": 26 } } } ], "loc": { - "start": { - "line": 2, - "column": 25 - }, "end": { "line": 4, "column": 2 + }, + "start": { + "line": 2, + "column": 25 } } + }, + "range": [ + 39, + 96 + ], + "loc": { + "end": { + "line": 4, + "column": 4 + }, + "start": { + "line": 2, + "column": 14 + } } }, "range": [ @@ -301,49 +322,37 @@ 96 ], "loc": { - "start": { - "line": 2, - "column": 6 - }, "end": { "line": 4, "column": 4 + }, + "start": { + "line": 2, + "column": 6 } } } ], + "declare": false, "kind": "const", "range": [ 25, 96 ], "loc": { - "start": { - "line": 2, - "column": 0 - }, "end": { "line": 4, "column": 4 + }, + "start": { + "line": 2, + "column": 0 } } } ], + "comments": [], "sourceType": "module", - "range": [ - 25, - 97 - ], - "loc": { - "start": { - "line": 2, - "column": 0 - }, - "end": { - "line": 5, - "column": 0 - } - }, "tokens": [ { "type": "Punctuator", @@ -365,399 +374,399 @@ }, { "type": "Keyword", - "value": "const", + "loc": { + "end": { + "line": 2, + "column": 5 + }, + "start": { + "line": 2, + "column": 0 + } + }, "range": [ 25, 30 ], + "value": "const" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 2, - "column": 0 + "column": 11 }, - "end": { + "start": { "line": 2, - "column": 5 + "column": 6 } - } - }, - { - "type": "Identifier", - "value": "slots", + }, "range": [ 31, 36 ], + "value": "slots" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 6 + "column": 13 }, - "end": { + "start": { "line": 2, - "column": 11 + "column": 12 } - } - }, - { - "type": "Punctuator", - "value": "=", + }, "range": [ 37, 38 ], + "value": "=" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 2, - "column": 12 + "column": 25 }, - "end": { + "start": { "line": 2, - "column": 13 + "column": 14 } - } - }, - { - "type": "Identifier", - "value": "defineSlots", + }, "range": [ 39, 50 ], + "value": "defineSlots" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 14 + "column": 26 }, - "end": { + "start": { "line": 2, "column": 25 } - } - }, - { - "type": "Punctuator", - "value": "<", + }, "range": [ 50, 51 ], + "value": "<" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 25 + "column": 27 }, - "end": { + "start": { "line": 2, "column": 26 } - } - }, - { - "type": "Punctuator", - "value": "{", + }, "range": [ 51, 52 ], - "loc": { - "start": { - "line": 2, - "column": 26 - }, - "end": { - "line": 2, - "column": 27 - } - } + "value": "{" }, { "type": "Keyword", - "value": "default", + "loc": { + "end": { + "line": 3, + "column": 9 + }, + "start": { + "line": 3, + "column": 2 + } + }, "range": [ 55, 62 ], + "value": "default" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 3, - "column": 2 + "column": 10 }, - "end": { + "start": { "line": 3, "column": 9 } - } - }, - { - "type": "Punctuator", - "value": "(", + }, "range": [ 62, 63 ], + "value": "(" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 3, - "column": 9 + "column": 15 }, - "end": { + "start": { "line": 3, "column": 10 } - } - }, - { - "type": "Identifier", - "value": "props", + }, "range": [ 63, 68 ], + "value": "props" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 3, - "column": 10 + "column": 16 }, - "end": { + "start": { "line": 3, "column": 15 } - } - }, - { - "type": "Punctuator", - "value": ":", + }, "range": [ 68, 69 ], + "value": ":" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 3, - "column": 15 + "column": 18 }, - "end": { + "start": { "line": 3, - "column": 16 + "column": 17 } - } - }, - { - "type": "Punctuator", - "value": "{", + }, "range": [ 70, 71 ], + "value": "{" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 3, - "column": 17 + "column": 22 }, - "end": { + "start": { "line": 3, - "column": 18 + "column": 19 } - } - }, - { - "type": "Identifier", - "value": "msg", + }, "range": [ 72, 75 ], + "value": "msg" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 3, - "column": 19 + "column": 23 }, - "end": { + "start": { "line": 3, "column": 22 } - } - }, - { - "type": "Punctuator", - "value": ":", + }, "range": [ 75, 76 ], + "value": ":" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 3, - "column": 22 + "column": 30 }, - "end": { + "start": { "line": 3, - "column": 23 + "column": 24 } - } - }, - { - "type": "Identifier", - "value": "string", + }, "range": [ 77, 83 ], + "value": "string" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 3, - "column": 24 + "column": 32 }, - "end": { + "start": { "line": 3, - "column": 30 + "column": 31 } - } - }, - { - "type": "Punctuator", - "value": "}", + }, "range": [ 84, 85 ], + "value": "}" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 3, - "column": 31 + "column": 33 }, - "end": { + "start": { "line": 3, "column": 32 } - } - }, - { - "type": "Punctuator", - "value": ")", + }, "range": [ 85, 86 ], + "value": ")" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 3, - "column": 32 + "column": 34 }, - "end": { + "start": { "line": 3, "column": 33 } - } - }, - { - "type": "Punctuator", - "value": ":", + }, "range": [ 86, 87 ], + "value": ":" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 3, - "column": 33 + "column": 38 }, - "end": { + "start": { "line": 3, - "column": 34 + "column": 35 } - } - }, - { - "type": "Identifier", - "value": "any", + }, "range": [ 88, 91 ], - "loc": { - "start": { - "line": 3, - "column": 35 - }, - "end": { - "line": 3, - "column": 38 - } - } + "value": "any" }, { "type": "Punctuator", - "value": "}", + "loc": { + "end": { + "line": 4, + "column": 1 + }, + "start": { + "line": 4, + "column": 0 + } + }, "range": [ 92, 93 ], + "value": "}" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 4, - "column": 0 + "column": 2 }, - "end": { + "start": { "line": 4, "column": 1 } - } - }, - { - "type": "Punctuator", - "value": ">", + }, "range": [ 93, 94 ], + "value": ">" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 4, - "column": 1 + "column": 3 }, - "end": { + "start": { "line": 4, "column": 2 } - } - }, - { - "type": "Punctuator", - "value": "(", + }, "range": [ 94, 95 ], + "value": "(" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 4, - "column": 2 + "column": 4 }, - "end": { + "start": { "line": 4, "column": 3 } - } - }, - { - "type": "Punctuator", - "value": ")", + }, "range": [ 95, 96 ], - "loc": { - "start": { - "line": 4, - "column": 3 - }, - "end": { - "line": 4, - "column": 4 - } - } + "value": ")" }, { "type": "Punctuator", @@ -778,5 +787,14 @@ "value": "</script>" } ], - "comments": [] + "loc": { + "end": { + "line": 5, + "column": 0 + }, + "start": { + "line": 2, + "column": 0 + } + } } \ No newline at end of file diff --git a/test/fixtures/ast/define-slots01/scope.json b/test/fixtures/ast/define-slots01/scope.json index 3a65764c..b5874fdd 100644 --- a/test/fixtures/ast/define-slots01/scope.json +++ b/test/fixtures/ast/define-slots01/scope.json @@ -2,904 +2,1180 @@ "type": "global", "variables": [ { - "name": "ClassMemberDecoratorContext", + "name": "Intl", "identifiers": [], "defs": [], "references": [] }, { - "name": "DecoratorContext", + "name": "SymbolConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassDecoratorContext", + "name": "Function", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassMethodDecoratorContext", + "name": "Disposable", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassGetterDecoratorContext", + "name": "AsyncDisposable", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassSetterDecoratorContext", + "name": "SuppressedError", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassAccessorDecoratorContext", + "name": "SuppressedErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassAccessorDecoratorTarget", + "name": "DisposableStack", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassAccessorDecoratorResult", + "name": "DisposableStackConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassFieldDecoratorContext", + "name": "AsyncDisposableStack", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassDecorator", + "name": "AsyncDisposableStackConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "PropertyDecorator", + "name": "IteratorObject", "identifiers": [], "defs": [], "references": [] }, { - "name": "MethodDecorator", + "name": "AsyncIteratorObject", "identifiers": [], "defs": [], "references": [] }, { - "name": "ParameterDecorator", + "name": "ReadonlySetLike", "identifiers": [], "defs": [], "references": [] }, { - "name": "Symbol", + "name": "Set", "identifiers": [], "defs": [], "references": [] }, { - "name": "PropertyKey", + "name": "ReadonlySet", "identifiers": [], "defs": [], "references": [] }, { - "name": "PropertyDescriptor", + "name": "ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "PropertyDescriptorMap", + "name": "Iterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "Object", + "name": "IteratorObjectConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ObjectConstructor", + "name": "PromiseConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Function", + "name": "Float16Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "FunctionConstructor", + "name": "Float16ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ThisParameterType", + "name": "Math", "identifiers": [], "defs": [], "references": [] }, { - "name": "OmitThisParameter", + "name": "DataView", "identifiers": [], "defs": [], "references": [] }, { - "name": "CallableFunction", + "name": "ArrayBuffer", "identifiers": [], "defs": [], "references": [] }, { - "name": "NewableFunction", + "name": "ArrayBufferConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "IArguments", + "name": "MapConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "String", + "name": "ObjectConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "StringConstructor", + "name": "PromiseWithResolvers", "identifiers": [], "defs": [], "references": [] }, { - "name": "Boolean", + "name": "RegExp", "identifiers": [], "defs": [], "references": [] }, { - "name": "BooleanConstructor", + "name": "Atomics", "identifiers": [], "defs": [], "references": [] }, { - "name": "Number", + "name": "SharedArrayBuffer", "identifiers": [], "defs": [], "references": [] }, { - "name": "NumberConstructor", + "name": "SharedArrayBufferConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "TemplateStringsArray", + "name": "String", "identifiers": [], "defs": [], "references": [] }, { - "name": "ImportMeta", + "name": "ClassMemberDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "ImportCallOptions", + "name": "DecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "ImportAssertions", + "name": "DecoratorMetadataObject", "identifiers": [], "defs": [], "references": [] }, { - "name": "Math", + "name": "DecoratorMetadata", "identifiers": [], "defs": [], "references": [] }, { - "name": "Date", + "name": "ClassDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "DateConstructor", + "name": "ClassMethodDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "RegExpMatchArray", + "name": "ClassGetterDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "RegExpExecArray", + "name": "ClassSetterDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "RegExp", + "name": "ClassAccessorDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "RegExpConstructor", + "name": "ClassAccessorDecoratorTarget", "identifiers": [], "defs": [], "references": [] }, { - "name": "Error", + "name": "ClassAccessorDecoratorResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "ErrorConstructor", + "name": "ClassFieldDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "EvalError", + "name": "IteratorYieldResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "EvalErrorConstructor", + "name": "IteratorReturnResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "RangeError", + "name": "IteratorResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "RangeErrorConstructor", + "name": "Iterable", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReferenceError", + "name": "IterableIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReferenceErrorConstructor", + "name": "BuiltinIteratorReturn", "identifiers": [], "defs": [], "references": [] }, { - "name": "SyntaxError", + "name": "ArrayIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "SyntaxErrorConstructor", + "name": "Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "TypeError", + "name": "ReadonlyArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "TypeErrorConstructor", + "name": "IArguments", "identifiers": [], "defs": [], "references": [] }, { - "name": "URIError", + "name": "MapIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "URIErrorConstructor", + "name": "Map", "identifiers": [], "defs": [], "references": [] }, { - "name": "JSON", + "name": "ReadonlyMap", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReadonlyArray", + "name": "WeakMap", "identifiers": [], "defs": [], "references": [] }, { - "name": "ConcatArray", + "name": "WeakMapConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Array", + "name": "SetIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayConstructor", + "name": "SetConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "TypedPropertyDescriptor", + "name": "WeakSet", "identifiers": [], "defs": [], "references": [] }, { - "name": "PromiseConstructorLike", + "name": "WeakSetConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "PromiseLike", + "name": "Promise", "identifiers": [], "defs": [], "references": [] }, { - "name": "Promise", + "name": "StringIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "Awaited", + "name": "Int8Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayLike", + "name": "Int8ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Partial", + "name": "Uint8Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Required", + "name": "Uint8ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Readonly", + "name": "Uint8ClampedArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "Pick", + "name": "Uint8ClampedArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Record", + "name": "Int16Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Exclude", + "name": "Int16ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Extract", + "name": "Uint16Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Omit", + "name": "Uint16ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "NonNullable", + "name": "Int32Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Parameters", + "name": "Int32ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ConstructorParameters", + "name": "Uint32Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReturnType", + "name": "Uint32ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "InstanceType", + "name": "Float32Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uppercase", + "name": "Float32ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Lowercase", + "name": "Float64Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Capitalize", + "name": "Float64ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uncapitalize", + "name": "AsyncIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "ThisType", + "name": "AsyncIterable", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayBuffer", + "name": "AsyncIterableIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayBufferTypes", + "name": "BigInt64Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayBufferLike", + "name": "BigUint64Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayBufferConstructor", + "name": "WeakKeyTypes", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayBufferView", + "name": "BigIntToLocaleStringOptions", "identifiers": [], "defs": [], "references": [] }, { - "name": "DataView", + "name": "BigInt", "identifiers": [], "defs": [], "references": [] }, { - "name": "DataViewConstructor", + "name": "BigIntConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int8Array", + "name": "BigInt64ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int8ArrayConstructor", + "name": "BigUint64ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint8Array", + "name": "ErrorOptions", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint8ArrayConstructor", + "name": "Error", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint8ClampedArray", + "name": "ErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint8ClampedArrayConstructor", + "name": "EvalErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int16Array", + "name": "RangeErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int16ArrayConstructor", + "name": "ReferenceErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint16Array", + "name": "SyntaxErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint16ArrayConstructor", + "name": "TypeErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int32Array", + "name": "URIErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int32ArrayConstructor", + "name": "AggregateErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint32Array", + "name": "RegExpMatchArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint32ArrayConstructor", + "name": "RegExpExecArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "Float32Array", + "name": "RegExpIndicesArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "Float32ArrayConstructor", + "name": "AggregateError", "identifiers": [], "defs": [], "references": [] }, { - "name": "Float64Array", + "name": "WeakRef", "identifiers": [], "defs": [], "references": [] }, { - "name": "Float64ArrayConstructor", + "name": "WeakRefConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Intl", + "name": "FinalizationRegistry", "identifiers": [], "defs": [], "references": [] }, { - "name": "Map", + "name": "FinalizationRegistryConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "MapConstructor", + "name": "Date", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReadonlyMap", + "name": "Number", "identifiers": [], "defs": [], "references": [] }, { - "name": "WeakMap", + "name": "PromiseFulfilledResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "WeakMapConstructor", + "name": "PromiseRejectedResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "Set", + "name": "PromiseSettledResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "SetConstructor", + "name": "RegExpStringIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReadonlySet", + "name": "Symbol", "identifiers": [], "defs": [], "references": [] }, { - "name": "WeakSet", + "name": "JSON", "identifiers": [], "defs": [], "references": [] }, { - "name": "WeakSetConstructor", + "name": "GeneratorFunction", "identifiers": [], "defs": [], "references": [] }, { - "name": "SymbolConstructor", + "name": "RegExpConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "IteratorYieldResult", + "name": "FlatArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "IteratorReturnResult", + "name": "AsyncGenerator", "identifiers": [], "defs": [], "references": [] }, { - "name": "IteratorResult", + "name": "AsyncGeneratorFunction", "identifiers": [], "defs": [], "references": [] }, { - "name": "Iterator", + "name": "AsyncGeneratorFunctionConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Iterable", + "name": "DateConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "IterableIterator", + "name": "ArrayBufferTypes", "identifiers": [], "defs": [], "references": [] }, { - "name": "PromiseConstructor", + "name": "PropertyKey", "identifiers": [], "defs": [], "references": [] }, { - "name": "Generator", + "name": "PropertyDescriptor", "identifiers": [], "defs": [], "references": [] }, { - "name": "GeneratorFunction", + "name": "PropertyDescriptorMap", "identifiers": [], "defs": [], "references": [] }, { - "name": "GeneratorFunctionConstructor", + "name": "Object", "identifiers": [], "defs": [], "references": [] }, { - "name": "ProxyHandler", + "name": "FunctionConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ProxyConstructor", + "name": "ThisParameterType", "identifiers": [], "defs": [], "references": [] }, { - "name": "Reflect", + "name": "OmitThisParameter", "identifiers": [], "defs": [], "references": [] }, { - "name": "SharedArrayBuffer", + "name": "CallableFunction", "identifiers": [], "defs": [], "references": [] }, { - "name": "SharedArrayBufferConstructor", + "name": "NewableFunction", "identifiers": [], "defs": [], "references": [] }, { - "name": "Atomics", + "name": "StringConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncIterator", + "name": "Boolean", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncIterable", + "name": "BooleanConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncIterableIterator", + "name": "NumberConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncGenerator", + "name": "TemplateStringsArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncGeneratorFunction", + "name": "ImportMeta", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncGeneratorFunctionConstructor", + "name": "ImportCallOptions", "identifiers": [], "defs": [], "references": [] }, { - "name": "const", + "name": "ImportAssertions", "identifiers": [], "defs": [], "references": [] }, { - "name": "defineSlots", + "name": "ImportAttributes", "identifiers": [], "defs": [], - "references": [ - { - "identifier": { - "type": "Identifier", + "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": "defineSlots", + "identifiers": [], + "defs": [], + "references": [ + { + "identifier": { + "type": "Identifier", "name": "defineSlots", "loc": { - "start": { - "line": 2, - "column": 14 - }, "end": { "line": 2, "column": 25 + }, + "start": { + "line": 2, + "column": 14 } } }, @@ -921,13 +1197,13 @@ "type": "Identifier", "name": "slots", "loc": { - "start": { - "line": 2, - "column": 6 - }, "end": { "line": 2, "column": 11 + }, + "start": { + "line": 2, + "column": 6 } } } @@ -938,13 +1214,13 @@ "node": { "type": "VariableDeclarator", "loc": { - "start": { - "line": 2, - "column": 6 - }, "end": { "line": 4, "column": 4 + }, + "start": { + "line": 2, + "column": 6 } } }, @@ -957,13 +1233,13 @@ "type": "Identifier", "name": "slots", "loc": { - "start": { - "line": 2, - "column": 6 - }, "end": { "line": 2, "column": 11 + }, + "start": { + "line": 2, + "column": 6 } } }, @@ -972,13 +1248,13 @@ "type": "Identifier", "name": "slots", "loc": { - "start": { - "line": 2, - "column": 6 - }, "end": { "line": 2, "column": 11 + }, + "start": { + "line": 2, + "column": 6 } } }, @@ -993,13 +1269,13 @@ "type": "Identifier", "name": "slots", "loc": { - "start": { - "line": 2, - "column": 6 - }, "end": { "line": 2, "column": 11 + }, + "start": { + "line": 2, + "column": 6 } } }, @@ -1008,13 +1284,13 @@ "type": "Identifier", "name": "slots", "loc": { - "start": { - "line": 2, - "column": 6 - }, "end": { "line": 2, "column": 11 + }, + "start": { + "line": 2, + "column": 6 } } }, @@ -1025,13 +1301,13 @@ "type": "Identifier", "name": "defineSlots", "loc": { - "start": { - "line": 2, - "column": 14 - }, "end": { "line": 2, "column": 25 + }, + "start": { + "line": 2, + "column": 14 } } }, @@ -1050,13 +1326,13 @@ "type": "Identifier", "name": "props", "loc": { - "start": { - "line": 3, - "column": 10 - }, "end": { "line": 3, "column": 32 + }, + "start": { + "line": 3, + "column": 10 } } } @@ -1067,13 +1343,13 @@ "node": { "type": "TSMethodSignature", "loc": { - "start": { - "line": 3, - "column": 2 - }, "end": { "line": 3, "column": 38 + }, + "start": { + "line": 3, + "column": 2 } } }, @@ -1094,13 +1370,13 @@ "type": "Identifier", "name": "defineSlots", "loc": { - "start": { - "line": 2, - "column": 14 - }, "end": { "line": 2, "column": 25 + }, + "start": { + "line": 2, + "column": 14 } } }, diff --git a/test/fixtures/ast/directive-argument-and-modifiers/ast.json b/test/fixtures/ast/directive-argument-and-modifiers/ast.json index afca550e..a9f45e97 100644 --- a/test/fixtures/ast/directive-argument-and-modifiers/ast.json +++ b/test/fixtures/ast/directive-argument-and-modifiers/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/directive-arguments/ast.json b/test/fixtures/ast/directive-arguments/ast.json index 79f08bb1..6332d0bc 100644 --- a/test/fixtures/ast/directive-arguments/ast.json +++ b/test/fixtures/ast/directive-arguments/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/directive-empty-value/ast.json b/test/fixtures/ast/directive-empty-value/ast.json index 70f6eed9..27c2b1f4 100644 --- a/test/fixtures/ast/directive-empty-value/ast.json +++ b/test/fixtures/ast/directive-empty-value/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/directive-error-1/ast.json b/test/fixtures/ast/directive-error-1/ast.json index c784b8d6..27e6fc4c 100644 --- a/test/fixtures/ast/directive-error-1/ast.json +++ b/test/fixtures/ast/directive-error-1/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/directive-error-2/ast.json b/test/fixtures/ast/directive-error-2/ast.json index f59e6a92..a91128fe 100644 --- a/test/fixtures/ast/directive-error-2/ast.json +++ b/test/fixtures/ast/directive-error-2/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/directive-error-3/ast.json b/test/fixtures/ast/directive-error-3/ast.json index b7e95cc6..3883279f 100644 --- a/test/fixtures/ast/directive-error-3/ast.json +++ b/test/fixtures/ast/directive-error-3/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/directive-error-4/ast.json b/test/fixtures/ast/directive-error-4/ast.json index 3888d0db..5fd15aa4 100644 --- a/test/fixtures/ast/directive-error-4/ast.json +++ b/test/fixtures/ast/directive-error-4/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/directive-modifiers/ast.json b/test/fixtures/ast/directive-modifiers/ast.json index 3e8e9d73..c195ea3c 100644 --- a/test/fixtures/ast/directive-modifiers/ast.json +++ b/test/fixtures/ast/directive-modifiers/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/directive-shorthands/ast.json b/test/fixtures/ast/directive-shorthands/ast.json index 0a221c3c..8b371ec6 100644 --- a/test/fixtures/ast/directive-shorthands/ast.json +++ b/test/fixtures/ast/directive-shorthands/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/directives/ast.json b/test/fixtures/ast/directives/ast.json index b78d69a5..0195b968 100644 --- a/test/fixtures/ast/directives/ast.json +++ b/test/fixtures/ast/directives/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/dynamic-argument-dot/ast.json b/test/fixtures/ast/dynamic-argument-dot/ast.json index 6beacb73..5db5ae03 100644 --- a/test/fixtures/ast/dynamic-argument-dot/ast.json +++ b/test/fixtures/ast/dynamic-argument-dot/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/dynamic-argument-error-1/ast.json b/test/fixtures/ast/dynamic-argument-error-1/ast.json index 6a8e5a06..7a92b787 100644 --- a/test/fixtures/ast/dynamic-argument-error-1/ast.json +++ b/test/fixtures/ast/dynamic-argument-error-1/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/dynamic-argument-error-2/ast.json b/test/fixtures/ast/dynamic-argument-error-2/ast.json index a337e3c1..ef8ac183 100644 --- a/test/fixtures/ast/dynamic-argument-error-2/ast.json +++ b/test/fixtures/ast/dynamic-argument-error-2/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/dynamic-argument-error-4/ast.json b/test/fixtures/ast/dynamic-argument-error-4/ast.json index a4b2104e..c95d81f0 100644 --- a/test/fixtures/ast/dynamic-argument-error-4/ast.json +++ b/test/fixtures/ast/dynamic-argument-error-4/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/dynamic-argument-error-5/ast.json b/test/fixtures/ast/dynamic-argument-error-5/ast.json index e5b60f28..293bfa2e 100644 --- a/test/fixtures/ast/dynamic-argument-error-5/ast.json +++ b/test/fixtures/ast/dynamic-argument-error-5/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/dynamic-argument-expr/ast.json b/test/fixtures/ast/dynamic-argument-expr/ast.json index 6c6f087b..f196768c 100644 --- a/test/fixtures/ast/dynamic-argument-expr/ast.json +++ b/test/fixtures/ast/dynamic-argument-expr/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/dynamic-argument-v-bind/ast.json b/test/fixtures/ast/dynamic-argument-v-bind/ast.json index 1e9ff9af..9136b5b5 100644 --- a/test/fixtures/ast/dynamic-argument-v-bind/ast.json +++ b/test/fixtures/ast/dynamic-argument-v-bind/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/dynamic-argument-v-on/ast.json b/test/fixtures/ast/dynamic-argument-v-on/ast.json index c8c1873c..b26e5569 100644 --- a/test/fixtures/ast/dynamic-argument-v-on/ast.json +++ b/test/fixtures/ast/dynamic-argument-v-on/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/dynamic-argument-v-slot/ast.json b/test/fixtures/ast/dynamic-argument-v-slot/ast.json index d98a7503..9273ee82 100644 --- a/test/fixtures/ast/dynamic-argument-v-slot/ast.json +++ b/test/fixtures/ast/dynamic-argument-v-slot/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/elements/ast.json b/test/fixtures/ast/elements/ast.json index 941b75f3..d6629548 100644 --- a/test/fixtures/ast/elements/ast.json +++ b/test/fixtures/ast/elements/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/empty-script-only/ast.json b/test/fixtures/ast/empty-script-only/ast.json index 0900772c..db10289f 100644 --- a/test/fixtures/ast/empty-script-only/ast.json +++ b/test/fixtures/ast/empty-script-only/ast.json @@ -17,7 +17,7 @@ 8 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [ { diff --git a/test/fixtures/ast/empty-template-only/ast.json b/test/fixtures/ast/empty-template-only/ast.json index 01609b68..16a13e3c 100644 --- a/test/fixtures/ast/empty-template-only/ast.json +++ b/test/fixtures/ast/empty-template-only/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/empty/ast.json b/test/fixtures/ast/empty/ast.json index 0905cb4d..a10daf83 100644 --- a/test/fixtures/ast/empty/ast.json +++ b/test/fixtures/ast/empty/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/end-of-line01/ast.json b/test/fixtures/ast/end-of-line01/ast.json index 600e0aaf..2dd0fadf 100644 --- a/test/fixtures/ast/end-of-line01/ast.json +++ b/test/fixtures/ast/end-of-line01/ast.json @@ -99,7 +99,7 @@ "kind": "var" } ], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [ { diff --git a/test/fixtures/ast/end-of-line02/ast.json b/test/fixtures/ast/end-of-line02/ast.json index a4a1bead..392ced18 100644 --- a/test/fixtures/ast/end-of-line02/ast.json +++ b/test/fixtures/ast/end-of-line02/ast.json @@ -99,7 +99,7 @@ "kind": "var" } ], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [ { diff --git a/test/fixtures/ast/error-absence-of-digits-in-numeric-character-reference/ast.json b/test/fixtures/ast/error-absence-of-digits-in-numeric-character-reference/ast.json index e59ed2f9..e69c38ca 100644 --- a/test/fixtures/ast/error-absence-of-digits-in-numeric-character-reference/ast.json +++ b/test/fixtures/ast/error-absence-of-digits-in-numeric-character-reference/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-character-reference-outside-unicode-range/ast.json b/test/fixtures/ast/error-character-reference-outside-unicode-range/ast.json index 33c779c3..fa679dd1 100644 --- a/test/fixtures/ast/error-character-reference-outside-unicode-range/ast.json +++ b/test/fixtures/ast/error-character-reference-outside-unicode-range/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-control-character-reference/ast.json b/test/fixtures/ast/error-control-character-reference/ast.json index c6a2dba7..fdf8c650 100644 --- a/test/fixtures/ast/error-control-character-reference/ast.json +++ b/test/fixtures/ast/error-control-character-reference/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-duplicate-attribute/ast.json b/test/fixtures/ast/error-duplicate-attribute/ast.json index d82cfb06..a9c58684 100644 --- a/test/fixtures/ast/error-duplicate-attribute/ast.json +++ b/test/fixtures/ast/error-duplicate-attribute/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-end-tag-with-attributes/ast.json b/test/fixtures/ast/error-end-tag-with-attributes/ast.json index 696fe712..7322b7cc 100644 --- a/test/fixtures/ast/error-end-tag-with-attributes/ast.json +++ b/test/fixtures/ast/error-end-tag-with-attributes/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-end-tag-with-trailing-solidus/ast.json b/test/fixtures/ast/error-end-tag-with-trailing-solidus/ast.json index 3890be2a..4b466df3 100644 --- a/test/fixtures/ast/error-end-tag-with-trailing-solidus/ast.json +++ b/test/fixtures/ast/error-end-tag-with-trailing-solidus/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-eof-before-tag-name-2/ast.json b/test/fixtures/ast/error-eof-before-tag-name-2/ast.json index 9f8aee7f..15236497 100644 --- a/test/fixtures/ast/error-eof-before-tag-name-2/ast.json +++ b/test/fixtures/ast/error-eof-before-tag-name-2/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-eof-before-tag-name/ast.json b/test/fixtures/ast/error-eof-before-tag-name/ast.json index 06cccbc6..3a40017a 100644 --- a/test/fixtures/ast/error-eof-before-tag-name/ast.json +++ b/test/fixtures/ast/error-eof-before-tag-name/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-eof-in-cdata/ast.json b/test/fixtures/ast/error-eof-in-cdata/ast.json index de55171f..6ee92a11 100644 --- a/test/fixtures/ast/error-eof-in-cdata/ast.json +++ b/test/fixtures/ast/error-eof-in-cdata/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-eof-in-comment-2/ast.json b/test/fixtures/ast/error-eof-in-comment-2/ast.json index 75fabe21..f0b7158a 100644 --- a/test/fixtures/ast/error-eof-in-comment-2/ast.json +++ b/test/fixtures/ast/error-eof-in-comment-2/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-eof-in-comment-3/ast.json b/test/fixtures/ast/error-eof-in-comment-3/ast.json index 3b595b6e..546f7100 100644 --- a/test/fixtures/ast/error-eof-in-comment-3/ast.json +++ b/test/fixtures/ast/error-eof-in-comment-3/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-eof-in-comment-4/ast.json b/test/fixtures/ast/error-eof-in-comment-4/ast.json index 6087bd52..cb1d7145 100644 --- a/test/fixtures/ast/error-eof-in-comment-4/ast.json +++ b/test/fixtures/ast/error-eof-in-comment-4/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-eof-in-comment-5/ast.json b/test/fixtures/ast/error-eof-in-comment-5/ast.json index 80d7ae2c..cebbd6ec 100644 --- a/test/fixtures/ast/error-eof-in-comment-5/ast.json +++ b/test/fixtures/ast/error-eof-in-comment-5/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-eof-in-comment/ast.json b/test/fixtures/ast/error-eof-in-comment/ast.json index d9278c11..c45d5ebe 100644 --- a/test/fixtures/ast/error-eof-in-comment/ast.json +++ b/test/fixtures/ast/error-eof-in-comment/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-eof-in-tag-2/ast.json b/test/fixtures/ast/error-eof-in-tag-2/ast.json index a643133d..b59cdb7f 100644 --- a/test/fixtures/ast/error-eof-in-tag-2/ast.json +++ b/test/fixtures/ast/error-eof-in-tag-2/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-eof-in-tag-3/ast.json b/test/fixtures/ast/error-eof-in-tag-3/ast.json index e87d4b72..3008a1c8 100644 --- a/test/fixtures/ast/error-eof-in-tag-3/ast.json +++ b/test/fixtures/ast/error-eof-in-tag-3/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-eof-in-tag-4/ast.json b/test/fixtures/ast/error-eof-in-tag-4/ast.json index 2ceee212..189f335a 100644 --- a/test/fixtures/ast/error-eof-in-tag-4/ast.json +++ b/test/fixtures/ast/error-eof-in-tag-4/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-eof-in-tag-5/ast.json b/test/fixtures/ast/error-eof-in-tag-5/ast.json index 2ceee212..189f335a 100644 --- a/test/fixtures/ast/error-eof-in-tag-5/ast.json +++ b/test/fixtures/ast/error-eof-in-tag-5/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-eof-in-tag-6/ast.json b/test/fixtures/ast/error-eof-in-tag-6/ast.json index 96aa43e0..637a0766 100644 --- a/test/fixtures/ast/error-eof-in-tag-6/ast.json +++ b/test/fixtures/ast/error-eof-in-tag-6/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-eof-in-tag-7/ast.json b/test/fixtures/ast/error-eof-in-tag-7/ast.json index 95c443ad..ab4d4c67 100644 --- a/test/fixtures/ast/error-eof-in-tag-7/ast.json +++ b/test/fixtures/ast/error-eof-in-tag-7/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-eof-in-tag/ast.json b/test/fixtures/ast/error-eof-in-tag/ast.json index 1f060a42..52f0c380 100644 --- a/test/fixtures/ast/error-eof-in-tag/ast.json +++ b/test/fixtures/ast/error-eof-in-tag/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-invalid-first-character-of-tag-name/ast.json b/test/fixtures/ast/error-invalid-first-character-of-tag-name/ast.json index 853d8334..725d1e82 100644 --- a/test/fixtures/ast/error-invalid-first-character-of-tag-name/ast.json +++ b/test/fixtures/ast/error-invalid-first-character-of-tag-name/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-message-empty/ast.json b/test/fixtures/ast/error-message-empty/ast.json index 6f8a32e2..a2a913e5 100644 --- a/test/fixtures/ast/error-message-empty/ast.json +++ b/test/fixtures/ast/error-message-empty/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-message-outside/ast.json b/test/fixtures/ast/error-message-outside/ast.json index 4e041bcb..5747314c 100644 --- a/test/fixtures/ast/error-message-outside/ast.json +++ b/test/fixtures/ast/error-message-outside/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-missing-end-tag-name/ast.json b/test/fixtures/ast/error-missing-end-tag-name/ast.json index 012ad6a7..1eebe291 100644 --- a/test/fixtures/ast/error-missing-end-tag-name/ast.json +++ b/test/fixtures/ast/error-missing-end-tag-name/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-missing-semicolon-after-character-reference/ast.json b/test/fixtures/ast/error-missing-semicolon-after-character-reference/ast.json index bb29108e..8e8d338c 100644 --- a/test/fixtures/ast/error-missing-semicolon-after-character-reference/ast.json +++ b/test/fixtures/ast/error-missing-semicolon-after-character-reference/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-missing-whitespace-between-attributes/ast.json b/test/fixtures/ast/error-missing-whitespace-between-attributes/ast.json index 5b9f11b7..94602436 100644 --- a/test/fixtures/ast/error-missing-whitespace-between-attributes/ast.json +++ b/test/fixtures/ast/error-missing-whitespace-between-attributes/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-noncharacter-character-reference/ast.json b/test/fixtures/ast/error-noncharacter-character-reference/ast.json index 6b57ead0..48a89100 100644 --- a/test/fixtures/ast/error-noncharacter-character-reference/ast.json +++ b/test/fixtures/ast/error-noncharacter-character-reference/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-null-character-reference/ast.json b/test/fixtures/ast/error-null-character-reference/ast.json index ad092a2a..dedb8c73 100644 --- a/test/fixtures/ast/error-null-character-reference/ast.json +++ b/test/fixtures/ast/error-null-character-reference/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-surrogate-character-reference/ast.json b/test/fixtures/ast/error-surrogate-character-reference/ast.json index be1ba501..8e3bb162 100644 --- a/test/fixtures/ast/error-surrogate-character-reference/ast.json +++ b/test/fixtures/ast/error-surrogate-character-reference/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-unexpected-character-in-attribute-name/ast.json b/test/fixtures/ast/error-unexpected-character-in-attribute-name/ast.json index d9917c99..f74d916f 100644 --- a/test/fixtures/ast/error-unexpected-character-in-attribute-name/ast.json +++ b/test/fixtures/ast/error-unexpected-character-in-attribute-name/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-unexpected-character-in-unquoted-attribute-value/ast.json b/test/fixtures/ast/error-unexpected-character-in-unquoted-attribute-value/ast.json index 05610ed2..c96f41f1 100644 --- a/test/fixtures/ast/error-unexpected-character-in-unquoted-attribute-value/ast.json +++ b/test/fixtures/ast/error-unexpected-character-in-unquoted-attribute-value/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-unexpected-equals-sign-before-attribute-name/ast.json b/test/fixtures/ast/error-unexpected-equals-sign-before-attribute-name/ast.json index fac2297c..7cdf016e 100644 --- a/test/fixtures/ast/error-unexpected-equals-sign-before-attribute-name/ast.json +++ b/test/fixtures/ast/error-unexpected-equals-sign-before-attribute-name/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-unexpected-solidus-in-tag/ast.json b/test/fixtures/ast/error-unexpected-solidus-in-tag/ast.json index 1f336ace..22d04c52 100644 --- a/test/fixtures/ast/error-unexpected-solidus-in-tag/ast.json +++ b/test/fixtures/ast/error-unexpected-solidus-in-tag/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-unknown-named-character-reference/ast.json b/test/fixtures/ast/error-unknown-named-character-reference/ast.json index 3b6d9bbf..7ca7ecf6 100644 --- a/test/fixtures/ast/error-unknown-named-character-reference/ast.json +++ b/test/fixtures/ast/error-unknown-named-character-reference/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-v-on-function-expression/ast.json b/test/fixtures/ast/error-v-on-function-expression/ast.json index 0e6de9bd..4b5630aa 100644 --- a/test/fixtures/ast/error-v-on-function-expression/ast.json +++ b/test/fixtures/ast/error-v-on-function-expression/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-x-invalid-end-tag/ast.json b/test/fixtures/ast/error-x-invalid-end-tag/ast.json index 47e735a7..72d49ae8 100644 --- a/test/fixtures/ast/error-x-invalid-end-tag/ast.json +++ b/test/fixtures/ast/error-x-invalid-end-tag/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/error-x-invalid-namespace/ast.json b/test/fixtures/ast/error-x-invalid-namespace/ast.json index 76d2fd79..876d2520 100644 --- a/test/fixtures/ast/error-x-invalid-namespace/ast.json +++ b/test/fixtures/ast/error-x-invalid-namespace/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/expression-container-only/ast.json b/test/fixtures/ast/expression-container-only/ast.json index 104fd11f..cb659414 100644 --- a/test/fixtures/ast/expression-container-only/ast.json +++ b/test/fixtures/ast/expression-container-only/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/filter-empty/ast.json b/test/fixtures/ast/filter-empty/ast.json index e476fbbb..b7299032 100644 --- a/test/fixtures/ast/filter-empty/ast.json +++ b/test/fixtures/ast/filter-empty/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/filters-2/ast.json b/test/fixtures/ast/filters-2/ast.json index e1a0926b..7de005d1 100644 --- a/test/fixtures/ast/filters-2/ast.json +++ b/test/fixtures/ast/filters-2/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/filters-3/ast.json b/test/fixtures/ast/filters-3/ast.json index 59d0eeaa..24c0fd0d 100644 --- a/test/fixtures/ast/filters-3/ast.json +++ b/test/fixtures/ast/filters-3/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/filters-4/ast.json b/test/fixtures/ast/filters-4/ast.json index 7ed79a2e..4001e0ad 100644 --- a/test/fixtures/ast/filters-4/ast.json +++ b/test/fixtures/ast/filters-4/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/filters-error-2/ast.json b/test/fixtures/ast/filters-error-2/ast.json index 62069a7f..da887d04 100644 --- a/test/fixtures/ast/filters-error-2/ast.json +++ b/test/fixtures/ast/filters-error-2/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/filters-error/ast.json b/test/fixtures/ast/filters-error/ast.json index 83e1718d..a908741d 100644 --- a/test/fixtures/ast/filters-error/ast.json +++ b/test/fixtures/ast/filters-error/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/filters-opt-filter-off/ast.json b/test/fixtures/ast/filters-opt-filter-off/ast.json index 56f5ef80..5f4f64a3 100644 --- a/test/fixtures/ast/filters-opt-filter-off/ast.json +++ b/test/fixtures/ast/filters-opt-filter-off/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/filters-opt-filter-on/ast.json b/test/fixtures/ast/filters-opt-filter-on/ast.json index 5ea7e9fe..adc0b05b 100644 --- a/test/fixtures/ast/filters-opt-filter-on/ast.json +++ b/test/fixtures/ast/filters-opt-filter-on/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/filters/ast.json b/test/fixtures/ast/filters/ast.json index f227023b..e9964d67 100644 --- a/test/fixtures/ast/filters/ast.json +++ b/test/fixtures/ast/filters/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/foreignobject-lower/ast.json b/test/fixtures/ast/foreignobject-lower/ast.json index a0633d60..480e572a 100644 --- a/test/fixtures/ast/foreignobject-lower/ast.json +++ b/test/fixtures/ast/foreignobject-lower/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/foreignobject/ast.json b/test/fixtures/ast/foreignobject/ast.json index b1e10d56..2d0fc692 100644 --- a/test/fixtures/ast/foreignobject/ast.json +++ b/test/fixtures/ast/foreignobject/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/hole-in-array/ast.json b/test/fixtures/ast/hole-in-array/ast.json index 2c8dfa86..f435432e 100644 --- a/test/fixtures/ast/hole-in-array/ast.json +++ b/test/fixtures/ast/hole-in-array/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/html-entities-in-static-places/ast.json b/test/fixtures/ast/html-entities-in-static-places/ast.json index a9c98c69..1959d1b0 100644 --- a/test/fixtures/ast/html-entities-in-static-places/ast.json +++ b/test/fixtures/ast/html-entities-in-static-places/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/html-entities-lone-amp/ast.json b/test/fixtures/ast/html-entities-lone-amp/ast.json index 53e24b47..1714f23d 100644 --- a/test/fixtures/ast/html-entities-lone-amp/ast.json +++ b/test/fixtures/ast/html-entities-lone-amp/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/html-entities-mapping/ast.json b/test/fixtures/ast/html-entities-mapping/ast.json index a4214137..69aab3f9 100644 --- a/test/fixtures/ast/html-entities-mapping/ast.json +++ b/test/fixtures/ast/html-entities-mapping/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/html-entities-numeric/ast.json b/test/fixtures/ast/html-entities-numeric/ast.json index 4c5e77c8..0480cae5 100644 --- a/test/fixtures/ast/html-entities-numeric/ast.json +++ b/test/fixtures/ast/html-entities-numeric/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/html-entities-special-in-attributes/ast.json b/test/fixtures/ast/html-entities-special-in-attributes/ast.json index ef52f027..23c8c433 100644 --- a/test/fixtures/ast/html-entities-special-in-attributes/ast.json +++ b/test/fixtures/ast/html-entities-special-in-attributes/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/html-entities-surrogate-pair-and-expression/ast.json b/test/fixtures/ast/html-entities-surrogate-pair-and-expression/ast.json index 3cf43b01..a499ff27 100644 --- a/test/fixtures/ast/html-entities-surrogate-pair-and-expression/ast.json +++ b/test/fixtures/ast/html-entities-surrogate-pair-and-expression/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/html-entities-with-line-terminators/ast.json b/test/fixtures/ast/html-entities-with-line-terminators/ast.json index ff6d2941..18b3e947 100644 --- a/test/fixtures/ast/html-entities-with-line-terminators/ast.json +++ b/test/fixtures/ast/html-entities-with-line-terminators/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/html-entities/ast.json b/test/fixtures/ast/html-entities/ast.json index 0d9c4201..98faf0df 100644 --- a/test/fixtures/ast/html-entities/ast.json +++ b/test/fixtures/ast/html-entities/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/input-component/ast.json b/test/fixtures/ast/input-component/ast.json index 422c77da..0e782a38 100644 --- a/test/fixtures/ast/input-component/ast.json +++ b/test/fixtures/ast/input-component/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/link-component/ast.json b/test/fixtures/ast/link-component/ast.json index f24d7201..a0ea7e45 100644 --- a/test/fixtures/ast/link-component/ast.json +++ b/test/fixtures/ast/link-component/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/math/ast.json b/test/fixtures/ast/math/ast.json index dacb9357..eaac83cf 100644 --- a/test/fixtures/ast/math/ast.json +++ b/test/fixtures/ast/math/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/multiple-scripts-11/ast.json b/test/fixtures/ast/multiple-scripts-11/ast.json index 87bdc971..0e4de961 100644 --- a/test/fixtures/ast/multiple-scripts-11/ast.json +++ b/test/fixtures/ast/multiple-scripts-11/ast.json @@ -175,7 +175,8 @@ ], "value": "vue", "raw": "'vue'" - } + }, + "attributes": [] }, { "type": "ImportDeclaration", @@ -276,7 +277,8 @@ ], "value": "vuex", "raw": "'vuex'" - } + }, + "attributes": [] }, { "type": "ExportDefaultDeclaration", diff --git a/test/fixtures/ast/multiple-scripts-2/ast.json b/test/fixtures/ast/multiple-scripts-2/ast.json index 3a94a274..345cdacc 100644 --- a/test/fixtures/ast/multiple-scripts-2/ast.json +++ b/test/fixtures/ast/multiple-scripts-2/ast.json @@ -96,7 +96,8 @@ ], "value": "./a", "raw": "'./a'" - } + }, + "attributes": [] }, { "type": "ImportDeclaration", @@ -177,7 +178,8 @@ ], "value": "./a", "raw": "'./a'" - } + }, + "attributes": [] }, { "type": "VariableDeclaration", diff --git a/test/fixtures/ast/multiple-scripts-5/ast.json b/test/fixtures/ast/multiple-scripts-5/ast.json index 0c0ff3e9..6b026649 100644 --- a/test/fixtures/ast/multiple-scripts-5/ast.json +++ b/test/fixtures/ast/multiple-scripts-5/ast.json @@ -199,7 +199,8 @@ ], "value": "./Foo.vue", "raw": "'./Foo.vue'" - } + }, + "attributes": [] }, { "type": "VariableDeclaration", diff --git a/test/fixtures/ast/multiple-scripts-7/ast.json b/test/fixtures/ast/multiple-scripts-7/ast.json index 6689eb9a..eb6d9eae 100644 --- a/test/fixtures/ast/multiple-scripts-7/ast.json +++ b/test/fixtures/ast/multiple-scripts-7/ast.json @@ -199,7 +199,8 @@ ], "value": "./MyComponent1.vue", "raw": "'./MyComponent1.vue'" - } + }, + "attributes": [] }, { "type": "VariableDeclaration", @@ -362,7 +363,8 @@ ], "value": "./MyComponent2.vue", "raw": "'./MyComponent2.vue'" - } + }, + "attributes": [] }, { "type": "VariableDeclaration", diff --git a/test/fixtures/ast/multiple-scripts-8/ast.json b/test/fixtures/ast/multiple-scripts-8/ast.json index ba64ede6..2fc13bc3 100644 --- a/test/fixtures/ast/multiple-scripts-8/ast.json +++ b/test/fixtures/ast/multiple-scripts-8/ast.json @@ -261,7 +261,8 @@ ], "value": "./MyComponent1.vue", "raw": "'./MyComponent1.vue'" - } + }, + "attributes": [] }, { "type": "VariableDeclaration", @@ -424,7 +425,8 @@ ], "value": "./MyComponent2.vue", "raw": "'./MyComponent2.vue'" - } + }, + "attributes": [] }, { "type": "VariableDeclaration", diff --git a/test/fixtures/ast/multiple-scripts-with-export02/ast.json b/test/fixtures/ast/multiple-scripts-with-export02/ast.json index 2d8fc7a3..0d545d97 100644 --- a/test/fixtures/ast/multiple-scripts-with-export02/ast.json +++ b/test/fixtures/ast/multiple-scripts-with-export02/ast.json @@ -178,7 +178,8 @@ ], "value": "a", "raw": "'a'" - } + }, + "attributes": [] }, { "type": "VariableDeclaration", @@ -444,7 +445,8 @@ ], "value": "a", "raw": "'a'" - } + }, + "attributes": [] }, { "type": "VariableDeclaration", @@ -567,7 +569,8 @@ ], "value": "foo", "raw": "'foo'" - } + }, + "attributes": [] }, { "type": "VariableDeclaration", diff --git a/test/fixtures/ast/multiple-scripts-with-export03/ast.json b/test/fixtures/ast/multiple-scripts-with-export03/ast.json index 449ffd40..fff01a7e 100644 --- a/test/fixtures/ast/multiple-scripts-with-export03/ast.json +++ b/test/fixtures/ast/multiple-scripts-with-export03/ast.json @@ -260,7 +260,8 @@ ], "value": "foo", "raw": "'foo'" - } + }, + "attributes": [] }, { "type": "ExportAllDeclaration", @@ -320,7 +321,8 @@ ], "value": "foo", "raw": "'foo'" - } + }, + "attributes": [] }, { "type": "ImportDeclaration", @@ -401,7 +403,8 @@ ], "value": "foo", "raw": "'foo'" - } + }, + "attributes": [] }, { "type": "VariableDeclaration", @@ -585,7 +588,8 @@ ], "value": "foo", "raw": "'foo'" - } + }, + "attributes": [] }, { "type": "VariableDeclaration", @@ -748,7 +752,8 @@ ], "value": "foo", "raw": "'foo'" - } + }, + "attributes": [] }, { "type": "ExportNamedDeclaration", @@ -850,7 +855,8 @@ ], "value": "foo", "raw": "'foo'" - } + }, + "attributes": [] }, { "type": "VariableDeclaration", diff --git a/test/fixtures/ast/multiple-scripts-with-export04/ast.json b/test/fixtures/ast/multiple-scripts-with-export04/ast.json index c95d2858..c7b5583d 100644 --- a/test/fixtures/ast/multiple-scripts-with-export04/ast.json +++ b/test/fixtures/ast/multiple-scripts-with-export04/ast.json @@ -302,7 +302,8 @@ ], "value": "./MyComponent1.vue", "raw": "'./MyComponent1.vue'" - } + }, + "attributes": [] }, { "type": "VariableDeclaration", diff --git a/test/fixtures/ast/multiple-scripts-with-ts/ast.json b/test/fixtures/ast/multiple-scripts-with-ts/ast.json index 0f45883f..7a9a4eb9 100644 --- a/test/fixtures/ast/multiple-scripts-with-ts/ast.json +++ b/test/fixtures/ast/multiple-scripts-with-ts/ast.json @@ -1,42 +1,48 @@ { "type": "Program", + "range": [ + 9, + 98 + ], "body": [ { "type": "ExpressionStatement", "expression": { "type": "CallExpression", + "arguments": [], "callee": { "type": "Identifier", + "decorators": [], "name": "performGlobalSideEffect", + "optional": false, "range": [ 9, 32 ], "loc": { - "start": { - "line": 2, - "column": 0 - }, "end": { "line": 2, "column": 23 + }, + "start": { + "line": 2, + "column": 0 } } }, - "arguments": [], "optional": false, "range": [ 9, 34 ], "loc": { - "start": { - "line": 2, - "column": 0 - }, "end": { "line": 2, "column": 25 + }, + "start": { + "line": 2, + "column": 0 } } }, @@ -45,57 +51,65 @@ 34 ], "loc": { - "start": { - "line": 2, - "column": 0 - }, "end": { "line": 2, "column": 25 + }, + "start": { + "line": 2, + "column": 0 } } }, { "type": "ExportNamedDeclaration", + "range": [ + 36, + 58 + ], + "attributes": [], "declaration": { "type": "VariableDeclaration", "declarations": [ { "type": "VariableDeclarator", + "definite": false, "id": { "type": "Identifier", + "decorators": [], "name": "named", + "optional": false, "range": [ 49, 54 ], "loc": { - "start": { - "line": 4, - "column": 13 - }, "end": { "line": 4, "column": 18 + }, + "start": { + "line": 4, + "column": 13 } } }, "init": { "type": "Literal", - "value": 1, "raw": "1", + "value": 1, "range": [ 57, 58 ], "loc": { - "start": { - "line": 4, - "column": 21 - }, "end": { "line": 4, "column": 22 + }, + "start": { + "line": 4, + "column": 21 } } }, @@ -104,49 +118,45 @@ 58 ], "loc": { - "start": { - "line": 4, - "column": 13 - }, "end": { "line": 4, "column": 22 + }, + "start": { + "line": 4, + "column": 13 } } } ], + "declare": false, "kind": "const", "range": [ 43, 58 ], "loc": { - "start": { - "line": 4, - "column": 7 - }, "end": { "line": 4, "column": 22 + }, + "start": { + "line": 4, + "column": 7 } } }, - "specifiers": [], - "source": null, "exportKind": "value", - "range": [ - 36, - 58 - ], - "assertions": [], + "source": null, + "specifiers": [], "loc": { - "start": { - "line": 4, - "column": 0 - }, "end": { "line": 4, "column": 22 + }, + "start": { + "line": 4, + "column": 0 } } }, @@ -155,40 +165,43 @@ "declarations": [ { "type": "VariableDeclarator", + "definite": false, "id": { "type": "Identifier", + "decorators": [], "name": "count", + "optional": false, "range": [ 89, 94 ], "loc": { - "start": { - "line": 8, - "column": 4 - }, "end": { "line": 8, "column": 9 + }, + "start": { + "line": 8, + "column": 4 } } }, "init": { "type": "Literal", - "value": 0, "raw": "0", + "value": 0, "range": [ 97, 98 ], "loc": { - "start": { - "line": 8, - "column": 12 - }, "end": { "line": 8, "column": 13 + }, + "start": { + "line": 8, + "column": 12 } } }, @@ -197,49 +210,37 @@ 98 ], "loc": { - "start": { - "line": 8, - "column": 4 - }, "end": { "line": 8, "column": 13 + }, + "start": { + "line": 8, + "column": 4 } } } ], + "declare": false, "kind": "let", "range": [ 85, 98 ], "loc": { - "start": { - "line": 8, - "column": 0 - }, "end": { "line": 8, "column": 13 + }, + "start": { + "line": 8, + "column": 0 } } } ], + "comments": [], "sourceType": "module", - "range": [ - 9, - 98 - ], - "loc": { - "start": { - "line": 2, - "column": 0 - }, - "end": { - "line": 8, - "column": 13 - } - }, "tokens": [ { "type": "Punctuator", @@ -261,147 +262,147 @@ }, { "type": "Identifier", - "value": "performGlobalSideEffect", + "loc": { + "end": { + "line": 2, + "column": 23 + }, + "start": { + "line": 2, + "column": 0 + } + }, "range": [ 9, 32 ], + "value": "performGlobalSideEffect" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 0 + "column": 24 }, - "end": { + "start": { "line": 2, "column": 23 } - } - }, - { - "type": "Punctuator", - "value": "(", + }, "range": [ 32, 33 ], + "value": "(" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 23 + "column": 25 }, - "end": { + "start": { "line": 2, "column": 24 } - } - }, - { - "type": "Punctuator", - "value": ")", + }, "range": [ 33, 34 ], - "loc": { - "start": { - "line": 2, - "column": 24 - }, - "end": { - "line": 2, - "column": 25 - } - } + "value": ")" }, { "type": "Keyword", - "value": "export", + "loc": { + "end": { + "line": 4, + "column": 6 + }, + "start": { + "line": 4, + "column": 0 + } + }, "range": [ 36, 42 ], + "value": "export" + }, + { + "type": "Keyword", "loc": { - "start": { + "end": { "line": 4, - "column": 0 + "column": 12 }, - "end": { + "start": { "line": 4, - "column": 6 + "column": 7 } - } - }, - { - "type": "Keyword", - "value": "const", + }, "range": [ 43, 48 ], + "value": "const" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 4, - "column": 7 + "column": 18 }, - "end": { + "start": { "line": 4, - "column": 12 + "column": 13 } - } - }, - { - "type": "Identifier", - "value": "named", + }, "range": [ 49, 54 ], + "value": "named" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 4, - "column": 13 + "column": 20 }, - "end": { + "start": { "line": 4, - "column": 18 + "column": 19 } - } - }, - { - "type": "Punctuator", - "value": "=", + }, "range": [ 55, 56 ], + "value": "=" + }, + { + "type": "Numeric", "loc": { - "start": { + "end": { "line": 4, - "column": 19 + "column": 22 }, - "end": { + "start": { "line": 4, - "column": 20 + "column": 21 } - } - }, - { - "type": "Numeric", - "value": "1", + }, "range": [ 57, 58 ], - "loc": { - "start": { - "line": 4, - "column": 21 - }, - "end": { - "line": 4, - "column": 22 - } - } + "value": "1" }, { "type": "Punctuator", @@ -441,75 +442,75 @@ }, { "type": "Keyword", - "value": "let", + "loc": { + "end": { + "line": 8, + "column": 3 + }, + "start": { + "line": 8, + "column": 0 + } + }, "range": [ 85, 88 ], + "value": "let" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 8, - "column": 0 + "column": 9 }, - "end": { + "start": { "line": 8, - "column": 3 + "column": 4 } - } - }, - { - "type": "Identifier", - "value": "count", + }, "range": [ 89, 94 ], + "value": "count" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 8, - "column": 4 + "column": 11 }, - "end": { + "start": { "line": 8, - "column": 9 + "column": 10 } - } - }, - { - "type": "Punctuator", - "value": "=", + }, "range": [ 95, 96 ], + "value": "=" + }, + { + "type": "Numeric", "loc": { - "start": { + "end": { "line": 8, - "column": 10 + "column": 13 }, - "end": { + "start": { "line": 8, - "column": 11 + "column": 12 } - } - }, - { - "type": "Numeric", - "value": "0", + }, "range": [ 97, 98 ], - "loc": { - "start": { - "line": 8, - "column": 12 - }, - "end": { - "line": 8, - "column": 13 - } - } + "value": "0" }, { "type": "Punctuator", @@ -530,5 +531,14 @@ "value": "</script>" } ], - "comments": [] + "loc": { + "end": { + "line": 8, + "column": 13 + }, + "start": { + "line": 2, + "column": 0 + } + } } \ No newline at end of file diff --git a/test/fixtures/ast/mustache-errors-opt-interpolation-as-non-html/ast.json b/test/fixtures/ast/mustache-errors-opt-interpolation-as-non-html/ast.json index 712ef57e..3d5e6b8a 100644 --- a/test/fixtures/ast/mustache-errors-opt-interpolation-as-non-html/ast.json +++ b/test/fixtures/ast/mustache-errors-opt-interpolation-as-non-html/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/mustache-errors/ast.json b/test/fixtures/ast/mustache-errors/ast.json index 7d1a3129..9fc7248b 100644 --- a/test/fixtures/ast/mustache-errors/ast.json +++ b/test/fixtures/ast/mustache-errors/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/mustache-in-escape-opt-interpolation-as-non-html/ast.json b/test/fixtures/ast/mustache-in-escape-opt-interpolation-as-non-html/ast.json index 0aa3bd99..b7b14002 100644 --- a/test/fixtures/ast/mustache-in-escape-opt-interpolation-as-non-html/ast.json +++ b/test/fixtures/ast/mustache-in-escape-opt-interpolation-as-non-html/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/mustache-in-lt-gt-opt-interpolation-as-non-html-false/ast.json b/test/fixtures/ast/mustache-in-lt-gt-opt-interpolation-as-non-html-false/ast.json index 5f07b6d3..e93aa749 100644 --- a/test/fixtures/ast/mustache-in-lt-gt-opt-interpolation-as-non-html-false/ast.json +++ b/test/fixtures/ast/mustache-in-lt-gt-opt-interpolation-as-non-html-false/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/mustache-in-lt-gt-opt-interpolation-as-non-html/ast.json b/test/fixtures/ast/mustache-in-lt-gt-opt-interpolation-as-non-html/ast.json index d039a691..e2f24c2d 100644 --- a/test/fixtures/ast/mustache-in-lt-gt-opt-interpolation-as-non-html/ast.json +++ b/test/fixtures/ast/mustache-in-lt-gt-opt-interpolation-as-non-html/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/mustache-in-lt-gt/ast.json b/test/fixtures/ast/mustache-in-lt-gt/ast.json index d039a691..e2f24c2d 100644 --- a/test/fixtures/ast/mustache-in-lt-gt/ast.json +++ b/test/fixtures/ast/mustache-in-lt-gt/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/mustache-not-closed-opt-interpolation-as-non-html-false/ast.json b/test/fixtures/ast/mustache-not-closed-opt-interpolation-as-non-html-false/ast.json index 7b15f10c..381c58cc 100644 --- a/test/fixtures/ast/mustache-not-closed-opt-interpolation-as-non-html-false/ast.json +++ b/test/fixtures/ast/mustache-not-closed-opt-interpolation-as-non-html-false/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/mustache-not-closed/ast.json b/test/fixtures/ast/mustache-not-closed/ast.json index 4f81aa1b..87c10c14 100644 --- a/test/fixtures/ast/mustache-not-closed/ast.json +++ b/test/fixtures/ast/mustache-not-closed/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { @@ -1001,10 +1001,10 @@ "column": 11 }, { - "message": "Unexpected end of expression.", - "index": 47, + "message": "Assigning to rvalue", + "index": 36, "lineNumber": 3, - "column": 22 + "column": 11 }, { "message": "Unterminated regular expression", diff --git a/test/fixtures/ast/mustache-with-space/ast.json b/test/fixtures/ast/mustache-with-space/ast.json index 91a6594e..7abbc283 100644 --- a/test/fixtures/ast/mustache-with-space/ast.json +++ b/test/fixtures/ast/mustache-with-space/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { 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 e4419dca..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": "</script>" } ], - "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,46 +615,62 @@ 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 } } }, @@ -663,19 +681,21 @@ { "id": { "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 } } }, @@ -686,19 +706,21 @@ { "id": { "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 } } }, @@ -709,19 +731,21 @@ { "id": { "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 } } }, @@ -843,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": "</script>" } ], - "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 8ad44185..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,46 +226,62 @@ 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 } } }, @@ -282,19 +292,21 @@ { "id": { "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 } } }, @@ -305,19 +317,21 @@ { "id": { "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 } } }, @@ -328,19 +342,21 @@ { "id": { "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 } } }, @@ -462,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/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..bc1794e2 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": { 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 index 6d83d037..5f70958e 100644 --- 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 @@ -1,21 +1,12 @@ { "type": "Program", - "body": [], - "sourceType": "module", "range": [ 116, 116 ], - "loc": { - "start": { - "line": 8, - "column": 0 - }, - "end": { - "line": 8, - "column": 0 - } - }, + "body": [], + "comments": [], + "sourceType": "module", "tokens": [ { "type": "Punctuator", @@ -54,7 +45,16 @@ "value": "</script>" } ], - "comments": [], + "loc": { + "end": { + "line": 8, + "column": 0 + }, + "start": { + "line": 8, + "column": 0 + } + }, "templateBody": { "type": "VElement", "range": [ @@ -187,120 +187,68 @@ }, "expression": { "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "JSON", - "range": [ - 32, - 36 - ], - "loc": { - "start": { - "line": 3, - "column": 11 - }, - "end": { - "line": 3, - "column": 15 - } - } - }, - "property": { - "type": "Identifier", - "name": "stringify", - "range": [ - 37, - 46 - ], - "loc": { - "start": { - "line": 3, - "column": 16 - }, - "end": { - "line": 3, - "column": 25 - } - } - }, - "computed": false, - "optional": false, - "range": [ - 32, - 46 - ], - "loc": { - "start": { - "line": 3, - "column": 11 - }, - "end": { - "line": 3, - "column": 25 - } - } - }, "arguments": [ { "type": "ObjectExpression", "properties": [ { "type": "Property", + "computed": false, "key": { "type": "Identifier", + "decorators": [], "name": "test", + "optional": false, "range": [ 49, 53 ], "loc": { - "start": { - "line": 3, - "column": 28 - }, "end": { "line": 3, "column": 32 + }, + "start": { + "line": 3, + "column": 28 } } }, + "kind": "init", + "method": false, + "optional": false, + "shorthand": false, "value": { "type": "Literal", - "value": "test", "raw": "'test'", + "value": "test", "range": [ 55, 61 ], "loc": { - "start": { - "line": 3, - "column": 34 - }, "end": { "line": 3, "column": 40 + }, + "start": { + "line": 3, + "column": 34 } } }, - "computed": false, - "method": false, - "shorthand": false, - "kind": "init", "range": [ 49, 61 ], "loc": { - "start": { - "line": 3, - "column": 28 - }, "end": { "line": 3, "column": 40 + }, + "start": { + "line": 3, + "column": 28 } } } @@ -310,30 +258,89 @@ 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": 41 + "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": { - "start": { - "line": 3, - "column": 11 - }, "end": { "line": 3, "column": 42 + }, + "start": { + "line": 3, + "column": 11 } } }, @@ -341,19 +348,21 @@ { "id": { "type": "Identifier", + "decorators": [], "name": "JSON", + "optional": false, "range": [ 32, 36 ], "loc": { - "start": { - "line": 3, - "column": 11 - }, "end": { "line": 3, "column": 15 + }, + "start": { + "line": 3, + "column": 11 } } }, @@ -567,183 +576,183 @@ }, { "type": "Identifier", - "value": "JSON", + "loc": { + "end": { + "line": 3, + "column": 15 + }, + "start": { + "line": 3, + "column": 11 + } + }, "range": [ 32, 36 ], + "value": "JSON" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 3, - "column": 11 + "column": 16 }, - "end": { + "start": { "line": 3, "column": 15 } - } - }, - { - "type": "Punctuator", - "value": ".", + }, "range": [ 36, 37 ], + "value": "." + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 3, - "column": 15 + "column": 25 }, - "end": { + "start": { "line": 3, "column": 16 } - } - }, - { - "type": "Identifier", - "value": "stringify", + }, "range": [ 37, 46 ], + "value": "stringify" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 3, - "column": 16 + "column": 26 }, - "end": { + "start": { "line": 3, "column": 25 } - } - }, - { - "type": "Punctuator", - "value": "(", + }, "range": [ 46, 47 ], + "value": "(" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 3, - "column": 25 + "column": 27 }, - "end": { + "start": { "line": 3, "column": 26 } - } - }, - { - "type": "Punctuator", - "value": "{", + }, "range": [ 47, 48 ], + "value": "{" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 3, - "column": 26 + "column": 32 }, - "end": { + "start": { "line": 3, - "column": 27 + "column": 28 } - } - }, - { - "type": "Identifier", - "value": "test", + }, "range": [ 49, 53 ], + "value": "test" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 3, - "column": 28 + "column": 33 }, - "end": { + "start": { "line": 3, "column": 32 } - } - }, - { - "type": "Punctuator", - "value": ":", + }, "range": [ 53, 54 ], + "value": ":" + }, + { + "type": "String", "loc": { - "start": { + "end": { "line": 3, - "column": 32 + "column": 40 }, - "end": { + "start": { "line": 3, - "column": 33 + "column": 34 } - } - }, - { - "type": "String", - "value": "'test'", + }, "range": [ 55, 61 ], + "value": "'test'" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 3, - "column": 34 + "column": 41 }, - "end": { + "start": { "line": 3, "column": 40 } - } - }, - { - "type": "Punctuator", - "value": "}", + }, "range": [ 61, 62 ], + "value": "}" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 3, - "column": 40 + "column": 42 }, - "end": { + "start": { "line": 3, "column": 41 } - } - }, - { - "type": "Punctuator", - "value": ")", + }, "range": [ 62, 63 ], - "loc": { - "start": { - "line": 3, - "column": 41 - }, - "end": { - "line": 3, - "column": 42 - } - } + "value": ")" }, { "type": "VExpressionEnd", 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 index d82fa33c..3849ae94 100644 --- 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 @@ -1,6 +1,210 @@ { "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": [], @@ -13,6 +217,18 @@ "defs": [], "references": [] }, + { + "name": "DecoratorMetadataObject", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "DecoratorMetadata", + "identifiers": [], + "defs": [], + "references": [] + }, { "name": "ClassDecoratorContext", "identifiers": [], @@ -62,469 +278,499 @@ "references": [] }, { - "name": "ClassDecorator", + "name": "IteratorYieldResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "PropertyDecorator", + "name": "IteratorReturnResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "MethodDecorator", + "name": "IteratorResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "ParameterDecorator", + "name": "Iterable", "identifiers": [], "defs": [], "references": [] }, { - "name": "Symbol", + "name": "IterableIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "PropertyKey", + "name": "BuiltinIteratorReturn", "identifiers": [], "defs": [], "references": [] }, { - "name": "PropertyDescriptor", + "name": "ArrayIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "PropertyDescriptorMap", + "name": "Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Object", + "name": "ReadonlyArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "ObjectConstructor", + "name": "IArguments", "identifiers": [], "defs": [], "references": [] }, { - "name": "Function", + "name": "MapIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "FunctionConstructor", + "name": "Map", "identifiers": [], "defs": [], "references": [] }, { - "name": "ThisParameterType", + "name": "ReadonlyMap", "identifiers": [], "defs": [], "references": [] }, { - "name": "OmitThisParameter", + "name": "WeakMap", "identifiers": [], "defs": [], "references": [] }, { - "name": "CallableFunction", + "name": "WeakMapConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "NewableFunction", + "name": "SetIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "IArguments", + "name": "SetConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "String", + "name": "WeakSet", "identifiers": [], "defs": [], "references": [] }, { - "name": "StringConstructor", + "name": "WeakSetConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Boolean", + "name": "Promise", "identifiers": [], "defs": [], "references": [] }, { - "name": "BooleanConstructor", + "name": "StringIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "Number", + "name": "Int8Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "NumberConstructor", + "name": "Int8ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "TemplateStringsArray", + "name": "Uint8Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "ImportMeta", + "name": "Uint8ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ImportCallOptions", + "name": "Uint8ClampedArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "ImportAssertions", + "name": "Uint8ClampedArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Math", + "name": "Int16Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Date", + "name": "Int16ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "DateConstructor", + "name": "Uint16Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "RegExpMatchArray", + "name": "Uint16ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "RegExpExecArray", + "name": "Int32Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "RegExp", + "name": "Int32ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "RegExpConstructor", + "name": "Uint32Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Error", + "name": "Uint32ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ErrorConstructor", + "name": "Float32Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "EvalError", + "name": "Float32ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "EvalErrorConstructor", + "name": "Float64Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "RangeError", + "name": "Float64ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "RangeErrorConstructor", + "name": "AsyncIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReferenceError", + "name": "AsyncIterable", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReferenceErrorConstructor", + "name": "AsyncIterableIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "SyntaxError", + "name": "BigInt64Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "SyntaxErrorConstructor", + "name": "BigUint64Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "TypeError", + "name": "WeakKeyTypes", "identifiers": [], "defs": [], "references": [] }, { - "name": "TypeErrorConstructor", + "name": "BigIntToLocaleStringOptions", "identifiers": [], "defs": [], "references": [] }, { - "name": "URIError", + "name": "BigInt", "identifiers": [], "defs": [], "references": [] }, { - "name": "URIErrorConstructor", + "name": "BigIntConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "JSON", + "name": "BigInt64ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReadonlyArray", + "name": "BigUint64ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ConcatArray", + "name": "ErrorOptions", "identifiers": [], "defs": [], "references": [] }, { - "name": "Array", + "name": "Error", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayConstructor", + "name": "ErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "TypedPropertyDescriptor", + "name": "EvalErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "PromiseConstructorLike", + "name": "RangeErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "PromiseLike", + "name": "ReferenceErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Promise", + "name": "SyntaxErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Awaited", + "name": "TypeErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayLike", + "name": "URIErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Partial", + "name": "AggregateErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Required", + "name": "RegExpMatchArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "Readonly", + "name": "RegExpExecArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "Pick", + "name": "RegExpIndicesArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "Record", + "name": "AggregateError", "identifiers": [], "defs": [], "references": [] }, { - "name": "Exclude", + "name": "WeakRef", "identifiers": [], "defs": [], "references": [] }, { - "name": "Extract", + "name": "WeakRefConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Omit", + "name": "FinalizationRegistry", "identifiers": [], "defs": [], "references": [] }, { - "name": "NonNullable", + "name": "FinalizationRegistryConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Parameters", + "name": "Date", "identifiers": [], "defs": [], "references": [] }, { - "name": "ConstructorParameters", + "name": "Number", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReturnType", + "name": "PromiseFulfilledResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "InstanceType", + "name": "PromiseRejectedResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uppercase", + "name": "PromiseSettledResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "Lowercase", + "name": "RegExpStringIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "Capitalize", + "name": "Symbol", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uncapitalize", + "name": "JSON", "identifiers": [], "defs": [], "references": [] }, { - "name": "ThisType", + "name": "GeneratorFunction", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayBuffer", + "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": [] @@ -536,343 +782,373 @@ "references": [] }, { - "name": "ArrayBufferLike", + "name": "PropertyKey", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayBufferConstructor", + "name": "PropertyDescriptor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayBufferView", + "name": "PropertyDescriptorMap", "identifiers": [], "defs": [], "references": [] }, { - "name": "DataView", + "name": "Object", "identifiers": [], "defs": [], "references": [] }, { - "name": "DataViewConstructor", + "name": "FunctionConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int8Array", + "name": "ThisParameterType", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int8ArrayConstructor", + "name": "OmitThisParameter", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint8Array", + "name": "CallableFunction", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint8ArrayConstructor", + "name": "NewableFunction", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint8ClampedArray", + "name": "StringConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint8ClampedArrayConstructor", + "name": "Boolean", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int16Array", + "name": "BooleanConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int16ArrayConstructor", + "name": "NumberConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint16Array", + "name": "TemplateStringsArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint16ArrayConstructor", + "name": "ImportMeta", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int32Array", + "name": "ImportCallOptions", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int32ArrayConstructor", + "name": "ImportAssertions", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint32Array", + "name": "ImportAttributes", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint32ArrayConstructor", + "name": "EvalError", "identifiers": [], "defs": [], "references": [] }, { - "name": "Float32Array", + "name": "RangeError", "identifiers": [], "defs": [], "references": [] }, { - "name": "Float32ArrayConstructor", + "name": "ReferenceError", "identifiers": [], "defs": [], "references": [] }, { - "name": "Float64Array", + "name": "SyntaxError", "identifiers": [], "defs": [], "references": [] }, { - "name": "Float64ArrayConstructor", + "name": "TypeError", "identifiers": [], "defs": [], "references": [] }, { - "name": "Intl", + "name": "URIError", "identifiers": [], "defs": [], "references": [] }, { - "name": "Map", + "name": "ConcatArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "MapConstructor", + "name": "TypedPropertyDescriptor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReadonlyMap", + "name": "PromiseConstructorLike", "identifiers": [], "defs": [], "references": [] }, { - "name": "WeakMap", + "name": "PromiseLike", "identifiers": [], "defs": [], "references": [] }, { - "name": "WeakMapConstructor", + "name": "Awaited", "identifiers": [], "defs": [], "references": [] }, { - "name": "Set", + "name": "ArrayLike", "identifiers": [], "defs": [], "references": [] }, { - "name": "SetConstructor", + "name": "Partial", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReadonlySet", + "name": "Required", "identifiers": [], "defs": [], "references": [] }, { - "name": "WeakSet", + "name": "Readonly", "identifiers": [], "defs": [], "references": [] }, { - "name": "WeakSetConstructor", + "name": "Pick", "identifiers": [], "defs": [], "references": [] }, { - "name": "SymbolConstructor", + "name": "Record", "identifiers": [], "defs": [], "references": [] }, { - "name": "IteratorYieldResult", + "name": "Exclude", "identifiers": [], "defs": [], "references": [] }, { - "name": "IteratorReturnResult", + "name": "Extract", "identifiers": [], "defs": [], "references": [] }, { - "name": "IteratorResult", + "name": "Omit", "identifiers": [], "defs": [], "references": [] }, { - "name": "Iterator", + "name": "NonNullable", "identifiers": [], "defs": [], "references": [] }, { - "name": "Iterable", + "name": "Parameters", "identifiers": [], "defs": [], "references": [] }, { - "name": "IterableIterator", + "name": "ConstructorParameters", "identifiers": [], "defs": [], "references": [] }, { - "name": "PromiseConstructor", + "name": "ReturnType", "identifiers": [], "defs": [], "references": [] }, { - "name": "Generator", + "name": "InstanceType", "identifiers": [], "defs": [], "references": [] }, { - "name": "GeneratorFunction", + "name": "Uppercase", "identifiers": [], "defs": [], "references": [] }, { - "name": "GeneratorFunctionConstructor", + "name": "Lowercase", "identifiers": [], "defs": [], "references": [] }, { - "name": "ProxyHandler", + "name": "Capitalize", "identifiers": [], "defs": [], "references": [] }, { - "name": "ProxyConstructor", + "name": "Uncapitalize", "identifiers": [], "defs": [], "references": [] }, { - "name": "Reflect", + "name": "NoInfer", "identifiers": [], "defs": [], "references": [] }, { - "name": "SharedArrayBuffer", + "name": "ThisType", "identifiers": [], "defs": [], "references": [] }, { - "name": "SharedArrayBufferConstructor", + "name": "WeakKey", "identifiers": [], "defs": [], "references": [] }, { - "name": "Atomics", + "name": "ArrayBufferLike", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncIterator", + "name": "ArrayBufferView", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncIterable", + "name": "DataViewConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncIterableIterator", + "name": "Generator", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncGenerator", + "name": "GeneratorFunctionConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncGeneratorFunction", + "name": "ProxyHandler", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncGeneratorFunctionConstructor", + "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": [] 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 index 7159ba5a..7f661a33 100644 --- 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 @@ -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/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-shorthand02-options/scope.json b/test/fixtures/ast/v-bind-same-name-shorthand02-options/scope.json index 19cca0f2..66d2c7f4 100644 --- a/test/fixtures/ast/v-bind-same-name-shorthand02-options/scope.json +++ b/test/fixtures/ast/v-bind-same-name-shorthand02-options/scope.json @@ -4,25 +4,17 @@ "references": [], "childScopes": [ { - "type": "module", - "variables": [], - "references": [], - "childScopes": [ + "type": "function", + "variables": [ { - "type": "function", - "variables": [ - { - "name": "arguments", - "identifiers": [], - "defs": [], - "references": [] - } - ], - "references": [], - "childScopes": [], - "through": [] + "name": "arguments", + "identifiers": [], + "defs": [], + "references": [] } ], + "references": [], + "childScopes": [], "through": [] } ], 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 index 19cca0f2..66d2c7f4 100644 --- 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 @@ -4,25 +4,17 @@ "references": [], "childScopes": [ { - "type": "module", - "variables": [], - "references": [], - "childScopes": [ + "type": "function", + "variables": [ { - "type": "function", - "variables": [ - { - "name": "arguments", - "identifiers": [], - "defs": [], - "references": [] - } - ], - "references": [], - "childScopes": [], - "through": [] + "name": "arguments", + "identifiers": [], + "defs": [], + "references": [] } ], + "references": [], + "childScopes": [], "through": [] } ], 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..ddf0f4c2 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": { 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 index 17fa8149..76c9ea47 100644 --- a/test/fixtures/ast/v-on-async-arrow-function-expression/ast.json +++ b/test/fixtures/ast/v-on-async-arrow-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-async-function-expression/ast.json b/test/fixtures/ast/v-on-async-function-expression/ast.json index 447b74bf..af3d12eb 100644 --- a/test/fixtures/ast/v-on-async-function-expression/ast.json +++ b/test/fixtures/ast/v-on-async-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-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..1298f1e8 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": { diff --git a/test/fixtures/ast/v-slot-default/ast.json b/test/fixtures/ast/v-slot-default/ast.json index f1ce9aee..835b83b8 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": { diff --git a/test/fixtures/ast/v-slot-named-shorthand/ast.json b/test/fixtures/ast/v-slot-named-shorthand/ast.json index 4a94e5d4..a6a99b82 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": { diff --git a/test/fixtures/ast/v-slot-named/ast.json b/test/fixtures/ast/v-slot-named/ast.json index 60ab37e6..dcc9961d 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": { diff --git a/test/fixtures/ast/vue3.3-generic-1/ast.json b/test/fixtures/ast/vue3.3-generic-1/ast.json index c00e934a..6c0f8f26 100644 --- a/test/fixtures/ast/vue3.3-generic-1/ast.json +++ b/test/fixtures/ast/vue3.3-generic-1/ast.json @@ -1,45 +1,37 @@ { "type": "Program", + "range": [ + 37, + 60 + ], "body": [ { "type": "ExpressionStatement", "expression": { "type": "CallExpression", + "arguments": [], "callee": { "type": "Identifier", + "decorators": [], "name": "defineProps", + "optional": false, "range": [ 37, 48 ], "loc": { - "start": { - "line": 2, - "column": 0 - }, "end": { "line": 2, "column": 11 + }, + "start": { + "line": 2, + "column": 0 } } }, - "arguments": [], "optional": false, - "range": [ - 37, - 59 - ], - "loc": { - "start": { - "line": 2, - "column": 0 - }, - "end": { - "line": 2, - "column": 22 - } - }, - "typeParameters": { + "typeArguments": { "type": "TSTypeParameterInstantiation", "range": [ 48, @@ -54,32 +46,37 @@ "computed": false, "key": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 50, 53 ], "loc": { - "start": { - "line": 2, - "column": 13 - }, "end": { "line": 2, "column": 16 + }, + "start": { + "line": 2, + "column": 13 } } }, + "optional": false, + "readonly": false, + "static": false, "typeAnnotation": { "type": "TSTypeAnnotation", "loc": { - "start": { - "line": 2, - "column": 16 - }, "end": { "line": 2, "column": 18 + }, + "start": { + "line": 2, + "column": 16 } }, "range": [ @@ -90,19 +87,21 @@ "type": "TSTypeReference", "typeName": { "type": "Identifier", + "decorators": [], "name": "T", + "optional": false, "range": [ 54, 55 ], "loc": { - "start": { - "line": 2, - "column": 17 - }, "end": { "line": 2, "column": 18 + }, + "start": { + "line": 2, + "column": 17 } } }, @@ -111,13 +110,13 @@ 55 ], "loc": { - "start": { - "line": 2, - "column": 17 - }, "end": { "line": 2, "column": 18 + }, + "start": { + "line": 2, + "column": 17 } } } @@ -127,13 +126,13 @@ 55 ], "loc": { - "start": { - "line": 2, - "column": 13 - }, "end": { "line": 2, "column": 18 + }, + "start": { + "line": 2, + "column": 13 } } } @@ -143,27 +142,41 @@ 56 ], "loc": { - "start": { - "line": 2, - "column": 12 - }, "end": { "line": 2, "column": 19 + }, + "start": { + "line": 2, + "column": 12 } } } ], "loc": { - "start": { - "line": 2, - "column": 11 - }, "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": [ @@ -171,32 +184,19 @@ 59 ], "loc": { - "start": { - "line": 2, - "column": 0 - }, "end": { "line": 2, "column": 22 + }, + "start": { + "line": 2, + "column": 0 } } } ], + "comments": [], "sourceType": "module", - "range": [ - 37, - 60 - ], - "loc": { - "start": { - "line": 2, - "column": 0 - }, - "end": { - "line": 3, - "column": 0 - } - }, "tokens": [ { "type": "Punctuator", @@ -218,183 +218,183 @@ }, { "type": "Identifier", - "value": "defineProps", + "loc": { + "end": { + "line": 2, + "column": 11 + }, + "start": { + "line": 2, + "column": 0 + } + }, "range": [ 37, 48 ], + "value": "defineProps" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 0 + "column": 12 }, - "end": { + "start": { "line": 2, "column": 11 } - } - }, - { - "type": "Punctuator", - "value": "<", + }, "range": [ 48, 49 ], + "value": "<" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 11 + "column": 13 }, - "end": { + "start": { "line": 2, "column": 12 } - } - }, - { - "type": "Punctuator", - "value": "{", + }, "range": [ 49, 50 ], + "value": "{" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 2, - "column": 12 + "column": 16 }, - "end": { + "start": { "line": 2, "column": 13 } - } - }, - { - "type": "Identifier", - "value": "foo", + }, "range": [ 50, 53 ], + "value": "foo" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 13 + "column": 17 }, - "end": { + "start": { "line": 2, "column": 16 } - } - }, - { - "type": "Punctuator", - "value": ":", + }, "range": [ 53, 54 ], + "value": ":" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 2, - "column": 16 + "column": 18 }, - "end": { + "start": { "line": 2, "column": 17 } - } - }, - { - "type": "Identifier", - "value": "T", + }, "range": [ 54, 55 ], + "value": "T" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 17 + "column": 19 }, - "end": { + "start": { "line": 2, "column": 18 } - } - }, - { - "type": "Punctuator", - "value": "}", + }, "range": [ 55, 56 ], + "value": "}" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 18 + "column": 20 }, - "end": { + "start": { "line": 2, "column": 19 } - } - }, - { - "type": "Punctuator", - "value": ">", + }, "range": [ 56, 57 ], + "value": ">" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 19 + "column": 21 }, - "end": { + "start": { "line": 2, "column": 20 } - } - }, - { - "type": "Punctuator", - "value": "(", + }, "range": [ 57, 58 ], + "value": "(" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 20 + "column": 22 }, - "end": { + "start": { "line": 2, "column": 21 } - } - }, - { - "type": "Punctuator", - "value": ")", + }, "range": [ 58, 59 ], - "loc": { - "start": { - "line": 2, - "column": 21 - }, - "end": { - "line": 2, - "column": 22 - } - } + "value": ")" }, { "type": "Punctuator", @@ -415,7 +415,16 @@ "value": "</script>" } ], - "comments": [], + "loc": { + "end": { + "line": 3, + "column": 0 + }, + "start": { + "line": 2, + "column": 0 + } + }, "templateBody": { "type": "VElement", "range": [ @@ -491,19 +500,21 @@ }, "expression": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 83, 86 ], "loc": { - "start": { - "line": 5, - "column": 2 - }, "end": { "line": 5, "column": 5 + }, + "start": { + "line": 5, + "column": 2 } } }, @@ -511,19 +522,21 @@ { "id": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 83, 86 ], "loc": { - "start": { - "line": 5, - "column": 2 - }, "end": { "line": 5, "column": 5 + }, + "start": { + "line": 5, + "column": 2 } } }, @@ -717,21 +730,21 @@ }, { "type": "Identifier", - "value": "T", - "range": [ - 33, - 34 - ], "loc": { - "start": { - "line": 1, - "column": 33 - }, "end": { "line": 1, "column": 34 + }, + "start": { + "line": 1, + "column": 33 } - } + }, + "range": [ + 33, + 34 + ], + "value": "T" }, { "type": "Punctuator", @@ -951,21 +964,21 @@ }, { "type": "Identifier", - "value": "foo", - "range": [ - 83, - 86 - ], "loc": { - "start": { - "line": 5, - "column": 2 - }, "end": { "line": 5, "column": 5 + }, + "start": { + "line": 5, + "column": 2 } - } + }, + "range": [ + 83, + 86 + ], + "value": "foo" }, { "type": "VExpressionEnd", diff --git a/test/fixtures/ast/vue3.3-generic-1/scope.json b/test/fixtures/ast/vue3.3-generic-1/scope.json index f67735c2..cdafa028 100644 --- a/test/fixtures/ast/vue3.3-generic-1/scope.json +++ b/test/fixtures/ast/vue3.3-generic-1/scope.json @@ -2,904 +2,1180 @@ "type": "global", "variables": [ { - "name": "ClassMemberDecoratorContext", + "name": "Intl", "identifiers": [], "defs": [], "references": [] }, { - "name": "DecoratorContext", + "name": "SymbolConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassDecoratorContext", + "name": "Function", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassMethodDecoratorContext", + "name": "Disposable", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassGetterDecoratorContext", + "name": "AsyncDisposable", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassSetterDecoratorContext", + "name": "SuppressedError", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassAccessorDecoratorContext", + "name": "SuppressedErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassAccessorDecoratorTarget", + "name": "DisposableStack", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassAccessorDecoratorResult", + "name": "DisposableStackConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassFieldDecoratorContext", + "name": "AsyncDisposableStack", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassDecorator", + "name": "AsyncDisposableStackConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "PropertyDecorator", + "name": "IteratorObject", "identifiers": [], "defs": [], "references": [] }, { - "name": "MethodDecorator", + "name": "AsyncIteratorObject", "identifiers": [], "defs": [], "references": [] }, { - "name": "ParameterDecorator", + "name": "ReadonlySetLike", "identifiers": [], "defs": [], "references": [] }, { - "name": "Symbol", + "name": "Set", "identifiers": [], "defs": [], "references": [] }, { - "name": "PropertyKey", + "name": "ReadonlySet", "identifiers": [], "defs": [], "references": [] }, { - "name": "PropertyDescriptor", + "name": "ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "PropertyDescriptorMap", + "name": "Iterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "Object", + "name": "IteratorObjectConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ObjectConstructor", + "name": "PromiseConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Function", + "name": "Float16Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "FunctionConstructor", + "name": "Float16ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ThisParameterType", + "name": "Math", "identifiers": [], "defs": [], "references": [] }, { - "name": "OmitThisParameter", + "name": "DataView", "identifiers": [], "defs": [], "references": [] }, { - "name": "CallableFunction", + "name": "ArrayBuffer", "identifiers": [], "defs": [], "references": [] }, { - "name": "NewableFunction", + "name": "ArrayBufferConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "IArguments", + "name": "MapConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "String", + "name": "ObjectConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "StringConstructor", + "name": "PromiseWithResolvers", "identifiers": [], "defs": [], "references": [] }, { - "name": "Boolean", + "name": "RegExp", "identifiers": [], "defs": [], "references": [] }, { - "name": "BooleanConstructor", + "name": "Atomics", "identifiers": [], "defs": [], "references": [] }, { - "name": "Number", + "name": "SharedArrayBuffer", "identifiers": [], "defs": [], "references": [] }, { - "name": "NumberConstructor", + "name": "SharedArrayBufferConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "TemplateStringsArray", + "name": "String", "identifiers": [], "defs": [], "references": [] }, { - "name": "ImportMeta", + "name": "ClassMemberDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "ImportCallOptions", + "name": "DecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "ImportAssertions", + "name": "DecoratorMetadataObject", "identifiers": [], "defs": [], "references": [] }, { - "name": "Math", + "name": "DecoratorMetadata", "identifiers": [], "defs": [], "references": [] }, { - "name": "Date", + "name": "ClassDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "DateConstructor", + "name": "ClassMethodDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "RegExpMatchArray", + "name": "ClassGetterDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "RegExpExecArray", + "name": "ClassSetterDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "RegExp", + "name": "ClassAccessorDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "RegExpConstructor", + "name": "ClassAccessorDecoratorTarget", "identifiers": [], "defs": [], "references": [] }, { - "name": "Error", + "name": "ClassAccessorDecoratorResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "ErrorConstructor", + "name": "ClassFieldDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "EvalError", + "name": "IteratorYieldResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "EvalErrorConstructor", + "name": "IteratorReturnResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "RangeError", + "name": "IteratorResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "RangeErrorConstructor", + "name": "Iterable", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReferenceError", + "name": "IterableIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReferenceErrorConstructor", + "name": "BuiltinIteratorReturn", "identifiers": [], "defs": [], "references": [] }, { - "name": "SyntaxError", + "name": "ArrayIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "SyntaxErrorConstructor", + "name": "Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "TypeError", + "name": "ReadonlyArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "TypeErrorConstructor", + "name": "IArguments", "identifiers": [], "defs": [], "references": [] }, { - "name": "URIError", + "name": "MapIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "URIErrorConstructor", + "name": "Map", "identifiers": [], "defs": [], "references": [] }, { - "name": "JSON", + "name": "ReadonlyMap", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReadonlyArray", + "name": "WeakMap", "identifiers": [], "defs": [], "references": [] }, { - "name": "ConcatArray", + "name": "WeakMapConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Array", + "name": "SetIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayConstructor", + "name": "SetConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "TypedPropertyDescriptor", + "name": "WeakSet", "identifiers": [], "defs": [], "references": [] }, { - "name": "PromiseConstructorLike", + "name": "WeakSetConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "PromiseLike", + "name": "Promise", "identifiers": [], "defs": [], "references": [] }, { - "name": "Promise", + "name": "StringIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "Awaited", + "name": "Int8Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayLike", + "name": "Int8ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Partial", + "name": "Uint8Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Required", + "name": "Uint8ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Readonly", + "name": "Uint8ClampedArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "Pick", + "name": "Uint8ClampedArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Record", + "name": "Int16Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Exclude", + "name": "Int16ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Extract", + "name": "Uint16Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Omit", + "name": "Uint16ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "NonNullable", + "name": "Int32Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Parameters", + "name": "Int32ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ConstructorParameters", + "name": "Uint32Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReturnType", + "name": "Uint32ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "InstanceType", + "name": "Float32Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uppercase", + "name": "Float32ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Lowercase", + "name": "Float64Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Capitalize", + "name": "Float64ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uncapitalize", + "name": "AsyncIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "ThisType", + "name": "AsyncIterable", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayBuffer", + "name": "AsyncIterableIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayBufferTypes", + "name": "BigInt64Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayBufferLike", + "name": "BigUint64Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayBufferConstructor", + "name": "WeakKeyTypes", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayBufferView", + "name": "BigIntToLocaleStringOptions", "identifiers": [], "defs": [], "references": [] }, { - "name": "DataView", + "name": "BigInt", "identifiers": [], "defs": [], "references": [] }, { - "name": "DataViewConstructor", + "name": "BigIntConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int8Array", + "name": "BigInt64ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int8ArrayConstructor", + "name": "BigUint64ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint8Array", + "name": "ErrorOptions", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint8ArrayConstructor", + "name": "Error", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint8ClampedArray", + "name": "ErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint8ClampedArrayConstructor", + "name": "EvalErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int16Array", + "name": "RangeErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int16ArrayConstructor", + "name": "ReferenceErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint16Array", + "name": "SyntaxErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint16ArrayConstructor", + "name": "TypeErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int32Array", + "name": "URIErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int32ArrayConstructor", + "name": "AggregateErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint32Array", + "name": "RegExpMatchArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint32ArrayConstructor", + "name": "RegExpExecArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "Float32Array", + "name": "RegExpIndicesArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "Float32ArrayConstructor", + "name": "AggregateError", "identifiers": [], "defs": [], "references": [] }, { - "name": "Float64Array", + "name": "WeakRef", "identifiers": [], "defs": [], "references": [] }, { - "name": "Float64ArrayConstructor", + "name": "WeakRefConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Intl", + "name": "FinalizationRegistry", "identifiers": [], "defs": [], "references": [] }, { - "name": "Map", + "name": "FinalizationRegistryConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "MapConstructor", + "name": "Date", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReadonlyMap", + "name": "Number", "identifiers": [], "defs": [], "references": [] }, { - "name": "WeakMap", + "name": "PromiseFulfilledResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "WeakMapConstructor", + "name": "PromiseRejectedResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "Set", + "name": "PromiseSettledResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "SetConstructor", + "name": "RegExpStringIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReadonlySet", + "name": "Symbol", "identifiers": [], "defs": [], "references": [] }, { - "name": "WeakSet", + "name": "JSON", "identifiers": [], "defs": [], "references": [] }, { - "name": "WeakSetConstructor", + "name": "GeneratorFunction", "identifiers": [], "defs": [], "references": [] }, { - "name": "SymbolConstructor", + "name": "RegExpConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "IteratorYieldResult", + "name": "FlatArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "IteratorReturnResult", + "name": "AsyncGenerator", "identifiers": [], "defs": [], "references": [] }, { - "name": "IteratorResult", + "name": "AsyncGeneratorFunction", "identifiers": [], "defs": [], "references": [] }, { - "name": "Iterator", + "name": "AsyncGeneratorFunctionConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Iterable", + "name": "DateConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "IterableIterator", + "name": "ArrayBufferTypes", "identifiers": [], "defs": [], "references": [] }, { - "name": "PromiseConstructor", + "name": "PropertyKey", "identifiers": [], "defs": [], "references": [] }, { - "name": "Generator", + "name": "PropertyDescriptor", "identifiers": [], "defs": [], "references": [] }, { - "name": "GeneratorFunction", + "name": "PropertyDescriptorMap", "identifiers": [], "defs": [], "references": [] }, { - "name": "GeneratorFunctionConstructor", + "name": "Object", "identifiers": [], "defs": [], "references": [] }, { - "name": "ProxyHandler", + "name": "FunctionConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ProxyConstructor", + "name": "ThisParameterType", "identifiers": [], "defs": [], "references": [] }, { - "name": "Reflect", + "name": "OmitThisParameter", "identifiers": [], "defs": [], "references": [] }, { - "name": "SharedArrayBuffer", + "name": "CallableFunction", "identifiers": [], "defs": [], "references": [] }, { - "name": "SharedArrayBufferConstructor", + "name": "NewableFunction", "identifiers": [], "defs": [], "references": [] }, { - "name": "Atomics", + "name": "StringConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncIterator", + "name": "Boolean", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncIterable", + "name": "BooleanConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncIterableIterator", + "name": "NumberConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncGenerator", + "name": "TemplateStringsArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncGeneratorFunction", + "name": "ImportMeta", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncGeneratorFunctionConstructor", + "name": "ImportCallOptions", "identifiers": [], "defs": [], "references": [] }, { - "name": "const", + "name": "ImportAssertions", "identifiers": [], "defs": [], "references": [] }, { - "name": "defineProps", + "name": "ImportAttributes", "identifiers": [], "defs": [], - "references": [ - { - "identifier": { - "type": "Identifier", + "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": { - "start": { - "line": 2, - "column": 0 - }, "end": { "line": 2, "column": 11 + }, + "start": { + "line": 2, + "column": 0 } } }, @@ -918,13 +1194,13 @@ "type": "Identifier", "name": "T", "loc": { - "start": { - "line": 2, - "column": 17 - }, "end": { "line": 2, "column": 18 + }, + "start": { + "line": 2, + "column": 17 } } }, @@ -945,13 +1221,13 @@ "type": "Identifier", "name": "defineProps", "loc": { - "start": { - "line": 2, - "column": 0 - }, "end": { "line": 2, "column": 11 + }, + "start": { + "line": 2, + "column": 0 } } }, @@ -963,13 +1239,13 @@ "type": "Identifier", "name": "T", "loc": { - "start": { - "line": 2, - "column": 17 - }, "end": { "line": 2, "column": 18 + }, + "start": { + "line": 2, + "column": 17 } } }, @@ -984,13 +1260,13 @@ "type": "Identifier", "name": "defineProps", "loc": { - "start": { - "line": 2, - "column": 0 - }, "end": { "line": 2, "column": 11 + }, + "start": { + "line": 2, + "column": 0 } } }, @@ -1002,13 +1278,13 @@ "type": "Identifier", "name": "T", "loc": { - "start": { - "line": 2, - "column": 17 - }, "end": { "line": 2, "column": 18 + }, + "start": { + "line": 2, + "column": 17 } } }, diff --git a/test/fixtures/ast/vue3.3-generic-2/ast.json b/test/fixtures/ast/vue3.3-generic-2/ast.json index 3685710d..6eab96ca 100644 --- a/test/fixtures/ast/vue3.3-generic-2/ast.json +++ b/test/fixtures/ast/vue3.3-generic-2/ast.json @@ -1,23 +1,30 @@ { "type": "Program", + "range": [ + 9, + 162 + ], "body": [ { "type": "TSTypeAliasDeclaration", + "declare": false, "id": { "type": "Identifier", + "decorators": [], "name": "Foo", + "optional": false, "range": [ 14, 17 ], "loc": { - "start": { - "line": 2, - "column": 5 - }, "end": { "line": 2, "column": 8 + }, + "start": { + "line": 2, + "column": 5 } } }, @@ -31,13 +38,13 @@ 26 ], "loc": { - "start": { - "line": 2, - "column": 11 - }, "end": { "line": 2, "column": 17 + }, + "start": { + "line": 2, + "column": 11 } } }, @@ -48,13 +55,13 @@ 35 ], "loc": { - "start": { - "line": 2, - "column": 20 - }, "end": { "line": 2, "column": 26 + }, + "start": { + "line": 2, + "column": 20 } } } @@ -64,13 +71,13 @@ 35 ], "loc": { - "start": { - "line": 2, - "column": 11 - }, "end": { "line": 2, "column": 26 + }, + "start": { + "line": 2, + "column": 11 } } }, @@ -79,13 +86,13 @@ 35 ], "loc": { - "start": { - "line": 2, - "column": 0 - }, "end": { "line": 2, "column": 26 + }, + "start": { + "line": 2, + "column": 0 } } }, @@ -94,61 +101,52 @@ "declarations": [ { "type": "VariableDeclarator", + "definite": false, "id": { "type": "Identifier", + "decorators": [], "name": "p", + "optional": false, "range": [ 101, 102 ], "loc": { - "start": { - "line": 5, - "column": 6 - }, "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": { - "start": { - "line": 5, - "column": 10 - }, "end": { "line": 5, "column": 21 + }, + "start": { + "line": 5, + "column": 10 } } }, - "arguments": [], "optional": false, - "range": [ - 105, - 127 - ], - "loc": { - "start": { - "line": 5, - "column": 10 - }, - "end": { - "line": 5, - "column": 32 - } - }, - "typeParameters": { + "typeArguments": { "type": "TSTypeParameterInstantiation", "range": [ 116, @@ -163,32 +161,37 @@ "computed": false, "key": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 118, 121 ], "loc": { - "start": { - "line": 5, - "column": 23 - }, "end": { "line": 5, "column": 26 + }, + "start": { + "line": 5, + "column": 23 } } }, + "optional": false, + "readonly": false, + "static": false, "typeAnnotation": { "type": "TSTypeAnnotation", "loc": { - "start": { - "line": 5, - "column": 26 - }, "end": { "line": 5, "column": 28 + }, + "start": { + "line": 5, + "column": 26 } }, "range": [ @@ -199,19 +202,21 @@ "type": "TSTypeReference", "typeName": { "type": "Identifier", + "decorators": [], "name": "T", + "optional": false, "range": [ 122, 123 ], "loc": { - "start": { - "line": 5, - "column": 27 - }, "end": { "line": 5, "column": 28 + }, + "start": { + "line": 5, + "column": 27 } } }, @@ -220,13 +225,13 @@ 123 ], "loc": { - "start": { - "line": 5, - "column": 27 - }, "end": { "line": 5, "column": 28 + }, + "start": { + "line": 5, + "column": 27 } } } @@ -236,13 +241,13 @@ 123 ], "loc": { - "start": { - "line": 5, - "column": 23 - }, "end": { "line": 5, "column": 28 + }, + "start": { + "line": 5, + "column": 23 } } } @@ -252,27 +257,41 @@ 124 ], "loc": { - "start": { - "line": 5, - "column": 22 - }, "end": { "line": 5, "column": 29 + }, + "start": { + "line": 5, + "column": 22 } } } ], "loc": { - "start": { - "line": 5, - "column": 21 - }, "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": [ @@ -280,30 +299,31 @@ 127 ], "loc": { - "start": { - "line": 5, - "column": 6 - }, "end": { "line": 5, "column": 32 + }, + "start": { + "line": 5, + "column": 6 } } } ], + "declare": false, "kind": "const", "range": [ 95, 127 ], "loc": { - "start": { - "line": 5, - "column": 0 - }, "end": { "line": 5, "column": 32 + }, + "start": { + "line": 5, + "column": 0 } } }, @@ -312,76 +332,83 @@ "declarations": [ { "type": "VariableDeclarator", + "definite": false, "id": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 134, 137 ], "loc": { - "start": { - "line": 6, - "column": 6 - }, "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": { - "start": { - "line": 6, - "column": 12 - }, "end": { "line": 6, "column": 13 + }, + "start": { + "line": 6, + "column": 12 } } }, + "optional": false, "property": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 142, 145 ], "loc": { - "start": { - "line": 6, - "column": 14 - }, "end": { "line": 6, "column": 17 + }, + "start": { + "line": 6, + "column": 14 } } }, - "computed": false, - "optional": false, "range": [ 140, 145 ], "loc": { - "start": { - "line": 6, - "column": 12 - }, "end": { "line": 6, "column": 17 + }, + "start": { + "line": 6, + "column": 12 } } }, @@ -390,30 +417,31 @@ 145 ], "loc": { - "start": { - "line": 6, - "column": 6 - }, "end": { "line": 6, "column": 17 + }, + "start": { + "line": 6, + "column": 6 } } } ], + "declare": false, "kind": "const", "range": [ 128, 145 ], "loc": { - "start": { - "line": 6, - "column": 0 - }, "end": { "line": 6, "column": 17 + }, + "start": { + "line": 6, + "column": 0 } } }, @@ -421,94 +449,100 @@ "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": { - "start": { - "line": 7, - "column": 0 - }, "end": { "line": 7, "column": 7 + }, + "start": { + "line": 7, + "column": 0 } } }, + "optional": false, "property": { "type": "Identifier", + "decorators": [], "name": "log", + "optional": false, "range": [ 154, 157 ], "loc": { - "start": { - "line": 7, - "column": 8 - }, "end": { "line": 7, "column": 11 - } - } + }, + "start": { + "line": 7, + "column": 8 + } + } }, - "computed": false, - "optional": false, "range": [ 146, 157 ], "loc": { - "start": { - "line": 7, - "column": 0 - }, "end": { "line": 7, "column": 11 + }, + "start": { + "line": 7, + "column": 0 } } }, - "arguments": [ - { - "type": "Identifier", - "name": "foo", - "range": [ - 158, - 161 - ], - "loc": { - "start": { - "line": 7, - "column": 12 - }, - "end": { - "line": 7, - "column": 15 - } - } - } - ], "optional": false, "range": [ 146, 162 ], "loc": { - "start": { - "line": 7, - "column": 0 - }, "end": { "line": 7, "column": 16 + }, + "start": { + "line": 7, + "column": 0 } } }, @@ -517,32 +551,19 @@ 162 ], "loc": { - "start": { - "line": 7, - "column": 0 - }, "end": { "line": 7, "column": 16 + }, + "start": { + "line": 7, + "column": 0 } } } ], + "comments": [], "sourceType": "module", - "range": [ - 9, - 162 - ], - "loc": { - "start": { - "line": 2, - "column": 0 - }, - "end": { - "line": 7, - "column": 16 - } - }, "tokens": [ { "type": "Punctuator", @@ -564,111 +585,111 @@ }, { "type": "Identifier", - "value": "type", + "loc": { + "end": { + "line": 2, + "column": 4 + }, + "start": { + "line": 2, + "column": 0 + } + }, "range": [ 9, 13 ], + "value": "type" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 2, - "column": 0 + "column": 8 }, - "end": { + "start": { "line": 2, - "column": 4 + "column": 5 } - } - }, - { - "type": "Identifier", - "value": "Foo", + }, "range": [ 14, 17 ], + "value": "Foo" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 5 + "column": 10 }, - "end": { + "start": { "line": 2, - "column": 8 + "column": 9 } - } - }, - { - "type": "Punctuator", - "value": "=", + }, "range": [ 18, 19 ], + "value": "=" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 2, - "column": 9 + "column": 17 }, - "end": { + "start": { "line": 2, - "column": 10 + "column": 11 } - } - }, - { - "type": "Identifier", - "value": "number", + }, "range": [ 20, 26 ], + "value": "number" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 11 + "column": 19 }, - "end": { + "start": { "line": 2, - "column": 17 + "column": 18 } - } - }, - { - "type": "Punctuator", - "value": "|", + }, "range": [ 27, 28 ], + "value": "|" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 2, - "column": 18 + "column": 26 }, - "end": { + "start": { "line": 2, - "column": 19 + "column": 20 } - } - }, - { - "type": "Identifier", - "value": "string", + }, "range": [ 29, 35 ], - "loc": { - "start": { - "line": 2, - "column": 20 - }, - "end": { - "line": 2, - "column": 26 - } - } + "value": "string" }, { "type": "Punctuator", @@ -708,453 +729,453 @@ }, { "type": "Keyword", - "value": "const", + "loc": { + "end": { + "line": 5, + "column": 5 + }, + "start": { + "line": 5, + "column": 0 + } + }, "range": [ 95, 100 ], + "value": "const" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 5, - "column": 0 + "column": 7 }, - "end": { + "start": { "line": 5, - "column": 5 + "column": 6 } - } - }, - { - "type": "Identifier", - "value": "p", + }, "range": [ 101, 102 ], + "value": "p" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 6 + "column": 9 }, - "end": { + "start": { "line": 5, - "column": 7 + "column": 8 } - } - }, - { - "type": "Punctuator", - "value": "=", + }, "range": [ 103, 104 ], + "value": "=" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 5, - "column": 8 + "column": 21 }, - "end": { + "start": { "line": 5, - "column": 9 + "column": 10 } - } - }, - { - "type": "Identifier", - "value": "defineProps", + }, "range": [ 105, 116 ], + "value": "defineProps" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 10 + "column": 22 }, - "end": { + "start": { "line": 5, "column": 21 } - } - }, - { - "type": "Punctuator", - "value": "<", + }, "range": [ 116, 117 ], + "value": "<" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 21 + "column": 23 }, - "end": { + "start": { "line": 5, "column": 22 } - } - }, - { - "type": "Punctuator", - "value": "{", + }, "range": [ 117, 118 ], + "value": "{" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 5, - "column": 22 + "column": 26 }, - "end": { + "start": { "line": 5, "column": 23 } - } - }, - { - "type": "Identifier", - "value": "foo", + }, "range": [ 118, 121 ], + "value": "foo" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 23 + "column": 27 }, - "end": { + "start": { "line": 5, "column": 26 } - } - }, - { - "type": "Punctuator", - "value": ":", + }, "range": [ 121, 122 ], + "value": ":" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 5, - "column": 26 + "column": 28 }, - "end": { + "start": { "line": 5, "column": 27 } - } - }, - { - "type": "Identifier", - "value": "T", + }, "range": [ 122, 123 ], + "value": "T" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 27 + "column": 29 }, - "end": { + "start": { "line": 5, "column": 28 } - } - }, - { - "type": "Punctuator", - "value": "}", + }, "range": [ 123, 124 ], + "value": "}" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 28 + "column": 30 }, - "end": { + "start": { "line": 5, "column": 29 } - } - }, - { - "type": "Punctuator", - "value": ">", + }, "range": [ 124, 125 ], + "value": ">" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 29 + "column": 31 }, - "end": { + "start": { "line": 5, "column": 30 } - } - }, - { - "type": "Punctuator", - "value": "(", + }, "range": [ 125, 126 ], + "value": "(" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 30 + "column": 32 }, - "end": { + "start": { "line": 5, "column": 31 } - } - }, - { - "type": "Punctuator", - "value": ")", + }, "range": [ 126, 127 ], - "loc": { - "start": { - "line": 5, - "column": 31 - }, - "end": { - "line": 5, - "column": 32 - } - } + "value": ")" }, { "type": "Keyword", - "value": "const", + "loc": { + "end": { + "line": 6, + "column": 5 + }, + "start": { + "line": 6, + "column": 0 + } + }, "range": [ 128, 133 ], + "value": "const" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 6, - "column": 0 + "column": 9 }, - "end": { + "start": { "line": 6, - "column": 5 + "column": 6 } - } - }, - { - "type": "Identifier", - "value": "foo", + }, "range": [ 134, 137 ], + "value": "foo" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 6, - "column": 6 + "column": 11 }, - "end": { + "start": { "line": 6, - "column": 9 + "column": 10 } - } - }, - { - "type": "Punctuator", - "value": "=", + }, "range": [ 138, 139 ], + "value": "=" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 6, - "column": 10 + "column": 13 }, - "end": { + "start": { "line": 6, - "column": 11 + "column": 12 } - } - }, - { - "type": "Identifier", - "value": "p", + }, "range": [ 140, 141 ], + "value": "p" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 6, - "column": 12 + "column": 14 }, - "end": { + "start": { "line": 6, "column": 13 } - } - }, - { - "type": "Punctuator", - "value": ".", + }, "range": [ 141, 142 ], + "value": "." + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 6, - "column": 13 + "column": 17 }, - "end": { + "start": { "line": 6, "column": 14 } - } - }, - { - "type": "Identifier", - "value": "foo", + }, "range": [ 142, 145 ], - "loc": { - "start": { - "line": 6, - "column": 14 - }, - "end": { - "line": 6, - "column": 17 - } - } + "value": "foo" }, { "type": "Identifier", - "value": "console", + "loc": { + "end": { + "line": 7, + "column": 7 + }, + "start": { + "line": 7, + "column": 0 + } + }, "range": [ 146, 153 ], + "value": "console" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 7, - "column": 0 + "column": 8 }, - "end": { + "start": { "line": 7, "column": 7 } - } - }, - { - "type": "Punctuator", - "value": ".", + }, "range": [ 153, 154 ], + "value": "." + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 7, - "column": 7 + "column": 11 }, - "end": { + "start": { "line": 7, "column": 8 } - } - }, - { - "type": "Identifier", - "value": "log", + }, "range": [ 154, 157 ], + "value": "log" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 7, - "column": 8 + "column": 12 }, - "end": { + "start": { "line": 7, "column": 11 } - } - }, - { - "type": "Punctuator", - "value": "(", + }, "range": [ 157, 158 ], + "value": "(" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 7, - "column": 11 + "column": 15 }, - "end": { + "start": { "line": 7, "column": 12 } - } - }, - { - "type": "Identifier", - "value": "foo", + }, "range": [ 158, 161 ], + "value": "foo" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 7, - "column": 12 + "column": 16 }, - "end": { + "start": { "line": 7, "column": 15 } - } - }, - { - "type": "Punctuator", - "value": ")", + }, "range": [ 161, 162 ], - "loc": { - "start": { - "line": 7, - "column": 15 - }, - "end": { - "line": 7, - "column": 16 - } - } + "value": ")" }, { "type": "Punctuator", @@ -1175,7 +1196,16 @@ "value": "</script>" } ], - "comments": [], + "loc": { + "end": { + "line": 7, + "column": 16 + }, + "start": { + "line": 2, + "column": 0 + } + }, "templateBody": { "type": "VElement", "range": [ @@ -1251,19 +1281,21 @@ }, "expression": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 186, 189 ], "loc": { - "start": { - "line": 10, - "column": 2 - }, "end": { "line": 10, "column": 5 + }, + "start": { + "line": 10, + "column": 2 } } }, @@ -1271,19 +1303,21 @@ { "id": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 186, 189 ], "loc": { - "start": { - "line": 10, - "column": 2 - }, "end": { "line": 10, "column": 5 + }, + "start": { + "line": 10, + "column": 2 } } }, @@ -1801,57 +1835,57 @@ }, { "type": "Identifier", - "value": "T", + "loc": { + "end": { + "line": 4, + "column": 34 + }, + "start": { + "line": 4, + "column": 33 + } + }, "range": [ 79, 80 ], + "value": "T" + }, + { + "type": "Keyword", "loc": { - "start": { + "end": { "line": 4, - "column": 33 + "column": 42 }, - "end": { + "start": { "line": 4, - "column": 34 + "column": 35 } - } - }, - { - "type": "Keyword", - "value": "extends", + }, "range": [ 81, 88 ], + "value": "extends" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 4, - "column": 35 + "column": 46 }, - "end": { + "start": { "line": 4, - "column": 42 + "column": 43 } - } - }, - { - "type": "Identifier", - "value": "Foo", + }, "range": [ 89, 92 ], - "loc": { - "start": { - "line": 4, - "column": 43 - }, - "end": { - "line": 4, - "column": 46 - } - } + "value": "Foo" }, { "type": "Punctuator", @@ -2359,21 +2393,21 @@ }, { "type": "Identifier", - "value": "foo", - "range": [ - 186, - 189 - ], "loc": { - "start": { - "line": 10, - "column": 2 - }, "end": { "line": 10, "column": 5 + }, + "start": { + "line": 10, + "column": 2 } - } + }, + "range": [ + 186, + 189 + ], + "value": "foo" }, { "type": "VExpressionEnd", diff --git a/test/fixtures/ast/vue3.3-generic-2/scope.json b/test/fixtures/ast/vue3.3-generic-2/scope.json index 261ad368..df9d4a47 100644 --- a/test/fixtures/ast/vue3.3-generic-2/scope.json +++ b/test/fixtures/ast/vue3.3-generic-2/scope.json @@ -2,904 +2,1180 @@ "type": "global", "variables": [ { - "name": "ClassMemberDecoratorContext", + "name": "Intl", "identifiers": [], "defs": [], "references": [] }, { - "name": "DecoratorContext", + "name": "SymbolConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassDecoratorContext", + "name": "Function", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassMethodDecoratorContext", + "name": "Disposable", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassGetterDecoratorContext", + "name": "AsyncDisposable", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassSetterDecoratorContext", + "name": "SuppressedError", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassAccessorDecoratorContext", + "name": "SuppressedErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassAccessorDecoratorTarget", + "name": "DisposableStack", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassAccessorDecoratorResult", + "name": "DisposableStackConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassFieldDecoratorContext", + "name": "AsyncDisposableStack", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassDecorator", + "name": "AsyncDisposableStackConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "PropertyDecorator", + "name": "IteratorObject", "identifiers": [], "defs": [], "references": [] }, { - "name": "MethodDecorator", + "name": "AsyncIteratorObject", "identifiers": [], "defs": [], "references": [] }, { - "name": "ParameterDecorator", + "name": "ReadonlySetLike", "identifiers": [], "defs": [], "references": [] }, { - "name": "Symbol", + "name": "Set", "identifiers": [], "defs": [], "references": [] }, { - "name": "PropertyKey", + "name": "ReadonlySet", "identifiers": [], "defs": [], "references": [] }, { - "name": "PropertyDescriptor", + "name": "ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "PropertyDescriptorMap", + "name": "Iterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "Object", + "name": "IteratorObjectConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ObjectConstructor", + "name": "PromiseConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Function", + "name": "Float16Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "FunctionConstructor", + "name": "Float16ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ThisParameterType", + "name": "Math", "identifiers": [], "defs": [], "references": [] }, { - "name": "OmitThisParameter", + "name": "DataView", "identifiers": [], "defs": [], "references": [] }, { - "name": "CallableFunction", + "name": "ArrayBuffer", "identifiers": [], "defs": [], "references": [] }, { - "name": "NewableFunction", + "name": "ArrayBufferConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "IArguments", + "name": "MapConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "String", + "name": "ObjectConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "StringConstructor", + "name": "PromiseWithResolvers", "identifiers": [], "defs": [], "references": [] }, { - "name": "Boolean", + "name": "RegExp", "identifiers": [], "defs": [], "references": [] }, { - "name": "BooleanConstructor", + "name": "Atomics", "identifiers": [], "defs": [], "references": [] }, { - "name": "Number", + "name": "SharedArrayBuffer", "identifiers": [], "defs": [], "references": [] }, { - "name": "NumberConstructor", + "name": "SharedArrayBufferConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "TemplateStringsArray", + "name": "String", "identifiers": [], "defs": [], "references": [] }, { - "name": "ImportMeta", + "name": "ClassMemberDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "ImportCallOptions", + "name": "DecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "ImportAssertions", + "name": "DecoratorMetadataObject", "identifiers": [], "defs": [], "references": [] }, { - "name": "Math", + "name": "DecoratorMetadata", "identifiers": [], "defs": [], "references": [] }, { - "name": "Date", + "name": "ClassDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "DateConstructor", + "name": "ClassMethodDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "RegExpMatchArray", + "name": "ClassGetterDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "RegExpExecArray", + "name": "ClassSetterDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "RegExp", + "name": "ClassAccessorDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "RegExpConstructor", + "name": "ClassAccessorDecoratorTarget", "identifiers": [], "defs": [], "references": [] }, { - "name": "Error", + "name": "ClassAccessorDecoratorResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "ErrorConstructor", + "name": "ClassFieldDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "EvalError", + "name": "IteratorYieldResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "EvalErrorConstructor", + "name": "IteratorReturnResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "RangeError", + "name": "IteratorResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "RangeErrorConstructor", + "name": "Iterable", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReferenceError", + "name": "IterableIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReferenceErrorConstructor", + "name": "BuiltinIteratorReturn", "identifiers": [], "defs": [], "references": [] }, { - "name": "SyntaxError", + "name": "ArrayIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "SyntaxErrorConstructor", + "name": "Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "TypeError", + "name": "ReadonlyArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "TypeErrorConstructor", + "name": "IArguments", "identifiers": [], "defs": [], "references": [] }, { - "name": "URIError", + "name": "MapIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "URIErrorConstructor", + "name": "Map", "identifiers": [], "defs": [], "references": [] }, { - "name": "JSON", + "name": "ReadonlyMap", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReadonlyArray", + "name": "WeakMap", "identifiers": [], "defs": [], "references": [] }, { - "name": "ConcatArray", + "name": "WeakMapConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Array", + "name": "SetIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayConstructor", + "name": "SetConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "TypedPropertyDescriptor", + "name": "WeakSet", "identifiers": [], "defs": [], "references": [] }, { - "name": "PromiseConstructorLike", + "name": "WeakSetConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "PromiseLike", + "name": "Promise", "identifiers": [], "defs": [], "references": [] }, { - "name": "Promise", + "name": "StringIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "Awaited", + "name": "Int8Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayLike", + "name": "Int8ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Partial", + "name": "Uint8Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Required", + "name": "Uint8ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Readonly", + "name": "Uint8ClampedArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "Pick", + "name": "Uint8ClampedArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Record", + "name": "Int16Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Exclude", + "name": "Int16ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Extract", + "name": "Uint16Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Omit", + "name": "Uint16ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "NonNullable", + "name": "Int32Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Parameters", + "name": "Int32ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ConstructorParameters", + "name": "Uint32Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReturnType", + "name": "Uint32ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "InstanceType", + "name": "Float32Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uppercase", + "name": "Float32ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Lowercase", + "name": "Float64Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Capitalize", + "name": "Float64ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uncapitalize", + "name": "AsyncIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "ThisType", + "name": "AsyncIterable", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayBuffer", + "name": "AsyncIterableIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayBufferTypes", + "name": "BigInt64Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayBufferLike", + "name": "BigUint64Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayBufferConstructor", + "name": "WeakKeyTypes", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayBufferView", + "name": "BigIntToLocaleStringOptions", "identifiers": [], "defs": [], "references": [] }, { - "name": "DataView", + "name": "BigInt", "identifiers": [], "defs": [], "references": [] }, { - "name": "DataViewConstructor", + "name": "BigIntConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int8Array", + "name": "BigInt64ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int8ArrayConstructor", + "name": "BigUint64ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint8Array", + "name": "ErrorOptions", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint8ArrayConstructor", + "name": "Error", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint8ClampedArray", + "name": "ErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint8ClampedArrayConstructor", + "name": "EvalErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int16Array", + "name": "RangeErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int16ArrayConstructor", + "name": "ReferenceErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint16Array", + "name": "SyntaxErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint16ArrayConstructor", + "name": "TypeErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int32Array", + "name": "URIErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int32ArrayConstructor", + "name": "AggregateErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint32Array", + "name": "RegExpMatchArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint32ArrayConstructor", + "name": "RegExpExecArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "Float32Array", + "name": "RegExpIndicesArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "Float32ArrayConstructor", + "name": "AggregateError", "identifiers": [], "defs": [], "references": [] }, { - "name": "Float64Array", + "name": "WeakRef", "identifiers": [], "defs": [], "references": [] }, { - "name": "Float64ArrayConstructor", + "name": "WeakRefConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Intl", + "name": "FinalizationRegistry", "identifiers": [], "defs": [], "references": [] }, { - "name": "Map", + "name": "FinalizationRegistryConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "MapConstructor", + "name": "Date", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReadonlyMap", + "name": "Number", "identifiers": [], "defs": [], "references": [] }, { - "name": "WeakMap", + "name": "PromiseFulfilledResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "WeakMapConstructor", + "name": "PromiseRejectedResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "Set", + "name": "PromiseSettledResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "SetConstructor", + "name": "RegExpStringIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReadonlySet", + "name": "Symbol", "identifiers": [], "defs": [], "references": [] }, { - "name": "WeakSet", + "name": "JSON", "identifiers": [], "defs": [], "references": [] }, { - "name": "WeakSetConstructor", + "name": "GeneratorFunction", "identifiers": [], "defs": [], "references": [] }, { - "name": "SymbolConstructor", + "name": "RegExpConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "IteratorYieldResult", + "name": "FlatArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "IteratorReturnResult", + "name": "AsyncGenerator", "identifiers": [], "defs": [], "references": [] }, { - "name": "IteratorResult", + "name": "AsyncGeneratorFunction", "identifiers": [], "defs": [], "references": [] }, { - "name": "Iterator", + "name": "AsyncGeneratorFunctionConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Iterable", + "name": "DateConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "IterableIterator", + "name": "ArrayBufferTypes", "identifiers": [], "defs": [], "references": [] }, { - "name": "PromiseConstructor", + "name": "PropertyKey", "identifiers": [], "defs": [], "references": [] }, { - "name": "Generator", + "name": "PropertyDescriptor", "identifiers": [], "defs": [], "references": [] }, { - "name": "GeneratorFunction", + "name": "PropertyDescriptorMap", "identifiers": [], "defs": [], "references": [] }, { - "name": "GeneratorFunctionConstructor", + "name": "Object", "identifiers": [], "defs": [], "references": [] }, { - "name": "ProxyHandler", + "name": "FunctionConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ProxyConstructor", + "name": "ThisParameterType", "identifiers": [], "defs": [], "references": [] }, { - "name": "Reflect", + "name": "OmitThisParameter", "identifiers": [], "defs": [], "references": [] }, { - "name": "SharedArrayBuffer", + "name": "CallableFunction", "identifiers": [], "defs": [], "references": [] }, { - "name": "SharedArrayBufferConstructor", + "name": "NewableFunction", "identifiers": [], "defs": [], "references": [] }, { - "name": "Atomics", + "name": "StringConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncIterator", + "name": "Boolean", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncIterable", + "name": "BooleanConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncIterableIterator", + "name": "NumberConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncGenerator", + "name": "TemplateStringsArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncGeneratorFunction", + "name": "ImportMeta", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncGeneratorFunctionConstructor", + "name": "ImportCallOptions", "identifiers": [], "defs": [], "references": [] }, { - "name": "const", + "name": "ImportAssertions", "identifiers": [], "defs": [], "references": [] }, { - "name": "defineProps", + "name": "ImportAttributes", "identifiers": [], "defs": [], - "references": [ - { - "identifier": { - "type": "Identifier", + "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": { - "start": { - "line": 5, - "column": 10 - }, "end": { "line": 5, "column": 21 + }, + "start": { + "line": 5, + "column": 10 } } }, @@ -918,13 +1194,13 @@ "type": "Identifier", "name": "T", "loc": { - "start": { - "line": 5, - "column": 27 - }, "end": { "line": 5, "column": 28 + }, + "start": { + "line": 5, + "column": 27 } } }, @@ -946,13 +1222,13 @@ "type": "Identifier", "name": "Foo", "loc": { - "start": { - "line": 2, - "column": 5 - }, "end": { "line": 2, "column": 8 + }, + "start": { + "line": 2, + "column": 5 } } } @@ -963,13 +1239,13 @@ "node": { "type": "TSTypeAliasDeclaration", "loc": { - "start": { - "line": 2, - "column": 0 - }, "end": { "line": 2, "column": 26 + }, + "start": { + "line": 2, + "column": 0 } } }, @@ -982,13 +1258,13 @@ "type": "Identifier", "name": "Foo", "loc": { - "start": { - "line": 2, - "column": 5 - }, "end": { "line": 2, "column": 8 + }, + "start": { + "line": 2, + "column": 5 } } }, @@ -997,13 +1273,13 @@ "type": "Identifier", "name": "Foo", "loc": { - "start": { - "line": 2, - "column": 5 - }, "end": { "line": 2, "column": 8 + }, + "start": { + "line": 2, + "column": 5 } } }, @@ -1019,13 +1295,13 @@ "type": "Identifier", "name": "p", "loc": { - "start": { - "line": 5, - "column": 6 - }, "end": { "line": 5, "column": 7 + }, + "start": { + "line": 5, + "column": 6 } } } @@ -1036,13 +1312,13 @@ "node": { "type": "VariableDeclarator", "loc": { - "start": { - "line": 5, - "column": 6 - }, "end": { "line": 5, "column": 32 + }, + "start": { + "line": 5, + "column": 6 } } }, @@ -1055,13 +1331,13 @@ "type": "Identifier", "name": "p", "loc": { - "start": { - "line": 5, - "column": 6 - }, "end": { "line": 5, "column": 7 + }, + "start": { + "line": 5, + "column": 6 } } }, @@ -1070,13 +1346,13 @@ "type": "Identifier", "name": "p", "loc": { - "start": { - "line": 5, - "column": 6 - }, "end": { "line": 5, "column": 7 + }, + "start": { + "line": 5, + "column": 6 } } }, @@ -1087,13 +1363,13 @@ "type": "Identifier", "name": "p", "loc": { - "start": { - "line": 6, - "column": 12 - }, "end": { "line": 6, "column": 13 + }, + "start": { + "line": 6, + "column": 12 } } }, @@ -1102,13 +1378,13 @@ "type": "Identifier", "name": "p", "loc": { - "start": { - "line": 5, - "column": 6 - }, "end": { "line": 5, "column": 7 + }, + "start": { + "line": 5, + "column": 6 } } }, @@ -1123,13 +1399,13 @@ "type": "Identifier", "name": "foo", "loc": { - "start": { - "line": 6, - "column": 6 - }, "end": { "line": 6, "column": 9 + }, + "start": { + "line": 6, + "column": 6 } } } @@ -1140,13 +1416,13 @@ "node": { "type": "VariableDeclarator", "loc": { - "start": { - "line": 6, - "column": 6 - }, "end": { "line": 6, "column": 17 + }, + "start": { + "line": 6, + "column": 6 } } }, @@ -1159,13 +1435,13 @@ "type": "Identifier", "name": "foo", "loc": { - "start": { - "line": 6, - "column": 6 - }, "end": { "line": 6, "column": 9 + }, + "start": { + "line": 6, + "column": 6 } } }, @@ -1174,13 +1450,13 @@ "type": "Identifier", "name": "foo", "loc": { - "start": { - "line": 6, - "column": 6 - }, "end": { "line": 6, "column": 9 + }, + "start": { + "line": 6, + "column": 6 } } }, @@ -1191,13 +1467,13 @@ "type": "Identifier", "name": "foo", "loc": { - "start": { - "line": 7, - "column": 12 - }, "end": { "line": 7, "column": 15 + }, + "start": { + "line": 7, + "column": 12 } } }, @@ -1206,13 +1482,13 @@ "type": "Identifier", "name": "foo", "loc": { - "start": { - "line": 6, - "column": 6 - }, "end": { "line": 6, "column": 9 + }, + "start": { + "line": 6, + "column": 6 } } }, @@ -1223,13 +1499,13 @@ "type": "Identifier", "name": "foo", "loc": { - "start": { - "line": 6, - "column": 6 - }, "end": { "line": 6, "column": 9 + }, + "start": { + "line": 6, + "column": 6 } } }, @@ -1238,13 +1514,13 @@ "type": "Identifier", "name": "foo", "loc": { - "start": { - "line": 6, - "column": 6 - }, "end": { "line": 6, "column": 9 + }, + "start": { + "line": 6, + "column": 6 } } }, @@ -1260,13 +1536,13 @@ "type": "Identifier", "name": "p", "loc": { - "start": { - "line": 5, - "column": 6 - }, "end": { "line": 5, "column": 7 + }, + "start": { + "line": 5, + "column": 6 } } }, @@ -1275,13 +1551,13 @@ "type": "Identifier", "name": "p", "loc": { - "start": { - "line": 5, - "column": 6 - }, "end": { "line": 5, "column": 7 + }, + "start": { + "line": 5, + "column": 6 } } }, @@ -1292,13 +1568,13 @@ "type": "Identifier", "name": "defineProps", "loc": { - "start": { - "line": 5, - "column": 10 - }, "end": { "line": 5, "column": 21 + }, + "start": { + "line": 5, + "column": 10 } } }, @@ -1310,13 +1586,13 @@ "type": "Identifier", "name": "T", "loc": { - "start": { - "line": 5, - "column": 27 - }, "end": { "line": 5, "column": 28 + }, + "start": { + "line": 5, + "column": 27 } } }, @@ -1328,13 +1604,13 @@ "type": "Identifier", "name": "foo", "loc": { - "start": { - "line": 6, - "column": 6 - }, "end": { "line": 6, "column": 9 + }, + "start": { + "line": 6, + "column": 6 } } }, @@ -1343,13 +1619,13 @@ "type": "Identifier", "name": "foo", "loc": { - "start": { - "line": 6, - "column": 6 - }, "end": { "line": 6, "column": 9 + }, + "start": { + "line": 6, + "column": 6 } } }, @@ -1360,13 +1636,13 @@ "type": "Identifier", "name": "p", "loc": { - "start": { - "line": 6, - "column": 12 - }, "end": { "line": 6, "column": 13 + }, + "start": { + "line": 6, + "column": 12 } } }, @@ -1375,13 +1651,13 @@ "type": "Identifier", "name": "p", "loc": { - "start": { - "line": 5, - "column": 6 - }, "end": { "line": 5, "column": 7 + }, + "start": { + "line": 5, + "column": 6 } } }, @@ -1392,13 +1668,13 @@ "type": "Identifier", "name": "console", "loc": { - "start": { - "line": 7, - "column": 0 - }, "end": { "line": 7, "column": 7 + }, + "start": { + "line": 7, + "column": 0 } } }, @@ -1411,13 +1687,13 @@ "type": "Identifier", "name": "foo", "loc": { - "start": { - "line": 7, - "column": 12 - }, "end": { "line": 7, "column": 15 + }, + "start": { + "line": 7, + "column": 12 } } }, @@ -1426,13 +1702,13 @@ "type": "Identifier", "name": "foo", "loc": { - "start": { - "line": 6, - "column": 6 - }, "end": { "line": 6, "column": 9 + }, + "start": { + "line": 6, + "column": 6 } } }, @@ -1446,13 +1722,13 @@ "type": "Identifier", "name": "defineProps", "loc": { - "start": { - "line": 5, - "column": 10 - }, "end": { "line": 5, "column": 21 + }, + "start": { + "line": 5, + "column": 10 } } }, @@ -1464,13 +1740,13 @@ "type": "Identifier", "name": "T", "loc": { - "start": { - "line": 5, - "column": 27 - }, "end": { "line": 5, "column": 28 + }, + "start": { + "line": 5, + "column": 27 } } }, @@ -1482,13 +1758,13 @@ "type": "Identifier", "name": "console", "loc": { - "start": { - "line": 7, - "column": 0 - }, "end": { "line": 7, "column": 7 + }, + "start": { + "line": 7, + "column": 0 } } }, @@ -1505,13 +1781,13 @@ "type": "Identifier", "name": "console", "loc": { - "start": { - "line": 7, - "column": 0 - }, "end": { "line": 7, "column": 7 + }, + "start": { + "line": 7, + "column": 0 } } }, diff --git a/test/fixtures/ast/vue3.3-generic-3/ast.json b/test/fixtures/ast/vue3.3-generic-3/ast.json index 8dbd9da4..cb599c07 100644 --- a/test/fixtures/ast/vue3.3-generic-3/ast.json +++ b/test/fixtures/ast/vue3.3-generic-3/ast.json @@ -1,23 +1,30 @@ { "type": "Program", + "range": [ + 9, + 183 + ], "body": [ { "type": "TSTypeAliasDeclaration", + "declare": false, "id": { "type": "Identifier", + "decorators": [], "name": "Foo", + "optional": false, "range": [ 14, 17 ], "loc": { - "start": { - "line": 2, - "column": 5 - }, "end": { "line": 2, "column": 8 + }, + "start": { + "line": 2, + "column": 5 } } }, @@ -31,13 +38,13 @@ 26 ], "loc": { - "start": { - "line": 2, - "column": 11 - }, "end": { "line": 2, "column": 17 + }, + "start": { + "line": 2, + "column": 11 } } }, @@ -48,13 +55,13 @@ 35 ], "loc": { - "start": { - "line": 2, - "column": 20 - }, "end": { "line": 2, "column": 26 + }, + "start": { + "line": 2, + "column": 20 } } } @@ -64,13 +71,13 @@ 35 ], "loc": { - "start": { - "line": 2, - "column": 11 - }, "end": { "line": 2, "column": 26 + }, + "start": { + "line": 2, + "column": 11 } } }, @@ -79,13 +86,13 @@ 35 ], "loc": { - "start": { - "line": 2, - "column": 0 - }, "end": { "line": 2, "column": 26 + }, + "start": { + "line": 2, + "column": 0 } } }, @@ -94,61 +101,52 @@ "declarations": [ { "type": "VariableDeclarator", + "definite": false, "id": { "type": "Identifier", + "decorators": [], "name": "p", + "optional": false, "range": [ 114, 115 ], "loc": { - "start": { - "line": 5, - "column": 6 - }, "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": { - "start": { - "line": 5, - "column": 10 - }, "end": { "line": 5, "column": 21 + }, + "start": { + "line": 5, + "column": 10 } } }, - "arguments": [], "optional": false, - "range": [ - 118, - 148 - ], - "loc": { - "start": { - "line": 5, - "column": 10 - }, - "end": { - "line": 5, - "column": 40 - } - }, - "typeParameters": { + "typeArguments": { "type": "TSTypeParameterInstantiation", "range": [ 129, @@ -163,32 +161,37 @@ "computed": false, "key": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 131, 134 ], "loc": { - "start": { - "line": 5, - "column": 23 - }, "end": { "line": 5, "column": 26 + }, + "start": { + "line": 5, + "column": 23 } } }, + "optional": false, + "readonly": false, + "static": false, "typeAnnotation": { "type": "TSTypeAnnotation", "loc": { - "start": { - "line": 5, - "column": 26 - }, "end": { "line": 5, "column": 28 + }, + "start": { + "line": 5, + "column": 26 } }, "range": [ @@ -199,19 +202,21 @@ "type": "TSTypeReference", "typeName": { "type": "Identifier", + "decorators": [], "name": "T", + "optional": false, "range": [ 135, 136 ], "loc": { - "start": { - "line": 5, - "column": 27 - }, "end": { "line": 5, "column": 28 + }, + "start": { + "line": 5, + "column": 27 } } }, @@ -220,13 +225,13 @@ 136 ], "loc": { - "start": { - "line": 5, - "column": 27 - }, "end": { "line": 5, "column": 28 + }, + "start": { + "line": 5, + "column": 27 } } } @@ -236,13 +241,13 @@ 137 ], "loc": { - "start": { - "line": 5, - "column": 23 - }, "end": { "line": 5, "column": 29 + }, + "start": { + "line": 5, + "column": 23 } } }, @@ -251,32 +256,37 @@ "computed": false, "key": { "type": "Identifier", + "decorators": [], "name": "bar", + "optional": false, "range": [ 138, 141 ], "loc": { - "start": { - "line": 5, - "column": 30 - }, "end": { "line": 5, "column": 33 + }, + "start": { + "line": 5, + "column": 30 } } }, + "optional": false, + "readonly": false, + "static": false, "typeAnnotation": { "type": "TSTypeAnnotation", "loc": { - "start": { - "line": 5, - "column": 33 - }, "end": { "line": 5, "column": 36 + }, + "start": { + "line": 5, + "column": 33 } }, "range": [ @@ -287,19 +297,21 @@ "type": "TSTypeReference", "typeName": { "type": "Identifier", + "decorators": [], "name": "U", + "optional": false, "range": [ 143, 144 ], "loc": { - "start": { - "line": 5, - "column": 35 - }, "end": { "line": 5, "column": 36 + }, + "start": { + "line": 5, + "column": 35 } } }, @@ -308,13 +320,13 @@ 144 ], "loc": { - "start": { - "line": 5, - "column": 35 - }, "end": { "line": 5, "column": 36 + }, + "start": { + "line": 5, + "column": 35 } } } @@ -324,13 +336,13 @@ 144 ], "loc": { - "start": { - "line": 5, - "column": 30 - }, "end": { "line": 5, "column": 36 + }, + "start": { + "line": 5, + "column": 30 } } } @@ -340,27 +352,41 @@ 145 ], "loc": { - "start": { - "line": 5, - "column": 22 - }, "end": { "line": 5, "column": 37 + }, + "start": { + "line": 5, + "column": 22 } } } ], "loc": { - "start": { - "line": 5, - "column": 21 - }, "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": [ @@ -368,30 +394,31 @@ 148 ], "loc": { - "start": { - "line": 5, - "column": 6 - }, "end": { "line": 5, "column": 40 + }, + "start": { + "line": 5, + "column": 6 } } } ], + "declare": false, "kind": "const", "range": [ 108, 148 ], "loc": { - "start": { - "line": 5, - "column": 0 - }, "end": { "line": 5, "column": 40 + }, + "start": { + "line": 5, + "column": 0 } } }, @@ -400,76 +427,83 @@ "declarations": [ { "type": "VariableDeclarator", + "definite": false, "id": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 155, 158 ], "loc": { - "start": { - "line": 6, - "column": 6 - }, "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": { - "start": { - "line": 6, - "column": 12 - }, "end": { "line": 6, "column": 13 + }, + "start": { + "line": 6, + "column": 12 } } }, + "optional": false, "property": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 163, 166 ], "loc": { - "start": { - "line": 6, - "column": 14 - }, "end": { "line": 6, "column": 17 + }, + "start": { + "line": 6, + "column": 14 } } }, - "computed": false, - "optional": false, "range": [ 161, 166 ], "loc": { - "start": { - "line": 6, - "column": 12 - }, "end": { "line": 6, "column": 17 + }, + "start": { + "line": 6, + "column": 12 } } }, @@ -478,125 +512,132 @@ 166 ], "loc": { - "start": { - "line": 6, - "column": 6 - }, "end": { "line": 6, "column": 17 + }, + "start": { + "line": 6, + "column": 6 } } } ], + "declare": false, "kind": "const", "range": [ 149, 166 ], "loc": { - "start": { - "line": 6, - "column": 0 - }, "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": { - "start": { - "line": 7, - "column": 0 - }, "end": { "line": 7, "column": 7 + }, + "start": { + "line": 7, + "column": 0 } } }, + "optional": false, "property": { "type": "Identifier", + "decorators": [], "name": "log", + "optional": false, "range": [ 175, 178 ], "loc": { - "start": { - "line": 7, - "column": 8 - }, "end": { "line": 7, "column": 11 + }, + "start": { + "line": 7, + "column": 8 } } }, - "computed": false, - "optional": false, "range": [ 167, 178 ], "loc": { - "start": { - "line": 7, - "column": 0 - }, "end": { "line": 7, "column": 11 + }, + "start": { + "line": 7, + "column": 0 } } }, - "arguments": [ - { - "type": "Identifier", - "name": "foo", - "range": [ - 179, - 182 - ], - "loc": { - "start": { - "line": 7, - "column": 12 - }, - "end": { - "line": 7, - "column": 15 - } - } - } - ], "optional": false, "range": [ 167, 183 ], "loc": { - "start": { - "line": 7, - "column": 0 - }, "end": { "line": 7, "column": 16 + }, + "start": { + "line": 7, + "column": 0 } } }, @@ -605,32 +646,19 @@ 183 ], "loc": { - "start": { - "line": 7, - "column": 0 - }, "end": { "line": 7, "column": 16 + }, + "start": { + "line": 7, + "column": 0 } } } ], + "comments": [], "sourceType": "module", - "range": [ - 9, - 183 - ], - "loc": { - "start": { - "line": 2, - "column": 0 - }, - "end": { - "line": 7, - "column": 16 - } - }, "tokens": [ { "type": "Punctuator", @@ -652,111 +680,111 @@ }, { "type": "Identifier", - "value": "type", + "loc": { + "end": { + "line": 2, + "column": 4 + }, + "start": { + "line": 2, + "column": 0 + } + }, "range": [ 9, 13 ], + "value": "type" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 2, - "column": 0 + "column": 8 }, - "end": { + "start": { "line": 2, - "column": 4 + "column": 5 } - } - }, - { - "type": "Identifier", - "value": "Foo", + }, "range": [ 14, 17 ], + "value": "Foo" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 5 + "column": 10 }, - "end": { + "start": { "line": 2, - "column": 8 + "column": 9 } - } - }, - { - "type": "Punctuator", - "value": "=", + }, "range": [ 18, 19 ], + "value": "=" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 2, - "column": 9 + "column": 17 }, - "end": { + "start": { "line": 2, - "column": 10 + "column": 11 } - } - }, - { - "type": "Identifier", - "value": "number", + }, "range": [ 20, 26 ], + "value": "number" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 11 + "column": 19 }, - "end": { + "start": { "line": 2, - "column": 17 + "column": 18 } - } - }, - { - "type": "Punctuator", - "value": "|", + }, "range": [ 27, 28 ], + "value": "|" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 2, - "column": 18 + "column": 26 }, - "end": { + "start": { "line": 2, - "column": 19 + "column": 20 } - } - }, - { - "type": "Identifier", - "value": "string", + }, "range": [ 29, 35 ], - "loc": { - "start": { - "line": 2, - "column": 20 - }, - "end": { - "line": 2, - "column": 26 - } - } + "value": "string" }, { "type": "Punctuator", @@ -796,525 +824,525 @@ }, { "type": "Keyword", - "value": "const", + "loc": { + "end": { + "line": 5, + "column": 5 + }, + "start": { + "line": 5, + "column": 0 + } + }, "range": [ 108, 113 ], + "value": "const" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 5, - "column": 0 + "column": 7 }, - "end": { + "start": { "line": 5, - "column": 5 + "column": 6 } - } - }, - { - "type": "Identifier", - "value": "p", + }, "range": [ 114, 115 ], + "value": "p" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 6 + "column": 9 }, - "end": { + "start": { "line": 5, - "column": 7 + "column": 8 } - } - }, - { - "type": "Punctuator", - "value": "=", + }, "range": [ 116, 117 ], + "value": "=" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 5, - "column": 8 + "column": 21 }, - "end": { + "start": { "line": 5, - "column": 9 + "column": 10 } - } - }, - { - "type": "Identifier", - "value": "defineProps", + }, "range": [ 118, 129 ], + "value": "defineProps" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 10 + "column": 22 }, - "end": { + "start": { "line": 5, "column": 21 } - } - }, - { - "type": "Punctuator", - "value": "<", + }, "range": [ 129, 130 ], + "value": "<" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 21 + "column": 23 }, - "end": { + "start": { "line": 5, "column": 22 } - } - }, - { - "type": "Punctuator", - "value": "{", + }, "range": [ 130, 131 ], + "value": "{" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 5, - "column": 22 + "column": 26 }, - "end": { + "start": { "line": 5, "column": 23 } - } - }, - { - "type": "Identifier", - "value": "foo", + }, "range": [ 131, 134 ], + "value": "foo" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 23 + "column": 27 }, - "end": { + "start": { "line": 5, "column": 26 } - } - }, - { - "type": "Punctuator", - "value": ":", + }, "range": [ 134, 135 ], + "value": ":" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 5, - "column": 26 + "column": 28 }, - "end": { + "start": { "line": 5, "column": 27 } - } - }, - { - "type": "Identifier", - "value": "T", + }, "range": [ 135, 136 ], + "value": "T" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 27 + "column": 29 }, - "end": { + "start": { "line": 5, "column": 28 } - } - }, - { - "type": "Punctuator", - "value": ",", + }, "range": [ 136, 137 ], + "value": "," + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 5, - "column": 28 + "column": 33 }, - "end": { + "start": { "line": 5, - "column": 29 + "column": 30 } - } - }, - { - "type": "Identifier", - "value": "bar", + }, "range": [ 138, 141 ], + "value": "bar" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 30 + "column": 34 }, - "end": { + "start": { "line": 5, "column": 33 } - } - }, - { - "type": "Punctuator", - "value": ":", + }, "range": [ 141, 142 ], + "value": ":" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 5, - "column": 33 + "column": 36 }, - "end": { + "start": { "line": 5, - "column": 34 + "column": 35 } - } - }, - { - "type": "Identifier", - "value": "U", + }, "range": [ 143, 144 ], + "value": "U" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 35 + "column": 37 }, - "end": { + "start": { "line": 5, "column": 36 } - } - }, - { - "type": "Punctuator", - "value": "}", + }, "range": [ 144, 145 ], + "value": "}" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 36 + "column": 38 }, - "end": { + "start": { "line": 5, "column": 37 } - } - }, - { - "type": "Punctuator", - "value": ">", + }, "range": [ 145, 146 ], + "value": ">" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 37 + "column": 39 }, - "end": { + "start": { "line": 5, "column": 38 } - } - }, - { - "type": "Punctuator", - "value": "(", + }, "range": [ 146, 147 ], + "value": "(" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 38 + "column": 40 }, - "end": { + "start": { "line": 5, "column": 39 } - } - }, - { - "type": "Punctuator", - "value": ")", + }, "range": [ 147, 148 ], - "loc": { - "start": { - "line": 5, - "column": 39 - }, - "end": { - "line": 5, - "column": 40 - } - } + "value": ")" }, { "type": "Keyword", - "value": "const", + "loc": { + "end": { + "line": 6, + "column": 5 + }, + "start": { + "line": 6, + "column": 0 + } + }, "range": [ 149, 154 ], + "value": "const" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 6, - "column": 0 + "column": 9 }, - "end": { + "start": { "line": 6, - "column": 5 + "column": 6 } - } - }, - { - "type": "Identifier", - "value": "foo", + }, "range": [ 155, 158 ], + "value": "foo" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 6, - "column": 6 + "column": 11 }, - "end": { + "start": { "line": 6, - "column": 9 + "column": 10 } - } - }, - { - "type": "Punctuator", - "value": "=", + }, "range": [ 159, 160 ], + "value": "=" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 6, - "column": 10 + "column": 13 }, - "end": { + "start": { "line": 6, - "column": 11 + "column": 12 } - } - }, - { - "type": "Identifier", - "value": "p", + }, "range": [ 161, 162 ], + "value": "p" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 6, - "column": 12 + "column": 14 }, - "end": { + "start": { "line": 6, "column": 13 } - } - }, - { - "type": "Punctuator", - "value": ".", + }, "range": [ 162, 163 ], - "loc": { - "start": { - "line": 6, - "column": 13 - }, - "end": { - "line": 6, - "column": 14 - } - } + "value": "." }, { "type": "Identifier", - "value": "foo", - "range": [ - 163, - 166 - ], "loc": { - "start": { - "line": 6, - "column": 14 - }, "end": { "line": 6, "column": 17 + }, + "start": { + "line": 6, + "column": 14 } - } + }, + "range": [ + 163, + 166 + ], + "value": "foo" }, { "type": "Identifier", - "value": "console", + "loc": { + "end": { + "line": 7, + "column": 7 + }, + "start": { + "line": 7, + "column": 0 + } + }, "range": [ 167, 174 ], + "value": "console" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 7, - "column": 0 + "column": 8 }, - "end": { + "start": { "line": 7, "column": 7 } - } - }, - { - "type": "Punctuator", - "value": ".", + }, "range": [ 174, 175 ], + "value": "." + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 7, - "column": 7 + "column": 11 }, - "end": { + "start": { "line": 7, "column": 8 } - } - }, - { - "type": "Identifier", - "value": "log", + }, "range": [ 175, 178 ], + "value": "log" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 7, - "column": 8 + "column": 12 }, - "end": { + "start": { "line": 7, "column": 11 } - } - }, - { - "type": "Punctuator", - "value": "(", + }, "range": [ 178, 179 ], + "value": "(" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 7, - "column": 11 + "column": 15 }, - "end": { + "start": { "line": 7, "column": 12 } - } - }, - { - "type": "Identifier", - "value": "foo", + }, "range": [ 179, 182 ], + "value": "foo" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 7, - "column": 12 + "column": 16 }, - "end": { + "start": { "line": 7, "column": 15 } - } - }, - { - "type": "Punctuator", - "value": ")", + }, "range": [ 182, 183 ], - "loc": { - "start": { - "line": 7, - "column": 15 - }, - "end": { - "line": 7, - "column": 16 - } - } + "value": ")" }, { "type": "Punctuator", @@ -1335,7 +1363,16 @@ "value": "</script>" } ], - "comments": [], + "loc": { + "end": { + "line": 7, + "column": 16 + }, + "start": { + "line": 2, + "column": 0 + } + }, "templateBody": { "type": "VElement", "range": [ @@ -1411,19 +1448,21 @@ }, "expression": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 207, 210 ], "loc": { - "start": { - "line": 10, - "column": 2 - }, "end": { "line": 10, "column": 5 + }, + "start": { + "line": 10, + "column": 2 } } }, @@ -1431,19 +1470,21 @@ { "id": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 207, 210 ], "loc": { - "start": { - "line": 10, - "column": 2 - }, "end": { "line": 10, "column": 5 + }, + "start": { + "line": 10, + "column": 2 } } }, @@ -1961,129 +2002,129 @@ }, { "type": "Identifier", - "value": "T", + "loc": { + "end": { + "line": 4, + "column": 34 + }, + "start": { + "line": 4, + "column": 33 + } + }, "range": [ 79, 80 ], + "value": "T" + }, + { + "type": "Keyword", "loc": { - "start": { + "end": { "line": 4, - "column": 33 + "column": 42 }, - "end": { + "start": { "line": 4, - "column": 34 + "column": 35 } - } - }, - { - "type": "Keyword", - "value": "extends", + }, "range": [ 81, 88 ], + "value": "extends" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 4, - "column": 35 + "column": 46 }, - "end": { + "start": { "line": 4, - "column": 42 + "column": 43 } - } - }, - { - "type": "Identifier", - "value": "Foo", + }, "range": [ 89, 92 ], + "value": "Foo" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 4, - "column": 43 + "column": 47 }, - "end": { + "start": { "line": 4, "column": 46 } - } - }, - { - "type": "Punctuator", - "value": ",", + }, "range": [ 92, 93 ], + "value": "," + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 4, - "column": 46 + "column": 49 }, - "end": { + "start": { "line": 4, - "column": 47 + "column": 48 } - } - }, - { - "type": "Identifier", - "value": "U", + }, "range": [ 94, 95 ], + "value": "U" + }, + { + "type": "Keyword", "loc": { - "start": { + "end": { "line": 4, - "column": 48 + "column": 57 }, - "end": { + "start": { "line": 4, - "column": 49 + "column": 50 } - } - }, - { - "type": "Keyword", - "value": "extends", + }, "range": [ 96, 103 ], + "value": "extends" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 4, - "column": 50 + "column": 59 }, - "end": { + "start": { "line": 4, - "column": 57 + "column": 58 } - } - }, - { - "type": "Identifier", - "value": "T", + }, "range": [ 104, 105 ], - "loc": { - "start": { - "line": 4, - "column": 58 - }, - "end": { - "line": 4, - "column": 59 - } - } + "value": "T" }, { "type": "Punctuator", @@ -2663,21 +2704,21 @@ }, { "type": "Identifier", - "value": "foo", - "range": [ - 207, - 210 - ], "loc": { - "start": { - "line": 10, - "column": 2 - }, "end": { "line": 10, "column": 5 + }, + "start": { + "line": 10, + "column": 2 } - } + }, + "range": [ + 207, + 210 + ], + "value": "foo" }, { "type": "VExpressionEnd", diff --git a/test/fixtures/ast/vue3.3-generic-3/scope.json b/test/fixtures/ast/vue3.3-generic-3/scope.json index 07bfd168..fb10e250 100644 --- a/test/fixtures/ast/vue3.3-generic-3/scope.json +++ b/test/fixtures/ast/vue3.3-generic-3/scope.json @@ -2,911 +2,1162 @@ "type": "global", "variables": [ { - "name": "ClassMemberDecoratorContext", + "name": "Intl", "identifiers": [], "defs": [], "references": [] }, { - "name": "DecoratorContext", + "name": "SymbolConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassDecoratorContext", + "name": "Function", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassMethodDecoratorContext", + "name": "Disposable", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassGetterDecoratorContext", + "name": "AsyncDisposable", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassSetterDecoratorContext", + "name": "SuppressedError", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassAccessorDecoratorContext", + "name": "SuppressedErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassAccessorDecoratorTarget", + "name": "DisposableStack", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassAccessorDecoratorResult", + "name": "DisposableStackConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassFieldDecoratorContext", + "name": "AsyncDisposableStack", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassDecorator", + "name": "AsyncDisposableStackConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "PropertyDecorator", + "name": "IteratorObject", "identifiers": [], "defs": [], "references": [] }, { - "name": "MethodDecorator", + "name": "AsyncIteratorObject", "identifiers": [], "defs": [], "references": [] }, { - "name": "ParameterDecorator", + "name": "ReadonlySetLike", "identifiers": [], "defs": [], "references": [] }, { - "name": "Symbol", + "name": "Set", "identifiers": [], "defs": [], "references": [] }, { - "name": "PropertyKey", + "name": "ReadonlySet", "identifiers": [], "defs": [], "references": [] }, { - "name": "PropertyDescriptor", + "name": "ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "PropertyDescriptorMap", + "name": "Iterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "Object", + "name": "IteratorObjectConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ObjectConstructor", + "name": "PromiseConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Function", + "name": "Float16Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "FunctionConstructor", + "name": "Float16ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ThisParameterType", + "name": "Math", "identifiers": [], "defs": [], "references": [] }, { - "name": "OmitThisParameter", + "name": "DataView", "identifiers": [], "defs": [], "references": [] }, { - "name": "CallableFunction", + "name": "ArrayBuffer", "identifiers": [], "defs": [], "references": [] }, { - "name": "NewableFunction", + "name": "ArrayBufferConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "IArguments", + "name": "MapConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "String", + "name": "ObjectConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "StringConstructor", + "name": "PromiseWithResolvers", "identifiers": [], "defs": [], "references": [] }, { - "name": "Boolean", + "name": "RegExp", "identifiers": [], "defs": [], "references": [] }, { - "name": "BooleanConstructor", + "name": "Atomics", "identifiers": [], "defs": [], "references": [] }, { - "name": "Number", + "name": "SharedArrayBuffer", "identifiers": [], "defs": [], "references": [] }, { - "name": "NumberConstructor", + "name": "SharedArrayBufferConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "TemplateStringsArray", + "name": "String", "identifiers": [], "defs": [], "references": [] }, { - "name": "ImportMeta", + "name": "ClassMemberDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "ImportCallOptions", + "name": "DecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "ImportAssertions", + "name": "DecoratorMetadataObject", "identifiers": [], "defs": [], "references": [] }, { - "name": "Math", + "name": "DecoratorMetadata", "identifiers": [], "defs": [], "references": [] }, { - "name": "Date", + "name": "ClassDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "DateConstructor", + "name": "ClassMethodDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "RegExpMatchArray", + "name": "ClassGetterDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "RegExpExecArray", + "name": "ClassSetterDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "RegExp", + "name": "ClassAccessorDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "RegExpConstructor", + "name": "ClassAccessorDecoratorTarget", "identifiers": [], "defs": [], "references": [] }, { - "name": "Error", + "name": "ClassAccessorDecoratorResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "ErrorConstructor", + "name": "ClassFieldDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "EvalError", + "name": "IteratorYieldResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "EvalErrorConstructor", + "name": "IteratorReturnResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "RangeError", + "name": "IteratorResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "RangeErrorConstructor", + "name": "Iterable", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReferenceError", + "name": "IterableIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReferenceErrorConstructor", + "name": "BuiltinIteratorReturn", "identifiers": [], "defs": [], "references": [] }, { - "name": "SyntaxError", + "name": "ArrayIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "SyntaxErrorConstructor", + "name": "Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "TypeError", + "name": "ReadonlyArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "TypeErrorConstructor", + "name": "IArguments", "identifiers": [], "defs": [], "references": [] }, { - "name": "URIError", + "name": "MapIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "URIErrorConstructor", + "name": "Map", "identifiers": [], "defs": [], "references": [] }, { - "name": "JSON", + "name": "ReadonlyMap", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReadonlyArray", + "name": "WeakMap", "identifiers": [], "defs": [], "references": [] }, { - "name": "ConcatArray", + "name": "WeakMapConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Array", + "name": "SetIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayConstructor", + "name": "SetConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "TypedPropertyDescriptor", + "name": "WeakSet", "identifiers": [], "defs": [], "references": [] }, { - "name": "PromiseConstructorLike", + "name": "WeakSetConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "PromiseLike", + "name": "Promise", "identifiers": [], "defs": [], "references": [] }, { - "name": "Promise", + "name": "StringIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "Awaited", + "name": "Int8Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayLike", + "name": "Int8ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Partial", + "name": "Uint8Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Required", + "name": "Uint8ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Readonly", + "name": "Uint8ClampedArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "Pick", + "name": "Uint8ClampedArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Record", + "name": "Int16Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Exclude", + "name": "Int16ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Extract", + "name": "Uint16Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Omit", + "name": "Uint16ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "NonNullable", + "name": "Int32Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Parameters", + "name": "Int32ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ConstructorParameters", + "name": "Uint32Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReturnType", + "name": "Uint32ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "InstanceType", + "name": "Float32Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uppercase", + "name": "Float32ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Lowercase", + "name": "Float64Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Capitalize", + "name": "Float64ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uncapitalize", + "name": "AsyncIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "ThisType", + "name": "AsyncIterable", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayBuffer", + "name": "AsyncIterableIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayBufferTypes", + "name": "BigInt64Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayBufferLike", + "name": "BigUint64Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayBufferConstructor", + "name": "WeakKeyTypes", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayBufferView", + "name": "BigIntToLocaleStringOptions", "identifiers": [], "defs": [], "references": [] }, { - "name": "DataView", + "name": "BigInt", "identifiers": [], "defs": [], "references": [] }, { - "name": "DataViewConstructor", + "name": "BigIntConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int8Array", + "name": "BigInt64ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int8ArrayConstructor", + "name": "BigUint64ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint8Array", + "name": "ErrorOptions", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint8ArrayConstructor", + "name": "Error", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint8ClampedArray", + "name": "ErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint8ClampedArrayConstructor", + "name": "EvalErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int16Array", + "name": "RangeErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int16ArrayConstructor", + "name": "ReferenceErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint16Array", + "name": "SyntaxErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint16ArrayConstructor", + "name": "TypeErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int32Array", + "name": "URIErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int32ArrayConstructor", + "name": "AggregateErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint32Array", + "name": "RegExpMatchArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint32ArrayConstructor", + "name": "RegExpExecArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "Float32Array", + "name": "RegExpIndicesArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "Float32ArrayConstructor", + "name": "AggregateError", "identifiers": [], "defs": [], "references": [] }, { - "name": "Float64Array", + "name": "WeakRef", "identifiers": [], "defs": [], "references": [] }, { - "name": "Float64ArrayConstructor", + "name": "WeakRefConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Intl", + "name": "FinalizationRegistry", "identifiers": [], "defs": [], "references": [] }, { - "name": "Map", + "name": "FinalizationRegistryConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "MapConstructor", + "name": "Date", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReadonlyMap", + "name": "Number", "identifiers": [], "defs": [], "references": [] }, { - "name": "WeakMap", + "name": "PromiseFulfilledResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "WeakMapConstructor", + "name": "PromiseRejectedResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "Set", + "name": "PromiseSettledResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "SetConstructor", + "name": "RegExpStringIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReadonlySet", + "name": "Symbol", "identifiers": [], "defs": [], "references": [] }, { - "name": "WeakSet", + "name": "JSON", "identifiers": [], "defs": [], "references": [] }, { - "name": "WeakSetConstructor", + "name": "GeneratorFunction", "identifiers": [], "defs": [], "references": [] }, { - "name": "SymbolConstructor", + "name": "RegExpConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "IteratorYieldResult", + "name": "FlatArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "IteratorReturnResult", + "name": "AsyncGenerator", "identifiers": [], "defs": [], "references": [] }, { - "name": "IteratorResult", + "name": "AsyncGeneratorFunction", "identifiers": [], "defs": [], "references": [] }, { - "name": "Iterator", + "name": "AsyncGeneratorFunctionConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Iterable", + "name": "DateConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "IterableIterator", + "name": "ArrayBufferTypes", "identifiers": [], "defs": [], "references": [] }, { - "name": "PromiseConstructor", + "name": "PropertyKey", "identifiers": [], "defs": [], "references": [] }, { - "name": "Generator", + "name": "PropertyDescriptor", "identifiers": [], "defs": [], "references": [] }, { - "name": "GeneratorFunction", + "name": "PropertyDescriptorMap", "identifiers": [], "defs": [], "references": [] }, { - "name": "GeneratorFunctionConstructor", + "name": "Object", "identifiers": [], "defs": [], "references": [] }, { - "name": "ProxyHandler", + "name": "FunctionConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ProxyConstructor", + "name": "ThisParameterType", "identifiers": [], "defs": [], "references": [] }, { - "name": "Reflect", + "name": "OmitThisParameter", "identifiers": [], "defs": [], "references": [] }, { - "name": "SharedArrayBuffer", + "name": "CallableFunction", "identifiers": [], "defs": [], "references": [] }, { - "name": "SharedArrayBufferConstructor", + "name": "NewableFunction", "identifiers": [], "defs": [], "references": [] }, { - "name": "Atomics", + "name": "StringConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncIterator", + "name": "Boolean", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncIterable", + "name": "BooleanConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncIterableIterator", + "name": "NumberConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncGenerator", + "name": "TemplateStringsArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncGeneratorFunction", + "name": "ImportMeta", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncGeneratorFunctionConstructor", + "name": "ImportCallOptions", "identifiers": [], "defs": [], "references": [] }, { - "name": "const", + "name": "ImportAssertions", "identifiers": [], "defs": [], "references": [] }, { - "name": "defineProps", + "name": "ImportAttributes", "identifiers": [], "defs": [], - "references": [ - { - "identifier": { - "type": "Identifier", - "name": "defineProps", - "loc": { - "start": { - "line": 5, - "column": 10 - }, - "end": { - "line": 5, - "column": 21 - } - } - }, - "from": "module", - "init": null - } - ] + "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": "T", @@ -918,13 +1169,31 @@ "type": "Identifier", "name": "T", "loc": { - "start": { - "line": 5, - "column": 27 + "end": { + "column": 11, + "line": 8 }, + "start": { + "column": 10, + "line": 8 + } + } + }, + "from": "module", + "init": null + }, + { + "identifier": { + "type": "Identifier", + "name": "T", + "loc": { "end": { "line": 5, "column": 28 + }, + "start": { + "line": 5, + "column": 27 } } }, @@ -934,22 +1203,22 @@ ] }, { - "name": "U", + "name": "defineProps", "identifiers": [], "defs": [], "references": [ { "identifier": { "type": "Identifier", - "name": "U", + "name": "defineProps", "loc": { - "start": { + "end": { "line": 5, - "column": 35 + "column": 21 }, - "end": { + "start": { "line": 5, - "column": 36 + "column": 10 } } }, @@ -971,13 +1240,13 @@ "type": "Identifier", "name": "Foo", "loc": { - "start": { - "line": 2, - "column": 5 - }, "end": { "line": 2, "column": 8 + }, + "start": { + "line": 2, + "column": 5 } } } @@ -988,13 +1257,13 @@ "node": { "type": "TSTypeAliasDeclaration", "loc": { - "start": { - "line": 2, - "column": 0 - }, "end": { "line": 2, "column": 26 + }, + "start": { + "line": 2, + "column": 0 } } }, @@ -1007,13 +1276,13 @@ "type": "Identifier", "name": "Foo", "loc": { - "start": { - "line": 2, - "column": 5 - }, "end": { "line": 2, "column": 8 + }, + "start": { + "line": 2, + "column": 5 } } }, @@ -1022,13 +1291,13 @@ "type": "Identifier", "name": "Foo", "loc": { - "start": { - "line": 2, - "column": 5 - }, "end": { "line": 2, "column": 8 + }, + "start": { + "line": 2, + "column": 5 } } }, @@ -1037,6 +1306,78 @@ } ] }, + { + "name": "U", + "identifiers": [ + { + "type": "Identifier", + "name": "U", + "loc": { + "end": { + "column": 6, + "line": 8 + }, + "start": { + "column": 5, + "line": 8 + } + } + } + ], + "defs": [ + { + "type": "Type", + "node": { + "type": "TSTypeAliasDeclaration", + "loc": { + "end": { + "column": 1, + "line": 9 + }, + "start": { + "column": 0, + "line": 8 + } + } + }, + "name": "U" + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "U", + "loc": { + "end": { + "line": 5, + "column": 36 + }, + "start": { + "line": 5, + "column": 35 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "U", + "loc": { + "end": { + "column": 6, + "line": 8 + }, + "start": { + "column": 5, + "line": 8 + } + } + }, + "init": null + } + ] + }, { "name": "p", "identifiers": [ @@ -1044,13 +1385,13 @@ "type": "Identifier", "name": "p", "loc": { - "start": { - "line": 5, - "column": 6 - }, "end": { "line": 5, "column": 7 + }, + "start": { + "line": 5, + "column": 6 } } } @@ -1061,13 +1402,13 @@ "node": { "type": "VariableDeclarator", "loc": { - "start": { - "line": 5, - "column": 6 - }, "end": { "line": 5, "column": 40 + }, + "start": { + "line": 5, + "column": 6 } } }, @@ -1080,13 +1421,13 @@ "type": "Identifier", "name": "p", "loc": { - "start": { + "end": { "line": 5, - "column": 6 + "column": 7 }, - "end": { + "start": { "line": 5, - "column": 7 + "column": 6 } } }, @@ -1095,13 +1436,13 @@ "type": "Identifier", "name": "p", "loc": { - "start": { - "line": 5, - "column": 6 - }, "end": { "line": 5, "column": 7 + }, + "start": { + "line": 5, + "column": 6 } } }, @@ -1112,13 +1453,13 @@ "type": "Identifier", "name": "p", "loc": { - "start": { - "line": 6, - "column": 12 - }, "end": { "line": 6, "column": 13 + }, + "start": { + "line": 6, + "column": 12 } } }, @@ -1127,13 +1468,13 @@ "type": "Identifier", "name": "p", "loc": { - "start": { - "line": 5, - "column": 6 - }, "end": { "line": 5, "column": 7 + }, + "start": { + "line": 5, + "column": 6 } } }, @@ -1148,13 +1489,13 @@ "type": "Identifier", "name": "foo", "loc": { - "start": { - "line": 6, - "column": 6 - }, "end": { "line": 6, "column": 9 + }, + "start": { + "line": 6, + "column": 6 } } } @@ -1165,13 +1506,13 @@ "node": { "type": "VariableDeclarator", "loc": { - "start": { - "line": 6, - "column": 6 - }, "end": { "line": 6, "column": 17 + }, + "start": { + "line": 6, + "column": 6 } } }, @@ -1184,13 +1525,13 @@ "type": "Identifier", "name": "foo", "loc": { - "start": { - "line": 6, - "column": 6 - }, "end": { "line": 6, "column": 9 + }, + "start": { + "line": 6, + "column": 6 } } }, @@ -1199,13 +1540,13 @@ "type": "Identifier", "name": "foo", "loc": { - "start": { - "line": 6, - "column": 6 - }, "end": { "line": 6, "column": 9 + }, + "start": { + "line": 6, + "column": 6 } } }, @@ -1216,13 +1557,13 @@ "type": "Identifier", "name": "foo", "loc": { - "start": { - "line": 7, - "column": 12 - }, "end": { "line": 7, "column": 15 + }, + "start": { + "line": 7, + "column": 12 } } }, @@ -1231,13 +1572,13 @@ "type": "Identifier", "name": "foo", "loc": { - "start": { - "line": 6, - "column": 6 - }, "end": { "line": 6, "column": 9 + }, + "start": { + "line": 6, + "column": 6 } } }, @@ -1248,13 +1589,13 @@ "type": "Identifier", "name": "foo", "loc": { - "start": { - "line": 6, - "column": 6 - }, "end": { "line": 6, "column": 9 + }, + "start": { + "line": 6, + "column": 6 } } }, @@ -1263,13 +1604,13 @@ "type": "Identifier", "name": "foo", "loc": { - "start": { - "line": 6, - "column": 6 - }, "end": { "line": 6, "column": 9 + }, + "start": { + "line": 6, + "column": 6 } } }, @@ -1283,15 +1624,33 @@ { "identifier": { "type": "Identifier", - "name": "p", + "name": "T", "loc": { - "start": { - "line": 5, - "column": 6 + "end": { + "column": 11, + "line": 8 }, + "start": { + "column": 10, + "line": 8 + } + } + }, + "from": "module", + "init": null + }, + { + "identifier": { + "type": "Identifier", + "name": "p", + "loc": { "end": { "line": 5, "column": 7 + }, + "start": { + "line": 5, + "column": 6 } } }, @@ -1300,13 +1659,13 @@ "type": "Identifier", "name": "p", "loc": { - "start": { - "line": 5, - "column": 6 - }, "end": { "line": 5, "column": 7 + }, + "start": { + "line": 5, + "column": 6 } } }, @@ -1317,13 +1676,13 @@ "type": "Identifier", "name": "defineProps", "loc": { - "start": { - "line": 5, - "column": 10 - }, "end": { "line": 5, "column": 21 + }, + "start": { + "line": 5, + "column": 10 } } }, @@ -1335,13 +1694,13 @@ "type": "Identifier", "name": "T", "loc": { - "start": { - "line": 5, - "column": 27 - }, "end": { "line": 5, "column": 28 + }, + "start": { + "line": 5, + "column": 27 } } }, @@ -1353,17 +1712,31 @@ "type": "Identifier", "name": "U", "loc": { - "start": { - "line": 5, - "column": 35 - }, "end": { "line": 5, "column": 36 + }, + "start": { + "line": 5, + "column": 35 } } }, "from": "module", + "resolved": { + "type": "Identifier", + "name": "U", + "loc": { + "end": { + "column": 6, + "line": 8 + }, + "start": { + "column": 5, + "line": 8 + } + } + }, "init": null }, { @@ -1371,13 +1744,13 @@ "type": "Identifier", "name": "foo", "loc": { - "start": { - "line": 6, - "column": 6 - }, "end": { "line": 6, "column": 9 + }, + "start": { + "line": 6, + "column": 6 } } }, @@ -1386,13 +1759,13 @@ "type": "Identifier", "name": "foo", "loc": { - "start": { - "line": 6, - "column": 6 - }, "end": { "line": 6, "column": 9 + }, + "start": { + "line": 6, + "column": 6 } } }, @@ -1403,13 +1776,13 @@ "type": "Identifier", "name": "p", "loc": { - "start": { - "line": 6, - "column": 12 - }, "end": { "line": 6, "column": 13 + }, + "start": { + "line": 6, + "column": 12 } } }, @@ -1418,13 +1791,13 @@ "type": "Identifier", "name": "p", "loc": { - "start": { - "line": 5, - "column": 6 - }, "end": { "line": 5, "column": 7 + }, + "start": { + "line": 5, + "column": 6 } } }, @@ -1435,13 +1808,13 @@ "type": "Identifier", "name": "console", "loc": { - "start": { - "line": 7, - "column": 0 - }, "end": { "line": 7, "column": 7 + }, + "start": { + "line": 7, + "column": 0 } } }, @@ -1454,13 +1827,13 @@ "type": "Identifier", "name": "foo", "loc": { - "start": { - "line": 7, - "column": 12 - }, "end": { "line": 7, "column": 15 + }, + "start": { + "line": 7, + "column": 12 } } }, @@ -1469,13 +1842,13 @@ "type": "Identifier", "name": "foo", "loc": { - "start": { - "line": 6, - "column": 6 - }, "end": { "line": 6, "column": 9 + }, + "start": { + "line": 6, + "column": 6 } } }, @@ -1487,15 +1860,15 @@ { "identifier": { "type": "Identifier", - "name": "defineProps", + "name": "T", "loc": { - "start": { - "line": 5, - "column": 10 - }, "end": { - "line": 5, - "column": 21 + "column": 11, + "line": 8 + }, + "start": { + "column": 10, + "line": 8 } } }, @@ -1505,15 +1878,15 @@ { "identifier": { "type": "Identifier", - "name": "T", + "name": "defineProps", "loc": { - "start": { + "end": { "line": 5, - "column": 27 + "column": 21 }, - "end": { + "start": { "line": 5, - "column": 28 + "column": 10 } } }, @@ -1523,15 +1896,15 @@ { "identifier": { "type": "Identifier", - "name": "U", + "name": "T", "loc": { - "start": { + "end": { "line": 5, - "column": 35 + "column": 28 }, - "end": { + "start": { "line": 5, - "column": 36 + "column": 27 } } }, @@ -1543,13 +1916,13 @@ "type": "Identifier", "name": "console", "loc": { - "start": { - "line": 7, - "column": 0 - }, "end": { "line": 7, "column": 7 + }, + "start": { + "line": 7, + "column": 0 } } }, @@ -1566,13 +1939,13 @@ "type": "Identifier", "name": "console", "loc": { - "start": { - "line": 7, - "column": 0 - }, "end": { "line": 7, "column": 7 + }, + "start": { + "line": 7, + "column": 0 } } }, 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 index 401cda3f..6efed59a 100644 --- a/test/fixtures/ast/vue3.3-generic-4-with-spaces/ast.json +++ b/test/fixtures/ast/vue3.3-generic-4-with-spaces/ast.json @@ -1,23 +1,30 @@ { "type": "Program", + "range": [ + 92, + 195 + ], "body": [ { "type": "TSTypeAliasDeclaration", + "declare": false, "id": { "type": "Identifier", + "decorators": [], "name": "Foo", + "optional": false, "range": [ 97, 100 ], "loc": { - "start": { - "line": 8, - "column": 5 - }, "end": { "line": 8, "column": 8 + }, + "start": { + "line": 8, + "column": 5 } } }, @@ -31,13 +38,13 @@ 109 ], "loc": { - "start": { - "line": 8, - "column": 11 - }, "end": { "line": 8, "column": 17 + }, + "start": { + "line": 8, + "column": 11 } } }, @@ -48,13 +55,13 @@ 118 ], "loc": { - "start": { - "line": 8, - "column": 20 - }, "end": { "line": 8, "column": 26 + }, + "start": { + "line": 8, + "column": 20 } } } @@ -64,13 +71,13 @@ 118 ], "loc": { - "start": { - "line": 8, - "column": 11 - }, "end": { "line": 8, "column": 26 + }, + "start": { + "line": 8, + "column": 11 } } }, @@ -79,13 +86,13 @@ 118 ], "loc": { - "start": { - "line": 8, - "column": 0 - }, "end": { "line": 8, "column": 26 + }, + "start": { + "line": 8, + "column": 0 } } }, @@ -94,61 +101,52 @@ "declarations": [ { "type": "VariableDeclarator", + "definite": false, "id": { "type": "Identifier", + "decorators": [], "name": "p", + "optional": false, "range": [ 125, 126 ], "loc": { - "start": { - "line": 9, - "column": 6 - }, "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": { - "start": { - "line": 9, - "column": 10 - }, "end": { "line": 9, "column": 21 + }, + "start": { + "line": 9, + "column": 10 } } }, - "arguments": [], "optional": false, - "range": [ - 129, - 159 - ], - "loc": { - "start": { - "line": 9, - "column": 10 - }, - "end": { - "line": 9, - "column": 40 - } - }, - "typeParameters": { + "typeArguments": { "type": "TSTypeParameterInstantiation", "range": [ 140, @@ -163,32 +161,37 @@ "computed": false, "key": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 142, 145 ], "loc": { - "start": { - "line": 9, - "column": 23 - }, "end": { "line": 9, "column": 26 + }, + "start": { + "line": 9, + "column": 23 } } }, + "optional": false, + "readonly": false, + "static": false, "typeAnnotation": { "type": "TSTypeAnnotation", "loc": { - "start": { - "line": 9, - "column": 26 - }, "end": { "line": 9, "column": 28 + }, + "start": { + "line": 9, + "column": 26 } }, "range": [ @@ -199,19 +202,21 @@ "type": "TSTypeReference", "typeName": { "type": "Identifier", + "decorators": [], "name": "T", + "optional": false, "range": [ 146, 147 ], "loc": { - "start": { - "line": 9, - "column": 27 - }, "end": { "line": 9, "column": 28 + }, + "start": { + "line": 9, + "column": 27 } } }, @@ -220,13 +225,13 @@ 147 ], "loc": { - "start": { - "line": 9, - "column": 27 - }, "end": { "line": 9, "column": 28 + }, + "start": { + "line": 9, + "column": 27 } } } @@ -236,13 +241,13 @@ 148 ], "loc": { - "start": { - "line": 9, - "column": 23 - }, "end": { "line": 9, "column": 29 + }, + "start": { + "line": 9, + "column": 23 } } }, @@ -251,32 +256,37 @@ "computed": false, "key": { "type": "Identifier", + "decorators": [], "name": "bar", + "optional": false, "range": [ 149, 152 ], "loc": { - "start": { - "line": 9, - "column": 30 - }, "end": { "line": 9, "column": 33 + }, + "start": { + "line": 9, + "column": 30 } } }, + "optional": false, + "readonly": false, + "static": false, "typeAnnotation": { "type": "TSTypeAnnotation", "loc": { - "start": { - "line": 9, - "column": 33 - }, "end": { "line": 9, "column": 36 + }, + "start": { + "line": 9, + "column": 33 } }, "range": [ @@ -287,19 +297,21 @@ "type": "TSTypeReference", "typeName": { "type": "Identifier", + "decorators": [], "name": "U", + "optional": false, "range": [ 154, 155 ], "loc": { - "start": { - "line": 9, - "column": 35 - }, "end": { "line": 9, "column": 36 + }, + "start": { + "line": 9, + "column": 35 } } }, @@ -308,13 +320,13 @@ 155 ], "loc": { - "start": { - "line": 9, - "column": 35 - }, "end": { "line": 9, "column": 36 + }, + "start": { + "line": 9, + "column": 35 } } } @@ -324,13 +336,13 @@ 155 ], "loc": { - "start": { - "line": 9, - "column": 30 - }, "end": { "line": 9, "column": 36 + }, + "start": { + "line": 9, + "column": 30 } } } @@ -340,27 +352,41 @@ 156 ], "loc": { - "start": { - "line": 9, - "column": 22 - }, "end": { "line": 9, "column": 37 + }, + "start": { + "line": 9, + "column": 22 } } } ], "loc": { - "start": { - "line": 9, - "column": 21 - }, "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": [ @@ -368,30 +394,31 @@ 159 ], "loc": { - "start": { - "line": 9, - "column": 6 - }, "end": { "line": 9, "column": 40 + }, + "start": { + "line": 9, + "column": 6 } } } ], + "declare": false, "kind": "const", "range": [ 119, 159 ], "loc": { - "start": { - "line": 9, - "column": 0 - }, "end": { "line": 9, "column": 40 + }, + "start": { + "line": 9, + "column": 0 } } }, @@ -400,76 +427,83 @@ "declarations": [ { "type": "VariableDeclarator", + "definite": false, "id": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 166, 169 ], "loc": { - "start": { - "line": 10, - "column": 6 - }, "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": { - "start": { - "line": 10, - "column": 12 - }, "end": { "line": 10, "column": 13 + }, + "start": { + "line": 10, + "column": 12 } } }, + "optional": false, "property": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 174, 177 ], "loc": { - "start": { - "line": 10, - "column": 14 - }, "end": { "line": 10, "column": 17 + }, + "start": { + "line": 10, + "column": 14 } } }, - "computed": false, - "optional": false, "range": [ 172, 177 ], "loc": { - "start": { - "line": 10, - "column": 12 - }, "end": { "line": 10, "column": 17 + }, + "start": { + "line": 10, + "column": 12 } } }, @@ -478,125 +512,132 @@ 177 ], "loc": { - "start": { - "line": 10, - "column": 6 - }, "end": { "line": 10, "column": 17 + }, + "start": { + "line": 10, + "column": 6 } } } ], + "declare": false, "kind": "const", "range": [ 160, 177 ], "loc": { - "start": { - "line": 10, - "column": 0 - }, "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": { - "start": { - "line": 11, - "column": 0 - }, "end": { "line": 11, "column": 7 + }, + "start": { + "line": 11, + "column": 0 } } }, + "optional": false, "property": { "type": "Identifier", + "decorators": [], "name": "log", + "optional": false, "range": [ 186, 189 ], "loc": { - "start": { - "line": 11, - "column": 8 - }, "end": { "line": 11, "column": 11 + }, + "start": { + "line": 11, + "column": 8 } } }, - "computed": false, - "optional": false, "range": [ 178, 189 ], "loc": { - "start": { - "line": 11, - "column": 0 - }, "end": { "line": 11, "column": 11 + }, + "start": { + "line": 11, + "column": 0 } } }, - "arguments": [ - { - "type": "Identifier", - "name": "foo", - "range": [ - 190, - 193 - ], - "loc": { - "start": { - "line": 11, - "column": 12 - }, - "end": { - "line": 11, - "column": 15 - } - } - } - ], "optional": false, "range": [ 178, 194 ], "loc": { - "start": { - "line": 11, - "column": 0 - }, "end": { "line": 11, "column": 16 + }, + "start": { + "line": 11, + "column": 0 } } }, @@ -605,32 +646,19 @@ 194 ], "loc": { - "start": { - "line": 11, - "column": 0 - }, "end": { "line": 11, "column": 16 + }, + "start": { + "line": 11, + "column": 0 } } } ], + "comments": [], "sourceType": "module", - "range": [ - 92, - 195 - ], - "loc": { - "start": { - "line": 8, - "column": 0 - }, - "end": { - "line": 12, - "column": 0 - } - }, "tokens": [ { "type": "Punctuator", @@ -652,633 +680,633 @@ }, { "type": "Identifier", - "value": "type", + "loc": { + "end": { + "line": 8, + "column": 4 + }, + "start": { + "line": 8, + "column": 0 + } + }, "range": [ 92, 96 ], + "value": "type" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 8, - "column": 0 + "column": 8 }, - "end": { + "start": { "line": 8, - "column": 4 + "column": 5 } - } - }, - { - "type": "Identifier", - "value": "Foo", + }, "range": [ 97, 100 ], + "value": "Foo" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 8, - "column": 5 + "column": 10 }, - "end": { + "start": { "line": 8, - "column": 8 + "column": 9 } - } - }, - { - "type": "Punctuator", - "value": "=", + }, "range": [ 101, 102 ], + "value": "=" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 8, - "column": 9 + "column": 17 }, - "end": { + "start": { "line": 8, - "column": 10 + "column": 11 } - } - }, - { - "type": "Identifier", - "value": "number", + }, "range": [ 103, 109 ], + "value": "number" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 8, - "column": 11 + "column": 19 }, - "end": { + "start": { "line": 8, - "column": 17 + "column": 18 } - } - }, - { - "type": "Punctuator", - "value": "|", + }, "range": [ 110, 111 ], + "value": "|" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 8, - "column": 18 + "column": 26 }, - "end": { + "start": { "line": 8, - "column": 19 + "column": 20 } - } - }, - { - "type": "Identifier", - "value": "string", + }, "range": [ 112, 118 ], - "loc": { - "start": { - "line": 8, - "column": 20 - }, - "end": { - "line": 8, - "column": 26 - } - } + "value": "string" }, { "type": "Keyword", - "value": "const", + "loc": { + "end": { + "line": 9, + "column": 5 + }, + "start": { + "line": 9, + "column": 0 + } + }, "range": [ 119, 124 ], + "value": "const" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 9, - "column": 0 + "column": 7 }, - "end": { + "start": { "line": 9, - "column": 5 + "column": 6 } - } - }, - { - "type": "Identifier", - "value": "p", + }, "range": [ 125, 126 ], + "value": "p" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 9, - "column": 6 + "column": 9 }, - "end": { + "start": { "line": 9, - "column": 7 + "column": 8 } - } - }, - { - "type": "Punctuator", - "value": "=", + }, "range": [ 127, 128 ], + "value": "=" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 9, - "column": 8 + "column": 21 }, - "end": { + "start": { "line": 9, - "column": 9 + "column": 10 } - } - }, - { - "type": "Identifier", - "value": "defineProps", + }, "range": [ 129, 140 ], + "value": "defineProps" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 9, - "column": 10 + "column": 22 }, - "end": { + "start": { "line": 9, "column": 21 } - } - }, - { - "type": "Punctuator", - "value": "<", + }, "range": [ 140, 141 ], + "value": "<" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 9, - "column": 21 + "column": 23 }, - "end": { + "start": { "line": 9, "column": 22 } - } - }, - { - "type": "Punctuator", - "value": "{", + }, "range": [ 141, 142 ], + "value": "{" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 9, - "column": 22 + "column": 26 }, - "end": { + "start": { "line": 9, "column": 23 } - } - }, - { - "type": "Identifier", - "value": "foo", + }, "range": [ 142, 145 ], + "value": "foo" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 9, - "column": 23 + "column": 27 }, - "end": { + "start": { "line": 9, "column": 26 } - } - }, - { - "type": "Punctuator", - "value": ":", + }, "range": [ 145, 146 ], + "value": ":" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 9, - "column": 26 + "column": 28 }, - "end": { + "start": { "line": 9, "column": 27 } - } - }, - { - "type": "Identifier", - "value": "T", + }, "range": [ 146, 147 ], + "value": "T" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 9, - "column": 27 + "column": 29 }, - "end": { + "start": { "line": 9, "column": 28 } - } - }, - { - "type": "Punctuator", - "value": ",", + }, "range": [ 147, 148 ], + "value": "," + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 9, - "column": 28 + "column": 33 }, - "end": { + "start": { "line": 9, - "column": 29 + "column": 30 } - } - }, - { - "type": "Identifier", - "value": "bar", + }, "range": [ 149, 152 ], + "value": "bar" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 9, - "column": 30 + "column": 34 }, - "end": { + "start": { "line": 9, "column": 33 } - } - }, - { - "type": "Punctuator", - "value": ":", + }, "range": [ 152, 153 ], + "value": ":" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 9, - "column": 33 + "column": 36 }, - "end": { + "start": { "line": 9, - "column": 34 + "column": 35 } - } - }, - { - "type": "Identifier", - "value": "U", + }, "range": [ 154, 155 ], + "value": "U" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 9, - "column": 35 + "column": 37 }, - "end": { + "start": { "line": 9, "column": 36 } - } - }, - { - "type": "Punctuator", - "value": "}", + }, "range": [ 155, 156 ], + "value": "}" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 9, - "column": 36 + "column": 38 }, - "end": { + "start": { "line": 9, "column": 37 } - } - }, - { - "type": "Punctuator", - "value": ">", + }, "range": [ 156, 157 ], + "value": ">" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 9, - "column": 37 + "column": 39 }, - "end": { + "start": { "line": 9, "column": 38 } - } - }, - { - "type": "Punctuator", - "value": "(", + }, "range": [ 157, 158 ], + "value": "(" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 9, - "column": 38 + "column": 40 }, - "end": { + "start": { "line": 9, "column": 39 } - } - }, - { - "type": "Punctuator", - "value": ")", + }, "range": [ 158, 159 ], - "loc": { - "start": { - "line": 9, - "column": 39 - }, - "end": { - "line": 9, - "column": 40 - } - } + "value": ")" }, { "type": "Keyword", - "value": "const", + "loc": { + "end": { + "line": 10, + "column": 5 + }, + "start": { + "line": 10, + "column": 0 + } + }, "range": [ 160, 165 ], + "value": "const" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 10, - "column": 0 + "column": 9 }, - "end": { + "start": { "line": 10, - "column": 5 + "column": 6 } - } - }, - { - "type": "Identifier", - "value": "foo", + }, "range": [ 166, 169 ], + "value": "foo" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 10, - "column": 6 + "column": 11 }, - "end": { + "start": { "line": 10, - "column": 9 + "column": 10 } - } - }, - { - "type": "Punctuator", - "value": "=", + }, "range": [ 170, 171 ], + "value": "=" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 10, - "column": 10 + "column": 13 }, - "end": { + "start": { "line": 10, - "column": 11 + "column": 12 } - } - }, - { - "type": "Identifier", - "value": "p", + }, "range": [ 172, 173 ], + "value": "p" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 10, - "column": 12 + "column": 14 }, - "end": { + "start": { "line": 10, "column": 13 } - } - }, - { - "type": "Punctuator", - "value": ".", + }, "range": [ 173, 174 ], + "value": "." + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 10, - "column": 13 + "column": 17 }, - "end": { + "start": { "line": 10, "column": 14 } - } - }, - { - "type": "Identifier", - "value": "foo", + }, "range": [ 174, 177 ], - "loc": { - "start": { - "line": 10, - "column": 14 - }, - "end": { - "line": 10, - "column": 17 - } - } + "value": "foo" }, { "type": "Identifier", - "value": "console", + "loc": { + "end": { + "line": 11, + "column": 7 + }, + "start": { + "line": 11, + "column": 0 + } + }, "range": [ 178, 185 ], + "value": "console" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 11, - "column": 0 + "column": 8 }, - "end": { + "start": { "line": 11, "column": 7 - } - } - }, - { - "type": "Punctuator", - "value": ".", + } + }, "range": [ 185, 186 ], + "value": "." + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 11, - "column": 7 + "column": 11 }, - "end": { + "start": { "line": 11, "column": 8 } - } - }, - { - "type": "Identifier", - "value": "log", + }, "range": [ 186, 189 ], + "value": "log" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 11, - "column": 8 + "column": 12 }, - "end": { + "start": { "line": 11, "column": 11 } - } - }, - { - "type": "Punctuator", - "value": "(", + }, "range": [ 189, 190 ], + "value": "(" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 11, - "column": 11 + "column": 15 }, - "end": { + "start": { "line": 11, "column": 12 } - } - }, - { - "type": "Identifier", - "value": "foo", + }, "range": [ 190, 193 ], + "value": "foo" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 11, - "column": 12 + "column": 16 }, - "end": { + "start": { "line": 11, "column": 15 } - } - }, - { - "type": "Punctuator", - "value": ")", + }, "range": [ 193, 194 ], - "loc": { - "start": { - "line": 11, - "column": 15 - }, - "end": { - "line": 11, - "column": 16 - } - } + "value": ")" }, { "type": "Punctuator", @@ -1299,7 +1327,16 @@ "value": "</script>" } ], - "comments": [], + "loc": { + "end": { + "line": 12, + "column": 0 + }, + "start": { + "line": 8, + "column": 0 + } + }, "templateBody": { "type": "VElement", "range": [ @@ -1375,19 +1412,21 @@ }, "expression": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 218, 221 ], "loc": { - "start": { - "line": 14, - "column": 2 - }, "end": { "line": 14, "column": 5 + }, + "start": { + "line": 14, + "column": 2 } } }, @@ -1395,19 +1434,21 @@ { "id": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 218, 221 ], "loc": { - "start": { - "line": 14, - "column": 2 - }, "end": { "line": 14, "column": 5 + }, + "start": { + "line": 14, + "column": 2 } } }, @@ -1601,129 +1642,129 @@ }, { "type": "Identifier", - "value": "T", - "range": [ - 36, - 37 - ], "loc": { - "start": { - "line": 2, - "column": 2 - }, "end": { "line": 2, "column": 3 + }, + "start": { + "line": 2, + "column": 2 } - } + }, + "range": [ + 36, + 37 + ], + "value": "T" }, { "type": "Keyword", - "value": "extends", + "loc": { + "end": { + "line": 3, + "column": 11 + }, + "start": { + "line": 3, + "column": 4 + } + }, "range": [ 42, 49 ], + "value": "extends" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 3, - "column": 4 + "column": 15 }, - "end": { + "start": { "line": 3, - "column": 11 + "column": 12 } - } - }, - { - "type": "Identifier", - "value": "Foo", + }, "range": [ 50, 53 ], + "value": "Foo" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 3, - "column": 12 + "column": 16 }, - "end": { + "start": { "line": 3, "column": 15 } - } - }, - { - "type": "Punctuator", - "value": ",", + }, "range": [ 53, 54 ], - "loc": { - "start": { - "line": 3, - "column": 15 - }, - "end": { - "line": 3, - "column": 16 - } - } + "value": "," }, { "type": "Identifier", - "value": "U", - "range": [ - 73, - 74 - ], "loc": { - "start": { - "line": 5, - "column": 2 - }, "end": { "line": 5, "column": 3 + }, + "start": { + "line": 5, + "column": 2 } - } + }, + "range": [ + 73, + 74 + ], + "value": "U" }, { "type": "Keyword", - "value": "extends", - "range": [ - 75, - 82 - ], "loc": { - "start": { - "line": 5, - "column": 4 - }, "end": { "line": 5, "column": 11 + }, + "start": { + "line": 5, + "column": 4 } - } + }, + "range": [ + 75, + 82 + ], + "value": "extends" }, { "type": "Identifier", - "value": "T", - "range": [ - 87, - 88 - ], "loc": { - "start": { - "line": 6, - "column": 4 - }, "end": { "line": 6, "column": 5 + }, + "start": { + "line": 6, + "column": 4 } - } + }, + "range": [ + 87, + 88 + ], + "value": "T" }, { "type": "Punctuator", @@ -2519,21 +2560,21 @@ }, { "type": "Identifier", - "value": "foo", - "range": [ - 218, - 221 - ], "loc": { - "start": { - "line": 14, - "column": 2 - }, "end": { "line": 14, "column": 5 + }, + "start": { + "line": 14, + "column": 2 } - } + }, + "range": [ + 218, + 221 + ], + "value": "foo" }, { "type": "VExpressionEnd", @@ -2611,21 +2652,21 @@ "comments": [ { "type": "Line", - "value": " Comments", - "range": [ - 59, - 70 - ], "loc": { - "start": { - "line": 4, - "column": 4 - }, "end": { "line": 4, "column": 15 + }, + "start": { + "line": 4, + "column": 4 } - } + }, + "range": [ + 59, + 70 + ], + "value": " Comments" } ], "errors": [] 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 index 86d3fb49..b2319f0c 100644 --- a/test/fixtures/ast/vue3.3-generic-5-with-spaces/ast.json +++ b/test/fixtures/ast/vue3.3-generic-5-with-spaces/ast.json @@ -1,23 +1,30 @@ { "type": "Program", + "range": [ + 142, + 245 + ], "body": [ { "type": "TSTypeAliasDeclaration", + "declare": false, "id": { "type": "Identifier", + "decorators": [], "name": "Foo", + "optional": false, "range": [ 147, 150 ], "loc": { - "start": { - "line": 9, - "column": 5 - }, "end": { "line": 9, "column": 8 + }, + "start": { + "line": 9, + "column": 5 } } }, @@ -31,13 +38,13 @@ 159 ], "loc": { - "start": { - "line": 9, - "column": 11 - }, "end": { "line": 9, "column": 17 + }, + "start": { + "line": 9, + "column": 11 } } }, @@ -48,13 +55,13 @@ 168 ], "loc": { - "start": { - "line": 9, - "column": 20 - }, "end": { "line": 9, "column": 26 + }, + "start": { + "line": 9, + "column": 20 } } } @@ -64,13 +71,13 @@ 168 ], "loc": { - "start": { - "line": 9, - "column": 11 - }, "end": { "line": 9, "column": 26 + }, + "start": { + "line": 9, + "column": 11 } } }, @@ -79,13 +86,13 @@ 168 ], "loc": { - "start": { - "line": 9, - "column": 0 - }, "end": { "line": 9, "column": 26 + }, + "start": { + "line": 9, + "column": 0 } } }, @@ -94,61 +101,52 @@ "declarations": [ { "type": "VariableDeclarator", + "definite": false, "id": { "type": "Identifier", + "decorators": [], "name": "p", + "optional": false, "range": [ 175, 176 ], "loc": { - "start": { - "line": 10, - "column": 6 - }, "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": { - "start": { - "line": 10, - "column": 10 - }, "end": { "line": 10, "column": 21 + }, + "start": { + "line": 10, + "column": 10 } } }, - "arguments": [], "optional": false, - "range": [ - 179, - 209 - ], - "loc": { - "start": { - "line": 10, - "column": 10 - }, - "end": { - "line": 10, - "column": 40 - } - }, - "typeParameters": { + "typeArguments": { "type": "TSTypeParameterInstantiation", "range": [ 190, @@ -163,32 +161,37 @@ "computed": false, "key": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 192, 195 ], "loc": { - "start": { - "line": 10, - "column": 23 - }, "end": { "line": 10, "column": 26 + }, + "start": { + "line": 10, + "column": 23 } } }, + "optional": false, + "readonly": false, + "static": false, "typeAnnotation": { "type": "TSTypeAnnotation", "loc": { - "start": { - "line": 10, - "column": 26 - }, "end": { "line": 10, "column": 28 + }, + "start": { + "line": 10, + "column": 26 } }, "range": [ @@ -199,19 +202,21 @@ "type": "TSTypeReference", "typeName": { "type": "Identifier", + "decorators": [], "name": "T", + "optional": false, "range": [ 196, 197 ], "loc": { - "start": { - "line": 10, - "column": 27 - }, "end": { "line": 10, "column": 28 + }, + "start": { + "line": 10, + "column": 27 } } }, @@ -220,13 +225,13 @@ 197 ], "loc": { - "start": { - "line": 10, - "column": 27 - }, "end": { "line": 10, "column": 28 + }, + "start": { + "line": 10, + "column": 27 } } } @@ -236,13 +241,13 @@ 198 ], "loc": { - "start": { - "line": 10, - "column": 23 - }, "end": { "line": 10, "column": 29 + }, + "start": { + "line": 10, + "column": 23 } } }, @@ -251,32 +256,37 @@ "computed": false, "key": { "type": "Identifier", + "decorators": [], "name": "bar", + "optional": false, "range": [ 199, 202 ], "loc": { - "start": { - "line": 10, - "column": 30 - }, "end": { "line": 10, "column": 33 + }, + "start": { + "line": 10, + "column": 30 } } }, + "optional": false, + "readonly": false, + "static": false, "typeAnnotation": { "type": "TSTypeAnnotation", "loc": { - "start": { - "line": 10, - "column": 33 - }, "end": { "line": 10, "column": 36 + }, + "start": { + "line": 10, + "column": 33 } }, "range": [ @@ -287,19 +297,21 @@ "type": "TSTypeReference", "typeName": { "type": "Identifier", + "decorators": [], "name": "U", + "optional": false, "range": [ 204, 205 ], "loc": { - "start": { - "line": 10, - "column": 35 - }, "end": { "line": 10, "column": 36 + }, + "start": { + "line": 10, + "column": 35 } } }, @@ -308,13 +320,13 @@ 205 ], "loc": { - "start": { - "line": 10, - "column": 35 - }, "end": { "line": 10, "column": 36 + }, + "start": { + "line": 10, + "column": 35 } } } @@ -324,13 +336,13 @@ 205 ], "loc": { - "start": { - "line": 10, - "column": 30 - }, "end": { "line": 10, "column": 36 + }, + "start": { + "line": 10, + "column": 30 } } } @@ -340,27 +352,41 @@ 206 ], "loc": { - "start": { - "line": 10, - "column": 22 - }, "end": { "line": 10, "column": 37 + }, + "start": { + "line": 10, + "column": 22 } } } ], "loc": { - "start": { - "line": 10, - "column": 21 - }, "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": [ @@ -368,30 +394,31 @@ 209 ], "loc": { - "start": { - "line": 10, - "column": 6 - }, "end": { "line": 10, "column": 40 + }, + "start": { + "line": 10, + "column": 6 } } } ], + "declare": false, "kind": "const", "range": [ 169, 209 ], "loc": { - "start": { - "line": 10, - "column": 0 - }, "end": { "line": 10, "column": 40 + }, + "start": { + "line": 10, + "column": 0 } } }, @@ -400,76 +427,83 @@ "declarations": [ { "type": "VariableDeclarator", + "definite": false, "id": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 216, 219 ], "loc": { - "start": { - "line": 11, - "column": 6 - }, "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": { - "start": { - "line": 11, - "column": 12 - }, "end": { "line": 11, "column": 13 + }, + "start": { + "line": 11, + "column": 12 } } }, + "optional": false, "property": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 224, 227 ], "loc": { - "start": { - "line": 11, - "column": 14 - }, "end": { "line": 11, "column": 17 + }, + "start": { + "line": 11, + "column": 14 } } }, - "computed": false, - "optional": false, "range": [ 222, 227 ], "loc": { - "start": { - "line": 11, - "column": 12 - }, "end": { "line": 11, "column": 17 + }, + "start": { + "line": 11, + "column": 12 } } }, @@ -478,125 +512,132 @@ 227 ], "loc": { - "start": { - "line": 11, - "column": 6 - }, "end": { "line": 11, "column": 17 + }, + "start": { + "line": 11, + "column": 6 } } } ], + "declare": false, "kind": "const", "range": [ 210, 227 ], "loc": { - "start": { - "line": 11, - "column": 0 - }, "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": { - "start": { - "line": 12, - "column": 0 - }, "end": { "line": 12, "column": 7 + }, + "start": { + "line": 12, + "column": 0 } } }, + "optional": false, "property": { "type": "Identifier", + "decorators": [], "name": "log", + "optional": false, "range": [ 236, 239 ], "loc": { - "start": { - "line": 12, - "column": 8 - }, "end": { "line": 12, "column": 11 + }, + "start": { + "line": 12, + "column": 8 } } }, - "computed": false, - "optional": false, "range": [ 228, 239 ], "loc": { - "start": { - "line": 12, - "column": 0 - }, "end": { "line": 12, "column": 11 + }, + "start": { + "line": 12, + "column": 0 } } }, - "arguments": [ - { - "type": "Identifier", - "name": "foo", - "range": [ - 240, - 243 - ], - "loc": { - "start": { - "line": 12, - "column": 12 - }, - "end": { - "line": 12, - "column": 15 - } - } - } - ], "optional": false, "range": [ 228, 244 ], "loc": { - "start": { - "line": 12, - "column": 0 - }, "end": { "line": 12, "column": 16 + }, + "start": { + "line": 12, + "column": 0 } } }, @@ -605,32 +646,19 @@ 244 ], "loc": { - "start": { - "line": 12, - "column": 0 - }, "end": { "line": 12, "column": 16 + }, + "start": { + "line": 12, + "column": 0 } } } ], + "comments": [], "sourceType": "module", - "range": [ - 142, - 245 - ], - "loc": { - "start": { - "line": 9, - "column": 0 - }, - "end": { - "line": 13, - "column": 0 - } - }, "tokens": [ { "type": "Punctuator", @@ -652,633 +680,633 @@ }, { "type": "Identifier", - "value": "type", + "loc": { + "end": { + "line": 9, + "column": 4 + }, + "start": { + "line": 9, + "column": 0 + } + }, "range": [ 142, 146 ], + "value": "type" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 9, - "column": 0 + "column": 8 }, - "end": { + "start": { "line": 9, - "column": 4 + "column": 5 } - } - }, - { - "type": "Identifier", - "value": "Foo", + }, "range": [ 147, 150 ], + "value": "Foo" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 9, - "column": 5 + "column": 10 }, - "end": { + "start": { "line": 9, - "column": 8 + "column": 9 } - } - }, - { - "type": "Punctuator", - "value": "=", + }, "range": [ 151, 152 ], + "value": "=" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 9, - "column": 9 + "column": 17 }, - "end": { + "start": { "line": 9, - "column": 10 + "column": 11 } - } - }, - { - "type": "Identifier", - "value": "number", + }, "range": [ 153, 159 ], + "value": "number" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 9, - "column": 11 + "column": 19 }, - "end": { + "start": { "line": 9, - "column": 17 + "column": 18 } - } - }, - { - "type": "Punctuator", - "value": "|", + }, "range": [ 160, 161 ], + "value": "|" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 9, - "column": 18 + "column": 26 }, - "end": { + "start": { "line": 9, - "column": 19 + "column": 20 } - } - }, - { - "type": "Identifier", - "value": "string", + }, "range": [ 162, 168 ], - "loc": { - "start": { - "line": 9, - "column": 20 - }, - "end": { - "line": 9, - "column": 26 - } - } + "value": "string" }, { "type": "Keyword", - "value": "const", + "loc": { + "end": { + "line": 10, + "column": 5 + }, + "start": { + "line": 10, + "column": 0 + } + }, "range": [ 169, 174 ], + "value": "const" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 10, - "column": 0 + "column": 7 }, - "end": { + "start": { "line": 10, - "column": 5 + "column": 6 } - } - }, - { - "type": "Identifier", - "value": "p", + }, "range": [ 175, 176 ], + "value": "p" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 10, - "column": 6 + "column": 9 }, - "end": { + "start": { "line": 10, - "column": 7 + "column": 8 } - } - }, - { - "type": "Punctuator", - "value": "=", + }, "range": [ 177, 178 ], + "value": "=" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 10, - "column": 8 + "column": 21 }, - "end": { + "start": { "line": 10, - "column": 9 + "column": 10 } - } - }, - { - "type": "Identifier", - "value": "defineProps", + }, "range": [ 179, 190 ], + "value": "defineProps" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 10, - "column": 10 + "column": 22 }, - "end": { + "start": { "line": 10, "column": 21 } - } - }, - { - "type": "Punctuator", - "value": "<", + }, "range": [ 190, 191 ], + "value": "<" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 10, - "column": 21 + "column": 23 }, - "end": { + "start": { "line": 10, "column": 22 } - } - }, - { - "type": "Punctuator", - "value": "{", + }, "range": [ 191, 192 ], + "value": "{" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 10, - "column": 22 + "column": 26 }, - "end": { + "start": { "line": 10, "column": 23 } - } - }, - { - "type": "Identifier", - "value": "foo", + }, "range": [ 192, 195 ], + "value": "foo" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 10, - "column": 23 + "column": 27 }, - "end": { + "start": { "line": 10, "column": 26 } - } - }, - { - "type": "Punctuator", - "value": ":", + }, "range": [ 195, 196 ], + "value": ":" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 10, - "column": 26 + "column": 28 }, - "end": { + "start": { "line": 10, "column": 27 } - } - }, - { - "type": "Identifier", - "value": "T", + }, "range": [ 196, 197 ], + "value": "T" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 10, - "column": 27 + "column": 29 }, - "end": { + "start": { "line": 10, "column": 28 } - } - }, - { - "type": "Punctuator", - "value": ",", + }, "range": [ 197, 198 ], + "value": "," + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 10, - "column": 28 + "column": 33 }, - "end": { + "start": { "line": 10, - "column": 29 + "column": 30 } - } - }, - { - "type": "Identifier", - "value": "bar", + }, "range": [ 199, 202 ], + "value": "bar" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 10, - "column": 30 + "column": 34 }, - "end": { + "start": { "line": 10, "column": 33 } - } - }, - { - "type": "Punctuator", - "value": ":", + }, "range": [ 202, 203 ], + "value": ":" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 10, - "column": 33 + "column": 36 }, - "end": { + "start": { "line": 10, - "column": 34 + "column": 35 } - } - }, - { - "type": "Identifier", - "value": "U", + }, "range": [ 204, 205 ], + "value": "U" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 10, - "column": 35 + "column": 37 }, - "end": { + "start": { "line": 10, "column": 36 } - } - }, - { - "type": "Punctuator", - "value": "}", + }, "range": [ 205, 206 ], + "value": "}" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 10, - "column": 36 + "column": 38 }, - "end": { + "start": { "line": 10, "column": 37 } - } - }, - { - "type": "Punctuator", - "value": ">", + }, "range": [ 206, 207 ], + "value": ">" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 10, - "column": 37 + "column": 39 }, - "end": { + "start": { "line": 10, - "column": 38 - } - } - }, - { - "type": "Punctuator", - "value": "(", + "column": 38 + } + }, "range": [ 207, 208 ], + "value": "(" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 10, - "column": 38 + "column": 40 }, - "end": { + "start": { "line": 10, "column": 39 } - } - }, - { - "type": "Punctuator", - "value": ")", + }, "range": [ 208, 209 ], - "loc": { - "start": { - "line": 10, - "column": 39 - }, - "end": { - "line": 10, - "column": 40 - } - } + "value": ")" }, { "type": "Keyword", - "value": "const", + "loc": { + "end": { + "line": 11, + "column": 5 + }, + "start": { + "line": 11, + "column": 0 + } + }, "range": [ 210, 215 ], + "value": "const" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 11, - "column": 0 + "column": 9 }, - "end": { + "start": { "line": 11, - "column": 5 + "column": 6 } - } - }, - { - "type": "Identifier", - "value": "foo", + }, "range": [ 216, 219 ], + "value": "foo" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 11, - "column": 6 + "column": 11 }, - "end": { + "start": { "line": 11, - "column": 9 + "column": 10 } - } - }, - { - "type": "Punctuator", - "value": "=", + }, "range": [ 220, 221 ], + "value": "=" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 11, - "column": 10 + "column": 13 }, - "end": { + "start": { "line": 11, - "column": 11 + "column": 12 } - } - }, - { - "type": "Identifier", - "value": "p", + }, "range": [ 222, 223 ], + "value": "p" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 11, - "column": 12 + "column": 14 }, - "end": { + "start": { "line": 11, "column": 13 } - } - }, - { - "type": "Punctuator", - "value": ".", + }, "range": [ 223, 224 ], + "value": "." + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 11, - "column": 13 + "column": 17 }, - "end": { + "start": { "line": 11, "column": 14 } - } - }, - { - "type": "Identifier", - "value": "foo", + }, "range": [ 224, 227 ], - "loc": { - "start": { - "line": 11, - "column": 14 - }, - "end": { - "line": 11, - "column": 17 - } - } + "value": "foo" }, { "type": "Identifier", - "value": "console", + "loc": { + "end": { + "line": 12, + "column": 7 + }, + "start": { + "line": 12, + "column": 0 + } + }, "range": [ 228, 235 ], + "value": "console" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 12, - "column": 0 + "column": 8 }, - "end": { + "start": { "line": 12, "column": 7 } - } - }, - { - "type": "Punctuator", - "value": ".", + }, "range": [ 235, 236 ], + "value": "." + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 12, - "column": 7 + "column": 11 }, - "end": { + "start": { "line": 12, "column": 8 } - } - }, - { - "type": "Identifier", - "value": "log", + }, "range": [ 236, 239 ], + "value": "log" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 12, - "column": 8 + "column": 12 }, - "end": { + "start": { "line": 12, "column": 11 } - } - }, - { - "type": "Punctuator", - "value": "(", + }, "range": [ 239, 240 ], + "value": "(" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 12, - "column": 11 + "column": 15 }, - "end": { + "start": { "line": 12, "column": 12 } - } - }, - { - "type": "Identifier", - "value": "foo", + }, "range": [ 240, 243 ], + "value": "foo" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 12, - "column": 12 + "column": 16 }, - "end": { + "start": { "line": 12, "column": 15 } - } - }, - { - "type": "Punctuator", - "value": ")", + }, "range": [ 243, 244 ], - "loc": { - "start": { - "line": 12, - "column": 15 - }, - "end": { - "line": 12, - "column": 16 - } - } + "value": ")" }, { "type": "Punctuator", @@ -1299,7 +1327,16 @@ "value": "</script>" } ], - "comments": [], + "loc": { + "end": { + "line": 13, + "column": 0 + }, + "start": { + "line": 9, + "column": 0 + } + }, "templateBody": { "type": "VElement", "range": [ @@ -1375,19 +1412,21 @@ }, "expression": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 268, 271 ], "loc": { - "start": { - "line": 15, - "column": 2 - }, "end": { "line": 15, "column": 5 + }, + "start": { + "line": 15, + "column": 2 } } }, @@ -1395,19 +1434,21 @@ { "id": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 268, 271 ], "loc": { - "start": { - "line": 15, - "column": 2 - }, "end": { "line": 15, "column": 5 + }, + "start": { + "line": 15, + "column": 2 } } }, @@ -1601,219 +1642,219 @@ }, { "type": "Identifier", - "value": "T", - "range": [ - 36, - 37 - ], "loc": { - "start": { - "line": 2, - "column": 2 - }, "end": { "line": 2, "column": 3 + }, + "start": { + "line": 2, + "column": 2 } - } + }, + "range": [ + 36, + 37 + ], + "value": "T" }, { "type": "Keyword", - "value": "extends", + "loc": { + "end": { + "line": 3, + "column": 11 + }, + "start": { + "line": 3, + "column": 4 + } + }, "range": [ 54, 61 ], + "value": "extends" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 3, - "column": 4 + "column": 15 }, - "end": { + "start": { "line": 3, - "column": 11 + "column": 12 } - } - }, - { - "type": "Identifier", - "value": "Foo", + }, "range": [ 62, 65 ], + "value": "Foo" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 3, - "column": 12 + "column": 16 }, - "end": { + "start": { "line": 3, "column": 15 } - } - }, - { - "type": "Punctuator", - "value": ",", + }, "range": [ 65, 66 ], - "loc": { - "start": { - "line": 3, - "column": 15 - }, - "end": { - "line": 3, - "column": 16 - } - } + "value": "," }, { "type": "Identifier", - "value": "U", - "range": [ - 85, - 86 - ], "loc": { - "start": { - "line": 5, - "column": 2 - }, "end": { "line": 5, "column": 3 + }, + "start": { + "line": 5, + "column": 2 } - } + }, + "range": [ + 85, + 86 + ], + "value": "U" }, { "type": "Keyword", - "value": "extends", - "range": [ - 106, - 113 - ], "loc": { - "start": { - "line": 6, - "column": 4 - }, "end": { "line": 6, "column": 11 + }, + "start": { + "line": 6, + "column": 4 } - } + }, + "range": [ + 106, + 113 + ], + "value": "extends" }, { "type": "Identifier", - "value": "Record", + "loc": { + "end": { + "line": 7, + "column": 10 + }, + "start": { + "line": 7, + "column": 4 + } + }, "range": [ 118, 124 ], + "value": "Record" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 7, - "column": 4 + "column": 14 }, - "end": { + "start": { "line": 7, "column": 10 } - } - }, - { - "type": "Punctuator", - "value": "<", + }, "range": [ 124, 128 ], + "value": "<" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 7, - "column": 10 + "column": 20 }, - "end": { + "start": { "line": 7, "column": 14 } - } - }, - { - "type": "Identifier", - "value": "string", + }, "range": [ 128, 134 ], + "value": "string" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 7, - "column": 14 + "column": 21 }, - "end": { + "start": { "line": 7, "column": 20 } - } - }, - { - "type": "Punctuator", - "value": ",", + }, "range": [ 134, 135 ], + "value": "," + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 7, - "column": 20 + "column": 23 }, - "end": { + "start": { "line": 7, - "column": 21 + "column": 22 } - } - }, - { - "type": "Identifier", - "value": "T", + }, "range": [ 136, 137 ], + "value": "T" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 7, - "column": 22 + "column": 24 }, - "end": { + "start": { "line": 7, "column": 23 } - } - }, - { - "type": "Punctuator", - "value": ">", + }, "range": [ 137, 138 ], - "loc": { - "start": { - "line": 7, - "column": 23 - }, - "end": { - "line": 7, - "column": 24 - } - } + "value": ">" }, { "type": "Punctuator", @@ -2609,21 +2650,21 @@ }, { "type": "Identifier", - "value": "foo", - "range": [ - 268, - 271 - ], "loc": { - "start": { - "line": 15, - "column": 2 - }, "end": { "line": 15, "column": 5 + }, + "start": { + "line": 15, + "column": 2 } - } + }, + "range": [ + 268, + 271 + ], + "value": "foo" }, { "type": "VExpressionEnd", @@ -2701,57 +2742,57 @@ "comments": [ { "type": "Line", - "value": " Comments", - "range": [ - 38, - 49 - ], "loc": { - "start": { - "line": 2, - "column": 4 - }, "end": { "line": 2, "column": 15 + }, + "start": { + "line": 2, + "column": 4 } - } + }, + "range": [ + 38, + 49 + ], + "value": " Comments" }, { "type": "Line", - "value": " Comments", - "range": [ - 71, - 82 - ], "loc": { - "start": { - "line": 4, - "column": 4 - }, "end": { "line": 4, "column": 15 + }, + "start": { + "line": 4, + "column": 4 } - } + }, + "range": [ + 71, + 82 + ], + "value": " Comments" }, { "type": "Block", - "value": " Comments ", - "range": [ - 87, - 101 - ], "loc": { - "start": { - "line": 5, - "column": 4 - }, "end": { "line": 5, "column": 18 + }, + "start": { + "line": 5, + "column": 4 } - } + }, + "range": [ + 87, + 101 + ], + "value": " Comments " } ], "errors": [] 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 index 0c366303..df9f6fee 100644 --- a/test/fixtures/ast/vue3.3-generic-6-with-default/ast.json +++ b/test/fixtures/ast/vue3.3-generic-6-with-default/ast.json @@ -1,23 +1,30 @@ { "type": "Program", + "range": [ + 228, + 331 + ], "body": [ { "type": "TSTypeAliasDeclaration", + "declare": false, "id": { "type": "Identifier", + "decorators": [], "name": "Foo", + "optional": false, "range": [ 233, 236 ], "loc": { - "start": { - "line": 14, - "column": 5 - }, "end": { "line": 14, "column": 8 + }, + "start": { + "line": 14, + "column": 5 } } }, @@ -31,13 +38,13 @@ 245 ], "loc": { - "start": { - "line": 14, - "column": 11 - }, "end": { "line": 14, "column": 17 + }, + "start": { + "line": 14, + "column": 11 } } }, @@ -48,13 +55,13 @@ 254 ], "loc": { - "start": { - "line": 14, - "column": 20 - }, "end": { "line": 14, "column": 26 + }, + "start": { + "line": 14, + "column": 20 } } } @@ -64,13 +71,13 @@ 254 ], "loc": { - "start": { - "line": 14, - "column": 11 - }, "end": { "line": 14, "column": 26 + }, + "start": { + "line": 14, + "column": 11 } } }, @@ -79,13 +86,13 @@ 254 ], "loc": { - "start": { - "line": 14, - "column": 0 - }, "end": { "line": 14, "column": 26 + }, + "start": { + "line": 14, + "column": 0 } } }, @@ -94,61 +101,52 @@ "declarations": [ { "type": "VariableDeclarator", + "definite": false, "id": { "type": "Identifier", + "decorators": [], "name": "p", + "optional": false, "range": [ 261, 262 ], "loc": { - "start": { - "line": 15, - "column": 6 - }, "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": { - "start": { - "line": 15, - "column": 10 - }, "end": { "line": 15, "column": 21 + }, + "start": { + "line": 15, + "column": 10 } } }, - "arguments": [], "optional": false, - "range": [ - 265, - 295 - ], - "loc": { - "start": { - "line": 15, - "column": 10 - }, - "end": { - "line": 15, - "column": 40 - } - }, - "typeParameters": { + "typeArguments": { "type": "TSTypeParameterInstantiation", "range": [ 276, @@ -163,32 +161,37 @@ "computed": false, "key": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 278, 281 ], "loc": { - "start": { - "line": 15, - "column": 23 - }, "end": { "line": 15, "column": 26 + }, + "start": { + "line": 15, + "column": 23 } } }, + "optional": false, + "readonly": false, + "static": false, "typeAnnotation": { "type": "TSTypeAnnotation", "loc": { - "start": { - "line": 15, - "column": 26 - }, "end": { "line": 15, "column": 28 + }, + "start": { + "line": 15, + "column": 26 } }, "range": [ @@ -199,19 +202,21 @@ "type": "TSTypeReference", "typeName": { "type": "Identifier", + "decorators": [], "name": "T", + "optional": false, "range": [ 282, 283 ], "loc": { - "start": { - "line": 15, - "column": 27 - }, "end": { "line": 15, "column": 28 + }, + "start": { + "line": 15, + "column": 27 } } }, @@ -220,13 +225,13 @@ 283 ], "loc": { - "start": { - "line": 15, - "column": 27 - }, "end": { "line": 15, "column": 28 + }, + "start": { + "line": 15, + "column": 27 } } } @@ -236,13 +241,13 @@ 284 ], "loc": { - "start": { - "line": 15, - "column": 23 - }, "end": { "line": 15, "column": 29 + }, + "start": { + "line": 15, + "column": 23 } } }, @@ -251,32 +256,37 @@ "computed": false, "key": { "type": "Identifier", + "decorators": [], "name": "bar", + "optional": false, "range": [ 285, 288 ], "loc": { - "start": { - "line": 15, - "column": 30 - }, "end": { "line": 15, "column": 33 + }, + "start": { + "line": 15, + "column": 30 } } }, + "optional": false, + "readonly": false, + "static": false, "typeAnnotation": { "type": "TSTypeAnnotation", "loc": { - "start": { - "line": 15, - "column": 33 - }, "end": { "line": 15, "column": 36 + }, + "start": { + "line": 15, + "column": 33 } }, "range": [ @@ -287,19 +297,21 @@ "type": "TSTypeReference", "typeName": { "type": "Identifier", + "decorators": [], "name": "U", + "optional": false, "range": [ 290, 291 ], "loc": { - "start": { - "line": 15, - "column": 35 - }, "end": { "line": 15, "column": 36 + }, + "start": { + "line": 15, + "column": 35 } } }, @@ -308,13 +320,13 @@ 291 ], "loc": { - "start": { - "line": 15, - "column": 35 - }, "end": { "line": 15, "column": 36 + }, + "start": { + "line": 15, + "column": 35 } } } @@ -324,13 +336,13 @@ 291 ], "loc": { - "start": { - "line": 15, - "column": 30 - }, "end": { "line": 15, "column": 36 + }, + "start": { + "line": 15, + "column": 30 } } } @@ -340,27 +352,41 @@ 292 ], "loc": { - "start": { - "line": 15, - "column": 22 - }, "end": { "line": 15, "column": 37 + }, + "start": { + "line": 15, + "column": 22 } } } ], "loc": { - "start": { - "line": 15, - "column": 21 - }, "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": [ @@ -368,30 +394,31 @@ 295 ], "loc": { - "start": { - "line": 15, - "column": 6 - }, "end": { "line": 15, "column": 40 + }, + "start": { + "line": 15, + "column": 6 } } } ], + "declare": false, "kind": "const", "range": [ 255, 295 ], "loc": { - "start": { - "line": 15, - "column": 0 - }, "end": { "line": 15, "column": 40 + }, + "start": { + "line": 15, + "column": 0 } } }, @@ -400,76 +427,83 @@ "declarations": [ { "type": "VariableDeclarator", + "definite": false, "id": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 302, 305 ], "loc": { - "start": { - "line": 16, - "column": 6 - }, "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": { - "start": { - "line": 16, - "column": 12 - }, "end": { "line": 16, "column": 13 + }, + "start": { + "line": 16, + "column": 12 } } }, + "optional": false, "property": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 310, 313 ], "loc": { - "start": { - "line": 16, - "column": 14 - }, "end": { "line": 16, "column": 17 + }, + "start": { + "line": 16, + "column": 14 } } }, - "computed": false, - "optional": false, "range": [ 308, 313 ], "loc": { - "start": { - "line": 16, - "column": 12 - }, "end": { "line": 16, "column": 17 + }, + "start": { + "line": 16, + "column": 12 } } }, @@ -478,125 +512,132 @@ 313 ], "loc": { - "start": { - "line": 16, - "column": 6 - }, "end": { "line": 16, "column": 17 + }, + "start": { + "line": 16, + "column": 6 } } } ], + "declare": false, "kind": "const", "range": [ 296, 313 ], "loc": { - "start": { - "line": 16, - "column": 0 - }, "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": { - "start": { - "line": 17, - "column": 0 - }, "end": { "line": 17, "column": 7 + }, + "start": { + "line": 17, + "column": 0 } } }, + "optional": false, "property": { "type": "Identifier", + "decorators": [], "name": "log", + "optional": false, "range": [ 322, 325 ], "loc": { - "start": { - "line": 17, - "column": 8 - }, "end": { "line": 17, "column": 11 + }, + "start": { + "line": 17, + "column": 8 } } }, - "computed": false, - "optional": false, "range": [ 314, 325 ], "loc": { - "start": { - "line": 17, - "column": 0 - }, "end": { "line": 17, "column": 11 + }, + "start": { + "line": 17, + "column": 0 } } }, - "arguments": [ - { - "type": "Identifier", - "name": "foo", - "range": [ - 326, - 329 - ], - "loc": { - "start": { - "line": 17, - "column": 12 - }, - "end": { - "line": 17, - "column": 15 - } - } - } - ], "optional": false, "range": [ 314, 330 ], "loc": { - "start": { - "line": 17, - "column": 0 - }, "end": { "line": 17, "column": 16 + }, + "start": { + "line": 17, + "column": 0 } } }, @@ -605,32 +646,19 @@ 330 ], "loc": { - "start": { - "line": 17, - "column": 0 - }, "end": { "line": 17, "column": 16 + }, + "start": { + "line": 17, + "column": 0 } } } ], + "comments": [], "sourceType": "module", - "range": [ - 228, - 331 - ], - "loc": { - "start": { - "line": 14, - "column": 0 - }, - "end": { - "line": 18, - "column": 0 - } - }, "tokens": [ { "type": "Punctuator", @@ -652,633 +680,633 @@ }, { "type": "Identifier", - "value": "type", + "loc": { + "end": { + "line": 14, + "column": 4 + }, + "start": { + "line": 14, + "column": 0 + } + }, "range": [ 228, 232 ], + "value": "type" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 14, - "column": 0 + "column": 8 }, - "end": { + "start": { "line": 14, - "column": 4 + "column": 5 } - } - }, - { - "type": "Identifier", - "value": "Foo", + }, "range": [ 233, 236 ], + "value": "Foo" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 14, - "column": 5 + "column": 10 }, - "end": { + "start": { "line": 14, - "column": 8 + "column": 9 } - } - }, - { - "type": "Punctuator", - "value": "=", + }, "range": [ 237, 238 ], + "value": "=" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 14, - "column": 9 + "column": 17 }, - "end": { + "start": { "line": 14, - "column": 10 + "column": 11 } - } - }, - { - "type": "Identifier", - "value": "number", + }, "range": [ 239, 245 ], + "value": "number" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 14, - "column": 11 + "column": 19 }, - "end": { + "start": { "line": 14, - "column": 17 + "column": 18 } - } - }, - { - "type": "Punctuator", - "value": "|", + }, "range": [ 246, 247 ], + "value": "|" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 14, - "column": 18 + "column": 26 }, - "end": { + "start": { "line": 14, - "column": 19 + "column": 20 } - } - }, - { - "type": "Identifier", - "value": "string", + }, "range": [ 248, 254 ], - "loc": { - "start": { - "line": 14, - "column": 20 - }, - "end": { - "line": 14, - "column": 26 - } - } + "value": "string" }, { "type": "Keyword", - "value": "const", + "loc": { + "end": { + "line": 15, + "column": 5 + }, + "start": { + "line": 15, + "column": 0 + } + }, "range": [ 255, 260 ], + "value": "const" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 15, - "column": 0 + "column": 7 }, - "end": { + "start": { "line": 15, - "column": 5 + "column": 6 } - } - }, - { - "type": "Identifier", - "value": "p", + }, "range": [ 261, 262 ], + "value": "p" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 15, - "column": 6 + "column": 9 }, - "end": { + "start": { "line": 15, - "column": 7 + "column": 8 } - } - }, - { - "type": "Punctuator", - "value": "=", + }, "range": [ 263, 264 ], + "value": "=" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 15, - "column": 8 + "column": 21 }, - "end": { + "start": { "line": 15, - "column": 9 + "column": 10 } - } - }, - { - "type": "Identifier", - "value": "defineProps", + }, "range": [ 265, 276 ], + "value": "defineProps" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 15, - "column": 10 + "column": 22 }, - "end": { + "start": { "line": 15, "column": 21 } - } - }, - { - "type": "Punctuator", - "value": "<", + }, "range": [ 276, 277 ], + "value": "<" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 15, - "column": 21 + "column": 23 }, - "end": { + "start": { "line": 15, "column": 22 } - } - }, - { - "type": "Punctuator", - "value": "{", + }, "range": [ 277, 278 ], + "value": "{" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 15, - "column": 22 + "column": 26 }, - "end": { + "start": { "line": 15, "column": 23 } - } - }, - { - "type": "Identifier", - "value": "foo", + }, "range": [ 278, 281 ], + "value": "foo" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 15, - "column": 23 + "column": 27 }, - "end": { + "start": { "line": 15, "column": 26 } - } - }, - { - "type": "Punctuator", - "value": ":", + }, "range": [ 281, 282 ], + "value": ":" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 15, - "column": 26 + "column": 28 }, - "end": { + "start": { "line": 15, "column": 27 } - } - }, - { - "type": "Identifier", - "value": "T", + }, "range": [ 282, 283 ], + "value": "T" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 15, - "column": 27 + "column": 29 }, - "end": { + "start": { "line": 15, "column": 28 } - } - }, - { - "type": "Punctuator", - "value": ",", + }, "range": [ 283, 284 ], + "value": "," + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 15, - "column": 28 + "column": 33 }, - "end": { + "start": { "line": 15, - "column": 29 + "column": 30 } - } - }, - { - "type": "Identifier", - "value": "bar", + }, "range": [ 285, 288 ], + "value": "bar" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 15, - "column": 30 + "column": 34 }, - "end": { + "start": { "line": 15, "column": 33 } - } - }, - { - "type": "Punctuator", - "value": ":", + }, "range": [ 288, 289 ], + "value": ":" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 15, - "column": 33 + "column": 36 }, - "end": { + "start": { "line": 15, - "column": 34 + "column": 35 } - } - }, - { - "type": "Identifier", - "value": "U", + }, "range": [ 290, 291 ], + "value": "U" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 15, - "column": 35 + "column": 37 }, - "end": { + "start": { "line": 15, "column": 36 } - } - }, - { - "type": "Punctuator", - "value": "}", + }, "range": [ 291, 292 ], + "value": "}" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 15, - "column": 36 + "column": 38 }, - "end": { + "start": { "line": 15, "column": 37 } - } - }, - { - "type": "Punctuator", - "value": ">", + }, "range": [ 292, 293 ], + "value": ">" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 15, - "column": 37 + "column": 39 }, - "end": { + "start": { "line": 15, "column": 38 } - } - }, - { - "type": "Punctuator", - "value": "(", + }, "range": [ 293, 294 ], + "value": "(" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 15, - "column": 38 + "column": 40 }, - "end": { + "start": { "line": 15, "column": 39 } - } - }, - { - "type": "Punctuator", - "value": ")", + }, "range": [ 294, 295 ], - "loc": { - "start": { - "line": 15, - "column": 39 - }, - "end": { - "line": 15, - "column": 40 - } - } + "value": ")" }, { "type": "Keyword", - "value": "const", + "loc": { + "end": { + "line": 16, + "column": 5 + }, + "start": { + "line": 16, + "column": 0 + } + }, "range": [ 296, 301 ], + "value": "const" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 16, - "column": 0 + "column": 9 }, - "end": { + "start": { "line": 16, - "column": 5 + "column": 6 } - } - }, - { - "type": "Identifier", - "value": "foo", + }, "range": [ 302, 305 ], + "value": "foo" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 16, - "column": 6 + "column": 11 }, - "end": { + "start": { "line": 16, - "column": 9 + "column": 10 } - } - }, - { - "type": "Punctuator", - "value": "=", + }, "range": [ 306, 307 ], + "value": "=" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 16, - "column": 10 + "column": 13 }, - "end": { + "start": { "line": 16, - "column": 11 + "column": 12 } - } - }, - { - "type": "Identifier", - "value": "p", + }, "range": [ 308, 309 ], + "value": "p" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 16, - "column": 12 + "column": 14 }, - "end": { + "start": { "line": 16, "column": 13 } - } - }, - { - "type": "Punctuator", - "value": ".", + }, "range": [ 309, 310 ], + "value": "." + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 16, - "column": 13 + "column": 17 }, - "end": { + "start": { "line": 16, "column": 14 } - } - }, - { - "type": "Identifier", - "value": "foo", + }, "range": [ 310, 313 ], - "loc": { - "start": { - "line": 16, - "column": 14 - }, - "end": { - "line": 16, - "column": 17 - } - } + "value": "foo" }, { "type": "Identifier", - "value": "console", + "loc": { + "end": { + "line": 17, + "column": 7 + }, + "start": { + "line": 17, + "column": 0 + } + }, "range": [ 314, 321 ], + "value": "console" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 17, - "column": 0 + "column": 8 }, - "end": { + "start": { "line": 17, "column": 7 } - } - }, - { - "type": "Punctuator", - "value": ".", + }, "range": [ 321, 322 ], + "value": "." + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 17, - "column": 7 + "column": 11 }, - "end": { + "start": { "line": 17, "column": 8 } - } - }, - { - "type": "Identifier", - "value": "log", + }, "range": [ 322, 325 ], + "value": "log" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 17, - "column": 8 + "column": 12 }, - "end": { + "start": { "line": 17, "column": 11 } - } - }, - { - "type": "Punctuator", - "value": "(", + }, "range": [ 325, 326 ], + "value": "(" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 17, - "column": 11 + "column": 15 }, - "end": { + "start": { "line": 17, "column": 12 } - } - }, - { - "type": "Identifier", - "value": "foo", + }, "range": [ 326, 329 ], - "loc": { - "start": { - "line": 17, - "column": 12 - }, - "end": { - "line": 17, - "column": 15 - } - } + "value": "foo" }, { "type": "Punctuator", - "value": ")", - "range": [ - 329, - 330 - ], "loc": { - "start": { - "line": 17, - "column": 15 - }, "end": { "line": 17, "column": 16 + }, + "start": { + "line": 17, + "column": 15 } - } + }, + "range": [ + 329, + 330 + ], + "value": ")" }, { "type": "Punctuator", @@ -1299,7 +1327,16 @@ "value": "</script>" } ], - "comments": [], + "loc": { + "end": { + "line": 18, + "column": 0 + }, + "start": { + "line": 14, + "column": 0 + } + }, "templateBody": { "type": "VElement", "range": [ @@ -1375,19 +1412,21 @@ }, "expression": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 354, 357 ], "loc": { - "start": { - "line": 20, - "column": 2 - }, "end": { "line": 20, "column": 5 + }, + "start": { + "line": 20, + "column": 2 } } }, @@ -1395,19 +1434,21 @@ { "id": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 354, 357 ], "loc": { - "start": { - "line": 20, - "column": 2 - }, "end": { "line": 20, "column": 5 + }, + "start": { + "line": 20, + "column": 2 } } }, @@ -1601,381 +1642,381 @@ }, { "type": "Identifier", - "value": "T", - "range": [ - 36, - 37 - ], "loc": { - "start": { - "line": 2, - "column": 2 - }, "end": { "line": 2, "column": 3 + }, + "start": { + "line": 2, + "column": 2 } - } + }, + "range": [ + 36, + 37 + ], + "value": "T" }, { "type": "Keyword", - "value": "extends", + "loc": { + "end": { + "line": 3, + "column": 11 + }, + "start": { + "line": 3, + "column": 4 + } + }, "range": [ 54, 61 ], + "value": "extends" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 3, - "column": 4 + "column": 23 }, - "end": { + "start": { "line": 3, - "column": 11 + "column": 20 } - } - }, - { - "type": "Identifier", - "value": "Foo", + }, "range": [ 70, 73 ], + "value": "Foo" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 3, - "column": 20 + "column": 25 }, - "end": { + "start": { "line": 3, - "column": 23 + "column": 24 } - } - }, - { - "type": "Punctuator", - "value": "=", + }, "range": [ 74, 75 ], + "value": "=" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 3, - "column": 24 + "column": 32 }, - "end": { + "start": { "line": 3, - "column": 25 + "column": 26 } - } - }, - { - "type": "Identifier", - "value": "number", + }, "range": [ 76, 82 ], + "value": "number" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 3, - "column": 26 + "column": 33 }, - "end": { + "start": { "line": 3, "column": 32 } - } - }, - { - "type": "Punctuator", - "value": ",", + }, "range": [ 82, 83 ], - "loc": { - "start": { - "line": 3, - "column": 32 - }, - "end": { - "line": 3, - "column": 33 - } - } + "value": "," }, { "type": "Identifier", - "value": "U", - "range": [ - 102, - 103 - ], "loc": { - "start": { - "line": 5, - "column": 2 - }, "end": { "line": 5, "column": 3 + }, + "start": { + "line": 5, + "column": 2 } - } + }, + "range": [ + 102, + 103 + ], + "value": "U" }, { "type": "Keyword", - "value": "extends", - "range": [ - 122, - 129 - ], "loc": { - "start": { - "line": 6, - "column": 4 - }, "end": { "line": 6, "column": 11 + }, + "start": { + "line": 6, + "column": 4 } - } + }, + "range": [ + 122, + 129 + ], + "value": "extends" }, { "type": "Identifier", - "value": "Record", + "loc": { + "end": { + "line": 7, + "column": 10 + }, + "start": { + "line": 7, + "column": 4 + } + }, "range": [ 134, 140 ], + "value": "Record" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 7, - "column": 4 + "column": 14 }, - "end": { + "start": { "line": 7, "column": 10 } - } - }, - { - "type": "Punctuator", - "value": "<", + }, "range": [ 140, 144 ], - "loc": { - "start": { - "line": 7, - "column": 10 - }, - "end": { - "line": 7, - "column": 14 - } - } + "value": "<" }, { "type": "Identifier", - "value": "string", + "loc": { + "end": { + "line": 9, + "column": 12 + }, + "start": { + "line": 9, + "column": 6 + } + }, "range": [ 165, 171 ], + "value": "string" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 9, - "column": 6 + "column": 13 }, - "end": { + "start": { "line": 9, "column": 12 } - } - }, - { - "type": "Punctuator", - "value": ",", + }, "range": [ 171, 172 ], - "loc": { - "start": { - "line": 9, - "column": 12 - }, - "end": { - "line": 9, - "column": 13 - } - } + "value": "," }, { "type": "Identifier", - "value": "T", - "range": [ - 184, - 185 - ], "loc": { - "start": { - "line": 10, - "column": 6 - }, "end": { "line": 10, "column": 7 + }, + "start": { + "line": 10, + "column": 6 } - } + }, + "range": [ + 184, + 185 + ], + "value": "T" }, { "type": "Punctuator", - "value": ">", - "range": [ - 190, - 191 - ], "loc": { - "start": { - "line": 11, - "column": 4 - }, "end": { "line": 11, "column": 5 + }, + "start": { + "line": 11, + "column": 4 } - } + }, + "range": [ + 190, + 191 + ], + "value": ">" }, { "type": "Punctuator", - "value": "=", + "loc": { + "end": { + "line": 12, + "column": 6 + }, + "start": { + "line": 12, + "column": 5 + } + }, "range": [ 197, 198 ], + "value": "=" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 12, - "column": 5 + "column": 13 }, - "end": { + "start": { "line": 12, - "column": 6 + "column": 7 } - } - }, - { - "type": "Identifier", - "value": "Record", + }, "range": [ 199, 205 ], + "value": "Record" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 12, - "column": 7 + "column": 14 }, - "end": { + "start": { "line": 12, "column": 13 } - } - }, - { - "type": "Punctuator", - "value": "<", + }, "range": [ 205, 206 ], + "value": "<" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 12, - "column": 13 + "column": 20 }, - "end": { + "start": { "line": 12, "column": 14 } - } - }, - { - "type": "Identifier", - "value": "string", + }, "range": [ 206, 212 ], + "value": "string" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 12, - "column": 14 + "column": 21 }, - "end": { + "start": { "line": 12, "column": 20 } - } - }, - { - "type": "Punctuator", - "value": ",", + }, "range": [ 212, 213 ], + "value": "," + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 12, - "column": 20 + "column": 28 }, - "end": { + "start": { "line": 12, - "column": 21 + "column": 22 } - } - }, - { - "type": "Identifier", - "value": "number", + }, "range": [ 214, 220 ], + "value": "number" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 12, - "column": 22 + "column": 32 }, - "end": { + "start": { "line": 12, "column": 28 } - } - }, - { - "type": "Punctuator", - "value": ">", + }, "range": [ 220, 224 ], - "loc": { - "start": { - "line": 12, - "column": 28 - }, - "end": { - "line": 12, - "column": 32 - } - } + "value": ">" }, { "type": "Punctuator", @@ -2771,21 +2812,21 @@ }, { "type": "Identifier", - "value": "foo", - "range": [ - 354, - 357 - ], "loc": { - "start": { - "line": 20, - "column": 2 - }, "end": { "line": 20, "column": 5 + }, + "start": { + "line": 20, + "column": 2 } - } + }, + "range": [ + 354, + 357 + ], + "value": "foo" }, { "type": "VExpressionEnd", @@ -2863,111 +2904,111 @@ "comments": [ { "type": "Line", - "value": " Comments", - "range": [ - 38, - 49 - ], "loc": { - "start": { - "line": 2, - "column": 4 - }, "end": { "line": 2, "column": 15 + }, + "start": { + "line": 2, + "column": 4 } - } + }, + "range": [ + 38, + 49 + ], + "value": " Comments" }, { "type": "Block", - "value": " = ", - "range": [ - 62, - 69 - ], "loc": { - "start": { - "line": 3, - "column": 12 - }, "end": { "line": 3, "column": 19 + }, + "start": { + "line": 3, + "column": 12 } - } + }, + "range": [ + 62, + 69 + ], + "value": " = " }, { "type": "Line", - "value": " Comments", - "range": [ - 88, - 99 - ], "loc": { - "start": { - "line": 4, - "column": 4 - }, "end": { "line": 4, "column": 15 + }, + "start": { + "line": 4, + "column": 4 } - } + }, + "range": [ + 88, + 99 + ], + "value": " Comments" }, { "type": "Block", - "value": " extends ", - "range": [ - 104, - 117 - ], "loc": { - "start": { - "line": 5, - "column": 4 - }, "end": { "line": 5, "column": 17 + }, + "start": { + "line": 5, + "column": 4 } - } + }, + "range": [ + 104, + 117 + ], + "value": " extends " }, { "type": "Block", - "value": " = ", - "range": [ - 151, - 158 - ], "loc": { - "start": { - "line": 8, - "column": 6 - }, "end": { "line": 8, "column": 13 + }, + "start": { + "line": 8, + "column": 6 } - } + }, + "range": [ + 151, + 158 + ], + "value": " = " }, { "type": "Line", - "value": " =", - "range": [ - 173, - 177 - ], "loc": { - "start": { - "line": 9, - "column": 14 - }, "end": { "line": 9, "column": 18 + }, + "start": { + "line": 9, + "column": 14 } - } + }, + "range": [ + 173, + 177 + ], + "value": " =" } ], "errors": [] 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 index a08b871e..f79be40c 100644 --- a/test/fixtures/ast/vue3.3-generic-7-with-arrow/ast.json +++ b/test/fixtures/ast/vue3.3-generic-7-with-arrow/ast.json @@ -1,66 +1,61 @@ { "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": { - "start": { - "line": 5, - "column": 6 - }, "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": { - "start": { - "line": 5, - "column": 10 - }, "end": { "line": 5, "column": 21 + }, + "start": { + "line": 5, + "column": 10 } } }, - "arguments": [], "optional": false, - "range": [ - 113, - 140 - ], - "loc": { - "start": { - "line": 5, - "column": 10 - }, - "end": { - "line": 5, - "column": 37 - } - }, - "typeParameters": { + "typeArguments": { "type": "TSTypeParameterInstantiation", "range": [ 124, @@ -75,32 +70,37 @@ "computed": false, "key": { "type": "Identifier", + "decorators": [], "name": "t", + "optional": false, "range": [ 126, 127 ], "loc": { - "start": { - "line": 5, - "column": 23 - }, "end": { "line": 5, "column": 24 + }, + "start": { + "line": 5, + "column": 23 } } }, + "optional": false, + "readonly": false, + "static": false, "typeAnnotation": { "type": "TSTypeAnnotation", "loc": { - "start": { - "line": 5, - "column": 24 - }, "end": { "line": 5, "column": 27 + }, + "start": { + "line": 5, + "column": 24 } }, "range": [ @@ -111,19 +111,21 @@ "type": "TSTypeReference", "typeName": { "type": "Identifier", + "decorators": [], "name": "T", + "optional": false, "range": [ 129, 130 ], "loc": { - "start": { - "line": 5, - "column": 26 - }, "end": { "line": 5, "column": 27 + }, + "start": { + "line": 5, + "column": 26 } } }, @@ -132,13 +134,13 @@ 130 ], "loc": { - "start": { - "line": 5, - "column": 26 - }, "end": { "line": 5, "column": 27 + }, + "start": { + "line": 5, + "column": 26 } } } @@ -148,13 +150,13 @@ 131 ], "loc": { - "start": { - "line": 5, - "column": 23 - }, "end": { "line": 5, "column": 28 + }, + "start": { + "line": 5, + "column": 23 } } }, @@ -163,32 +165,37 @@ "computed": false, "key": { "type": "Identifier", + "decorators": [], "name": "u", + "optional": false, "range": [ 132, 133 ], "loc": { - "start": { - "line": 5, - "column": 29 - }, "end": { "line": 5, "column": 30 + }, + "start": { + "line": 5, + "column": 29 } } }, + "optional": false, + "readonly": false, + "static": false, "typeAnnotation": { "type": "TSTypeAnnotation", "loc": { - "start": { - "line": 5, - "column": 30 - }, "end": { "line": 5, "column": 33 + }, + "start": { + "line": 5, + "column": 30 } }, "range": [ @@ -199,19 +206,21 @@ "type": "TSTypeReference", "typeName": { "type": "Identifier", + "decorators": [], "name": "U", + "optional": false, "range": [ 135, 136 ], "loc": { - "start": { - "line": 5, - "column": 32 - }, "end": { "line": 5, "column": 33 + }, + "start": { + "line": 5, + "column": 32 } } }, @@ -220,13 +229,13 @@ 136 ], "loc": { - "start": { - "line": 5, - "column": 32 - }, "end": { "line": 5, "column": 33 + }, + "start": { + "line": 5, + "column": 32 } } } @@ -236,13 +245,13 @@ 136 ], "loc": { - "start": { - "line": 5, - "column": 29 - }, "end": { "line": 5, "column": 33 + }, + "start": { + "line": 5, + "column": 29 } } } @@ -252,27 +261,41 @@ 137 ], "loc": { - "start": { - "line": 5, - "column": 22 - }, "end": { "line": 5, "column": 34 + }, + "start": { + "line": 5, + "column": 22 } } } ], "loc": { - "start": { - "line": 5, - "column": 21 - }, "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": [ @@ -280,49 +303,37 @@ 140 ], "loc": { - "start": { - "line": 5, - "column": 6 - }, "end": { "line": 5, "column": 37 + }, + "start": { + "line": 5, + "column": 6 } } } ], + "declare": false, "kind": "const", "range": [ 103, 140 ], "loc": { - "start": { - "line": 5, - "column": 0 - }, "end": { "line": 5, "column": 37 + }, + "start": { + "line": 5, + "column": 0 } } } ], + "comments": [], "sourceType": "module", - "range": [ - 103, - 141 - ], - "loc": { - "start": { - "line": 5, - "column": 0 - }, - "end": { - "line": 6, - "column": 0 - } - }, "tokens": [ { "type": "Punctuator", @@ -344,309 +355,309 @@ }, { "type": "Keyword", - "value": "const", + "loc": { + "end": { + "line": 5, + "column": 5 + }, + "start": { + "line": 5, + "column": 0 + } + }, "range": [ 103, 108 ], + "value": "const" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 5, - "column": 0 + "column": 7 }, - "end": { + "start": { "line": 5, - "column": 5 + "column": 6 } - } - }, - { - "type": "Identifier", - "value": "p", + }, "range": [ 109, 110 ], + "value": "p" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 6 + "column": 9 }, - "end": { + "start": { "line": 5, - "column": 7 + "column": 8 } - } - }, - { - "type": "Punctuator", - "value": "=", + }, "range": [ 111, 112 ], + "value": "=" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 5, - "column": 8 + "column": 21 }, - "end": { + "start": { "line": 5, - "column": 9 + "column": 10 } - } - }, - { - "type": "Identifier", - "value": "defineProps", + }, "range": [ 113, 124 ], + "value": "defineProps" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 10 + "column": 22 }, - "end": { + "start": { "line": 5, "column": 21 } - } - }, - { - "type": "Punctuator", - "value": "<", + }, "range": [ 124, 125 ], + "value": "<" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 21 + "column": 23 }, - "end": { + "start": { "line": 5, "column": 22 } - } - }, - { - "type": "Punctuator", - "value": "{", + }, "range": [ 125, 126 ], + "value": "{" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 5, - "column": 22 + "column": 24 }, - "end": { + "start": { "line": 5, "column": 23 } - } - }, - { - "type": "Identifier", - "value": "t", + }, "range": [ 126, 127 ], + "value": "t" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 23 + "column": 25 }, - "end": { + "start": { "line": 5, "column": 24 } - } - }, - { - "type": "Punctuator", - "value": ":", + }, "range": [ 127, 128 ], + "value": ":" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 5, - "column": 24 + "column": 27 }, - "end": { + "start": { "line": 5, - "column": 25 + "column": 26 } - } - }, - { - "type": "Identifier", - "value": "T", + }, "range": [ 129, 130 ], + "value": "T" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 26 + "column": 28 }, - "end": { + "start": { "line": 5, "column": 27 } - } - }, - { - "type": "Punctuator", - "value": ",", + }, "range": [ 130, 131 ], + "value": "," + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 5, - "column": 27 + "column": 30 }, - "end": { + "start": { "line": 5, - "column": 28 + "column": 29 } - } - }, - { - "type": "Identifier", - "value": "u", + }, "range": [ 132, 133 ], + "value": "u" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 29 + "column": 31 }, - "end": { + "start": { "line": 5, "column": 30 } - } - }, - { - "type": "Punctuator", - "value": ":", + }, "range": [ 133, 134 ], + "value": ":" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 5, - "column": 30 + "column": 33 }, - "end": { + "start": { "line": 5, - "column": 31 + "column": 32 } - } - }, - { - "type": "Identifier", - "value": "U", + }, "range": [ 135, 136 ], + "value": "U" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 32 + "column": 34 }, - "end": { + "start": { "line": 5, "column": 33 } - } - }, - { - "type": "Punctuator", - "value": "}", + }, "range": [ 136, 137 ], + "value": "}" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 33 + "column": 35 }, - "end": { + "start": { "line": 5, "column": 34 } - } - }, - { - "type": "Punctuator", - "value": ">", + }, "range": [ 137, 138 ], + "value": ">" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 34 + "column": 36 }, - "end": { + "start": { "line": 5, "column": 35 } - } - }, - { - "type": "Punctuator", - "value": "(", + }, "range": [ 138, 139 ], + "value": "(" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 35 + "column": 37 }, - "end": { + "start": { "line": 5, "column": 36 } - } - }, - { - "type": "Punctuator", - "value": ")", + }, "range": [ 139, 140 ], - "loc": { - "start": { - "line": 5, - "column": 36 - }, - "end": { - "line": 5, - "column": 37 - } - } + "value": ")" }, { "type": "Punctuator", @@ -667,7 +678,16 @@ "value": "</script>" } ], - "comments": [], + "loc": { + "end": { + "line": 6, + "column": 0 + }, + "start": { + "line": 5, + "column": 0 + } + }, "templateBody": { "type": "VElement", "range": [ @@ -743,75 +763,79 @@ }, "expression": { "type": "CallExpression", + "arguments": [], "callee": { "type": "MemberExpression", + "computed": false, "object": { "type": "Identifier", + "decorators": [], "name": "p", + "optional": false, "range": [ 165, 166 ], "loc": { - "start": { - "line": 9, - "column": 2 - }, "end": { "line": 9, "column": 3 + }, + "start": { + "line": 9, + "column": 2 } } }, + "optional": false, "property": { "type": "Identifier", + "decorators": [], "name": "t", + "optional": false, "range": [ 167, 168 ], "loc": { - "start": { - "line": 9, - "column": 4 - }, "end": { "line": 9, "column": 5 + }, + "start": { + "line": 9, + "column": 4 } } }, - "computed": false, - "optional": false, "range": [ 165, 168 - ], - "loc": { - "start": { - "line": 9, - "column": 2 - }, + ], + "loc": { "end": { "line": 9, "column": 5 + }, + "start": { + "line": 9, + "column": 2 } } }, - "arguments": [], "optional": false, "range": [ 165, 170 ], "loc": { - "start": { - "line": 9, - "column": 2 - }, "end": { "line": 9, "column": 7 + }, + "start": { + "line": 9, + "column": 2 } } }, @@ -819,19 +843,21 @@ { "id": { "type": "Identifier", + "decorators": [], "name": "p", + "optional": false, "range": [ 165, 166 ], "loc": { - "start": { - "line": 9, - "column": 2 - }, "end": { "line": 9, "column": 3 + }, + "start": { + "line": 9, + "column": 2 } } }, @@ -877,75 +903,79 @@ }, "expression": { "type": "CallExpression", + "arguments": [], "callee": { "type": "MemberExpression", + "computed": false, "object": { "type": "Identifier", + "decorators": [], "name": "p", + "optional": false, "range": [ 175, 176 ], "loc": { - "start": { - "line": 10, - "column": 2 - }, "end": { "line": 10, "column": 3 + }, + "start": { + "line": 10, + "column": 2 } } }, + "optional": false, "property": { "type": "Identifier", + "decorators": [], "name": "u", + "optional": false, "range": [ 177, 178 ], "loc": { - "start": { - "line": 10, - "column": 4 - }, "end": { "line": 10, "column": 5 + }, + "start": { + "line": 10, + "column": 4 } } }, - "computed": false, - "optional": false, "range": [ 175, 178 ], "loc": { - "start": { - "line": 10, - "column": 2 - }, "end": { "line": 10, "column": 5 + }, + "start": { + "line": 10, + "column": 2 } } }, - "arguments": [], "optional": false, "range": [ 175, 180 ], "loc": { - "start": { - "line": 10, - "column": 2 - }, "end": { "line": 10, "column": 7 + }, + "start": { + "line": 10, + "column": 2 } } }, @@ -953,19 +983,21 @@ { "id": { "type": "Identifier", + "decorators": [], "name": "p", + "optional": false, "range": [ 175, 176 ], "loc": { - "start": { - "line": 10, - "column": 2 - }, "end": { "line": 10, "column": 3 + }, + "start": { + "line": 10, + "column": 2 } } }, @@ -1159,327 +1191,327 @@ }, { "type": "Identifier", - "value": "T", + "loc": { + "end": { + "line": 2, + "column": 3 + }, + "start": { + "line": 2, + "column": 2 + } + }, "range": [ 36, 37 ], + "value": "T" + }, + { + "type": "Keyword", "loc": { - "start": { + "end": { "line": 2, - "column": 2 + "column": 11 }, - "end": { + "start": { "line": 2, - "column": 3 + "column": 4 } - } - }, - { - "type": "Keyword", - "value": "extends", + }, "range": [ 38, 45 ], + "value": "extends" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 4 + "column": 13 }, - "end": { + "start": { "line": 2, - "column": 11 + "column": 12 } - } - }, - { - "type": "Punctuator", - "value": "(", + }, "range": [ 46, 47 ], + "value": "(" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 12 + "column": 14 }, - "end": { + "start": { "line": 2, "column": 13 } - } - }, - { - "type": "Punctuator", - "value": ")", + }, "range": [ 47, 48 ], + "value": ")" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 13 + "column": 17 }, - "end": { + "start": { "line": 2, - "column": 14 + "column": 15 } - } - }, - { - "type": "Punctuator", - "value": "=>", + }, "range": [ 49, 51 ], + "value": "=>" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 2, - "column": 15 + "column": 24 }, - "end": { + "start": { "line": 2, - "column": 17 + "column": 18 } - } - }, - { - "type": "Identifier", - "value": "string", + }, "range": [ 52, 58 ], + "value": "string" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 18 + "column": 25 }, - "end": { + "start": { "line": 2, "column": 24 } - } - }, - { - "type": "Punctuator", - "value": ",", + }, "range": [ 58, 59 ], - "loc": { - "start": { - "line": 2, - "column": 24 - }, - "end": { - "line": 2, - "column": 25 - } - } + "value": "," }, { "type": "Identifier", - "value": "U", + "loc": { + "end": { + "line": 3, + "column": 3 + }, + "start": { + "line": 3, + "column": 2 + } + }, "range": [ 62, 63 ], + "value": "U" + }, + { + "type": "Keyword", "loc": { - "start": { + "end": { "line": 3, - "column": 2 + "column": 12 }, - "end": { + "start": { "line": 3, - "column": 3 + "column": 5 } - } - }, - { - "type": "Keyword", - "value": "extends", + }, "range": [ 65, 72 ], + "value": "extends" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 3, - "column": 5 + "column": 14 }, - "end": { + "start": { "line": 3, - "column": 12 + "column": 13 } - } - }, - { - "type": "Punctuator", - "value": "(", + }, "range": [ 73, 74 ], + "value": "(" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 3, - "column": 13 + "column": 15 }, - "end": { + "start": { "line": 3, "column": 14 } - } - }, - { - "type": "Punctuator", - "value": ")", + }, "range": [ 74, 75 ], + "value": ")" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 3, - "column": 14 + "column": 18 }, - "end": { + "start": { "line": 3, - "column": 15 + "column": 16 } - } - }, - { - "type": "Punctuator", - "value": "=>", + }, "range": [ 76, 78 ], + "value": "=>" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 3, - "column": 16 + "column": 25 }, - "end": { + "start": { "line": 3, - "column": 18 + "column": 19 } - } - }, - { - "type": "Identifier", - "value": "string", + }, "range": [ 79, 85 ], + "value": "string" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 3, - "column": 19 + "column": 27 }, - "end": { + "start": { "line": 3, - "column": 25 + "column": 26 } - } - }, - { - "type": "Punctuator", - "value": "=", + }, "range": [ 86, 87 ], + "value": "=" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 3, - "column": 26 + "column": 29 }, - "end": { + "start": { "line": 3, - "column": 27 + "column": 28 } - } - }, - { - "type": "Punctuator", - "value": "(", + }, "range": [ 88, 89 ], + "value": "(" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 3, - "column": 28 + "column": 30 }, - "end": { + "start": { "line": 3, "column": 29 } - } - }, - { - "type": "Punctuator", - "value": ")", + }, "range": [ 89, 90 ], + "value": ")" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 3, - "column": 29 + "column": 33 }, - "end": { + "start": { "line": 3, - "column": 30 + "column": 31 } - } - }, - { - "type": "Punctuator", - "value": "=>", + }, "range": [ 91, 93 ], + "value": "=>" + }, + { + "type": "String", "loc": { - "start": { + "end": { "line": 3, - "column": 31 + "column": 39 }, - "end": { + "start": { "line": 3, - "column": 33 + "column": 34 } - } - }, - { - "type": "String", - "value": "'abc'", + }, "range": [ 94, 99 ], - "loc": { - "start": { - "line": 3, - "column": 34 - }, - "end": { - "line": 3, - "column": 39 - } - } + "value": "'abc'" }, { "type": "Punctuator", @@ -1915,93 +1947,93 @@ }, { "type": "Identifier", - "value": "p", + "loc": { + "end": { + "line": 9, + "column": 3 + }, + "start": { + "line": 9, + "column": 2 + } + }, "range": [ 165, 166 ], + "value": "p" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 9, - "column": 2 + "column": 4 }, - "end": { + "start": { "line": 9, "column": 3 } - } - }, - { - "type": "Punctuator", - "value": ".", + }, "range": [ 166, 167 ], + "value": "." + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 9, - "column": 3 + "column": 5 }, - "end": { + "start": { "line": 9, "column": 4 } - } - }, - { - "type": "Identifier", - "value": "t", + }, "range": [ 167, 168 ], + "value": "t" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 9, - "column": 4 + "column": 6 }, - "end": { + "start": { "line": 9, "column": 5 } - } - }, - { - "type": "Punctuator", - "value": "(", + }, "range": [ 168, 169 ], + "value": "(" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 9, - "column": 5 + "column": 7 }, - "end": { + "start": { "line": 9, "column": 6 } - } - }, - { - "type": "Punctuator", - "value": ")", + }, "range": [ 169, 170 ], - "loc": { - "start": { - "line": 9, - "column": 6 - }, - "end": { - "line": 9, - "column": 7 - } - } + "value": ")" }, { "type": "VExpressionEnd", @@ -2059,93 +2091,93 @@ }, { "type": "Identifier", - "value": "p", + "loc": { + "end": { + "line": 10, + "column": 3 + }, + "start": { + "line": 10, + "column": 2 + } + }, "range": [ 175, 176 ], + "value": "p" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 10, - "column": 2 + "column": 4 }, - "end": { + "start": { "line": 10, "column": 3 } - } - }, - { - "type": "Punctuator", - "value": ".", + }, "range": [ 176, 177 ], + "value": "." + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 10, - "column": 3 + "column": 5 }, - "end": { + "start": { "line": 10, "column": 4 } - } - }, - { - "type": "Identifier", - "value": "u", + }, "range": [ 177, 178 ], + "value": "u" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 10, - "column": 4 + "column": 6 }, - "end": { + "start": { "line": 10, "column": 5 } - } - }, - { - "type": "Punctuator", - "value": "(", + }, "range": [ 178, 179 ], + "value": "(" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 10, - "column": 5 + "column": 7 }, - "end": { + "start": { "line": 10, "column": 6 } - } - }, - { - "type": "Punctuator", - "value": ")", + }, "range": [ 179, 180 ], - "loc": { - "start": { - "line": 10, - "column": 6 - }, - "end": { - "line": 10, - "column": 7 - } - } + "value": ")" }, { "type": "VExpressionEnd", 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 index b354feda..13c2a968 100644 --- a/test/fixtures/document-fragment/vue3.3-generic-1/document-fragment.json +++ b/test/fixtures/document-fragment/vue3.3-generic-1/document-fragment.json @@ -235,39 +235,41 @@ "params": [ { "type": "TSTypeParameter", + "const": false, + "in": false, "name": { "type": "Identifier", + "decorators": [], "name": "T", + "optional": false, "range": [ 33, 34 ], "loc": { - "start": { - "line": 1, - "column": 33 - }, "end": { "line": 1, "column": 34 + }, + "start": { + "line": 1, + "column": 33 } } }, - "in": false, "out": false, - "const": false, "range": [ 33, 34 ], "loc": { - "start": { - "line": 1, - "column": 33 - }, "end": { "line": 1, "column": 34 + }, + "start": { + "line": 1, + "column": 33 } } } @@ -322,19 +324,21 @@ { "id": { "type": "Identifier", + "decorators": [], "name": "T", + "optional": false, "range": [ 33, 34 ], "loc": { - "start": { - "line": 1, - "column": 33 - }, "end": { "line": 1, "column": 34 + }, + "start": { + "line": 1, + "column": 33 } } }, @@ -435,19 +439,21 @@ }, "expression": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 83, 86 ], "loc": { - "start": { - "line": 5, - "column": 2 - }, "end": { "line": 5, "column": 5 + }, + "start": { + "line": 5, + "column": 2 } } }, @@ -455,19 +461,21 @@ { "id": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 83, 86 ], "loc": { - "start": { - "line": 5, - "column": 2 - }, "end": { "line": 5, "column": 5 + }, + "start": { + "line": 5, + "column": 2 } } }, @@ -661,21 +669,21 @@ }, { "type": "Identifier", - "value": "T", - "range": [ - 33, - 34 - ], "loc": { - "start": { - "line": 1, - "column": 33 - }, "end": { "line": 1, "column": 34 + }, + "start": { + "line": 1, + "column": 33 } - } + }, + "range": [ + 33, + 34 + ], + "value": "T" }, { "type": "Punctuator", @@ -895,21 +903,21 @@ }, { "type": "Identifier", - "value": "foo", - "range": [ - 83, - 86 - ], "loc": { - "start": { - "line": 5, - "column": 2 - }, "end": { "line": 5, "column": 5 + }, + "start": { + "line": 5, + "column": 2 } - } + }, + "range": [ + 83, + 86 + ], + "value": "foo" }, { "type": "VExpressionEnd", @@ -1135,21 +1143,21 @@ }, { "type": "Identifier", - "value": "T", - "range": [ - 33, - 34 - ], "loc": { - "start": { - "line": 1, - "column": 33 - }, "end": { "line": 1, "column": 34 + }, + "start": { + "line": 1, + "column": 33 } - } + }, + "range": [ + 33, + 34 + ], + "value": "T" }, { "type": "Punctuator", @@ -1369,21 +1377,21 @@ }, { "type": "Identifier", - "value": "foo", - "range": [ - 83, - 86 - ], "loc": { - "start": { - "line": 5, - "column": 2 - }, "end": { "line": 5, "column": 5 + }, + "start": { + "line": 5, + "column": 2 } - } + }, + "range": [ + 83, + 86 + ], + "value": "foo" }, { "type": "VExpressionEnd", 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 index efd5dc1c..370d495c 100644 --- a/test/fixtures/document-fragment/vue3.3-generic-2/document-fragment.json +++ b/test/fixtures/document-fragment/vue3.3-generic-2/document-fragment.json @@ -330,41 +330,26 @@ "params": [ { "type": "TSTypeParameter", - "name": { - "type": "Identifier", - "name": "T", - "range": [ - 79, - 80 - ], - "loc": { - "start": { - "line": 4, - "column": 33 - }, - "end": { - "line": 4, - "column": 34 - } - } - }, + "const": false, "constraint": { "type": "TSTypeReference", "typeName": { "type": "Identifier", + "decorators": [], "name": "Foo", + "optional": false, "range": [ 89, 92 ], "loc": { - "start": { - "line": 4, - "column": 43 - }, "end": { "line": 4, "column": 46 + }, + "start": { + "line": 4, + "column": 43 } } }, @@ -373,31 +358,50 @@ 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": 46 + "column": 34 + }, + "start": { + "line": 4, + "column": 33 } } }, - "in": false, "out": false, - "const": false, "range": [ 79, 92 ], "loc": { - "start": { - "line": 4, - "column": 33 - }, "end": { "line": 4, "column": 46 + }, + "start": { + "line": 4, + "column": 33 } } } @@ -410,19 +414,21 @@ { "id": { "type": "Identifier", + "decorators": [], "name": "Foo", + "optional": false, "range": [ 89, 92 ], "loc": { - "start": { - "line": 4, - "column": 43 - }, "end": { "line": 4, "column": 46 + }, + "start": { + "line": 4, + "column": 43 } } }, @@ -476,19 +482,21 @@ { "id": { "type": "Identifier", + "decorators": [], "name": "T", + "optional": false, "range": [ 79, 80 ], "loc": { - "start": { - "line": 4, - "column": 33 - }, "end": { "line": 4, "column": 34 + }, + "start": { + "line": 4, + "column": 33 } } }, @@ -589,19 +597,21 @@ }, "expression": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 186, 189 ], "loc": { - "start": { - "line": 10, - "column": 2 - }, "end": { "line": 10, "column": 5 + }, + "start": { + "line": 10, + "column": 2 } } }, @@ -609,19 +619,21 @@ { "id": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 186, 189 ], "loc": { - "start": { - "line": 10, - "column": 2 - }, "end": { "line": 10, "column": 5 + }, + "start": { + "line": 10, + "column": 2 } } }, @@ -1139,57 +1151,57 @@ }, { "type": "Identifier", - "value": "T", + "loc": { + "end": { + "line": 4, + "column": 34 + }, + "start": { + "line": 4, + "column": 33 + } + }, "range": [ 79, 80 ], + "value": "T" + }, + { + "type": "Keyword", "loc": { - "start": { + "end": { "line": 4, - "column": 33 + "column": 42 }, - "end": { + "start": { "line": 4, - "column": 34 + "column": 35 } - } - }, - { - "type": "Keyword", - "value": "extends", + }, "range": [ 81, 88 ], + "value": "extends" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 4, - "column": 35 + "column": 46 }, - "end": { + "start": { "line": 4, - "column": 42 + "column": 43 } - } - }, - { - "type": "Identifier", - "value": "Foo", + }, "range": [ 89, 92 ], - "loc": { - "start": { - "line": 4, - "column": 43 - }, - "end": { - "line": 4, - "column": 46 - } - } + "value": "Foo" }, { "type": "Punctuator", @@ -1697,21 +1709,21 @@ }, { "type": "Identifier", - "value": "foo", - "range": [ - 186, - 189 - ], "loc": { - "start": { - "line": 10, - "column": 2 - }, "end": { "line": 10, "column": 5 + }, + "start": { + "line": 10, + "column": 2 } - } + }, + "range": [ + 186, + 189 + ], + "value": "foo" }, { "type": "VExpressionEnd", @@ -2261,57 +2273,57 @@ }, { "type": "Identifier", - "value": "T", + "loc": { + "end": { + "line": 4, + "column": 34 + }, + "start": { + "line": 4, + "column": 33 + } + }, "range": [ 79, 80 ], + "value": "T" + }, + { + "type": "Keyword", "loc": { - "start": { + "end": { "line": 4, - "column": 33 + "column": 42 }, - "end": { + "start": { "line": 4, - "column": 34 + "column": 35 } - } - }, - { - "type": "Keyword", - "value": "extends", + }, "range": [ 81, 88 ], + "value": "extends" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 4, - "column": 35 + "column": 46 }, - "end": { + "start": { "line": 4, - "column": 42 + "column": 43 } - } - }, - { - "type": "Identifier", - "value": "Foo", + }, "range": [ 89, 92 ], - "loc": { - "start": { - "line": 4, - "column": 43 - }, - "end": { - "line": 4, - "column": 46 - } - } + "value": "Foo" }, { "type": "Punctuator", @@ -2819,21 +2831,21 @@ }, { "type": "Identifier", - "value": "foo", - "range": [ - 186, - 189 - ], "loc": { - "start": { - "line": 10, - "column": 2 - }, "end": { "line": 10, "column": 5 + }, + "start": { + "line": 10, + "column": 2 } - } + }, + "range": [ + 186, + 189 + ], + "value": "foo" }, { "type": "VExpressionEnd", diff --git a/test/fixtures/document-fragment/vue3.3-generic-2/tree.json b/test/fixtures/document-fragment/vue3.3-generic-2/tree.json index c55894cd..02563812 100644 --- a/test/fixtures/document-fragment/vue3.3-generic-2/tree.json +++ b/test/fixtures/document-fragment/vue3.3-generic-2/tree.json @@ -91,11 +91,6 @@ "type": "TSTypeParameter", "text": "T extends Foo", "children": [ - { - "type": "Identifier", - "text": "T", - "children": [] - }, { "type": "TSTypeReference", "text": "Foo", @@ -106,6 +101,11 @@ "children": [] } ] + }, + { + "type": "Identifier", + "text": "T", + "children": [] } ] } 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 index f3bedad1..352fa378 100644 --- a/test/fixtures/document-fragment/vue3.3-generic-3/document-fragment.json +++ b/test/fixtures/document-fragment/vue3.3-generic-3/document-fragment.json @@ -330,41 +330,26 @@ "params": [ { "type": "TSTypeParameter", - "name": { - "type": "Identifier", - "name": "T", - "range": [ - 79, - 80 - ], - "loc": { - "start": { - "line": 4, - "column": 33 - }, - "end": { - "line": 4, - "column": 34 - } - } - }, + "const": false, "constraint": { "type": "TSTypeReference", "typeName": { "type": "Identifier", + "decorators": [], "name": "Foo", + "optional": false, "range": [ 89, 92 ], "loc": { - "start": { - "line": 4, - "column": 43 - }, "end": { "line": 4, "column": 46 + }, + "start": { + "line": 4, + "column": 43 } } }, @@ -373,71 +358,75 @@ 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": 46 + "column": 34 + }, + "start": { + "line": 4, + "column": 33 } } }, - "in": false, "out": false, - "const": false, "range": [ 79, 92 ], "loc": { - "start": { - "line": 4, - "column": 33 - }, "end": { "line": 4, "column": 46 + }, + "start": { + "line": 4, + "column": 33 } } }, { "type": "TSTypeParameter", - "name": { - "type": "Identifier", - "name": "U", - "range": [ - 94, - 95 - ], - "loc": { - "start": { - "line": 4, - "column": 48 - }, - "end": { - "line": 4, - "column": 49 - } - } - }, + "const": false, "constraint": { "type": "TSTypeReference", "typeName": { "type": "Identifier", + "decorators": [], "name": "T", + "optional": false, "range": [ 104, 105 ], "loc": { - "start": { - "line": 4, - "column": 58 - }, "end": { "line": 4, "column": 59 + }, + "start": { + "line": 4, + "column": 58 } } }, @@ -446,31 +435,50 @@ 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": 59 + "column": 49 + }, + "start": { + "line": 4, + "column": 48 } } }, - "in": false, "out": false, - "const": false, "range": [ 94, 105 ], "loc": { - "start": { - "line": 4, - "column": 48 - }, "end": { "line": 4, "column": 59 + }, + "start": { + "line": 4, + "column": 48 } } } @@ -484,19 +492,21 @@ { "id": { "type": "Identifier", + "decorators": [], "name": "Foo", + "optional": false, "range": [ 89, 92 ], "loc": { - "start": { - "line": 4, - "column": 43 - }, "end": { "line": 4, "column": 46 + }, + "start": { + "line": 4, + "column": 43 } } }, @@ -550,19 +560,21 @@ { "id": { "type": "Identifier", + "decorators": [], "name": "T", + "optional": false, "range": [ 79, 80 ], "loc": { - "start": { - "line": 4, - "column": 33 - }, "end": { "line": 4, "column": 34 + }, + "start": { + "line": 4, + "column": 33 } } }, @@ -571,19 +583,21 @@ { "id": { "type": "Identifier", + "decorators": [], "name": "U", + "optional": false, "range": [ 94, 95 ], "loc": { - "start": { - "line": 4, - "column": 48 - }, "end": { "line": 4, "column": 49 + }, + "start": { + "line": 4, + "column": 48 } } }, @@ -684,19 +698,21 @@ }, "expression": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 207, 210 ], "loc": { - "start": { - "line": 10, - "column": 2 - }, "end": { "line": 10, "column": 5 + }, + "start": { + "line": 10, + "column": 2 } } }, @@ -704,19 +720,21 @@ { "id": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 207, 210 ], "loc": { - "start": { - "line": 10, - "column": 2 - }, "end": { "line": 10, "column": 5 + }, + "start": { + "line": 10, + "column": 2 } } }, @@ -1234,129 +1252,129 @@ }, { "type": "Identifier", - "value": "T", + "loc": { + "end": { + "line": 4, + "column": 34 + }, + "start": { + "line": 4, + "column": 33 + } + }, "range": [ 79, 80 ], + "value": "T" + }, + { + "type": "Keyword", "loc": { - "start": { + "end": { "line": 4, - "column": 33 + "column": 42 }, - "end": { + "start": { "line": 4, - "column": 34 + "column": 35 } - } - }, - { - "type": "Keyword", - "value": "extends", + }, "range": [ 81, 88 ], + "value": "extends" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 4, - "column": 35 + "column": 46 }, - "end": { + "start": { "line": 4, - "column": 42 + "column": 43 } - } - }, - { - "type": "Identifier", - "value": "Foo", + }, "range": [ 89, 92 ], + "value": "Foo" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 4, - "column": 43 + "column": 47 }, - "end": { + "start": { "line": 4, "column": 46 } - } - }, - { - "type": "Punctuator", - "value": ",", + }, "range": [ 92, 93 ], + "value": "," + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 4, - "column": 46 + "column": 49 }, - "end": { + "start": { "line": 4, - "column": 47 + "column": 48 } - } - }, - { - "type": "Identifier", - "value": "U", + }, "range": [ 94, 95 ], + "value": "U" + }, + { + "type": "Keyword", "loc": { - "start": { + "end": { "line": 4, - "column": 48 + "column": 57 }, - "end": { + "start": { "line": 4, - "column": 49 + "column": 50 } - } - }, - { - "type": "Keyword", - "value": "extends", + }, "range": [ 96, 103 ], + "value": "extends" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 4, - "column": 50 + "column": 59 }, - "end": { + "start": { "line": 4, - "column": 57 + "column": 58 } - } - }, - { - "type": "Identifier", - "value": "T", + }, "range": [ 104, 105 ], - "loc": { - "start": { - "line": 4, - "column": 58 - }, - "end": { - "line": 4, - "column": 59 - } - } + "value": "T" }, { "type": "Punctuator", @@ -1936,21 +1954,21 @@ }, { "type": "Identifier", - "value": "foo", - "range": [ - 207, - 210 - ], "loc": { - "start": { - "line": 10, - "column": 2 - }, "end": { "line": 10, "column": 5 + }, + "start": { + "line": 10, + "column": 2 } - } + }, + "range": [ + 207, + 210 + ], + "value": "foo" }, { "type": "VExpressionEnd", @@ -2500,129 +2518,129 @@ }, { "type": "Identifier", - "value": "T", + "loc": { + "end": { + "line": 4, + "column": 34 + }, + "start": { + "line": 4, + "column": 33 + } + }, "range": [ 79, 80 ], + "value": "T" + }, + { + "type": "Keyword", "loc": { - "start": { + "end": { "line": 4, - "column": 33 + "column": 42 }, - "end": { + "start": { "line": 4, - "column": 34 + "column": 35 } - } - }, - { - "type": "Keyword", - "value": "extends", + }, "range": [ 81, 88 ], + "value": "extends" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 4, - "column": 35 + "column": 46 }, - "end": { + "start": { "line": 4, - "column": 42 + "column": 43 } - } - }, - { - "type": "Identifier", - "value": "Foo", + }, "range": [ 89, 92 ], + "value": "Foo" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 4, - "column": 43 + "column": 47 }, - "end": { + "start": { "line": 4, "column": 46 } - } - }, - { - "type": "Punctuator", - "value": ",", + }, "range": [ 92, 93 ], + "value": "," + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 4, - "column": 46 + "column": 49 }, - "end": { + "start": { "line": 4, - "column": 47 + "column": 48 } - } - }, - { - "type": "Identifier", - "value": "U", + }, "range": [ 94, 95 ], + "value": "U" + }, + { + "type": "Keyword", "loc": { - "start": { + "end": { "line": 4, - "column": 48 + "column": 57 }, - "end": { + "start": { "line": 4, - "column": 49 + "column": 50 } - } - }, - { - "type": "Keyword", - "value": "extends", + }, "range": [ 96, 103 ], + "value": "extends" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 4, - "column": 50 + "column": 59 }, - "end": { + "start": { "line": 4, - "column": 57 + "column": 58 } - } - }, - { - "type": "Identifier", - "value": "T", + }, "range": [ 104, 105 ], - "loc": { - "start": { - "line": 4, - "column": 58 - }, - "end": { - "line": 4, - "column": 59 - } - } + "value": "T" }, { "type": "Punctuator", @@ -3202,21 +3220,21 @@ }, { "type": "Identifier", - "value": "foo", - "range": [ - 207, - 210 - ], "loc": { - "start": { - "line": 10, - "column": 2 - }, "end": { "line": 10, "column": 5 + }, + "start": { + "line": 10, + "column": 2 } - } + }, + "range": [ + 207, + 210 + ], + "value": "foo" }, { "type": "VExpressionEnd", diff --git a/test/fixtures/document-fragment/vue3.3-generic-3/tree.json b/test/fixtures/document-fragment/vue3.3-generic-3/tree.json index 39979906..098b5927 100644 --- a/test/fixtures/document-fragment/vue3.3-generic-3/tree.json +++ b/test/fixtures/document-fragment/vue3.3-generic-3/tree.json @@ -91,11 +91,6 @@ "type": "TSTypeParameter", "text": "T extends Foo", "children": [ - { - "type": "Identifier", - "text": "T", - "children": [] - }, { "type": "TSTypeReference", "text": "Foo", @@ -106,6 +101,11 @@ "children": [] } ] + }, + { + "type": "Identifier", + "text": "T", + "children": [] } ] }, @@ -113,11 +113,6 @@ "type": "TSTypeParameter", "text": "U extends T", "children": [ - { - "type": "Identifier", - "text": "U", - "children": [] - }, { "type": "TSTypeReference", "text": "T", @@ -128,6 +123,11 @@ "children": [] } ] + }, + { + "type": "Identifier", + "text": "U", + "children": [] } ] } 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 index 23514a87..fd104f1b 100644 --- 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 @@ -235,41 +235,26 @@ "params": [ { "type": "TSTypeParameter", - "name": { - "type": "Identifier", - "name": "T", - "range": [ - 36, - 37 - ], - "loc": { - "start": { - "line": 2, - "column": 2 - }, - "end": { - "line": 2, - "column": 3 - } - } - }, + "const": false, "constraint": { "type": "TSTypeReference", "typeName": { "type": "Identifier", + "decorators": [], "name": "Foo", + "optional": false, "range": [ 50, 53 ], "loc": { - "start": { - "line": 3, - "column": 12 - }, "end": { "line": 3, "column": 15 + }, + "start": { + "line": 3, + "column": 12 } } }, @@ -278,71 +263,75 @@ 53 ], "loc": { - "start": { - "line": 3, - "column": 12 - }, "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, - "const": false, "range": [ 36, 53 ], "loc": { - "start": { - "line": 2, - "column": 2 - }, "end": { "line": 3, "column": 15 + }, + "start": { + "line": 2, + "column": 2 } } }, { "type": "TSTypeParameter", - "name": { - "type": "Identifier", - "name": "U", - "range": [ - 73, - 74 - ], - "loc": { - "start": { - "line": 5, - "column": 2 - }, - "end": { - "line": 5, - "column": 3 - } - } - }, + "const": false, "constraint": { "type": "TSTypeReference", "typeName": { "type": "Identifier", + "decorators": [], "name": "T", + "optional": false, "range": [ 87, 88 ], "loc": { - "start": { - "line": 6, - "column": 4 - }, "end": { "line": 6, "column": 5 + }, + "start": { + "line": 6, + "column": 4 } } }, @@ -351,31 +340,50 @@ 88 ], "loc": { - "start": { - "line": 6, - "column": 4 - }, "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, - "const": false, "range": [ 73, 88 ], "loc": { - "start": { - "line": 5, - "column": 2 - }, "end": { "line": 6, "column": 5 + }, + "start": { + "line": 5, + "column": 2 } } } @@ -389,19 +397,21 @@ { "id": { "type": "Identifier", + "decorators": [], "name": "Foo", + "optional": false, "range": [ 50, 53 ], "loc": { - "start": { - "line": 3, - "column": 12 - }, "end": { "line": 3, "column": 15 + }, + "start": { + "line": 3, + "column": 12 } } }, @@ -455,19 +465,21 @@ { "id": { "type": "Identifier", + "decorators": [], "name": "T", + "optional": false, "range": [ 36, 37 ], "loc": { - "start": { - "line": 2, - "column": 2 - }, "end": { "line": 2, "column": 3 + }, + "start": { + "line": 2, + "column": 2 } } }, @@ -476,19 +488,21 @@ { "id": { "type": "Identifier", + "decorators": [], "name": "U", + "optional": false, "range": [ 73, 74 ], "loc": { - "start": { - "line": 5, - "column": 2 - }, "end": { "line": 5, "column": 3 + }, + "start": { + "line": 5, + "column": 2 } } }, @@ -589,19 +603,21 @@ }, "expression": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 218, 221 ], "loc": { - "start": { - "line": 14, - "column": 2 - }, "end": { "line": 14, "column": 5 + }, + "start": { + "line": 14, + "column": 2 } } }, @@ -609,19 +625,21 @@ { "id": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 218, 221 ], "loc": { - "start": { - "line": 14, - "column": 2 - }, "end": { "line": 14, "column": 5 + }, + "start": { + "line": 14, + "column": 2 } } }, @@ -815,129 +833,129 @@ }, { "type": "Identifier", - "value": "T", - "range": [ - 36, - 37 - ], "loc": { - "start": { - "line": 2, - "column": 2 - }, "end": { "line": 2, "column": 3 + }, + "start": { + "line": 2, + "column": 2 } - } + }, + "range": [ + 36, + 37 + ], + "value": "T" }, { "type": "Keyword", - "value": "extends", + "loc": { + "end": { + "line": 3, + "column": 11 + }, + "start": { + "line": 3, + "column": 4 + } + }, "range": [ 42, 49 ], + "value": "extends" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 3, - "column": 4 + "column": 15 }, - "end": { + "start": { "line": 3, - "column": 11 + "column": 12 } - } - }, - { - "type": "Identifier", - "value": "Foo", + }, "range": [ 50, 53 ], + "value": "Foo" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 3, - "column": 12 + "column": 16 }, - "end": { + "start": { "line": 3, "column": 15 } - } - }, - { - "type": "Punctuator", - "value": ",", + }, "range": [ 53, 54 ], - "loc": { - "start": { - "line": 3, - "column": 15 - }, - "end": { - "line": 3, - "column": 16 - } - } + "value": "," }, { "type": "Identifier", - "value": "U", - "range": [ - 73, - 74 - ], "loc": { - "start": { - "line": 5, - "column": 2 - }, "end": { "line": 5, "column": 3 + }, + "start": { + "line": 5, + "column": 2 } - } + }, + "range": [ + 73, + 74 + ], + "value": "U" }, { "type": "Keyword", - "value": "extends", - "range": [ - 75, - 82 - ], "loc": { - "start": { - "line": 5, - "column": 4 - }, "end": { "line": 5, "column": 11 + }, + "start": { + "line": 5, + "column": 4 } - } + }, + "range": [ + 75, + 82 + ], + "value": "extends" }, { "type": "Identifier", - "value": "T", - "range": [ - 87, - 88 - ], "loc": { - "start": { - "line": 6, - "column": 4 - }, "end": { "line": 6, "column": 5 + }, + "start": { + "line": 6, + "column": 4 } - } + }, + "range": [ + 87, + 88 + ], + "value": "T" }, { "type": "Punctuator", @@ -1733,21 +1751,21 @@ }, { "type": "Identifier", - "value": "foo", - "range": [ - 218, - 221 - ], "loc": { - "start": { - "line": 14, - "column": 2 - }, "end": { "line": 14, "column": 5 + }, + "start": { + "line": 14, + "column": 2 } - } + }, + "range": [ + 218, + 221 + ], + "value": "foo" }, { "type": "VExpressionEnd", @@ -1825,21 +1843,21 @@ "comments": [ { "type": "Line", - "value": " Comments", - "range": [ - 59, - 70 - ], "loc": { - "start": { - "line": 4, - "column": 4 - }, "end": { "line": 4, "column": 15 + }, + "start": { + "line": 4, + "column": 4 } - } + }, + "range": [ + 59, + 70 + ], + "value": " Comments" } ], "errors": [] @@ -1992,129 +2010,129 @@ }, { "type": "Identifier", - "value": "T", - "range": [ - 36, - 37 - ], "loc": { - "start": { - "line": 2, - "column": 2 - }, "end": { "line": 2, "column": 3 + }, + "start": { + "line": 2, + "column": 2 } - } + }, + "range": [ + 36, + 37 + ], + "value": "T" }, { "type": "Keyword", - "value": "extends", + "loc": { + "end": { + "line": 3, + "column": 11 + }, + "start": { + "line": 3, + "column": 4 + } + }, "range": [ 42, 49 ], + "value": "extends" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 3, - "column": 4 + "column": 15 }, - "end": { + "start": { "line": 3, - "column": 11 + "column": 12 } - } - }, - { - "type": "Identifier", - "value": "Foo", + }, "range": [ 50, 53 ], + "value": "Foo" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 3, - "column": 12 + "column": 16 }, - "end": { + "start": { "line": 3, "column": 15 } - } - }, - { - "type": "Punctuator", - "value": ",", + }, "range": [ 53, 54 ], - "loc": { - "start": { - "line": 3, - "column": 15 - }, - "end": { - "line": 3, - "column": 16 - } - } + "value": "," }, { "type": "Identifier", - "value": "U", - "range": [ - 73, - 74 - ], "loc": { - "start": { - "line": 5, - "column": 2 - }, "end": { "line": 5, "column": 3 + }, + "start": { + "line": 5, + "column": 2 } - } + }, + "range": [ + 73, + 74 + ], + "value": "U" }, { "type": "Keyword", - "value": "extends", - "range": [ - 75, - 82 - ], "loc": { - "start": { - "line": 5, - "column": 4 - }, "end": { "line": 5, "column": 11 + }, + "start": { + "line": 5, + "column": 4 } - } + }, + "range": [ + 75, + 82 + ], + "value": "extends" }, { "type": "Identifier", - "value": "T", - "range": [ - 87, - 88 - ], "loc": { - "start": { - "line": 6, - "column": 4 - }, "end": { "line": 6, "column": 5 + }, + "start": { + "line": 6, + "column": 4 } - } + }, + "range": [ + 87, + 88 + ], + "value": "T" }, { "type": "Punctuator", @@ -2910,21 +2928,21 @@ }, { "type": "Identifier", - "value": "foo", - "range": [ - 218, - 221 - ], "loc": { - "start": { - "line": 14, - "column": 2 - }, "end": { "line": 14, "column": 5 + }, + "start": { + "line": 14, + "column": 2 } - } + }, + "range": [ + 218, + 221 + ], + "value": "foo" }, { "type": "VExpressionEnd", @@ -3002,21 +3020,21 @@ "comments": [ { "type": "Line", - "value": " Comments", - "range": [ - 59, - 70 - ], "loc": { - "start": { - "line": 4, - "column": 4 - }, "end": { "line": 4, "column": 15 + }, + "start": { + "line": 4, + "column": 4 } - } + }, + "range": [ + 59, + 70 + ], + "value": " Comments" } ], "errors": [] 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 index 7e5efdcf..8ccbd3bd 100644 --- 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 @@ -65,11 +65,6 @@ "type": "TSTypeParameter", "text": "T\n extends Foo", "children": [ - { - "type": "Identifier", - "text": "T", - "children": [] - }, { "type": "TSTypeReference", "text": "Foo", @@ -80,6 +75,11 @@ "children": [] } ] + }, + { + "type": "Identifier", + "text": "T", + "children": [] } ] }, @@ -87,11 +87,6 @@ "type": "TSTypeParameter", "text": "U extends\n T", "children": [ - { - "type": "Identifier", - "text": "U", - "children": [] - }, { "type": "TSTypeReference", "text": "T", @@ -102,6 +97,11 @@ "children": [] } ] + }, + { + "type": "Identifier", + "text": "U", + "children": [] } ] } 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 index 27212ef2..6ead8821 100644 --- 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 @@ -235,41 +235,26 @@ "params": [ { "type": "TSTypeParameter", - "name": { - "type": "Identifier", - "name": "T", - "range": [ - 36, - 37 - ], - "loc": { - "start": { - "line": 2, - "column": 2 - }, - "end": { - "line": 2, - "column": 3 - } - } - }, + "const": false, "constraint": { "type": "TSTypeReference", "typeName": { "type": "Identifier", + "decorators": [], "name": "Foo", + "optional": false, "range": [ 61, 64 ], "loc": { - "start": { - "line": 3, - "column": 12 - }, "end": { "line": 3, "column": 15 + }, + "start": { + "line": 3, + "column": 12 } } }, @@ -278,75 +263,59 @@ 64 ], "loc": { - "start": { - "line": 3, - "column": 12 - }, "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, - "const": false, "range": [ 36, 64 ], "loc": { - "start": { - "line": 2, - "column": 2 - }, "end": { "line": 3, "column": 15 + }, + "start": { + "line": 2, + "column": 2 } } }, { "type": "TSTypeParameter", - "name": { - "type": "Identifier", - "name": "U", - "range": [ - 84, - 85 - ], - "loc": { - "start": { - "line": 5, - "column": 2 - }, - "end": { - "line": 5, - "column": 3 - } - } - }, + "const": false, "constraint": { "type": "TSTypeReference", - "typeName": { - "type": "Identifier", - "name": "Record", - "range": [ - 116, - 122 - ], - "loc": { - "start": { - "line": 7, - "column": 4 - }, - "end": { - "line": 7, - "column": 10 - } - } - }, - "typeParameters": { + "typeArguments": { "type": "TSTypeParameterInstantiation", "range": [ 122, @@ -360,13 +329,13 @@ 132 ], "loc": { - "start": { - "line": 7, - "column": 14 - }, "end": { "line": 7, "column": 20 + }, + "start": { + "line": 7, + "column": 14 } } }, @@ -374,19 +343,21 @@ "type": "TSTypeReference", "typeName": { "type": "Identifier", + "decorators": [], "name": "T", + "optional": false, "range": [ 134, 135 ], "loc": { - "start": { - "line": 7, - "column": 22 - }, "end": { "line": 7, "column": 23 + }, + "start": { + "line": 7, + "column": 22 } } }, @@ -395,25 +366,45 @@ 135 ], "loc": { - "start": { - "line": 7, - "column": 22 - }, "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": 24 + "column": 10 + }, + "start": { + "line": 7, + "column": 4 } } }, @@ -422,31 +413,50 @@ 136 ], "loc": { - "start": { - "line": 7, - "column": 4 - }, "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, - "const": false, "range": [ 84, 136 ], "loc": { - "start": { - "line": 5, - "column": 2 - }, "end": { "line": 7, "column": 24 + }, + "start": { + "line": 5, + "column": 2 } } } @@ -460,19 +470,21 @@ { "id": { "type": "Identifier", + "decorators": [], "name": "Foo", + "optional": false, "range": [ 61, 64 ], "loc": { - "start": { - "line": 3, - "column": 12 - }, "end": { "line": 3, "column": 15 + }, + "start": { + "line": 3, + "column": 12 } } }, @@ -526,19 +538,21 @@ { "id": { "type": "Identifier", + "decorators": [], "name": "T", + "optional": false, "range": [ 36, 37 ], "loc": { - "start": { - "line": 2, - "column": 2 - }, "end": { "line": 2, "column": 3 + }, + "start": { + "line": 2, + "column": 2 } } }, @@ -547,19 +561,21 @@ { "id": { "type": "Identifier", + "decorators": [], "name": "U", + "optional": false, "range": [ 84, 85 ], "loc": { - "start": { - "line": 5, - "column": 2 - }, "end": { "line": 5, "column": 3 + }, + "start": { + "line": 5, + "column": 2 } } }, @@ -660,19 +676,21 @@ }, "expression": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 266, 269 ], "loc": { - "start": { - "line": 15, - "column": 2 - }, "end": { "line": 15, "column": 5 + }, + "start": { + "line": 15, + "column": 2 } } }, @@ -680,19 +698,21 @@ { "id": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 266, 269 ], "loc": { - "start": { - "line": 15, - "column": 2 - }, "end": { "line": 15, "column": 5 + }, + "start": { + "line": 15, + "column": 2 } } }, @@ -886,219 +906,219 @@ }, { "type": "Identifier", - "value": "T", - "range": [ - 36, - 37 - ], "loc": { - "start": { - "line": 2, - "column": 2 - }, "end": { "line": 2, "column": 3 + }, + "start": { + "line": 2, + "column": 2 } - } + }, + "range": [ + 36, + 37 + ], + "value": "T" }, { "type": "Keyword", - "value": "extends", + "loc": { + "end": { + "line": 3, + "column": 11 + }, + "start": { + "line": 3, + "column": 4 + } + }, "range": [ 53, 60 ], + "value": "extends" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 3, - "column": 4 + "column": 15 }, - "end": { + "start": { "line": 3, - "column": 11 + "column": 12 } - } - }, - { - "type": "Identifier", - "value": "Foo", + }, "range": [ 61, 64 ], + "value": "Foo" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 3, - "column": 12 + "column": 16 }, - "end": { + "start": { "line": 3, "column": 15 } - } - }, - { - "type": "Punctuator", - "value": ",", + }, "range": [ 64, 65 ], - "loc": { - "start": { - "line": 3, - "column": 15 - }, - "end": { - "line": 3, - "column": 16 - } - } + "value": "," }, { "type": "Identifier", - "value": "U", - "range": [ - 84, - 85 - ], "loc": { - "start": { - "line": 5, - "column": 2 - }, "end": { "line": 5, "column": 3 + }, + "start": { + "line": 5, + "column": 2 } - } + }, + "range": [ + 84, + 85 + ], + "value": "U" }, { "type": "Keyword", - "value": "extends", - "range": [ - 104, - 111 - ], "loc": { - "start": { - "line": 6, - "column": 4 - }, "end": { "line": 6, "column": 11 + }, + "start": { + "line": 6, + "column": 4 } - } + }, + "range": [ + 104, + 111 + ], + "value": "extends" }, { "type": "Identifier", - "value": "Record", + "loc": { + "end": { + "line": 7, + "column": 10 + }, + "start": { + "line": 7, + "column": 4 + } + }, "range": [ 116, 122 ], + "value": "Record" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 7, - "column": 4 + "column": 14 }, - "end": { + "start": { "line": 7, "column": 10 } - } - }, - { - "type": "Punctuator", - "value": "<", + }, "range": [ 122, 126 ], + "value": "<" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 7, - "column": 10 + "column": 20 }, - "end": { + "start": { "line": 7, "column": 14 } - } - }, - { - "type": "Identifier", - "value": "string", + }, "range": [ 126, 132 ], + "value": "string" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 7, - "column": 14 + "column": 21 }, - "end": { + "start": { "line": 7, "column": 20 } - } - }, - { - "type": "Punctuator", - "value": ",", + }, "range": [ 132, 133 ], + "value": "," + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 7, - "column": 20 + "column": 23 }, - "end": { + "start": { "line": 7, - "column": 21 + "column": 22 } - } - }, - { - "type": "Identifier", - "value": "T", + }, "range": [ 134, 135 ], + "value": "T" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 7, - "column": 22 + "column": 24 }, - "end": { + "start": { "line": 7, "column": 23 } - } - }, - { - "type": "Punctuator", - "value": ">", + }, "range": [ 135, 136 ], - "loc": { - "start": { - "line": 7, - "column": 23 - }, - "end": { - "line": 7, - "column": 24 - } - } + "value": ">" }, { "type": "Punctuator", @@ -1894,21 +1914,21 @@ }, { "type": "Identifier", - "value": "foo", - "range": [ - 266, - 269 - ], "loc": { - "start": { - "line": 15, - "column": 2 - }, "end": { "line": 15, "column": 5 + }, + "start": { + "line": 15, + "column": 2 } - } + }, + "range": [ + 266, + 269 + ], + "value": "foo" }, { "type": "VExpressionEnd", @@ -1986,57 +2006,57 @@ "comments": [ { "type": "Line", - "value": " extends", - "range": [ - 38, - 48 - ], "loc": { - "start": { - "line": 2, - "column": 4 - }, "end": { "line": 2, "column": 14 + }, + "start": { + "line": 2, + "column": 4 } - } + }, + "range": [ + 38, + 48 + ], + "value": " extends" }, { "type": "Line", - "value": " Comments", - "range": [ - 70, - 81 - ], "loc": { - "start": { - "line": 4, - "column": 4 - }, "end": { "line": 4, "column": 15 + }, + "start": { + "line": 4, + "column": 4 } - } + }, + "range": [ + 70, + 81 + ], + "value": " Comments" }, { "type": "Block", - "value": " extends ", - "range": [ - 86, - 99 - ], "loc": { - "start": { - "line": 5, - "column": 4 - }, "end": { "line": 5, "column": 17 + }, + "start": { + "line": 5, + "column": 4 } - } + }, + "range": [ + 86, + 99 + ], + "value": " extends " } ], "errors": [] @@ -2189,219 +2209,219 @@ }, { "type": "Identifier", - "value": "T", - "range": [ - 36, - 37 - ], "loc": { - "start": { - "line": 2, - "column": 2 - }, "end": { "line": 2, "column": 3 + }, + "start": { + "line": 2, + "column": 2 } - } + }, + "range": [ + 36, + 37 + ], + "value": "T" }, { "type": "Keyword", - "value": "extends", + "loc": { + "end": { + "line": 3, + "column": 11 + }, + "start": { + "line": 3, + "column": 4 + } + }, "range": [ 53, 60 ], + "value": "extends" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 3, - "column": 4 + "column": 15 }, - "end": { + "start": { "line": 3, - "column": 11 + "column": 12 } - } - }, - { - "type": "Identifier", - "value": "Foo", + }, "range": [ 61, 64 ], + "value": "Foo" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 3, - "column": 12 + "column": 16 }, - "end": { + "start": { "line": 3, "column": 15 } - } - }, - { - "type": "Punctuator", - "value": ",", + }, "range": [ 64, 65 ], - "loc": { - "start": { - "line": 3, - "column": 15 - }, - "end": { - "line": 3, - "column": 16 - } - } + "value": "," }, { "type": "Identifier", - "value": "U", - "range": [ - 84, - 85 - ], "loc": { - "start": { - "line": 5, - "column": 2 - }, "end": { "line": 5, "column": 3 + }, + "start": { + "line": 5, + "column": 2 } - } + }, + "range": [ + 84, + 85 + ], + "value": "U" }, { "type": "Keyword", - "value": "extends", - "range": [ - 104, - 111 - ], "loc": { - "start": { - "line": 6, - "column": 4 - }, "end": { "line": 6, "column": 11 + }, + "start": { + "line": 6, + "column": 4 } - } + }, + "range": [ + 104, + 111 + ], + "value": "extends" }, { "type": "Identifier", - "value": "Record", + "loc": { + "end": { + "line": 7, + "column": 10 + }, + "start": { + "line": 7, + "column": 4 + } + }, "range": [ 116, 122 ], + "value": "Record" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 7, - "column": 4 + "column": 14 }, - "end": { + "start": { "line": 7, "column": 10 } - } - }, - { - "type": "Punctuator", - "value": "<", + }, "range": [ 122, 126 ], + "value": "<" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 7, - "column": 10 + "column": 20 }, - "end": { + "start": { "line": 7, "column": 14 } - } - }, - { - "type": "Identifier", - "value": "string", + }, "range": [ 126, 132 ], + "value": "string" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 7, - "column": 14 + "column": 21 }, - "end": { + "start": { "line": 7, "column": 20 } - } - }, - { - "type": "Punctuator", - "value": ",", + }, "range": [ 132, 133 ], + "value": "," + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 7, - "column": 20 + "column": 23 }, - "end": { + "start": { "line": 7, - "column": 21 + "column": 22 } - } - }, - { - "type": "Identifier", - "value": "T", + }, "range": [ 134, 135 ], + "value": "T" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 7, - "column": 22 + "column": 24 }, - "end": { + "start": { "line": 7, "column": 23 } - } - }, - { - "type": "Punctuator", - "value": ">", + }, "range": [ 135, 136 ], - "loc": { - "start": { - "line": 7, - "column": 23 - }, - "end": { - "line": 7, - "column": 24 - } - } + "value": ">" }, { "type": "Punctuator", @@ -3197,21 +3217,21 @@ }, { "type": "Identifier", - "value": "foo", - "range": [ - 266, - 269 - ], "loc": { - "start": { - "line": 15, - "column": 2 - }, "end": { "line": 15, "column": 5 + }, + "start": { + "line": 15, + "column": 2 } - } + }, + "range": [ + 266, + 269 + ], + "value": "foo" }, { "type": "VExpressionEnd", @@ -3289,57 +3309,57 @@ "comments": [ { "type": "Line", - "value": " extends", - "range": [ - 38, - 48 - ], "loc": { - "start": { - "line": 2, - "column": 4 - }, "end": { "line": 2, "column": 14 + }, + "start": { + "line": 2, + "column": 4 } - } + }, + "range": [ + 38, + 48 + ], + "value": " extends" }, { "type": "Line", - "value": " Comments", - "range": [ - 70, - 81 - ], "loc": { - "start": { - "line": 4, - "column": 4 - }, "end": { "line": 4, "column": 15 + }, + "start": { + "line": 4, + "column": 4 } - } + }, + "range": [ + 70, + 81 + ], + "value": " Comments" }, { "type": "Block", - "value": " extends ", - "range": [ - 86, - 99 - ], "loc": { - "start": { - "line": 5, - "column": 4 - }, "end": { "line": 5, "column": 17 + }, + "start": { + "line": 5, + "column": 4 } - } + }, + "range": [ + 86, + 99 + ], + "value": " extends " } ], "errors": [] 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 index 4e69420d..eb531362 100644 --- 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 @@ -65,11 +65,6 @@ "type": "TSTypeParameter", "text": "T // extends\n extends Foo", "children": [ - { - "type": "Identifier", - "text": "T", - "children": [] - }, { "type": "TSTypeReference", "text": "Foo", @@ -80,6 +75,11 @@ "children": [] } ] + }, + { + "type": "Identifier", + "text": "T", + "children": [] } ] }, @@ -87,20 +87,10 @@ "type": "TSTypeParameter", "text": "U /* extends */\n extends\n Record<string, T>", "children": [ - { - "type": "Identifier", - "text": "U", - "children": [] - }, { "type": "TSTypeReference", "text": "Record<string, T>", "children": [ - { - "type": "Identifier", - "text": "Record", - "children": [] - }, { "type": "TSTypeParameterInstantiation", "text": "<string, T>", @@ -122,8 +112,18 @@ ] } ] + }, + { + "type": "Identifier", + "text": "Record", + "children": [] } ] + }, + { + "type": "Identifier", + "text": "U", + "children": [] } ] } 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 index e1fb2002..36290861 100644 --- 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 @@ -235,41 +235,26 @@ "params": [ { "type": "TSTypeParameter", - "name": { - "type": "Identifier", - "name": "T", - "range": [ - 36, - 37 - ], - "loc": { - "start": { - "line": 2, - "column": 2 - }, - "end": { - "line": 2, - "column": 3 - } - } - }, + "const": false, "constraint": { "type": "TSTypeReference", "typeName": { "type": "Identifier", + "decorators": [], "name": "Foo", + "optional": false, "range": [ 70, 73 ], "loc": { - "start": { - "line": 3, - "column": 20 - }, "end": { "line": 3, "column": 23 + }, + "start": { + "line": 3, + "column": 20 } } }, @@ -278,13 +263,13 @@ 73 ], "loc": { - "start": { - "line": 3, - "column": 20 - }, "end": { "line": 3, "column": 23 + }, + "start": { + "line": 3, + "column": 20 } } }, @@ -295,75 +280,59 @@ 82 ], "loc": { - "start": { - "line": 3, - "column": 26 - }, "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, - "const": false, "range": [ 36, 82 ], "loc": { - "start": { - "line": 2, - "column": 2 - }, "end": { "line": 3, "column": 32 + }, + "start": { + "line": 2, + "column": 2 } } }, { "type": "TSTypeParameter", - "name": { - "type": "Identifier", - "name": "U", - "range": [ - 102, - 103 - ], - "loc": { - "start": { - "line": 5, - "column": 2 - }, - "end": { - "line": 5, - "column": 3 - } - } - }, + "const": false, "constraint": { "type": "TSTypeReference", - "typeName": { - "type": "Identifier", - "name": "Record", - "range": [ - 134, - 140 - ], - "loc": { - "start": { - "line": 7, - "column": 4 - }, - "end": { - "line": 7, - "column": 10 - } - } - }, - "typeParameters": { + "typeArguments": { "type": "TSTypeParameterInstantiation", "range": [ 140, @@ -377,13 +346,13 @@ 171 ], "loc": { - "start": { - "line": 9, - "column": 6 - }, "end": { "line": 9, "column": 12 + }, + "start": { + "line": 9, + "column": 6 } } }, @@ -391,19 +360,21 @@ "type": "TSTypeReference", "typeName": { "type": "Identifier", + "decorators": [], "name": "T", + "optional": false, "range": [ 184, 185 ], "loc": { - "start": { - "line": 10, - "column": 6 - }, "end": { "line": 10, "column": 7 + }, + "start": { + "line": 10, + "column": 6 } } }, @@ -412,25 +383,45 @@ 185 ], "loc": { - "start": { - "line": 10, - "column": 6 - }, "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": 11, - "column": 5 + "line": 7, + "column": 10 + }, + "start": { + "line": 7, + "column": 4 } } }, @@ -439,37 +430,19 @@ 191 ], "loc": { - "start": { - "line": 7, - "column": 4 - }, "end": { "line": 11, "column": 5 + }, + "start": { + "line": 7, + "column": 4 } } }, "default": { "type": "TSTypeReference", - "typeName": { - "type": "Identifier", - "name": "Record", - "range": [ - 199, - 205 - ], - "loc": { - "start": { - "line": 12, - "column": 7 - }, - "end": { - "line": 12, - "column": 13 - } - } - }, - "typeParameters": { + "typeArguments": { "type": "TSTypeParameterInstantiation", "range": [ 205, @@ -483,13 +456,13 @@ 212 ], "loc": { - "start": { - "line": 12, - "column": 14 - }, "end": { "line": 12, "column": 20 + }, + "start": { + "line": 12, + "column": 14 } } }, @@ -500,25 +473,45 @@ 220 ], "loc": { - "start": { - "line": 12, - "column": 22 - }, "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": 32 + "column": 13 + }, + "start": { + "line": 12, + "column": 7 } } }, @@ -527,31 +520,50 @@ 224 ], "loc": { - "start": { - "line": 12, - "column": 7 - }, "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, - "const": false, "range": [ 102, 224 ], "loc": { - "start": { - "line": 5, - "column": 2 - }, "end": { "line": 12, "column": 32 + }, + "start": { + "line": 5, + "column": 2 } } } @@ -565,19 +577,21 @@ { "id": { "type": "Identifier", + "decorators": [], "name": "Foo", + "optional": false, "range": [ 70, 73 ], "loc": { - "start": { - "line": 3, - "column": 20 - }, "end": { "line": 3, "column": 23 + }, + "start": { + "line": 3, + "column": 20 } } }, @@ -631,19 +645,21 @@ { "id": { "type": "Identifier", + "decorators": [], "name": "T", + "optional": false, "range": [ 36, 37 ], "loc": { - "start": { - "line": 2, - "column": 2 - }, "end": { "line": 2, "column": 3 + }, + "start": { + "line": 2, + "column": 2 } } }, @@ -652,19 +668,21 @@ { "id": { "type": "Identifier", + "decorators": [], "name": "U", + "optional": false, "range": [ 102, 103 ], "loc": { - "start": { - "line": 5, - "column": 2 - }, "end": { "line": 5, "column": 3 + }, + "start": { + "line": 5, + "column": 2 } } }, @@ -765,19 +783,21 @@ }, "expression": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 354, 357 ], "loc": { - "start": { - "line": 20, - "column": 2 - }, "end": { "line": 20, "column": 5 + }, + "start": { + "line": 20, + "column": 2 } } }, @@ -785,19 +805,21 @@ { "id": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 354, 357 ], "loc": { - "start": { - "line": 20, - "column": 2 - }, "end": { "line": 20, "column": 5 + }, + "start": { + "line": 20, + "column": 2 } } }, @@ -991,381 +1013,381 @@ }, { "type": "Identifier", - "value": "T", - "range": [ - 36, - 37 - ], "loc": { - "start": { - "line": 2, - "column": 2 - }, "end": { "line": 2, "column": 3 + }, + "start": { + "line": 2, + "column": 2 } - } + }, + "range": [ + 36, + 37 + ], + "value": "T" }, { "type": "Keyword", - "value": "extends", + "loc": { + "end": { + "line": 3, + "column": 11 + }, + "start": { + "line": 3, + "column": 4 + } + }, "range": [ 54, 61 ], + "value": "extends" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 3, - "column": 4 + "column": 23 }, - "end": { + "start": { "line": 3, - "column": 11 + "column": 20 } - } - }, - { - "type": "Identifier", - "value": "Foo", + }, "range": [ 70, 73 ], + "value": "Foo" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 3, - "column": 20 + "column": 25 }, - "end": { + "start": { "line": 3, - "column": 23 + "column": 24 } - } - }, - { - "type": "Punctuator", - "value": "=", + }, "range": [ 74, 75 ], + "value": "=" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 3, - "column": 24 + "column": 32 }, - "end": { + "start": { "line": 3, - "column": 25 + "column": 26 } - } - }, - { - "type": "Identifier", - "value": "number", + }, "range": [ 76, 82 ], + "value": "number" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 3, - "column": 26 + "column": 33 }, - "end": { + "start": { "line": 3, "column": 32 } - } - }, - { - "type": "Punctuator", - "value": ",", + }, "range": [ 82, 83 ], - "loc": { - "start": { - "line": 3, - "column": 32 - }, - "end": { - "line": 3, - "column": 33 - } - } + "value": "," }, { "type": "Identifier", - "value": "U", - "range": [ - 102, - 103 - ], "loc": { - "start": { - "line": 5, - "column": 2 - }, "end": { "line": 5, "column": 3 + }, + "start": { + "line": 5, + "column": 2 } - } + }, + "range": [ + 102, + 103 + ], + "value": "U" }, { "type": "Keyword", - "value": "extends", - "range": [ - 122, - 129 - ], "loc": { - "start": { - "line": 6, - "column": 4 - }, "end": { "line": 6, "column": 11 + }, + "start": { + "line": 6, + "column": 4 } - } + }, + "range": [ + 122, + 129 + ], + "value": "extends" }, { "type": "Identifier", - "value": "Record", - "range": [ - 134, - 140 - ], "loc": { - "start": { - "line": 7, - "column": 4 - }, "end": { "line": 7, "column": 10 + }, + "start": { + "line": 7, + "column": 4 } - } + }, + "range": [ + 134, + 140 + ], + "value": "Record" }, { "type": "Punctuator", - "value": "<", - "range": [ - 140, - 144 - ], "loc": { - "start": { - "line": 7, - "column": 10 - }, "end": { "line": 7, "column": 14 + }, + "start": { + "line": 7, + "column": 10 } - } + }, + "range": [ + 140, + 144 + ], + "value": "<" }, { "type": "Identifier", - "value": "string", + "loc": { + "end": { + "line": 9, + "column": 12 + }, + "start": { + "line": 9, + "column": 6 + } + }, "range": [ 165, 171 ], + "value": "string" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 9, - "column": 6 + "column": 13 }, - "end": { + "start": { "line": 9, "column": 12 } - } - }, - { - "type": "Punctuator", - "value": ",", + }, "range": [ 171, 172 ], - "loc": { - "start": { - "line": 9, - "column": 12 - }, - "end": { - "line": 9, - "column": 13 - } - } + "value": "," }, { "type": "Identifier", - "value": "T", - "range": [ - 184, - 185 - ], "loc": { - "start": { - "line": 10, - "column": 6 - }, "end": { "line": 10, "column": 7 + }, + "start": { + "line": 10, + "column": 6 } - } + }, + "range": [ + 184, + 185 + ], + "value": "T" }, { "type": "Punctuator", - "value": ">", - "range": [ - 190, - 191 - ], "loc": { - "start": { - "line": 11, - "column": 4 - }, "end": { "line": 11, "column": 5 + }, + "start": { + "line": 11, + "column": 4 } - } + }, + "range": [ + 190, + 191 + ], + "value": ">" }, { "type": "Punctuator", - "value": "=", + "loc": { + "end": { + "line": 12, + "column": 6 + }, + "start": { + "line": 12, + "column": 5 + } + }, "range": [ 197, 198 ], + "value": "=" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 12, - "column": 5 + "column": 13 }, - "end": { + "start": { "line": 12, - "column": 6 + "column": 7 } - } - }, - { - "type": "Identifier", - "value": "Record", + }, "range": [ 199, 205 ], + "value": "Record" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 12, - "column": 7 + "column": 14 }, - "end": { + "start": { "line": 12, "column": 13 } - } - }, - { - "type": "Punctuator", - "value": "<", + }, "range": [ 205, 206 ], + "value": "<" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 12, - "column": 13 + "column": 20 }, - "end": { + "start": { "line": 12, "column": 14 } - } - }, - { - "type": "Identifier", - "value": "string", + }, "range": [ 206, 212 ], + "value": "string" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 12, - "column": 14 + "column": 21 }, - "end": { + "start": { "line": 12, "column": 20 } - } - }, - { - "type": "Punctuator", - "value": ",", + }, "range": [ 212, 213 ], + "value": "," + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 12, - "column": 20 + "column": 28 }, - "end": { + "start": { "line": 12, - "column": 21 + "column": 22 } - } - }, - { - "type": "Identifier", - "value": "number", + }, "range": [ 214, 220 ], + "value": "number" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 12, - "column": 22 + "column": 32 }, - "end": { + "start": { "line": 12, "column": 28 } - } - }, - { - "type": "Punctuator", - "value": ">", + }, "range": [ 220, 224 ], - "loc": { - "start": { - "line": 12, - "column": 28 - }, - "end": { - "line": 12, - "column": 32 - } - } + "value": ">" }, { "type": "Punctuator", @@ -2161,21 +2183,21 @@ }, { "type": "Identifier", - "value": "foo", - "range": [ - 354, - 357 - ], "loc": { - "start": { - "line": 20, - "column": 2 - }, "end": { "line": 20, "column": 5 + }, + "start": { + "line": 20, + "column": 2 } - } + }, + "range": [ + 354, + 357 + ], + "value": "foo" }, { "type": "VExpressionEnd", @@ -2253,111 +2275,111 @@ "comments": [ { "type": "Line", - "value": " Comments", - "range": [ - 38, - 49 - ], "loc": { - "start": { - "line": 2, - "column": 4 - }, "end": { "line": 2, "column": 15 + }, + "start": { + "line": 2, + "column": 4 } - } + }, + "range": [ + 38, + 49 + ], + "value": " Comments" }, { "type": "Block", - "value": " = ", - "range": [ - 62, - 69 - ], "loc": { - "start": { - "line": 3, - "column": 12 - }, "end": { "line": 3, "column": 19 + }, + "start": { + "line": 3, + "column": 12 } - } + }, + "range": [ + 62, + 69 + ], + "value": " = " }, { "type": "Line", - "value": " Comments", - "range": [ - 88, - 99 - ], "loc": { - "start": { - "line": 4, - "column": 4 - }, "end": { "line": 4, "column": 15 + }, + "start": { + "line": 4, + "column": 4 } - } + }, + "range": [ + 88, + 99 + ], + "value": " Comments" }, { "type": "Block", - "value": " extends ", - "range": [ - 104, - 117 - ], "loc": { - "start": { - "line": 5, - "column": 4 - }, "end": { "line": 5, "column": 17 + }, + "start": { + "line": 5, + "column": 4 } - } + }, + "range": [ + 104, + 117 + ], + "value": " extends " }, { "type": "Block", - "value": " = ", - "range": [ - 151, - 158 - ], "loc": { - "start": { - "line": 8, - "column": 6 - }, "end": { "line": 8, "column": 13 + }, + "start": { + "line": 8, + "column": 6 } - } + }, + "range": [ + 151, + 158 + ], + "value": " = " }, { "type": "Line", - "value": " =", - "range": [ - 173, - 177 - ], "loc": { - "start": { - "line": 9, - "column": 14 - }, "end": { "line": 9, "column": 18 + }, + "start": { + "line": 9, + "column": 14 } - } + }, + "range": [ + 173, + 177 + ], + "value": " =" } ], "errors": [] @@ -2510,381 +2532,381 @@ }, { "type": "Identifier", - "value": "T", - "range": [ - 36, - 37 - ], "loc": { - "start": { - "line": 2, - "column": 2 - }, "end": { "line": 2, "column": 3 + }, + "start": { + "line": 2, + "column": 2 } - } + }, + "range": [ + 36, + 37 + ], + "value": "T" }, { "type": "Keyword", - "value": "extends", + "loc": { + "end": { + "line": 3, + "column": 11 + }, + "start": { + "line": 3, + "column": 4 + } + }, "range": [ 54, 61 ], + "value": "extends" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 3, - "column": 4 + "column": 23 }, - "end": { + "start": { "line": 3, - "column": 11 + "column": 20 } - } - }, - { - "type": "Identifier", - "value": "Foo", + }, "range": [ 70, 73 ], + "value": "Foo" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 3, - "column": 20 + "column": 25 }, - "end": { + "start": { "line": 3, - "column": 23 + "column": 24 } - } - }, - { - "type": "Punctuator", - "value": "=", + }, "range": [ 74, 75 ], + "value": "=" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 3, - "column": 24 + "column": 32 }, - "end": { + "start": { "line": 3, - "column": 25 + "column": 26 } - } - }, - { - "type": "Identifier", - "value": "number", + }, "range": [ 76, 82 ], + "value": "number" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 3, - "column": 26 + "column": 33 }, - "end": { + "start": { "line": 3, "column": 32 } - } - }, - { - "type": "Punctuator", - "value": ",", + }, "range": [ 82, 83 ], - "loc": { - "start": { - "line": 3, - "column": 32 - }, - "end": { - "line": 3, - "column": 33 - } - } + "value": "," }, { "type": "Identifier", - "value": "U", - "range": [ - 102, - 103 - ], "loc": { - "start": { - "line": 5, - "column": 2 - }, "end": { "line": 5, "column": 3 + }, + "start": { + "line": 5, + "column": 2 } - } + }, + "range": [ + 102, + 103 + ], + "value": "U" }, { "type": "Keyword", - "value": "extends", - "range": [ - 122, - 129 - ], "loc": { - "start": { - "line": 6, - "column": 4 - }, "end": { "line": 6, "column": 11 + }, + "start": { + "line": 6, + "column": 4 } - } + }, + "range": [ + 122, + 129 + ], + "value": "extends" }, { "type": "Identifier", - "value": "Record", + "loc": { + "end": { + "line": 7, + "column": 10 + }, + "start": { + "line": 7, + "column": 4 + } + }, "range": [ 134, 140 ], + "value": "Record" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 7, - "column": 4 + "column": 14 }, - "end": { + "start": { "line": 7, "column": 10 } - } - }, - { - "type": "Punctuator", - "value": "<", + }, "range": [ 140, 144 ], - "loc": { - "start": { - "line": 7, - "column": 10 - }, - "end": { - "line": 7, - "column": 14 - } - } + "value": "<" }, { "type": "Identifier", - "value": "string", - "range": [ - 165, - 171 - ], "loc": { - "start": { - "line": 9, - "column": 6 - }, "end": { "line": 9, "column": 12 + }, + "start": { + "line": 9, + "column": 6 } - } + }, + "range": [ + 165, + 171 + ], + "value": "string" }, { "type": "Punctuator", - "value": ",", - "range": [ - 171, - 172 - ], "loc": { - "start": { - "line": 9, - "column": 12 - }, "end": { "line": 9, "column": 13 + }, + "start": { + "line": 9, + "column": 12 } - } - }, - { - "type": "Identifier", - "value": "T", + }, "range": [ - 184, - 185 + 171, + 172 ], + "value": "," + }, + { + "type": "Identifier", "loc": { - "start": { - "line": 10, - "column": 6 - }, "end": { "line": 10, "column": 7 + }, + "start": { + "line": 10, + "column": 6 } - } + }, + "range": [ + 184, + 185 + ], + "value": "T" }, { "type": "Punctuator", - "value": ">", - "range": [ - 190, - 191 - ], "loc": { - "start": { - "line": 11, - "column": 4 - }, "end": { "line": 11, "column": 5 + }, + "start": { + "line": 11, + "column": 4 } - } + }, + "range": [ + 190, + 191 + ], + "value": ">" }, { "type": "Punctuator", - "value": "=", + "loc": { + "end": { + "line": 12, + "column": 6 + }, + "start": { + "line": 12, + "column": 5 + } + }, "range": [ 197, 198 ], + "value": "=" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 12, - "column": 5 + "column": 13 }, - "end": { + "start": { "line": 12, - "column": 6 + "column": 7 } - } - }, - { - "type": "Identifier", - "value": "Record", + }, "range": [ 199, 205 ], + "value": "Record" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 12, - "column": 7 + "column": 14 }, - "end": { + "start": { "line": 12, "column": 13 } - } - }, - { - "type": "Punctuator", - "value": "<", + }, "range": [ 205, 206 ], + "value": "<" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 12, - "column": 13 + "column": 20 }, - "end": { + "start": { "line": 12, "column": 14 } - } - }, - { - "type": "Identifier", - "value": "string", + }, "range": [ 206, 212 ], + "value": "string" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 12, - "column": 14 + "column": 21 }, - "end": { + "start": { "line": 12, "column": 20 } - } - }, - { - "type": "Punctuator", - "value": ",", + }, "range": [ 212, 213 ], + "value": "," + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 12, - "column": 20 + "column": 28 }, - "end": { + "start": { "line": 12, - "column": 21 + "column": 22 } - } - }, - { - "type": "Identifier", - "value": "number", + }, "range": [ 214, 220 ], + "value": "number" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 12, - "column": 22 + "column": 32 }, - "end": { + "start": { "line": 12, "column": 28 } - } - }, - { - "type": "Punctuator", - "value": ">", + }, "range": [ 220, 224 ], - "loc": { - "start": { - "line": 12, - "column": 28 - }, - "end": { - "line": 12, - "column": 32 - } - } + "value": ">" }, { "type": "Punctuator", @@ -3680,21 +3702,21 @@ }, { "type": "Identifier", - "value": "foo", - "range": [ - 354, - 357 - ], "loc": { - "start": { - "line": 20, - "column": 2 - }, "end": { "line": 20, "column": 5 + }, + "start": { + "line": 20, + "column": 2 } - } + }, + "range": [ + 354, + 357 + ], + "value": "foo" }, { "type": "VExpressionEnd", @@ -3772,111 +3794,111 @@ "comments": [ { "type": "Line", - "value": " Comments", - "range": [ - 38, - 49 - ], "loc": { - "start": { - "line": 2, - "column": 4 - }, "end": { "line": 2, "column": 15 + }, + "start": { + "line": 2, + "column": 4 } - } + }, + "range": [ + 38, + 49 + ], + "value": " Comments" }, { "type": "Block", - "value": " = ", - "range": [ - 62, - 69 - ], "loc": { - "start": { - "line": 3, - "column": 12 - }, "end": { "line": 3, "column": 19 + }, + "start": { + "line": 3, + "column": 12 } - } + }, + "range": [ + 62, + 69 + ], + "value": " = " }, { "type": "Line", - "value": " Comments", - "range": [ - 88, - 99 - ], "loc": { - "start": { - "line": 4, - "column": 4 - }, "end": { "line": 4, "column": 15 + }, + "start": { + "line": 4, + "column": 4 } - } + }, + "range": [ + 88, + 99 + ], + "value": " Comments" }, { "type": "Block", - "value": " extends ", - "range": [ - 104, - 117 - ], "loc": { - "start": { - "line": 5, - "column": 4 - }, "end": { "line": 5, "column": 17 + }, + "start": { + "line": 5, + "column": 4 } - } + }, + "range": [ + 104, + 117 + ], + "value": " extends " }, { "type": "Block", - "value": " = ", - "range": [ - 151, - 158 - ], "loc": { - "start": { - "line": 8, - "column": 6 - }, "end": { "line": 8, "column": 13 + }, + "start": { + "line": 8, + "column": 6 } - } + }, + "range": [ + 151, + 158 + ], + "value": " = " }, { "type": "Line", - "value": " =", - "range": [ - 173, - 177 - ], "loc": { - "start": { - "line": 9, - "column": 14 - }, "end": { "line": 9, "column": 18 + }, + "start": { + "line": 9, + "column": 14 } - } + }, + "range": [ + 173, + 177 + ], + "value": " =" } ], "errors": [] 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 index 2147714f..ab3eb2d9 100644 --- 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 @@ -65,11 +65,6 @@ "type": "TSTypeParameter", "text": "T // Comments\n extends /* = */ Foo = number", "children": [ - { - "type": "Identifier", - "text": "T", - "children": [] - }, { "type": "TSTypeReference", "text": "Foo", @@ -85,6 +80,11 @@ "type": "TSNumberKeyword", "text": "number", "children": [] + }, + { + "type": "Identifier", + "text": "T", + "children": [] } ] }, @@ -92,20 +92,10 @@ "type": "TSTypeParameter", "text": "U /* extends */\n extends\n Record<\n /* = */\n string, // =\n T\n >\n = Record<string, number>", "children": [ - { - "type": "Identifier", - "text": "U", - "children": [] - }, { "type": "TSTypeReference", "text": "Record<\n /* = */\n string, // =\n T\n >", "children": [ - { - "type": "Identifier", - "text": "Record", - "children": [] - }, { "type": "TSTypeParameterInstantiation", "text": "<\n /* = */\n string, // =\n T\n >", @@ -127,6 +117,11 @@ ] } ] + }, + { + "type": "Identifier", + "text": "Record", + "children": [] } ] }, @@ -134,11 +129,6 @@ "type": "TSTypeReference", "text": "Record<string, number>", "children": [ - { - "type": "Identifier", - "text": "Record", - "children": [] - }, { "type": "TSTypeParameterInstantiation", "text": "<string, number>", @@ -154,8 +144,18 @@ "children": [] } ] + }, + { + "type": "Identifier", + "text": "Record", + "children": [] } ] + }, + { + "type": "Identifier", + "text": "U", + "children": [] } ] } 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 index c6cf8e44..15d9ad50 100644 --- 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 @@ -235,51 +235,20 @@ "params": [ { "type": "TSTypeParameter", - "name": { - "type": "Identifier", - "name": "T", - "range": [ - 36, - 37 - ], - "loc": { - "start": { - "line": 2, - "column": 2 - }, - "end": { - "line": 2, - "column": 3 - } - } - }, + "const": false, "constraint": { "type": "TSFunctionType", "params": [], - "range": [ - 46, - 58 - ], - "loc": { - "start": { - "line": 2, - "column": 12 - }, - "end": { - "line": 2, - "column": 24 - } - }, "returnType": { "type": "TSTypeAnnotation", "loc": { - "start": { - "line": 2, - "column": 15 - }, "end": { "line": 2, "column": 24 + }, + "start": { + "line": 2, + "column": 15 } }, "range": [ @@ -293,83 +262,85 @@ 58 ], "loc": { - "start": { - "line": 2, - "column": 18 - }, "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, - "const": false, "range": [ 36, 58 ], "loc": { - "start": { - "line": 2, - "column": 2 - }, "end": { "line": 2, "column": 24 + }, + "start": { + "line": 2, + "column": 2 } } }, { "type": "TSTypeParameter", - "name": { - "type": "Identifier", - "name": "U", - "range": [ - 62, - 63 - ], - "loc": { - "start": { - "line": 3, - "column": 2 - }, - "end": { - "line": 3, - "column": 3 - } - } - }, + "const": false, "constraint": { "type": "TSFunctionType", "params": [], - "range": [ - 73, - 85 - ], - "loc": { - "start": { - "line": 3, - "column": 13 - }, - "end": { - "line": 3, - "column": 25 - } - }, "returnType": { "type": "TSTypeAnnotation", "loc": { - "start": { - "line": 3, - "column": 16 - }, "end": { "line": 3, "column": 25 + }, + "start": { + "line": 3, + "column": 16 } }, "range": [ @@ -383,45 +354,45 @@ 85 ], "loc": { - "start": { - "line": 3, - "column": 19 - }, "end": { "line": 3, "column": 25 + }, + "start": { + "line": 3, + "column": 19 } } } - } - }, - "default": { - "type": "TSFunctionType", - "params": [], + }, "range": [ - 88, - 99 + 73, + 85 ], "loc": { - "start": { + "end": { "line": 3, - "column": 28 + "column": 25 }, - "end": { + "start": { "line": 3, - "column": 39 + "column": 13 } - }, + } + }, + "default": { + "type": "TSFunctionType", + "params": [], "returnType": { "type": "TSTypeAnnotation", "loc": { - "start": { - "line": 3, - "column": 31 - }, "end": { "line": 3, "column": 39 + }, + "start": { + "line": 3, + "column": 31 } }, "range": [ @@ -432,20 +403,20 @@ "type": "TSLiteralType", "literal": { "type": "Literal", - "value": "abc", "raw": "'abc'", + "value": "abc", "range": [ 94, 99 ], "loc": { - "start": { - "line": 3, - "column": 34 - }, "end": { "line": 3, "column": 39 + }, + "start": { + "line": 3, + "column": 34 } } }, @@ -454,33 +425,66 @@ 99 ], "loc": { - "start": { - "line": 3, - "column": 34 - }, "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, - "const": false, "range": [ 62, 99 ], "loc": { - "start": { - "line": 3, - "column": 2 - }, "end": { "line": 3, "column": 39 + }, + "start": { + "line": 3, + "column": 2 } } } @@ -536,19 +540,21 @@ { "id": { "type": "Identifier", + "decorators": [], "name": "T", + "optional": false, "range": [ 36, 37 ], "loc": { - "start": { - "line": 2, - "column": 2 - }, "end": { "line": 2, "column": 3 + }, + "start": { + "line": 2, + "column": 2 } } }, @@ -557,19 +563,21 @@ { "id": { "type": "Identifier", + "decorators": [], "name": "U", + "optional": false, "range": [ 62, 63 ], "loc": { - "start": { - "line": 3, - "column": 2 - }, "end": { "line": 3, "column": 3 + }, + "start": { + "line": 3, + "column": 2 } } }, @@ -670,75 +678,79 @@ }, "expression": { "type": "CallExpression", + "arguments": [], "callee": { "type": "MemberExpression", + "computed": false, "object": { "type": "Identifier", + "decorators": [], "name": "p", + "optional": false, "range": [ 165, 166 ], "loc": { - "start": { - "line": 9, - "column": 2 - }, "end": { "line": 9, "column": 3 + }, + "start": { + "line": 9, + "column": 2 } } }, + "optional": false, "property": { "type": "Identifier", + "decorators": [], "name": "t", + "optional": false, "range": [ 167, 168 ], "loc": { - "start": { - "line": 9, - "column": 4 - }, "end": { "line": 9, "column": 5 + }, + "start": { + "line": 9, + "column": 4 } } }, - "computed": false, - "optional": false, "range": [ 165, 168 ], "loc": { - "start": { - "line": 9, - "column": 2 - }, "end": { "line": 9, "column": 5 + }, + "start": { + "line": 9, + "column": 2 } } }, - "arguments": [], "optional": false, "range": [ 165, 170 ], "loc": { - "start": { - "line": 9, - "column": 2 - }, "end": { "line": 9, "column": 7 + }, + "start": { + "line": 9, + "column": 2 } } }, @@ -746,19 +758,21 @@ { "id": { "type": "Identifier", + "decorators": [], "name": "p", + "optional": false, "range": [ 165, 166 ], "loc": { - "start": { - "line": 9, - "column": 2 - }, "end": { "line": 9, "column": 3 + }, + "start": { + "line": 9, + "column": 2 } } }, @@ -804,75 +818,79 @@ }, "expression": { "type": "CallExpression", + "arguments": [], "callee": { "type": "MemberExpression", + "computed": false, "object": { "type": "Identifier", + "decorators": [], "name": "p", + "optional": false, "range": [ 175, 176 ], "loc": { - "start": { - "line": 10, - "column": 2 - }, "end": { "line": 10, "column": 3 + }, + "start": { + "line": 10, + "column": 2 } } }, + "optional": false, "property": { "type": "Identifier", + "decorators": [], "name": "u", + "optional": false, "range": [ 177, 178 ], "loc": { - "start": { - "line": 10, - "column": 4 - }, "end": { "line": 10, "column": 5 + }, + "start": { + "line": 10, + "column": 4 } } }, - "computed": false, - "optional": false, "range": [ 175, 178 ], "loc": { - "start": { - "line": 10, - "column": 2 - }, "end": { "line": 10, "column": 5 + }, + "start": { + "line": 10, + "column": 2 } } }, - "arguments": [], "optional": false, "range": [ 175, 180 ], "loc": { - "start": { - "line": 10, - "column": 2 - }, "end": { "line": 10, "column": 7 + }, + "start": { + "line": 10, + "column": 2 } } }, @@ -880,19 +898,21 @@ { "id": { "type": "Identifier", + "decorators": [], "name": "p", + "optional": false, "range": [ 175, 176 ], "loc": { - "start": { - "line": 10, - "column": 2 - }, "end": { "line": 10, "column": 3 + }, + "start": { + "line": 10, + "column": 2 } } }, @@ -1086,327 +1106,327 @@ }, { "type": "Identifier", - "value": "T", + "loc": { + "end": { + "line": 2, + "column": 3 + }, + "start": { + "line": 2, + "column": 2 + } + }, "range": [ 36, 37 ], + "value": "T" + }, + { + "type": "Keyword", "loc": { - "start": { + "end": { "line": 2, - "column": 2 + "column": 11 }, - "end": { + "start": { "line": 2, - "column": 3 + "column": 4 } - } - }, - { - "type": "Keyword", - "value": "extends", + }, "range": [ 38, 45 ], + "value": "extends" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 4 + "column": 13 }, - "end": { + "start": { "line": 2, - "column": 11 + "column": 12 } - } - }, - { - "type": "Punctuator", - "value": "(", + }, "range": [ 46, 47 ], + "value": "(" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 12 + "column": 14 }, - "end": { + "start": { "line": 2, "column": 13 } - } - }, - { - "type": "Punctuator", - "value": ")", + }, "range": [ 47, 48 ], + "value": ")" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 13 + "column": 17 }, - "end": { + "start": { "line": 2, - "column": 14 + "column": 15 } - } - }, - { - "type": "Punctuator", - "value": "=>", + }, "range": [ 49, 51 ], + "value": "=>" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 2, - "column": 15 + "column": 24 }, - "end": { + "start": { "line": 2, - "column": 17 + "column": 18 } - } - }, - { - "type": "Identifier", - "value": "string", + }, "range": [ 52, 58 ], + "value": "string" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 18 + "column": 25 }, - "end": { + "start": { "line": 2, "column": 24 } - } - }, - { - "type": "Punctuator", - "value": ",", + }, "range": [ 58, 59 ], - "loc": { - "start": { - "line": 2, - "column": 24 - }, - "end": { - "line": 2, - "column": 25 - } - } + "value": "," }, { "type": "Identifier", - "value": "U", + "loc": { + "end": { + "line": 3, + "column": 3 + }, + "start": { + "line": 3, + "column": 2 + } + }, "range": [ 62, 63 ], + "value": "U" + }, + { + "type": "Keyword", "loc": { - "start": { + "end": { "line": 3, - "column": 2 + "column": 12 }, - "end": { + "start": { "line": 3, - "column": 3 + "column": 5 } - } - }, - { - "type": "Keyword", - "value": "extends", + }, "range": [ 65, 72 ], + "value": "extends" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 3, - "column": 5 + "column": 14 }, - "end": { + "start": { "line": 3, - "column": 12 + "column": 13 } - } - }, - { - "type": "Punctuator", - "value": "(", + }, "range": [ 73, 74 ], + "value": "(" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 3, - "column": 13 + "column": 15 }, - "end": { + "start": { "line": 3, "column": 14 } - } - }, - { - "type": "Punctuator", - "value": ")", + }, "range": [ 74, 75 ], + "value": ")" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 3, - "column": 14 + "column": 18 }, - "end": { + "start": { "line": 3, - "column": 15 + "column": 16 } - } - }, - { - "type": "Punctuator", - "value": "=>", + }, "range": [ 76, 78 ], + "value": "=>" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 3, - "column": 16 + "column": 25 }, - "end": { + "start": { "line": 3, - "column": 18 + "column": 19 } - } - }, - { - "type": "Identifier", - "value": "string", + }, "range": [ 79, 85 ], + "value": "string" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 3, - "column": 19 + "column": 27 }, - "end": { + "start": { "line": 3, - "column": 25 + "column": 26 } - } - }, - { - "type": "Punctuator", - "value": "=", + }, "range": [ 86, 87 ], + "value": "=" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 3, - "column": 26 + "column": 29 }, - "end": { + "start": { "line": 3, - "column": 27 + "column": 28 } - } - }, - { - "type": "Punctuator", - "value": "(", + }, "range": [ 88, 89 ], + "value": "(" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 3, - "column": 28 + "column": 30 }, - "end": { + "start": { "line": 3, "column": 29 } - } - }, - { - "type": "Punctuator", - "value": ")", + }, "range": [ 89, 90 ], + "value": ")" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 3, - "column": 29 + "column": 33 }, - "end": { + "start": { "line": 3, - "column": 30 + "column": 31 } - } - }, - { - "type": "Punctuator", - "value": "=>", + }, "range": [ 91, 93 ], + "value": "=>" + }, + { + "type": "String", "loc": { - "start": { + "end": { "line": 3, - "column": 31 + "column": 39 }, - "end": { + "start": { "line": 3, - "column": 33 + "column": 34 } - } - }, - { - "type": "String", - "value": "'abc'", + }, "range": [ 94, 99 ], - "loc": { - "start": { - "line": 3, - "column": 34 - }, - "end": { - "line": 3, - "column": 39 - } - } + "value": "'abc'" }, { "type": "Punctuator", @@ -1842,93 +1862,93 @@ }, { "type": "Identifier", - "value": "p", + "loc": { + "end": { + "line": 9, + "column": 3 + }, + "start": { + "line": 9, + "column": 2 + } + }, "range": [ 165, 166 ], + "value": "p" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 9, - "column": 2 + "column": 4 }, - "end": { + "start": { "line": 9, "column": 3 } - } - }, - { - "type": "Punctuator", - "value": ".", + }, "range": [ 166, 167 ], + "value": "." + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 9, - "column": 3 + "column": 5 }, - "end": { + "start": { "line": 9, "column": 4 } - } - }, - { - "type": "Identifier", - "value": "t", + }, "range": [ 167, 168 ], + "value": "t" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 9, - "column": 4 + "column": 6 }, - "end": { + "start": { "line": 9, "column": 5 } - } - }, - { - "type": "Punctuator", - "value": "(", + }, "range": [ 168, 169 ], + "value": "(" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 9, - "column": 5 + "column": 7 }, - "end": { + "start": { "line": 9, "column": 6 } - } - }, - { - "type": "Punctuator", - "value": ")", + }, "range": [ 169, 170 ], - "loc": { - "start": { - "line": 9, - "column": 6 - }, - "end": { - "line": 9, - "column": 7 - } - } + "value": ")" }, { "type": "VExpressionEnd", @@ -1986,93 +2006,93 @@ }, { "type": "Identifier", - "value": "p", + "loc": { + "end": { + "line": 10, + "column": 3 + }, + "start": { + "line": 10, + "column": 2 + } + }, "range": [ 175, 176 ], + "value": "p" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 10, - "column": 2 + "column": 4 }, - "end": { + "start": { "line": 10, "column": 3 } - } - }, - { - "type": "Punctuator", - "value": ".", + }, "range": [ 176, 177 ], + "value": "." + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 10, - "column": 3 + "column": 5 }, - "end": { + "start": { "line": 10, "column": 4 } - } - }, - { - "type": "Identifier", - "value": "u", + }, "range": [ 177, 178 ], + "value": "u" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 10, - "column": 4 + "column": 6 }, - "end": { + "start": { "line": 10, "column": 5 } - } - }, - { - "type": "Punctuator", - "value": "(", + }, "range": [ 178, 179 ], + "value": "(" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 10, - "column": 5 + "column": 7 }, - "end": { + "start": { "line": 10, "column": 6 } - } - }, - { - "type": "Punctuator", - "value": ")", + }, "range": [ 179, 180 ], - "loc": { - "start": { - "line": 10, - "column": 6 - }, - "end": { - "line": 10, - "column": 7 - } - } + "value": ")" }, { "type": "VExpressionEnd", @@ -2298,327 +2318,327 @@ }, { "type": "Identifier", - "value": "T", + "loc": { + "end": { + "line": 2, + "column": 3 + }, + "start": { + "line": 2, + "column": 2 + } + }, "range": [ 36, 37 ], + "value": "T" + }, + { + "type": "Keyword", "loc": { - "start": { + "end": { "line": 2, - "column": 2 + "column": 11 }, - "end": { + "start": { "line": 2, - "column": 3 + "column": 4 } - } - }, - { - "type": "Keyword", - "value": "extends", + }, "range": [ 38, 45 ], + "value": "extends" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 4 + "column": 13 }, - "end": { + "start": { "line": 2, - "column": 11 + "column": 12 } - } - }, - { - "type": "Punctuator", - "value": "(", + }, "range": [ 46, 47 ], + "value": "(" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 12 + "column": 14 }, - "end": { + "start": { "line": 2, "column": 13 } - } - }, - { - "type": "Punctuator", - "value": ")", + }, "range": [ 47, 48 ], + "value": ")" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 13 + "column": 17 }, - "end": { + "start": { "line": 2, - "column": 14 + "column": 15 } - } - }, - { - "type": "Punctuator", - "value": "=>", + }, "range": [ 49, 51 ], + "value": "=>" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 2, - "column": 15 + "column": 24 }, - "end": { + "start": { "line": 2, - "column": 17 + "column": 18 } - } - }, - { - "type": "Identifier", - "value": "string", + }, "range": [ 52, 58 ], + "value": "string" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 18 + "column": 25 }, - "end": { + "start": { "line": 2, "column": 24 } - } - }, - { - "type": "Punctuator", - "value": ",", + }, "range": [ 58, 59 ], - "loc": { - "start": { - "line": 2, - "column": 24 - }, - "end": { - "line": 2, - "column": 25 - } - } + "value": "," }, { "type": "Identifier", - "value": "U", + "loc": { + "end": { + "line": 3, + "column": 3 + }, + "start": { + "line": 3, + "column": 2 + } + }, "range": [ 62, 63 ], + "value": "U" + }, + { + "type": "Keyword", "loc": { - "start": { + "end": { "line": 3, - "column": 2 + "column": 12 }, - "end": { + "start": { "line": 3, - "column": 3 + "column": 5 } - } - }, - { - "type": "Keyword", - "value": "extends", + }, "range": [ 65, 72 ], + "value": "extends" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 3, - "column": 5 + "column": 14 }, - "end": { + "start": { "line": 3, - "column": 12 + "column": 13 } - } - }, - { - "type": "Punctuator", - "value": "(", + }, "range": [ 73, 74 ], + "value": "(" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 3, - "column": 13 + "column": 15 }, - "end": { + "start": { "line": 3, "column": 14 } - } - }, - { - "type": "Punctuator", - "value": ")", + }, "range": [ 74, 75 ], + "value": ")" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 3, - "column": 14 + "column": 18 }, - "end": { + "start": { "line": 3, - "column": 15 + "column": 16 } - } - }, - { - "type": "Punctuator", - "value": "=>", + }, "range": [ 76, 78 ], + "value": "=>" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 3, - "column": 16 + "column": 25 }, - "end": { + "start": { "line": 3, - "column": 18 + "column": 19 } - } - }, - { - "type": "Identifier", - "value": "string", + }, "range": [ 79, 85 ], + "value": "string" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 3, - "column": 19 + "column": 27 }, - "end": { + "start": { "line": 3, - "column": 25 + "column": 26 } - } - }, - { - "type": "Punctuator", - "value": "=", + }, "range": [ 86, 87 ], + "value": "=" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 3, - "column": 26 + "column": 29 }, - "end": { + "start": { "line": 3, - "column": 27 + "column": 28 } - } - }, - { - "type": "Punctuator", - "value": "(", + }, "range": [ 88, 89 ], + "value": "(" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 3, - "column": 28 + "column": 30 }, - "end": { + "start": { "line": 3, "column": 29 } - } - }, - { - "type": "Punctuator", - "value": ")", + }, "range": [ 89, 90 ], + "value": ")" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 3, - "column": 29 + "column": 33 }, - "end": { + "start": { "line": 3, - "column": 30 + "column": 31 } - } - }, - { - "type": "Punctuator", - "value": "=>", + }, "range": [ 91, 93 ], + "value": "=>" + }, + { + "type": "String", "loc": { - "start": { + "end": { "line": 3, - "column": 31 + "column": 39 }, - "end": { + "start": { "line": 3, - "column": 33 + "column": 34 } - } - }, - { - "type": "String", - "value": "'abc'", + }, "range": [ 94, 99 ], - "loc": { - "start": { - "line": 3, - "column": 34 - }, - "end": { - "line": 3, - "column": 39 - } - } + "value": "'abc'" }, { "type": "Punctuator", @@ -3054,93 +3074,93 @@ }, { "type": "Identifier", - "value": "p", + "loc": { + "end": { + "line": 9, + "column": 3 + }, + "start": { + "line": 9, + "column": 2 + } + }, "range": [ 165, 166 ], + "value": "p" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 9, - "column": 2 + "column": 4 }, - "end": { + "start": { "line": 9, "column": 3 } - } - }, - { - "type": "Punctuator", - "value": ".", + }, "range": [ 166, 167 ], + "value": "." + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 9, - "column": 3 + "column": 5 }, - "end": { + "start": { "line": 9, "column": 4 } - } - }, - { - "type": "Identifier", - "value": "t", + }, "range": [ 167, 168 ], + "value": "t" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 9, - "column": 4 + "column": 6 }, - "end": { + "start": { "line": 9, "column": 5 } - } - }, - { - "type": "Punctuator", - "value": "(", + }, "range": [ 168, 169 ], + "value": "(" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 9, - "column": 5 + "column": 7 }, - "end": { + "start": { "line": 9, "column": 6 } - } - }, - { - "type": "Punctuator", - "value": ")", + }, "range": [ 169, 170 ], - "loc": { - "start": { - "line": 9, - "column": 6 - }, - "end": { - "line": 9, - "column": 7 - } - } + "value": ")" }, { "type": "VExpressionEnd", @@ -3198,93 +3218,93 @@ }, { "type": "Identifier", - "value": "p", + "loc": { + "end": { + "line": 10, + "column": 3 + }, + "start": { + "line": 10, + "column": 2 + } + }, "range": [ 175, 176 ], + "value": "p" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 10, - "column": 2 + "column": 4 }, - "end": { + "start": { "line": 10, "column": 3 } - } - }, - { - "type": "Punctuator", - "value": ".", + }, "range": [ 176, 177 ], + "value": "." + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 10, - "column": 3 + "column": 5 }, - "end": { + "start": { "line": 10, "column": 4 } - } - }, - { - "type": "Identifier", - "value": "u", + }, "range": [ 177, 178 ], + "value": "u" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 10, - "column": 4 + "column": 6 }, - "end": { + "start": { "line": 10, "column": 5 } - } - }, - { - "type": "Punctuator", - "value": "(", + }, "range": [ 178, 179 ], + "value": "(" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 10, - "column": 5 + "column": 7 }, - "end": { + "start": { "line": 10, "column": 6 } - } - }, - { - "type": "Punctuator", - "value": ")", + }, "range": [ 179, 180 ], - "loc": { - "start": { - "line": 10, - "column": 6 - }, - "end": { - "line": 10, - "column": 7 - } - } + "value": ")" }, { "type": "VExpressionEnd", 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 index 8a3067f7..64d30e2d 100644 --- 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 @@ -65,11 +65,6 @@ "type": "TSTypeParameter", "text": "T extends () => string", "children": [ - { - "type": "Identifier", - "text": "T", - "children": [] - }, { "type": "TSFunctionType", "text": "() => string", @@ -86,6 +81,11 @@ ] } ] + }, + { + "type": "Identifier", + "text": "T", + "children": [] } ] }, @@ -93,11 +93,6 @@ "type": "TSTypeParameter", "text": "U extends () => string = () => 'abc'", "children": [ - { - "type": "Identifier", - "text": "U", - "children": [] - }, { "type": "TSFunctionType", "text": "() => string", @@ -137,6 +132,11 @@ ] } ] + }, + { + "type": "Identifier", + "text": "U", + "children": [] } ] } diff --git a/test/fixtures/eslint b/test/fixtures/eslint deleted file mode 160000 index 8bb52766..00000000 --- a/test/fixtures/eslint +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 8bb527660ffddc122204fb5bf59076687aaa78b8 diff --git a/test/index.js b/test/index.js index 8f8c9a19..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,87 +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"]) - - assert.deepStrictEqual(report[0].messages, []) - assert.deepStrictEqual(report[1].messages, []) + 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: { - env: { es6: true, node: true }, - parser: PARSER_PATH, + 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"] }, }, - 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 + + 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: { - env: { es6: true, node: true }, - parser: PARSER_PATH, + 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"] }, }, - useEslintrc: false, - }) - const report = await cli.lintFiles(["typed.ts", "typed.tsx"]) - - assert.deepStrictEqual(report[0].messages, []) - assert.deepStrictEqual(report[1].messages, []) + 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", () => { @@ -356,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 @@ -372,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"])) @@ -422,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 @@ -500,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 @@ -517,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", @@ -684,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`. @@ -704,22 +763,25 @@ describe("Basic tests", () => { it("should work even if AST object was reused.", () => { const code = "<template><div/></template>" 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) @@ -732,22 +794,28 @@ describe("Basic tests", () => { it("should work even if used sibling selector.", () => { const code = "<template><div/><div/></template>" 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) @@ -763,12 +831,11 @@ describe("Basic tests", () => { const code = '<script>"script" /* </script><script setup>/**/</script>' 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) @@ -780,15 +847,14 @@ describe("Basic tests", () => { it("should notify parsing error #2", () => { const code = "<script>var a = `</script><script setup>`</script>" 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) @@ -800,12 +866,11 @@ describe("Basic tests", () => { it("should notify parsing error #3", () => { const code = '<script>var a = "</script><script setup>"</script>' 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) @@ -818,15 +883,14 @@ describe("Basic tests", () => { const code = "<script>var a = 1, b = 2;</script><script setup>c = a + b</script>" 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) @@ -834,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 index 1f230e95..88e9c501 100644 --- a/test/integrations.js +++ b/test/integrations.js @@ -6,7 +6,6 @@ const assert = require("assert") const path = require("path") const fs = require("fs-extra") const cp = require("child_process") -const semver = require("semver") const eslintCompat = require("./lib/eslint-compat") //------------------------------------------------------------------------------ @@ -20,9 +19,6 @@ const FIXTURE_DIR = path.join(__dirname, "fixtures/integrations") //------------------------------------------------------------------------------ describe("Integration tests", () => { - if (!semver.gte(process.version, "14.0.0")) { - return - } for (const target of fs.readdirSync(FIXTURE_DIR)) { it(target, async () => { let ESLint = eslintCompat(require("eslint")).ESLint @@ -32,11 +28,13 @@ describe("Integration tests", () => { process.chdir(path.join(FIXTURE_DIR, target)) cp.execSync("npm i", { stdio: "inherit" }) ESLint = eslintCompat( - require(path.join( - FIXTURE_DIR, - target, - "node_modules/eslint", - )), + require( + path.join( + FIXTURE_DIR, + target, + "node_modules/eslint", + ), + ), ).ESLint } finally { process.chdir(originalCwd) @@ -94,8 +92,8 @@ describe("Integration tests", () => { a.filePath < b.filePath ? -1 : a.filePath < b.filePath - ? 1 - : 0, + ? 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<eslint.ESLint['lintText']>} params * @returns {ReturnType<eslint.ESLint['lintText']>} */ - // 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<eslint.ESLint['lintFiles']>} params * @returns {ReturnType<eslint.ESLint['lintFiles']>} */ - // 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<eslint.ESLint['outputFixes']>} params * @returns {ReturnType<eslint.ESLint['outputFixes']>} */ - // 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( + `<template> + <div v-bind:class="{}"> + <template v-for="item in items"> + {{ 'str' }} + <button v-on:click="handler()"></button> + </template> + <MyComponent> + <template v-slot="{a}"> + <div v-if="a">A</div> + </template> + </MyComponent> + </div> + </template> + <script> + export default {} + </script> + `, + { + 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 <script setup>.", () => { + let projectCount = 0 + parseForESLint( + `<script setup> + let items = ["foo"] + </script> + <template> + <div v-bind:class="{}"> + <template v-for="item in items"> + {{ 'str' }} + <button v-on:click="handler()"></button> + </template> + <MyComponent> + <template v-slot="{a}"> + <div v-if="a">A</div> + </template> + </MyComponent> + </div> + </template> + <style scoped> + .a { + color: v-bind(color) + } + </style> + `, + { + 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 <script setup> with <script>.", () => { + let projectCount = 0 + parseForESLint( + `<script> + import { ref } from 'vue' + </script> + <script setup> + let items = ref(["foo"]) + </script> + <template> + <div v-bind:class="{}"> + <template v-for="item in items"> + {{ 'str' }} + <button v-on:click="handler()"></button> + </template> + <MyComponent> + <template v-slot="{a}"> + <div v-if="a">A</div> + </template> + </MyComponent> + </div> + </template> + `, + { + 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 '<script>'.", () => { const code = `<template>Hello</template> <script>This is syntax error</script>` 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 <script setup> without sourceType.", () => { + it("Fail in <script setup> with sourceType: script.", () => { const code = `<template>Hello</template> <script setup>import Foo from './foo'</script>` 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 index 9373502d..8ea0b760 100644 --- a/test/test-utils.js +++ b/test/test-utils.js @@ -68,7 +68,7 @@ function scopeToJSON(scopeManager) { reference.resolved.defs[0] && reference.resolved.defs[0].name, ), - init: reference.init || null, + init: reference.init ?? null, vueUsedInTemplate: reference.vueUsedInTemplate ? reference.vueUsedInTemplate : undefined, @@ -105,9 +105,9 @@ function scopeToJSON(scopeManager) { * Analyze scope */ function analyze(ast, parserOptions) { - const ecmaVersion = parserOptions.ecmaVersion || 2017 - const ecmaFeatures = parserOptions.ecmaFeatures || {} - const sourceType = parserOptions.sourceType || "script" + const ecmaVersion = parserOptions.ecmaVersion ?? 2022 + const ecmaFeatures = parserOptions.ecmaFeatures ?? {} + const sourceType = parserOptions.sourceType ?? "script" const result = escope.analyze(ast, { ignoreEval: true, nodejsScope: false, diff --git a/test/tokens.js b/test/tokens.js index 09cc4a2c..51a68c27 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() }) diff --git a/test/variables-references.js b/test/variables-references.js index 8a43d0a3..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 @@ -366,10 +339,7 @@ describe("Variables of v-for and references of v-bind same-name shorthand", () = let vBindReferences = 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 @@ -395,10 +365,7 @@ describe("Variables of v-for and references of v-bind same-name shorthand with k let vBindReferences = 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 diff --git a/tsconfig.json b/tsconfig.json index e4397962..e4cbfcc2 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,41 +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", - - "skipLibCheck": true, + "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/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