Skip to content

Commit

Permalink
chore: fixing linting
Browse files Browse the repository at this point in the history
  • Loading branch information
Jocelyn Badgley (Twipped) committed May 28, 2024
1 parent 5d66947 commit 97e5e58
Show file tree
Hide file tree
Showing 46 changed files with 155 additions and 138 deletions.
6 changes: 6 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
"rules": {
"jsdoc/require-jsdoc": "warn",
"one-var": "off",
"no-param-reassign": "off",
"no-return-assign": "off",
"no-unused-expressions": "off",
"jsdoc/check-tag-names": [ "error", {
"jsxTags": true,
"definedTags": [
Expand All @@ -26,6 +29,9 @@
"files": [
"./tests/*"
],
"rules": {
"consistent-return": "off"
},
"extends": "@twipped/eslint-config/node-esm"
},
{
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"build:types": "tsc"
},
"engines": {
"node": ">=14.10.0"
"node": ">=18.18.0"
},
"author": "Jocelyn Badgley <[email protected]> (http://twipped.com)",
"license": "MIT",
Expand Down
10 changes: 5 additions & 5 deletions src/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default function assert (ok, message, ...substitutions) {
*
* @category Errors
*/
export const fail = /* #__PURE__ */(...args) => assert(false, ...args);
export const fail = /* #__PURE__ */(...args) => assert(false, ...args);


/**
Expand All @@ -54,7 +54,7 @@ export const fail = /* #__PURE__ */(...args) => assert(false, ...
* @throws Error
* @category Errors
*/
export const assertIsArray = /* #__PURE__ */(ok, ...args) => assert(isArray(ok), ...args);
export const assertIsArray = /* #__PURE__ */(ok, ...args) => assert(isArray(ok), ...args);

/**
* Tests if the first argument is object like, and throws the passed message if it is not.
Expand All @@ -67,7 +67,7 @@ export const assertIsArray = /* #__PURE__ */(ok, ...args) => assert(isArra
* @throws Error
* @category Errors
*/
export const assertIsObject = /* #__PURE__ */(ok, ...args) => assert(isObject(ok), ...args);
export const assertIsObject = /* #__PURE__ */(ok, ...args) => assert(isObject(ok), ...args);

/**
* Tests if the first argument is a plain object, and throws the passed message if it is not.
Expand All @@ -93,7 +93,7 @@ export const assertIsPlainObject = /* #__PURE__ */(ok, ...args) => assert(isObje
* @throws Error
* @category Errors
*/
export const assertIsString = /* #__PURE__ */(ok, ...args) => assert(isString(ok), ...args);
export const assertIsString = /* #__PURE__ */(ok, ...args) => assert(isString(ok), ...args);

/**
* Tests if the first argument is a number, and throws the passed message if it is not.
Expand All @@ -106,4 +106,4 @@ export const assertIsString = /* #__PURE__ */(ok, ...args) => assert(isStri
* @throws Error
* @category Errors
*/
export const assertIsNumber = /* #__PURE__ */(ok, ...args) => assert(isNumber(ok), ...args);
export const assertIsNumber = /* #__PURE__ */(ok, ...args) => assert(isNumber(ok), ...args);
2 changes: 1 addition & 1 deletion src/clamp.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { isDate } from './types.js';
* @returns {number|Date}
* @category Math
*/
export default function clamp (value, minv = -Infinity, maxv = Infinity, nearest) {
export default function clamp (value, minv = -Infinity, maxv = Infinity, nearest = undefined) {
if (value === undefined || value === null || value === '') return null;
if (minv === undefined || minv === null || minv === '') minv = -Infinity;
if (maxv === undefined || maxv === null || maxv === '') maxv = Infinity;
Expand Down
2 changes: 1 addition & 1 deletion src/clr.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* @function clr
* @param {string|Array<string>} input
* @param {Object} classMap
* @param {object} classMap
*
* @returns {string}
* @category Text
Expand Down
4 changes: 2 additions & 2 deletions src/collect.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import hasOwn from './hasOwn.js';
* Supports using wildcards in paths to iterate over all keys of an
* object or array.
*
* @param {Object|Array} target Structure to get a value from.
* @param {object | Array} target Structure to get a value from.
* @param {string|Array<string|number>} path Property Key, dot-notation path,
* or array of key names which describes the target value.
*
Expand All @@ -45,7 +45,7 @@ export default function collect (target, path) {
/**
* Object Descender
*
* @param {Object|Array} res Structure to get a value from.
* @param {object | Array} res Structure to get a value from.
* @param {string|Array<string|number>} level Property Key, dot-notation path,
* or array of key names which describes the target value.
* @private
Expand Down
2 changes: 1 addition & 1 deletion src/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import assert from './assert.js';

/**
* @typedef {Object} Unit
* @typedef {object} Unit
* @property {Array<string>} names
* @property {number} ratio
*/
Expand Down
1 change: 1 addition & 0 deletions src/dom.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-param-reassign */
/* global Predicate */

import iteratee from './iteratee.js';
Expand Down
12 changes: 6 additions & 6 deletions src/faccimilate.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ import nullIterator from './nullIterator.js';
*/
export default function faccimilate (collection, strict) {
switch (isString(collection) ? collection : mapMode(collection, strict)) {
case MAPMODE_ARRAY: return [];
case MAPMODE_SET: return new Set();
case MAPMODE_MAP: return new Map();
case MAPMODE_OBJECT: return {};
case MAPMODE_ARRAY: return [];
case MAPMODE_SET: return new Set();
case MAPMODE_MAP: return new Map();
case MAPMODE_OBJECT: return {};
case MAPMODE_ITERABLE: return { [Symbol.iterator]: nullIterator };
case MAPMODE_ITERATOR: return nullIterator();
case MAPMODE_STRING: return '';
default: return undefined;
case MAPMODE_STRING: return '';
default: return undefined;
}
}
1 change: 1 addition & 0 deletions src/findIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ export default function findIndex (collection, predicate) {
return false;
// no default
}
return undefined;
}
3 changes: 2 additions & 1 deletion src/fromPairs.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import mapReduce from './mapReduce.js';
* Produces a collection from an array of key/value tuples.
*
* @param {Array<Array<any,any>>} pairs
* @param {Object} options
* @param {object} options
* @param {MAPMODE} [options.mode] Type of collection to produce. Defaults to Object.
*
* @returns {Collection}
Expand All @@ -36,4 +36,5 @@ export default function fromPairs (pairs, { mode = MAPMODE_OBJECT } = {}) {

// no default
}
return undefined;
}
17 changes: 10 additions & 7 deletions src/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export async function isWritable (file) {
return true;
} catch (err) {
if (err.code === 'ENOENT') {
return await fs.access(dirname(file), fsConstants.F_OK | fsConstants.W_OK).then(() => true, () => false);
return fs.access(dirname(file), fsConstants.F_OK | fsConstants.W_OK).then(() => true, () => false);
}
return false;
}
Expand All @@ -35,14 +35,16 @@ export async function isWritable (file) {
* If the file already exists, its modification time will be updated.
*
* @param {string} file
* @returns {Promise}
*
* @category File System
*/
export async function touch (file) {
const stats = await linkStat(file);
if (stats) {
if (stats.isDirectory()) return; // nothing to do
return await fs.utimes(file, new Date, new Date);
fs.utimes(file, new Date, new Date);
return;
}

if (!await exists(dirname(file))) await mkdir(dirname(file));
Expand All @@ -54,12 +56,13 @@ export async function touch (file) {
* Deletes the file at the given path, if it exists.
*
* @param {string} file
* @returns {Promise}
*
* @category File System
*/
export async function remove (file) {
const stats = await linkStat(file);
if (!stats) return;
if (!stats) return undefined;
if (stats.isDirectory()) return fs.rmdir(file, { recursive: true });
return fs.unlink(file);
}
Expand All @@ -68,8 +71,8 @@ export async function remove (file) {
* Write the passed data structure to a file as JSON.
*
* @param {string} file
* @param {Object|Array} object
* @param {Object} [options] Options for fs.writeFile
* @param {object | Array} object
* @param {object} [options] Options for fs.writeFile
* @param {string} [options.encoding] File encoding for the data, defaults to utf8
*
* @alias writeJSON
Expand All @@ -88,12 +91,12 @@ export const writeJSON = writeJson;
* Reads a JSON file from disk and parses its contents.
*
* @param {string} file
* @param {Object} [options] Options for fs.readFile
* @param {object} [options] Options for fs.readFile
* @param {Function} [options.reviver]
* @param {boolean} [options.quiet]
* @param {string} [options.encoding] File encoding for the data, defaults to utf8
*
* @returns {Object|Array|string|number|boolean}
* @returns {object | Array | string | number | boolean}
* @alias readJSON
* @category File System
*/
Expand Down
2 changes: 1 addition & 1 deletion src/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const NOT_FOUND = Symbol('NOT_FOUND');
/**
* Deeply extracts a value from a nested object structure.
*
* @param {Object|Array} target Structure to get a value from.
* @param {object | Array} target Structure to get a value from.
* @param {string|Array<string|number>} path Property Key, dot-notation path,
* or array of key names which describes the target value.
* @param {any} [defaultValue] The value to return if the path
Expand Down
2 changes: 1 addition & 1 deletion src/has.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import parsePath from './parsePath.js';
* Deeply searches for a value in a nested object structure and returns true
* if a value is found.
*
* @param {Object|Array} target Structure to get a value from.
* @param {object | Array} target Structure to get a value from.
* @param {string|Array<string|number>} path Property Key, dot-notation path,
* or array of key names which describes the target value.
*
Expand Down
4 changes: 2 additions & 2 deletions src/hasOwn.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/**
* Shorthand, prototype safe way to test if an object's property is its own
*
* @param {Object} target Object to check
* @param {object} target Object to check
* @param {string} key Property key to check
*
* @returns {boolean}
* @category Data
*/
export default function hasOwn (target, key) {
return Object.prototype.hasOwnProperty.call(target, key);
return Object.hasOwn(target, key);
}
4 changes: 2 additions & 2 deletions src/hash.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export default function hash (input) {
}
let h = 0;
for (let i = 0; i < input.length; i += 1) {
const chr = input.charCodeAt(i);
h = ((h << 5) - h) + chr;
const chr = input.charCodeAt(i);
h = ((h << 5) - h) + chr;
h |= 0; // Convert to 32bit integer
}
return h;
Expand Down
20 changes: 10 additions & 10 deletions src/is.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ export const isa = (constructor) => (input) => input instanceof constructor;


const IS_LOOKUP = new Map([
[ Array, isArray ],
[ Number, isNumber ],
[ String, isString ],
[ Boolean, isBoolean ],
[ Map, isMap ],
[ Set, isSet ],
[ Date, isDate ],
[ RegExp, isRegExp ],
[ Array, isArray ],
[ Number, isNumber ],
[ String, isString ],
[ Boolean, isBoolean ],
[ Map, isMap ],
[ Set, isSet ],
[ Date, isDate ],
[ RegExp, isRegExp ],
[ undefined, isUndefined ],
[ true, isTruthy ],
[ false, isFalsey ],
[ true, isTruthy ],
[ false, isFalsey ],
]);

/**
Expand Down
Loading

0 comments on commit 97e5e58

Please sign in to comment.