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 a prettier script for ease of use (npm run prettier) #105

Merged

Conversation

justcallmelarry
Copy link
Contributor

I'm not sure if I have things installed incorrectly or something on my machine, but I can't seem to run prettier normally, so I added a script for it locally so that I can just run npm run prettier in order to fix formatting.

I thought I'd share, but feel free to shoot down this PR if this isn't something you want in the repo.

@shynst
Copy link
Contributor

shynst commented Feb 21, 2024

Which IDE / editor are you using?

I am using Visual Studio Code and I like prettier rules to be applied whenever I save a file. So there is no need to remember having to run a script to get formatting right.

If you are using VSCode too, just add these lines to .vscode/settings.json

{
  "[javascript]": {
    "editor.formatOnSave": true
  },
  "[typescript]": {
    "editor.formatOnSave": true
  },
  "[typescriptreact]": {
    "editor.formatOnSave": true
  },
  "[json]": {
    "editor.formatOnSave": true
  },
  "[jsonc]": {
    "editor.formatOnSave": true
  },
  ...
}

@justcallmelarry
Copy link
Contributor Author

Which IDE / editor are you using?

I am using Visual Studio Code and I like prettier rules to be applied whenever I save a file. So there is no need to remember having to run a script to get formatting right.

If you are using VSCode too, just add these lines to .vscode/settings.json

{
  "[javascript]": {
    "editor.formatOnSave": true
  },
  "[typescript]": {
    "editor.formatOnSave": true
  },
  "[typescriptreact]": {
    "editor.formatOnSave": true
  },
  "[json]": {
    "editor.formatOnSave": true
  },
  "[jsonc]": {
    "editor.formatOnSave": true
  },
  ...
}

I do use VSCode generally (and sometimes Sublime) but I prefer not to have these things set globally at least, and I generally don't use format on save as I don't like the code "jumping around" as I type it, as I'm a compulsive saver…

So I prefer to do changes -> see that they work -> format the code -> commit&push as my workflow.

It's nice to have these settings pointed out to others though! Does these settings respect the chosen ESLint/prettier settings for the project even if I have the repo open as a subdir in another project rather than opening the project on it's own in VSCode?

@shynst
Copy link
Contributor

shynst commented Feb 24, 2024

I was like you. Initially I hated tools like prettier messing around with my formatting. After I while I gave up - and now I love it and can't live without it! I write my code without any formatting rules at all, then hit save and watch the code unwrapping. :)

The file .vscode\settings is to be placed under project root, so everything you put in there is a local workspace setting.

Does these settings respect the chosen ESLint/prettier settings for the project even if I have the repo open as a subdir in another project rather than opening the project on it's own in VSCode?

You have to try, I don't know honestly.

@scastiel scastiel merged commit c2b5913 into spliit-app:main Feb 28, 2024
2 checks passed
@justcallmelarry justcallmelarry deleted the feature/add-prettier-npm-script branch February 28, 2024 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants