Skip to content

Commit 49af10a

Browse files
authored
Merge pull request #197 from golopot/fix-valid-types-link
fix: make valid-types ignore @link (fixes #143)
2 parents bcaf02e + c01f42e commit 49af10a

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2718,6 +2718,13 @@ function quux() {
27182718
*/
27192719
function quux() {
27202720

2721+
}
2722+
2723+
/**
2724+
* @see {@link foo}
2725+
*/
2726+
function quux() {
2727+
27212728
}
27222729
````
27232730

src/rules/validTypes.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,17 @@ import _ from 'lodash';
22
import {parse} from 'jsdoctypeparser';
33
import iterateJsdoc from '../iterateJsdoc';
44

5+
/** @param {string} tag */
6+
const isLink = (tag) => {
7+
return /^(@link|@linkcode|@linkplain|@tutorial) /.test(tag);
8+
};
9+
510
export default iterateJsdoc(({
611
jsdoc,
712
report
813
}) => {
914
_.forEach(jsdoc.tags, (tag) => {
10-
if (tag.type) {
15+
if (tag.type && !isLink(tag.type)) {
1116
try {
1217
parse(tag.type);
1318
} catch (error) {

test/rules/assertions/validTypes.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@ export default {
4545
*/
4646
function quux() {
4747
48+
}
49+
`
50+
},
51+
{
52+
code: `
53+
/**
54+
* @see {@link foo}
55+
*/
56+
function quux() {
57+
4858
}
4959
`
5060
}

0 commit comments

Comments
 (0)