Skip to content

Commit 3b9ee76

Browse files
committed
chore(require-explicit-slots): remove redundant getComponentSlotsFromDefine utility
1 parent 1dda641 commit 3b9ee76

File tree

2 files changed

+0
-112
lines changed

2 files changed

+0
-112
lines changed

lib/utils/index.js

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ const { getScope } = require('./scope')
2626
* @typedef {import('../../typings/eslint-plugin-vue/util-types/utils').ComponentInferTypeEmit} ComponentInferTypeEmit
2727
* @typedef {import('../../typings/eslint-plugin-vue/util-types/utils').ComponentUnknownEmit} ComponentUnknownEmit
2828
* @typedef {import('../../typings/eslint-plugin-vue/util-types/utils').ComponentEmit} ComponentEmit
29-
* @typedef {import('../../typings/eslint-plugin-vue/util-types/utils').ComponentArraySlot} ComponentArraySlot
30-
* @typedef {import('../../typings/eslint-plugin-vue/util-types/utils').ComponentObjectSlot} ComponentObjectSlot
3129
* @typedef {import('../../typings/eslint-plugin-vue/util-types/utils').ComponentTypeSlot} ComponentTypeSlot
3230
* @typedef {import('../../typings/eslint-plugin-vue/util-types/utils').ComponentInferTypeSlot} ComponentInferTypeSlot
3331
* @typedef {import('../../typings/eslint-plugin-vue/util-types/utils').ComponentUnknownSlot} ComponentUnknownSlot
@@ -3387,19 +3385,6 @@ function getComponentEmitsFromDefineEmits(context, node) {
33873385
* @return {ComponentSlot[]} Array of component slots
33883386
*/
33893387
function getComponentSlotsFromDefineSlots(context, node) {
3390-
if (node.arguments.length > 0) {
3391-
const defNode = getObjectOrArray(context, node.arguments[0])
3392-
if (defNode) {
3393-
return getComponentSlotsFromDefine(defNode)
3394-
}
3395-
return [
3396-
{
3397-
type: 'unknown',
3398-
slotName: null,
3399-
node: node.arguments[0]
3400-
}
3401-
]
3402-
}
34033388
const typeArguments =
34043389
'typeArguments' in node ? node.typeArguments : node.typeParameters
34053390
if (typeArguments && typeArguments.params.length > 0) {
@@ -3578,67 +3563,6 @@ function getComponentEmitsFromDefine(emitsNode) {
35783563
})
35793564
}
35803565

3581-
/**
3582-
* Get all slots by looking at all component's properties
3583-
* @param {ObjectExpression|ArrayExpression} slotsNode Object with slots definition
3584-
* @return {(ComponentArraySlot | ComponentObjectSlot | ComponentUnknownSlot)[]} Array of component slots
3585-
*/
3586-
function getComponentSlotsFromDefine(slotsNode) {
3587-
if (slotsNode.type === 'ObjectExpression') {
3588-
return slotsNode.properties.map(
3589-
/** @returns {ComponentArraySlot | ComponentObjectSlot | ComponentUnknownSlot} */
3590-
(slot) => {
3591-
if (!isProperty(slot)) {
3592-
return {
3593-
type: 'unknown',
3594-
slotName: null,
3595-
node: slot
3596-
}
3597-
}
3598-
const slotName = getStaticPropertyName(slot)
3599-
if (slotName != null) {
3600-
return {
3601-
type: 'object',
3602-
key: slot.key,
3603-
slotName,
3604-
value: skipTSAsExpression(slot.value),
3605-
node: slot
3606-
}
3607-
}
3608-
return {
3609-
type: 'object',
3610-
key: null,
3611-
slotName: null,
3612-
value: skipTSAsExpression(slot.value),
3613-
node: slot
3614-
}
3615-
}
3616-
)
3617-
}
3618-
3619-
return slotsNode.elements.filter(isDef).map((slot) => {
3620-
if (slot.type === 'Literal' || slot.type === 'TemplateLiteral') {
3621-
const slotName = getStringLiteralValue(slot)
3622-
if (slotName != null) {
3623-
return {
3624-
type: 'array',
3625-
key: slot,
3626-
slotName,
3627-
value: null,
3628-
node: slot
3629-
}
3630-
}
3631-
}
3632-
return {
3633-
type: 'array',
3634-
key: null,
3635-
slotName: null,
3636-
value: null,
3637-
node: slot
3638-
}
3639-
})
3640-
}
3641-
36423566
/**
36433567
* @param {RuleContext} context The rule context object.
36443568
* @param {ESNode} node

typings/eslint-plugin-vue/util-types/utils.ts

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -192,40 +192,6 @@ export type ComponentEmit =
192192
| ComponentInferTypeEmit
193193
| ComponentUnknownEmit
194194

195-
type ComponentArraySlotDetectName = {
196-
type: 'array'
197-
key: Literal | TemplateLiteral
198-
slotName: string
199-
node: Expression | SpreadElement
200-
}
201-
type ComponentArraySlotUnknownName = {
202-
type: 'array'
203-
key: null
204-
slotName: null
205-
node: Expression | SpreadElement
206-
}
207-
export type ComponentArraySlot =
208-
| ComponentArraySlotDetectName
209-
| ComponentArraySlotUnknownName
210-
211-
type ComponentObjectSlotDetectName = {
212-
type: 'object'
213-
key: Expression
214-
slotName: string
215-
value: Expression
216-
node: Property
217-
}
218-
type ComponentObjectSlotUnknownName = {
219-
type: 'object'
220-
key: null
221-
slotName: null
222-
value: Expression
223-
node: Property
224-
}
225-
export type ComponentObjectSlot =
226-
| ComponentObjectSlotDetectName
227-
| ComponentObjectSlotUnknownName
228-
229195
export type ComponentUnknownSlot = {
230196
type: 'unknown'
231197
slotName: null
@@ -246,8 +212,6 @@ export type ComponentInferTypeSlot = {
246212
}
247213

248214
export type ComponentSlot =
249-
| ComponentArraySlot
250-
| ComponentObjectSlot
251215
| ComponentTypeSlot
252216
| ComponentInferTypeSlot
253217
| ComponentUnknownSlot

0 commit comments

Comments
 (0)