
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
@vue/eslint-config-typescript
Advanced tools
@vue/eslint-config-typescript is an ESLint configuration package specifically designed for Vue.js projects that use TypeScript. It provides a set of rules and configurations to ensure code quality and consistency in Vue.js applications written in TypeScript.
TypeScript Support
This configuration extends the recommended rules from both Vue and TypeScript ESLint plugins, ensuring that your TypeScript code in Vue components is linted according to best practices.
{"extends":["plugin:vue/vue3-essential","plugin:@typescript-eslint/recommended","@vue/typescript/recommended"],"parserOptions":{"ecmaVersion":2020,"sourceType":"module"}}
Vue Specific Rules
Includes Vue-specific linting rules to catch common issues in Vue components, such as unused variables in script setup and unused components.
{"rules":{"vue/script-setup-uses-vars":"error","vue/no-unused-components":"warn"}}
TypeScript Specific Rules
Provides TypeScript-specific linting rules to catch issues like unused variables and to enforce or relax certain TypeScript practices.
{"rules":{"@typescript-eslint/no-unused-vars":["error",{"argsIgnorePattern":"^_"}],"@typescript-eslint/explicit-function-return-type":"off"}}
This package provides a set of TypeScript-specific linting rules for ESLint. It is more general-purpose compared to @vue/eslint-config-typescript, which is tailored specifically for Vue.js projects.
This plugin provides Vue.js specific linting rules for ESLint. While it supports Vue.js, it does not include TypeScript-specific configurations, making it less comprehensive for projects that use both Vue.js and TypeScript.
This package extends Airbnb's ESLint configuration to support TypeScript. It is a good choice for projects that follow Airbnb's style guide but does not include Vue.js specific rules.
ESLint configuration for Vue 3 + TypeScript projects.
See @typescript-eslint/eslint-plugin for available rules.
This config is specifically designed to be used by create-vue
setups
and is not meant for outside use (it can be used but some adaptations
on the user side might be needed - for details see the config file).
A part of its design is that this config may implicitly depend on
other parts of create-vue
setups, such as eslint-plugin-vue
being
extended in the same resulting config.
[!NOTE] The current version doesn't support the legacy
.eslintrc*
configuration format. For that you need to use version 13 or earlier. See the corresponding README for more usage instructions.
npm add --dev @vue/eslint-config-typescript
Please also make sure that you have typescript
and eslint
installed.
Because of the complexity of the configurations, this package exports several utilities:
defineConfigWithVueTs
, a utility function whose type signature is the same as the config
function from typescript-eslint
, but will modify the given ESLint config to work with Vue.js + TypeScript.vueTsConfigs
, contains all the shared configurations from typescript-eslint
(in camelCase, e.g. vueTsConfigs.recommendedTypeChecked
), and applies to .vue
files in addition to TypeScript files.configureVueProject({ scriptLangs, rootDir })
. More info below.// eslint.config.mjs
import pluginVue from 'eslint-plugin-vue'
import {
defineConfigWithVueTs,
vueTsConfigs,
} from '@vue/eslint-config-typescript'
export default defineConfigWithVueTs(
pluginVue.configs['flat/essential'],
vueTsConfigs.recommended,
)
The above configuration enables the essential rules for Vue 3 and the recommended rules for TypeScript.
All the <script>
blocks in .vue
files MUST be written in TypeScript (should be either <script setup lang="ts">
or <script lang="ts">
).
// eslint.config.mjs
import pluginVue from 'eslint-plugin-vue'
import {
defineConfigWithVueTs,
vueTsConfigs,
configureVueProject,
} from '@vue/eslint-config-typescript'
// Optional: configure the Vue project to adjust the strictness of the rulesets or speed up linting.
configureVueProject({
// Whether to parse TypeScript syntax in Vue templates.
// Defaults to `true`.
// Setting it to `false` could improve performance.
// But TypeScript syntax in Vue templates will then lead to syntax errors.
// Also, type-aware rules won't be applied to expressions in templates in that case.
tsSyntaxInTemplates: true,
// Specify the script langs in `.vue` files
// Defaults to `['ts']`.
scriptLangs: [
'ts',
// [!DISCOURAGED]
// Include 'js' to allow plain `<script>` or `<script setup>` blocks.
// This might result-in false positive or negatives in some rules for `.vue` files.
// Note you also need to configure `allowJs: true` and `checkJs: true`
// in corresponding `tsconfig.json` files.
'js',
// [!STRONGLY DISCOURAGED]
// Include 'tsx' to allow `<script lang="tsx">` blocks.
// This would be in conflict with all type-aware rules.
'tsx',
// [!STRONGLY DISCOURAGED]
// Include 'jsx' to allow `<script lang="jsx">` blocks.
// This would be in conflict with all type-aware rules and may result in false positives.
'jsx',
],
// Whether to override some `no-unsafe-*` rules to avoid false positives on Vue component operations.
// Defaults to `true`.
// Usually you should keep this enabled,
// but if you're using a metaframework or in a TSX-only project
// where you're certain you won't operate on `.vue` components in a way that violates the rules,
// and you want the strictest rules (e.g. when extending from `strictTypeChecked`),
// you can set this to `false` to ensure the strictest rules apply to all files.
allowComponentTypeUnsafety: true,
// The root directory to resolve the `.vue` files.
// Defaults to `process.cwd()`.
// More info: <https://github.com/vuejs/eslint-plugin-vue/issues/1910#issuecomment-1819993961>
// You may need to set this to the root directory of your project if you have a monorepo.
// This is useful when you allow any other languages than `ts` in `.vue` files.
// Our config helper would resolve and parse all the `.vue` files under `rootDir`,
// and only apply the loosened rules to the files that do need them.
rootDir: import.meta.dirname,
})
export default defineConfigWithVueTs(
pluginVue.configs["flat/essential"],
// We STRONGLY RECOMMEND you to start with `recommended` or `recommendedTypeChecked`.
// But if you are determined to configure all rules by yourself,
// you can start with `base`, and then turn on/off the rules you need.
vueTsConfigs.base,
)
Some typescript-eslint
rules utilizes type information to provide deeper insights into your code.
But type-checking is a much slower process than linting with only syntax information.
It is not always easy to set up the type-checking environment for ESLint without severe performance penalties.
So we don't recommend you to configure individual type-aware rules and the corresponding language options all by yourself.
Instead, you can start by extending from the recommendedTypeChecked
configuration and then turn on/off the rules you need.
// eslint.config.mjs
import pluginVue from 'eslint-plugin-vue'
import {
defineConfigWithVueTs,
vueTsConfigs,
} from '@vue/eslint-config-typescript'
export default defineConfigWithVueTs(
pluginVue.configs['flat/essential'],
vueTsConfigs.recommendedTypeChecked
)
You can use this package as a normal ESLint config, without the defineConfigWithVueTs
helper. But in this case, overriding the rules for .vue
files would be more difficult and comes with many nuances. Please be cautious.
You can check the documentation for 14.1 and earlier versions for more information.
typescript-eslint
.typescript-eslint
.@vue/eslint-config-standard-with-typescript
FAQs
ESLint config for TypeScript + Vue.js projects
The npm package @vue/eslint-config-typescript receives a total of 1,112,109 weekly downloads. As such, @vue/eslint-config-typescript popularity was classified as popular.
We found that @vue/eslint-config-typescript demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.