-
-
Notifications
You must be signed in to change notification settings - Fork 77
Add pug support for vue templates #123
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add pug support for vue templates #123
Conversation
.yarn | ||
.yarnrc.yml | ||
yarn.lock |
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 use yarn locally.
To prevent accidental commit of 80+ files, I ignored these for now.
Can revert it when out of draft
Why is a scripts element used here? Do I need to use partially the HTMLParser for that? |
@mysticatea Please guide me in the right direction from here Am I on the correct track? @leo-buneev Are you totally not interested anymore? Do you have any hints for me what issues you had in the past? @lehni @SkyaTura Hey my pug team ^^ |
This parser also parses |
Also, this parser treats the content of custom blocks without vue-eslint-parser/test/fixtures/document-fragment/custom-block-html/source.vue Lines 5 to 7 in 184dc09
vue-eslint-parser/test/fixtures/document-fragment/custom-block-html/document-fragment.json Lines 361 to 379 in 184dc09
|
@ota-meshi Oh this is really helpful! Thx 🚀 But the problem is, that The goal of this PR should be to solve explicitly this. |
vue-eslint-parser/src/index.ts Line 93 in 184dc09
I think it's a good to change the conditions as you change the parser to make it understand pug. |
79d0226
to
9a2d5b1
Compare
Could you trigger the tests? I took the easy route for now: just dump the parsed tokens into doc's So at least I can try to start working on my plugin 🤔 |
@ota-meshi please retrigger 🙂 |
In your change, you can't use traverse with esquery when creating rules for eslint. Is this what you intended? /** @param {RuleContext} context */
create(context) {
const df =
context.parserServices.getDocumentFragment &&
context.parserServices.getDocumentFragment()
if (!df) {
return {}
}
/** @type {VElement} */
const pugTemplateElement = df.children.find(
(node) =>
node.type === 'VElement' &&
node.name === 'template' &&
node.startTag.attributes.some(
(attr) =>
!attr.directive &&
attr.key.name === 'lang' &&
attr.value &&
attr.value.value === 'pug'
)
)
if (!pugTemplateElement) {
return {}
}
const pugText = context
.getSourceCode()
.text.slice(
pugTemplateElement.startTag.range[1],
pugTemplateElement.endTag.range[0]
)
const pugTokens = require('pug-lexer')(pugText)
// ...
} (Actually, I think that a cache mechanism is necessary, but I omit it.) I think the value of making changes to this parser is that the children of |
Interesting, I will try this out and test if this fulfills my needs. Will report back, but could take a while due to other prios. And yeah, I need to find a way to cache this so not every single rule reparses the |
references #29