Bump packages to fix linter
This commit is contained in:
parent
ed9506bbaf
commit
0a11e3fdd9
6063 changed files with 378752 additions and 306784 deletions
36
node_modules/eslint-plugin-github/lib/utils/get-element-type.js
generated
vendored
Normal file
36
node_modules/eslint-plugin-github/lib/utils/get-element-type.js
generated
vendored
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
const {elementType, getProp, getPropValue} = require('jsx-ast-utils')
|
||||
|
||||
/*
|
||||
Allows custom component to be mapped to an element type.
|
||||
When a default is set, all instances of the component will be mapped to the default.
|
||||
If a prop determines the type, it can be specified with `props`.
|
||||
|
||||
For now, we only support the mapping of one prop type to an element type, rather than combinations of props.
|
||||
*/
|
||||
function getElementType(context, node) {
|
||||
const {settings} = context
|
||||
const rawElement = elementType(node)
|
||||
if (!settings) return rawElement
|
||||
|
||||
const componentMap = settings.github && settings.github.components
|
||||
if (!componentMap) return rawElement
|
||||
const component = componentMap[rawElement]
|
||||
if (!component) return rawElement
|
||||
let element = component.default ? component.default : rawElement
|
||||
|
||||
if (component.props) {
|
||||
const props = Object.entries(component.props)
|
||||
for (const [key, value] of props) {
|
||||
const propMap = value
|
||||
const propValue = getPropValue(getProp(node.attributes, key))
|
||||
const mapValue = propMap[propValue]
|
||||
|
||||
if (mapValue) {
|
||||
element = mapValue
|
||||
}
|
||||
}
|
||||
}
|
||||
return element
|
||||
}
|
||||
|
||||
module.exports = {getElementType}
|
||||
Loading…
Add table
Add a link
Reference in a new issue