eslint-plugin-jsdoc
Advanced tools
Comparing version 48.8.2 to 48.8.3
@@ -147,3 +147,3 @@ { | ||
}, | ||
"version": "48.8.2" | ||
"version": "48.8.3" | ||
} |
@@ -67,24 +67,37 @@ import { | ||
const potentialType = typedefTags[0].type; | ||
/** | ||
* @param {string} potentialType | ||
*/ | ||
const checkForUsedTypes = (potentialType) => { | ||
let parsedType; | ||
try { | ||
parsedType = mode === 'permissive' ? | ||
tryParseType(/** @type {string} */ (potentialType)) : | ||
parseType(/** @type {string} */ (potentialType), mode); | ||
} catch { | ||
return; | ||
} | ||
let parsedType; | ||
try { | ||
parsedType = mode === 'permissive' ? | ||
tryParseType(/** @type {string} */ (potentialType)) : | ||
parseType(/** @type {string} */ (potentialType), mode) | ||
} catch { | ||
// Todo: Should handle types in @prop/erty | ||
return; | ||
traverse(parsedType, (nde) => { | ||
const { | ||
type, | ||
value, | ||
} = /** @type {import('jsdoc-type-pratt-parser').NameResult} */ (nde); | ||
if (type === 'JsdocTypeName' && (/^[A-Z]$/).test(value)) { | ||
usedNames.add(value); | ||
} | ||
}); | ||
}; | ||
const potentialTypedefType = typedefTags[0].type; | ||
checkForUsedTypes(potentialTypedefType); | ||
const tagName = /** @type {string} */ (utils.getPreferredTagName({ | ||
tagName: 'property', | ||
})); | ||
const propertyTags = utils.getTags(tagName); | ||
for (const propertyTag of propertyTags) { | ||
checkForUsedTypes(propertyTag.type); | ||
} | ||
traverse(parsedType, (nde) => { | ||
const { | ||
type, | ||
value, | ||
} = /** @type {import('jsdoc-type-pratt-parser').NameResult} */ (nde); | ||
if (type === 'JsdocTypeName' && (/^[A-Z]$/).test(value)) { | ||
usedNames.add(value); | ||
} | ||
}); | ||
for (const tag of templateTags) { | ||
@@ -91,0 +104,0 @@ const {name} = tag; |
@@ -78,28 +78,46 @@ import { | ||
const potentialType = typedefTags[0].type; | ||
const usedNameToTag = new Map(); | ||
let parsedType; | ||
try { | ||
parsedType = mode === 'permissive' ? | ||
tryParseType(/** @type {string} */ (potentialType)) : | ||
parseType(/** @type {string} */ (potentialType), mode) | ||
} catch { | ||
// Todo: Should handle types in @prop/erty | ||
return; | ||
/** | ||
* @param {import('comment-parser').Spec} potentialTag | ||
*/ | ||
const checkForUsedTypes = (potentialTag) => { | ||
let parsedType; | ||
try { | ||
parsedType = mode === 'permissive' ? | ||
tryParseType(/** @type {string} */ (potentialTag.type)) : | ||
parseType(/** @type {string} */ (potentialTag.type), mode) | ||
} catch { | ||
return; | ||
} | ||
traverse(parsedType, (nde) => { | ||
const { | ||
type, | ||
value, | ||
} = /** @type {import('jsdoc-type-pratt-parser').NameResult} */ (nde); | ||
if (type === 'JsdocTypeName' && (/^[A-Z]$/).test(value)) { | ||
usedNames.add(value); | ||
if (!usedNameToTag.has(value)) { | ||
usedNameToTag.set(value, potentialTag); | ||
} | ||
} | ||
}); | ||
}; | ||
const potentialTypedef = typedefTags[0]; | ||
checkForUsedTypes(potentialTypedef); | ||
const tagName = /** @type {string} */ (utils.getPreferredTagName({ | ||
tagName: 'property', | ||
})); | ||
const propertyTags = utils.getTags(tagName); | ||
for (const propertyTag of propertyTags) { | ||
checkForUsedTypes(propertyTag); | ||
} | ||
traverse(parsedType, (nde) => { | ||
const { | ||
type, | ||
value, | ||
} = /** @type {import('jsdoc-type-pratt-parser').NameResult} */ (nde); | ||
if (type === 'JsdocTypeName' && (/^[A-Z]$/).test(value)) { | ||
usedNames.add(value); | ||
} | ||
}); | ||
// Could check against whitelist/blacklist | ||
for (const usedName of usedNames) { | ||
if (!templateNames.includes(usedName)) { | ||
report(`Missing @template ${usedName}`, null, typedefTags[0]); | ||
report(`Missing @template ${usedName}`, null, usedNameToTag.get(usedName)); | ||
} | ||
@@ -106,0 +124,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1938940
31831