-
-
Notifications
You must be signed in to change notification settings - Fork 243
fix(eslint-plugin): handle output()
and input()
functions in various rules
#2098
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
Conversation
output()
and input()
functions in various rulesoutput()
and input()
functions in various rules
☁️ Nx Cloud ReportCI is running/has finished running commands for commit 25e0fb0. 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. |
export const INPUT_ALIAS = `:matches(PropertyDefinition, MethodDefinition[kind='set']) ${INPUT_DECORATOR} ${LITERAL_OR_TEMPLATE_ELEMENT}`; | ||
export const INPUT_ALIAS = [ | ||
`:matches(PropertyDefinition, MethodDefinition[kind='set']) ${INPUT_DECORATOR} > CallExpression > Literal`, | ||
`:matches(PropertyDefinition, MethodDefinition[kind='set']) ${INPUT_DECORATOR} > CallExpression > TemplateLiteral > TemplateElement`, |
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.
ℹ️ I didn't use LITERAL_OR_TEMPLATE_ELEMENT
here. Using that selector means the no-input-rename
rule would need to check if the string that matched is the value of an alias
property to avoid false positives. By using three different selectors, it guarantees that it matches to either @Output('foo')
or @Output(`foo`)
or @Output({ alias: 'foo' })
, and won't match to something like @Output({ test: 'foo' })
.
You'll see in the no-input-rename
rule that I've been able to remove the two checks where it was looking for the parent property or object expression to determine if the matched literal was the value of an alias
property.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2098 +/- ##
==========================================
+ Coverage 90.99% 91.05% +0.06%
==========================================
Files 181 181
Lines 3475 3521 +46
Branches 580 587 +7
==========================================
+ Hits 3162 3206 +44
+ Misses 165 164 -1
- Partials 148 151 +3
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Thanks so much! |
I know this is old and closed, but can this be updated with an "allowPrefix" option like some other rules have? My current workaround is to just disable this rule. |
Fixes #2004
Rules affected:
no-output-native
no-output-on-prefix
no-output-rename
no-input-rename
This change makes
no-output-native
check properties that are initialized to the result of theoutput()
function. This was achieved by changing the selector to also look for properties that are assigned the result of a call expression for anoutput
function that contains an object expression with analias
property. Theno-output-native
rule itself did not need to change.As mentioned by @5im0n in #2004 (comment), the
no-output-on-prefix
rule was also not checking properties that are initialized to the result of theoutput()
function. Because it uses the same selector, that rule now also checks those properties.The
no-output-rename
rule also wasn't checking foroutput()
properties, and due to the changes to the selectors, it now does. The rule itself did have to change to account for the alias coming from a property in an object expression instead of just being the single parameter to the@Output()
decorator.The
no-input-rename
rule wasn't affected by the changes to the selectors for the rules mentioned above, but I thought it was a good idea to update it at the same time because the changes that needed to be made to the rule were almost identical to the changes made tono-output-rename
- it just had to account for thealias
property being on an object expression that is the second argument toinput()
instead of the first argument like it would be foroutput()
.