Skip to content

Commit 76b8406

Browse files
authored
fix(valid-types): avoid reporting for next (handled by own rule) (#1503)
1 parent 91f1c30 commit 76b8406

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

docs/rules/valid-types.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -902,5 +902,14 @@ function quux() {
902902
export function onGlobalEvent (selector, type, callback, options) {
903903
delegate(document, selector, type, callback, options)
904904
}
905+
906+
/**
907+
* Even if added to `structuredTags` as in our recommended config,
908+
* we don't want `valid-types` to report since
909+
* `jsdoc/require-next-type` already does this.
910+
* @next
911+
*/
912+
function a () {}
913+
// Settings: {"jsdoc":{"structuredTags":{"next":{"required":["type"]}}}}
905914
````
906915

src/rules/validTypes.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,10 @@ export default iterateJsdoc(({
328328

329329
// REQUIRED TYPE
330330
const mustHaveTypePosition = utils.tagMustHaveTypePosition(tag.tag, otherModeMaps);
331-
if (mustHaveTypePosition !== false && !tag.type) {
331+
if (mustHaveTypePosition !== false && !tag.type &&
332+
// Auto-added to settings and has own rule already, so don't duplicate
333+
tag.tag !== 'next'
334+
) {
332335
const modeInfo = mustHaveTypePosition === true ? '' : ` in "${mode}" mode`;
333336
report(`Tag @${tag.tag} must have a type${modeInfo}.`, null, tag);
334337

test/rules/assertions/validTypes.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1886,5 +1886,27 @@ export default /** @type {import('../index.js').TestCases} */ ({
18861886
}
18871887
`,
18881888
},
1889+
{
1890+
code: `
1891+
/**
1892+
* Even if added to \`structuredTags\` as in our recommended config,
1893+
* we don't want \`valid-types\` to report since
1894+
* \`jsdoc/require-next-type\` already does this.
1895+
* @next
1896+
*/
1897+
function a () {}
1898+
`,
1899+
settings: {
1900+
jsdoc: {
1901+
structuredTags: {
1902+
next: {
1903+
required: [
1904+
'type',
1905+
],
1906+
},
1907+
},
1908+
},
1909+
},
1910+
},
18891911
],
18901912
});

0 commit comments

Comments
 (0)