question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

transform to camelCase, PascalCase and snake_case

See original GitHub issue

Will prettier consider a case transform feature?

example:

  • variable names to camelCase or snake_case
  • object keys names to camelCase or snake_case
  • class names to PascalCase or snake_case
  • class type function names to PascalCase or snake_case

I managed to toy with babylon parser’s AST to see if this was possible and had some success.

There is an eslint issue that was closed because transformations like these are unsafe.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
Rayraegahcommented, Mar 4, 2018

@j-f1 @lipis my use case was quite specific, I did not have conflicts. I used it in the process of transforming python code into javascript code (and pretty printed with prettier)

@bennyn Let me find the script for you. I don’t have one online.

2reactions
k15acommented, Jun 24, 2017

Unfortunately, this is out of scope of Prettier. We are only pretty printing your code but we will never transform the AST because this would change the meaning of your code. You should probably write a codemod or something else if you want to have this functionality.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Case Styles: Camel, Pascal, Snake, and Kebab Case
The commonly used strategies for combining words are: camel case, pascal case, snake case, and kebab case. We'll go over those here.
Read more >
Convert String to Different Case Styles: Snake, Kebab, Camel ...
We will learn 4 different case styles which are: Snake case; Kebab case; Camel case; Pascal case. 1. Snake case.
Read more >
Case Converter - Lower case, Upper Case, Camel ... - Fossbytes
Use this Case Converter tool to convert any written text into different letter cases like lower case, upper case, camel case, sentence case,...
Read more >
Camel Case vs. Snake Case vs. Pascal Case - Khalil Stemmler
Camel case, pascal case, and snake case are the three most common naming conventions in modern programming languages.
Read more >
blakeembrey/change-case: Convert strings between ... - GitHub
Convert strings between camelCase, PascalCase, Capital Case, snake_case and more ... Transform into upper case string with an underscore between words.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found