@@ -48,15 +48,13 @@ const nativeSourceFileName = "dataSentrySourceFile";
4848interface AnnotationOpts {
4949 native ?: boolean ;
5050 "annotate-fragments" ?: boolean ;
51- ignoreComponents ?: IgnoredComponent [ ] ;
51+ ignoredComponents ?: string [ ] ;
5252}
5353
5454interface AnnotationPluginPass extends PluginPass {
5555 opts : AnnotationOpts ;
5656}
5757
58- type IgnoredComponent = [ file : string , component : string , element : string ] ;
59-
6058type AnnotationPlugin = PluginObj < AnnotationPluginPass > ;
6159
6260// 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):
7876 path . node . id . name ,
7977 sourceFileNameFromState ( state ) ,
8078 attributeNamesFromState ( state ) ,
81- state . opts . ignoreComponents ?? [ ]
79+ state . opts . ignoredComponents ?? [ ]
8280 ) ;
8381 } ,
8482 ArrowFunctionExpression ( path , state ) {
@@ -106,7 +104,7 @@ export default function componentNameAnnotatePlugin({ types: t }: typeof Babel):
106104 parent . id . name ,
107105 sourceFileNameFromState ( state ) ,
108106 attributeNamesFromState ( state ) ,
109- state . opts . ignoreComponents ?? [ ]
107+ state . opts . ignoredComponents ?? [ ]
110108 ) ;
111109 } ,
112110 ClassDeclaration ( path , state ) {
@@ -120,7 +118,7 @@ export default function componentNameAnnotatePlugin({ types: t }: typeof Babel):
120118 return ;
121119 }
122120
123- const ignoredComponents = state . opts . ignoreComponents ?? [ ] ;
121+ const ignoredComponents = state . opts . ignoredComponents ?? [ ] ;
124122
125123 render . traverse ( {
126124 ReturnStatement ( returnStatement ) {
@@ -153,7 +151,7 @@ function functionBodyPushAttributes(
153151 componentName : string ,
154152 sourceFileName : string | undefined ,
155153 attributeNames : string [ ] ,
156- ignoredComponents : IgnoredComponent [ ]
154+ ignoredComponents : string [ ]
157155) {
158156 let jsxNode : Babel . NodePath ;
159157
@@ -249,7 +247,7 @@ function processJSX(
249247 componentName : string | null ,
250248 sourceFileName : string | undefined ,
251249 attributeNames : string [ ] ,
252- ignoredComponents : IgnoredComponent [ ]
250+ ignoredComponents : string [ ]
253251) {
254252 if ( ! jsxNode ) {
255253 return ;
@@ -324,7 +322,7 @@ function applyAttributes(
324322 componentName : string | null ,
325323 sourceFileName : string | undefined ,
326324 attributeNames : string [ ] ,
327- ignoredComponents : IgnoredComponent [ ]
325+ ignoredComponents : string [ ]
328326) {
329327 const [ componentAttributeName , elementAttributeName , sourceFileAttributeName ] = attributeNames ;
330328
@@ -340,10 +338,7 @@ function applyAttributes(
340338 const elementName = getPathName ( t , openingElement ) ;
341339
342340 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
347342 ) ;
348343
349344 // 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):
501496 return false ;
502497}
503498
504- function matchesIgnoreRule ( rule : string , name : string | undefined | null ) {
505- return rule === "*" || rule === name ;
506- }
507-
508499function hasAttributeWithName (
509500 openingElement : Babel . NodePath < Babel . types . JSXOpeningElement > ,
510501 name : string | undefined | null
0 commit comments