-
-
Notifications
You must be signed in to change notification settings - Fork 665
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
Don't report user-defined createApp
function in vue/one-component-per-file
#2203
base: master
Are you sure you want to change the base?
Conversation
ed050e9
to
257c814
Compare
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.
Thanks for implementing a fix! I have one comment, see below :)
createApp
function in vue/one-component-per-file
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.
Looks good to me now, thanks :)
@@ -2536,6 +2537,31 @@ function getVueComponentDefinitionType(node) { | |||
if (callee.name === 'createApp') { | |||
// for Vue.js 3.x | |||
// createApp({}) | |||
|
|||
const variable = findVariable(context.getScope(), callee) |
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.
Sorry for the late reply. I am busy with office work.
I think it can be written more simply using tracker.iterateEsmReferences
.
https://eslint-community.github.io/eslint-utils/api/scope-utils.html#tracker-iterateesmreferences
e.g.
const tracker = new ReferenceTracker(context.getSourceCode().scopeManager.globalScope)
const traceMap = utils.createCompositionApiTraceMap({
[ReferenceTracker.ESM]: true,
createApp: {
[ReferenceTracker.CALL]: true
}
})
if ([...tracker.iterateEsmReferences(traceMap)].every(({ node }) => node !== callee)) {
return 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.
@candy-Tong Would you like to give this a try?
No description provided.