From 6d475ebfa9bf76250f290c00bf2a2b0f1ad276d6 Mon Sep 17 00:00:00 2001 From: snyk-bot Date: Sat, 22 Jun 2024 07:13:52 +0000 Subject: [PATCH 1/6] fix: upgrade eslint-config-expensify from 2.0.48 to 2.0.50 Snyk has created this PR to upgrade eslint-config-expensify from 2.0.48 to 2.0.50. See this package in npm: eslint-config-expensify See this project in Snyk: https://app.snyk.io/org/expensify/project/4945ebcf-d145-4524-893a-d9c905019a72?utm_source=github&utm_medium=referral&page=upgrade-pr --- package-lock.json | 127 ++-------------------------------------------- package.json | 2 +- 2 files changed, 6 insertions(+), 123 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8b75bb8b..57dc2cdc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -37,7 +37,7 @@ "babel-jest": "^29.0.0", "babelify": "10.0.0", "eslint": "^8.57.0", - "eslint-config-expensify": "^2.0.48", + "eslint-config-expensify": "^2.0.50", "eslint-config-prettier": "^8.10.0", "eslint-plugin-jest": "^28.6.0", "eslint-plugin-prettier": "^5.1.3", @@ -3380,24 +3380,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/@typescript-eslint/scope-manager": { - "version": "7.10.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-7.10.0.tgz", - "integrity": "sha512-7L01/K8W/VGl7noe2mgH0K7BE29Sq6KAbVmxurj8GGaPDZXPr8EEQ2seOeAS+mEV9DnzxBQB6ax6qQQ5C6P4xg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@typescript-eslint/types": "7.10.0", - "@typescript-eslint/visitor-keys": "7.10.0" - }, - "engines": { - "node": "^18.18.0 || >=20.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, "node_modules/@typescript-eslint/type-utils": { "version": "7.11.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-7.11.0.tgz", @@ -3526,75 +3508,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/@typescript-eslint/types": { - "version": "7.10.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.10.0.tgz", - "integrity": "sha512-7fNj+Ya35aNyhuqrA1E/VayQX9Elwr8NKZ4WueClR3KwJ7Xx9jcCdOrLW04h51de/+gNbyFMs+IDxh5xIwfbNg==", - "dev": true, - "license": "MIT", - "engines": { - "node": "^18.18.0 || >=20.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, - "node_modules/@typescript-eslint/typescript-estree": { - "version": "7.10.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-7.10.0.tgz", - "integrity": "sha512-LXFnQJjL9XIcxeVfqmNj60YhatpRLt6UhdlFwAkjNc6jSUlK8zQOl1oktAP8PlWFzPQC1jny/8Bai3/HPuvN5g==", - "dev": true, - "license": "BSD-2-Clause", - "dependencies": { - "@typescript-eslint/types": "7.10.0", - "@typescript-eslint/visitor-keys": "7.10.0", - "debug": "^4.3.4", - "globby": "^11.1.0", - "is-glob": "^4.0.3", - "minimatch": "^9.0.4", - "semver": "^7.6.0", - "ts-api-utils": "^1.3.0" - }, - "engines": { - "node": "^18.18.0 || >=20.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - } - } - }, - "node_modules/@typescript-eslint/typescript-estree/node_modules/brace-expansion": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", - "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", - "dev": true, - "license": "MIT", - "dependencies": { - "balanced-match": "^1.0.0" - } - }, - "node_modules/@typescript-eslint/typescript-estree/node_modules/minimatch": { - "version": "9.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.4.tgz", - "integrity": "sha512-KqWh+VchfxcMNRAJjj2tnsSJdNbHsVgnkBhTNrW7AjVo6OvLtxw8zfT9oLw1JSohlFzJ8jCoTgaoXvJ+kHt6fw==", - "dev": true, - "license": "ISC", - "dependencies": { - "brace-expansion": "^2.0.1" - }, - "engines": { - "node": ">=16 || 14 >=14.17" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/@typescript-eslint/utils": { "version": "7.11.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-7.11.0.tgz", @@ -3736,37 +3649,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/@typescript-eslint/visitor-keys": { - "version": "7.10.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.10.0.tgz", - "integrity": "sha512-9ntIVgsi6gg6FIq9xjEO4VQJvwOqA3jaBFQJ/6TK5AvEup2+cECI6Fh7QiBxmfMHXU0V0J4RyPeOU1VDNzl9cg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@typescript-eslint/types": "7.10.0", - "eslint-visitor-keys": "^3.4.3" - }, - "engines": { - "node": "^18.18.0 || >=20.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, - "node_modules/@typescript-eslint/visitor-keys/node_modules/eslint-visitor-keys": { - "version": "3.4.3", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", - "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", - "dev": true, - "license": "Apache-2.0", - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - } - }, "node_modules/@ungap/structured-clone": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.2.0.tgz", @@ -5585,10 +5467,11 @@ } }, "node_modules/eslint-config-expensify": { - "version": "2.0.48", - "resolved": "https://registry.npmjs.org/eslint-config-expensify/-/eslint-config-expensify-2.0.48.tgz", - "integrity": "sha512-PFegJ9Wfsiu5tgevhjA1toCxsZ8Etfk6pIjtXAnwpmVj7q4CtB3QDRusJoUDyJ3HrZr8AsFKViz7CU/CBTfwOw==", + "version": "2.0.50", + "resolved": "https://registry.npmjs.org/eslint-config-expensify/-/eslint-config-expensify-2.0.50.tgz", + "integrity": "sha512-I+OMkEprqEWlSCZGJBJxpt2Wg4HQ41/QqpKVfcADiQ3xJ76bZ1mBueqz6DR4jfph1xC6XVRl4dqGNlwbeU/2Rg==", "dev": true, + "license": "ISC", "dependencies": { "@lwc/eslint-plugin-lwc": "^1.7.2", "babel-eslint": "^10.1.0", diff --git a/package.json b/package.json index bc672ab4..10fe17e0 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "babel-jest": "^29.0.0", "babelify": "10.0.0", "eslint": "^8.57.0", - "eslint-config-expensify": "^2.0.48", + "eslint-config-expensify": "^2.0.50", "eslint-config-prettier": "^8.10.0", "eslint-plugin-jest": "^28.6.0", "eslint-plugin-prettier": "^5.1.3", From 68d26fe2af85a54ef27703a8e49691e2bd2ca12d Mon Sep 17 00:00:00 2001 From: Alberto Date: Mon, 24 Jun 2024 15:30:48 +0200 Subject: [PATCH 2/6] try a couple of changes --- lib/Cookie.jsx | 2 +- lib/components/form/element/combobox.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Cookie.jsx b/lib/Cookie.jsx index d2ae6f3c..656a5d6c 100644 --- a/lib/Cookie.jsx +++ b/lib/Cookie.jsx @@ -72,7 +72,7 @@ function enabled() { const cookieName = `cookieTest_${Math.floor(Math.random() * 1000)}`; const cookieValue = 'enabled'; set(cookieName, cookieValue, 1); - const result = Boolean(document.cookie.indexOf(cookieName) >= 0) || false; + const result = document.cookie.indexOf(cookieName) >= 0 || false; if (result) { remove(cookieName); } diff --git a/lib/components/form/element/combobox.js b/lib/components/form/element/combobox.js index 53a6e10b..8772ce8e 100644 --- a/lib/components/form/element/combobox.js +++ b/lib/components/form/element/combobox.js @@ -485,7 +485,7 @@ class Combobox extends React.Component { const formatOption = (option) => ({ focused: false, - isSelected: option.selected && (isEqual(option.value, currentValue) || Boolean(alreadySelected.find((item) => item.value === option.value))), + isSelected: option.selected && (isEqual(option.value, currentValue) || !!(alreadySelected.find((item) => item.value === option.value))), ...option, }); From fb53a8019caec4f12c20c72822037ffeeef3d841 Mon Sep 17 00:00:00 2001 From: Alberto Date: Mon, 24 Jun 2024 15:36:44 +0200 Subject: [PATCH 3/6] combobox style --- lib/components/form/element/combobox.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/components/form/element/combobox.js b/lib/components/form/element/combobox.js index 8772ce8e..2740dd77 100644 --- a/lib/components/form/element/combobox.js +++ b/lib/components/form/element/combobox.js @@ -551,7 +551,7 @@ class Combobox extends React.Component { const deselectOption = (initialOption) => { const option = initialOption; const isSelected = isEqual(option.value, val); - option.isSelected = isSelected || Boolean(this.props.alreadySelectedOptions.find((optionItem) => optionItem.value === option.value)); + option.isSelected = isSelected || !!(this.props.alreadySelectedOptions.find((optionItem) => optionItem.value === option.value)); return option; }; @@ -655,7 +655,7 @@ class Combobox extends React.Component { } const state = this.getStartState(noDefaultValue, this.options, newAlreadySelectedOptions); const handleDropdownStateChange = () => { - this.props.onDropdownStateChange(Boolean(state.isDropdownOpen)); + this.props.onDropdownStateChange(!!state.isDropdownOpen); }; this.setState(state, handleDropdownStateChange); } @@ -860,7 +860,7 @@ class Combobox extends React.Component { focused: false, isSelected: isEqual(option.value ? option.value.toUpperCase : '', value.toUpperCase()) || - Boolean(this.props.alreadySelectedOptions.find((optionItem) => optionItem.value === option.value)), + !!(this.props.alreadySelectedOptions.find((optionItem) => optionItem.value === option.value)), ...option, }); From 6b1268176a5df95e1d201d083a200cd42897be68 Mon Sep 17 00:00:00 2001 From: Alberto Date: Mon, 24 Jun 2024 15:44:14 +0200 Subject: [PATCH 4/6] str style --- lib/str.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/str.ts b/lib/str.ts index 210a72f5..13f8b4f5 100644 --- a/lib/str.ts +++ b/lib/str.ts @@ -350,7 +350,7 @@ const Str = { * @returns True if the string is a domain name */ isValidDomainName(str: string): boolean { - return Boolean(String(str).match(Constants.CONST.REG_EXP.DOMAIN)); + return !!String(str).match(Constants.CONST.REG_EXP.DOMAIN); }, /** @@ -359,7 +359,7 @@ const Str = { * @returns True if the string is a valid hyperlink */ isValidURL(str: string): boolean { - return Boolean(String(str).match(Constants.CONST.REG_EXP.HYPERLINK)); + return !!String(str).match(Constants.CONST.REG_EXP.HYPERLINK); }, /** @@ -371,7 +371,7 @@ const Str = { * @returns True if the string is an email */ isValidEmail(str: string): boolean { - return Boolean(String(str).match(Constants.CONST.REG_EXP.EMAIL)); + !!String(str).match(Constants.CONST.REG_EXP.EMAIL); }, /** @@ -382,7 +382,7 @@ const Str = { * @returns True if the string is an valid email created by comment markdown. */ isValidEmailMarkdown(str: string): boolean { - return Boolean(String(str).match(`^${Constants.CONST.REG_EXP.MARKDOWN_EMAIL}$`)); + return !!String(str).match(`^${Constants.CONST.REG_EXP.MARKDOWN_EMAIL}$`); }, /** @@ -818,7 +818,7 @@ const Str = { if (this.isString(value)) { return value.toLowerCase() === 'true'; } - return Boolean(value); + return !!value; }, /** From a645f85f95f9c675b2708508dd176f2cb5147578 Mon Sep 17 00:00:00 2001 From: Alberto Date: Mon, 24 Jun 2024 15:55:11 +0200 Subject: [PATCH 5/6] typo --- lib/str.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/str.ts b/lib/str.ts index 13f8b4f5..1b6af24f 100644 --- a/lib/str.ts +++ b/lib/str.ts @@ -371,7 +371,7 @@ const Str = { * @returns True if the string is an email */ isValidEmail(str: string): boolean { - !!String(str).match(Constants.CONST.REG_EXP.EMAIL); + return !!String(str).match(Constants.CONST.REG_EXP.EMAIL); }, /** From 9d8b39bac9b3ea834a687a0779f801b9813661d5 Mon Sep 17 00:00:00 2001 From: Alberto Date: Mon, 24 Jun 2024 16:23:14 +0200 Subject: [PATCH 6/6] prettier --- lib/components/form/element/combobox.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/components/form/element/combobox.js b/lib/components/form/element/combobox.js index 2740dd77..ae482a59 100644 --- a/lib/components/form/element/combobox.js +++ b/lib/components/form/element/combobox.js @@ -485,7 +485,7 @@ class Combobox extends React.Component { const formatOption = (option) => ({ focused: false, - isSelected: option.selected && (isEqual(option.value, currentValue) || !!(alreadySelected.find((item) => item.value === option.value))), + isSelected: option.selected && (isEqual(option.value, currentValue) || !!alreadySelected.find((item) => item.value === option.value)), ...option, }); @@ -551,7 +551,7 @@ class Combobox extends React.Component { const deselectOption = (initialOption) => { const option = initialOption; const isSelected = isEqual(option.value, val); - option.isSelected = isSelected || !!(this.props.alreadySelectedOptions.find((optionItem) => optionItem.value === option.value)); + option.isSelected = isSelected || !!this.props.alreadySelectedOptions.find((optionItem) => optionItem.value === option.value); return option; }; @@ -859,8 +859,7 @@ class Combobox extends React.Component { const formatOption = (option) => ({ focused: false, isSelected: - isEqual(option.value ? option.value.toUpperCase : '', value.toUpperCase()) || - !!(this.props.alreadySelectedOptions.find((optionItem) => optionItem.value === option.value)), + isEqual(option.value ? option.value.toUpperCase : '', value.toUpperCase()) || !!this.props.alreadySelectedOptions.find((optionItem) => optionItem.value === option.value), ...option, });