优化unplugin-auto-import插件配置

This commit is contained in:
hooray 2022-05-02 16:45:38 +08:00
parent cf6fef85c0
commit e1344e7c91
4 changed files with 16 additions and 58 deletions

View File

@ -15,7 +15,7 @@ module.exports = {
'plugin:vue/vue3-recommended', 'plugin:vue/vue3-recommended',
'plugin:vue/vue3-strongly-recommended', 'plugin:vue/vue3-strongly-recommended',
'eslint:recommended', 'eslint:recommended',
'./auto-import-eslint-config.js' './.eslintrc-auto-import.json'
], ],
parser: 'vue-eslint-parser', parser: 'vue-eslint-parser',
parserOptions: { parserOptions: {

1
.gitignore vendored
View File

@ -3,5 +3,6 @@ node_modules
dist* dist*
dist-ssr dist-ssr
*.local *.local
.eslintrc-auto-import.json
public/icons public/icons
src/assets/sprites/*.* src/assets/sprites/*.*

View File

@ -1,56 +0,0 @@
module.exports = {
globals: {
// lifecycle
onActivated: 'readonly',
onBeforeMount: 'readonly',
onBeforeUnmount: 'readonly',
onBeforeUpdate: 'readonly',
onDeactivated: 'readonly',
onErrorCaptured: 'readonly',
onMounted: 'readonly',
onServerPrefetch: 'readonly',
onUnmounted: 'readonly',
onUpdated: 'readonly',
// reactivity
computed: 'readonly',
customRef: 'readonly',
isReadonly: 'readonly',
isRef: 'readonly',
markRaw: 'readonly',
reactive: 'readonly',
readonly: 'readonly',
ref: 'readonly',
shallowReactive: 'readonly',
shallowReadonly: 'readonly',
shallowRef: 'readonly',
toRaw: 'readonly',
toRef: 'readonly',
toRefs: 'readonly',
triggerRef: 'readonly',
unref: 'readonly',
watch: 'readonly',
watchEffect: 'readonly',
// component
defineComponent: 'readonly',
defineAsyncComponent: 'readonly',
getCurrentInstance: 'readonly',
h: 'readonly',
inject: 'readonly',
nextTick: 'readonly',
provide: 'readonly',
useCssModule: 'readonly',
// other
defineProps: 'readonly',
defineEmits: 'readonly',
defineExpose: 'readonly',
withDefaults: 'readonly',
// vue-router
useRoute: 'readonly',
useRouter: 'readonly',
// element plus
ElMessage: 'readonly',
ElNotification: 'readonly',
ElMessageBox: 'readonly',
ElLoading: 'readonly'
}
}

View File

@ -5,8 +5,21 @@ export default function createAutoImport() {
return autoImport({ return autoImport({
imports: [ imports: [
'vue', 'vue',
'vue-router' 'vue-router',
{
'vue': [
'defineProps',
'defineEmits',
'defineExpose',
'withDefaults'
]
}
], ],
eslintrc: {
enabled: true,
filepath: './.eslintrc-auto-import.json',
globalsPropValue: true
},
resolvers: [ resolvers: [
ElementPlusResolver() ElementPlusResolver()
], ],