Skip to content

Commit d044441

Browse files
authored
chore: enable eslint recommended config (#1659)
Enables the recommended lint rules from `eslint`. Also deletes `getEnumerableProperties.js` which is no longer referenced.
1 parent 0fa4061 commit d044441

8 files changed

+66
-50
lines changed

eslint.config.js

+14
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

+5-5
Original file line numberDiff line numberDiff line change
@@ -2024,11 +2024,11 @@ Assertion.addMethod('property', assertProperty);
20242024

20252025
/**
20262026
*
2027-
* @param {unknown} name
2028-
* @param {unknown} value
2029-
* @param {string} msg
2027+
* @param {unknown} _name
2028+
* @param {unknown} _value
2029+
* @param {string} _msg
20302030
*/
2031-
function assertOwnProperty(name, value, msg) {
2031+
function assertOwnProperty(_name, _value, _msg) {
20322032
flag(this, 'own', true);
20332033
assertProperty.apply(this, arguments);
20342034
}
@@ -4052,7 +4052,7 @@ Assertion.addProperty('frozen', function () {
40524052
* @namespace BDD
40534053
* @public
40544054
*/
4055-
Assertion.addProperty('finite', function (msg) {
4055+
Assertion.addProperty('finite', function (_msg) {
40564056
var obj = flag(this, 'object');
40574057

40584058
this.assert(

lib/chai/interface/assert.js

+18-12
Original file line numberDiff line numberDiff line change
@@ -3164,16 +3164,22 @@ assert.isNotEmpty = function (val, msg) {
31643164
* @param {unknown} as
31653165
* @returns {unknown}
31663166
*/
3167-
(function alias(name, as) {
3167+
const aliases = [
3168+
['isOk', 'ok'],
3169+
['isNotOk', 'notOk'],
3170+
['throws', 'throw'],
3171+
['throws', 'Throw'],
3172+
['isExtensible', 'extensible'],
3173+
['isNotExtensible', 'notExtensible'],
3174+
['isSealed', 'sealed'],
3175+
['isNotSealed', 'notSealed'],
3176+
['isFrozen', 'frozen'],
3177+
['isNotFrozen', 'notFrozen'],
3178+
['isEmpty', 'empty'],
3179+
['isNotEmpty', 'notEmpty'],
3180+
['isCallable', 'isFunction'],
3181+
['isNotCallable', 'isNotFunction']
3182+
];
3183+
for (const [name, as] of aliases) {
31683184
assert[as] = assert[name];
3169-
return alias;
3170-
})('isOk', 'ok')('isNotOk', 'notOk')('throws', 'throw')('throws', 'Throw')(
3171-
'isExtensible',
3172-
'extensible'
3173-
)('isNotExtensible', 'notExtensible')('isSealed', 'sealed')(
3174-
'isNotSealed',
3175-
'notSealed'
3176-
)('isFrozen', 'frozen')('isNotFrozen', 'notFrozen')('isEmpty', 'empty')(
3177-
'isNotEmpty',
3178-
'notEmpty'
3179-
)('isCallable', 'isFunction')('isNotCallable', 'isNotFunction');
3185+
}

lib/chai/utils/getEnumerableProperties.js

-25
This file was deleted.

lib/chai/utils/index.js

+6
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,12 @@ export function isRegExp(obj) {
107107
return Object.prototype.toString.call(obj) === '[object RegExp]';
108108
}
109109

110+
/**
111+
* Determines if an object is numeric or not
112+
*
113+
* @param {unknown} obj Object to test
114+
* @returns {boolean}
115+
*/
110116
export function isNumeric(obj) {
111117
return ['Number', 'BigInt'].includes(type(obj));
112118
}

lib/chai/utils/proxify.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ export function proxify(obj, nonChainableMethodName) {
6464
var suggestionDistance = 4;
6565
getProperties(target).forEach(function (prop) {
6666
if (
67+
// we actually mean to check `Object.prototype` here
68+
// eslint-disable-next-line no-prototype-builtins
6769
!Object.prototype.hasOwnProperty(prop) &&
6870
builtins.indexOf(prop) === -1
6971
) {
@@ -128,17 +130,17 @@ function stringDistanceCapped(strA, strB, cap) {
128130
// `memo` is a two-dimensional array containing distances.
129131
// memo[i][j] is the distance between strA.slice(0, i) and
130132
// strB.slice(0, j).
131-
for (var i = 0; i <= strA.length; i++) {
133+
for (let i = 0; i <= strA.length; i++) {
132134
memo[i] = Array(strB.length + 1).fill(0);
133135
memo[i][0] = i;
134136
}
135-
for (var j = 0; j < strB.length; j++) {
137+
for (let j = 0; j < strB.length; j++) {
136138
memo[0][j] = j;
137139
}
138140

139-
for (var i = 1; i <= strA.length; i++) {
141+
for (let i = 1; i <= strA.length; i++) {
140142
var ch = strA.charCodeAt(i - 1);
141-
for (var j = 1; j <= strB.length; j++) {
143+
for (let j = 1; j <= strB.length; j++) {
142144
if (Math.abs(i - j) >= cap) {
143145
memo[i][j] = cap;
144146
continue;

package-lock.json

+16-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
"pathval": "^2.0.0"
5353
},
5454
"devDependencies": {
55+
"@eslint/js": "^9.17.0",
5556
"@rollup/plugin-commonjs": "^25.0.7",
5657
"@web/dev-server-rollup": "^0.6.1",
5758
"@web/test-runner": "^0.18.0",

0 commit comments

Comments
 (0)