eslint-plugin-jsdoc
Advanced tools
Comparing version 48.10.1 to 48.10.2
@@ -155,3 +155,3 @@ { | ||
}, | ||
"version": "48.10.1" | ||
"version": "48.10.2" | ||
} |
@@ -23,2 +23,26 @@ import { | ||
/** | ||
* @param {string} potentialType | ||
*/ | ||
const checkForUsedTypes = (potentialType) => { | ||
let parsedType; | ||
try { | ||
parsedType = mode === 'permissive' ? | ||
tryParseType(/** @type {string} */ (potentialType)) : | ||
parseType(/** @type {string} */ (potentialType), 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); | ||
} | ||
}); | ||
}; | ||
/** | ||
* @param {import('@typescript-eslint/types').TSESTree.FunctionDeclaration| | ||
@@ -28,4 +52,5 @@ * import('@typescript-eslint/types').TSESTree.ClassDeclaration| | ||
* import('@typescript-eslint/types').TSESTree.TSTypeAliasDeclaration} aliasDeclaration | ||
* @param {boolean} [checkParamsAndReturns] | ||
*/ | ||
const checkParameters = (aliasDeclaration) => { | ||
const checkParameters = (aliasDeclaration, checkParamsAndReturns) => { | ||
/* c8 ignore next -- Guard */ | ||
@@ -36,2 +61,19 @@ const {params} = aliasDeclaration.typeParameters ?? {params: []}; | ||
} | ||
if (checkParamsAndReturns) { | ||
const paramName = /** @type {string} */ (utils.getPreferredTagName({ | ||
tagName: 'param', | ||
})); | ||
const paramTags = utils.getTags(paramName); | ||
for (const paramTag of paramTags) { | ||
checkForUsedTypes(paramTag.type); | ||
} | ||
const returnsName = /** @type {string} */ (utils.getPreferredTagName({ | ||
tagName: 'returns', | ||
})); | ||
const returnsTags = utils.getTags(returnsName); | ||
for (const returnsTag of returnsTags) { | ||
checkForUsedTypes(returnsTag.type); | ||
} | ||
} | ||
for (const tag of templateTags) { | ||
@@ -59,4 +101,6 @@ const {name} = tag; | ||
switch (nde.declaration?.type) { | ||
case 'FunctionDeclaration': | ||
checkParameters(nde.declaration, true); | ||
break; | ||
case 'ClassDeclaration': | ||
case 'FunctionDeclaration': | ||
case 'TSTypeAliasDeclaration': | ||
@@ -68,4 +112,6 @@ case 'TSInterfaceDeclaration': | ||
break; | ||
case 'FunctionDeclaration': | ||
checkParameters(nde, true); | ||
break; | ||
case 'ClassDeclaration': | ||
case 'FunctionDeclaration': | ||
case 'TSTypeAliasDeclaration': | ||
@@ -84,33 +130,9 @@ case 'TSInterfaceDeclaration': | ||
/** | ||
* @param {string} potentialType | ||
*/ | ||
const checkForUsedTypes = (potentialType) => { | ||
let parsedType; | ||
try { | ||
parsedType = mode === 'permissive' ? | ||
tryParseType(/** @type {string} */ (potentialType)) : | ||
parseType(/** @type {string} */ (potentialType), 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); | ||
} | ||
}); | ||
}; | ||
const potentialTypedefType = typedefTags[0].type; | ||
checkForUsedTypes(potentialTypedefType); | ||
const tagName = /** @type {string} */ (utils.getPreferredTagName({ | ||
const propertyName = /** @type {string} */ (utils.getPreferredTagName({ | ||
tagName: 'property', | ||
})); | ||
const propertyTags = utils.getTags(tagName); | ||
const propertyTags = utils.getTags(propertyName); | ||
for (const propertyTag of propertyTags) { | ||
@@ -117,0 +139,0 @@ checkForUsedTypes(propertyTag.type); |
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
2038376
33405