Skip to content

jQuery's extend method ($.extend) is treated as a styled component #33

@evankim390

Description

@evankim390

Hi Igor, thanks for creating this package - overall it works great and the code is well written.

I'm trying to use this in my team's project, but I noticed that instances of jQuery's $.extend are treated as styled components and get expanded to $.extend.withConfig. I believe this is due to the isValidComponentName method in createTransformer.ts, which checks eligibility based on whether the first letter of the component name is a capital one. In my case, '$' === '$'.toUpperCase() which is causing the issue. To verify, I changed the isValidComponentName method to return name[0] === name[0].toUpperCase() && name !== "$";, which fixes the problem, but isn't a great solution. This will also be problematic in other popular libraries with a single character namespace like lodash _.extend.

I'm not sure what direction you'd like to take here, but one choice is to have a new option identifierExcludes which takes an array of identifiers to ignore.

createTransformer({
  identifierExcludes: ['$', '_']
});

What are your thoughts? Happy to work with you to get a patch in if you're short on time.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions