chore: import upstream snapshot with attribution
tests / Test (macos-latest, 3.14) (push) Has been cancelled
tests / Test (ubuntu-latest, 3.10) (push) Has been cancelled
tests / Test (ubuntu-latest, 3.11) (push) Has been cancelled
tests / Test (windows-latest, 3.13) (push) Has been cancelled
tests / Test (windows-latest, 3.14) (push) Has been cancelled
tests / Validate (push) Has been cancelled
tests / Test (macos-latest, 3.10) (push) Has been cancelled
tests / Test (macos-latest, 3.11) (push) Has been cancelled
tests / Test (macos-latest, 3.12) (push) Has been cancelled
tests / Test (macos-latest, 3.13) (push) Has been cancelled
tests / Test (ubuntu-latest, 3.12) (push) Has been cancelled
tests / Test (ubuntu-latest, 3.13) (push) Has been cancelled
tests / Test (ubuntu-latest, 3.14) (push) Has been cancelled
tests / Test (windows-latest, 3.10) (push) Has been cancelled
tests / Test (windows-latest, 3.11) (push) Has been cancelled
tests / Test (windows-latest, 3.12) (push) Has been cancelled
universe validation / Validate (push) Has been cancelled
tests / Test (macos-latest, 3.14) (push) Has been cancelled
tests / Test (ubuntu-latest, 3.10) (push) Has been cancelled
tests / Test (ubuntu-latest, 3.11) (push) Has been cancelled
tests / Test (windows-latest, 3.13) (push) Has been cancelled
tests / Test (windows-latest, 3.14) (push) Has been cancelled
tests / Validate (push) Has been cancelled
tests / Test (macos-latest, 3.10) (push) Has been cancelled
tests / Test (macos-latest, 3.11) (push) Has been cancelled
tests / Test (macos-latest, 3.12) (push) Has been cancelled
tests / Test (macos-latest, 3.13) (push) Has been cancelled
tests / Test (ubuntu-latest, 3.12) (push) Has been cancelled
tests / Test (ubuntu-latest, 3.13) (push) Has been cancelled
tests / Test (ubuntu-latest, 3.14) (push) Has been cancelled
tests / Test (windows-latest, 3.10) (push) Has been cancelled
tests / Test (windows-latest, 3.11) (push) Has been cancelled
tests / Test (windows-latest, 3.12) (push) Has been cancelled
universe validation / Validate (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
const parseAttribute = (expression) => {
|
||||
if (expression.type !== 'AssignmentExpression' || !expression.left || !expression.right) {
|
||||
return
|
||||
}
|
||||
|
||||
const { left, right } = expression
|
||||
|
||||
if (left.type !== 'Identifier' || right.type !== 'Literal' || !left.name || !right.value) {
|
||||
return
|
||||
}
|
||||
|
||||
return [left.name, right.value]
|
||||
}
|
||||
|
||||
const getProps = (estree) => {
|
||||
if (estree.type !== 'Program' || !estree.body || estree.body.length <= 0 || !estree.body[0]) {
|
||||
return {}
|
||||
}
|
||||
|
||||
const estreeBodyFirstNode =
|
||||
estree.body[0].type === 'BlockStatement' ? estree.body[0].body[0] : estree.body[0]
|
||||
|
||||
if (estreeBodyFirstNode.type !== 'ExpressionStatement' || !estreeBodyFirstNode.expression) {
|
||||
return {}
|
||||
}
|
||||
|
||||
const statement = estreeBodyFirstNode.expression
|
||||
|
||||
const attributeExpressions = [
|
||||
...(statement.type === 'SequenceExpression' && statement.expressions
|
||||
? statement.expressions
|
||||
: []),
|
||||
...(statement.type === 'AssignmentExpression' ? [statement] : []),
|
||||
]
|
||||
|
||||
return Object.fromEntries(attributeExpressions.map(parseAttribute))
|
||||
}
|
||||
|
||||
export default getProps
|
||||
Reference in New Issue
Block a user