File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed
Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change 11const providerRegex = / P r o v i d e r $ / ;
22
3+ function getJSXElementName ( jsx ) {
4+ if ( jsx . openingElement . name . type === 'JSXIdentifier' ) {
5+ // e.g. List
6+ return jsx . openingElement . name . name ;
7+ }
8+ if ( jsx . openingElement . name . type === 'JSXMemberExpression' ) {
9+ // e.g. List.Provider
10+ return `${ jsx . openingElement . name . object . name } .${ jsx . openingElement . name . property . name } ` ;
11+ }
12+ }
13+
314function handleJSX ( context , name , jsx ) {
415 if (
5- ! providerRegex . test ( name ) &&
16+ ! providerRegex . test ( getJSXElementName ( jsx ) ) &&
617 ! jsx . openingElement . attributes . find (
718 ( a ) => a . name ?. name === 'data-component' ,
819 )
Original file line number Diff line number Diff line change @@ -242,8 +242,13 @@ export default forwardRef<HTMLAnchorElement, InternalLinkProps>(
242242);` ;
243243
244244const provider = /* tsx */ `
245- export const MyProvider = () => <Foo />;
245+ export const Test = () => <TestProvider />;
246246` ;
247+
248+ const providerWithDot = /* tsx */ `
249+ export const Test = () => <Test.Provider />;
250+ ` ;
251+
247252const tests = {
248253 'data-component' : {
249254 // Require the actual rule definition
@@ -304,6 +309,9 @@ const tests = {
304309 {
305310 code : provider ,
306311 } ,
312+ {
313+ code : providerWithDot ,
314+ } ,
307315 ] ,
308316 invalid : [
309317 {
You can’t perform that action at this time.
0 commit comments