Skip to content

Commit

Permalink
fix: TS support for eslint, type defs for utils
Browse files Browse the repository at this point in the history
  • Loading branch information
solaris007 committed Nov 29, 2023
1 parent 9d1a67d commit 5a25585
Show file tree
Hide file tree
Showing 5 changed files with 303 additions and 15 deletions.
25 changes: 23 additions & 2 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,27 @@

module.exports = {
root: true,
extends: '@adobe/helix',
plugins: ['import'],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module',
},
extends: [
'@adobe/helix',
'plugin:@typescript-eslint/recommended',
],
plugins: [
'import',
'@typescript-eslint',
],
overrides: [
{
files: ['*.ts'],
rules: {},
},
{
files: ['*.js', '*.cjs'],
rules: {},
},
],
};
233 changes: 231 additions & 2 deletions package-lock.json

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

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
"@semantic-release/changelog": "6.0.3",
"@semantic-release/git": "10.0.1",
"@semantic-release/npm": "9.0.2",
"@typescript-eslint/eslint-plugin": "6.13.1",
"@typescript-eslint/parser": "6.13.1",
"ajv": "8.12.0",
"c8": "8.0.1",
"eslint": "8.54.0",
Expand All @@ -41,7 +43,8 @@
"mocha-multi-reporters": "1.5.1",
"nock": "13.3.8",
"semantic-release": "19.0.5",
"semantic-release-monorepo": "7.0.5"
"semantic-release-monorepo": "7.0.5",
"typescript": "5.3.2"
},
"lint-staged": {
"*.js": "eslint"
Expand Down
20 changes: 10 additions & 10 deletions packages/spacecat-shared-utils/src/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,21 @@ function isNumber(value) {
/**
* Checks if the given parameter is an object and not an array or null.
*
* @param {*} obj - The object to check.
* @param {*} value - The value to check.
* @returns {boolean} True if the parameter is an object, false otherwise.
*/
function isObject(obj) {
return !Array.isArray(obj) && obj !== null && typeof obj === 'object';
function isObject(value) {
return !Array.isArray(value) && value !== null && typeof value === 'object';
}

/**
* Determines if the given parameter is a string.
*
* @param {*} str - The string to check.
* @param {*} value - The value to check.
* @returns {boolean} True if the parameter is a string, false otherwise.
*/
function isString(str) {
return (!!str || str === '') && typeof str === 'string';
function isString(value) {
return (!!value || value === '') && typeof value === 'string';
}

/**
Expand All @@ -73,17 +73,17 @@ function isString(str) {
* @returns {boolean} True if the string is not empty, false otherwise.
*/
function hasText(str) {
return !!str && typeof str === 'string';
return !!str && isString(str);
}

/**
* Checks whether the given object is a valid JavaScript Date.
*
* @param {*} obj - The object to check.
* @param {*} value - The value to check.
* @returns {boolean} True if the given object is a valid Date object, false otherwise.
*/
function isValidDate(obj) {
return obj instanceof Date && !Number.isNaN(obj.getTime());
function isValidDate(value) {
return value instanceof Date && !Number.isNaN(value.getTime());
}

/**
Expand Down
Loading

0 comments on commit 5a25585

Please sign in to comment.