-
-
Notifications
You must be signed in to change notification settings - Fork 681
Fix: Add registeredComponentsOnly
option to component-name-in-template-casing
rule
#714
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
Now, if i use this option in single file component, it will change component name in template but not in js. Will this PR fix this issue? <template>
<ComponentA> // this changes
</template>
<script>
var ComponentB = {
components: {
// this is a bug, it did not change this key
'componentA': ComponentA
},
}
<script> |
@fxxkscript Hi. If you have the following <template>
<componentA>
</template>
<script>
// @vue/component
var ComponentB = {
components: {
'componentA': ComponentA
},
}
</script> |
Good job @ota-meshi I like the idea with I also have a question though, what do you think about simplifying the API a little bit? That is, having only these two:
Isn't Then |
@michalsnik I think that your proposal is simple and good! I will remove the |
# Conflicts: # docs/rules/component-name-in-template-casing.md
I updated it. Please check again. |
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.
Awesome @ota-meshi Good job :) I left only two suggestions.
const allowedCaseOptions = ['PascalCase', 'kebab-case'] | ||
const defaultCase = 'PascalCase' | ||
|
||
const RE_REGEXP_CHAR = /[\\^$.*+?()[\]{}|]/gu |
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.
What do you think about adding comment above for a reference with example string that it describes? Or even better, write unit test for each REGEX? From my experience unit tests serve the best documentation for regular expressions :)
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.
@michalsnik
Thank you for review! I added test cases.
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.
Well done @ota-meshi
This PR makes the following changes to
component-name-in-template-casing
rule.registeredComponentsOnly
option.registeredComponentsOnly
options to true.AddglobalRegisteredComponents
option.AddglobalRegisteredComponentPatterns
option.ignores
option.The feature of each additional option is as follows.
registeredComponentsOnly
... Iftrue
, only registered components (in PascalCase) are checked. Iffalse
, check all.default
true
globalRegisteredComponents
(string[]
) ... (Only available whenregisteredComponentsOnly
istrue
) The name of globally registered components.globalRegisteredComponentPatterns
(string[]
) ... (Only available whenregisteredComponentsOnly
istrue
) The pattern of the names of globally registered components.https://vuejs.org/v2/guide/components-registration.html#Name-Casing
Since the casing of the globally registered component is unknown, we made an option to check only the local registered components that are explicitly used.
Also, I changed this option to work by default.
This fixes the problem pointed out below.
vue/component-name-in-template-casing
#397 (comment)Fixed #710 #705