Skip to content

ESLint Configuration

17.1.1. Flat Config Usage

The Flat Config format (eslint.config.js) from ESLint v9 or later must be used. The legacy .eslintrc.* format must not be used.


17.1.2. Required Packages

bash
yarn add -D eslint @eslint/js typescript-eslint eslint-plugin-vue eslint-config-prettier
PackageRole
eslintLinter core
@eslint/jsESLint base rules
typescript-eslintTypeScript parser and rules
eslint-plugin-vueVue SFC lint rules
eslint-config-prettierPrevents Prettier conflicts

17.1.3. Full eslint.config.js Example

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

export default tseslint.config(
  {
    ignores: ['dist/', 'node_modules/', '*.config.js'],
  },

  js.configs.recommended,

  ...tseslint.configs.recommended,

  ...pluginVue.configs['flat/recommended'],

  {
    files: ['**/*.vue'],
    languageOptions: {
      parserOptions: {
        parser: tseslint.parser,
      },
    },
  },

  {
    rules: {
      // TypeScript
      '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
      '@typescript-eslint/no-explicit-any': 'warn',
      '@typescript-eslint/consistent-type-imports': 'error',

      // Vue
      'vue/multi-word-component-names': 'off',
      'vue/define-macros-order': ['error', {
        order: ['defineProps', 'defineEmits'],
      }],
      'vue/block-order': ['error', {
        order: ['script', 'template', 'style'],
      }],
      'vue/component-api-style': ['error', ['script-setup']],

      // General
      'no-console': ['warn', { allow: ['warn', 'error'] }],
      'no-debugger': 'error',
    },
  },

  prettierConfig,
)

17.1.4. Key Rule Descriptions

RuleSettingRationale
no-consolewarnPrevents console.log overuse. warn and error are allowed
no-debuggererrorPrevents leftover debugger statements
@typescript-eslint/no-explicit-anywarnMinimizes any type usage
@typescript-eslint/consistent-type-importserrorEnforces import type consistency
vue/component-api-styleerrorEnforces <script setup> usage
vue/block-ordererrorUnifies SFC block ordering

TIENIPIA QUALIFIED STANDARD