Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
jsdocTagsWithPossibleType.forEach((tag) => {
let parsedType;
try {
parsedType = parseType(tag.type);
} catch (error) {
// On syntax error, will be handled by valid-types.
return;
}
traverse(parsedType, ({type, name}) => {
if (type === 'NAME') {
if (!allDefinedTypes.includes(name)) {
report(`The type '${name}' is undefined.`, null, tag);
} else if (!_.includes(extraTypes, name)) {
context.markVariableAsUsed(name);
}
}
});
});
}, {
jsdocTagsWithPossibleType.forEach((jsdocTag) => {
const invalidTypes = [];
let typeAst;
try {
typeAst = parse(jsdocTag.type);
} catch (error) {
return;
}
traverse(typeAst, (node, parentName, parentNode) => {
const {type, name} = node;
if (!['NAME', 'ANY'].includes(type)) {
return;
}
let nodeName = type === 'ANY' ? '*' : name;
const [hasMatchingPreferredType, typeName, isGenericMatch] = getPreferredTypeInfo(type, nodeName, parentName, parentNode);
let preferred;
if (hasMatchingPreferredType) {
const preferredSetting = preferredTypes[typeName];
nodeName = typeName === '[]' ? typeName : nodeName;
if (!preferredSetting) {
invalidTypes.push([nodeName]);
} else if (typeof preferredSetting === 'string') {