-
-
Notifications
You must be signed in to change notification settings - Fork 217
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
fix(eslint-plugin-template): fix control flow syntax with i18n rule #1656
fix(eslint-plugin-template): fix control flow syntax with i18n rule #1656
Conversation
@@ -49,10 +49,11 @@ const KEYS: VisitorKeys = { | |||
PropertyRead: ['receiver'], | |||
Template: ['templateAttrs', 'children', 'inputs'], | |||
BindingPipe: ['exp'], | |||
DeferredBlock: ['children'], | |||
DeferredBlock: ['children', 'placeholder', 'loading', 'error'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without this angular-eslint won't parse elements within @placeholder
, @loading
or @error
nodes inside of @defer
blocks
DeferredBlockLoading: ['children'], | ||
DeferredBlockError: ['children'], | ||
DeferredBlockPlaceholder: ['children'], | ||
ForLoopBlock: ['children', 'empty'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without this angular-eslint won't parse elements inside of @empty
nodes inside of @for
blocks
☁️ Nx Cloud ReportCI is running/has finished running commands for commit ee3ba44. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution ⌛ The following targets are in progress ✅ Successfully ran 4 targetsSent with 💌 from NxCloud. |
0ae761b
to
c9aa2a2
Compare
@@ -99,6 +100,9 @@ function preprocessNode(node: Node) { | |||
|
|||
for (i = 0; i < keys.length; ++i) { | |||
const child = node[keys[i]]; | |||
if (child == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without this defer block parsing fails with:
● parseForESLint() › @defer › should support the different variants of @defer
TypeError: Cannot read properties of null (reading 'type')
105 | }
106 | const isArr = Array.isArray(child);
> 107 | if (child.type !== undefined) {
| ^
108 | // Angular sometimes uses a prop called type already
109 | child.__originalType = child.type;
110 | }
at preprocessNode (src/index.ts:107:15)
at preprocessNode (src/index.ts:129:11)
at parseForESLint (src/index.ts:272:3)
at Object.<anonymous> (tests/index.test.ts:559:23)
Maybe I got something wrong in the visitor keys? But with this check everything seems to work ok so maybe it's the correct thing to do?
c9aa2a2
to
ee3ba44
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1656 +/- ##
==========================================
+ Coverage 89.44% 89.50% +0.05%
==========================================
Files 169 169
Lines 3175 3183 +8
Branches 540 542 +2
==========================================
+ Hits 2840 2849 +9
Misses 198 198
+ Partials 137 136 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
|
☁️ Nx Cloud ReportCI is running/has finished running commands for commit 5da26b3. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution ✅ Successfully ran 7 targetsSent with 💌 from NxCloud. |
Thanks @mattlewis92! |
Adds support for control flow block syntax inside the i18n rule. Currently using elements inside control flow blocks will result in a lint error, even if there is a parent element that has the i18n attribute.
Fixes #1640