Skip to content

Commit 55102fd

Browse files
committed
chore: apply lint
1 parent 085ec5a commit 55102fd

36 files changed

+76
-76
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -241,13 +241,13 @@ Supported Resolvers:
241241
- [Dev UI](https://github.com/antfu/unplugin-vue-components/blob/main/src/core/resolvers/devui.ts)
242242

243243
```ts
244-
// vite.config.js
245-
import Components from 'unplugin-vue-components/vite'
246244
import {
247245
AntDesignVueResolver,
248246
ElementPlusResolver,
249247
VantResolver,
250248
} from 'unplugin-vue-components/resolvers'
249+
// vite.config.js
250+
import Components from 'unplugin-vue-components/vite'
251251

252252
// your plugin installation
253253
Components({

examples/vite-vue3/vite.config.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import path from 'node:path'
21
import type { UserConfig } from 'vite'
2+
import path from 'node:path'
33
import Vue from '@vitejs/plugin-vue'
4-
import Components from 'unplugin-vue-components/vite'
4+
import IconsResolver from 'unplugin-icons/resolver'
5+
import Icons from 'unplugin-icons/vite'
56
import { VantResolver } from 'unplugin-vue-components/resolvers'
7+
import Components from 'unplugin-vue-components/vite'
68
import Markdown from 'unplugin-vue-markdown/vite'
7-
import Icons from 'unplugin-icons/vite'
8-
import IconsResolver from 'unplugin-icons/resolver'
99
import Inspect from 'vite-plugin-inspect'
1010

1111
const config: UserConfig = {

examples/vue-cli/src/main.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import Vue from 'vue'
21
import VueCompostionAPI from '@vue/composition-api'
2+
import Vue from 'vue'
33
import App from './App.vue'
44
import './index.css'
55

examples/vue-cli/vue.config.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
const ScriptSetup = require('unplugin-vue2-script-setup/webpack')
2-
const Icons = require('unplugin-icons/webpack')
31
const IconsResolver = require('unplugin-icons/resolver')
2+
const Icons = require('unplugin-icons/webpack')
3+
const ScriptSetup = require('unplugin-vue2-script-setup/webpack')
44
const Components = require('unplugin-vue-components/webpack')
55

66
/**

src/core/context.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import { relative } from 'node:path'
21
import type fs from 'node:fs'
3-
import process from 'node:process'
4-
import Debug from 'debug'
52
import type { UpdatePayload, ViteDevServer } from 'vite'
6-
import { slash, throttle, toArray } from '@antfu/utils'
73
import type { ComponentInfo, Options, ResolvedOptions, Transformer } from '../types'
4+
import { relative } from 'node:path'
5+
import process from 'node:process'
6+
import { slash, throttle, toArray } from '@antfu/utils'
7+
import Debug from 'debug'
88
import { DIRECTIVE_IMPORT_PREFIX } from './constants'
9-
import { getNameFromFilePath, isExclude, matchGlobs, normalizeComponentInfo, parseId, pascalCase, resolveAlias } from './utils'
10-
import { resolveOptions } from './options'
11-
import { searchComponents } from './fs/glob'
129
import { writeDeclaration } from './declaration'
10+
import { searchComponents } from './fs/glob'
11+
import { resolveOptions } from './options'
1312
import transformer from './transformer'
13+
import { getNameFromFilePath, isExclude, matchGlobs, normalizeComponentInfo, parseId, pascalCase, resolveAlias } from './utils'
1414

1515
const debug = {
1616
components: Debug('unplugin-vue-components:context:components'),

src/core/declaration.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { dirname, isAbsolute, relative } from 'node:path'
1+
import type { ComponentInfo, Options } from '../types'
2+
import type { Context } from './context'
23
import { existsSync } from 'node:fs'
34
import { mkdir, readFile, writeFile as writeFile_ } from 'node:fs/promises'
5+
import { dirname, isAbsolute, relative } from 'node:path'
46
import { notNullish, slash } from '@antfu/utils'
5-
import type { ComponentInfo, Options } from '../types'
6-
import type { Context } from './context'
7-
import { getTransformedPath } from './utils'
87
import { resolveTypeImports } from './type-imports/detect'
8+
import { getTransformedPath } from './utils'
99

1010
const multilineCommentsRE = /\/\*.*?\*\//gs
1111
const singlelineCommentsRE = /\/\/.*$/gm

src/core/fs/glob.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import fg from 'fast-glob'
2-
import Debug from 'debug'
31
import type { Context } from '../context'
2+
import Debug from 'debug'
3+
import fg from 'fast-glob'
44

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

src/core/options.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
import type { ComponentResolver, ComponentResolverObject, Options, ResolvedOptions } from '../types'
12
import { join, resolve } from 'node:path'
23
import { slash, toArray } from '@antfu/utils'
34
import { getPackageInfoSync, isPackageExists } from 'local-pkg'
4-
import type { ComponentResolver, ComponentResolverObject, Options, ResolvedOptions } from '../types'
55
import { detectTypeImports } from './type-imports/detect'
66

77
export const defaultOptions: Omit<Required<Options>, 'include' | 'exclude' | 'excludeNames' | 'transformer' | 'globs' | 'directives' | 'types' | 'version'> = {

src/core/resolvers/_READ_BEFORE_CONTRIBUTE.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ Instead, we suggest UI libraries to maintain and publish their own resolvers, as
99
We recommend to have it under a submodule, or publish as a separate package.
1010

1111
```ts
12-
import Components from 'unplugin-vue-components'
13-
1412
import MyLibResolver from 'my-lib/auto-import-resolver' // <--
1513
14+
import Components from 'unplugin-vue-components'
15+
1616
export default defineConfig({
1717
plugins: [
1818
Components({

src/core/resolvers/arco.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import Debug from 'debug'
21
import type { ComponentInfo, ComponentResolver } from '../../types'
2+
import Debug from 'debug'
33
import { isExclude, kebabCase, pascalCase } from '../utils'
44

55
const debug = Debug('unplugin-vue-components:resolvers:arco')

src/core/resolvers/devui.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { kebabCase } from '../utils'
21
import type { ComponentInfo, ComponentResolver } from '../../types'
2+
import { kebabCase } from '../utils'
33

44
export interface DevResolverOptions {
55
/**

src/core/resolvers/element-plus.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { compare } from 'compare-versions'
21
import type { ComponentInfo, ComponentResolver, SideEffectsInfo } from '../../types'
2+
import { compare } from 'compare-versions'
33
import { getPkgVersion, kebabCase } from '../utils'
44

55
export interface ElementPlusResolverOptions {

src/core/resolvers/idux.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { resolveModule } from 'local-pkg'
2-
import { compare } from 'compare-versions'
31
import type { ComponentResolver } from '../../types'
2+
import { compare } from 'compare-versions'
3+
import { resolveModule } from 'local-pkg'
44
import { getPkgVersion, kebabCase } from '../utils'
55

66
// @keep-sorted

src/core/resolvers/index.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
export * from './antdv'
2+
export * from './arco'
3+
export * from './bootstrap-vue'
4+
export * from './devui'
25
export * from './element-plus'
36
export * from './element-ui'
47
export * from './headless-ui'
58
export * from './idux'
69
export * from './inkline'
10+
export * from './ionic'
11+
export * from './layui-vue'
712
export * from './naive-ui'
813
export * from './prime-vue'
14+
export * from './quasar'
15+
export * from './tdesign'
916
export * from './vant'
1017
export * from './varlet-ui'
1118
export * from './veui'
1219
export * from './view-ui'
1320
export * from './vuetify'
1421
export * from './vueuse'
1522
export * from './vueuse-directive'
16-
export * from './quasar'
17-
export * from './devui'
18-
export * from './arco'
19-
export * from './tdesign'
20-
export * from './layui-vue'
21-
export * from './bootstrap-vue'
22-
export * from './ionic'

src/core/resolvers/layui-vue.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { FilterPattern } from '@rollup/pluginutils'
2-
import { isExclude } from '../utils'
32
import type { ComponentInfo, ComponentResolver, SideEffectsInfo } from '../../types'
3+
import { isExclude } from '../utils'
44

55
const matchComponents = [
66
{

src/core/resolvers/quasar.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import type { ComponentResolver } from '../../types'
12
import { promises as fs } from 'node:fs'
23
import { resolveModule } from 'local-pkg'
3-
import type { ComponentResolver } from '../../types'
44

55
/**
66
* Resolver for Quasar

src/core/resolvers/varlet-ui.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { ComponentResolveResult, ComponentResolver } from '../../types'
1+
import type { ComponentResolver, ComponentResolveResult } from '../../types'
22
import { kebabCase } from '../utils'
33

44
export interface VarletUIResolverOptions {

src/core/resolvers/veui.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import type { ComponentResolver, SideEffectsInfo } from '../../types'
12
import { join, normalize } from 'node:path'
23
import { resolvePathSync } from 'mlly'
3-
import type { ComponentResolver, SideEffectsInfo } from '../../types'
44
import { camelCase, kebabCase, pascalCase } from '../utils'
55

66
interface VeuiPeerConfig {

src/core/resolvers/vueuse-directive.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
import type { ComponentResolver } from '../../types'
12
import { readFileSync } from 'node:fs'
23
import process from 'node:process'
34
import { resolveModule } from 'local-pkg'
4-
import type { ComponentResolver } from '../../types'
55

66
let directives: string[] | undefined
77

src/core/resolvers/vueuse.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
import type { ComponentResolver } from '../../types'
12
import { readFileSync } from 'node:fs'
23
import process from 'node:process'
34
import { resolveModule } from 'local-pkg'
4-
import type { ComponentResolver } from '../../types'
55

66
let components: string[] | undefined
77

src/core/transformer.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import Debug from 'debug'
2-
import MagicString from 'magic-string'
31
import type { TransformResult } from 'unplugin'
42
import type { SupportedTransformer } from '..'
53
import type { Transformer } from '../types'
6-
import { DISABLE_COMMENT } from './constants'
74
import type { Context } from './context'
5+
import Debug from 'debug'
6+
import MagicString from 'magic-string'
7+
import { DISABLE_COMMENT } from './constants'
88
import transformComponent from './transforms/component'
99
import transformDirectives from './transforms/directive'
1010

src/core/transforms/component.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import Debug from 'debug'
21
import type MagicString from 'magic-string'
3-
import { pascalCase, stringifyComponentImport } from '../utils'
2+
import type { SupportedTransformer } from '../..'
43
import type { Context } from '../context'
54
import type { ResolveResult } from '../transformer'
6-
import type { SupportedTransformer } from '../..'
5+
import Debug from 'debug'
6+
import { pascalCase, stringifyComponentImport } from '../utils'
77

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

src/core/transforms/directive/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import Debug from 'debug'
21
import type MagicString from 'magic-string'
3-
import { pascalCase, stringifyComponentImport } from '../../utils'
4-
import type { Context } from '../../context'
52
import type { SupportedTransformer } from '../../..'
3+
import type { Context } from '../../context'
4+
import Debug from 'debug'
65
import { DIRECTIVE_IMPORT_PREFIX } from '../../constants'
6+
import { pascalCase, stringifyComponentImport } from '../../utils'
77
import vue2Resolver from './vue2'
88
import vue3Resolver from './vue3'
99

src/core/transforms/directive/vue2.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import type {
88
VariableDeclaration,
99
} from '@babel/types'
1010
import type MagicString from 'magic-string'
11-
import { importModule, isPackageExists } from 'local-pkg'
1211
import type { ResolveResult } from '../../transformer'
12+
import { importModule, isPackageExists } from 'local-pkg'
1313

1414
/**
1515
* Get Vue 2 render function position

src/core/type-imports/detect.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { isPackageExists } from 'local-pkg'
2-
import { notNullish } from '@antfu/utils'
31
import type { ComponentInfo, TypeImport } from '../../types'
2+
import { notNullish } from '@antfu/utils'
3+
import { isPackageExists } from 'local-pkg'
44
import { TypeImportPresets } from '.'
55

66
export function detectTypeImports(): TypeImport[] {

src/core/unplugin.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
import type { ResolvedConfig, ViteDevServer } from 'vite'
2+
import type { Watching } from 'webpack'
3+
import type { Options, PublicPluginAPI } from '../types'
14
import { existsSync } from 'node:fs'
25
import process from 'node:process'
3-
import { createUnplugin } from 'unplugin'
46
import { createFilter } from '@rollup/pluginutils'
57
import chokidar from 'chokidar'
6-
import type { ResolvedConfig, ViteDevServer } from 'vite'
7-
import type { Watching } from 'webpack'
8-
import type { Options, PublicPluginAPI } from '../types'
8+
import { createUnplugin } from 'unplugin'
99
import { Context } from './context'
1010
import { shouldTransform, stringifyComponentImport } from './utils'
1111

src/core/utils.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1+
import type { FilterPattern } from '@rollup/pluginutils'
2+
import type { ComponentInfo, ImportInfo, ImportInfoLegacy, Options, ResolvedOptions } from '../types'
3+
import type { Context } from './context'
14
import { parse } from 'node:path'
25
import process from 'node:process'
3-
import { minimatch } from 'minimatch'
46
import { slash, toArray } from '@antfu/utils'
57
import {
68
getPackageInfo,
79
isPackageExists,
810
} from 'local-pkg'
9-
import type { FilterPattern } from '@rollup/pluginutils'
10-
import type { ComponentInfo, ImportInfo, ImportInfoLegacy, Options, ResolvedOptions } from '../types'
11-
import type { Context } from './context'
11+
import { minimatch } from 'minimatch'
1212
import { DISABLE_COMMENT } from './constants'
1313

1414
export const isSSR = Boolean(process.env.SSR || process.env.SSG || process.env.VITE_SSR || process.env.VITE_SSG)

src/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
export * from './types'
21
export { default } from './core/unplugin'
3-
export { camelCase, pascalCase, kebabCase } from './core/utils'
2+
export { camelCase, kebabCase, pascalCase } from './core/utils'
3+
export * from './types'

src/nuxt.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { addVitePlugin, addWebpackPlugin, defineNuxtModule } from '@nuxt/kit'
2-
31
// Workaround for:
42
// src/nuxt.ts(5,1): error TS2742: The inferred type of 'default' cannot be named without a reference to '.pnpm/@nuxt+schema@3.0.0_rollup@2.79.0/node_modules/@nuxt/schema'. This is likely not portable. A type annotation is necessary.
53
import type { } from '@nuxt/schema'
4+
65
import type { Options } from './types'
6+
import { addVitePlugin, addWebpackPlugin, defineNuxtModule } from '@nuxt/kit'
77
import unplugin from '.'
88

99
export default defineNuxtModule({

src/types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import type { Awaitable } from '@antfu/utils'
12
import type { FilterPattern } from '@rollup/pluginutils'
23
import type { TransformResult } from 'unplugin'
3-
import type { Awaitable } from '@antfu/utils'
44

55
export interface ImportInfoLegacy {
66
/**

test/dts.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
import type { ComponentResolver } from '../src'
12
import { readFile, writeFile } from 'node:fs/promises'
23
import path from 'node:path'
34
import { describe, expect, it } from 'vitest'
4-
import type { ComponentResolver } from '../src'
55
import { Context } from '../src/core/context'
66
import { getDeclaration, parseDeclaration } from '../src/core/declaration'
77

test/resolvers/arco.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
import type { ComponentResolveResult, ComponentResolverObject } from '../../src'
12
import { describe, expect, it } from 'vitest'
2-
import { ArcoResolver } from '../../src/resolvers'
33

4-
import type { ComponentResolveResult, ComponentResolverObject } from '../../src'
4+
import { ArcoResolver } from '../../src/resolvers'
55

66
function testNoIconComponentResolve(resolver: ComponentResolverObject) {
77
expect(resolver.resolve('AButton')).toEqual<ComponentResolveResult>({

test/resolvers/element-plus.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { describe, expect, it } from 'vitest'
2-
import { ElementPlusResolver } from '../../src/resolvers'
32
import { Context } from '../../src/core/context'
3+
import { ElementPlusResolver } from '../../src/resolvers'
44

55
describe('element Plus Resolver', () => {
66
it('components and directives should be transformed', async () => {

test/resolvers/tdesign.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
import type { ComponentResolverObject } from '../../src'
12
import { describe, expect, it } from 'vitest'
2-
import { TDesignResolver } from '../../src/resolvers'
33

4-
import type { ComponentResolverObject } from '../../src'
4+
import { TDesignResolver } from '../../src/resolvers'
55

66
describe('tDesignResolver', () => {
77
it('name matching string rule should not be resolved', async () => {

test/transform.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { describe, expect, it } from 'vitest'
21
import type { ComponentResolver } from '../src'
2+
import { describe, expect, it } from 'vitest'
33
import { Context } from '../src/core/context'
44

55
const resolver: ComponentResolver[] = [

test/utils.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { describe, expect, it } from 'vitest'
21
import type { ResolvedOptions } from '../src'
2+
import { describe, expect, it } from 'vitest'
33
import { getNameFromFilePath } from '../src/core/utils'
44

55
describe('getNameFromFilePath', () => {

0 commit comments

Comments
 (0)