File tree Expand file tree Collapse file tree 3 files changed +34
-0
lines changed Expand file tree Collapse file tree 3 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -1115,5 +1115,15 @@ const Severities = {
11151115 */
11161116
11171117export default Severities ;
1118+
1119+ /**
1120+ * @template {unknown} T
1121+ * @param {unknown} value
1122+ * @param {...T} validValues
1123+ * @returns {value is T}
1124+ */
1125+ const checkIsOnOf = (value , ... validValues ) => {
1126+ return validValues .includes (value );
1127+ };
11181128````
11191129
Original file line number Diff line number Diff line change @@ -466,6 +466,16 @@ export default iterateJsdoc(({
466466 return utils . isNamepathOrUrlReferencingTag ( tag ) ;
467467 } ) . map ( tagToParsedType ( 'namepathOrURL' ) ) ;
468468
469+ const definedNamesAndNamepaths = new Set ( utils . filterTags ( ( {
470+ tag,
471+ } ) => {
472+ return utils . isNameOrNamepathDefiningTag ( tag ) ;
473+ } ) . map ( ( {
474+ name,
475+ } ) => {
476+ return name ;
477+ } ) ) ;
478+
469479 const tagsWithTypes = /** @type {TypeAndTagInfo[] } */ ( [
470480 ...typeTags ,
471481 ...namepathReferencingTags ,
@@ -520,6 +530,7 @@ export default iterateJsdoc(({
520530 if ( type === 'JsdocTypeName' ) {
521531 const structuredTypes = structuredTags [ tag . tag ] ?. type ;
522532 if ( ! allDefinedTypes . has ( val ) &&
533+ ! definedNamesAndNamepaths . has ( val ) &&
523534 ( ! Array . isArray ( structuredTypes ) || ! structuredTypes . includes ( val ) )
524535 ) {
525536 const parent =
Original file line number Diff line number Diff line change @@ -1891,5 +1891,18 @@ export default /** @type {import('../index.js').TestCases} */ ({
18911891 export default Severities;
18921892 ` ,
18931893 } ,
1894+ {
1895+ code : `
1896+ /**
1897+ * @template {unknown} T
1898+ * @param {unknown} value
1899+ * @param {...T} validValues
1900+ * @returns {value is T}
1901+ */
1902+ const checkIsOnOf = (value, ...validValues) => {
1903+ return validValues.includes(value);
1904+ };
1905+ ` ,
1906+ } ,
18941907 ] ,
18951908} ) ;
You can’t perform that action at this time.
0 commit comments