Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: add @typescript-eslint/eslint-plugin plugin #8978

Merged
merged 1 commit into from
Dec 19, 2023

Conversation

Alfred-Skyblue
Copy link
Member

@Alfred-Skyblue Alfred-Skyblue commented Aug 15, 2023

I have added the following rules using the @typescript-eslint/eslint-plugin:

  • @typescript-eslint/prefer-ts-expect-error: replace @ts-ignore with @ts-expect-error
  • @typescript-eslint/no-unnecessary-type-assertion: avoid unnecessary type assertions
  • @typescript-eslint/consistent-type-imports: use the type keyword when importing types
  • @typescript-eslint/no-import-type-side-effects: enforce the use of top-level import type qualifier when an import only has specifiers with inline type qualifiers
  • @typescript-eslint/consistent-indexed-object-style: ensure consistent usage of indexed object access style in TypeScript code

https://typescript-eslint.io/rules/

@sxzz sxzz added the ready to merge The PR is ready to be merged. label Aug 15, 2023
@github-actions
Copy link

github-actions bot commented Aug 21, 2023

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 85.8 kB 32.6 kB 29.4 kB
vue.global.prod.js 132 kB 49.3 kB 44.3 kB

Usages

Name Size Gzip Brotli
createApp 47.7 kB 18.9 kB 17.2 kB
createSSRApp 50.5 kB 19.9 kB 18.2 kB
defineCustomElement 50.1 kB 19.6 kB 17.9 kB
overall 61.1 kB 23.7 kB 21.6 kB

Copy link
Member

@haoqunjiang haoqunjiang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be more helpful and more comprehensive if we could add an ESLint rule in the project to avoid such issues from happening again. https://typescript-eslint.io/rules/prefer-ts-expect-error

@sxzz sxzz changed the base branch from main to chore/style September 7, 2023 13:44
@sxzz
Copy link
Member

sxzz commented Sep 7, 2023

I changed the base branch to chore/style. We can merge these stylistic PRs into a commit and put it into .git-blame-ignore-revs to avoid making git history messy.

Also #8565

@sxzz sxzz changed the title chore(types): remove unnecessary @ts-ignore style: remove unnecessary @ts-ignore Sep 7, 2023
@Alfred-Skyblue Alfred-Skyblue changed the title style: remove unnecessary @ts-ignore style: use @ts-expect-error to replace @ts-ignore Sep 8, 2023
@Alfred-Skyblue
Copy link
Member Author

Alfred-Skyblue commented Sep 8, 2023

I added the @typescript-eslinteslint-plugin plugin to eslint, checking for @ts-ignore and unnecessary type assertions

https://typescript-eslint.io/rules/prefer-ts-expect-error/

cc @sxzz @sodatea

@Alfred-Skyblue Alfred-Skyblue changed the title style: use @ts-expect-error to replace @ts-ignore style: add @typescript-eslinteslint-plugin plugin to eslint Sep 8, 2023
@Alfred-Skyblue Alfred-Skyblue changed the title style: add @typescript-eslinteslint-plugin plugin to eslint style: add @typescript-eslint/eslint-plugin plugin to eslint Sep 8, 2023
@Alfred-Skyblue Alfred-Skyblue marked this pull request as draft September 9, 2023 02:05
@Alfred-Skyblue Alfred-Skyblue marked this pull request as ready for review September 9, 2023 13:56
@@ -0,0 +1,4 @@
{
"extends": "./tsconfig.json",
"include": ["packages", "scripts", "./*.ts"]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tsconfig.eslint.json added here is to prevent ESLint from reporting errors for files that are not matched. Please refer to: https://typescript-eslint.io/linting/troubleshooting/#i-get-errors-telling-me-eslint-was-configured-to-run--however-that-tsconfig-does-not--none-of-those-tsconfigs-include-this-file

@sxzz sxzz merged commit 4e587b6 into vuejs:chore/style Dec 19, 2023
2 checks passed
@sxzz sxzz changed the title style: add @typescript-eslint/eslint-plugin plugin to eslint style: add @typescript-eslint/eslint-plugin plugin Dec 19, 2023
@Alfred-Skyblue Alfred-Skyblue deleted the chore-remove-ts-ignore branch December 19, 2023 13:28
sxzz added a commit that referenced this pull request Dec 19, 2023
sxzz added a commit that referenced this pull request Dec 19, 2023
sxzz added a commit that referenced this pull request Dec 19, 2023
sxzz added a commit that referenced this pull request Dec 20, 2023
sxzz added a commit that referenced this pull request Dec 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready to merge The PR is ready to be merged.
Projects
Development

Successfully merging this pull request may close these issues.

3 participants