Skip to content

Commit

Permalink
chore: apply lint
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Nov 27, 2024
1 parent 085ec5a commit 55102fd
Show file tree
Hide file tree
Showing 36 changed files with 76 additions and 76 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,13 +241,13 @@ Supported Resolvers:
- [Dev UI](https://github.com/antfu/unplugin-vue-components/blob/main/src/core/resolvers/devui.ts)

```ts
// vite.config.js
import Components from 'unplugin-vue-components/vite'
import {
AntDesignVueResolver,
ElementPlusResolver,
VantResolver,
} from 'unplugin-vue-components/resolvers'
// vite.config.js
import Components from 'unplugin-vue-components/vite'

// your plugin installation
Components({
Expand Down
8 changes: 4 additions & 4 deletions examples/vite-vue3/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import path from 'node:path'
import type { UserConfig } from 'vite'
import path from 'node:path'
import Vue from '@vitejs/plugin-vue'
import Components from 'unplugin-vue-components/vite'
import IconsResolver from 'unplugin-icons/resolver'
import Icons from 'unplugin-icons/vite'
import { VantResolver } from 'unplugin-vue-components/resolvers'
import Components from 'unplugin-vue-components/vite'
import Markdown from 'unplugin-vue-markdown/vite'
import Icons from 'unplugin-icons/vite'
import IconsResolver from 'unplugin-icons/resolver'
import Inspect from 'vite-plugin-inspect'

const config: UserConfig = {
Expand Down
2 changes: 1 addition & 1 deletion examples/vue-cli/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Vue from 'vue'
import VueCompostionAPI from '@vue/composition-api'
import Vue from 'vue'
import App from './App.vue'
import './index.css'

Expand Down
4 changes: 2 additions & 2 deletions examples/vue-cli/vue.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const ScriptSetup = require('unplugin-vue2-script-setup/webpack')
const Icons = require('unplugin-icons/webpack')
const IconsResolver = require('unplugin-icons/resolver')
const Icons = require('unplugin-icons/webpack')
const ScriptSetup = require('unplugin-vue2-script-setup/webpack')
const Components = require('unplugin-vue-components/webpack')

/**
Expand Down
14 changes: 7 additions & 7 deletions src/core/context.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { relative } from 'node:path'
import type fs from 'node:fs'
import process from 'node:process'
import Debug from 'debug'
import type { UpdatePayload, ViteDevServer } from 'vite'
import { slash, throttle, toArray } from '@antfu/utils'
import type { ComponentInfo, Options, ResolvedOptions, Transformer } from '../types'
import { relative } from 'node:path'
import process from 'node:process'
import { slash, throttle, toArray } from '@antfu/utils'
import Debug from 'debug'
import { DIRECTIVE_IMPORT_PREFIX } from './constants'
import { getNameFromFilePath, isExclude, matchGlobs, normalizeComponentInfo, parseId, pascalCase, resolveAlias } from './utils'
import { resolveOptions } from './options'
import { searchComponents } from './fs/glob'
import { writeDeclaration } from './declaration'
import { searchComponents } from './fs/glob'
import { resolveOptions } from './options'
import transformer from './transformer'
import { getNameFromFilePath, isExclude, matchGlobs, normalizeComponentInfo, parseId, pascalCase, resolveAlias } from './utils'

const debug = {
components: Debug('unplugin-vue-components:context:components'),
Expand Down
8 changes: 4 additions & 4 deletions src/core/declaration.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { dirname, isAbsolute, relative } from 'node:path'
import type { ComponentInfo, Options } from '../types'
import type { Context } from './context'
import { existsSync } from 'node:fs'
import { mkdir, readFile, writeFile as writeFile_ } from 'node:fs/promises'
import { dirname, isAbsolute, relative } from 'node:path'
import { notNullish, slash } from '@antfu/utils'
import type { ComponentInfo, Options } from '../types'
import type { Context } from './context'
import { getTransformedPath } from './utils'
import { resolveTypeImports } from './type-imports/detect'
import { getTransformedPath } from './utils'

const multilineCommentsRE = /\/\*.*?\*\//gs
const singlelineCommentsRE = /\/\/.*$/gm
Expand Down
4 changes: 2 additions & 2 deletions src/core/fs/glob.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fg from 'fast-glob'
import Debug from 'debug'
import type { Context } from '../context'
import Debug from 'debug'
import fg from 'fast-glob'

const debug = Debug('unplugin-vue-components:glob')

Expand Down
2 changes: 1 addition & 1 deletion src/core/options.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { ComponentResolver, ComponentResolverObject, Options, ResolvedOptions } from '../types'
import { join, resolve } from 'node:path'
import { slash, toArray } from '@antfu/utils'
import { getPackageInfoSync, isPackageExists } from 'local-pkg'
import type { ComponentResolver, ComponentResolverObject, Options, ResolvedOptions } from '../types'
import { detectTypeImports } from './type-imports/detect'

export const defaultOptions: Omit<Required<Options>, 'include' | 'exclude' | 'excludeNames' | 'transformer' | 'globs' | 'directives' | 'types' | 'version'> = {
Expand Down
4 changes: 2 additions & 2 deletions src/core/resolvers/_READ_BEFORE_CONTRIBUTE.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ Instead, we suggest UI libraries to maintain and publish their own resolvers, as
We recommend to have it under a submodule, or publish as a separate package.

```ts
import Components from 'unplugin-vue-components'

import MyLibResolver from 'my-lib/auto-import-resolver' // <--
import Components from 'unplugin-vue-components'

export default defineConfig({
plugins: [
Components({
Expand Down
2 changes: 1 addition & 1 deletion src/core/resolvers/arco.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Debug from 'debug'
import type { ComponentInfo, ComponentResolver } from '../../types'
import Debug from 'debug'
import { isExclude, kebabCase, pascalCase } from '../utils'

const debug = Debug('unplugin-vue-components:resolvers:arco')
Expand Down
2 changes: 1 addition & 1 deletion src/core/resolvers/devui.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { kebabCase } from '../utils'
import type { ComponentInfo, ComponentResolver } from '../../types'
import { kebabCase } from '../utils'

export interface DevResolverOptions {
/**
Expand Down
2 changes: 1 addition & 1 deletion src/core/resolvers/element-plus.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { compare } from 'compare-versions'
import type { ComponentInfo, ComponentResolver, SideEffectsInfo } from '../../types'
import { compare } from 'compare-versions'
import { getPkgVersion, kebabCase } from '../utils'

export interface ElementPlusResolverOptions {
Expand Down
4 changes: 2 additions & 2 deletions src/core/resolvers/idux.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { resolveModule } from 'local-pkg'
import { compare } from 'compare-versions'
import type { ComponentResolver } from '../../types'
import { compare } from 'compare-versions'
import { resolveModule } from 'local-pkg'
import { getPkgVersion, kebabCase } from '../utils'

// @keep-sorted
Expand Down
14 changes: 7 additions & 7 deletions src/core/resolvers/index.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
export * from './antdv'
export * from './arco'
export * from './bootstrap-vue'
export * from './devui'
export * from './element-plus'
export * from './element-ui'
export * from './headless-ui'
export * from './idux'
export * from './inkline'
export * from './ionic'
export * from './layui-vue'
export * from './naive-ui'
export * from './prime-vue'
export * from './quasar'
export * from './tdesign'
export * from './vant'
export * from './varlet-ui'
export * from './veui'
export * from './view-ui'
export * from './vuetify'
export * from './vueuse'
export * from './vueuse-directive'
export * from './quasar'
export * from './devui'
export * from './arco'
export * from './tdesign'
export * from './layui-vue'
export * from './bootstrap-vue'
export * from './ionic'
2 changes: 1 addition & 1 deletion src/core/resolvers/layui-vue.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { FilterPattern } from '@rollup/pluginutils'
import { isExclude } from '../utils'
import type { ComponentInfo, ComponentResolver, SideEffectsInfo } from '../../types'
import { isExclude } from '../utils'

const matchComponents = [
{
Expand Down
2 changes: 1 addition & 1 deletion src/core/resolvers/quasar.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { ComponentResolver } from '../../types'
import { promises as fs } from 'node:fs'
import { resolveModule } from 'local-pkg'
import type { ComponentResolver } from '../../types'

/**
* Resolver for Quasar
Expand Down
2 changes: 1 addition & 1 deletion src/core/resolvers/varlet-ui.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ComponentResolveResult, ComponentResolver } from '../../types'
import type { ComponentResolver, ComponentResolveResult } from '../../types'
import { kebabCase } from '../utils'

export interface VarletUIResolverOptions {
Expand Down
2 changes: 1 addition & 1 deletion src/core/resolvers/veui.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { ComponentResolver, SideEffectsInfo } from '../../types'
import { join, normalize } from 'node:path'
import { resolvePathSync } from 'mlly'
import type { ComponentResolver, SideEffectsInfo } from '../../types'
import { camelCase, kebabCase, pascalCase } from '../utils'

interface VeuiPeerConfig {
Expand Down
2 changes: 1 addition & 1 deletion src/core/resolvers/vueuse-directive.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { ComponentResolver } from '../../types'
import { readFileSync } from 'node:fs'
import process from 'node:process'
import { resolveModule } from 'local-pkg'
import type { ComponentResolver } from '../../types'

let directives: string[] | undefined

Expand Down
2 changes: 1 addition & 1 deletion src/core/resolvers/vueuse.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { ComponentResolver } from '../../types'
import { readFileSync } from 'node:fs'
import process from 'node:process'
import { resolveModule } from 'local-pkg'
import type { ComponentResolver } from '../../types'

let components: string[] | undefined

Expand Down
6 changes: 3 additions & 3 deletions src/core/transformer.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import Debug from 'debug'
import MagicString from 'magic-string'
import type { TransformResult } from 'unplugin'
import type { SupportedTransformer } from '..'
import type { Transformer } from '../types'
import { DISABLE_COMMENT } from './constants'
import type { Context } from './context'
import Debug from 'debug'
import MagicString from 'magic-string'
import { DISABLE_COMMENT } from './constants'
import transformComponent from './transforms/component'
import transformDirectives from './transforms/directive'

Expand Down
6 changes: 3 additions & 3 deletions src/core/transforms/component.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import Debug from 'debug'
import type MagicString from 'magic-string'
import { pascalCase, stringifyComponentImport } from '../utils'
import type { SupportedTransformer } from '../..'
import type { Context } from '../context'
import type { ResolveResult } from '../transformer'
import type { SupportedTransformer } from '../..'
import Debug from 'debug'
import { pascalCase, stringifyComponentImport } from '../utils'

const debug = Debug('unplugin-vue-components:transform:component')

Expand Down
6 changes: 3 additions & 3 deletions src/core/transforms/directive/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import Debug from 'debug'
import type MagicString from 'magic-string'
import { pascalCase, stringifyComponentImport } from '../../utils'
import type { Context } from '../../context'
import type { SupportedTransformer } from '../../..'
import type { Context } from '../../context'
import Debug from 'debug'
import { DIRECTIVE_IMPORT_PREFIX } from '../../constants'
import { pascalCase, stringifyComponentImport } from '../../utils'
import vue2Resolver from './vue2'
import vue3Resolver from './vue3'

Expand Down
2 changes: 1 addition & 1 deletion src/core/transforms/directive/vue2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import type {
VariableDeclaration,
} from '@babel/types'
import type MagicString from 'magic-string'
import { importModule, isPackageExists } from 'local-pkg'
import type { ResolveResult } from '../../transformer'
import { importModule, isPackageExists } from 'local-pkg'

/**
* Get Vue 2 render function position
Expand Down
4 changes: 2 additions & 2 deletions src/core/type-imports/detect.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { isPackageExists } from 'local-pkg'
import { notNullish } from '@antfu/utils'
import type { ComponentInfo, TypeImport } from '../../types'
import { notNullish } from '@antfu/utils'
import { isPackageExists } from 'local-pkg'
import { TypeImportPresets } from '.'

export function detectTypeImports(): TypeImport[] {
Expand Down
8 changes: 4 additions & 4 deletions src/core/unplugin.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { ResolvedConfig, ViteDevServer } from 'vite'
import type { Watching } from 'webpack'
import type { Options, PublicPluginAPI } from '../types'
import { existsSync } from 'node:fs'
import process from 'node:process'
import { createUnplugin } from 'unplugin'
import { createFilter } from '@rollup/pluginutils'
import chokidar from 'chokidar'
import type { ResolvedConfig, ViteDevServer } from 'vite'
import type { Watching } from 'webpack'
import type { Options, PublicPluginAPI } from '../types'
import { createUnplugin } from 'unplugin'
import { Context } from './context'
import { shouldTransform, stringifyComponentImport } from './utils'

Expand Down
8 changes: 4 additions & 4 deletions src/core/utils.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import type { FilterPattern } from '@rollup/pluginutils'
import type { ComponentInfo, ImportInfo, ImportInfoLegacy, Options, ResolvedOptions } from '../types'
import type { Context } from './context'
import { parse } from 'node:path'
import process from 'node:process'
import { minimatch } from 'minimatch'
import { slash, toArray } from '@antfu/utils'
import {
getPackageInfo,
isPackageExists,
} from 'local-pkg'
import type { FilterPattern } from '@rollup/pluginutils'
import type { ComponentInfo, ImportInfo, ImportInfoLegacy, Options, ResolvedOptions } from '../types'
import type { Context } from './context'
import { minimatch } from 'minimatch'
import { DISABLE_COMMENT } from './constants'

export const isSSR = Boolean(process.env.SSR || process.env.SSG || process.env.VITE_SSR || process.env.VITE_SSG)
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from './types'
export { default } from './core/unplugin'
export { camelCase, pascalCase, kebabCase } from './core/utils'
export { camelCase, kebabCase, pascalCase } from './core/utils'
export * from './types'
4 changes: 2 additions & 2 deletions src/nuxt.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { addVitePlugin, addWebpackPlugin, defineNuxtModule } from '@nuxt/kit'

// Workaround for:
// src/nuxt.ts(5,1): error TS2742: The inferred type of 'default' cannot be named without a reference to '.pnpm/@[email protected][email protected]/node_modules/@nuxt/schema'. This is likely not portable. A type annotation is necessary.
import type { } from '@nuxt/schema'

import type { Options } from './types'
import { addVitePlugin, addWebpackPlugin, defineNuxtModule } from '@nuxt/kit'
import unplugin from '.'

export default defineNuxtModule({
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Awaitable } from '@antfu/utils'
import type { FilterPattern } from '@rollup/pluginutils'
import type { TransformResult } from 'unplugin'
import type { Awaitable } from '@antfu/utils'

export interface ImportInfoLegacy {
/**
Expand Down
2 changes: 1 addition & 1 deletion test/dts.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { ComponentResolver } from '../src'
import { readFile, writeFile } from 'node:fs/promises'
import path from 'node:path'
import { describe, expect, it } from 'vitest'
import type { ComponentResolver } from '../src'
import { Context } from '../src/core/context'
import { getDeclaration, parseDeclaration } from '../src/core/declaration'

Expand Down
4 changes: 2 additions & 2 deletions test/resolvers/arco.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { ComponentResolveResult, ComponentResolverObject } from '../../src'
import { describe, expect, it } from 'vitest'
import { ArcoResolver } from '../../src/resolvers'

import type { ComponentResolveResult, ComponentResolverObject } from '../../src'
import { ArcoResolver } from '../../src/resolvers'

function testNoIconComponentResolve(resolver: ComponentResolverObject) {
expect(resolver.resolve('AButton')).toEqual<ComponentResolveResult>({
Expand Down
2 changes: 1 addition & 1 deletion test/resolvers/element-plus.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest'
import { ElementPlusResolver } from '../../src/resolvers'
import { Context } from '../../src/core/context'
import { ElementPlusResolver } from '../../src/resolvers'

describe('element Plus Resolver', () => {
it('components and directives should be transformed', async () => {
Expand Down
4 changes: 2 additions & 2 deletions test/resolvers/tdesign.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { ComponentResolverObject } from '../../src'
import { describe, expect, it } from 'vitest'
import { TDesignResolver } from '../../src/resolvers'

import type { ComponentResolverObject } from '../../src'
import { TDesignResolver } from '../../src/resolvers'

describe('tDesignResolver', () => {
it('name matching string rule should not be resolved', async () => {
Expand Down
2 changes: 1 addition & 1 deletion test/transform.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest'
import type { ComponentResolver } from '../src'
import { describe, expect, it } from 'vitest'
import { Context } from '../src/core/context'

const resolver: ComponentResolver[] = [
Expand Down
2 changes: 1 addition & 1 deletion test/utils.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest'
import type { ResolvedOptions } from '../src'
import { describe, expect, it } from 'vitest'
import { getNameFromFilePath } from '../src/core/utils'

describe('getNameFromFilePath', () => {
Expand Down

0 comments on commit 55102fd

Please sign in to comment.