-
-
Notifications
You must be signed in to change notification settings - Fork 44
Add support for <i18n> blocks of SFC. #80
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
Thank you for your PR! I'll try to review, please wait! 🙏 |
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.
Great works!
I've put a comment.
Could you check it please?
lib/utils/collect-keys.js
Outdated
}) | ||
} | ||
vueESLintParser.AST.traverseNodes(node, { | ||
visitorKeys: visitorKeys, |
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.
You can use shorthand prop name
sytanx.
vueESLintParser.AST.traverseNodes(node, {
visitorKeys
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 fixed this. I also enabled the "object-shorthand" rule in .eslintrc
.
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.
(Disclaimer: I'm not a maintainer.)
Current vue-eslint-parser
parses the below code incorrect:
<i18n>
{
"hello_incorrect": "</",
"hello_correct": "hello"
}
</i18n>
The above code is parsed to like the below AST:
{
type: 'VElement',
range: [ 5, 91 ],
loc: { start: { line: 2, column: 4 }, end: { line: 8, column: 4 } },
name: 'i18n',
rawName: 'i18n',
namespace: 'http://www.w3.org/1999/xhtml',
startTag: {
type: 'VStartTag',
range: [ 5, 11 ],
loc: { start: [Object], end: [Object] },
parent: [Circular *1],
selfClosing: false,
attributes: []
},
children: [
{
type: 'VText',
range: [Array],
loc: [Object],
parent: [Circular *1],
value: '\n {\n "hello_incorrect": "'
},
{
type: 'VText',
range: [Array],
loc: [Object],
parent: [Circular *1],
value: '\n '
}
],
endTag: null,
variables: []
}
Informations for under "hello_incorrect"
is removed from AST. So some rules for SFC custom blocks probably will be broken.
The best way is to fix this problem on parser side. But if you can't fix it we should create new issue about it.
@sosukesuzuki Do mysticatea know about that issue? |
Probably, no. |
I didn't know that vue-template-compiler could parse a custom block without HTML escaping😅 |
@kazupon Thank you for reviewing! |
Does this also work with |
yaml is not yet supported. |
Is it possible to use the ability of Vue-Loader for custom blocks ? https://vue-loader.vuejs.org/guide/custom-blocks.html |
This PR adds support for the
<i18n>
block.close #11
I have made the following changes to support
<i18n>
.@intlify/vue-i18n/no-html-messages
rule to also verify the json in the<i18n>
block.@intlify/vue-i18n/no-missing-keys
rule to not report if the message used by SFC is inside<i18n>
block.@intlify/vue-i18n/no-unused-keys
rule to report even if the message in the<i18n>
block is not used by that SFC.In addition, If you don't validate the
.json
and using<i18n>
, the rule no longer reports an error even if you don't havesettings
.Parsing the
<i18n>
block understands the following attributes:src
... The@intlify/vue-i18n/no-missing-keys
rule also looks for keys in the file specified bysrc
.locale
... If this is specified, it is determined that JSON does not include locale, similar tovue-i18n-loader
.