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

refactor: Adding ability to convert field name from camelCase to CONSTANT_CASE if varName is not specified for @EnvField #42

Merged
merged 17 commits into from
Nov 10, 2023

Conversation

ryanaidilp
Copy link
Contributor

@ryanaidilp ryanaidilp commented Jul 13, 2023

This pull request adds a new feature to the envied package, allowing the conversion of field names from camelCase to CONSTANT_CASE if the @EnvField annotation is not provided with a specific varName. The motivation behind this enhancement is to adhere to the Effective Dart rules of naming conventions, which specify that variables and field names should start with lowercase letters and use uppercase for the first letter of each subsequent word, such as firstName, secondName, and getAllColors.

With this new functionality, the envied package will automatically transform the field names into CONSTANT_CASE format when the @EnvField annotation is not explicitly assigned a varName. This conversion ensures compliance with the prescribed naming conventions, promoting consistency and readability in the codebase.

The implementation includes logic to detect when the @EnvField annotation is not provided with a varName and applies the necessary transformation to convert the field name from camelCase to CONSTANT_CASE. This feature adds flexibility and convenience to the package, enabling developers to adhere to the recommended naming conventions effortlessly.

This pull request aligns with the goals of the envied package by promoting best practices and making it easier for users to adopt effective coding standards. It contributes to the overall quality and maintainability of projects utilizing the envied package.

Thank you for considering this pull request. I am confident that this feature will enhance the functionality and usability of the envied package, benefiting developers who strive to follow the Effective Dart naming conventions.

@ryanaidilp ryanaidilp changed the title Adding ability to convert field name from camelCase to UPPER_SNAKE_CASE if varName is not specified for @EnvField refactor: Adding ability to convert field name from camelCase to UPPER_SNAKE_CASE if varName is not specified for @EnvField Jul 13, 2023
@techouse
Copy link
Collaborator

techouse commented Nov 5, 2023

Hi @ryanaidilp

Can you please resolve the merge conflicts with the main branch?

@ryanaidilp
Copy link
Contributor Author

Hi @ryanaidilp

Can you please resolve the merge conflicts with the main branch?

Okay, resolving it now.

@techouse
Copy link
Collaborator

techouse commented Nov 9, 2023

Couple of observations:

  1. if this is a breaking change, it should not be a default behaviour but rather enabled by a flag
  2. you might also want to use somehting like recase instead of rolling your own string conversions
import 'package:recase/recase.dart';

final String varName = 'camelCaseVariable'.constantCase; // becomes CAMEL_CASE_VARIABLE

@ryanaidilp
Copy link
Contributor Author

ryanaidilp commented Nov 9, 2023

Couple of observations:

  1. if this is a breaking change, it should not be a default behaviour but rather enabled by a flag
  2. you might also want to use somehting like recase instead of rolling your own string conversions
import 'package:recase/recase.dart';

final String varName = 'camelCaseVariable'.constantCase; // becomes CAMEL_CASE_VARIABLE

Thank you for your feedback! I appreciate your suggestions.

Regarding your first point, I've implemented your advice and added a flag to enable and disable this feature. It's no longer the default behavior.

Additionally, I've integrated the recase package for more robust string conversions.

I've already pushed these changes in my recent commit. Kindly review it, and feel free to let me know if you have any more suggestions or concerns. Your input is valuable to improve the package further.

@petercinibulk
Copy link
Owner

@ryanaidilp Sorry to make you have to handle conflicts again but we just pushed some updates that have conflicts with this PR

@ryanaidilp
Copy link
Contributor Author

@ryanaidilp Sorry to make you have to handle conflicts again but we just pushed some updates that have conflicts with this PR

No worries at all! I've resolved the conflicts in my recent commits. Let me know if there's anything else needed.

@ryanaidilp ryanaidilp changed the title refactor: Adding ability to convert field name from camelCase to UPPER_SNAKE_CASE if varName is not specified for @EnvField refactor: Adding ability to convert field name from camelCase to CONSTANT_CASE if varName is not specified for @EnvField Nov 9, 2023
@techouse
Copy link
Collaborator

techouse commented Nov 9, 2023

No worries at all! I've resolved the conflicts in my recent commits. Let me know if there's anything else needed.

@ryanaidilp We merged #72 into origin/main earlier, so I resolved the merge conflicts for you. Check if everything is in order, please and if you're happy with it we can merge this into origin/main. 😇

@techouse techouse self-assigned this Nov 9, 2023
@techouse techouse added the enhancement New feature or request label Nov 9, 2023
Copy link
Contributor Author

@ryanaidilp ryanaidilp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀. Thanks for the update! Everything looks good to me. Please go ahead and merge it into main. Appreciate your assistance! 😇

@techouse techouse merged commit b4ed8d7 into petercinibulk:main Nov 10, 2023
3 checks passed
This was referenced Nov 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants