Skip to content

feat(eslint-plugin): add no-uncalled-signals rule #2383

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

Merged
merged 4 commits into from
May 31, 2025

Conversation

scj7t4
Copy link
Contributor

@scj7t4 scj7t4 commented Apr 20, 2025

Checks that signals used in logical expressions are invoked. For #2302

Thanks for your work on the project! This is my first attempt at a typescript eslint plugin, so feedback is very appreciated on what I messed up :)

@scj7t4 scj7t4 force-pushed the add-signal-logic-rule branch from fc8bd24 to 41eaa68 Compare April 20, 2025 17:19
Copy link
Member

@JamesHenry JamesHenry left a comment

Choose a reason for hiding this comment

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

TypeScript has always referred to this as uncalled function checks: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#uncalled-function-checks

So maybe no-uncalled-signals is a better name (given it doesn't check any other kind of "misuse")?

@JamesHenry
Copy link
Member

WDYT about the name @reduckted?

@reduckted
Copy link
Contributor

I think no-uncalled-signals is a good name. It aligns with the TypeScript concept, and also describes what ithe rule actually checks - that signals are called.
👍

@scj7t4 scj7t4 force-pushed the add-signal-logic-rule branch 2 times, most recently from 6826326 to 74db158 Compare May 10, 2025 17:23
@scj7t4
Copy link
Contributor Author

scj7t4 commented May 10, 2025

Thanks for the feedback! I've reverted the package.json files and changed the name of the rule to no-uncalled-signals

@scj7t4 scj7t4 changed the title feat(no-misused-signals): check use of signals in logical expressions feat(no-uncalled-signals): check use of signals in logical expressions (Formerly no-misused-signals) May 10, 2025
@scj7t4 scj7t4 force-pushed the add-signal-logic-rule branch from 74db158 to fd51cce Compare May 10, 2025 21:41
@JamesHenry JamesHenry changed the title feat(no-uncalled-signals): check use of signals in logical expressions (Formerly no-misused-signals) feat(no-uncalled-signals): check use of signals in logical expressions May 11, 2025
@JamesHenry JamesHenry changed the title feat(no-uncalled-signals): check use of signals in logical expressions feat(eslint-plugin): add no-uncalled-signals rule May 11, 2025
Copy link

nx-cloud bot commented May 11, 2025

View your CI Pipeline Execution ↗ for commit 42d68fd.

Command Status Duration Result
nx run-many -t e2e-suite --parallel 1 ✅ Succeeded 32s View ↗
nx run-many -t test --codeCoverage ✅ Succeeded 53s View ↗
nx run-many -t build,typecheck,check-rule-docs,... ✅ Succeeded 43s View ↗
nx-cloud record -- pnpm nx sync:check ✅ Succeeded 3s View ↗
nx-cloud record -- pnpm format-check ✅ Succeeded 6s View ↗
nx run-many -t test ✅ Succeeded 36s View ↗
nx run-many -t build ✅ Succeeded 14s View ↗

☁️ Nx Cloud last updated this comment at 2025-05-31 08:48:26 UTC

@JamesHenry
Copy link
Member

@scj7t4 Thanks please see the CI failures they tell you what to do to fix them

@scj7t4 scj7t4 marked this pull request as draft May 12, 2025 00:57
@scj7t4 scj7t4 force-pushed the add-signal-logic-rule branch from f2adafb to 33e6dfc Compare May 12, 2025 01:23
@scj7t4 scj7t4 marked this pull request as ready for review May 12, 2025 01:26
@scj7t4
Copy link
Contributor Author

scj7t4 commented May 12, 2025

@scj7t4 Thanks please see the CI failures they tell you what to do to fix them

Should be fixed

@reduckted
Copy link
Contributor

@scj7t4 You'll need to run these two commands to update some generated files:

pnpm update-rule-lists
pnpm update-rule-configs
pnpm update-rule-docs

@scj7t4 scj7t4 marked this pull request as draft May 14, 2025 12:10
@scj7t4 scj7t4 force-pushed the add-signal-logic-rule branch from c9d9712 to 42d68fd Compare May 30, 2025 16:37
@scj7t4 scj7t4 marked this pull request as ready for review May 30, 2025 16:42
Copy link

codecov bot commented May 31, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.91%. Comparing base (d37c7bd) to head (42d68fd).
Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2383      +/-   ##
==========================================
+ Coverage   92.88%   92.91%   +0.03%     
==========================================
  Files         197      200       +3     
  Lines        4145     4165      +20     
  Branches      970      972       +2     
==========================================
+ Hits         3850     3870      +20     
  Misses        227      227              
  Partials       68       68              
Flag Coverage Δ
unittest 92.91% <100.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
packages/eslint-plugin/src/index.ts 100.00% <100.00%> (ø)
...ges/eslint-plugin/src/rules/no-uncalled-signals.ts 100.00% <100.00%> (ø)
packages/eslint-plugin/src/rules/prefer-signals.ts 87.93% <100.00%> (ø)
packages/eslint-plugin/src/utils/signals.ts 100.00% <100.00%> (ø)
...nt-plugin/tests/rules/no-uncalled-signals/cases.ts 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JamesHenry
Copy link
Member

Thanks so much for this!

@JamesHenry JamesHenry merged commit ac01c2c into angular-eslint:main May 31, 2025
9 checks passed
igord pushed a commit to tcorral/angular-eslint that referenced this pull request Jun 1, 2025
@danielvieira1
Copy link

can we use this rule in the template for control flow for example?

invalid
@if(signal) {

valid
@if(signal()) {

@JamesHenry
Copy link
Member

@danielvieira1 No, template rules work totally differently in a different plugin, that would require a separate rule

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants