Skip to content

Commit

Permalink
fix: just eslint fix
Browse files Browse the repository at this point in the history
  • Loading branch information
卢海宇 committed Jun 27, 2024
1 parent aebb8bb commit 11a5133
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
7 changes: 4 additions & 3 deletions src/core/declaration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import type { Context } from './context'
import { getTransformedPath } from './utils'
import { resolveTypeImports } from './type-imports/detect'

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

function extractImports(code: string) {
// eslint-disable-next-line regexp/no-super-linear-backtracking, regexp/no-misleading-capturing-group
return Object.fromEntries(Array.from(code.matchAll(/['"]?([^\s'"]+)['"]?\s*:\s*(.+?)[,;\n]/g)).map(i => [i[1], i[2]]))
}

Expand All @@ -26,11 +27,11 @@ export function parseDeclaration(code: string): DeclarationImports | undefined {
component: {},
directive: {},
}
const componentDeclaration = /export\s+interface\s+GlobalComponents\s*{(.*?)}/s.exec(code)?.[0]
const componentDeclaration = /export\s+interface\s+GlobalComponents\s*\{.*?\}/s.exec(code)?.[0]
if (componentDeclaration)
imports.component = extractImports(componentDeclaration)

const directiveDeclaration = /export\s+interface\s+ComponentCustomProperties\s*{(.*?)}/s.exec(code)?.[0]
const directiveDeclaration = /export\s+interface\s+ComponentCustomProperties\s*\{.*?\}/s.exec(code)?.[0]
if (directiveDeclaration)
imports.directive = extractImports(directiveDeclaration)

Expand Down
2 changes: 1 addition & 1 deletion src/core/resolvers/bootstrap-vue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ const COMPONENT_ALIASES: Record<string, string> = {
BBtnGroup: 'BButtonGroup',
BBtnToolbar: 'BButtonToolbar',
BCheck: 'BFormCheckbox',
BCheckGroup: 'BFormCheckboxGroup',
BCheckbox: 'BFormCheckbox',
BCheckboxGroup: 'BFormCheckboxGroup',
BCheckGroup: 'BFormCheckboxGroup',
BDatalist: 'BFormDatalist',
BDatepicker: 'BFormDatepicker',
BDd: 'BDropdown',
Expand Down
2 changes: 1 addition & 1 deletion src/core/resolvers/layui-vue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export interface LayuiVueResolverOptions {

const layuiRE = /^Lay[A-Z]/
const layerRE = /^(layer|LayLayer)$/
const iconsRE = /^([A-Z][\w]+Icon|LayIcon)$/
const iconsRE = /^([A-Z]\w+Icon)$/
let libName = '@layui/layui-vue'

function lowerCamelCase(str: string) {
Expand Down
4 changes: 2 additions & 2 deletions src/core/transforms/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const debug = Debug('unplugin-vue-components:transform:component')

function resolveVue2(code: string, s: MagicString) {
const results: ResolveResult[] = []
for (const match of code.matchAll(/\b(_c|h)\([\s\n\t]*['"](.+?)["']([,)])/g)) {
for (const match of code.matchAll(/\b(_c|h)\(\s*['"](.+?)["']([,)])/g)) {
const [full, renderFunctionName, matchedName, append] = match
if (match.index != null && matchedName && !matchedName.startsWith('_')) {
const start = match.index
Expand All @@ -30,7 +30,7 @@ function resolveVue3(code: string, s: MagicString) {
/**
* when using some plugin like plugin-vue-jsx, resolveComponent will be imported as resolveComponent1 to avoid duplicate import
*/
for (const match of code.matchAll(/_resolveComponent[0-9]*\("(.+?)"\)/g)) {
for (const match of code.matchAll(/_resolveComponent\d*\("(.+?)"\)/g)) {
const matchedName = match[1]
if (match.index != null && matchedName && !matchedName.startsWith('_')) {
const start = match.index
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export interface Options {
}

export type ResolvedOptions = Omit<
Required<Options>,
Required<Options>,
'resolvers' | 'extensions' | 'dirs' | 'globalComponentsDeclaration'
> & {
resolvers: ComponentResolverObject[]
Expand Down

0 comments on commit 11a5133

Please sign in to comment.