Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add lint rule for conditional jsx rendering strict boolean checks #10516

Merged
merged 1 commit into from
Jan 10, 2025
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
4 changes: 2 additions & 2 deletions packages/fiori/src/DynamicPageTitle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,8 @@ class DynamicPageTitle extends UI5Element {
}
}

get _needsSeparator() {
return (this.navigationBar.length && this.actionsBar.length);
get _needsSeparator(): boolean {
return (this.navigationBar.length > 0 && this.actionsBar.length > 0);
}

prepareLayoutActions() {
Expand Down
4 changes: 2 additions & 2 deletions packages/fiori/src/UserMenuTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export default function UserMenuTemplate(this: UserMenu) {
<Button slot="header" class="ui5-pm-add-account-btn" design="Transparent" icon={addEmployee} onClick={this._handleAddAccountClick} tooltip={this._addAccountTooltip}/>
}
</div>
{this._otherAccounts.length &&
{this._otherAccounts.length > 0 &&
<List onItemClick={this._handleAccountSwitch}>
{this._otherAccounts.map(account =>
<ListItemCustom
Expand Down Expand Up @@ -108,7 +108,7 @@ export default function UserMenuTemplate(this: UserMenu) {
</Panel>
}

{this.menuItems.length &&
{this.menuItems.length > 0 &&
<List
class="ui5-user-menu-list"
selectionMode="None"
Expand Down
2 changes: 1 addition & 1 deletion packages/main/src/DialogTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default function DialogTemplate(this: Dialog) {

function beforeContent(this: Dialog) {
return (<>
{this._displayHeader &&
{!!this._displayHeader &&
<header>
<div
class="ui5-popup-header-root"
Expand Down
4 changes: 2 additions & 2 deletions packages/main/src/SliderBaseTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function SliderBaseTemplate(this: SliderBase, hooks?: {
{(hooks?.handlesAriaText || handlesAriaText).call(this)}

<div class="ui5-slider-inner">
{this.step && this.showTickmarks && <>
{!!this.step && this.showTickmarks && <>
<ul class="ui5-slider-tickmarks">
{this.tickmarksObject.map(tm => <>
{tm ?
Expand All @@ -34,7 +34,7 @@ export default function SliderBaseTemplate(this: SliderBase, hooks?: {
}
</>)}
</ul>
{this.labelInterval &&
{!!this.labelInterval &&
<ul class={{
"ui5-slider-labels": true,
"ui5-slider-hidden-labels": this._labelsOverlapping,
Expand Down
2 changes: 1 addition & 1 deletion packages/main/src/SuggestionListItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class SuggestionListItem extends ListItemStandard {
}

get hasDescription() {
return this.richDescription.length || this.description;
return this.richDescription.length > 0 || this.description;
}

get groupItem() {
Expand Down
2 changes: 1 addition & 1 deletion packages/main/src/TreeItemTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default function TreeItemTemplate(this: TreeItem, hooks?: Partial<ListIte
function listItemContent(this: TreeItem) {
return <>
<div class="ui5-li-text-wrapper">
{this._showTitle &&
{!!this._showTitle &&
<div part="title" class="ui5-li-title"> {this.text}</div>
}
</div>
Expand Down
2 changes: 2 additions & 0 deletions packages/tools/components-package/eslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ const getTsModeOverrides = () => {

const tsxConfiguration = JSON.parse(JSON.stringify(tsConfiguration));
tsxConfiguration.files = ["*.tsx"];
tsxConfiguration.plugins.push("jsx-no-leaked-values");
tsxConfiguration.rules = {
...tsxConfiguration.rules,
"jsx-no-leaked-values/jsx-no-leaked-values": "error",
"@typescript-eslint/unbound-method": "off", // to be able to attach on* listeners
"@typescript-eslint/no-misused-promises": "off", // to be able to have async event listeners
"operator-linebreak": "off",
Expand Down
1 change: 1 addition & 0 deletions packages/tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"eslint-config-airbnb-base": "^14.2.1",
"eslint-plugin-cypress": "^3.4.0",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-jsx-no-leaked-values": "^0.1.24",
"esprima": "^4.0.1",
"getopts": "^2.3.0",
"glob": "^7.1.6",
Expand Down
92 changes: 90 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2333,6 +2333,13 @@
resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.21.5.tgz#acad351d582d157bb145535db2a6ff53dd514b5c"
integrity sha512-tQd/1efJuzPC6rCFwEvLtci/xNFcTZknmXs98FYDfGE4wP9ClFV98nyKrzJKVPMhdDnjzLhdUyMX4PsQAPjwIw==

"@eslint-community/eslint-utils@^4.2.0":
version "4.4.1"
resolved "https://registry.yarnpkg.com/@eslint-community/eslint-utils/-/eslint-utils-4.4.1.tgz#d1145bf2c20132d6400495d6df4bf59362fd9d56"
integrity sha512-s3O3waFUrMV8P/XaF/+ZTp1X9XBZW1a4B97ZnjQF2KYWaFD2A8KyFBsrsfSjEmjn3RGWAIuvlneuZm3CUK3jbA==
dependencies:
eslint-visitor-keys "^3.4.3"

"@eslint-community/eslint-utils@^4.4.0":
version "4.4.0"
resolved "https://registry.yarnpkg.com/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz#a23514e8fb9af1269d5f7788aa556798d61c6b59"
Expand Down Expand Up @@ -4376,6 +4383,11 @@
resolved "https://registry.yarnpkg.com/@types/scheduler/-/scheduler-0.16.3.tgz#cef09e3ec9af1d63d2a6cc5b383a737e24e6dcf5"
integrity sha512-5cJ8CB4yAx7BH1oMvdU0Jh9lrEXyPkar6F9G/ERswkCuvP4KQZfZkSjcMbAICCpQTN4OuZn8tz0HiKv9TGZgrQ==

"@types/semver@^7.3.12":
version "7.5.8"
resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.5.8.tgz#8268a8c57a3e4abd25c165ecd36237db7948a55e"
integrity sha512-I8EUhyrgfLrcTkzV3TSsGyl1tSuPrEDzr0yd5m90UgNxQkyDXULk3b6MlQqTCpZpNtWe1K0hzclnZkTcLBe2UQ==

"@types/semver@^7.5.0":
version "7.5.4"
resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.5.4.tgz#0a41252ad431c473158b22f9bfb9a63df7541cff"
Expand Down Expand Up @@ -4552,6 +4564,13 @@
semver "^7.5.4"
ts-api-utils "^1.0.1"

"@typescript-eslint/experimental-utils@^5.36.1":
version "5.62.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-5.62.0.tgz#14559bf73383a308026b427a4a6129bae2146741"
integrity sha512-RTXpeB3eMkpoclG3ZHft6vG/Z30azNHuqY6wKPBHlVMZFuEvrtlEDe8gMqDb+SO+9hjC/pLekeSCryf9vMZlCw==
dependencies:
"@typescript-eslint/utils" "5.62.0"

"@typescript-eslint/parser@^6.9.0":
version "6.9.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-6.9.0.tgz#2b402cadeadd3f211c25820e5433413347b27391"
Expand All @@ -4563,6 +4582,14 @@
"@typescript-eslint/visitor-keys" "6.9.0"
debug "^4.3.4"

"@typescript-eslint/[email protected]":
version "5.62.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.62.0.tgz#d9457ccc6a0b8d6b37d0eb252a23022478c5460c"
integrity sha512-VXuvVvZeQCQb5Zgf4HAxc04q5j+WrNAtNh9OwCsCgpKqESMTu3tF/jhZ3xG6T4NZwWl65Bg8KuS2uEvhSfLl0w==
dependencies:
"@typescript-eslint/types" "5.62.0"
"@typescript-eslint/visitor-keys" "5.62.0"

"@typescript-eslint/[email protected]":
version "6.9.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-6.9.0.tgz#2626e9a7fe0e004c3e25f3b986c75f584431134e"
Expand All @@ -4581,11 +4608,29 @@
debug "^4.3.4"
ts-api-utils "^1.0.1"

"@typescript-eslint/[email protected]":
version "5.62.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.62.0.tgz#258607e60effa309f067608931c3df6fed41fd2f"
integrity sha512-87NVngcbVXUahrRTqIK27gD2t5Cu1yuCXxbLcFtCzZGlfyVWWh8mLHkoxzjsB6DDNnvdL+fW8MiwPEJyGJQDgQ==

"@typescript-eslint/[email protected]":
version "6.9.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-6.9.0.tgz#86a0cbe7ac46c0761429f928467ff3d92f841098"
integrity sha512-+KB0lbkpxBkBSiVCuQvduqMJy+I1FyDbdwSpM3IoBS7APl4Bu15lStPjgBIdykdRqQNYqYNMa8Kuidax6phaEw==

"@typescript-eslint/[email protected]":
version "5.62.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.62.0.tgz#7d17794b77fabcac615d6a48fb143330d962eb9b"
integrity sha512-CmcQ6uY7b9y694lKdRB8FEel7JbU/40iSAPomu++SjLMntB+2Leay2LO6i8VnJk58MtE9/nQSFIH6jpyRWyYzA==
dependencies:
"@typescript-eslint/types" "5.62.0"
"@typescript-eslint/visitor-keys" "5.62.0"
debug "^4.3.4"
globby "^11.1.0"
is-glob "^4.0.3"
semver "^7.3.7"
tsutils "^3.21.0"

"@typescript-eslint/[email protected]":
version "6.9.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-6.9.0.tgz#d0601b245be873d8fe49f3737f93f8662c8693d4"
Expand All @@ -4599,6 +4644,20 @@
semver "^7.5.4"
ts-api-utils "^1.0.1"

"@typescript-eslint/[email protected]":
version "5.62.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.62.0.tgz#141e809c71636e4a75daa39faed2fb5f4b10df86"
integrity sha512-n8oxjeb5aIbPFEtmQxQYOLI0i9n5ySBEY/ZEHHZqKQSFnxio1rv6dthascc9dLuwrL0RC5mPCxB7vnAVGAYWAQ==
dependencies:
"@eslint-community/eslint-utils" "^4.2.0"
"@types/json-schema" "^7.0.9"
"@types/semver" "^7.3.12"
"@typescript-eslint/scope-manager" "5.62.0"
"@typescript-eslint/types" "5.62.0"
"@typescript-eslint/typescript-estree" "5.62.0"
eslint-scope "^5.1.1"
semver "^7.3.7"

"@typescript-eslint/[email protected]":
version "6.9.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-6.9.0.tgz#5bdac8604fca4823f090e4268e681c84d3597c9f"
Expand All @@ -4612,6 +4671,14 @@
"@typescript-eslint/typescript-estree" "6.9.0"
semver "^7.5.4"

"@typescript-eslint/[email protected]":
version "5.62.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.62.0.tgz#2174011917ce582875954ffe2f6912d5931e353e"
integrity sha512-07ny+LHRzQXepkGg6w0mFY41fVUNBrL2Roj/++7V1txKugfjm/Ci/qSND03r2RhlJhJYMcTn9AhhSSqQp0Ysyw==
dependencies:
"@typescript-eslint/types" "5.62.0"
eslint-visitor-keys "^3.3.0"

"@typescript-eslint/[email protected]":
version "6.9.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-6.9.0.tgz#cc69421c10c4ac997ed34f453027245988164e80"
Expand Down Expand Up @@ -8460,6 +8527,15 @@ eslint-plugin-import@^2.31.0:
string.prototype.trimend "^1.0.8"
tsconfig-paths "^3.15.0"

eslint-plugin-jsx-no-leaked-values@^0.1.24:
version "0.1.24"
resolved "https://registry.yarnpkg.com/eslint-plugin-jsx-no-leaked-values/-/eslint-plugin-jsx-no-leaked-values-0.1.24.tgz#5503c11c5f019d17c86ee65df926df2fc8f71109"
integrity sha512-gr81LxBZlWu+YsbdaoG6ruRN/wKPTLhuhZGrX95hgCNMoiyfPv4Xw/PFw8xR/sYOIIAGgrkuv38XFT0KrfSMWw==
dependencies:
"@typescript-eslint/experimental-utils" "^5.36.1"
ts-pattern "^4.0.5"
tsutils "^3.21.0"

[email protected], eslint-scope@^5.1.1:
version "5.1.1"
resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c"
Expand Down Expand Up @@ -8490,7 +8566,7 @@ eslint-visitor-keys@^3.3.0:
resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.4.1.tgz#c22c48f48942d08ca824cc526211ae400478a994"
integrity sha512-pZnmmLwYzf+kWaM/Qgrvpen51upAktaaiI01nsJD/Yr3lMOdNtq0cxkrrg16w64VtisN6okbs7Q8AfGqj4c9fA==

eslint-visitor-keys@^3.4.1:
eslint-visitor-keys@^3.4.1, eslint-visitor-keys@^3.4.3:
version "3.4.3"
resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz#0cd72fe8550e3c2eae156a96a4dddcd1c8ac5800"
integrity sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==
Expand Down Expand Up @@ -17735,6 +17811,11 @@ ts-node@^10.8.1:
v8-compile-cache-lib "^3.0.1"
yn "3.1.1"

ts-pattern@^4.0.5:
version "4.3.0"
resolved "https://registry.yarnpkg.com/ts-pattern/-/ts-pattern-4.3.0.tgz#7a995b39342f1b00d1507c2d2f3b90ea16e178a6"
integrity sha512-pefrkcd4lmIVR0LA49Imjf9DYLK8vtWhqBPA3Ya1ir8xCW0O2yjL9dsCVvI7pCodLC5q7smNpEtDR2yVulQxOg==

tsconfck@^2.1.0:
version "2.1.2"
resolved "https://registry.yarnpkg.com/tsconfck/-/tsconfck-2.1.2.tgz#f667035874fa41d908c1fe4d765345fcb1df6e35"
Expand All @@ -17759,7 +17840,7 @@ tsconfig-paths@^4.1.2:
minimist "^1.2.6"
strip-bom "^3.0.0"

tslib@^1.9.0:
tslib@^1.8.1, tslib@^1.9.0:
version "1.14.1"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00"
integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==
Expand All @@ -17774,6 +17855,13 @@ tslib@^2.0.3, tslib@^2.6.0:
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.2.tgz#703ac29425e7b37cd6fd456e92404d46d1f3e4ae"
integrity sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==

tsutils@^3.21.0:
version "3.21.0"
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.21.0.tgz#b48717d394cea6c1e096983eed58e9d61715b623"
integrity sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==
dependencies:
tslib "^1.8.1"

tuf-js@^1.1.7:
version "1.1.7"
resolved "https://registry.yarnpkg.com/tuf-js/-/tuf-js-1.1.7.tgz#21b7ae92a9373015be77dfe0cb282a80ec3bbe43"
Expand Down
Loading