Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
chore: enable eslint recommended config
Enables the recommended lint rules from `eslint`.

Also deletes `getEnumerableProperties.js` which is no longer referenced.
  • Loading branch information
43081j committed Jan 16, 2025
commit 39e600cce24d41a2a9c347f68a1e737ee6ef8eb8
14 changes: 14 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -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: "^_"
}]
},
},
];
10 changes: 5 additions & 5 deletions lib/chai/core/assertions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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(
Expand Down
30 changes: 18 additions & 12 deletions lib/chai/interface/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
25 changes: 0 additions & 25 deletions lib/chai/utils/getEnumerableProperties.js

This file was deleted.

6 changes: 6 additions & 0 deletions lib/chai/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
10 changes: 6 additions & 4 deletions lib/chai/utils/proxify.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
) {
Expand Down Expand Up @@ -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;
Expand Down
20 changes: 16 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading