Skip to content

fix(eslint-plugin): [no-input-prefix] false positive on input initializer value #2184

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
Jan 26, 2025

Conversation

lucasnbsb
Copy link
Contributor

Input properties initialized with literal values containing the prohibited prefix were being incorrectly flagged, causing code like:

// the prefix is "on"
@Component()
class Test {
  @Input() notOn: string = 'on';
}

To trigger on the initializer

That happened because the selector matched any literal or identifier that were children of property definitions.

So the fix could either be in the selector or once the match already happened. I went with the latter.

I added 3 test cases, one valid with the disalowed prefix in the initializer instead of the property name and two invalids with the initializer not being matched,

@JamesHenry JamesHenry changed the title fix(eslint-plugin): [no-input-prefix] incorrectly triggers on literal… fix(eslint-plugin): [no-input-prefix] false positive on input initializer value Jan 23, 2025
Copy link

nx-cloud bot commented Jan 23, 2025

View your CI Pipeline Execution ↗ for commit 72638f6.

Command Status Duration Result
nx run-many -t e2e-suite --parallel 1 ✅ Succeeded 36s View ↗
nx run-many -t test --codeCoverage ✅ Succeeded 1m 29s View ↗
nx run-many -t build,typecheck,check-rule-docs,... ✅ Succeeded 56s View ↗
nx-cloud record -- pnpm nx sync:check ✅ Succeeded 4s View ↗
nx-cloud record -- pnpm format-check ✅ Succeeded 5s View ↗
nx run-many -t test ✅ Succeeded 33s View ↗
nx run-many -t build ✅ Succeeded 19s View ↗

☁️ Nx Cloud last updated this comment at 2025-01-26 13:55:32 UTC

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.

Thanks a lot @lucasnbsb, you please need to update the rule docs and commit the results. Our rule docs are generated from our unit tests, so whenever they change the rule docs need to as well.

pnpm update-rule-docs

@lucasnbsb lucasnbsb requested a review from JamesHenry January 23, 2025 12:14
@lucasnbsb
Copy link
Contributor Author

Hi @JamesHenry. Docs updated 👍

Copy link

codecov bot commented Jan 26, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.45%. Comparing base (3475d1c) to head (72638f6).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2184      +/-   ##
==========================================
+ Coverage   90.44%   90.45%   +0.01%     
==========================================
  Files         177      177              
  Lines        3527     3532       +5     
  Branches      593      595       +2     
==========================================
+ Hits         3190     3195       +5     
  Misses        183      183              
  Partials      154      154              
Flag Coverage Δ
unittest 90.45% <100.00%> (+0.01%) ⬆️

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

Files with missing lines Coverage Δ
...ackages/eslint-plugin/src/rules/no-input-prefix.ts 90.00% <100.00%> (+1.42%) ⬆️
...eslint-plugin/tests/rules/no-input-prefix/cases.ts 100.00% <ø> (ø)

@JamesHenry JamesHenry merged commit 79f2d5d into angular-eslint:main Jan 26, 2025
8 checks passed
@JamesHenry
Copy link
Member

Thank you!

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.

2 participants