0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ESLint - How to Add ESLint with Vue3, Vite, prettier and TypeScript?

Last updated at Posted at 2024-12-31

NPM install

npm install -D eslint @eslint/js typescript typescript-eslint @vue/eslint-config-typescript @vue/eslint-config-prettier vite-plugin-eslint

Added eslint.config.mjs

eslint.config.mjs
// @ts-check

import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
import pluginVue from 'eslint-plugin-vue';
import vueTsEslintConfig from '@vue/eslint-config-typescript';
import prettierConfig from '@vue/eslint-config-prettier';

export default tseslint.config({
  files: ['**/*.{js,ts,vue}'],
  ignores: ['**/.*', 'node_modules/**/*', 'dist/**/*'],
  extends: [
    eslint.configs.recommended,
    tseslint.configs.strict,
    tseslint.configs.stylistic,
    ...pluginVue.configs['flat/essential'],
    ...vueTsEslintConfig(),
    prettierConfig,
  ],
  rules: {
    'vue/no-unused-components': 'off',
    '@typescript-eslint/no-unused-vars': 'warn',
    // You can add rule here.
  },
});

Added vite.config.ts

vite.config.ts
import { defineConfig } from 'vite'
import eslint from 'vite-plugin-eslint'

export default defineConfig({
  plugins: [
    eslint({
      include: ['src/**/*.ts', 'src/**/*.vue'],
      failOnError: false,
    })
  ]
})

Reference

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?