Skip to content

Commit 28bb84b

Browse files
authored
chore: remove unused function parameter (#56)
1 parent 0fce4b6 commit 28bb84b

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

packages/plugin-vue-jsx/src/index.ts

+12-18
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,13 @@ function vueJsxPlugin(options: Options = {}): Plugin {
136136
}
137137

138138
// check for hmr injection
139-
const declaredComponents: { name: string }[] = []
139+
const declaredComponents: string[] = []
140140
const hotComponents: HotComponent[] = []
141141
let hasDefault = false
142142

143143
for (const node of result.ast!.program.body) {
144144
if (node.type === 'VariableDeclaration') {
145-
const names = parseComponentDecls(node, code)
145+
const names = parseComponentDecls(node)
146146
if (names.length) {
147147
declaredComponents.push(...names)
148148
}
@@ -154,13 +154,11 @@ function vueJsxPlugin(options: Options = {}): Plugin {
154154
node.declaration.type === 'VariableDeclaration'
155155
) {
156156
hotComponents.push(
157-
...parseComponentDecls(node.declaration, code).map(
158-
({ name }) => ({
159-
local: name,
160-
exported: name,
161-
id: getHash(id + name),
162-
}),
163-
),
157+
...parseComponentDecls(node.declaration).map((name) => ({
158+
local: name,
159+
exported: name,
160+
id: getHash(id + name),
161+
})),
164162
)
165163
} else if (node.specifiers.length) {
166164
for (const spec of node.specifiers) {
@@ -169,7 +167,7 @@ function vueJsxPlugin(options: Options = {}): Plugin {
169167
spec.exported.type === 'Identifier'
170168
) {
171169
const matched = declaredComponents.find(
172-
({ name }) => name === spec.local.name,
170+
(name) => name === spec.local.name,
173171
)
174172
if (matched) {
175173
hotComponents.push({
@@ -186,12 +184,10 @@ function vueJsxPlugin(options: Options = {}): Plugin {
186184
if (node.type === 'ExportDefaultDeclaration') {
187185
if (node.declaration.type === 'Identifier') {
188186
const _name = node.declaration.name
189-
const matched = declaredComponents.find(
190-
({ name }) => name === _name,
191-
)
187+
const matched = declaredComponents.find((name) => name === _name)
192188
if (matched) {
193189
hotComponents.push({
194-
local: node.declaration.name,
190+
local: _name,
195191
exported: 'default',
196192
id: getHash(id + 'default'),
197193
})
@@ -255,13 +251,11 @@ function vueJsxPlugin(options: Options = {}): Plugin {
255251
}
256252
}
257253

258-
function parseComponentDecls(node: types.VariableDeclaration, source: string) {
254+
function parseComponentDecls(node: types.VariableDeclaration) {
259255
const names = []
260256
for (const decl of node.declarations) {
261257
if (decl.id.type === 'Identifier' && isDefineComponentCall(decl.init)) {
262-
names.push({
263-
name: decl.id.name,
264-
})
258+
names.push(decl.id.name)
265259
}
266260
}
267261
return names

0 commit comments

Comments
 (0)