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

Opt out of Svg... prefix in component names #250

Closed
mattfelten opened this issue Dec 8, 2018 · 4 comments
Closed

Opt out of Svg... prefix in component names #250

mattfelten opened this issue Dec 8, 2018 · 4 comments

Comments

@mattfelten
Copy link

Looks like in #190 we're adding a prefix to all icons. I'd like to remove that in my project for less overhead of having to remember to prefix it every time we're using an icon. I want the name of the component to be the name of the SVG and if we're using an invalid name, it's on us to change the name of the SVG. How can I do that?

@gregberge
Copy link
Owner

Hello @mattfelten, the name of the component only have an impact for debug. Since it is the default export, you can import it with the name of your choice. That's why there is no option to control it.

@ergenekonyigit
Copy link

hi @gregberge, this is really old issue but i have problem with Svg prefix. Sonar (static code analyzer) see as code smell problem. I can fix with change svg file but this not very convenient fix.
image

@gregberge
Copy link
Owner

Hello @ergenekonyigit, you should make a PR to Sonar. It is not a code smell.

@dheerajsinghnagdali
Copy link

You can use a custom template to opt out of the "Svg" prefix. I would recommend using the following template.

const template = (variables, { tpl }) => { return tpl`
${variables.imports};

${variables.interfaces};

export default function ${
variables.componentName.startsWith("Svg")
? variables.componentName.slice(3)
: variables.componentName
}(${variables.props}) {
return ${variables.jsx};
}
`;
};

module.exports = template;

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

No branches or pull requests

4 participants