Skip to content

Commit 63d203f

Browse files
authored
chore: fix lint errors and add lint to CI (#1689)
Fixes some leftover lint errors and adds lint to CI.
1 parent 3ac864e commit 63d203f

File tree

2 files changed

+52
-41
lines changed

2 files changed

+52
-41
lines changed

.github/workflows/node.js.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@ on:
1010
branches: [ main, 4.x.x ]
1111

1212
jobs:
13+
lint:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
- name: Use Node.js ${{ matrix.node-version }}
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: 22
21+
- run: npm ci
22+
- run: npm run lint
23+
1324
build:
1425

1526
runs-on: ubuntu-latest

lib/chai/assertion.js

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -11,43 +11,43 @@ import * as util from './utils/index.js';
1111

1212
export class Assertion {
1313
/** @type {{}} */
14-
__flags = {}
15-
16-
/**
17-
* Creates object for chaining.
18-
* `Assertion` objects contain metadata in the form of flags. Three flags can
19-
* be assigned during instantiation by passing arguments to this constructor:
20-
*
21-
* - `object`: This flag contains the target of the assertion. For example, in
22-
* the assertion `expect(numKittens).to.equal(7);`, the `object` flag will
23-
* contain `numKittens` so that the `equal` assertion can reference it when
24-
* needed.
25-
*
26-
* - `message`: This flag contains an optional custom error message to be
27-
* prepended to the error message that's generated by the assertion when it
28-
* fails.
29-
*
30-
* - `ssfi`: This flag stands for "start stack function indicator". It
31-
* contains a function reference that serves as the starting point for
32-
* removing frames from the stack trace of the error that's created by the
33-
* assertion when it fails. The goal is to provide a cleaner stack trace to
34-
* end users by removing Chai's internal functions. Note that it only works
35-
* in environments that support `Error.captureStackTrace`, and only when
36-
* `Chai.config.includeStack` hasn't been set to `false`.
37-
*
38-
* - `lockSsfi`: This flag controls whether or not the given `ssfi` flag
39-
* should retain its current value, even as assertions are chained off of
40-
* this object. This is usually set to `true` when creating a new assertion
41-
* from within another assertion. It's also temporarily set to `true` before
42-
* an overwritten assertion gets called by the overwriting assertion.
43-
*
44-
* - `eql`: This flag contains the deepEqual function to be used by the assertion.
45-
*
46-
* @param {unknown} obj target of the assertion
47-
* @param {string} [msg] (optional) custom error message
48-
* @param {Function} [ssfi] (optional) starting point for removing stack frames
49-
* @param {boolean} [lockSsfi] (optional) whether or not the ssfi flag is locked
50-
*/
14+
__flags = {};
15+
16+
/**
17+
* Creates object for chaining.
18+
* `Assertion` objects contain metadata in the form of flags. Three flags can
19+
* be assigned during instantiation by passing arguments to this constructor:
20+
*
21+
* - `object`: This flag contains the target of the assertion. For example, in
22+
* the assertion `expect(numKittens).to.equal(7);`, the `object` flag will
23+
* contain `numKittens` so that the `equal` assertion can reference it when
24+
* needed.
25+
*
26+
* - `message`: This flag contains an optional custom error message to be
27+
* prepended to the error message that's generated by the assertion when it
28+
* fails.
29+
*
30+
* - `ssfi`: This flag stands for "start stack function indicator". It
31+
* contains a function reference that serves as the starting point for
32+
* removing frames from the stack trace of the error that's created by the
33+
* assertion when it fails. The goal is to provide a cleaner stack trace to
34+
* end users by removing Chai's internal functions. Note that it only works
35+
* in environments that support `Error.captureStackTrace`, and only when
36+
* `Chai.config.includeStack` hasn't been set to `false`.
37+
*
38+
* - `lockSsfi`: This flag controls whether or not the given `ssfi` flag
39+
* should retain its current value, even as assertions are chained off of
40+
* this object. This is usually set to `true` when creating a new assertion
41+
* from within another assertion. It's also temporarily set to `true` before
42+
* an overwritten assertion gets called by the overwriting assertion.
43+
*
44+
* - `eql`: This flag contains the deepEqual function to be used by the assertion.
45+
*
46+
* @param {unknown} obj target of the assertion
47+
* @param {string} [msg] (optional) custom error message
48+
* @param {Function} [ssfi] (optional) starting point for removing stack frames
49+
* @param {boolean} [lockSsfi] (optional) whether or not the ssfi flag is locked
50+
*/
5151
constructor(obj, msg, ssfi, lockSsfi) {
5252
util.flag(this, 'ssfi', ssfi || Assertion);
5353
util.flag(this, 'lockSsfi', lockSsfi);
@@ -155,22 +155,22 @@ export class Assertion {
155155
* @returns {void}
156156
*/
157157
assert(_expr, msg, _negateMsg, expected, _actual, showDiff) {
158-
var ok = util.test(this, arguments);
158+
const ok = util.test(this, arguments);
159159
if (false !== showDiff) showDiff = true;
160160
if (undefined === expected && undefined === _actual) showDiff = false;
161161
if (true !== config.showDiff) showDiff = false;
162162

163163
if (!ok) {
164164
msg = util.getMessage(this, arguments);
165-
var actual = util.getActual(this, arguments);
165+
const actual = util.getActual(this, arguments);
166166
/** @type {Record<PropertyKey, unknown>} */
167-
var assertionErrorObjectProperties = {
167+
const assertionErrorObjectProperties = {
168168
actual: actual,
169169
expected: expected,
170170
showDiff: showDiff
171171
};
172172

173-
var operator = util.getOperator(this, arguments);
173+
const operator = util.getOperator(this, arguments);
174174
if (operator) {
175175
assertionErrorObjectProperties.operator = operator;
176176
}

0 commit comments

Comments
 (0)