Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f14d066

Browse filesBrowse files
authored
Fix crash for script setup in no-obj-calls rule (#152)
1 parent fb2f67d commit f14d066
Copy full SHA for f14d066

File tree

Expand file treeCollapse file tree

12 files changed

+2200
-3
lines changed
Filter options
Expand file treeCollapse file tree

12 files changed

+2200
-3
lines changed

‎scripts/update-fixtures-ast.js

Copy file name to clipboardExpand all lines: scripts/update-fixtures-ast.js
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ function scopeToJSON(scopeManager) {
131131
reference.resolved.defs[0].name,
132132
),
133133
init: reference.init || null,
134+
vueUsedInTemplate: reference.vueUsedInTemplate
135+
? reference.vueUsedInTemplate
136+
: undefined,
134137
}
135138
}
136139

‎src/script-setup/scope-analyzer.ts

Copy file name to clipboardExpand all lines: src/script-setup/scope-analyzer.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ function analyzeUsedInTemplateVariables(
171171

172172
function markVariableAsUsed(name: string) {
173173
const variable = scriptVariables.get(name)
174-
if (!variable) {
174+
if (!variable || variable.identifiers.length === 0) {
175175
return
176176
}
177177
if (markedVariables.has(name)) {

‎test/fixtures/ast/multiple-scripts-7/scope.json

Copy file name to clipboardExpand all lines: test/fixtures/ast/multiple-scripts-7/scope.json
+103-2Lines changed: 103 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,39 @@
138138
}
139139
},
140140
"init": true
141+
},
142+
{
143+
"identifier": {
144+
"type": "Identifier",
145+
"name": "count",
146+
"loc": {
147+
"start": {
148+
"line": 2,
149+
"column": 11
150+
},
151+
"end": {
152+
"line": 2,
153+
"column": 16
154+
}
155+
}
156+
},
157+
"from": "module",
158+
"resolved": {
159+
"type": "Identifier",
160+
"name": "count",
161+
"loc": {
162+
"start": {
163+
"line": 2,
164+
"column": 11
165+
},
166+
"end": {
167+
"line": 2,
168+
"column": 16
169+
}
170+
}
171+
},
172+
"init": null,
173+
"vueUsedInTemplate": true
141174
}
142175
]
143176
},
@@ -178,7 +211,41 @@
178211
"name": "MyComponent1"
179212
}
180213
],
181-
"references": []
214+
"references": [
215+
{
216+
"identifier": {
217+
"type": "Identifier",
218+
"name": "MyComponent1",
219+
"loc": {
220+
"start": {
221+
"line": 6,
222+
"column": 7
223+
},
224+
"end": {
225+
"line": 6,
226+
"column": 19
227+
}
228+
}
229+
},
230+
"from": "module",
231+
"resolved": {
232+
"type": "Identifier",
233+
"name": "MyComponent1",
234+
"loc": {
235+
"start": {
236+
"line": 6,
237+
"column": 7
238+
},
239+
"end": {
240+
"line": 6,
241+
"column": 19
242+
}
243+
}
244+
},
245+
"init": null,
246+
"vueUsedInTemplate": true
247+
}
248+
]
182249
},
183250
{
184251
"name": "MyComponent2",
@@ -217,7 +284,41 @@
217284
"name": "MyComponent2"
218285
}
219286
],
220-
"references": []
287+
"references": [
288+
{
289+
"identifier": {
290+
"type": "Identifier",
291+
"name": "MyComponent2",
292+
"loc": {
293+
"start": {
294+
"line": 8,
295+
"column": 7
296+
},
297+
"end": {
298+
"line": 8,
299+
"column": 19
300+
}
301+
}
302+
},
303+
"from": "module",
304+
"resolved": {
305+
"type": "Identifier",
306+
"name": "MyComponent2",
307+
"loc": {
308+
"start": {
309+
"line": 8,
310+
"column": 7
311+
},
312+
"end": {
313+
"line": 8,
314+
"column": 19
315+
}
316+
}
317+
},
318+
"init": null,
319+
"vueUsedInTemplate": true
320+
}
321+
]
221322
},
222323
{
223324
"name": "a",

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.