百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
E

eslint-config-typescript

> 编程语言
开源

Vue 3 + TypeScript项目的ESLint配置

190 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

Vue 3 + TypeScript项目的ESLint配置

@vue/eslint-config-typescript

ESLint configuration for Vue 3 + TypeScript projects.

See @typescript-eslint/eslint-plugin for available rules.

This config is designed for create-vue setups. Other projects can use it, but may need project-specific adjustments.

It may rely on other create-vue defaults, such as eslint-plugin-vue being extended in the same final config.

[!NOTE] The current version doesn't support the legacy .eslintrc* configuration format. Use version 13 or earlier for that format. See the corresponding README for more usage instructions.

Installation

bash
npm add --dev @vue/eslint-config-typescript

Please also make sure that you have typescript and eslint installed.

Usage

For new flat configs, use these two exports:

  • withVueTs, a helper that builds a flat ESLint config for Vue.js + TypeScript. It accepts either withVueTs(...configs) or withVueTs(options, ...configs).
  • vueTsConfigs, the shared configurations from typescript-eslint adapted for .vue files in addition to TypeScript files. The names are in camel case, such as vueTsConfigs.recommendedTypeChecked.

The helper APIs used before v14.9 remain available for existing projects. See Helper APIs Before v14.9.

Recommended

withVueTs(...) is available in v14.9 and later. Export the withVueTs(...) call from eslint.config.js, eslint.config.mjs, or eslint.config.ts.

javascript
// eslint.config.mjs
import pluginVue from 'eslint-plugin-vue'
import { withVueTs, vueTsConfigs } from '@vue/eslint-config-typescript'

export default withVueTs(
  pluginVue.configs['flat/essential'],
  vueTsConfigs.recommended,
)

The above configuration enables the essential rules for Vue 3 and the recommended rules for TypeScript.

All the blocks in `.vue` files _MUST_ be written in TypeScript (should be either or ``).

withVueTs(...) accepts config objects, config arrays, and promises. This matches the input style used by eslint-flat-config-utils, so configs built with Antfu's or Nuxt's ESLint config utilities can be passed to withVueTs(...) for Vue + TypeScript resolution.

Linting with Type Information

Some typescript-eslint rules use type information to provide deeper insights into the project code. Type-checking is much slower than linting with syntax information only. Setting up typed linting for ESLint without severe performance penalties can be difficult.

We don't recommend configuring individual type-aware rules and the corresponding language options manually. Start with the recommendedTypeChecked configuration, then turn rules on or off as needed.

javascript
// eslint.config.mjs
import pluginVue from 'eslint-plugin-vue'
import { withVueTs, vueTsConfigs } from '@vue/eslint-config-typescript'

export default withVueTs(
  pluginVue.configs['flat/essential'],
  vueTsConfigs.recommendedTypeChecked,
)

Project Options

withVueTs(...) accepts options for this config as the first argument. These are the same options accepted by configureVueProject(...) in the helper APIs before v14.9.

Only pass the options that differ from the defaults. This example lists all available options:

…

Helper APIs Before v14.9

Configs written before v14.9 usually use defineConfigWithVueTs(...) as the final config helper, with configureVueProject(...) for the same project options.

Both APIs remain supported. defineConfigWithVueTs(...) accepts flat config entries and applies the final Vue + TypeScript resolution. configureVueProject(...) sets the project options used by defineConfigWithVueTs(...).

The pre-v14.9 API shape:

javascript
configureVueProject(options)
export default defineConfigWithVueTs(...configs)

maps to:

javascript
export default withVueTs(options, ...configs)
javascript
// eslint.config.mjs
import pluginVue from 'eslint-plugin-vue'
import {
  defineConfigWithVueTs,
  vueTsConfigs,
  configureVueProject,
} from '@vue/eslint-config-typescript'

configureVueProject({
  rootDir: import.meta.dirname,
  scriptLangs: ['ts', 'js'],
})

export default defineConfigWithVueTs(
  pluginVue.configs['flat/essential'],
  vueTsConfigs.recommended,
)

Migration

To migrate an existing flat config from defineConfigWithVueTs(...) / configureVueProject(...) to withVueTs(...), use:

bash
npx @vue/eslint-config-typescript migrate-to-with-vue-ts

This command is interactive by default. It discovers eslint.config.{js,mjs,ts,mts}, shows the planned changes, and asks before writing files.

The codemod is conservative. It auto-fixes common top-level helper patterns, and reports unusual cases such as non-top-level configureVueProject(...) calls or ambiguous first arguments for manual migration.

Explicit paths and non-interactive runs are also supported:

bash
npx @vue/eslint-config-typescript migrate-to-with-vue-ts eslint.config.ts
npx @vue/eslint-config-typescript migrate-to-with-vue-ts "packages/*/eslint.config.ts" --yes

There is also a versioned alias:

bash
npx @vue/eslint-config-typescript migrate-14.9

Use migrate-to-with-vue-ts as the primary interface. The alias is only a convenience for this specific migration and future releases may add other migrations.

Use As a Normal Shared ESLint Config (Not Recommended)

This package can be used as a normal ESLint config, without withVueTs or defineConfigWithVueTs. In that setup, overriding the rules for .vue files is more difficult and comes with many nuances. Use this mode with caution.

See the documentation for 14.1 and earlier versions for more information.

Further Reading

  • All the extendable configurations from typescript-eslint.
  • All the available rules from typescript-eslint.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

TypeScript

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言