Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function stringifyObject(obj, inline, lvl) {
if (Object.keys(obj).length > 0 || obj.length > 0) {
// eslint-disable-next-line array-callback-return
obj = traverse(obj).map(function(value) {
if (isValidElement(value) || this.isLeaf) {
this.update(formatValue(value, inline, lvl));
}
});
obj = sortobject(obj);
}
const stringified = stringify(obj);
if (inline) {
return collapse(stringified)
.replace(/{ /g, '{')
.replace(/ }/g, '}')
.replace(/\[ /g, '[')
.replace(/ ]/g, ']');
}
// Replace tabs with spaces, and add necessary indentation in front of each new line
return stringified
.replace(/\\\'/g, "'")
.replace(/\t/g, spacer(1, tabStop))
.replace(/\n([^$])/g, `\n${spacer(lvl + 1, tabStop)}$1`);
}
}
visit(ast, (node, index, parent) => {
const {type, identifier} = node
const normal = collapse(identifier).toUpperCase()
if (type === 'linkReference' || type === 'imageReference') {
references[normal] = true
} else if (type === 'definition') {
if (overwrite && identifiers.indexOf(normal) !== -1) {
parent.children.splice(index, 1)
return index
}
if (references[normal]) {
references[normal] = node
}
}
})
identifiers.forEach(identifier => {
const normal = collapse(identifier).toUpperCase()
const {url, label} = associations[normal]
if (references[normal] === true) {
ast.children.push({
type: 'definition',
url,
identifier: normal.toLowerCase(),
label
})
}
})
}
function jsxInclude({expected, actual}) {
this.assert(
~collapse(actual).indexOf(collapse(expected)),
`expected #{act} to contain ${inspect(expected)}`,
`expected #{act} to not contain ${inspect(expected)}`,
expected,
actual
)
}
toIncludeJSX(ReactElement) {
return expect(
collapse(reactElementToJSXString(this.actual))
).toInclude(
collapse(reactElementToJSXString(ReactElement))
);
},
toNotIncludeJSX(ReactElement) {
toNotIncludeJSX(ReactElement) {
return expect(
collapse(reactElementToJSXString(this.actual))
).toExclude(
collapse(reactElementToJSXString(ReactElement))
);
},
};
function jsxEql({expected, actual}) {
this.assert(
collapse(actual) === collapse(expected),
'expected #{act} to equal #{exp}',
'expected #{act} to not equal #{exp}',
expected,
actual,
true
)
}
const associations = Object.keys(bookmarks).reduce((map, label) => {
map[collapse(label).toUpperCase()] = {label, url: bookmarks[label]}
return map
}, {})