Skip to content

Commit 4fa645b

Browse files
style: Require jsdoc check*, implements-on-classes, and some no-undefined-types (newrelic#3404)
1 parent 1008073 commit 4fa645b

File tree

16 files changed

+50
-32
lines changed

16 files changed

+50
-32
lines changed

eslint.config.js

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,28 +56,37 @@ const jsdocConfig = {
5656
// General rules
5757
'jsdoc/require-jsdoc': 'off',
5858
'jsdoc/tag-lines': 'off',
59+
'jsdoc/check-tag-names': 'error',
60+
'jsdoc/check-access': 'error',
61+
'jsdoc/implements-on-classes': 'error',
5962
// Types rules
6063
'jsdoc/check-types': 'error',
61-
'jsdoc/valid-types': 'error',
6264
'jsdoc/no-undefined-types': [
6365
'warn',
6466
{
6567
definedTypes: [
66-
'Logger',
6768
'Agent',
68-
'Shim',
69-
'MessageShim',
70-
'TraceSegment',
71-
'Transaction',
72-
'Tracer',
69+
'Context',
70+
'EventEmitter',
7371
'Exception',
72+
'Logger',
73+
'MessageShim',
7474
'MetricAggregator',
7575
'Metrics',
76-
'EventEmitter',
77-
'Context'
76+
'OperationSpec',
77+
'Segment',
78+
'Shim',
79+
'Spec',
80+
'Trace',
81+
'TraceSegment',
82+
'Tracer',
83+
'Transaction',
84+
'QuerySpec',
85+
'WebFrameworkShim'
7886
]
7987
}
8088
],
89+
'jsdoc/valid-types': 'error',
8190
// Parameter rules
8291
'jsdoc/require-param-description': 'error',
8392
'jsdoc/check-param-names': 'error',
@@ -98,7 +107,8 @@ const jsdocOverrides = {
98107
'api.js'
99108
],
100109
rules: {
101-
'jsdoc/require-jsdoc': 'warn'
110+
// Public-facing functions should always have jsdoc
111+
'jsdoc/require-jsdoc': 'error'
102112
}
103113
}
104114

lib/config/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1530,7 +1530,7 @@ function _laspReponse(keys) {
15301530
* Applies the server side LASP policies to a local configuration object
15311531
*
15321532
* @param {Agent} agent Agent instance
1533-
* @param {bject} policies server side LASP policy
1533+
* @param {object} policies server side LASP policy
15341534
* @returns {object} { missingRequired, finalPolicies } list of missing required fields and finalized LASP policy
15351535
*/
15361536
Config.prototype._buildLaspPolicy = function _buildLaspPolicy(agent, policies) {

lib/metrics/recorders/database-operation.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,12 @@ const metrics = require('../names')
1212
*
1313
* - `recordOperationMetrics(segment [, scope])`
1414
*
15+
* This function is an implementation of {@link MetricFunction} (see #agentlib/shim/shim.js)
1516
* @private
16-
* @this DatastoreShim
17-
* @implements {MetricFunction}
1817
* @param {TraceSegment} segment - The segment being recorded.
1918
* @param {string} [scope] - The scope of the segment.
19+
* @param {Transaction} transaction - The transaction associated with the segment.
2020
* @see DatastoreShim#recordOperation
21-
* @see MetricFunction
2221
*/
2322
function recordOperationMetrics(segment, scope, transaction) {
2423
const duration = segment.getDurationInMillis()

lib/shim/message-shim/consume.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ module.exports = createRecorder
2020
* @param {string} params.fnName name of function
2121
* @param {Array} params.args arguments passed to original consume function
2222
* @param {object} params.ctx this binding of the original function
23-
* @param {specs.MessageSpec} params.spec spec for the wrapped consume function
24-
* @returns {specs.MessageSpec} new spec
23+
* @param {MessageSpec} params.spec spec for the wrapped consume function
24+
* @returns {MessageSpec} new spec
2525
*/
2626
function updateSpecFromArgs({ shim, fn, fnName, args, spec, ctx }) {
2727
let msgDesc = null

lib/shim/promise-shim.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,6 @@ function _wrapExecutorContext(shim, args) {
382382
* @param {object} context context object
383383
* @param {Function} fn function that is wrapped
384384
* @returns {Function} wrapped function
385-
* @private
386385
*/
387386
function _wrapResolver(context, fn) {
388387
return function wrappedResolveReject(val) {

lib/shim/shim.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -242,12 +242,12 @@ Shim.prototype[symbols.unwrap] = unwrapAll
242242
*/
243243

244244
/**
245+
* Measures all the necessary metrics for the given segment. This functionality
246+
* is meant to be used by Shim subclasses; instrumentations should never create
247+
* their own recorders.
248+
*
245249
* @private
246250
* @callback MetricFunction
247-
* @summary
248-
* Measures all the necessary metrics for the given segment. This functionality
249-
* is meant to be used by Shim subclasses, instrumentations should never create
250-
* their own recorders.
251251
* @param {TraceSegment} segment - The segment to record.
252252
* @param {string} [scope] - The scope of the recording.
253253
*/
@@ -1239,7 +1239,7 @@ function applyContext({ func, context, full, boundThis, args, inContextCB }) {
12391239
this.logger.trace('Applying segment %s', segment.name)
12401240

12411241
/**
1242-
*
1242+
* Callback to be run in the context of the segment.
12431243
*/
12441244
function runInContextCb() {
12451245
if (typeof inContextCB === 'function') {

lib/shim/webframework-shim/index.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,12 +339,21 @@ function savePossibleTransactionName(req) {
339339
}
340340
}
341341

342+
/**
343+
* Predicate used to determine whether a middleware invocation constitutes a response.
344+
*
345+
* @typedef {Function} ResponsePredicate
346+
* @param {object[]} args - The arguments passed into the middleware.
347+
* @param {object} res - The value returned from the middleware (if any).
348+
* @returns {boolean} True if the invocation should be considered a response.
349+
*/
350+
342351
/**
343352
* Sets a function to call with the result of a middleware to determine if it has
344353
* responded.
345354
*
346355
* @memberof WebFrameworkShim.prototype
347-
* @param {function(args, object): boolean} pred
356+
* @param {ResponsePredicate} pred
348357
* Function which should return true if the object passed to it is considered
349358
* a response.
350359
*/

lib/spans/span-context.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class SpanContext {
4141
*
4242
* Last error wins.
4343
*
44-
* @param {Obejct} details error details
44+
* @param {object} details error details
4545
*/
4646
setError(details) {
4747
this.hasError = true

lib/spans/streaming-span-event.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ class StreamingHttpSpanEvent extends StreamingSpanEvent {
224224
* Currently designed to be sent over grpc via the v1.proto definition.
225225
*
226226
* @private
227-
* @class.
227+
* @class
228228
*/
229229
class StreamingDatastoreSpanEvent extends StreamingSpanEvent {
230230
/**

lib/transaction/trace/segment.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ function _setExclusiveDurationInMillis(duration) {
246246
* The duration of the transaction trace tree that only this level accounts
247247
* for.
248248
*
249-
* @returns {integer} The amount of time the trace took, minus any child
249+
* @returns {number} The amount of time the trace took, minus any child
250250
* segments, in milliseconds.
251251
*/
252252
TraceSegment.prototype.getExclusiveDurationInMillis = getExclusiveDurationInMillis

0 commit comments

Comments
 (0)