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

[INFRA] Add a R/JS formater #33

Open
csouchet opened this issue Aug 30, 2021 · 4 comments
Open

[INFRA] Add a R/JS formater #33

csouchet opened this issue Aug 30, 2021 · 4 comments
Labels
chore Build, CI/CD or repository tasks (issues/PR maintenance, environments, ...) hacktoberfest Can be done during the Hacktoberfest

Comments

@csouchet
Copy link
Member

csouchet commented Aug 30, 2021

For now, we have to manage formatting manually. In RStudio, select the file content and then do Ctrl + Shift + A

See this article for general guidelines: https://blog.r-hub.io/2022/03/21/code-style/

For formatting rules

tooling candidates

IDE extension supporting autoformating

@csouchet csouchet added the chore Build, CI/CD or repository tasks (issues/PR maintenance, environments, ...) label Aug 30, 2021
@csouchet csouchet changed the title [FEAT] Add a R/JS formater [INFRA] Add a R/JS formater Aug 30, 2021
@csouchet csouchet added the hacktoberfest Can be done during the Hacktoberfest label Sep 22, 2021
@ColinFay
Copy link
Contributor

ColinFay commented Oct 12, 2022

For {golem}, we have the following formatter grkstyle::grk_style_transformer()

I suggest all {golem} contributor to add the following code to their .Rprofile.

# If you work in RStudio
options(styler.addins_style_transformer = "grkstyle::grk_style_transformer()")

# If you work in VSCode
options(languageserver.formatting_style = function(options) {
  grkstyle::grk_style_transformer()
})

This is a piece of my personal .Rprofile that does format the code every time I open VScode :

if (file.exists("~/.Rprofile") { 
	source("~/.Rprofile") 
}

cli::cat_rule("[.Rprofile] Sourcing project-wide RProfile")

options(styler.addins_style_transformer = "grkstyle::grk_style_transformer()")

options(languageserver.formatting_style = function(options) {
  grkstyle::grk_style_transformer()
})


try(
  {
    grkstyle::grk_style_pkg(".")
  },
  silent = TRUE
)

options(styler.cache_root = "styler-perm")

Given that the package is in a folder, you can enforce the formatting with a project Rprofile

@ColinFay
Copy link
Contributor

For the JS, I would suggest minifying too, for example with https://github.com/ColinFay/minifyr (requires nodejs)

@tbouffard
Copy link
Member

@ColinFay thanks for the information, we will review quickly.
I have seen some formatting changes in your PR #117 probably because of the configuration you use. We definitively need to setup shared linting settings for all contributors.

@ColinFay
Copy link
Contributor

Ah, yes, I've turned on "Format on save" in VSCode :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Build, CI/CD or repository tasks (issues/PR maintenance, environments, ...) hacktoberfest Can be done during the Hacktoberfest
Projects
None yet
Development

No branches or pull requests

3 participants