8000 ✨ add parsing error about invalid dynamic argument (refs #39) · vuejs/vue-eslint-parser@9326fa0 · GitHub
[go: up one dir, main page]

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 9326fa0

Browse files
committed
✨ add parsing error about invalid dynamic argument (refs #39)
1 parent b57cd06 commit 9326fa0

File tree

9 files changed

+1539
-0
lines changed

9 files changed

+1539
-0
lines changed

src/template/index.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import {
3636

3737
const shorthandSign = /^[.:@#]/u
3838
const shorthandNameMap = { ":": "bind", ".": "bind", "@": "on", "#": "slot" }
39+
const invalidDynamicArgumentNextChar = /^[\s\r\n=/>]$/u
3940

4041
/**
4142
* Get the belonging document of the given node.
@@ -649,6 +650,25 @@ export function convertToDirective(
649650
locationCalculator,
650651
)
651652

653+
const { argument } = directive.key
654+
if (
655+
argument &&
656+
argument.type === "VIdentifier" &&
657+
argument.name.startsWith("[") &&
658+
invalidDynamicArgumentNextChar.test(code[argument.range[1]])
659+
) {
660+
insertError(
661+
document,
662+
new ParseError(
663+
"Dynamic argument cannot contain spaces, '=', '/', or '>'.",
664+
undefined,
665+
argument.range[1],
666+
argument.loc.end.line,
667+
argument.loc.end.column,
668 59C1 +
),
669+
)
670+
}
671+
652672
if (node.value == null) {
653673
return
654674
}

0 commit comments

Comments
 (0)
0