File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,8 @@ then in your ~/.eslintrc:
22
22
}
23
23
```
24
24
25
+ ` jsx/no-undef ` also accepts a ` varsIgnorePattern ` which can be used to ignore certain undefined patterns (e.g. when using custom web elements).
26
+
25
27
All those rules are defined by default though so you can leave out the ones you agree with.
26
28
27
29
## Thanks
Original file line number Diff line number Diff line change @@ -71,6 +71,12 @@ const markUsedRule = context => {
71
71
*/
72
72
73
73
const noUndefRule = context => {
74
+ const config = context . options [ 0 ] || { }
75
+ const ignored = config . varsIgnorePattern && new RegExp ( config . varsIgnorePattern )
76
+ const isIgnored = ignored
77
+ ? name => ignored . test ( name )
78
+ : ( ) => false
79
+
74
80
return {
75
81
JSXOpeningElement ( node ) {
76
82
var name = node . name
@@ -79,9 +85,9 @@ const noUndefRule = context => {
79
85
const variables = variablesInScope ( context )
80
86
node . attributes . forEach ( attr => {
81
87
if ( attr . type == 'JSXSpreadAttribute' ) return
82
- if ( attr . value == null ) checkDefined ( context , variables , attr . name )
88
+ if ( attr . value == null && ! isIgnored ( attr . name . name ) ) checkDefined ( context , variables , attr . name )
83
89
} )
84
- if ( ! standardTags . has ( name . name ) ) checkDefined ( context , variables , name )
90
+ if ( ! standardTags . has ( name . name ) && ! isIgnored ( name . name ) ) checkDefined ( context , variables , name )
85
91
}
86
92
}
87
93
}
You can’t perform that action at this time.
0 commit comments