Skip to content

Commit 8475d2a

Browse files
author
Kristján Oddsson
authored
Set up ESLint for JSDoc comments (#1605)
* Set up ESLint * Fix violations
1 parent 936c0ca commit 8475d2a

36 files changed

+1753
-820
lines changed

eslint.config.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import jsdoc from "eslint-plugin-jsdoc";
2+
3+
export default [
4+
jsdoc.configs["flat/recommended"],
5+
{
6+
rules: {
7+
"jsdoc/require-param-description": "off",
8+
"jsdoc/require-returns-description": "off",
9+
"jsdoc/tag-lines": ["error", "any", { startLines: 1 }],
10+
},
11+
},
12+
];

lib/chai.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ export {AssertionError};
2323
*
2424
* Provides a way to extend the internals of Chai.
2525
*
26-
* @param {Function}
26+
* @param {Function} fn
2727
* @returns {this} for chaining
28-
* @api public
28+
* @public
2929
*/
3030
export function use(fn) {
3131
const exports = {

lib/chai/assertion.js

+28-28
Original file line numberDiff line numberDiff line change
@@ -18,37 +18,37 @@ import * as util from './utils/index.js';
1818
* be assigned during instantiation by passing arguments to this constructor:
1919
*
2020
* - `object`: This flag contains the target of the assertion. For example, in
21-
* the assertion `expect(numKittens).to.equal(7);`, the `object` flag will
22-
* contain `numKittens` so that the `equal` assertion can reference it when
23-
* needed.
21+
* the assertion `expect(numKittens).to.equal(7);`, the `object` flag will
22+
* contain `numKittens` so that the `equal` assertion can reference it when
23+
* needed.
2424
*
2525
* - `message`: This flag contains an optional custom error message to be
26-
* prepended to the error message that's generated by the assertion when it
27-
* fails.
26+
* prepended to the error message that's generated by the assertion when it
27+
* fails.
2828
*
2929
* - `ssfi`: This flag stands for "start stack function indicator". It
30-
* contains a function reference that serves as the starting point for
31-
* removing frames from the stack trace of the error that's created by the
32-
* assertion when it fails. The goal is to provide a cleaner stack trace to
33-
* end users by removing Chai's internal functions. Note that it only works
34-
* in environments that support `Error.captureStackTrace`, and only when
35-
* `Chai.config.includeStack` hasn't been set to `false`.
30+
* contains a function reference that serves as the starting point for
31+
* removing frames from the stack trace of the error that's created by the
32+
* assertion when it fails. The goal is to provide a cleaner stack trace to
33+
* end users by removing Chai's internal functions. Note that it only works
34+
* in environments that support `Error.captureStackTrace`, and only when
35+
* `Chai.config.includeStack` hasn't been set to `false`.
3636
*
3737
* - `lockSsfi`: This flag controls whether or not the given `ssfi` flag
38-
* should retain its current value, even as assertions are chained off of
39-
* this object. This is usually set to `true` when creating a new assertion
40-
* from within another assertion. It's also temporarily set to `true` before
41-
* an overwritten assertion gets called by the overwriting assertion.
38+
* should retain its current value, even as assertions are chained off of
39+
* this object. This is usually set to `true` when creating a new assertion
40+
* from within another assertion. It's also temporarily set to `true` before
41+
* an overwritten assertion gets called by the overwriting assertion.
4242
*
4343
* - `eql`: This flag contains the deepEqual function to be used by the assertion.
4444
*
45-
* @param {Mixed} obj target of the assertion
46-
* @param {String} msg (optional) custom error message
45+
* @param {unknown} obj target of the assertion
46+
* @param {string} msg (optional) custom error message
4747
* @param {Function} ssfi (optional) starting point for removing stack frames
48-
* @param {Boolean} lockSsfi (optional) whether or not the ssfi flag is locked
49-
* @api private
48+
* @param {boolean} lockSsfi (optional) whether or not the ssfi flag is locked
49+
* @returns {unknown}
50+
* @private
5051
*/
51-
5252
export function Assertion (obj, msg, ssfi, lockSsfi) {
5353
util.flag(this, 'ssfi', ssfi || Assertion);
5454
util.flag(this, 'lockSsfi', lockSsfi);
@@ -111,13 +111,13 @@ Assertion.overwriteChainableMethod = function (name, fn, chainingBehavior) {
111111
* Executes an expression and check expectations. Throws AssertionError for reporting if test doesn't pass.
112112
*
113113
* @name assert
114-
* @param {Philosophical} expression to be tested
115-
* @param {String|Function} message or function that returns message to display if expression fails
116-
* @param {String|Function} negatedMessage or function that returns negatedMessage to display if negated expression fails
117-
* @param {Mixed} expected value (remember to check for negation)
118-
* @param {Mixed} actual (optional) will default to `this.obj`
119-
* @param {Boolean} showDiff (optional) when set to `true`, assert will display a diff in addition to the message if expression fails
120-
* @api private
114+
* @param {unknown} expression to be tested
115+
* @param {string | Function} message or function that returns message to display if expression fails
116+
* @param {string | Function} negatedMessage or function that returns negatedMessage to display if negated expression fails
117+
* @param {unknown} expected value (remember to check for negation)
118+
* @param {unknown} actual (optional) will default to `this.obj`
119+
* @param {boolean} showDiff (optional) when set to `true`, assert will display a diff in addition to the message if expression fails
120+
* @private
121121
*/
122122

123123
Assertion.prototype.assert = function (expr, msg, negateMsg, expected, _actual, showDiff) {
@@ -152,7 +152,7 @@ Assertion.prototype.assert = function (expr, msg, negateMsg, expected, _actual,
152152
*
153153
* Quick reference to stored `actual` value for plugin developers.
154154
*
155-
* @api private
155+
* @private
156156
*/
157157
Object.defineProperty(Assertion.prototype, '_obj',
158158
{ get: function () {

lib/chai/config.js

+18-24
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@ export const config = {
99
*
1010
* chai.config.includeStack = true; // enable stack on error
1111
*
12-
* @param {Boolean}
13-
* @api public
12+
* @param {boolean}
13+
* @public
1414
*/
15-
1615
includeStack: false,
1716

1817
/**
@@ -24,10 +23,9 @@ export const config = {
2423
* will be true when the assertion has requested a diff
2524
* be shown.
2625
*
27-
* @param {Boolean}
28-
* @api public
26+
* @param {boolean}
27+
* @public
2928
*/
30-
3129
showDiff: true,
3230

3331
/**
@@ -46,10 +44,9 @@ export const config = {
4644
*
4745
* chai.config.truncateThreshold = 0; // disable truncating
4846
*
49-
* @param {Number}
50-
* @api public
47+
* @param {number}
48+
* @public
5149
*/
52-
5350
truncateThreshold: 40,
5451

5552
/**
@@ -66,10 +63,9 @@ export const config = {
6663
* This feature is automatically disabled regardless of this config value
6764
* in environments that don't support proxies.
6865
*
69-
* @param {Boolean}
70-
* @api public
66+
* @param {boolean}
67+
* @public
7168
*/
72-
7369
useProxy: true,
7470

7571
/**
@@ -87,9 +83,8 @@ export const config = {
8783
* chai.config.proxyExcludedKeys = ['then', 'inspect'];
8884
*
8985
* @param {Array}
90-
* @api public
86+
* @public
9187
*/
92-
9388
proxyExcludedKeys: ['then', 'catch', 'inspect', 'toJSON'],
9489

9590
/**
@@ -101,20 +96,19 @@ export const config = {
10196
*
10297
* // use a custom comparator
10398
* chai.config.deepEqual = (expected, actual) => {
104-
* return chai.util.eql(expected, actual, {
105-
* comparator: (expected, actual) => {
106-
* // for non number comparison, use the default behavior
107-
* if(typeof expected !== 'number') return null;
108-
* // allow a difference of 10 between compared numbers
109-
* return typeof actual === 'number' && Math.abs(actual - expected) < 10
110-
* }
111-
* })
99+
* return chai.util.eql(expected, actual, {
100+
* comparator: (expected, actual) => {
101+
* // for non number comparison, use the default behavior
102+
* if(typeof expected !== 'number') return null;
103+
* // allow a difference of 10 between compared numbers
104+
* return typeof actual === 'number' && Math.abs(actual - expected) < 10
105+
* }
106+
* })
112107
* };
113108
*
114109
* @param {Function}
115-
* @api public
110+
* @public
116111
*/
117-
118112
deepEqual: null
119113

120114
};

0 commit comments

Comments
 (0)