File tree Expand file tree Collapse file tree 5 files changed +585
-552
lines changed Expand file tree Collapse file tree 5 files changed +585
-552
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
}
Original file line number Diff line number Diff line change 23
23
"homepage" : " https://github.com/intellicode/eslint-plugin-react-native" ,
24
24
"bugs" : " https://github.com/intellicode/eslint-plugin-react-native/issues" ,
25
25
"devDependencies" : {
26
+ "@typescript-eslint/parser" : " ^1.4.2" ,
26
27
"babel-eslint" : " 7.2.3" ,
27
28
"coveralls" : " ^3.0.2" ,
28
29
"eslint" : " ^5.5.0" ,
31
32
"eslint-plugin-jsx-a11y" : " ^5.1.1" ,
32
33
"eslint-plugin-react" : " ^7.3.0" ,
33
34
"istanbul" : " 0.4.5" ,
34
- "mocha" : " ^5.2.0"
35
+ "mocha" : " ^5.2.0" ,
36
+ "typescript" : " ^3.3.3333"
35
37
},
36
38
"peerDependencies" : {
37
39
"eslint" : " ^3.17.0 || ^4 || ^5"
Original file line number Diff line number Diff line change @@ -171,7 +171,23 @@ const config = {
171
171
} ,
172
172
} ;
173
173
174
+ const TSConfig = {
175
+ parser : '@typescript-eslint/parser' ,
176
+ parserOptions : {
177
+ ecmaVersion : 2018 ,
178
+ sourceType : 'module' ,
179
+ ecmaFeatures : {
180
+ jsx : true ,
181
+ } ,
182
+ } ,
183
+ } ;
184
+
174
185
tests . valid . forEach ( t => Object . assign ( t , config ) ) ;
175
186
tests . invalid . forEach ( t => Object . assign ( t , config ) ) ;
176
187
177
188
ruleTester . run ( 'no-raw-text' , rule , tests ) ;
189
+
190
+ tests . valid . forEach ( t => Object . assign ( t , TSConfig ) ) ;
191
+ tests . invalid . forEach ( t => Object . assign ( t , TSConfig ) ) ;
192
+
193
+ ruleTester . run ( 'no-raw-text' , rule , tests ) ;
You can’t perform that action at this time.
0 commit comments