0.0.4 • Published 2 years ago

auto-import-types v0.0.4

Weekly downloads
-
License
-
Repository
github
Last release
2 years ago

auto-import-types

NPM version

Auto Import Types on-demand for Vite. With TypeScript support. The implementation idea by unplugin-auto-import.It will automatically configure declared types in esLint's global option.

Install

npm i auto-import-types

Setup

// vite.config.ts
import { defineConfig } from 'vite'
import AutoImportTypes from 'auto-import-types'

export default defineConfig({
  plugins: [AutoImportTypes()],
})
// .eslintrc.js
module.exports = {
  extends: ['.eslintrc-auto-import-types.json'],
}

Config Options

type ESLintGlobalsPropValue = boolean | 'readonly' | 'readable' | 'writable' | 'writeable'

interface ESLintConfigs {
  globals: Record<string, ESLintGlobalsPropValue>
}

type Options = Partial<{
  dtsDir: string
  filepath: string
  globalsPropValue: ESLintGlobalsPropValue
}>

const defaultOptions = {
  dtsDir: 'src/@types',
  filepath: '.eslintrc-auto-import-types.json',
  globalsPropValue: true,
}