fix(eslint-plugin): [no-uncalled-signals] properly handle statements with unary operators#2926
Conversation
…with unary operators
|
View your CI Pipeline Execution ↗ for commit 9fb5db7
☁️ Nx Cloud last updated this comment at |
There was a problem hiding this comment.
Important
At least one additional CI pipeline execution has run since the conclusion below was written and it may no longer be applicable.
Nx Cloud is proposing a fix for your failed CI:
We regenerated the auto-generated docs for the no-uncalled-signals rule to reflect the updated unary operator handling introduced in this PR. The eslint-plugin:check-rule-docs task performs a git diff check to ensure generated docs are in sync with the rule implementation, and this was failing because the docs hadn't been updated after the code change. Committing the regenerated documentation resolves the check.
Tip
✅ We verified this fix by re-running eslint-plugin:check-rule-docs.
Suggested Fix changes
diff --git a/packages/eslint-plugin/docs/rules/no-uncalled-signals.md b/packages/eslint-plugin/docs/rules/no-uncalled-signals.md
index b0506218..7c3d414b 100644
--- a/packages/eslint-plugin/docs/rules/no-uncalled-signals.md
+++ b/packages/eslint-plugin/docs/rules/no-uncalled-signals.md
@@ -146,6 +146,65 @@ for (let i = 0; a; i++) { }
#### ❌ Invalid Code
+```ts
+function test(): boolean {
+ let a: Signal<boolean>;
+
+ return !a;
+ ~
+}
+```
+
+<br>
+
+---
+
+<br>
+
+#### Default Config
+
+```json
+{
+ "rules": {
+ "@angular-eslint/no-uncalled-signals": [
+ "error"
+ ]
+ }
+}
+```
+
+<br>
+
+#### ❌ Invalid Code
+
+```ts
+let a: Signal<boolean>;
+const flag = !a;
+ ~
+```
+
+<br>
+
+---
+
+<br>
+
+#### Default Config
+
+```json
+{
+ "rules": {
+ "@angular-eslint/no-uncalled-signals": [
+ "error"
+ ]
+ }
+}
+```
+
+<br>
+
+#### ❌ Invalid Code
+
```ts
let a: Signal<boolean>;
if (a) { }
@@ -1264,6 +1323,122 @@ let b = a;
#### ✅ Valid Code
+```ts
+let a: Signal<boolean>;
+let b = !a();
+```
+
+<br>
+
+---
+
+<br>
+
+#### Default Config
+
+```json
+{
+ "rules": {
+ "@angular-eslint/no-uncalled-signals": [
+ "error"
+ ]
+ }
+}
+```
+
+<br>
+
+#### ✅ Valid Code
+
+```ts
+let a: Signal<number>;
+let b = -a();
+```
+
+<br>
+
+---
+
+<br>
+
+#### Default Config
+
+```json
+{
+ "rules": {
+ "@angular-eslint/no-uncalled-signals": [
+ "error"
+ ]
+ }
+}
+```
+
+<br>
+
+#### ✅ Valid Code
+
+```ts
+class AppComponent {
+ prop = viewChild<AppComponent | undefined>();
+
+ test() {
+ delete this.prop;
+ }
+}
+```
+
+<br>
+
+---
+
+<br>
+
+#### Default Config
+
+```json
+{
+ "rules": {
+ "@angular-eslint/no-uncalled-signals": [
+ "error"
+ ]
+ }
+}
+```
+
+<br>
+
+#### ✅ Valid Code
+
+```ts
+function test(): boolean {
+ let a: Signal<boolean>;
+
+ return !a();
+}
+```
+
+<br>
+
+---
+
+<br>
+
+#### Default Config
+
+```json
+{
+ "rules": {
+ "@angular-eslint/no-uncalled-signals": [
+ "error"
+ ]
+ }
+}
+```
+
+<br>
+
+#### ✅ Valid Code
+
```ts
function getSignal(): Signal<boolean> {}
if (getSignal()()) { }
Because this branch comes from a fork, it is not possible for us to apply fixes directly, but you can apply the changes locally using the available options below.
Apply changes locally with:
npx nx-cloud apply-locally oLY1-Z3eI
Apply fix locally with your editor ↗ View interactive diff ↗
🎓 Learn more about Self-Healing CI on nx.dev
JamesHenry
left a comment
There was a problem hiding this comment.
See CI failure, our docs are generated from our unit tests so whenever they change the docs need to be regenerated.
There is a command you can run to fix it in the Nx Cloud comment
|
@JamesHenry updated docs accordingly, thanks for pointing me out. Btw, why there is no |
|
@BEGEMOT9I they go stale and people ignore them anyway 😄 Thanks a lot for this contribution! |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2926 +/- ##
==========================================
- Coverage 90.88% 0 -90.89%
==========================================
Files 214 0 -214
Lines 5066 0 -5066
Branches 1609 0 -1609
==========================================
- Hits 4604 0 -4604
+ Misses 457 0 -457
+ Partials 5 0 -5
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
Previously, not all operations with unary operators were handled correctly. For example, it was possible to return an incorrectly handled signal from a method in a component:
The same was for the assignment and other cases. This pull request fixes this behavior.
Note: the
deleteoperator was omitted intentionally because signal properties can be optional