ESLint configuration for Vue 3 + TypeScript projects
ESLint configuration for Vue 3 + TypeScript projects
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.
npm add --dev @vue/eslint-config-typescriptPlease also make sure that you have typescript and eslint installed.
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.
withVueTs(...) is available in v14.9 and later. Export the withVueTs(...) call from eslint.config.js, eslint.config.mjs, or eslint.config.ts.
// 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.
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.
// 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,
)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:
…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:
configureVueProject(options)
export default defineConfigWithVueTs(...configs)maps to:
export default withVueTs(options, ...configs)// 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,
)To migrate an existing flat config from defineConfigWithVueTs(...) / configureVueProject(...) to withVueTs(...), use:
npx @vue/eslint-config-typescript migrate-to-with-vue-tsThis 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:
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" --yesThere is also a versioned alias:
npx @vue/eslint-config-typescript migrate-14.9Use 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.
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.
No open issues yet, or sync has not completed.