diff --git a/eslint.config.js b/eslint.config.js index c9017f6c..22339fce 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,12 +1,26 @@ import jsdoc from "eslint-plugin-jsdoc"; +import eslintjs from "@eslint/js"; + +const {configs: eslintConfigs} = eslintjs; export default [ jsdoc.configs["flat/recommended"], + eslintConfigs["recommended"], { + languageOptions: { + // if we ever use more globals than this, pull in the `globals` package + globals: { + console: false + } + }, rules: { "jsdoc/require-param-description": "off", "jsdoc/require-returns-description": "off", "jsdoc/tag-lines": ["error", "any", { startLines: 1 }], + "no-unused-vars": ["error", { + argsIgnorePattern: "^_", + caughtErrorsIgnorePattern: "^_" + }] }, }, ]; diff --git a/lib/chai/core/assertions.js b/lib/chai/core/assertions.js index f18da8a9..80a1ce7e 100644 --- a/lib/chai/core/assertions.js +++ b/lib/chai/core/assertions.js @@ -2024,11 +2024,11 @@ Assertion.addMethod('property', assertProperty); /** * - * @param {unknown} name - * @param {unknown} value - * @param {string} msg + * @param {unknown} _name + * @param {unknown} _value + * @param {string} _msg */ -function assertOwnProperty(name, value, msg) { +function assertOwnProperty(_name, _value, _msg) { flag(this, 'own', true); assertProperty.apply(this, arguments); } @@ -4052,7 +4052,7 @@ Assertion.addProperty('frozen', function () { * @namespace BDD * @public */ -Assertion.addProperty('finite', function (msg) { +Assertion.addProperty('finite', function (_msg) { var obj = flag(this, 'object'); this.assert( diff --git a/lib/chai/interface/assert.js b/lib/chai/interface/assert.js index 8f0fa9bc..07a6767f 100644 --- a/lib/chai/interface/assert.js +++ b/lib/chai/interface/assert.js @@ -3164,16 +3164,22 @@ assert.isNotEmpty = function (val, msg) { * @param {unknown} as * @returns {unknown} */ -(function alias(name, as) { +const aliases = [ + ['isOk', 'ok'], + ['isNotOk', 'notOk'], + ['throws', 'throw'], + ['throws', 'Throw'], + ['isExtensible', 'extensible'], + ['isNotExtensible', 'notExtensible'], + ['isSealed', 'sealed'], + ['isNotSealed', 'notSealed'], + ['isFrozen', 'frozen'], + ['isNotFrozen', 'notFrozen'], + ['isEmpty', 'empty'], + ['isNotEmpty', 'notEmpty'], + ['isCallable', 'isFunction'], + ['isNotCallable', 'isNotFunction'] +]; +for (const [name, as] of aliases) { assert[as] = assert[name]; - return alias; -})('isOk', 'ok')('isNotOk', 'notOk')('throws', 'throw')('throws', 'Throw')( - 'isExtensible', - 'extensible' -)('isNotExtensible', 'notExtensible')('isSealed', 'sealed')( - 'isNotSealed', - 'notSealed' -)('isFrozen', 'frozen')('isNotFrozen', 'notFrozen')('isEmpty', 'empty')( - 'isNotEmpty', - 'notEmpty' -)('isCallable', 'isFunction')('isNotCallable', 'isNotFunction'); +} diff --git a/lib/chai/utils/getEnumerableProperties.js b/lib/chai/utils/getEnumerableProperties.js deleted file mode 100644 index 46960524..00000000 --- a/lib/chai/utils/getEnumerableProperties.js +++ /dev/null @@ -1,25 +0,0 @@ -/*! - * Chai - getEnumerableProperties utility - * Copyright(c) 2012-2014 Jake Luer - * MIT Licensed - */ - -/** - * ### .getEnumerableProperties(object) - * - * This allows the retrieval of enumerable property names of an object, - * inherited or not. - * - * @param {object} object - * @returns {Array} - * @namespace Utils - * @name getEnumerableProperties - * @public - */ -module.exports = function getEnumerableProperties(object) { - var result = []; - for (var name in object) { - result.push(name); - } - return result; -}; diff --git a/lib/chai/utils/index.js b/lib/chai/utils/index.js index b9029bba..70d9f4c1 100644 --- a/lib/chai/utils/index.js +++ b/lib/chai/utils/index.js @@ -107,6 +107,12 @@ export function isRegExp(obj) { return Object.prototype.toString.call(obj) === '[object RegExp]'; } +/** + * Determines if an object is numeric or not + * + * @param {unknown} obj Object to test + * @returns {boolean} + */ export function isNumeric(obj) { return ['Number', 'BigInt'].includes(type(obj)); } diff --git a/lib/chai/utils/proxify.js b/lib/chai/utils/proxify.js index 19112f90..4c1cf695 100644 --- a/lib/chai/utils/proxify.js +++ b/lib/chai/utils/proxify.js @@ -64,6 +64,8 @@ export function proxify(obj, nonChainableMethodName) { var suggestionDistance = 4; getProperties(target).forEach(function (prop) { if ( + // we actually mean to check `Object.prototype` here + // eslint-disable-next-line no-prototype-builtins !Object.prototype.hasOwnProperty(prop) && builtins.indexOf(prop) === -1 ) { @@ -128,17 +130,17 @@ function stringDistanceCapped(strA, strB, cap) { // `memo` is a two-dimensional array containing distances. // memo[i][j] is the distance between strA.slice(0, i) and // strB.slice(0, j). - for (var i = 0; i <= strA.length; i++) { + for (let i = 0; i <= strA.length; i++) { memo[i] = Array(strB.length + 1).fill(0); memo[i][0] = i; } - for (var j = 0; j < strB.length; j++) { + for (let j = 0; j < strB.length; j++) { memo[0][j] = j; } - for (var i = 1; i <= strA.length; i++) { + for (let i = 1; i <= strA.length; i++) { var ch = strA.charCodeAt(i - 1); - for (var j = 1; j <= strB.length; j++) { + for (let j = 1; j <= strB.length; j++) { if (Math.abs(i - j) >= cap) { memo[i][j] = cap; continue; diff --git a/package-lock.json b/package-lock.json index b38faf0f..f44d3140 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,6 +16,7 @@ "pathval": "^2.0.0" }, "devDependencies": { + "@eslint/js": "^9.17.0", "@rollup/plugin-commonjs": "^25.0.7", "@web/dev-server-rollup": "^0.6.1", "@web/test-runner": "^0.18.0", @@ -549,12 +550,13 @@ } }, "node_modules/@eslint/js": { - "version": "8.56.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.56.0.tgz", - "integrity": "sha512-gMsVel9D7f2HLkBma9VbtzZRehRogVRfbr++f06nL2vnCGCNlzOD+/MUov/F4p8myyAHspEhVobgjpX64q5m6A==", + "version": "9.17.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.17.0.tgz", + "integrity": "sha512-Sxc4hqcs1kTu0iID3kcZDW3JHq2a77HO9P8CP6YEA/FpH3Ll8UXE2r/86Rz9YJLKme39S9vU5OWNjC6Xl0Cr3w==", "dev": true, + "license": "MIT", "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" } }, "node_modules/@humanwhocodes/config-array": { @@ -2999,6 +3001,16 @@ "url": "https://opencollective.com/eslint" } }, + "node_modules/eslint/node_modules/@eslint/js": { + "version": "8.56.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.56.0.tgz", + "integrity": "sha512-gMsVel9D7f2HLkBma9VbtzZRehRogVRfbr++f06nL2vnCGCNlzOD+/MUov/F4p8myyAHspEhVobgjpX64q5m6A==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + } + }, "node_modules/eslint/node_modules/ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", diff --git a/package.json b/package.json index f1d2c0cf..4af256d8 100644 --- a/package.json +++ b/package.json @@ -52,6 +52,7 @@ "pathval": "^2.0.0" }, "devDependencies": { + "@eslint/js": "^9.17.0", "@rollup/plugin-commonjs": "^25.0.7", "@web/dev-server-rollup": "^0.6.1", "@web/test-runner": "^0.18.0",