You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Vue3+TypeScript新项目中ESLint无法正常运行的问题求助

Vue3+TypeScript新项目中ESLint无法正常运行的问题求助

我最近在搭建一个Vue3 + TypeScript的新项目,配置了Prettier和ESLint相关规则,但不管怎么调整配置,运行lint命令都没法正常工作。下面是我的脚本、报错信息和配置文件,麻烦大家帮我看看问题出在哪!

我的package.json中的lint脚本

"lint": "eslint \"./src/**/*.{js,ts,vue}\"",
"lint:fix": "eslint \"./src/**/*.{js,ts,vue}\" --fix",

运行lint命令后的报错信息

eslint "src/**/*.{js,ts,vue}"

Oops! Something went wrong! :(

ESLint: 9.18.0

You are linting "src//*.{js,ts,vue}", but all of the files matching the glob pattern "src//*.{js,ts,vue}" are ignored.

If you don't want to lint these files, remove the pattern "src/**/*.{js,ts,vue}" from the list of arguments passed to ESLint.

If you do want to lint these files, explicitly list one or more of the files from this glob that you'd like to lint to see more details about why they are ignored.

  • If the file is ignored because of a matching ignore pattern, check global ignores in your config file.
  • If the file is ignored because no matching configuration was supplied, check file patterns in your config file.
  • If the file is ignored because it is located outside of the base path, change the location of your config file to be in a parent directory.

我的eslint.config.js配置文件

import { defineConfig } from 'eslint-define-config';
import pluginJs from '@eslint/js';
import pluginVue from 'eslint-plugin-vue';
import tseslint from '@typescript-eslint/eslint-plugin';

export default defineConfig({
  root: true,
  env: {
    browser: true,
    es2021: true,
    node: true,
  },
  extends: [
    'eslint:recommended',
    'plugin:vue/vue3-recommended',
    'plugin:@typescript-eslint/recommended',
    'plugin:prettier/recommended',
  ],
  parser: 'vue-eslint-parser',
  parserOptions: {
    parser: '@typescript-eslint/parser',
    ecmaVersion: 2021,
    sourceType: 'module',
  },
  plugins: ['vue', '@typescript-eslint', 'prettier'],
  rules: {
    'prettier/prettier': 'error',
    'no-console': 'warn',
    'no-unused-vars': 'off',
    '@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
    '@typescript-eslint/explicit-module-boundary-types': 'warn',
    'eqeqeq': ['error', 'always'],
    'consistent-return': 'warn',
    'no-undef': 'error',
    'vue/require-default-prop': 'warn',
    'vue/no-v-html': 'warn',
  },
  ignorePatterns: ['node_modules/', 'dist/', 'build/', '**/*.min.js'],
  overrides: [
    {
      files: ['*.vue'],
      rules: {
        'max-len': 'off',
      },
    },
  ],
});

我尝试在配置里加了这段代码,但还是没解决问题:

{ ignores: ['*.d.ts', '**/coverage', '**/dist'] },

我期望lint命令能正常运行,检查并修复src目录下的所有js、ts和vue文件,麻烦各位大佬帮我排查一下问题!

备注:内容来源于stack exchange,提问作者Ali Hamza Rao

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.14 13:39:30