Skip to content

Commit 5d1b1d9

Browse files
style: Require jsdoc/valid-types and jsdoc/check-param-names (newrelic#3368)
1 parent 6ff70e4 commit 5d1b1d9

36 files changed

+99
-145
lines changed

eslint.config.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ const newrelicConfigOverrides = {
4545
}
4646

4747
const jsdocConfig = {
48+
settings: {
49+
jsdoc: {
50+
// This is explicity set, so we don't get TypeScript-specific linting errors.
51+
mode: 'jsdoc'
52+
}
53+
},
4854
plugins: { jsdoc },
4955
rules: {
5056
'jsdoc/require-jsdoc': 'off',
@@ -66,7 +72,9 @@ const jsdocConfig = {
6672
'EventEmitter'
6773
]
6874
}
69-
]
75+
],
76+
'jsdoc/valid-types': 'error',
77+
'jsdoc/check-param-names': 'error'
7078
}
7179
}
7280
const jsdocOverrides = {

lib/collector/parse-response.js

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,15 @@ const logger = require('../logger').child({ component: 'new_relic_response' })
1616
* about errors as possible, and to parse out the return value as often
1717
* as possible.
1818
*
19-
* @param string name Remote method name that was invoked.
20-
* @param ServerResponse response HTTP response stream
21-
* @param Function callback Function that will be called with any
22-
* error, the value returned by the server
23-
* (if any), and the raw JSON of the
24-
* server's response.
25-
* @param name
26-
* @param response
27-
* @param callback
28-
* @returns Function Another callback that is meant to be invoked with
29-
* any errors from reading the response stream, as
30-
* well as a string containing the full response.
19+
* @param {string} name Remote method name that was invoked.
20+
* @param {ServerResponse} response HTTP response stream
21+
* @param {Function} callback Function that will be called with any
22+
* error, the value returned by the server
23+
* (if any), and the raw JSON of the
24+
* server's response.
25+
* @returns {Function} Another callback that is meant to be invoked with
26+
* any errors from reading the response stream, as
27+
* well as a string containing the full response.
3128
*/
3229
module.exports = function parse(name, response, callback) {
3330
if (!callback) {

lib/collector/remote-method.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,8 @@ RemoteMethod.prototype.invoke = function invoke(payload, nrHeaders, callback) {
128128
* Take a serialized payload and create a response wrapper for it before
129129
* invoking the method on the collector.
130130
*
131-
* @param {string} methodName Name of method to invoke on collector.
132131
* @param {string} data Serialized payload.
133-
* @param {?object} nrHeaders NR request headers from connect response.
132+
* @param {object} nrHeaders NR request headers from connect response.
134133
* @param {Function} callback What to do next. Gets passed any error.
135134
*/
136135
RemoteMethod.prototype._post = function _post(data, nrHeaders, callback) {
@@ -282,6 +281,7 @@ RemoteMethod.prototype._safeRequest = function _safeRequest(options) {
282281
* Generate the request headers and wire up the request. There are many
283282
* parameters used to make a request:
284283
*
284+
* @param options
285285
* @param {string} options.host Hostname (or proxy hostname) for collector.
286286
* @param {string} options.port Port (or proxy port) for collector.
287287
* @param {string} options.path URL path for method being invoked on collector.
@@ -292,7 +292,6 @@ RemoteMethod.prototype._safeRequest = function _safeRequest(options) {
292292
* original callback given to .send).
293293
* @param {Function} options.onResponse Response handler for this request (created by
294294
* ._post).
295-
* @param options
296295
*/
297296
RemoteMethod.prototype._request = function _request(options) {
298297
const requestOptions = {

lib/config/formatters.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const formatters = module.exports
1010
* Splits a string by a ',' and trims whitespace
1111
*
1212
* @param {string} val config setting
13-
* @param {Array}
13+
* @returns {Array}
1414
*/
1515
formatters.array = function array(val) {
1616
return val.split(',').map((k) => k.trim())
@@ -39,8 +39,7 @@ formatters.float = function float(val) {
3939
/**
4040
* Parses a config setting as a boolean
4141
*
42-
* @param {string} val config setting
43-
* @param setting
42+
* @param {string} setting value of config setting
4443
* @returns {boolean}
4544
*/
4645
formatters.boolean = function boolean(setting) {

lib/instrumentation/core/http-outbound.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,7 @@ function applySegment({ opts, makeRequest, host, port, hostname, segment, config
289289
* events.
290290
*
291291
* @param {Agent} agent New Relic agent
292-
* @param {string} hostname host of outbound request
293-
* @param host
292+
* @param {string} host host of outbound request
294293
* @param {TraceSegment} segment outbound http segment
295294
* @param {http.IncomingMessage} request actual http outbound request
296295
*/

lib/metrics/normalizer.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,8 @@ util.inherits(MetricNormalizer, EventEmitter)
8888
* Convert the raw, de-serialized JSON response into a set of
8989
* NormalizationRules.
9090
*
91-
* @param object json The de-serialized JSON response sent on collector
91+
* @param {object} json The de-serialized JSON response sent on collector
9292
* connection.
93-
* @param json
9493
*/
9594
MetricNormalizer.prototype.load = function load(json) {
9695
if (json) {

lib/shim/datastore-shim.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ function captureInstanceAttributes(host, port, database) {
500500
/**
501501
* Parses the database name from a `USE` SQL query.
502502
*
503-
* @memberof DatastoreShim.prototype
503+
* @this DatastoreShim
504504
* @param {string} query - The SQL query to parse the database name from.
505505
* @returns {?string} The name of the database if it could be parsed, otherwise
506506
* `null`.

lib/shim/message-shim/subscribe-consume.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ function _nameMessageTransaction(shim, msgDesc) {
3838
* @param {Function} params.fn subscriber function
3939
* @param {specs.MessageSubscribeSpec} params.spec spec for subscriber
4040
* @param params.name
41-
* @param {boolean} params.destNameIsArg flag to state if destination is an argument
4241
* @returns {Function} wrapped subscribe function
4342
*/
4443
function createSubscriberWrapper({ shim, fn, spec, name }) {

lib/shim/promise-shim.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -366,9 +366,7 @@ function _wrapExecutorContext(shim, args) {
366366

367367
/**
368368
*
369-
* @param {Function} resolve function of promise
370-
* @param {Function} reject function of promise
371-
* @param {...any} args
369+
* @param {Object} args contains the `resolve` and `reject` functions of a promise
372370
*/
373371
function contextExporter(...args) {
374372
const [resolve, reject] = args

lib/shim/shim.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1453,8 +1453,7 @@ function isPromise(obj) {
14531453
* promise or async function
14541454
*
14551455
* @memberof Shim.prototype
1456-
* @param fn
1457-
* @param (function) function to test if async
1456+
* @param {function} fn function to test if async
14581457
* @returns {boolean} True if the function is an async function
14591458
*/
14601459
function isAsyncFunction(fn) {
@@ -1871,8 +1870,8 @@ function _makeBindWrapper(shim, func, context, full) {
18711870
* (i.e. `bindRowCallbackSegment` for `rowCallback`), but will fall back to the
18721871
* generic callback binding method, `bindCallbackSegment`, otherwise.
18731872
*
1874-
* @this *
18751873
* @private
1874+
* @this *
18761875
* @param {Shim} shim
18771876
* The shim performing this binding.
18781877
* @param {Function} fn

0 commit comments

Comments
 (0)