Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork680
Don't report user-definedcreateApp
function invue/one-component-per-file
#2203
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:master
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
ed050e9
to257c814
CompareThere 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 :)
Uh oh!
There was an error while loading.Please reload this page.
createApp
function invue/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 usingtracker.iterateEsmReferences
.
https://eslint-community.github.io/eslint-utils/api/scope-utils.html#tracker-iterateesmreferences
e.g.
consttracker=newReferenceTracker(context.getSourceCode().scopeManager.globalScope)consttraceMap=utils.createCompositionApiTraceMap({[ReferenceTracker.ESM]:true,createApp:{[ReferenceTracker.CALL]:true}})if([...tracker.iterateEsmReferences(traceMap)].every(({ node})=>node!==callee)){returnnull;}
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.