Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce option to allow remove attributes for any component name #939

Open
vitonsky opened this issue Jan 17, 2024 · 0 comments
Open

Introduce option to allow remove attributes for any component name #939

vitonsky opened this issue Jan 17, 2024 · 0 comments

Comments

@vitonsky
Copy link

vitonsky commented Jan 17, 2024

🚀 Feature Proposal

Introduce any option to allow remove attributes for any component name

Motivation

We use data-testid attributes on the project, to test our components, but we need to remove this attribute for production.
I've found package https://www.npmjs.com/package/@svgr/babel-plugin-remove-jsx-attribute that allow to remove attributes by name, but it requires to provide all components names on the project where attributes must be deleted.

We need to delete specified attributes for any components.

Example

It could be implemented with option in .babelrc like that

{
  "plugins": [
    [
      "@svgr/babel-plugin-remove-jsx-attribute",
      {
        "elements": "all",
        "attributes": ["data-testid"]
      }
    ]
  ]
}

Pitch

Why does this feature belong in the SVGR ecosystem?

Package https://www.npmjs.com/package/@svgr/babel-plugin-remove-jsx-attribute already exists and enough popular. It would be nice to add so small feature, instead of create one more yet package in NPM and do the same work over and over.

To implement this feature we probably need change couple lines in docs and one in code here

if (!t.isJSXIdentifier(path.node.name)) return

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant