Skip to content

fix(eslint-plugin-template): [attributes-order] treat inputs without square brackets as attributes #2316

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

Conversation

reduckted
Copy link
Contributor

@reduckted reduckted commented Mar 11, 2025

Fixes #1914

Given an element with two attributes, where one sets a static valid and the other uses interpolation, Angular classifies the first attribute as an "attribute" and the second attribute as an "input".

<div a="b" c="{{ d }}"></div>

See here for an example of the AST (the template parser it uses is quite a few versions behind, but the same behavior exists with v19):
https://astexplorer.net/#/gist/cd84edb20d811a8896c9f28f6f5031d9/1567654ea0ba120f0c3844e9786387bb3c921d17

This pull request changes the attributes-order rule such that an input will only be classified as an input if it's surrounded with square brackets.

Note

This PR is piggy-backing off #2307 since that PR made large changes to the attributes-order rule. Once/if that is merged, then I'll rebase this PR to remove the extra commits.

The specific commit that is relevant to this PR is 6fc0cd5.

Copy link

nx-cloud bot commented Mar 11, 2025

View your CI Pipeline Execution ↗ for commit 9490faa.

Command Status Duration Result
nx run-many -t e2e-suite --parallel 1 ✅ Succeeded 9m 34s View ↗
nx run-many -t test --codeCoverage ✅ Succeeded 1m 10s View ↗
nx run-many -t build,typecheck,check-rule-docs,... ✅ Succeeded 46s 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 22s View ↗
nx run-many -t build ✅ Succeeded 11s View ↗

☁️ Nx Cloud last updated this comment at 2025-03-22 09:46:59 UTC

Copy link

codecov bot commented Mar 11, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.39%. Comparing base (1bd350b) to head (9490faa).
Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2316      +/-   ##
==========================================
+ Coverage   92.36%   92.39%   +0.03%     
==========================================
  Files         181      181              
  Lines        3377     3419      +42     
  Branches      689      704      +15     
==========================================
+ Hits         3119     3159      +40     
- Misses        200      201       +1     
- Partials       58       59       +1     
Flag Coverage Δ
unittest 92.39% <100.00%> (+0.03%) ⬆️

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

Files with missing lines Coverage Δ
...lint-plugin-template/src/rules/attributes-order.ts 94.67% <100.00%> (+0.18%) ⬆️
...gin-template/tests/rules/attributes-order/cases.ts 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 I merged #2307

@reduckted reduckted force-pushed the bugfix/1914-attribute-is-input branch from 3addfec to 9490faa Compare March 22, 2025 09:34
@reduckted reduckted marked this pull request as ready for review March 22, 2025 09:38
@JamesHenry JamesHenry merged commit 3335025 into angular-eslint:main Mar 22, 2025
8 checks passed
@reduckted reduckted deleted the bugfix/1914-attribute-is-input branch March 22, 2025 10:19
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.

[attributes-order] ngClass is being treated as STRUCTURAL_DIRECTIVE
2 participants