This question is about code styling in Nestjs. This framework suggests file naming lowercase letters and across the dot.
Example:
file user.service.ts
export class UserService {
}
another file
import { UserService } from './user.service'
In most cases every file contains one class. I find it convenient to export this class as default and then import the file with the same name
file UserService.ts
export default class UserService {
}
another file
import UserService from './UserService'
Because it is faster and easier.
Could you argue to me why I should not do this? Also I don’t understand why the only entity in a file is not exported as default. Are you comfortable working with file names in Nest JS?
UPD. One more question: If I have a class name consisting of several words. For example "UserRoleService". What should I name this file?
userrole.service.ts
user-role.service.ts
user_role.service.ts
user.role.service.ts
It looks weird and not readable. I think CamelCase would be preferable but here we come back where we started
