@@ -48,15 +48,13 @@ const nativeSourceFileName = "dataSentrySourceFile";
48
48
interface AnnotationOpts {
49
49
native ?: boolean ;
50
50
"annotate-fragments" ?: boolean ;
51
- ignoreComponents ?: IgnoredComponent [ ] ;
51
+ ignoredComponents ?: string [ ] ;
52
52
}
53
53
54
54
interface AnnotationPluginPass extends PluginPass {
55
55
opts : AnnotationOpts ;
56
56
}
57
57
58
- type IgnoredComponent = [ file : string , component : string , element : string ] ;
59
-
60
58
type AnnotationPlugin = PluginObj < AnnotationPluginPass > ;
61
59
62
60
// We must export the plugin as default, otherwise the Babel loader will not be able to resolve it when configured using its string identifier
@@ -78,7 +76,7 @@ export default function componentNameAnnotatePlugin({ types: t }: typeof Babel):
78
76
path . node . id . name ,
79
77
sourceFileNameFromState ( state ) ,
80
78
attributeNamesFromState ( state ) ,
81
- state . opts . ignoreComponents ?? [ ]
79
+ state . opts . ignoredComponents ?? [ ]
82
80
) ;
83
81
} ,
84
82
ArrowFunctionExpression ( path , state ) {
@@ -106,7 +104,7 @@ export default function componentNameAnnotatePlugin({ types: t }: typeof Babel):
106
104
parent . id . name ,
107
105
sourceFileNameFromState ( state ) ,
108
106
attributeNamesFromState ( state ) ,
109
- state . opts . ignoreComponents ?? [ ]
107
+ state . opts . ignoredComponents ?? [ ]
110
108
) ;
111
109
} ,
112
110
ClassDeclaration ( path , state ) {
@@ -120,7 +118,7 @@ export default function componentNameAnnotatePlugin({ types: t }: typeof Babel):
120
118
return ;
121
119
}
122
120
123
- const ignoredComponents = state . opts . ignoreComponents ?? [ ] ;
121
+ const ignoredComponents = state . opts . ignoredComponents ?? [ ] ;
124
122
125
123
render . traverse ( {
126
124
ReturnStatement ( returnStatement ) {
@@ -153,7 +151,7 @@ function functionBodyPushAttributes(
153
151
componentName : string ,
154
152
sourceFileName : string | undefined ,
155
153
attributeNames : string [ ] ,
156
- ignoredComponents : IgnoredComponent [ ]
154
+ ignoredComponents : string [ ]
157
155
) {
158
156
let jsxNode : Babel . NodePath ;
159
157
@@ -249,7 +247,7 @@ function processJSX(
249
247
componentName : string | null ,
250
248
sourceFileName : string | undefined ,
251
249
attributeNames : string [ ] ,
252
- ignoredComponents : IgnoredComponent [ ]
250
+ ignoredComponents : string [ ]
253
251
) {
254
252
if ( ! jsxNode ) {
255
253
return ;
@@ -324,7 +322,7 @@ function applyAttributes(
324
322
componentName : string | null ,
325
323
sourceFileName : string | undefined ,
326
324
attributeNames : string [ ] ,
327
- ignoredComponents : IgnoredComponent [ ]
325
+ ignoredComponents : string [ ]
328
326
) {
329
327
const [ componentAttributeName , elementAttributeName , sourceFileAttributeName ] = attributeNames ;
330
328
@@ -340,10 +338,7 @@ function applyAttributes(
340
338
const elementName = getPathName ( t , openingElement ) ;
341
339
342
340
const isAnIgnoredComponent = ignoredComponents . some (
343
- ( ignoredComponent ) =>
344
- matchesIgnoreRule ( ignoredComponent [ 0 ] , sourceFileName ) &&
345
- matchesIgnoreRule ( ignoredComponent [ 1 ] , componentName ) &&
346
- matchesIgnoreRule ( ignoredComponent [ 2 ] , elementName )
341
+ ( ignoredComponent ) => ignoredComponent === componentName || ignoredComponent === elementName
347
342
) ;
348
343
349
344
// Add a stable attribute for the element name but only for non-DOM names
@@ -501,10 +496,6 @@ function isReactFragment(t: typeof Babel.types, openingElement: Babel.NodePath):
501
496
return false ;
502
497
}
503
498
504
- function matchesIgnoreRule ( rule : string , name : string | undefined | null ) {
505
- return rule === "*" || rule === name ;
506
- }
507
-
508
499
function hasAttributeWithName (
509
500
openingElement : Babel . NodePath < Babel . types . JSXOpeningElement > ,
510
501
name : string | undefined | null
0 commit comments