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

Opinionated file name casing in svg-to-jsx parser #119

Open
abdavid opened this issue Mar 7, 2022 · 1 comment
Open

Opinionated file name casing in svg-to-jsx parser #119

abdavid opened this issue Mar 7, 2022 · 1 comment
Assignees
Labels
enhancement New feature or request svg-to-jsx

Comments

@abdavid
Copy link

abdavid commented Mar 7, 2022

: `${_.camelCase(token.name)}.${options?.formatConfig?.isTsx ? 'tsx' : 'jsx'}`;

Hi, It would be nice if it would be possible to configure what type of casing that should be used (seen in context with the newly added isTsx option).

An alternative workaround is ofcourse using the name-assets-files-by-pattern parser to enforce casing on the filename, but that would also make the isTsx option dedundant.

Here is my asset configuration for reference and if you have any optimizations or suggestions.

{
            name: "Assets",
            path: "packages/core/assets/icons",
            filter: {
                types: ["vector"]
            },
            parsers: [
                {
                    name: "replace-string",
                    options: {
                        keys: ["name"],
                        regex: {
                            pattern: "\\d+",
                        },
                        trim: true
                    }
                },
                {
                    name: "svgo",
                    options: {
                        svgo: {
                            plugins: [
                                {
                                    removeDimensions: true
                                },
                                {
                                    removeAttrs: {
                                        attrs: "*:(fill|stroke)"
                                    }
                                }
                            ]
                        }
                    }
                },
                {
                    name: "pascalcasify",
                    options: {
                        keys: ["name"]
                    }
                },
                { // this part here I would like to omit, but currently need to enforce casing
                    name: "name-assets-files-by-pattern",
                    options: {
                        pattern: "{{name}}.tsx"
                    }
                },
                {
                    name: "svg-to-jsx",
                    options: {
                        prepend: "import React from 'react';",
                        variableFormat: "pascalCase",
                        //filenameFormat: "pascalCase" <-- my initial suggestion
                        wrapper: {
                            "tag": "div",
                            "className": "rds-icon"
                        },
                        formatConfig: {
                            isTsx: true,
                        }
                    }
                }
            ],
        }

-- David

@AMoreaux
Copy link
Member

AMoreaux commented Mar 7, 2022

Hi @abdavid,

Thanks for your suggestion. It's a good idea, we will add this update to our roadmap.

If it's really important for you, feel free to open a PR. I will be happy to review it 🙂

@AMoreaux AMoreaux added the enhancement New feature or request label Mar 7, 2022
@AMoreaux AMoreaux self-assigned this Mar 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request svg-to-jsx
Projects
None yet
Development

No branches or pull requests

2 participants