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

Support different moveToNewFile file name conventions #46514

Open
5 tasks done
bobbyg603 opened this issue Oct 25, 2021 · 9 comments
Open
5 tasks done

Support different moveToNewFile file name conventions #46514

bobbyg603 opened this issue Oct 25, 2021 · 9 comments
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Domain: Refactorings e.g. extract to constant or function, rename symbol In Discussion Not yet reached consensus Suggestion An idea for TypeScript

Comments

@bobbyg603
Copy link

bobbyg603 commented Oct 25, 2021

Suggestion

Support additional file naming conventions when refactoring.

๐Ÿ” Search Terms

moveToNewFile move to file "move to a new file"

โœ… Viability Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

โญ Suggestion

Specify project file naming conventions in tsconfig.json and use the rule here.

๐Ÿ“ƒ Motivating Example

Angular projects use the file name convention some-example.component.ts. The refactor action "Move to a new file" uses the convention SomeNewFile.ts. Ideally, there would be a way to specify the naming convention of the new file. In this case, some-new-file.ts would be the desirable outcome.

๐Ÿ’ป Use Cases

  1. Create a TS interface in the same file where it's being used called SomeExampleInterface
  2. Extract the interface using "Move to a new file" in VS Code
  3. Notice the created file is SomeExampleInterface.ts, which needs to be renamed to some-example-interface.ts to follow project naming conventions
@DanielRosenwasser DanielRosenwasser added Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Domain: Refactorings e.g. extract to constant or function, rename symbol In Discussion Not yet reached consensus Suggestion An idea for TypeScript labels Nov 4, 2021
@rtablada
Copy link

This would be great if it could be supported!

@ImLunaHey
Copy link

To save others time trying to find this issue.

Related: microsoft/vscode#81835

@bobbyg603
Copy link
Author

This issue has been resolved. You can choose an arbitrary file name via "Move to File" then "Enter a new file path".

move-to-file.mov

@BartaG512
Copy link

BartaG512 commented Jan 24, 2024

This issue has been resolved. You can choose an arbitrary file name via "Move to File" then "Enter a new file path".

move-to-file.mov

I would not say it is completed. You need to type in the file name, but the original request was about adding file name conventions, so you can do refactor faster without typing.

@bobbyg603
Copy link
Author

@BartaG512 Allowing the user to specify a file name seems like an elegant and satisfactory way to solve the problem I originally reported. Please feel free to open a new issue if the solution isn't satisfactory for your use case.

@ImLunaHey
Copy link

This should be reopened as this does not fix the issue stated in the OP.

@chad-schwab
Copy link

I always want my filename to be the kebab case version of my function name. The solution as stated is hardly different than Move to new file -> rename. In fact, with autocomplete it's worse, as it's easy to accidentally move to an existing file with a similar name.

@ImLunaHey
Copy link

That's exactly what I'm after @chad-schwab. Since I work a lot with react and want my components to be capitalised in code but kebab case in the file name.

@bobbyg603 bobbyg603 reopened this Jan 30, 2024
@bobbyg603
Copy link
Author

Re-opened, this is no longer an issue for me, but it seems it's still an issue for others. I'll let the company with more resources and time figure out what to do about this ๐Ÿ˜ฎโ€๐Ÿ’จ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Domain: Refactorings e.g. extract to constant or function, rename symbol In Discussion Not yet reached consensus Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

6 participants