How is the Eslint9.x version configured with AutoImport to eliminate no-undef
tracker1999 opened this issue · 1 comments
tracker1999 commented
vite disposition:
plugins: [
vue(),
vueDevTools(),
AutoImport({
imports: ['vue'],
resolvers: [ElementPlusResolver()],
eslintrc: {
enabled: true,
},
}),
Components({
resolvers: [ElementPlusResolver()],
}),
]
How can I write the eslint configuration so that I don't get no-undef errors when using the vue api
I tried to introduce.eslintrc-auto-import.json, but it didn't work and would invalidate all of my eslint rules
eslint.config.ts
import pluginVue from 'eslint-plugin-vue'
import { defineConfigWithVueTs, vueTsConfigs } from '@vue/eslint-config-typescript'
import skipFormatting from '@vue/eslint-config-prettier/skip-formatting'
import eslintrcImport from './.eslintrc-auto-import.json' assert { type: 'json' }
// To allow more languages other than `ts` in `.vue` files, uncomment the following lines:
// import { configureVueProject } from '@vue/eslint-config-typescript'
// configureVueProject({ scriptLangs: ['ts', 'tsx'] })
// More info at https://github.com/vuejs/eslint-config-typescript/#advanced-setup
export default defineConfigWithVueTs(
{
name: 'app/files-to-lint',
files: ['**/*.{ts,mts,tsx,vue}'],
},
{
name: 'app/files-to-ignore',
ignores: ['**/dist/**', '**/dist-ssr/**', '**/coverage/**'],
},
pluginVue.configs['flat/essential'],
vueTsConfigs.recommended,
skipFormatting,
{ languageOptions: { globals: eslintrcImport.globals } },
)
haoqunjiang commented
Can't reproduce. Do you have a runnable reproduction?
Because in the recommended setup, the no-undef rule isn't turned on at all. typescript-eslint strongly recommends against using this rule
https://typescript-eslint.io/troubleshooting/faqs/eslint/#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors and it is off in our recommended config.