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

Define default name structure to main file component #36

Closed
ErickRodrCodes opened this issue Jan 24, 2021 · 0 comments · Fixed by #40
Closed

Define default name structure to main file component #36

ErickRodrCodes opened this issue Jan 24, 2021 · 0 comments · Fixed by #40

Comments

@ErickRodrCodes
Copy link

ErickRodrCodes commented Jan 24, 2021

Thank you for reading. As you might know, The resultant component follows the following pattern:

.
└── src
    └── components
        └── MyCustomComponent
            ├── MyCustomComponent.tsx
            ├── MyCustomComponent.test.tsx
            └── MyCustomComponent.module.scss

the resultant code while importing the component suppose more characters:

import MyCustomComponent from "@/components/MyCustomComponent/MyCustomComponent";

Hypotetical ideal Scenario

Leave the Main file as index.tsx rather than the name of the component:

.
└── src
    └── components
        └── MyCustomComponent
            ├── index.tsx
            ├── MyCustomComponent.test.tsx
            └── MyCustomComponent.module.scss

By doing that the import becomes more simpler:

import MyCustomComponent from "@/components/MyCustomComponent";

Editing the text after generating the refactor stills consume time. Ideally, it should not be like that.

By adding an option on the config, you should enable/disable the switch to use the name of the component in the main file, or use the index naming convention:

{
  "usesTypeScript": true,
  "usesCssModule": true,
  "cssPreprocessor": "scss",
  "testLibrary": "Testing Library",
  "component": {
    "default": {
      "customTemplates": {
        "component": "scripts/templates/component.tsx",
        "test": "scripts/templates/test.tsx"
      },
      "path": "src/Components",
      "withStyle": true,
      "withTest": true,
      "withStory": false,
      "withLazy": false,
      "useIndexName:" true // false will use the name of the component
    }
  }
}
@ErickRodrCodes ErickRodrCodes changed the title Define custom name structure to component Define default name structure to main file component Jan 24, 2021
arminbro added a commit that referenced this issue Feb 16, 2021
This feature will allow for adding custom component file types (e.g., withIndex, withwithStoryStyle,
etc.)

#21 #22 #27 #34 #36 #37 #39
@arminbro arminbro linked a pull request Feb 17, 2021 that will close this issue
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

Successfully merging a pull request may close this issue.

1 participant