Skip to content

Commit ec02d4f

Browse files
committed
chore: enable eslint recommended config
Enables the recommended lint rules from `eslint`. Also deletes `getEnumerableProperties.js` which is no longer referenced.
1 parent 3bc02ee commit ec02d4f

File tree

7 files changed

+66
-61
lines changed

7 files changed

+66
-61
lines changed

eslint.config.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,26 @@
11
import jsdoc from "eslint-plugin-jsdoc";
2+
import eslintjs from "@eslint/js";
3+
4+
const {configs: eslintConfigs} = eslintjs;
25

36
export default [
47
jsdoc.configs["flat/recommended"],
8+
eslintConfigs["recommended"],
59
{
10+
languageOptions: {
11+
// if we ever use more globals than this, pull in the `globals` package
12+
globals: {
13+
console: false
14+
}
15+
},
616
rules: {
717
"jsdoc/require-param-description": "off",
818
"jsdoc/require-returns-description": "off",
919
"jsdoc/tag-lines": ["error", "any", { startLines: 1 }],
20+
"no-unused-vars": ["error", {
21+
argsIgnorePattern: "^_",
22+
caughtErrorsIgnorePattern: "^_"
23+
}]
1024
},
1125
},
1226
];

lib/chai/core/assertions.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,7 @@ Assertion.addProperty('callable', function () {
727727
const negate = flag(this, 'negate');
728728

729729
const assertionMessage = negate ?
730-
`${msg}expected ${_.inspect(val)} not to be a callable function` :
730+
`${msg}expected ${_.inspect(val)} not to be a callable function` :
731731
`${msg}expected ${_.inspect(val)} to be a callable function`;
732732

733733
const isCallable = ['Function', 'AsyncFunction', 'GeneratorFunction', 'AsyncGeneratorFunction'].includes(_.type(val));
@@ -1424,7 +1424,7 @@ function assertBelow (n, msg) {
14241424
if (doLength && objType !== 'map' && objType !== 'set') {
14251425
new Assertion(obj, flagMsg, ssfi, true).to.have.property('length');
14261426
}
1427-
1427+
14281428
if (!doLength && (objType === 'date' && nType !== 'date')) {
14291429
errorMessage = msgPrefix + 'the argument to below must be a date';
14301430
} else if (!_.isNumeric(n) && (doLength || _.isNumeric(obj))) {
@@ -1744,7 +1744,7 @@ function assertInstanceOf (constructor, msg) {
17441744
, 'expected #{this} to be an instance of ' + name
17451745
, 'expected #{this} to not be an instance of ' + name
17461746
);
1747-
};
1747+
}
17481748

17491749
Assertion.addMethod('instanceof', assertInstanceOf);
17501750
Assertion.addMethod('instanceOf', assertInstanceOf);
@@ -1951,11 +1951,11 @@ Assertion.addMethod('property', assertProperty);
19511951

19521952
/**
19531953
*
1954-
* @param {unknown} name
1955-
* @param {unknown} value
1956-
* @param {string} msg
1954+
* @param {unknown} _name
1955+
* @param {unknown} _value
1956+
* @param {string} _msg
19571957
*/
1958-
function assertOwnProperty (name, value, msg) {
1958+
function assertOwnProperty (_name, _value, _msg) {
19591959
flag(this, 'own', true);
19601960
assertProperty.apply(this, arguments);
19611961
}
@@ -2409,7 +2409,7 @@ function assertKeys (keys) {
24092409
actual = [];
24102410

24112411
// Map and Set '.keys' aren't supported in IE 11. Therefore, use .forEach.
2412-
obj.forEach(function (val, key) { actual.push(key) });
2412+
obj.forEach(function (_val, key) { actual.push(key) });
24132413

24142414
if (keysType !== 'Array') {
24152415
keys = Array.prototype.slice.call(arguments);
@@ -2808,7 +2808,7 @@ function assertThrows (errorLike, errMsgMatcher, msg) {
28082808
}
28092809

28102810
flag(this, 'object', caughtErr);
2811-
};
2811+
}
28122812

28132813
Assertion.addMethod('throw', assertThrows);
28142814
Assertion.addMethod('throws', assertThrows);
@@ -3923,7 +3923,7 @@ Assertion.addProperty('frozen', function() {
39233923
* @namespace BDD
39243924
* @public
39253925
*/
3926-
Assertion.addProperty('finite', function(msg) {
3926+
Assertion.addProperty('finite', function() {
39273927
var obj = flag(this, 'object');
39283928

39293929
this.assert(

lib/chai/interface/assert.js

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ assert.isNotNumber = function (val, msg) {
713713
*
714714
* var cups = 2;
715715
* assert.isNumeric(cups, 'how many cups');
716-
*
716+
*
717717
* var cups = 10n;
718718
* assert.isNumeric(cups, 'how many cups');
719719
*
@@ -3031,21 +3031,22 @@ assert.isNotEmpty = function(val, msg) {
30313031
* @param {unknown} as
30323032
* @returns {unknown}
30333033
*/
3034-
(function alias(name, as){
3034+
const aliases = [
3035+
['isOk', 'ok'],
3036+
['isNotOk', 'notOk'],
3037+
['throws', 'throw'],
3038+
['throws', 'Throw'],
3039+
['isExtensible', 'extensible'],
3040+
['isNotExtensible', 'notExtensible'],
3041+
['isSealed', 'sealed'],
3042+
['isNotSealed', 'notSealed'],
3043+
['isFrozen', 'frozen'],
3044+
['isNotFrozen', 'notFrozen'],
3045+
['isEmpty', 'empty'],
3046+
['isNotEmpty', 'notEmpty'],
3047+
['isCallable', 'isFunction'],
3048+
['isNotCallable', 'isNotFunction']
3049+
];
3050+
for (const [name, as] of aliases) {
30353051
assert[as] = assert[name];
3036-
return alias;
3037-
})
3038-
('isOk', 'ok')
3039-
('isNotOk', 'notOk')
3040-
('throws', 'throw')
3041-
('throws', 'Throw')
3042-
('isExtensible', 'extensible')
3043-
('isNotExtensible', 'notExtensible')
3044-
('isSealed', 'sealed')
3045-
('isNotSealed', 'notSealed')
3046-
('isFrozen', 'frozen')
3047-
('isNotFrozen', 'notFrozen')
3048-
('isEmpty', 'empty')
3049-
('isNotEmpty', 'notEmpty')
3050-
('isCallable', 'isFunction')
3051-
('isNotCallable', 'isNotFunction')
3052+
}

lib/chai/utils/getEnumerableProperties.js

Lines changed: 0 additions & 25 deletions
This file was deleted.

lib/chai/utils/proxify.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ export function proxify(obj ,nonChainableMethodName) {
5656
var suggestionDistance = 4;
5757
getProperties(target).forEach(function(prop) {
5858
if (
59+
// we actually mean to check `Object.prototype` here
60+
// eslint-disable-next-line no-prototype-builtins
5961
!Object.prototype.hasOwnProperty(prop) &&
6062
builtins.indexOf(prop) === -1
6163
) {
@@ -119,17 +121,17 @@ function stringDistanceCapped(strA, strB, cap) {
119121
// `memo` is a two-dimensional array containing distances.
120122
// memo[i][j] is the distance between strA.slice(0, i) and
121123
// strB.slice(0, j).
122-
for (var i = 0; i <= strA.length; i++) {
124+
for (let i = 0; i <= strA.length; i++) {
123125
memo[i] = Array(strB.length + 1).fill(0);
124126
memo[i][0] = i;
125127
}
126-
for (var j = 0; j < strB.length; j++) {
128+
for (let j = 0; j < strB.length; j++) {
127129
memo[0][j] = j;
128130
}
129131

130-
for (var i = 1; i <= strA.length; i++) {
132+
for (let i = 1; i <= strA.length; i++) {
131133
var ch = strA.charCodeAt(i - 1);
132-
for (var j = 1; j <= strB.length; j++) {
134+
for (let j = 1; j <= strB.length; j++) {
133135
if (Math.abs(i - j) >= cap) {
134136
memo[i][j] = cap;
135137
continue;

package-lock.json

Lines changed: 16 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"pathval": "^2.0.0"
5050
},
5151
"devDependencies": {
52+
"@eslint/js": "^9.17.0",
5253
"@rollup/plugin-commonjs": "^25.0.7",
5354
"@web/dev-server-rollup": "^0.6.1",
5455
"@web/test-runner": "^0.18.0",

0 commit comments

Comments
 (0)