Skip to content

Commit 9e47ec1

Browse files
authored
Lint all type-containing tags. Fixes #380 (#477)
1 parent f00c7bd commit 9e47ec1

10 files changed

+24
-18
lines changed

lib/lint.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function lintComments(comment) {
4848
}
4949
}
5050

51-
if (tag.title === 'param' && tag.type) {
51+
if (tag.type && typeof tag.type === 'object') {
5252
checkCanonical(tag.type);
5353
}
5454
});

test/fixture/_multi-file-input.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@
303303
"lineNumber": 2,
304304
"type": {
305305
"type": "NameExpression",
306-
"name": "Number"
306+
"name": "number"
307307
}
308308
}
309309
],
@@ -328,7 +328,7 @@
328328
"column": 2
329329
}
330330
},
331-
"code": "/**\n * This function returns the number one.\n * @returns {Number} numberone\n */\nmodule.exports = function () {\n // this returns 1\n return 1;\n};\n"
331+
"code": "/**\n * This function returns the number one.\n * @returns {number} numberone\n */\nmodule.exports = function () {\n // this returns 1\n return 1;\n};\n"
332332
},
333333
"errors": [],
334334
"returns": [
@@ -387,7 +387,7 @@
387387
},
388388
"type": {
389389
"type": "NameExpression",
390-
"name": "Number"
390+
"name": "number"
391391
}
392392
}
393393
],

test/fixture/lint/lint.input.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33
* @param {Array<Number>} foo bar
44
* @param {Array<Number>} foo bar
55
* @param {Array|Number} foo bar
6+
* @returns {object} bad object return type
7+
* @type {Array<object>} bad object type
68
* @memberof notfound
79
*/
810

911
/**
1012
* @param {String} baz bar
13+
* @property {String} bad property
1114
* @private
1215
*/

test/fixture/lint/lint.output.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22
3:1 warning type Number found, number is standard
33
4:1 warning type Number found, number is standard
44
5:1 warning type Number found, number is standard
5-
6:1 warning @memberof reference to notfound not found
6-
9:1 warning could not determine @name for hierarchy
7-
10:1 warning type String found, string is standard
5+
6:1 warning type object found, Object is standard
6+
7:1 warning type object found, Object is standard
7+
8:1 warning @memberof reference to notfound not found
8+
11:1 warning could not determine @name for hierarchy
9+
12:1 warning type String found, string is standard
10+
13:1 warning type String found, string is standard
811

9-
8 warnings
12+
11 warnings

test/fixture/simple.input.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* This function returns the number one.
3-
* @returns {Number} numberone
3+
* @returns {number} numberone
44
*/
55
module.exports = function () {
66
// this returns 1

test/fixture/simple.output.github.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"lineNumber": 2,
6060
"type": {
6161
"type": "NameExpression",
62-
"name": "Number"
62+
"name": "number"
6363
}
6464
}
6565
],
@@ -84,7 +84,7 @@
8484
"column": 2
8585
}
8686
},
87-
"code": "/**\n * This function returns the number one.\n * @returns {Number} numberone\n */\nmodule.exports = function () {\n // this returns 1\n return 1;\n};\n",
87+
"code": "/**\n * This function returns the number one.\n * @returns {number} numberone\n */\nmodule.exports = function () {\n // this returns 1\n return 1;\n};\n",
8888
"github": "[github]",
8989
"path": "test/fixture/simple.input.js"
9090
},
@@ -145,7 +145,7 @@
145145
},
146146
"type": {
147147
"type": "NameExpression",
148-
"name": "Number"
148+
"name": "number"
149149
}
150150
}
151151
],

test/fixture/simple.output.github.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55
This function returns the number one.
66

7-
Returns **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** numberone
7+
Returns **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** numberone

test/fixture/simple.output.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"lineNumber": 2,
6060
"type": {
6161
"type": "NameExpression",
62-
"name": "Number"
62+
"name": "number"
6363
}
6464
}
6565
],
@@ -84,7 +84,7 @@
8484
"column": 2
8585
}
8686
},
87-
"code": "/**\n * This function returns the number one.\n * @returns {Number} numberone\n */\nmodule.exports = function () {\n // this returns 1\n return 1;\n};\n"
87+
"code": "/**\n * This function returns the number one.\n * @returns {number} numberone\n */\nmodule.exports = function () {\n // this returns 1\n return 1;\n};\n"
8888
},
8989
"errors": [],
9090
"returns": [
@@ -143,7 +143,7 @@
143143
},
144144
"type": {
145145
"type": "NameExpression",
146-
"name": "Number"
146+
"name": "number"
147147
}
148148
}
149149
],

test/fixture/simple.output.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
This function returns the number one.
44

5-
Returns **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** numberone
5+
Returns **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** numberone

test/fixture/simple.output.md.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"children": [
6464
{
6565
"type": "text",
66-
"value": "Number"
66+
"value": "number"
6767
}
6868
]
6969
}

0 commit comments

Comments
 (0)