ESLint configuration library for Vue.js + TypeScript projects with advanced utilities and preset configurations
—
Factory function for configuring Vue project-specific options like script language support, type checking behavior, and parser settings for optimal performance and accuracy.
Configures global Vue project settings that affect how ESLint processes Vue files and applies TypeScript rules.
/**
* Configure Vue project-specific options globally
* Must be called before defineConfigWithVueTs to take effect
* @param userOptions - Project configuration options
*/
function configureVueProject(userOptions: ProjectOptions): void;
interface ProjectOptions {
/**
* Whether to parse TypeScript syntax in Vue templates
* Defaults to `true`
* Setting to `false` improves performance but disables TS syntax in templates
*/
tsSyntaxInTemplates?: boolean;
/**
* Allowed script languages in `vue` files
* Defaults to `['ts']`
*/
scriptLangs?: ScriptLang[];
/**
* Whether to override some `no-unsafe-*` rules to avoid false positives on Vue component operations
* Defaults to `true`
* Set to `false` for stricter type checking in TSX-only or metaframework projects
*/
allowComponentTypeUnsafety?: boolean;
/**
* The root directory of the project
* Defaults to `process.cwd()`
*/
rootDir?: string;
}
type ScriptLang = "ts" | "tsx" | "js" | "jsx";Usage Examples:
import {
configureVueProject,
defineConfigWithVueTs,
vueTsConfigs
} from "@vue/eslint-config-typescript";
// Basic configuration - TypeScript only
configureVueProject({
tsSyntaxInTemplates: true,
scriptLangs: ["ts"],
allowComponentTypeUnsafety: true,
});
export default defineConfigWithVueTs(vueTsConfigs.recommended);
// Advanced configuration - Multiple script languages
configureVueProject({
tsSyntaxInTemplates: false, // Better performance
scriptLangs: ["ts", "js"], // Allow both TS and JS
allowComponentTypeUnsafety: true,
rootDir: __dirname,
});
export default defineConfigWithVueTs(vueTsConfigs.strictTypeChecked);
// Strict TypeScript-only setup
configureVueProject({
tsSyntaxInTemplates: true,
scriptLangs: ["ts"], // Only TypeScript
allowComponentTypeUnsafety: false, // Strict type checking
rootDir: process.cwd(),
});
export default defineConfigWithVueTs(vueTsConfigs.strictTypeChecked);Controls whether TypeScript syntax is parsed in Vue templates.
// Enable TypeScript in templates (default)
configureVueProject({
tsSyntaxInTemplates: true,
});
// This allows TypeScript syntax in templates:
// <template>
// <div>{{ (user as User).name }}</div>
// <MyComponent :prop="someValue!" />
// </template>
// Disable for better performance
configureVueProject({
tsSyntaxInTemplates: false,
});Trade-offs:
true: Full TypeScript support in templates, type-aware rules work on template expressionsfalse: Better performance, but TypeScript syntax in templates will cause parse errorsSpecifies which script languages are allowed in Vue single-file components.
// TypeScript only (recommended)
configureVueProject({
scriptLangs: ["ts"],
});
// Allow JavaScript (may cause false positives)
configureVueProject({
scriptLangs: ["ts", "js"],
});
// Allow JSX/TSX (strongly discouraged - conflicts with type-aware rules)
configureVueProject({
scriptLangs: ["ts", "tsx", "js", "jsx"],
});Script Language Support:
"ts": TypeScript - Recommended, full type checking support"js": JavaScript - Requires allowJs and checkJs in tsconfig.json"tsx": TypeScript with JSX - Conflicts with type-aware rules"jsx": JavaScript with JSX - May cause false positivesControls whether to override no-unsafe-* rules for Vue component operations.
// Allow Vue component type patterns (default)
configureVueProject({
allowComponentTypeUnsafety: true,
});
// This allows patterns like:
// createApp(App)
// useTemplateRef()
// createRouter({ ... })
// Strict type checking (for TSX-only or metaframework projects)
configureVueProject({
allowComponentTypeUnsafety: false,
});When to use false:
Specifies the project root directory for file discovery and type checking setup.
// Default - current working directory
configureVueProject({
rootDir: process.cwd(),
});
// Custom root directory
configureVueProject({
rootDir: "/path/to/project/root",
});
// Relative to current file
configureVueProject({
rootDir: __dirname,
});The configuration affects several internal processes:
Based on scriptLangs and file content analysis:
// Files are categorized as:
type VueFilesByGroup = {
typeCheckable: string[]; // .vue files with <script lang="ts">
nonTypeCheckable: string[]; // .vue files with other script languages
};Script language settings determine parser selection:
// Parser mapping based on scriptLangs
const parser = {
js: "espree", // For JavaScript files
jsx: "espree", // For JSX files
ts: tseslint.parser, // For TypeScript files
tsx: tseslint.parser, // For TSX files
};Configuration affects which rules are applied:
typeCheckable Vue filesnonTypeCheckable filesno-unsafe-* rule overrides are applied based on allowComponentTypeUnsafety// For large projects - disable TS in templates if not needed
configureVueProject({
tsSyntaxInTemplates: false,
scriptLangs: ["ts"],
});// Maximum type safety
configureVueProject({
tsSyntaxInTemplates: true,
scriptLangs: ["ts"], // TypeScript only
allowComponentTypeUnsafety: false, // If applicable to your project
});// Gradual migration approach
configureVueProject({
tsSyntaxInTemplates: false, // Start with false, enable later
scriptLangs: ["ts", "js"], // Allow both during migration
allowComponentTypeUnsafety: true,
});Install with Tessl CLI
npx tessl i tessl/npm-vue--eslint-config-typescript