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 1
1
const providerRegex = / P r o v i d e r $ / ;
2
2
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
+
3
14
function handleJSX ( context , name , jsx ) {
4
15
if (
5
- ! providerRegex . test ( name ) &&
16
+ ! providerRegex . test ( getJSXElementName ( jsx ) ) &&
6
17
! jsx . openingElement . attributes . find (
7
18
( a ) => a . name ?. name === 'data-component' ,
8
19
)
Original file line number Diff line number Diff line change @@ -242,8 +242,13 @@ export default forwardRef<HTMLAnchorElement, InternalLinkProps>(
242
242
);` ;
243
243
244
244
const provider = /* tsx */ `
245
- export const MyProvider = () => <Foo />;
245
+ export const Test = () => <TestProvider />;
246
246
` ;
247
+
248
+ const providerWithDot = /* tsx */ `
249
+ export const Test = () => <Test.Provider />;
250
+ ` ;
251
+
247
252
const tests = {
248
253
'data-component' : {
249
254
// Require the actual rule definition
@@ -304,6 +309,9 @@ const tests = {
304
309
{
305
310
code : provider ,
306
311
} ,
312
+ {
313
+ code : providerWithDot ,
314
+ } ,
307
315
] ,
308
316
invalid : [
309
317
{
You can’t perform that action at this time.
0 commit comments