diff --git a/.circleci/config.yml b/.circleci/config.yml index d9b4f0204..cd2a71931 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -44,7 +44,7 @@ jobs: - run: name: Install eslint@6 command: | - npm install --save-exact eslint@6.8.0 + npm install --save-exact eslint@6.8.0 @typescript-eslint/parser@5 - run: name: Install dependencies command: npm install @@ -62,7 +62,7 @@ jobs: - run: name: Install eslint@7 command: | - npm install eslint@7 + npm install eslint@7 @typescript-eslint/parser@5 - run: name: Install dependencies command: npm install @@ -88,9 +88,23 @@ jobs: name: Test command: npm test node-v14: - <<: *node-base docker: - image: node:14 + steps: + - run: + name: Versions + command: npm version + - checkout + - run: + name: Install @typescript-eslint/parser@5 + command: | + npm install @typescript-eslint/parser@5 --save-exact + - run: + name: Install dependencies + command: npm install + - run: + name: Test + command: npm test node-v16: <<: *node-base docker: diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 910d33c70..afb8b9ad4 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -17,8 +17,6 @@ jobs: uses: actions/checkout@v3 - name: Install Node.js uses: actions/setup-node@v3 - with: - node-version: 16 - name: Install Packages run: npm install --legacy-peer-deps - name: Lint @@ -28,7 +26,7 @@ jobs: name: Test strategy: matrix: - node: [17, 18] + node: [17, 18, 20] os: [ubuntu-latest] runs-on: ${{ matrix.os }} @@ -43,3 +41,20 @@ jobs: run: npm install --legacy-peer-deps - name: Test run: npm test + + test-for-ts-eslint-v5: + name: Test + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Install Node.js v${{ matrix.node }} + uses: actions/setup-node@v3 + with: + node-version: 18 + - name: Install Packages + run: npm install --legacy-peer-deps + - name: Install typescript-eslint v5 + run: npm install -D @typescript-eslint/parser + - name: Test + run: npm test diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index 5b2d65516..baa74d471 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -1,4 +1,6 @@ +// @ts-expect-error -- Cannot change `module` option import type { DefaultTheme } from 'vitepress' +// @ts-expect-error -- Cannot change `module` option import { defineConfig } from 'vitepress' import { BUNDLED_LANGUAGES } from 'shiki' import path from 'path' diff --git a/docs/.vitepress/theme/index.ts b/docs/.vitepress/theme/index.ts index 8afcf4054..757e63cab 100644 --- a/docs/.vitepress/theme/index.ts +++ b/docs/.vitepress/theme/index.ts @@ -9,7 +9,9 @@ if (typeof window !== 'undefined') { } } } +// @ts-expect-error -- Cannot change `module` option import type { Theme } from 'vitepress' +// @ts-expect-error -- Cannot change `module` option import DefaultTheme from 'vitepress/theme' // @ts-expect-error -- ignore import Layout from './Layout.vue' diff --git a/docs/.vitepress/vite-plugin.ts b/docs/.vitepress/vite-plugin.ts index 2a044ced1..4b5b2a619 100644 --- a/docs/.vitepress/vite-plugin.ts +++ b/docs/.vitepress/vite-plugin.ts @@ -1,3 +1,4 @@ +// @ts-expect-error -- Cannot change `module` option import type { UserConfig } from 'vitepress' import path from 'path' import { fileURLToPath } from 'url' diff --git a/lib/utils/indent-ts.js b/lib/utils/indent-ts.js index 5ab3df993..c6f146f66 100644 --- a/lib/utils/indent-ts.js +++ b/lib/utils/indent-ts.js @@ -1168,18 +1168,24 @@ function defineVisitor({ isOpeningParenToken ) setOffset(leftParenToken, 1, firstToken) + const argument = + node.argument || + /** @type {any} typescript-eslint v5 */ (node).parameter const rightParenToken = tokenStore.getTokenAfter( - node.parameter, + argument, isClosingParenToken ) - processNodeList([node.parameter], leftParenToken, rightParenToken, 1) + processNodeList([argument], leftParenToken, rightParenToken, 1) if (node.qualifier) { const dotToken = tokenStore.getTokenBefore(node.qualifier) const propertyToken = tokenStore.getTokenAfter(dotToken) setOffset([dotToken, propertyToken], 1, firstToken) } - if (node.typeParameters) { - setOffset(tokenStore.getFirstToken(node.typeParameters), 1, firstToken) + const typeArguments = + node.typeArguments || + /** @type {any} typescript-eslint v5 */ (node).typeParameters + if (typeArguments) { + setOffset(tokenStore.getFirstToken(typeArguments), 1, firstToken) } }, TSParameterProperty(node) { diff --git a/package.json b/package.json index d23aca8c7..a13f8f854 100644 --- a/package.json +++ b/package.json @@ -70,7 +70,8 @@ "@types/node": "^14.18.54", "@types/semver": "^7.5.0", "@types/xml-name-validator": "^4.0.1", - "@typescript-eslint/parser": "^5.45.0", + "@typescript-eslint/parser": "^6.2.0", + "@typescript-eslint/types": "^6.2.0", "assert": "^2.0.0", "env-cmd": "^10.1.0", "esbuild": "^0.18.17", diff --git a/tests/fixtures/script-indent/ts-class-declaration-04.vue b/tests/fixtures/script-indent/ts-class-declaration-04.vue index 1b7e09fdb..206c64347 100644 --- a/tests/fixtures/script-indent/ts-class-declaration-04.vue +++ b/tests/fixtures/script-indent/ts-class-declaration-04.vue @@ -5,6 +5,11 @@ class < T > + extends + Bar + < + T + > implements Baz1 < @@ -15,11 +20,6 @@ class < T > - extends - Bar - < - T - > { prop:string } diff --git a/tests/fixtures/script-indent/ts-class-declaration-05.vue b/tests/fixtures/script-indent/ts-class-declaration-05.vue index 69bff1cc1..4f0796e35 100644 --- a/tests/fixtures/script-indent/ts-class-declaration-05.vue +++ b/tests/fixtures/script-indent/ts-class-declaration-05.vue @@ -2,12 +2,12 @@ diff --git a/tests/fixtures/script-indent/ts-interface-declaration-05.vue b/tests/fixtures/script-indent/ts-interface-declaration-05.vue index 2e14604b6..9b59a53dd 100644 --- a/tests/fixtures/script-indent/ts-interface-declaration-05.vue +++ b/tests/fixtures/script-indent/ts-interface-declaration-05.vue @@ -4,10 +4,10 @@ interface Foo < T > -implements // visitor key is not provided -Bar -< -T -> +// implements // parsing error +// Bar +// < +// T +// > { } diff --git a/tests/lib/rules/no-required-prop-with-default.js b/tests/lib/rules/no-required-prop-with-default.js index ec1e749cc..f1f5b655a 100644 --- a/tests/lib/rules/no-required-prop-with-default.js +++ b/tests/lib/rules/no-required-prop-with-default.js @@ -508,47 +508,6 @@ tester.run('no-required-prop-with-default', rule, { } ] }, - { - filename: 'test.vue', - code: ` - - `, - output: ` - - `, - options: [{ autofix: true }], - parserOptions: { - parser: require.resolve('@typescript-eslint/parser') - }, - errors: [ - { - message: 'Prop "foo" should be optional.', - line: 4 - } - ] - }, { filename: 'test.vue', code: ` diff --git a/tsconfig.json b/tsconfig.json index d64b99e1c..ac4ab815a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,6 +2,7 @@ "compilerOptions": { "target": "ES2019", "module": "commonjs", + "moduleResolution": "Node16", "lib": ["es2020"], "allowJs": true, "checkJs": true, diff --git a/typings/eslint-plugin-vue/util-types/ast/es-ast.ts b/typings/eslint-plugin-vue/util-types/ast/es-ast.ts index 800943419..944246411 100644 --- a/typings/eslint-plugin-vue/util-types/ast/es-ast.ts +++ b/typings/eslint-plugin-vue/util-types/ast/es-ast.ts @@ -341,6 +341,9 @@ export type Expression = export interface Identifier extends HasParentNode { type: 'Identifier' name: string + + // for typescript-eslint + typeAnnotation?: any } export interface PrivateIdentifier extends HasParentNode { type: 'PrivateIdentifier'