Skip to content

Commit

Permalink
chore: enable eslint recommended config
Browse files Browse the repository at this point in the history
Enables the recommended lint rules from `eslint`.

Also deletes `getEnumerableProperties.js` which is no longer referenced.
  • Loading branch information
43081j committed Jan 7, 2025
1 parent 3bc02ee commit ec02d4f
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 61 deletions.
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: "^_"
}]
},
},
];
20 changes: 10 additions & 10 deletions lib/chai/core/assertions.js
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ Assertion.addProperty('callable', function () {
const negate = flag(this, 'negate');

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

const isCallable = ['Function', 'AsyncFunction', 'GeneratorFunction', 'AsyncGeneratorFunction'].includes(_.type(val));
Expand Down Expand Up @@ -1424,7 +1424,7 @@ function assertBelow (n, msg) {
if (doLength && objType !== 'map' && objType !== 'set') {
new Assertion(obj, flagMsg, ssfi, true).to.have.property('length');
}

if (!doLength && (objType === 'date' && nType !== 'date')) {
errorMessage = msgPrefix + 'the argument to below must be a date';
} else if (!_.isNumeric(n) && (doLength || _.isNumeric(obj))) {
Expand Down Expand Up @@ -1744,7 +1744,7 @@ function assertInstanceOf (constructor, msg) {
, 'expected #{this} to be an instance of ' + name
, 'expected #{this} to not be an instance of ' + name
);
};
}

Assertion.addMethod('instanceof', assertInstanceOf);
Assertion.addMethod('instanceOf', assertInstanceOf);
Expand Down Expand Up @@ -1951,11 +1951,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 @@ -2409,7 +2409,7 @@ function assertKeys (keys) {
actual = [];

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

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

flag(this, 'object', caughtErr);
};
}

Assertion.addMethod('throw', assertThrows);
Assertion.addMethod('throws', assertThrows);
Expand Down Expand Up @@ -3923,7 +3923,7 @@ Assertion.addProperty('frozen', function() {
* @namespace BDD
* @public
*/
Assertion.addProperty('finite', function(msg) {
Assertion.addProperty('finite', function() {
var obj = flag(this, 'object');

this.assert(
Expand Down
37 changes: 19 additions & 18 deletions lib/chai/interface/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ assert.isNotNumber = function (val, msg) {
*
* var cups = 2;
* assert.isNumeric(cups, 'how many cups');
*
*
* var cups = 10n;
* assert.isNumeric(cups, 'how many cups');
*
Expand Down Expand Up @@ -3031,21 +3031,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.

10 changes: 6 additions & 4 deletions lib/chai/utils/proxify.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,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 @@ -119,17 +121,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 @@ -49,6 +49,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

0 comments on commit ec02d4f

Please sign in to comment.