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

Add configuration option to generate files with PascalCase instead of the default naming convention #462

Closed
1 task done
bbenoist opened this issue Nov 13, 2019 · 13 comments

Comments

@bbenoist
Copy link

bbenoist commented Nov 13, 2019

I'm submitting a...

  • Feature request

Current behavior

As of now, if I generate a new file with nest g, its is named name.type.ts (e.g. my.module.ts).

I'd like the tool to create a file named NameType.ts (e.g. MyModule.ts) so that it matches the name of the class it contains.

Expected behavior

Ideally, a fileNameCase configuration option in nest-cli.json of type "dot" | "pascal" | "camel" | "snake" | "kebab" would be nice.

Minimal reproduction of the problem with instructions

nest g mo my generates a file named my.module.ts

What is the motivation / use case for changing the behavior?

All of my company source files are named with the same name as the classes that they include. It's a common convention we see in a lot of OOP projects.

@bbenoist
Copy link
Author

Side-demand. It would be nice to also support naming test files with .test.ts instead of .spec.ts via a testFileExtension option too.

@kamilmysliwiec
Copy link
Member

Side-demand. It would be nice to also support naming test files with .test.ts instead of .spec.ts via a testFileExtension option too.

We're tracking this here nestjs/schematics#143

@emilgodsk
Copy link
Contributor

If a fileNameCase is introduced, should it only affect filenames, as suggested by the option name? What about directory names, if you specify that in the generate command, such as nest g controller auth-dir/users_dir/users --no-spec?

Should there also be introduced a directoryNameCase option? or should it just be a nameCase option that affect both files and directories?

Something like https://www.npmjs.com/package/change-case could help implement the solution without having to worry about correct case convertions

@cyrdax
Copy link

cyrdax commented Nov 11, 2020

this would be a very nice addition. having to switch to kabob case is a huge pain for our team

@donnyroufs
Copy link

Is there any news on this?

@oonsamyi
Copy link

Is there any news on this?(

@hydra13
Copy link

hydra13 commented Jan 18, 2022

Is there any news on this? Do you need any help?

@kamilmysliwiec
Copy link
Member

Contributions are more than welcome! @hydra13

@erie0210
Copy link

Hi, is this issue still on going? I need this feature (with camelcase) and want to take a look if it's still valid. @kamilmysliwiec

@bennycode
Copy link

@kamilmysliwiec can you point me to the code which generates the files? I want to try implementing support for file names in PascalCase. 🙂

@micalevisk
Copy link
Member

@bennycode
all templates lives here: https://github.com/nestjs/schematics
and are chosen here: https://github.com/nestjs/nest-cli/blob/master/actions/generate.action.ts

@espoal
Copy link

espoal commented Jul 31, 2023

I started working on a draft PR for this feature. @kamilmysliwiec or @micalevisk I would love some feedback!

@kamilmysliwiec
Copy link
Member

Let's track this here #2208

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