Skip to content

fix(biome-js-analyze): add a check for if/ else and ternary operators… #6524

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

Conversation

vladimir-ivanov
Copy link
Contributor

@vladimir-ivanov vladimir-ivanov commented Jun 24, 2025

Summary

Fixed an issue where class properties that are set in the constructor were not being marked as readonly when they
should be if found in if/ else condition.

Example:

class Price {
 #price: string;

 @Input()
 set some(value: string | number) {
   if (value === undefined || value === null || value === 'undefined' || value === 'null' || Number.isNaN(value)) {
     this.#price = '';
   } else {
     this.#price = '' + value;
   }
 }
}

closes #6500

Copy link

changeset-bot bot commented Jun 24, 2025

🦋 Changeset detected

Latest commit: 7ac70fa

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 13 packages
Name Type
@biomejs/biome Patch
@biomejs/cli-win32-x64 Patch
@biomejs/cli-win32-arm64 Patch
@biomejs/cli-darwin-x64 Patch
@biomejs/cli-darwin-arm64 Patch
@biomejs/cli-linux-x64 Patch
@biomejs/cli-linux-arm64 Patch
@biomejs/cli-linux-x64-musl Patch
@biomejs/cli-linux-arm64-musl Patch
@biomejs/wasm-web Patch
@biomejs/wasm-bundler Patch
@biomejs/wasm-nodejs Patch
@biomejs/backend-jsonrpc Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added A-Linter Area: linter L-JavaScript Language: JavaScript and super languages labels Jun 24, 2025
Copy link

codspeed-hq bot commented Jun 24, 2025

CodSpeed Performance Report

Merging #6524 will not alter performance

Comparing vladimir-ivanov:fix/useReadonlyClassProperties-set-ignored (7ac70fa) with main (a3a3715)

Summary

✅ 115 untouched benchmarks

Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left some questions around the code, to have more clarity. Also left some comments around the changeset

Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! 👏

@vladimir-ivanov vladimir-ivanov force-pushed the fix/useReadonlyClassProperties-set-ignored branch from 4eb012c to 62e0a7b Compare June 24, 2025 13:22
@github-actions github-actions bot added A-CLI Area: CLI A-Project Area: project A-Parser Area: parser A-Formatter Area: formatter L-CSS Language: CSS L-JSON Language: JSON and super languages A-Diagnostic Area: diagnostocis L-Grit Language: GritQL A-Resolver Area: resolver labels Jun 24, 2025
@vladimir-ivanov vladimir-ivanov force-pushed the fix/useReadonlyClassProperties-set-ignored branch from 62e0a7b to aece21b Compare June 24, 2025 13:26
@github-actions github-actions bot removed A-Project Area: project A-Parser Area: parser A-Formatter Area: formatter L-CSS Language: CSS A-Diagnostic Area: diagnostocis L-Grit Language: GritQL A-Resolver Area: resolver labels Jun 24, 2025
@vladimir-ivanov vladimir-ivanov force-pushed the fix/useReadonlyClassProperties-set-ignored branch from dfc5c45 to 7ac70fa Compare June 24, 2025 14:34
@vladimir-ivanov vladimir-ivanov merged commit a27b825 into biomejs:main Jun 24, 2025
28 checks passed
@vladimir-ivanov vladimir-ivanov deleted the fix/useReadonlyClassProperties-set-ignored branch June 24, 2025 15:07
@github-actions github-actions bot mentioned this pull request Jun 24, 2025
@burka
Copy link

burka commented Jun 25, 2025

Yeah great! That works, I tested it on my code :-) Thanks @vladimir-ivanov for that fast fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-CLI Area: CLI A-Linter Area: linter L-JavaScript Language: JavaScript and super languages L-JSON Language: JSON and super languages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

useReadonlyClassProperties ignores accessor writes (typescript)
3 participants