File tree Expand file tree Collapse file tree 6 files changed +341
-63
lines changed Expand file tree Collapse file tree 6 files changed +341
-63
lines changed Original file line number Diff line number Diff line change @@ -62,6 +62,19 @@ const extractCommentNodes = (node: ts.Node): TxtNode[] => {
62
62
// A list of ts.SyntaxKind that the parsing of comments at the parent node is skipped. Comments should be parsed at the child node.
63
63
const ignoredCommentKinds = [ ts . SyntaxKind . SourceFile ] ;
64
64
65
+ const trimQuotes = ( str : string ) => {
66
+ if ( str . length < 2 ) {
67
+ return str ;
68
+ }
69
+ if ( str [ 0 ] !== `"` && str [ 0 ] !== `'` ) {
70
+ return str ;
71
+ }
72
+ if ( str [ 0 ] !== str [ str . length - 1 ] ) {
73
+ return str ;
74
+ }
75
+ return str . slice ( 1 , - 1 ) ;
76
+ } ;
77
+
65
78
const jsxToAST = ( node : ts . Node ) => {
66
79
const startLineAndCharacter = node
67
80
. getSourceFile ( )
@@ -124,7 +137,7 @@ const jsxToAST = (node: ts.Node) => {
124
137
return {
125
138
...txtPartialNode ,
126
139
type : ASTNodeTypes . Str ,
127
- value : node . getText ( ) ,
140
+ value : trimQuotes ( node . getText ( ) ) ,
128
141
} satisfies TxtTextNode ;
129
142
}
130
143
@@ -158,7 +171,6 @@ class JSXProcessor implements TextlintPluginProcessor {
158
171
ts . ScriptTarget . Latest ,
159
172
true ,
160
173
) ;
161
-
162
174
return jsxToAST ( sourceFile ) as TxtParentNode ;
163
175
} ,
164
176
postProcess ( messages : any [ ] , filePath ?: string ) {
Original file line number Diff line number Diff line change 239
239
}
240
240
},
241
241
"type" : " Str" ,
242
- "value" : " \" str\" "
242
+ "value" : " str"
243
243
}
244
244
]
245
245
}
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ export const Dialog = ( ) => {
2
+ const text = "Hello World" ;
3
+
4
+ // @ts -expect-error
5
+ return < Dialog
6
+ text = { text }
7
+ alt = "Howdy, World"
8
+ /> ;
9
+ } ;
You can’t perform that action at this time.
0 commit comments