File tree Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -27,3 +27,7 @@ build/Release
27
27
node_modules
28
28
29
29
.idea
30
+
31
+ # OSX
32
+ #
33
+ .DS_Store
Original file line number Diff line number Diff line change @@ -33,14 +33,16 @@ module.exports = (context) => {
33
33
const skippedElements = options . skip ? options . skip : [ ] ;
34
34
const allowedElements = [ 'Text' , 'TSpan' , 'StyledText' ] . concat ( skippedElements ) ;
35
35
36
+ const hasOnlyLineBreak = value => / ^ [ \r \n \t \f \v ] + $ / . test ( value . replace ( / / g, '' ) ) ;
37
+
36
38
const getValidation = node => ! allowedElements . includes ( elementName ( node . parent ) ) ;
37
39
38
40
return {
39
41
Literal ( node ) {
40
42
const parentType = node . parent . type ;
41
43
const onlyFor = [ 'JSXExpressionContainer' , 'JSXElement' ] ;
42
44
if ( typeof node . value !== 'string' ||
43
- / ^ [ \r \n \t \f \v ] + $ / . test ( node . value . replace ( / / g , '' ) ) ||
45
+ hasOnlyLineBreak ( node . value ) ||
44
46
! onlyFor . includes ( parentType ) ||
45
47
( node . parent . parent && node . parent . parent . type === 'JSXAttribute' )
46
48
) return ;
@@ -52,6 +54,7 @@ module.exports = (context) => {
52
54
} ,
53
55
54
56
JSXText ( node ) {
57
+ if ( typeof node . value !== 'string' || hasOnlyLineBreak ( node . value ) ) return ;
55
58
if ( getValidation ( node ) ) {
56
59
report ( node ) ;
57
60
}
You can’t perform that action at this time.
0 commit comments