Add the context test for jsx tag without attributes when matching in expression
Handles #478
This commit is contained in:
Родитель
3bf5728c89
Коммит
137e54244a
|
@ -92,6 +92,15 @@ repository:
|
|||
name: invalid.illegal.attribute.tsx
|
||||
match: \S+
|
||||
|
||||
jsx-tag-without-attributes-in-expression:
|
||||
begin: |-
|
||||
(?x)
|
||||
(?<=[({\[,?=>:*]|&&|\|\||\?|\Wreturn|^return|\Wdefault|^)\s*
|
||||
(?=(<)\s*((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\w.]*))(?<!\.|-))\s*(>))
|
||||
end: (?!\s*(<)\s*((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\w.]*))(?<!\.|-))\s*(>))
|
||||
patterns:
|
||||
- include: '#jsx-tag-without-attributes'
|
||||
|
||||
jsx-tag-without-attributes:
|
||||
name: meta.tag.without-attributes.tsx
|
||||
begin: (<)\s*((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\w.]*))(?<!\.|-))\s*(>)
|
||||
|
@ -115,7 +124,6 @@ repository:
|
|||
begin: |-
|
||||
(?x)
|
||||
(?<=[({\[,?=>:*]|&&|\|\||\?|\Wreturn|^return|\Wdefault|^)\s*
|
||||
(?!(<)\s*([_$a-zA-Z][-$\w.]*(?<!\.|-))\s*(>)) #look ahead is not start of tag without attributes
|
||||
(?!<\s*[_$[:alpha:]][_$[:alnum:]]*((\s+extends\s+[^=>])|,)) # look ahead is not type parameter of arrow
|
||||
(?=(<)\s*
|
||||
([_$a-zA-Z][-$\w.]*(?<!\.|-))
|
||||
|
@ -194,7 +202,7 @@ repository:
|
|||
|
||||
jsx:
|
||||
patterns:
|
||||
- include: '#jsx-tag-without-attributes'
|
||||
- include: '#jsx-tag-without-attributes-in-expression'
|
||||
- include: '#jsx-tag-in-expression'
|
||||
- include: '#jsx-tag-invalid'
|
||||
|
||||
|
|
|
@ -6665,6 +6665,22 @@
|
|||
<key>match</key>
|
||||
<string>\S+</string>
|
||||
</dict>
|
||||
<key>jsx-tag-without-attributes-in-expression</key>
|
||||
<dict>
|
||||
<key>begin</key>
|
||||
<string>(?x)
|
||||
(?<=[({\[,?=>:*]|&&|\|\||\?|\Wreturn|^return|\Wdefault|^)\s*
|
||||
(?=(<)\s*((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\w.]*))(?<!\.|-))\s*(>))</string>
|
||||
<key>end</key>
|
||||
<string>(?!\s*(<)\s*((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\w.]*))(?<!\.|-))\s*(>))</string>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#jsx-tag-without-attributes</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
<key>jsx-tag-without-attributes</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
|
@ -6734,7 +6750,6 @@
|
|||
<key>begin</key>
|
||||
<string>(?x)
|
||||
(?<=[({\[,?=>:*]|&&|\|\||\?|\Wreturn|^return|\Wdefault|^)\s*
|
||||
(?!(<)\s*([_$a-zA-Z][-$\w.]*(?<!\.|-))\s*(>)) #look ahead is not start of tag without attributes
|
||||
(?!<\s*[_$[:alpha:]][_$[:alnum:]]*((\s+extends\s+[^=>])|,)) # look ahead is not type parameter of arrow
|
||||
(?=(<)\s*
|
||||
([_$a-zA-Z][-$\w.]*(?<!\.|-))
|
||||
|
@ -6951,7 +6966,7 @@
|
|||
<array>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#jsx-tag-without-attributes</string>
|
||||
<string>#jsx-tag-without-attributes-in-expression</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
|
|
|
@ -0,0 +1,274 @@
|
|||
original file
|
||||
-----------------------------------
|
||||
// Before
|
||||
a = (b: string, c: number) => {
|
||||
console.log(b, c);
|
||||
}
|
||||
|
||||
d = (e: string) => (
|
||||
f: G<H>
|
||||
) => {
|
||||
console.log(e, f);
|
||||
};
|
||||
|
||||
// After
|
||||
a = (b: string, c: number) => {
|
||||
console.log(b, c);
|
||||
}
|
||||
-----------------------------------
|
||||
|
||||
Grammar: TypeScriptReact.tmLanguage
|
||||
-----------------------------------
|
||||
>// Before
|
||||
^^
|
||||
source.tsx comment.line.double-slash.tsx punctuation.definition.comment.tsx
|
||||
^^^^^^^^^
|
||||
source.tsx comment.line.double-slash.tsx
|
||||
>a = (b: string, c: number) => {
|
||||
^
|
||||
source.tsx entity.name.function.tsx
|
||||
^
|
||||
source.tsx
|
||||
^
|
||||
source.tsx keyword.operator.assignment.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx meta.parameters.tsx punctuation.definition.parameters.begin.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx meta.parameters.tsx variable.parameter.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx meta.parameters.tsx meta.type.annotation.tsx keyword.operator.type.annotation.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx meta.parameters.tsx meta.type.annotation.tsx
|
||||
^^^^^^
|
||||
source.tsx meta.arrow.tsx meta.parameters.tsx meta.type.annotation.tsx support.type.primitive.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx meta.parameters.tsx punctuation.separator.parameter.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx meta.parameters.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx meta.parameters.tsx variable.parameter.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx meta.parameters.tsx meta.type.annotation.tsx keyword.operator.type.annotation.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx meta.parameters.tsx meta.type.annotation.tsx
|
||||
^^^^^^
|
||||
source.tsx meta.arrow.tsx meta.parameters.tsx meta.type.annotation.tsx support.type.primitive.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx meta.parameters.tsx punctuation.definition.parameters.end.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx
|
||||
^^
|
||||
source.tsx meta.arrow.tsx storage.type.function.arrow.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx meta.block.tsx punctuation.definition.block.tsx
|
||||
^^
|
||||
source.tsx meta.arrow.tsx meta.block.tsx
|
||||
> console.log(b, c);
|
||||
^^
|
||||
source.tsx meta.arrow.tsx meta.block.tsx
|
||||
^^^^^^^
|
||||
source.tsx meta.arrow.tsx meta.block.tsx meta.function-call.tsx support.class.console.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx meta.block.tsx meta.function-call.tsx punctuation.accessor.tsx
|
||||
^^^
|
||||
source.tsx meta.arrow.tsx meta.block.tsx meta.function-call.tsx support.function.console.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx meta.block.tsx meta.brace.round.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx meta.block.tsx variable.other.readwrite.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx meta.block.tsx punctuation.separator.comma.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx meta.block.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx meta.block.tsx variable.other.readwrite.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx meta.block.tsx meta.brace.round.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx meta.block.tsx punctuation.terminator.statement.tsx
|
||||
^^
|
||||
source.tsx meta.arrow.tsx meta.block.tsx
|
||||
>}
|
||||
^
|
||||
source.tsx meta.arrow.tsx meta.block.tsx punctuation.definition.block.tsx
|
||||
^^
|
||||
source.tsx
|
||||
>
|
||||
^^
|
||||
source.tsx
|
||||
>d = (e: string) => (
|
||||
^
|
||||
source.tsx entity.name.function.tsx
|
||||
^
|
||||
source.tsx
|
||||
^
|
||||
source.tsx keyword.operator.assignment.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx meta.parameters.tsx punctuation.definition.parameters.begin.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx meta.parameters.tsx variable.parameter.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx meta.parameters.tsx meta.type.annotation.tsx keyword.operator.type.annotation.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx meta.parameters.tsx meta.type.annotation.tsx
|
||||
^^^^^^
|
||||
source.tsx meta.arrow.tsx meta.parameters.tsx meta.type.annotation.tsx support.type.primitive.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx meta.parameters.tsx punctuation.definition.parameters.end.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx
|
||||
^^
|
||||
source.tsx meta.arrow.tsx storage.type.function.arrow.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx
|
||||
^
|
||||
source.tsx meta.brace.round.tsx
|
||||
^^
|
||||
source.tsx
|
||||
> f: G<H>
|
||||
^^
|
||||
source.tsx
|
||||
^
|
||||
source.tsx variable.other.readwrite.tsx
|
||||
^^
|
||||
source.tsx
|
||||
^
|
||||
source.tsx variable.other.constant.tsx
|
||||
^
|
||||
source.tsx keyword.operator.relational.tsx
|
||||
^
|
||||
source.tsx variable.other.constant.tsx
|
||||
^
|
||||
source.tsx keyword.operator.relational.tsx
|
||||
^^
|
||||
source.tsx
|
||||
>) => {
|
||||
^
|
||||
source.tsx meta.brace.round.tsx
|
||||
^
|
||||
source.tsx
|
||||
^^
|
||||
source.tsx meta.arrow.tsx storage.type.function.arrow.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx meta.block.tsx punctuation.definition.block.tsx
|
||||
^^
|
||||
source.tsx meta.arrow.tsx meta.block.tsx
|
||||
> console.log(e, f);
|
||||
^^
|
||||
source.tsx meta.arrow.tsx meta.block.tsx
|
||||
^^^^^^^
|
||||
source.tsx meta.arrow.tsx meta.block.tsx meta.function-call.tsx support.class.console.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx meta.block.tsx meta.function-call.tsx punctuation.accessor.tsx
|
||||
^^^
|
||||
source.tsx meta.arrow.tsx meta.block.tsx meta.function-call.tsx support.function.console.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx meta.block.tsx meta.brace.round.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx meta.block.tsx variable.other.readwrite.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx meta.block.tsx punctuation.separator.comma.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx meta.block.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx meta.block.tsx variable.other.readwrite.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx meta.block.tsx meta.brace.round.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx meta.block.tsx punctuation.terminator.statement.tsx
|
||||
^^
|
||||
source.tsx meta.arrow.tsx meta.block.tsx
|
||||
>};
|
||||
^
|
||||
source.tsx meta.arrow.tsx meta.block.tsx punctuation.definition.block.tsx
|
||||
^
|
||||
source.tsx punctuation.terminator.statement.tsx
|
||||
^^
|
||||
source.tsx
|
||||
>
|
||||
^^
|
||||
source.tsx
|
||||
>// After
|
||||
^^
|
||||
source.tsx comment.line.double-slash.tsx punctuation.definition.comment.tsx
|
||||
^^^^^^^^
|
||||
source.tsx comment.line.double-slash.tsx
|
||||
>a = (b: string, c: number) => {
|
||||
^
|
||||
source.tsx entity.name.function.tsx
|
||||
^
|
||||
source.tsx
|
||||
^
|
||||
source.tsx keyword.operator.assignment.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx meta.parameters.tsx punctuation.definition.parameters.begin.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx meta.parameters.tsx variable.parameter.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx meta.parameters.tsx meta.type.annotation.tsx keyword.operator.type.annotation.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx meta.parameters.tsx meta.type.annotation.tsx
|
||||
^^^^^^
|
||||
source.tsx meta.arrow.tsx meta.parameters.tsx meta.type.annotation.tsx support.type.primitive.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx meta.parameters.tsx punctuation.separator.parameter.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx meta.parameters.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx meta.parameters.tsx variable.parameter.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx meta.parameters.tsx meta.type.annotation.tsx keyword.operator.type.annotation.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx meta.parameters.tsx meta.type.annotation.tsx
|
||||
^^^^^^
|
||||
source.tsx meta.arrow.tsx meta.parameters.tsx meta.type.annotation.tsx support.type.primitive.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx meta.parameters.tsx punctuation.definition.parameters.end.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx
|
||||
^^
|
||||
source.tsx meta.arrow.tsx storage.type.function.arrow.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx meta.block.tsx punctuation.definition.block.tsx
|
||||
^^
|
||||
source.tsx meta.arrow.tsx meta.block.tsx
|
||||
> console.log(b, c);
|
||||
^^
|
||||
source.tsx meta.arrow.tsx meta.block.tsx
|
||||
^^^^^^^
|
||||
source.tsx meta.arrow.tsx meta.block.tsx meta.function-call.tsx support.class.console.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx meta.block.tsx meta.function-call.tsx punctuation.accessor.tsx
|
||||
^^^
|
||||
source.tsx meta.arrow.tsx meta.block.tsx meta.function-call.tsx support.function.console.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx meta.block.tsx meta.brace.round.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx meta.block.tsx variable.other.readwrite.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx meta.block.tsx punctuation.separator.comma.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx meta.block.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx meta.block.tsx variable.other.readwrite.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx meta.block.tsx meta.brace.round.tsx
|
||||
^
|
||||
source.tsx meta.arrow.tsx meta.block.tsx punctuation.terminator.statement.tsx
|
||||
^^
|
||||
source.tsx meta.arrow.tsx meta.block.tsx
|
||||
>}
|
||||
^
|
||||
source.tsx meta.arrow.tsx meta.block.tsx punctuation.definition.block.tsx
|
|
@ -0,0 +1,15 @@
|
|||
// Before
|
||||
a = (b: string, c: number) => {
|
||||
console.log(b, c);
|
||||
}
|
||||
|
||||
d = (e: string) => (
|
||||
f: G<H>
|
||||
) => {
|
||||
console.log(e, f);
|
||||
};
|
||||
|
||||
// After
|
||||
a = (b: string, c: number) => {
|
||||
console.log(b, c);
|
||||
}
|
|
@ -6,7 +6,7 @@
|
|||
"main": "test.ts",
|
||||
"scripts": {
|
||||
"pretest": "node ../build/build.js && tsc",
|
||||
"test": "mocha test.js"
|
||||
"test": "mocha --full-trace test.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/chai": "latest",
|
||||
|
|
Загрузка…
Ссылка в новой задаче